validation in current loan : ps

This commit is contained in:
venbatechnologies@gmail.com 2019-01-11 11:24:34 +05:30
parent 1a14a81349
commit fc804356c7
5 changed files with 189 additions and 44 deletions

View File

@ -90,17 +90,26 @@
<mat-expansion-panel class="banlFields" [expanded]="step == i">
<mat-expansion-panel-header>
<mat-panel-title>
<p>{{i+1}} , Banking Details
<p>Banking Details #{{i+1}}
</p>
</mat-panel-title>
</mat-expansion-panel-header>
<mat-form-field>
<mat-select placeholder="Account Name" formControlName="applicant_name" (selectionChange)="selectedBorrower($event.value,i)">
<mat-option value="{{owner.pd_co_applicant_id}}" *ngFor="let owner of applicants">{{owner.applicant_name}}</mat-option>
<mat-select placeholder="Account Name" formControlName="applicant_name" [compareWith]="compareObjects">
<mat-optgroup *ngFor="let group of mergeCompanyApplicant" [label]="group.groupName">
<mat-option *ngFor="let val of group.groupValues" [value]="val">
{{val.name}}
</mat-option>
</mat-optgroup>
</mat-select>
</mat-form-field>
<!-- <mat-form-field *ngIf="itemrow.get('applicant_name').value == 0"> -->
<mat-form-field *ngIf="this.OtherFlag[i]">
<!-- <mat-select placeholder="Account Name" formControlName="applicant_name" (selectionChange)="selectedBorrower($event.value,i)">
<mat-option value="{{owner.pd_co_applicant_id}}" *ngFor="let owner of applicants">{{owner.applicant_name}}</mat-option>
</mat-select> --
!-- <mat-form-field *ngIf="itemrow.get('applicant_name').value == 0"> --
!-- <mat-form-field *ngIf="this.OtherFlag[i]"> -->
<mat-form-field *ngIf="checkOthers(itemrow.get('applicant_name').value)===true" style="width:45%">
<input matInput placeholder="Specify Applicant Name" formControlName="other_applicant" autocomplete="off">
</mat-form-field>

View File

@ -43,6 +43,9 @@ export class BankingDetailsComponent implements OnInit {
amtInwords : any = [];
emiAmtInwords : any = [];
existCompanyList: any =[];
mergeCompanyApplicant: any=[];
constructor(notifier: NotifierService, private fb: FormBuilder, private route: ActivatedRoute,
private router: Router,
private _pd: PdTrigerService,
@ -79,6 +82,30 @@ export class BankingDetailsComponent implements OnInit {
ngOnInit() {
this.step = 0;
this.initBankingForm();
this._pd.getCompaniesListsForBusiness(this.pdid).subscribe(data=>{
if(data.dataStatus){
this.existCompanyList = data.records.filter(val =>val.is_active);
}
let modifyCompanyList : any=[];
if(this.existCompanyList.length>0){
modifyCompanyList = this.existCompanyList.map(element => {
return {id:element.company_order_id.toString(),name:element.company_name,group_id:1};
});
this.mergeCompanyApplicant.push({groupName:'COMPANIES',groupValues:modifyCompanyList})
}
let modifyApplicantList: any=[];
if(this.applicants.length > 0){
modifyApplicantList = this.applicants.map(element => {
return {id:element.pd_co_applicant_id,name:element.applicant_name,group_id:2};
});
this.mergeCompanyApplicant.push({groupName:'APPLICANTS',groupValues:modifyApplicantList})
}
})
this.getM_AccountType();
this.getM_BTLenderList();
@ -89,6 +116,7 @@ export class BankingDetailsComponent implements OnInit {
// // console.log(this.pd_cus_segment);
// this.pd_cus_segment = this.pd_cus_segment.substring(0,3);
// this.applicants = this.pd_all_details.pdapplicants_detials;
let params: any = {};
params.pd_id = this.pdid;
params.pd_form_id = '7';
@ -105,7 +133,7 @@ export class BankingDetailsComponent implements OnInit {
} else {
result.forEach((datas,index) => {
this.amtInwords[index] = this._pd.convertNumberToWords(+datas.limit);
this.selectedBorrower(datas.applicant_name,index);
// this.selectedBorrower(datas.applicant_name,index);
this.selectedAccTypeChanges(+datas.account_type,index)
// this.emiAmtInwords[index] = this._pd.convertNumberToWords(val.emi);
@ -216,13 +244,33 @@ export class BankingDetailsComponent implements OnInit {
});
}
selectedBorrower(e,i){
if(e == 0){
this.OtherFlag[i] = true;
// selectedBorrower(e,i){
// if(e == 0){
// this.OtherFlag[i] = true;
// }
// else{
// this.OtherFlag[i] = false;
// }
// }
// compare objects for merge two master table details
compareObjects(o1: any, o2: any) {
if(o1.id == o2.id && o1.group_id == o2.group_id)
return true;
else return false
}
else{
this.OtherFlag[i] = false;
// check others
checkOthers(values){
if(values!=null) {
return values.id==0 ? true : false;
}
else {
return false;
}
}
selectedAccTypeChanges(event: any,i){

View File

@ -42,16 +42,17 @@
<mat-hint align="start" style="font-size:70%" *ngIf="details.get('loan_amount').value != ''">{{"&#8377;"}} {{amtInwords[i]}} Only</mat-hint>
</mat-form-field>
<mat-form-field>
<mat-select (selectionChange)="selectedfrequency($event.value,i)" placeholder="Frequency"
<mat-select placeholder="Frequency" (selectionChange)="selectedfrequency($event.value,i)"
formControlName="frequency" >
<mat-option *ngFor="let freq of frequencyData" value="{{freq.frequency_id}}">{{freq.name}}</mat-option>
</mat-select>
</mat-form-field>
<mat-form-field *ngIf="details.get('frequency').value == 8">
<mat-form-field *ngIf="details.get('frequency').value == 7">
<input matInput autocomplete="off" placeholder="Specify Frequency" formControlName="other_frequency">
</mat-form-field>
<mat-form-field *ngIf="details.get('frequency').value != ''" style="width:35%">
<input matInput autocomplete="off" [placeholder]="placeholderName[i] != '' ? placeholderName[i] : 'Instalment Amount' " formControlName="emi" (keypress)="keyPress($event)" (keyup)="inWords($event,i,2)">
<!-- <input matInput autocomplete="off" placeholder="details.get('loan_type').value + Instalment Amount " formControlName="emi" (keypress)="keyPress($event)" (keyup)="inWords($event,i,2)"> -->
<mat-hint align="start" style="font-size:70%" *ngIf="details.get('emi').value != ''">{{"&#8377;"}} {{emiAmtInwords[i]}} Only</mat-hint>
</mat-form-field>
<mat-form-field>
@ -64,14 +65,21 @@
<input matInput autocomplete="off" placeholder="Specify Loan Type" formControlName="others_loan_type">
</mat-form-field>
<mat-form-field>
<mat-select placeholder="Loan Taken By" formControlName="loan_taken_by" (selectionChange)="selectedBorrower($event.value,i)">
<!-- <mat-select placeholder="Loan Taken By" formControlName="loan_taken_by" (selectionChange)="selectedBorrower($event.value,i)">
<mat-option value="{{owner.pd_co_applicant_id}}" *ngFor="let owner of applicants">{{owner.applicant_name}}</mat-option>
<!-- <mat-option value= 0 >Others</mat-option> -->
<!-- <mat-option value= 0 >Others</mat-option> ->
</mat-select> -->
<mat-select placeholder="Loan Taken By" formControlName="loan_taken_by" [compareWith]="compareObjects">
<mat-optgroup *ngFor="let group of mergeCompanyApplicant" [label]="group.groupName">
<mat-option *ngFor="let val of group.groupValues" [value]="val">
{{val.name}}
</mat-option>
</mat-optgroup>
</mat-select>
</mat-form-field>
<!-- {{details.get('loan_taken_by').value}} -->
<!-- <mat-form-field *ngIf="details.get('loan_taken_by').value == 0"> -->
<mat-form-field *ngIf="this.OtherFlag[i]">
<mat-form-field *ngIf="checkOthers(details.get('loan_taken_by').value)===true" style="width:45%">
<input matInput autocomplete="off" placeholder="Specify Borrower" formControlName="others_loan_taken">
</mat-form-field>
<mat-form-field>
@ -87,10 +95,12 @@
</mat-form-field> -->
<div style="width:100%">
<mat-form-field style="width:35%">
<input matInput autocomplete="off" placeholder="Original Tenure in Months" formControlName="original_tenure" >
<input matInput autocomplete="off" placeholder="Original Tenure in Months" formControlName="original_tenure" (change)="checkTenure(details)">
</mat-form-field>
<mat-form-field style="width:35%">
<input matInput autocomplete="off" placeholder="Current Balance Tenure in Months" formControlName="current_balance_tenure" >
<input matInput autocomplete="off" placeholder="Current Balance Tenure in Months" formControlName="current_balance_tenure">
<mat-error>Invalid Balance Tenure.</mat-error>
<!-- //*ngIf="current_balance_tenure.hasError('min')" class="mat-text-warn" -->
</mat-form-field>
</div>
<button type="button" class="mr-1 mb-1 hover-icon" mat-raised-button mat-icon-button matTooltip="Add More Loan Details" matTooltipPosition="above" color="primary" (click)="addLoanDetails()"

View File

@ -22,19 +22,24 @@
color: #fff !important;
background-color: #e00201 !important;
}
.my-mat-hint {
line-height: 1.2em;
transform: translateY(10px);
font-size: 75%;
}
.mat-card-content {
background-color: white;
}
.mat-card-actions {
}
.mat-card-actions {
background-color: white;
}
::ng-deep .cdk-global-overlay-wrapper{
}
::ng-deep .cdk-global-overlay-wrapper{
justify-content: center !important;
}
mat-form-field {
mat-form-field {
margin: 0 2%;
}
$base-card-box-shadow:1.5px 2.6px 24px 0 rgba(0, 35, 136, 0.08) !important;
}
$base-card-box-shadow:1.5px 2.6px 24px 0 rgba(0, 35, 136, 0.08) !important;
$product-bg-color-hover: rgba(103, 58, 183, 0.7);
.p-list-main {
background: white;

View File

@ -48,6 +48,9 @@ export class CurrentLoanComponent implements OnInit {
amtInwords : any = [];
emiAmtInwords : any = [];
existCompanyList: any =[];
mergeCompanyApplicant: any=[];
constructor(notifier: NotifierService, private fb: FormBuilder, private route: ActivatedRoute,
private router: Router,
private _pd: PdTrigerService,
@ -83,6 +86,30 @@ export class CurrentLoanComponent implements OnInit {
this.getMasterDetails('FREQUENCY',2);
this.getMasterDetails('EXISTINGLOANTYPES',3);
this.initCurrentloanForm();
this._pd.getCompaniesListsForBusiness(this.pdid).subscribe(data=>{
if(data.dataStatus){
this.existCompanyList = data.records.filter(val =>val.is_active);
}
let modifyCompanyList : any=[];
if(this.existCompanyList.length>0){
modifyCompanyList = this.existCompanyList.map(element => {
return {id:element.company_order_id.toString(),name:element.company_name,group_id:1};
});
this.mergeCompanyApplicant.push({groupName:'COMPANIES',groupValues:modifyCompanyList})
}
let modifyApplicantList: any=[];
if(this.applicants.length > 0){
modifyApplicantList = this.applicants.map(element => {
return {id:element.pd_co_applicant_id,name:element.applicant_name,group_id:2};
});
this.mergeCompanyApplicant.push({groupName:'APPLICANTS',groupValues:modifyApplicantList})
}
})
let params: any = {};
params.pd_id = this.pdid;
params.pd_form_id = this.form_id;
@ -118,6 +145,33 @@ export class CurrentLoanComponent implements OnInit {
}
})
}
checkTenure(details){
let originalTenure = details.value.original_tenure;
// alert(originalTenure);
details.controls.current_balance_tenure.setValidators([Validators.required, Validators.max(+originalTenure)]);
details.controls.current_balance_tenure.updateValueAndValidity();
// details.controls.current_balance_tenure.setValidators([Validators.max(+originalTenure)]);
// details.controls.current_balance_tenure.updateValueAndValidity();
// let BalanceTenure = details.value.current_balance_tenure;
// if( originalTenure < BalanceTenure){
// alert('Greater');
// details.controls.current_balance_tenure.setValue('');
// alert('validation setted For');
// details.controls.current_balance_tenure.setValidators([Validators.min(+originalTenure)]);
// details.controls.current_balance_tenure.updateValueAndValidity();
// }
}
// validateNumber(input: AbstractControl) {
// const wordControl = input.get("word");
// if(wordControl.value != null && wordControl.value.length > 4) {
// wordControl.setValidators([Validators.required, Validators.minLength(8)]);
// wordControl.updateValueAndValidity();
// }
// }
public initCurrentloanForm(): void {
this.currentLoanForm = this.fb.group({
existing_loan: [''],
@ -138,26 +192,25 @@ export class CurrentLoanComponent implements OnInit {
arr.removeAt(0);
}
}
selectedBorrower(e,i){
if(e == 0){
this.OtherFlag[i] = true;
}
else{
this.OtherFlag[i] = false;
}
}
// selectedBorrower(e,i){
// if(e == 0){
// this.OtherFlag[i] = true;
// }
// else{
// this.OtherFlag[i] = false;
// }
// }
selectedfrequency(e,i){
switch(+e){
case 1: this.placeholderName[i] = 'Weekly Instalment Amount'; break;
case 2: this.placeholderName[i] = 'Daily Instalment Amount'; break;
case 3: this.placeholderName[i] = 'Annual Instalment Amount'; break;
case 4: this.placeholderName[i] = 'Hourly Instalment Amount'; break;
case 5: this.placeholderName[i] = 'EMI Amount'; break;
case 1: this.placeholderName[i] = 'Monthly Instalment Amount'; break;
case 2: this.placeholderName[i] = 'Annual Instalment Amount'; break;
case 3: this.placeholderName[i] = 'Halfyearly Instalment Amount'; break;
case 4: this.placeholderName[i] = 'Fortnightly Instalment Amount'; break;
case 5: this.placeholderName[i] = 'Daily Instalment Amount'; break;
case 6: this.placeholderName[i] = 'Quarterly Instalment Amount'; break;
case 7: this.placeholderName[i] = 'Halfyearly Instalment Amount'; break;
default : this.placeholderName[i] = ''; break;
default: this.placeholderName[i] = 'Instalment Amount'; break;
}
}
@ -177,6 +230,26 @@ export class CurrentLoanComponent implements OnInit {
current_balance_tenure: [''],
});
}
// compare objects for merge two master table details
compareObjects(o1: any, o2: any) {
if(o1.id == o2.id && o1.group_id == o2.group_id)
return true;
else return false
}
// check others
checkOthers(values){
if(values!=null) {
return values.id==0 ? true : false;
}
else {
return false;
}
}
addLoanDetails() {
const control = <FormArray>this.currentLoanForm.controls['loan_details'];
control.push(this.createLoanDetail());