diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/business-assets-info/business-assets-info.component.html b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/business-assets-info/business-assets-info.component.html index 203ffd89e..8078cc8c1 100755 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/business-assets-info/business-assets-info.component.html +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/business-assets-info/business-assets-info.component.html @@ -1,151 +1,170 @@

-
- {{main_applicant}} ({{lender_applicant_id}}), {{customer_segment_abbr}} - {{subproduct_abbr}}
- {{pageTitle}} -
-
- -
+
+ {{main_applicant}} ({{lender_applicant_id}}), {{customer_segment_abbr}} - {{subproduct_abbr}}
+ {{pageTitle}} +
+
+ +

- - - -
-
- - -

Address Details {{addressLabel | titlecase}}

-
- + + + +
+
+ + + +

Address Details {{addressLabel | titlecase}}

+
+
-
- - - Yes - No - - -
- -
-
- - - - {{yearErrorMessage}} - Year's Required - - - - {{monthErrorMessage}} - Month's Required - -
- - - - Yes - No - - Field Required - - - - - - Remarks Required - - -
+
+ + + Yes + No + + +
-
-
-
-
- - - - Owned - Rented - - +
+
+ + + + {{yearErrorMessage}} + Year's + Required + + + + {{monthErrorMessage}} + + +
- - - {{"₹"}} {{RentAmtInwords2[i]}} Only - Monthly Rent Amount Required - - -
- + + + Yes + No + + Field + Required + - - - - {{"₹"}} {{appxMarketAmtInwords2[i]}} Only - - - - - - - {{val.name}} - - - - Asset Owned by Required - - - + Owned + Rented + + + + + + {{"₹"}} + {{RentAmtInwordsForAddress[i]}} Only + Monthly Rent Amount Required + + + +
+ + + + + + {{"₹"}} + {{appxMarketAmtInwordsForAddress[i]}} Only + + + + + + + {{val.name}} + + + + Asset Owned by Required + + + - - - - - - - - - - Approx Vintage - - - + + + + - - Purchase Year - - - -
- - - -
- - - Yes - No - - -
-
-
-
-
-
- - + + Approx Vintage + + + + + + Purchase Year + + + +
+ + + +
+ + + Yes + No + + +
+
+
+
+
+
+ + - - - - - -
-
- - -

Other Assets Used in Business

-
- -
-
-
- - -
-
- - - {{ asset.name | titlecase }} - - -
- -
- - -
-
-
-
- - - - {{m_address_type.address_type}} - - - - - - - - - -
-
-
-
- -
-
-
-
- - - - {{ vehicle.vehicle_type_name }} - - + +
+
+ + + +

Other Assets Used in Business

+
+
+ +
+
+
+ + +
+
+ + + {{ + asset.name | titlecase }} + + +
+ +
- - - + +
+
+
+
- - - -
-
-
-
- - -
-
-
+ + + + {{m_address_type.address_type}} + + + + + + + + + +
+
+
+
-
- - + +
+
+
+
- -
-
-
-
+ + + {{ + vehicle.vehicle_type_name }} + + - +
+
+
+ +
+ + + + +
+
+
+
+ + - - - -
-
-
-
- - - -
+ +
+
+
+
+ + + +
-
- - - - {{"₹"}} {{AssetValueInwords[s]}} Only - +
- - - {{data.viewValue | titlecase}} - - - - + + + + {{data.viewValue + | titlecase}} + + + + -
+
-
-
-
- -
+
+
+
- - -
- - - - Owned - Rented - - +
- - - - {{"₹"}} {{RentAmtInwords[i]}} Only - Monthly Rent Amount Required - -
+ -
+
+ + + + Owned + Rented + + - - - - {{"₹"}} {{appxMarketAmtInwords[i]}} Only - - - - - - - {{val.name}} - - - - Asset Owned by Required - - - - - - - - - - Approx Vintage - - - + + + {{"₹"}} + {{RentAmtInwords[i]}} Only + Monthly Rent Amount Required + +
- - Purchase Year - - - -
- - -
- - - Yes - No - - -
-
-
- - -
- -
-
- -
- + + + {{"₹"}} + {{appxMarketAmtInwords[i]}} Only + + + + + + + {{val.name}} + + + + Asset Owned by Required + + + + + + + + + + + Approx Vintage + + + + + + Purchase Year + + + +
+ + +
+ + + Yes + No + + +
+
+
+
+ +
+ +
+
+ +
+ - -
-
-
-
-
- - -
-
- - - - - - - - - - -
- - Remarks - - -
-
- - -
-
+ + +
+
+
+ + +
+
+
+
+ + + + + +
+
+ + +
+ + Remarks + + +
+
+ + +
+
-
Loading....
+
Loading....
\ No newline at end of file diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/business-assets-info/business-assets-info.component.ts b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/business-assets-info/business-assets-info.component.ts index f5d168921..6ffb1d997 100755 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/business-assets-info/business-assets-info.component.ts +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/business-assets-info/business-assets-info.component.ts @@ -1,10 +1,10 @@ -import { Component,OnInit,Inject,Input } from '@angular/core'; +import { Component, OnInit, Inject, Input } from '@angular/core'; -import { FormBuilder, FormGroup, Validators, FormArray,} from '@angular/forms'; +import { FormBuilder, FormGroup, Validators, FormArray, } from '@angular/forms'; import { NotifierService } from 'angular-notifier'; -import { MatDialog, MatDialogRef, MAT_DIALOG_DATA} from '@angular/material'; +import { MatDialog, MatDialogRef, MAT_DIALOG_DATA } from '@angular/material'; /** Service */ import { PdTrigerService } from '../../../../../pd-service/pd-triger.service'; @@ -20,145 +20,137 @@ export class BusinessAssetsInfoComponent implements OnInit { lender_applicant_id: any; main_applicant: any; - pageTitle: string ="Assets used for Business"; - pdid:string; - placeholderName : any = 'Was any business activity seen at the Address Type during PD visit?'; - + pageTitle: string = "Assets used for Business"; + pdid: string; + placeholderName: any = 'Was any business activity seen at the Address Type during PD visit?'; + public _businessAssetsQuesFrom: FormGroup; public submitted = false; public m_assets_type = []; public applicants: any; - + // businessEmiAmtFlag : boolean = false; - public m_any_asset_loan_type = [{'value': "yes",'viewValue': "Yes"}, - {'value': "no",'viewValue': "No"}, - ] - appxMarketAmtInwords : any = []; - appxMarketAmtInwords2:any=[]; - // emiAmtInwords : any = []; - // PremiumPaidInwords : any = []; - // SumAssuredInwords: any = []; - // AmtInvestInwords: any = []; - AssetValueInwords: any = []; - - // B_emiAmtInwords: any = []; - RentAmtInwords:any=[]; - RentAmtInwords2:any=[]; + public m_any_asset_loan_type = [{ 'value': "yes", 'viewValue': "Yes" }, + { 'value': "no", 'viewValue': "No" }] + appxMarketAmtInwords: any = []; + appxMarketAmtInwordsForAddress: any = []; + // AssetValueInwords: any = []; + RentAmtInwords: any = []; + RentAmtInwordsForAddress: any = []; public m_propertyType = []; - PropertyOwnedType : any = []; - // public m_investmentType = []; - // public m_freqOfPurchase = []; + PropertyOwnedType: any = []; private notifier: NotifierService; - existCompanyList: any =[]; - mergeCompanyApplicant: any=[]; - currentYear:any=new Date().getFullYear(); - addressLabel : any; + existCompanyList: any = []; + mergeCompanyApplicant: any = []; + currentYear: any = new Date().getFullYear(); + addressLabel: any; public m_address_type = []; public m_vehicle_type = []; + endUserList = []; CustSegAbbr: any; - generalExistBusinessYear:Number; - generalExistBusinessMonth:Number; + generalExistBusinessYear: Number; + generalExistBusinessMonth: Number; yearErrorMessage: any; monthErrorMessage: any; + isOtherOwnerForAddress : boolean = false; + isOtherOwner: boolean = false; public viewerOptions: any = { navbar: false, toolbar: { - zoomIn: 4, - zoomOut: 4, - oneToOne: 4, - reset: 4, - prev: 4, - play: { - show: 4, - size: 'large', - }, - next: 4, - rotateLeft: 4, - rotateRight: 4, - flipHorizontal: 4, - flipVertical: 4, - } + zoomIn: 4, + zoomOut: 4, + oneToOne: 4, + reset: 4, + prev: 4, + play: { + show: 4, + size: 'large', + }, + next: 4, + rotateLeft: 4, + rotateRight: 4, + flipHorizontal: 4, + flipVertical: 4, + } }; company_id: any; constructor( notifier: NotifierService, private _formBuilder: FormBuilder, - private pdTrigerService: PdTrigerService, + private pdTrigerService: PdTrigerService, private dialogRef: MatDialogRef, - @Inject(MAT_DIALOG_DATA) public pd_all_details: any) { - this.pdid = this.pd_all_details.pdmaster_details.pd_id; - this.applicants = this.pd_all_details.pdapplicants_detials; - this.applicants = this.applicants.filter(appt=>appt.applicant_type != 2) - this.applicants.push({'pd_co_applicant_id':'0','applicant_name':'Others'}); - this.company_id =this.pd_all_details.company_id; - this.notifier = notifier; - this.pageTitle = this.pd_all_details.company_name + ' - ' +this.pageTitle ; - this.main_applicant = this.pd_all_details.pdmaster_details.main_applicant; - this.lender_applicant_id = this.pd_all_details.pdmaster_details.lender_applicant_id; - this.subproduct_abbr = this.pd_all_details.pdmaster_details.subproduct_abbr; - this.customer_segment_abbr = this.pd_all_details.pdmaster_details.customer_segment_abbr; - this.generalExistBusinessYear = this.pd_all_details.business_years; - this.generalExistBusinessMonth = this.pd_all_details.business_month; - } - - + @Inject(MAT_DIALOG_DATA) public pd_all_details: any) { + this.pdid = this.pd_all_details.pdmaster_details.pd_id; + this.applicants = this.pd_all_details.pdapplicants_detials; + this.applicants = this.applicants.filter(appt => appt.applicant_type != 2) + this.applicants.push({ 'pd_co_applicant_id': '0', 'applicant_name': 'Others' }); + this.company_id = this.pd_all_details.company_id; + this.notifier = notifier; + this.pageTitle = this.pd_all_details.company_name + ' - ' + this.pageTitle; + this.main_applicant = this.pd_all_details.pdmaster_details.main_applicant; + this.lender_applicant_id = this.pd_all_details.pdmaster_details.lender_applicant_id; + this.subproduct_abbr = this.pd_all_details.pdmaster_details.subproduct_abbr; + this.customer_segment_abbr = this.pd_all_details.pdmaster_details.customer_segment_abbr; + this.generalExistBusinessYear = this.pd_all_details.business_years; + this.generalExistBusinessMonth = this.pd_all_details.business_month; + } + + ngOnInit() { - - // this.pdTrigerService.getTypeofActivityForSuppliedInfoForm(this.pdid,'').subscribe(data => { - // this.businessProfessionName = (data.status == 200) ? data.records.profession_name : '' ; - // }); - this.pdTrigerService.getCompaniesListsForBusiness(this.pdid).subscribe(data=>{ - if(data.dataStatus){ - this.existCompanyList = data.records.filter(val =>val.is_active===true); - } + // this.pdTrigerService.getTypeofActivityForSuppliedInfoForm(this.pdid,'').subscribe(data => { + // this.businessProfessionName = (data.status == 200) ? data.records.profession_name : '' ; + // }); - 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.pdTrigerService.getCompaniesListsForBusiness(this.pdid).subscribe(data => { + if (data.dataStatus) { + this.existCompanyList = data.records.filter(val => val.is_active === true); + } - } - }) - - this.getPdSupplierFormDetails(); - this.getM_Assets_Type(); - this.getM_PropertyType(); - // this.getM_InvestmentType(); - // this.getM_FreqOfPurchase(); - this.getM_Address_Type(); - this.getM_Vehicle_Type(); - - let params: any = {}; - params.pd_id = this.pdid; - params.pd_form_id = '5'; - - this.pdTrigerService.retriveForm(params).subscribe(data => { - if(data.status == 200) { - - - this.addressLabel = ''; - - let selectedAddressType = this.m_address_type.filter(element =>element.address_type_id == data.records.address_type)[0]; - let address = data.records.address; - let addressType = data.records.address_type != 1 ? selectedAddressType.address_type : data.records.address_type_others; - - this.placeholderName = 'Was any business activity seen at the '+addressType+' during PD visit?'; - this.addressLabel = " : "+address+' / '+addressType ; - - } + 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.getPdSupplierFormDetails(); + this.getM_Assets_Type(); + this.getM_PropertyType(); + this.getM_Address_Type(); + this.getM_Vehicle_Type(); + + let params: any = {}; + params.pd_id = this.pdid; + params.pd_form_id = '5'; + + this.pdTrigerService.retriveForm(params).subscribe(data => { + if (data.status == 200) { + + + this.addressLabel = ''; + + let selectedAddressType = this.m_address_type.filter(element => element.address_type_id == data.records.address_type)[0]; + let address = data.records.address; + let addressType = data.records.address_type != 1 ? selectedAddressType.address_type : data.records.address_type_others; + + this.placeholderName = 'Was any business activity seen at the ' + addressType + ' during PD visit?'; + this.addressLabel = " : " + address + ' / ' + addressType; + + } + }); } /** Assets Type For Dropdown List */ @@ -175,7 +167,7 @@ export class BusinessAssetsInfoComponent implements OnInit { } /** Property Type For Dropdown List */ - getM_PropertyType() { + getM_PropertyType() { this.pdTrigerService.getAllMasterDatas('PROPERTIES').subscribe( data => { this.m_propertyType = data.records.filter(data => data.isactive == 1); @@ -215,22 +207,21 @@ export class BusinessAssetsInfoComponent implements OnInit { this.pdTrigerService.getAllMasterDatas('ADDRESSTYPE').subscribe( data => { this.m_address_type = data.records.filter(data => data.isactive == 1); - + // if(this.CustSegAbbr == 'SENP' || this.CustSegAbbr == 'SEP'){ - - + // let index1 = this.m_address_type.map(data => data.address_type).indexOf("Residence"); // this.m_address_type.splice(index1, 1); - + // let index2 = this.m_address_type.map(data => data.address_type).indexOf("Residence cum Office"); // this.m_address_type.splice(index2, 1); - + // } - + }) } - getM_Vehicle_Type(){ + getM_Vehicle_Type() { this.pdTrigerService.getAllMasterDatas('VEHICLETYPE').subscribe( data => { this.m_vehicle_type = data.records.filter(data => data.is_active == 1); @@ -240,7 +231,7 @@ export class BusinessAssetsInfoComponent implements OnInit { //Get Data Based on PDID and FORMID apiLoadFinish: boolean = false; getPdSupplierFormDetails() { - this.pdTrigerService.getPDFormDetailsWithCompanyID(this.pdid, '22',this.company_id).subscribe( + this.pdTrigerService.getPDFormDetailsWithCompanyID(this.pdid, '22', this.company_id).subscribe( data => { if (data) { if (data.dataStatus) { @@ -263,24 +254,24 @@ export class BusinessAssetsInfoComponent implements OnInit { this._businessAssetsQuesFrom = this._formBuilder.group({ pdid: [this.pdid], formid: ['22'], - company_id : [this.company_id], - business_years:[value.business_years], - business_month:[value.business_month], - business_address_availability:[value.business_address_availability], - business_is_pd_visited:[value.business_is_pd_visited], - business_pd_visited_remark:[value.business_pd_visited_remark], + company_id: [this.company_id], + business_years: [value.business_years], + business_month: [value.business_month], + business_address_availability: [value.business_address_availability], + business_is_pd_visited: [value.business_is_pd_visited], + business_pd_visited_remark: [value.business_pd_visited_remark], business_assets_for_address: this._formBuilder.array([]), // business_activity:[value.business_activity], // business_premises_additional_units: this._formBuilder.array([]), - business_assets_details : this._formBuilder.array([]), - business_assets_form_remark:[value.business_assets_form_remark || null] + business_assets_details: this._formBuilder.array([]), + business_assets_form_remark: [value.business_assets_form_remark || null] }); - if(value.business_address_availability == 'yes'){ - this.addBusinessAssetsForAddress(value.business_assets_for_address); + if (value.business_address_availability == 'yes') { + this.addBusinessAssetsForAddress(value.business_assets_for_address); } - else{ + else { const control = this._businessAssetsQuesFrom.controls['business_assets_for_address']; - control.push(this.createBusinessAssetsForAddress()); + control.push(this.createBusinessAssetsForAddress()); } // if(value.business_activity == 'yes'){ // this.addBusinessUnitsWithData(value.business_premises_additional_units); @@ -294,22 +285,22 @@ export class BusinessAssetsInfoComponent implements OnInit { this._businessAssetsQuesFrom = this._formBuilder.group({ pdid: [this.pdid], formid: ['22'], - company_id : [this.company_id], - business_assets_details : this._formBuilder.array([ + company_id: [this.company_id], + business_assets_details: this._formBuilder.array([ this.initBusinessDetails(), ]), - business_years:[''], - business_month:[''], - business_address_availability:[''], + business_years: [''], + business_month: [''], + business_address_availability: [''], // business_activity:[''], - business_is_pd_visited:[''], - business_pd_visited_remark:[''], + business_is_pd_visited: [''], + business_pd_visited_remark: [''], business_assets_for_address: this._formBuilder.array([ - this.createBusinessAssetsForAddress() ]), + this.createBusinessAssetsForAddress()]), // business_premises_additional_units: this._formBuilder.array([ // this.createUnits() // ]), - business_assets_form_remark:[''] + business_assets_form_remark: [''] }); } this.loadDetails = true; @@ -328,71 +319,71 @@ export class BusinessAssetsInfoComponent implements OnInit { business_assets_mode: [''], business_details: this._formBuilder.array([]), business_approximate_market_value: [''], - business_ownership_type:[''], - business_monthly_rented_amt:[''], + business_ownership_type: [''], + business_monthly_rented_amt: [''], business_name_of_the_owner: [''], business_name_of_the_other_owner: [''], business_vintage: [''], - business_purchase_year: ['',Validators.compose([Validators.pattern("[1-9]{1}[0-9]{3}")])], + business_purchase_year: ['', Validators.compose([Validators.pattern("[1-9]{1}[0-9]{3}")])], business_emi: [''], }); } createUnits(): FormGroup { return this._formBuilder.group({ - no_of_additional_units: [''], - premises_type: [''], - premises_type_others: [''], - premises_city: [''], - premises_remarks: [''], - }); - } + no_of_additional_units: [''], + premises_type: [''], + premises_type_others: [''], + premises_city: [''], + premises_remarks: [''], + }); + } - createBusinessAssetsForAddress(): FormGroup { - return this._formBuilder.group({ - business_approximate_market_value: [''], - business_ownership_type:[''], - business_monthly_rented_amt:[''], - business_name_of_the_owner: [''], - business_name_of_the_other_owner: [''], - business_vintage: [''], - business_purchase_year: ['',Validators.compose([Validators.pattern("[1-9]{1}[0-9]{3}")])], - business_emi:[''] - }); - } + createBusinessAssetsForAddress(): FormGroup { + return this._formBuilder.group({ + business_approximate_market_value: [''], + business_ownership_type: [''], + business_monthly_rented_amt: [''], + business_name_of_the_owner: [''], + business_name_of_the_other_owner: [''], + business_vintage: [''], + business_purchase_year: ['', Validators.compose([Validators.pattern("[1-9]{1}[0-9]{3}")])], + business_emi: [''] + }); + } + + + selectedPropertyOwnedType(e, s, i) { - - selectedPropertyOwnedType(e,s,i){ - // const control = (this._businessAssetsQuesFrom.controls['business_assets_details']).at(i).get('business_details') as FormArray ; - if(e == "owned"){ - - this.PropertyOwnedType[i] = true; + if (e == "owned") { + + this.PropertyOwnedType[i] = true; } - else{ - - this.PropertyOwnedType[i] = false; + else { + + this.PropertyOwnedType[i] = false; } } show: boolean; selectedAssetsType(e: any, i: any): void { let val = i; - const arr = (this._businessAssetsQuesFrom.controls['business_assets_details']).at(val).get('business_details') as FormArray; - arr.controls.splice(0); - + const arr = (this._businessAssetsQuesFrom.controls['business_assets_details']).at(val).get('business_details') as FormArray; + arr.controls.splice(0); + switch (e.value) { case '2': { let val = i; - const control = (this._businessAssetsQuesFrom.controls['business_assets_details']).at(val).get('business_details') as FormArray ; + const control = (this._businessAssetsQuesFrom.controls['business_assets_details']).at(val).get('business_details') as FormArray; control.push(this.loadProperty()); break; } case '3': { - const control = (this._businessAssetsQuesFrom.controls['business_assets_details']).at(val).get('business_details') as FormArray ; + const control = (this._businessAssetsQuesFrom.controls['business_assets_details']).at(val).get('business_details') as FormArray; control.push(this.load_Four_Weeler()); break; } case '4': { - const control = (this._businessAssetsQuesFrom.controls['business_assets_details']).at(val).get('business_details') as FormArray ; + const control = (this._businessAssetsQuesFrom.controls['business_assets_details']).at(val).get('business_details') as FormArray; control.push(this.loadEquipmentManufacturingDescription()); break; } @@ -417,7 +408,7 @@ export class BusinessAssetsInfoComponent implements OnInit { // break; // } case '1': { - const control = (this._businessAssetsQuesFrom.controls['business_assets_details']).at(val).get('business_details') as FormArray ; + const control = (this._businessAssetsQuesFrom.controls['business_assets_details']).at(val).get('business_details') as FormArray; control.push(this.otherBusinessAssetsDescription()); break; } @@ -432,7 +423,7 @@ export class BusinessAssetsInfoComponent implements OnInit { return this._formBuilder.group({ property_type: [''], other_property_type: [''], - address_of_the_property:[''] + address_of_the_property: [''] }); } @@ -457,8 +448,8 @@ export class BusinessAssetsInfoComponent implements OnInit { otherBusinessAssetsDescription() { return this._formBuilder.group({ any_other_assets: [''], - any_other_asset_value : [''], - any_other_asset_loan : [''], + // any_other_asset_value: [''], + any_other_asset_loan: [''], }); } @@ -485,8 +476,8 @@ export class BusinessAssetsInfoComponent implements OnInit { load_Four_Weeler() { return this._formBuilder.group({ manufacturer_model_vehicle: [''], - vehicle_type:[''], - other_vehicle_type:[''] + vehicle_type: [''], + other_vehicle_type: [''] }); } @@ -497,11 +488,11 @@ export class BusinessAssetsInfoComponent implements OnInit { // }); // } - loadPropertyWithData(data) { + loadPropertyWithData(data) { return this._formBuilder.group({ property_type: [data.property_type], other_property_type: [data.other_property_type], - address_of_the_property:[data.address_of_the_property], + address_of_the_property: [data.address_of_the_property], //property_type:[''] }); } @@ -527,12 +518,12 @@ export class BusinessAssetsInfoComponent implements OnInit { otherBusinessAssetsDescriptionWithData(data) { return this._formBuilder.group({ any_other_assets: [data.any_other_assets], - any_other_asset_value : [data.any_other_asset_value], - any_other_asset_loan : [data.any_other_asset_loan], + // any_other_asset_value: [data.any_other_asset_value], + any_other_asset_loan: [data.any_other_asset_loan], }); } - + // loadInsuranceDescriptionWithData(data) { // return this._formBuilder.group({ // //insurance_type: [data.insurance_type], @@ -556,8 +547,8 @@ export class BusinessAssetsInfoComponent implements OnInit { load_Four_WeelerWithData(data) { return this._formBuilder.group({ manufacturer_model_vehicle: [data.manufacturer_model_vehicle], - vehicle_type:[data.vehicle_type], - other_vehicle_type:[data.other_vehicle_type] + vehicle_type: [data.vehicle_type], + other_vehicle_type: [data.other_vehicle_type] }); } @@ -567,8 +558,8 @@ export class BusinessAssetsInfoComponent implements OnInit { // }); // } - createUnitswithData(data){ - let formGroup= this._formBuilder.group({ + createUnitswithData(data) { + let formGroup = this._formBuilder.group({ no_of_additional_units: [data.no_of_additional_units], premises_type: [data.premises_type], premises_type_others: [data.premises_type_others], @@ -580,30 +571,30 @@ export class BusinessAssetsInfoComponent implements OnInit { createBusinessAssetsForAddressWithData(data): FormGroup { return this._formBuilder.group({ - business_approximate_market_value: [data.business_approximate_market_value], - business_ownership_type:[data.business_ownership_type], - business_monthly_rented_amt:[data.business_monthly_rented_amt], - business_name_of_the_owner: [data.business_name_of_the_owner], - business_name_of_the_other_owner: [data.business_name_of_the_other_owner], - business_vintage: [data.business_vintage], - business_purchase_year: [data.business_purchase_year,Validators.compose([Validators.pattern("[1-9]{1}[0-9]{3}")])], - business_emi:[data.business_emi] - }); - } + business_approximate_market_value: [data.business_approximate_market_value], + business_ownership_type: [data.business_ownership_type], + business_monthly_rented_amt: [data.business_monthly_rented_amt], + business_name_of_the_owner: [data.business_name_of_the_owner], + business_name_of_the_other_owner: [data.business_name_of_the_other_owner], + business_vintage: [data.business_vintage], + business_purchase_year: [data.business_purchase_year, Validators.compose([Validators.pattern("[1-9]{1}[0-9]{3}")])], + business_emi: [data.business_emi] + }); + } initBusinessDetailsWithdata(data) { - let formGroup= this._formBuilder.group({ + let formGroup = this._formBuilder.group({ business_assets_mode: [data.business_assets_mode], business_details: this._formBuilder.array([]), business_approximate_market_value: [data.business_approximate_market_value], - business_ownership_type : [data.business_ownership_type], - business_monthly_rented_amt:[data.business_monthly_rented_amt], + business_ownership_type: [data.business_ownership_type], + business_monthly_rented_amt: [data.business_monthly_rented_amt], business_name_of_the_owner: [data.business_name_of_the_owner], - business_name_of_the_other_owner:[data.business_name_of_the_other_owner || ''], + business_name_of_the_other_owner: [data.business_name_of_the_other_owner || ''], // relation: [data.relation || ''], - business_vintage: [data. business_vintage], - business_purchase_year: [data. business_purchase_year,Validators.compose([Validators.pattern("[1-9]{1}[0-9]{3}")])], + business_vintage: [data.business_vintage], + business_purchase_year: [data.business_purchase_year, Validators.compose([Validators.pattern("[1-9]{1}[0-9]{3}")])], // purchase_month: [data.purchase_month], business_emi: [data.business_emi || ''], }); @@ -611,59 +602,69 @@ export class BusinessAssetsInfoComponent implements OnInit { } loadDetails: boolean; - addBusinessAssetsForAddress(data){ + addBusinessAssetsForAddress(data) { var result = Object.keys(data).map(function (key) { - return data[key]; + return data[key]; }); if (result.length > 0) { - result.forEach((datas,index) => { - this.RentAmtInwords2[index] = this.pdTrigerService.convertNumberToWords(datas.business_monthly_rented_amt); - this.appxMarketAmtInwords2[index] = this.pdTrigerService.convertNumberToWords(datas.business_approximate_market_value); + result.forEach((datas, index) => { + this.RentAmtInwordsForAddress[index] = this.pdTrigerService.convertNumberToWords(datas.business_monthly_rented_amt); + this.appxMarketAmtInwordsForAddress[index] = this.pdTrigerService.convertNumberToWords(datas.business_approximate_market_value); + let Avaliablity = 1; + // console.log(datas.business_name_of_the_owner); + if(datas.business_name_of_the_owner.length > 0){ + datas.business_name_of_the_owner.forEach(option => { + if(option.id == 0 && option.group_id == 2){ + Avaliablity = option.id; + } + }); + } + this.isOtherOwnerForAddress = Avaliablity == 0 ? true : false; }); - for (let val of result) { - let vals = { - business_approximate_market_value: val.business_approximate_market_value, - business_ownership_type:val.business_ownership_type, - business_monthly_rented_amt:val.business_monthly_rented_amt, - business_name_of_the_owner: val.business_name_of_the_owner, - business_name_of_the_other_owner: val.business_name_of_the_other_owner, - business_vintage: val.business_vintage, - business_purchase_year: val.business_purchase_year, - business_emi:val.business_emi - }; - const control = this._businessAssetsQuesFrom.controls['business_assets_for_address']; - control.push(this.createBusinessAssetsForAddressWithData(vals)); - } - }else{ - const control = this._businessAssetsQuesFrom.controls['business_assets_for_address']; - control.push(this.createBusinessAssetsForAddress()); + for (let val of result) { + let vals = { + business_approximate_market_value: val.business_approximate_market_value, + business_ownership_type: val.business_ownership_type, + business_monthly_rented_amt: val.business_monthly_rented_amt, + business_name_of_the_owner: val.business_name_of_the_owner, + business_name_of_the_other_owner: val.business_name_of_the_other_owner, + business_vintage: val.business_vintage, + business_purchase_year: val.business_purchase_year, + business_emi: val.business_emi + }; + const control = this._businessAssetsQuesFrom.controls['business_assets_for_address']; + control.push(this.createBusinessAssetsForAddressWithData(vals)); + } + } else { + const control = this._businessAssetsQuesFrom.controls['business_assets_for_address']; + control.push(this.createBusinessAssetsForAddress()); } } -// addBusinessUnitsWithData(data){ - -// var result = Object.keys(data).map(function (key) { -// return data[key]; -// }); + // addBusinessUnitsWithData(data){ -// if (result.length > 0) { -// for (let val of result) { -// let vals = { -// no_of_additional_units: val.no_of_additional_units, -// premises_type: val.premises_type, -// premises_type_others: val.premises_type_others, -// premises_city: val.premises_city, -// premises_remarks: val.premises_remarks, -// }; -// const control = this._businessAssetsQuesFrom.controls['business_premises_additional_units']; -// control.push(this.createUnitswithData(vals)); -// } -// }else{ -// const control = this._businessAssetsQuesFrom.controls['business_premises_additional_units']; -// control.push(this.createUnits()); -// } + // var result = Object.keys(data).map(function (key) { + // return data[key]; + // }); -// } + // if (result.length > 0) { + // for (let val of result) { + // let vals = { + // no_of_additional_units: val.no_of_additional_units, + // premises_type: val.premises_type, + // premises_type_others: val.premises_type_others, + // premises_city: val.premises_city, + // premises_remarks: val.premises_remarks, + // }; + // const control = this._businessAssetsQuesFrom.controls['business_premises_additional_units']; + // control.push(this.createUnitswithData(vals)); + // } + // }else{ + // const control = this._businessAssetsQuesFrom.controls['business_premises_additional_units']; + // control.push(this.createUnits()); + // } + + // } addBusinessAssetsDetailsWithData(supp_data) { @@ -672,21 +673,31 @@ export class BusinessAssetsInfoComponent implements OnInit { }); if (result.length > 0) { - result.forEach((datas,index) => { - this.appxMarketAmtInwords[index] = this.pdTrigerService.convertNumberToWords(+datas.business_approximate_market_value); - this.RentAmtInwords[index] = this.pdTrigerService.convertNumberToWords(+datas.business_monthly_rented_amt); + result.forEach((datas, index) => { + this.appxMarketAmtInwords[index] = this.pdTrigerService.convertNumberToWords(+datas.business_approximate_market_value); + this.RentAmtInwords[index] = this.pdTrigerService.convertNumberToWords(+datas.business_monthly_rented_amt); + let Avaliablity = 1; + // console.log(datas.business_name_of_the_owner); + // datas.business_name_of_the_owner.forEach(option => { + // if(option.id == 0 && option.group_id == 2){ + // Avaliablity = option.id; + // } + // }); + this.isOtherOwner = Avaliablity == 0 ? true : false; + // .business_assets_details['controls'] + // this.setRequiredValidation(datas.business_name_of_the_owner, item, 4); }); for (let val of result) { let vals = { business_assets_mode: val.business_assets_mode, business_approximate_market_value: val.business_approximate_market_value, - business_ownership_type:val.business_ownership_type, - business_monthly_rented_amt:val.business_monthly_rented_amt, + business_ownership_type: val.business_ownership_type, + business_monthly_rented_amt: val.business_monthly_rented_amt, business_name_of_the_owner: val.business_name_of_the_owner, business_name_of_the_other_owner: val.business_name_of_the_other_owner, - business_purchase_year: val. business_purchase_year, - business_vintage : val.business_vintage, + business_purchase_year: val.business_purchase_year, + business_vintage: val.business_vintage, business_emi: val.business_emi, }; @@ -699,39 +710,39 @@ export class BusinessAssetsInfoComponent implements OnInit { } setBusinessAssetsDetailsWithData(assets_details_mode: any, datas: any, i: any): void { - + let val = i; let data = datas; - - const arr = (this._businessAssetsQuesFrom.controls['business_assets_details']).at(val).get('business_details') as FormArray ; + + const arr = (this._businessAssetsQuesFrom.controls['business_assets_details']).at(val).get('business_details') as FormArray; arr.controls.splice(0); - + switch (assets_details_mode) { case '2': { - let business_property_datas : any; - data.forEach((datas,i) => { - business_property_datas = { 'property_type':datas.property_type,'other_property_type':datas.other_property_type,'address_of_the_property':datas.address_of_the_property }; + let business_property_datas: any; + data.forEach((datas, i) => { + business_property_datas = { 'property_type': datas.property_type, 'other_property_type': datas.other_property_type, 'address_of_the_property': datas.address_of_the_property }; // this.selectedPropertyOwnedType(datas.properties_ownership_type,i,val); }); - const control = (this._businessAssetsQuesFrom.controls['business_assets_details']).at(val).get('business_details') as FormArray ; + const control = (this._businessAssetsQuesFrom.controls['business_assets_details']).at(val).get('business_details') as FormArray; control.push(this.loadPropertyWithData(business_property_datas)); break; } case '3': { - let business_Four_Weeler_datas : any; - data.forEach((datas,i) => { - business_Four_Weeler_datas = { 'manufacturer_model_vehicle': datas.manufacturer_model_vehicle ,'vehicle_type':datas.vehicle_type,'other_vehicle_type':datas.other_vehicle_type}; + let business_Four_Weeler_datas: any; + data.forEach((datas, i) => { + business_Four_Weeler_datas = { 'manufacturer_model_vehicle': datas.manufacturer_model_vehicle, 'vehicle_type': datas.vehicle_type, 'other_vehicle_type': datas.other_vehicle_type }; }); - const control = (this._businessAssetsQuesFrom.controls['business_assets_details']).at(val).get('business_details') as FormArray ; + const control = (this._businessAssetsQuesFrom.controls['business_assets_details']).at(val).get('business_details') as FormArray; control.push(this.load_Four_WeelerWithData(business_Four_Weeler_datas)); break; } case '4': { - let equipment_manufacturing_description_datas : any; - data.forEach((datas,i) => { - equipment_manufacturing_description_datas= { 'equipment_manufacturing_description': datas.equipment_manufacturing_description }; + let equipment_manufacturing_description_datas: any; + data.forEach((datas, i) => { + equipment_manufacturing_description_datas = { 'equipment_manufacturing_description': datas.equipment_manufacturing_description }; }); - const control = (this._businessAssetsQuesFrom.controls['business_assets_details']).at(val).get('business_details') as FormArray ; + const control = (this._businessAssetsQuesFrom.controls['business_assets_details']).at(val).get('business_details') as FormArray; control.push(this.loadEquipmentManufacturingDescriptionWithData(equipment_manufacturing_description_datas)); break; } @@ -778,16 +789,16 @@ export class BusinessAssetsInfoComponent implements OnInit { // break; // } case '1': { - let array_datas : any; - data.forEach((datas,i) => { - this.AssetValueInwords[i] = this.pdTrigerService.convertNumberToWords(+data.any_other_asset_value); + let array_datas: any; + data.forEach((datas, i) => { + // this.AssetValueInwords[i] = this.pdTrigerService.convertNumberToWords(+data.any_other_asset_value); array_datas = { 'any_other_assets': datas.any_other_assets, - 'any_other_asset_value' : datas.any_other_asset_value, - 'any_other_asset_loan' : datas.any_other_asset_loan, + // 'any_other_asset_value': datas.any_other_asset_value, + 'any_other_asset_loan': datas.any_other_asset_loan, }; }); - const control = (this._businessAssetsQuesFrom.controls['business_assets_details']).at(val).get('business_details') as FormArray ; + const control = (this._businessAssetsQuesFrom.controls['business_assets_details']).at(val).get('business_details') as FormArray; control.push(this.otherBusinessAssetsDescriptionWithData(array_datas)); break; } @@ -799,18 +810,18 @@ export class BusinessAssetsInfoComponent implements OnInit { /** Add More Asset using Flag Both "Other Asset" And "Business Asset" */ addAssetDetails(e) { - - const control = this._businessAssetsQuesFrom.controls['business_assets_details']; - control.push(this.initBusinessDetails()); - + + const control = this._businessAssetsQuesFrom.controls['business_assets_details']; + control.push(this.initBusinessDetails()); + } /** To remove The Added Asset using Flag Both "Other Asset" And "Business Asset" */ removeAssetsDetails(i: number) { - - const control = this._businessAssetsQuesFrom.controls['business_assets_details']; - control.removeAt(i); - + + const control = this._businessAssetsQuesFrom.controls['business_assets_details']; + control.removeAt(i); + } public paymentModeTextBox: number; @@ -825,78 +836,86 @@ export class BusinessAssetsInfoComponent implements OnInit { } // // 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; + 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; - } - - } + // checkOthers(values) { + // if (values != null) { + // return values.id == 0 ? true : false; + // } + // else { + // return false; + // } - checkOthers2(values){ - if(values!=null) { - return values.id==0 ? true : false; - } - else { - return false; - } - - } + // } + + // checkOthers2(values) { + // if (values != null) { + // return values.id == 0 ? true : false; + // } + // else { + // return false; + // } + + // } // calculate vintage and purchase {} - calculateVintagePurchase(value: any, controlKey: any,type: number){ - if(type==1){ + calculateVintagePurchase(value: any, controlKey: any, type: number) { + if (type == 1) { let control: any = this._businessAssetsQuesFrom.controls['business_assets_details']; - control.controls[controlKey].controls['business_purchase_year'].setValue(value!='' ? parseInt(this.currentYear)-parseInt(value) : ''); - } - else if(type==2) { - let control: any = this._businessAssetsQuesFrom.controls['business_assets_details']; - value!='' && value<=this.currentYear ? control.controls[controlKey].controls['business_purchase_year'].setValue(value) : control.controls[controlKey].controls['business_purchase_year'].setValue(''); - value!='' && value<=this.currentYear ? control.controls[controlKey].controls['business_vintage'].setValue(parseInt(this.currentYear)-parseInt(value)) : control.controls[controlKey].controls['business_vintage'].setValue('') + control.controls[controlKey].controls['business_purchase_year'].setValue(value != '' ? parseInt(this.currentYear) - parseInt(value) : ''); } - if(type==3){ + else if (type == 2) { + let control: any = this._businessAssetsQuesFrom.controls['business_assets_details']; + value != '' && value <= this.currentYear ? control.controls[controlKey].controls['business_purchase_year'].setValue(value) : control.controls[controlKey].controls['business_purchase_year'].setValue(''); + value != '' && value <= this.currentYear ? control.controls[controlKey].controls['business_vintage'].setValue(parseInt(this.currentYear) - parseInt(value)) : control.controls[controlKey].controls['business_vintage'].setValue('') + } + if (type == 3) { let control: any = this._businessAssetsQuesFrom.controls['business_assets_for_address']; - control.controls[controlKey].controls['business_purchase_year'].setValue(value!='' ? parseInt(this.currentYear)-parseInt(value) : ''); - } - else if(type==4) { + control.controls[controlKey].controls['business_purchase_year'].setValue(value != '' ? parseInt(this.currentYear) - parseInt(value) : ''); + } + else if (type == 4) { let control: any = this._businessAssetsQuesFrom.controls['business_assets_for_address']; - value!='' && value<=this.currentYear ? control.controls[controlKey].controls['business_purchase_year'].setValue(value) : control.controls[controlKey].controls['business_purchase_year'].setValue(''); - value!='' && value<=this.currentYear ? control.controls[controlKey].controls['business_vintage'].setValue(parseInt(this.currentYear)-parseInt(value)) : control.controls[controlKey].controls['business_vintage'].setValue('') + value != '' && value <= this.currentYear ? control.controls[controlKey].controls['business_purchase_year'].setValue(value) : control.controls[controlKey].controls['business_purchase_year'].setValue(''); + value != '' && value <= this.currentYear ? control.controls[controlKey].controls['business_vintage'].setValue(parseInt(this.currentYear) - parseInt(value)) : control.controls[controlKey].controls['business_vintage'].setValue('') } } /** To Save/Edited Popup Data */ onSubmit() { this.submitted = true; - + // stop here if form is invalid if (this._businessAssetsQuesFrom.invalid) { this.notifier.notify('warning', 'Please Fill All Mandatory Fields.!'); return; } else { var answerFormValues = this._businessAssetsQuesFrom.value; + let dataOwner_name = []; + // console.log('answerFormValues',answerFormValues); + + // this.loanDetailsForm.controls['owner_name'].value.forEach(element => { + // dataOwner_name.push({ owner_name: element }) + // }); + // records.owner_name_group = dataOwner_name; + //To Remove The "Null" With Key also Object.keys(answerFormValues).forEach((key) => (answerFormValues[key] == null) && delete answerFormValues[key]); // Save the data with help of Service this.pdTrigerService.savePDFormDetailsWithID(answerFormValues).subscribe( dataresult => { - if(dataresult.status == 200) { + if (dataresult.status == 200) { this.notifier.notify('success', 'Saved Successfully.'); - setTimeout(() =>{ - this.dialogRef.close(); - },3000); - } - else { - this.notifier.notify('warning', 'Something Wents Wrong Try Again.!'); - } + setTimeout(() => { + this.dialogRef.close(); + }, 3000); + } + else { + this.notifier.notify('warning', 'Something Wents Wrong Try Again.!'); + } }, error => { this.notifier.notify('warning', 'Something Wents Wrong Try Again.!'); }); @@ -909,7 +928,7 @@ export class BusinessAssetsInfoComponent implements OnInit { // arr.controls.splice(0); // this.getPdSupplierFormDetails(); // } - + /** On Key Press Event For Number only Accepting */ keyPress(event: any) { const pattern = /[0-9]/; @@ -920,201 +939,285 @@ export class BusinessAssetsInfoComponent implements OnInit { } } - // ConvertMonthintoYear(e){ - - // let business_year = this._businessAssetsQuesFrom.controls.business_years.value; + // ConvertMonthintoYear(e){ - // let converted_month : number = e%12; - // let converted_year : number = e/12; + // let business_year = this._businessAssetsQuesFrom.controls.business_years.value; - // this._businessAssetsQuesFrom.controls.business_years.setValue(+business_year + +Math.floor(converted_year)); - // this._businessAssetsQuesFrom.controls.business_month.setValue(Math.floor(converted_month)); - - // } + // let converted_month : number = e%12; + // let converted_year : number = e/12; - /** To Convert Month into Year */ - ConvertMonthintoYear(e){ + // this._businessAssetsQuesFrom.controls.business_years.setValue(+business_year + +Math.floor(converted_year)); + // this._businessAssetsQuesFrom.controls.business_month.setValue(Math.floor(converted_month)); - let business_year = this._businessAssetsQuesFrom.controls.business_years.value; - - let converted_month : number = e%12; - let converted_year : number = e/12; - - let Year = +business_year + +Math.floor(converted_year); - - if(Year > this.generalExistBusinessYear){ - this.yearErrorMessage = "Higher than Business Vintage"; - this._businessAssetsQuesFrom.controls.business_years.setValue(''); - this._businessAssetsQuesFrom.controls.business_month.setValue(''); - - } - else{ - if(Year == this.generalExistBusinessYear && +converted_month > this.generalExistBusinessMonth) - { - this.monthErrorMessage = "Higher than Business Vintage"; - this._businessAssetsQuesFrom.controls.business_years.setValue(''); - this._businessAssetsQuesFrom.controls.business_month.setValue(''); - - }else{ - this.monthErrorMessage = ''; - this.yearErrorMessage = ''; - this._businessAssetsQuesFrom.controls.business_years.setValue(+business_year + +Math.floor(converted_year)); - this._businessAssetsQuesFrom.controls.business_month.setValue(Math.floor(converted_month)); - } - } - } - - checkWithExistBusinessYear(e){ - - if(+e > this.generalExistBusinessYear){ - this.yearErrorMessage = "Higher than Business Vintage"; - this._businessAssetsQuesFrom.controls.business_years.setValue(''); - - } - else{ - this.yearErrorMessage = ''; - } - } - - setRequiredValidation(value,item,flag) { - - if(flag == 1){ - if(value == 'yes') - { this._businessAssetsQuesFrom.controls.business_years.setValidators([Validators.required]) ; - this._businessAssetsQuesFrom.controls.business_month.setValidators([Validators.required]) ; - this._businessAssetsQuesFrom.controls.business_address_availability.setValidators([Validators.required]) ; - // this._businessAssetsQuesFrom.controls.business_activity.setValidators([Validators.required]) ; - this._businessAssetsQuesFrom.controls.business_is_pd_visited.setValidators([Validators.required]) ; - this._businessAssetsQuesFrom.controls.business_pd_visited_remark.setValidators([Validators.required]) ; - // this._businessAssetsQuesFrom.controls.business_activity.setValidators([Validators.required]) ; - } - else{ - this._businessAssetsQuesFrom.controls.business_years.clearValidators(); - this._businessAssetsQuesFrom.controls.business_month.clearValidators(); - this._businessAssetsQuesFrom.controls.business_address_availability.clearValidators(); - // this._businessAssetsQuesFrom.controls.business_activity.clearValidators(); - this._businessAssetsQuesFrom.controls.business_is_pd_visited.clearValidators(); - this._businessAssetsQuesFrom.controls.business_pd_visited_remark.clearValidators(); - // this._businessAssetsQuesFrom.controls.business_activity.clearValidators(); - } - this._businessAssetsQuesFrom.controls.business_years.updateValueAndValidity(); - this._businessAssetsQuesFrom.controls.business_month.updateValueAndValidity(); - this._businessAssetsQuesFrom.controls.business_address_availability.updateValueAndValidity(); - // this._businessAssetsQuesFrom.controls.business_activity.updateValueAndValidity(); - this._businessAssetsQuesFrom.controls.business_is_pd_visited.updateValueAndValidity(); - this._businessAssetsQuesFrom.controls.business_pd_visited_remark.updateValueAndValidity(); - // this._businessAssetsQuesFrom.controls.business_activity.updateValueAndValidity(); - - - } - // if(flag == 2){ - // value==1 - // ? item.controls.premises_type_others.setValidators([Validators.required]) - // : item.controls.premises_type_others.clearValidators(); - // item.controls.premises_type_others.updateValueAndValidity(); // } - if(flag == 3){ - if(value == 'owned'){ - item.controls.business_monthly_rented_amt.clearValidators(); + + /** To Convert Month into Year */ + ConvertMonthintoYear(e) { + + let business_year = this._businessAssetsQuesFrom.controls.business_years.value; + + let converted_month: number = e % 12; + let converted_year: number = e / 12; + + let Year = +business_year + +Math.floor(converted_year); + + if (Year > this.generalExistBusinessYear) { + this.yearErrorMessage = "Higher than Business Vintage"; + this._businessAssetsQuesFrom.controls.business_years.setValue(''); + this._businessAssetsQuesFrom.controls.business_month.setValue(''); + + } + else { + if (Year == this.generalExistBusinessYear && +converted_month > this.generalExistBusinessMonth) { + this.monthErrorMessage = "Higher than Business Vintage"; + this._businessAssetsQuesFrom.controls.business_years.setValue(''); + this._businessAssetsQuesFrom.controls.business_month.setValue(''); + + } else { + this.monthErrorMessage = ''; + this.yearErrorMessage = ''; + this._businessAssetsQuesFrom.controls.business_years.setValue(+business_year + +Math.floor(converted_year)); + this._businessAssetsQuesFrom.controls.business_month.setValue(Math.floor(converted_month)); + } + } + } + + checkWithExistBusinessYear(e) { + + if (+e > this.generalExistBusinessYear) { + this.yearErrorMessage = "Higher than Business Vintage"; + this._businessAssetsQuesFrom.controls.business_years.setValue(''); + + } + else { + this.yearErrorMessage = ''; + } + } + + setRequiredValidation(value, item, flag) { + + if (flag == 1) { + if (value == 'yes') { + this._businessAssetsQuesFrom.controls.business_years.setValidators([Validators.required]); + + this._businessAssetsQuesFrom.controls.business_address_availability.setValidators([Validators.required]); + // this._businessAssetsQuesFrom.controls.business_activity.setValidators([Validators.required]) ; + this._businessAssetsQuesFrom.controls.business_is_pd_visited.setValidators([Validators.required]); + this._businessAssetsQuesFrom.controls.business_pd_visited_remark.setValidators([Validators.required]); + // this._businessAssetsQuesFrom.controls.business_activity.setValidators([Validators.required]) ; + } + else { + this._businessAssetsQuesFrom.controls.business_years.clearValidators(); + + this._businessAssetsQuesFrom.controls.business_address_availability.clearValidators(); + // this._businessAssetsQuesFrom.controls.business_activity.clearValidators(); + this._businessAssetsQuesFrom.controls.business_is_pd_visited.clearValidators(); + this._businessAssetsQuesFrom.controls.business_pd_visited_remark.clearValidators(); + // this._businessAssetsQuesFrom.controls.business_activity.clearValidators(); + } + this._businessAssetsQuesFrom.controls.business_years.updateValueAndValidity(); + + this._businessAssetsQuesFrom.controls.business_address_availability.updateValueAndValidity(); + // this._businessAssetsQuesFrom.controls.business_activity.updateValueAndValidity(); + this._businessAssetsQuesFrom.controls.business_is_pd_visited.updateValueAndValidity(); + this._businessAssetsQuesFrom.controls.business_pd_visited_remark.updateValueAndValidity(); + // this._businessAssetsQuesFrom.controls.business_activity.updateValueAndValidity(); + + + } + // if(flag == 2){ + // value==1 + // ? item.controls.premises_type_others.setValidators([Validators.required]) + // : item.controls.premises_type_others.clearValidators(); + // item.controls.premises_type_others.updateValueAndValidity(); + // } + if (flag == 3) { + if (value == 'owned') { + item.controls.business_monthly_rented_amt.clearValidators(); item.controls.business_name_of_the_owner.setValidators([Validators.required]); } - else{ + else { item.controls.business_monthly_rented_amt.setValidators([Validators.required]); - item.controls.business_name_of_the_owner.clearValidators(); + item.controls.business_name_of_the_owner.clearValidators(); } - item.controls.business_monthly_rented_amt.updateValueAndValidity(); - item.controls.business_name_of_the_owner.updateValueAndValidity(); - } - if(flag == 4){ - value==0 - ? item.controls.business_name_of_the_other_owner.setValidators([Validators.required]) - : item.controls.business_name_of_the_other_owner.clearValidators(); - item.controls.business_name_of_the_other_owner.updateValueAndValidity(); - } - if(flag == 5){ - value==1 - ? item.controls.other_vehicle_type.setValidators([Validators.required]) - : item.controls.other_vehicle_type.clearValidators(); - item.controls.other_vehicle_type.updateValueAndValidity(); - } - if(flag == 6){ - value==1 - ? item.controls.other_property_type.setValidators([Validators.required]) - : item.controls.other_property_type.clearValidators(); - item.controls.other_property_type.updateValueAndValidity(); - } - if(flag == 7){ - if(value == 'owned'){ - item.controls.business_monthly_rented_amt.clearValidators(); - item.controls.business_name_of_the_owner.setValidators([Validators.required]); + item.controls.business_monthly_rented_amt.updateValueAndValidity(); + item.controls.business_name_of_the_owner.updateValueAndValidity(); } - else{ - item.controls.business_monthly_rented_amt.setValidators([Validators.required]); - item.controls.business_name_of_the_owner.clearValidators(); + if (flag == 4) { + let Avaliablity = 1; + value.forEach(option => { + if(option.id == 0 && option.group_id == 2){ + Avaliablity = option.id; + } + }); + if(Avaliablity == 0){ + + item.controls.business_name_of_the_other_owner.setValidators([Validators.required]); + this.isOtherOwner = true; + }else{ + + item.controls.business_name_of_the_other_owner.setValue(''); + item.controls.business_name_of_the_other_owner.clearValidators(); + this.isOtherOwner = false; + } + + item.controls.business_name_of_the_other_owner.updateValueAndValidity(); + + // value == 0 + // ? item.controls.business_name_of_the_other_owner.setValidators([Validators.required]) + // : item.controls.business_name_of_the_other_owner.clearValidators(); + // item.controls.business_name_of_the_other_owner.updateValueAndValidity(); } - item.controls.business_monthly_rented_amt.updateValueAndValidity(); - item.controls.business_name_of_the_owner.updateValueAndValidity(); -} -if(flag == 8){ - value==0 - ? item.controls.business_name_of_the_other_owner.setValidators([Validators.required]) - : item.controls.business_name_of_the_other_owner.clearValidators(); - item.controls.business_name_of_the_other_owner.updateValueAndValidity(); -} - + if (flag == 5) { + value == 1 + ? item.controls.other_vehicle_type.setValidators([Validators.required]) + : item.controls.other_vehicle_type.clearValidators(); + item.controls.other_vehicle_type.updateValueAndValidity(); + } + if (flag == 6) { + value == 1 + ? item.controls.other_property_type.setValidators([Validators.required]) + : item.controls.other_property_type.clearValidators(); + item.controls.other_property_type.updateValueAndValidity(); + + value != '' + ? item.controls.address_of_the_property.setValidators([Validators.required]) + : item.controls.address_of_the_property.clearValidators(); + item.controls.address_of_the_property.updateValueAndValidity(); + } + if (flag == 7) { + if (value == 'owned') { + item.controls.business_monthly_rented_amt.clearValidators(); + item.controls.business_name_of_the_owner.setValidators([Validators.required]); + } + else { + item.controls.business_monthly_rented_amt.setValidators([Validators.required]); + item.controls.business_name_of_the_owner.clearValidators(); + } + item.controls.business_monthly_rented_amt.updateValueAndValidity(); + item.controls.business_name_of_the_owner.updateValueAndValidity(); + } + if(flag == 8){ + let Avaliablity = 1; + value.forEach(option => { + if(option.id == 0 && option.group_id == 2){ + // console.log('true'); + Avaliablity = option.id; + } + }); + // isOtherOwner: boolean = false; + if(Avaliablity == 0){ + // console.log(Avaliablity); + item.controls.business_name_of_the_other_owner.setValidators([Validators.required]); + this.isOtherOwnerForAddress = true; + }else{ + // console.log(Avaliablity); + item.controls.business_name_of_the_other_owner.setValue(''); + item.controls.business_name_of_the_other_owner.clearValidators(); + this.isOtherOwnerForAddress = false; + } + + item.controls.business_name_of_the_other_owner.updateValueAndValidity(); + } - // addUnits() { - // const control = this._businessAssetsQuesFrom.controls['business_premises_additional_units']; - // control.push(this.createUnits()); - // } + } - // removeUnits(index) { - // const control = this._businessAssetsQuesFrom.controls['business_premises_additional_units']; - // control.removeAt(index); - // } +// endUserChange(event) { + +// this.endUserList = []; +// - selectedAddressType(e: any){ - this.placeholderName = 'Was any business activity seen at the '+e+' during PD visit?'; - } +// event.forEach(option => { +// // let othersData = this.m_endUseofLoad.filter(sub=>sub.subproduct_id==option)[0]; +// let othersData = this.m_endUseForLoan.filter(sub => sub.enduse_of_loan_id == option)[0]; + +// OthersAvaliable = othersData.enduse_of_loan.substr(0, 6).toLowerCase(); + +// this.endUserList.push({ end_use: option }); +// }); + +// if (OthersAvaliable == 'others') { +// this.isOtherPurpose = true; +// this.loanDetailsForm.controls['end_use_other'].setValidators([Validators.required]); + +// } else { +// this.loanDetailsForm.controls['end_use_other'].clearValidators(); +// this.isOtherPurpose = false; +// } +// this.loanDetailsForm.controls['end_use_other'].updateValueAndValidity(); +// //this.isOtherPurpose = event.some(e => e == 'others') // this return true or false Only; +// } + + // addUnits() { + // const control = this._businessAssetsQuesFrom.controls['business_premises_additional_units']; + // control.push(this.createUnits()); + // } + + // removeUnits(index) { + // const control = this._businessAssetsQuesFrom.controls['business_premises_additional_units']; + // control.removeAt(index); + // } + + selectedAddressType(e: any) { + this.placeholderName = 'Was any business activity seen at the ' + e + ' during PD visit?'; + } /** Amount InWords */ - inWords(e,i,flag){ - switch(flag){ - case 1 : + inWords(e, i, flag) { + switch (flag) { + case 1: this.appxMarketAmtInwords[i] = this.pdTrigerService.convertNumberToWords(e.target.value); break; - // case 2 : - // this.PremiumPaidInwords[i] = this.pdTrigerService.convertNumberToWords(e.target.value); - // break; - // case 3 : - // this.emiAmtInwords[i] = this.pdTrigerService.convertNumberToWords(e.target.value); - // break; - // case 4 : - // this.SumAssuredInwords[i] = this.pdTrigerService.convertNumberToWords(e.target.value); - // break; - // case 5 : - // this.AmtInvestInwords[i] = this.pdTrigerService.convertNumberToWords(e.target.value); - // break; - case 6 : - this.AssetValueInwords[i] = this.pdTrigerService.convertNumberToWords(e.target.value); - break; - // case 7 : - // this.B_emiAmtInwords[i] = this.pdTrigerService.convertNumberToWords(e.target.value); - // break; - case 8: + // case 2 : + // this.PremiumPaidInwords[i] = this.pdTrigerService.convertNumberToWords(e.target.value); + // break; + // case 3 : + // this.emiAmtInwords[i] = this.pdTrigerService.convertNumberToWords(e.target.value); + // break; + // case 4 : + // this.SumAssuredInwords[i] = this.pdTrigerService.convertNumberToWords(e.target.value); + // break; + // case 5 : + // this.AmtInvestInwords[i] = this.pdTrigerService.convertNumberToWords(e.target.value); + // break; + // case 6: + // this.AssetValueInwords[i] = this.pdTrigerService.convertNumberToWords(e.target.value); + // break; + // case 7 : + // this.B_emiAmtInwords[i] = this.pdTrigerService.convertNumberToWords(e.target.value); + // break; + case 8: this.RentAmtInwords[i] = this.pdTrigerService.convertNumberToWords(e.target.value); break; - case 9: - this.RentAmtInwords2[i] = this.pdTrigerService.convertNumberToWords(e.target.value); + case 9: + this.RentAmtInwordsForAddress[i] = this.pdTrigerService.convertNumberToWords(e.target.value); break; - case 10: - this.appxMarketAmtInwords2[i] = this.pdTrigerService.convertNumberToWords(e.target.value); + case 10: + this.appxMarketAmtInwordsForAddress[i] = this.pdTrigerService.convertNumberToWords(e.target.value); break; - default: + default: break; } -} + } } +// let ownername: any = []; +// if (value.records.owner_name_group != null) { +// let owner = Object.keys(value.records.owner_name_group).map(function (key) { +// return value.records.owner_name_group[key]; +// }); + + +// owner.forEach(val => { +// ownername.push(val.business_name_of_the_owner); +// if (val.business_name_of_the_owner == 'Others') { +// this.OtherOwnerFlag = true; +// } +// else { +// this.OtherOwnerFlag = false; +// } +// }); +// } +// this.loanDetailsForm.controls['business_name_of_the_owner'].setValue(owner); \ No newline at end of file diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/business-banking-details/business-banking-details.component.ts b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/business-banking-details/business-banking-details.component.ts index d8ad9a234..4206e8787 100755 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/business-banking-details/business-banking-details.component.ts +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/business-banking-details/business-banking-details.component.ts @@ -97,7 +97,7 @@ export class BusinessBankingDetailsComponent implements OnInit { this.initBankingForm(); this._pd.getCompaniesListsForBusiness(this.pdid).subscribe(data=>{ if(data.dataStatus){ - this.existCompanyList = data.records.filter(val =>val.is_active===true && val.is_company_applicant===true && val.company_order_id==this.company_id); + this.existCompanyList = data.records.filter(val =>val.is_active===true);/* && val.is_company_applicant===true && val.company_order_id==this.company_id */ } let modifyCompanyList : any=[]; diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/business-info/business-info.component.ts b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/business-info/business-info.component.ts index 77485766e..b54ee3b53 100755 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/business-info/business-info.component.ts +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/business-info/business-info.component.ts @@ -647,17 +647,17 @@ export class BusinessInfoComponent implements OnInit { // businees activity type change event changeBusinessActivity(event: any){ - // console.log('changeBusinessActivity'); + if(event.value.exist_status==true && event.value.type_of_activity_id==2){ - // console.log('changeBusinessActivity 1'); + this.ManufacturingChecked = event.value.exist_status; let manufacturingControl = this.businessForm.controls['manufacturing_activity_details']; manufacturingControl.controls = []; manufacturingControl.setValue([]); } else if(event.value.exist_status==false && event.value.type_of_activity_id==2){ - // console.log('changeBusinessActivity 2'); + this.ManufacturingChecked = event.value.exist_status; let manufacturingControl = this.businessForm.controls['manufacturing_activity_details']; manufacturingControl.push(this.createActivity()); @@ -665,40 +665,40 @@ export class BusinessInfoComponent implements OnInit { } if(event.value.exist_status==true && event.value.type_of_activity_id==3){ - // console.log('changeBusinessActivity 3'); + this.RetailedChecked = event.value.exist_status; let retailControl = this.businessForm.controls['retail_trading_activity_details']; retailControl.controls = []; retailControl.setValue([]); } else if(event.value.exist_status==false && event.value.type_of_activity_id==3){ - // console.log('changeBusinessActivity 4'); + this.RetailedChecked = event.value.exist_status; let retailControl = this.businessForm.controls['retail_trading_activity_details']; retailControl.push(this.createActivity()); } if(event.value.exist_status==true && event.value.type_of_activity_id==4){ - // console.log('changeBusinessActivity 5'); + this.WholeSalesChecked = event.value.exist_status; let wholesaleControl = this.businessForm.controls['wholesale_trading_activity_details']; wholesaleControl.controls = []; wholesaleControl.setValue([]); } else if(event.value.exist_status==false && event.value.type_of_activity_id==4){ - // console.log('changeBusinessActivity 6'); + this.WholeSalesChecked = event.value.exist_status; let wholesaleControl = this.businessForm.controls['wholesale_trading_activity_details']; wholesaleControl.push(this.createActivity()); } if(event.value.exist_status==true && event.value.type_of_activity_id==5){ - // console.log('changeBusinessActivity 7'); + this.ServiceChecked = event.value.exist_status; let serviceControl = this.businessForm.controls['service_provider_activity_details']; serviceControl.controls = []; serviceControl.setValue([]); } else if(event.value.exist_status==false && event.value.type_of_activity_id==5){ - // console.log('changeBusinessActivity 8'); + this.ServiceChecked = event.value.exist_status; let serviceControl = this.businessForm.controls['service_provider_activity_details']; serviceControl.push(this.createServiceActivity()); @@ -1157,9 +1157,7 @@ export class BusinessInfoComponent implements OnInit { this.businessEntityTypeList.business_entity_type_name = filterList[0].business_entity_type_id!=1 ? filterList[0].business_entity_type_name : this.generalExistEntityType_other; this.businessEntityTypeList.section_label = filterList[0].business_entity_type_id!=1 ? filterList[0].section_label : this.generalExistEntityType_other; - // console.log(this.businessEntityTypeList.business_entity_type_id+' , '+this.businessEntityTypeList.business_entity_type_name+' , '+this.businessEntityTypeList.section_label); - // console.log(this.businessForm.controls.partners['controls']); - // console.log(this.businessForm.controls.partners['controls'].length); + // if(this.businessForm.controls.partners['controls'].length > 1) // { // console.log('asd'); @@ -1317,9 +1315,7 @@ export class BusinessInfoComponent implements OnInit { // Out of Total Export Sales what % of Sales is done in Albania? getPlaceHolderName(id){ let name = this.countryDataList.filter(value=>value.country_id == id); - // console.log(name); - // console.log(name[0].country_name); - // console.log(id); + return 'Out of Total Export Sales what % of Sales is done in '+ name[0].country_name +' ?'; // return name[0].country_name +'?'; } @@ -1386,20 +1382,11 @@ export class BusinessInfoComponent implements OnInit { /** * This Function For validate For Appx. sale based on Type OF Activities */ - // validateAppxSales(records){ - - // //console.log(records.manufacturing_activity_details.length); - - // //this Variable For Validation - - - // } + // validateAppxSales(records){} submitDetails() { // let family: any = []; - // console.log(this.businessForm.value); - if(this.EntityTypeFlag == true){ let control: any = this.businessForm.controls['partners']; @@ -1441,7 +1428,7 @@ export class BusinessInfoComponent implements OnInit { } // let design: any; let records = this.businessForm.value; - // console.log(records); + //to check the Appx. sale validation. // this.validateAppxSales(records); @@ -1459,8 +1446,8 @@ export class BusinessInfoComponent implements OnInit { let validationFlag : number = 0; // let shareHoldValidationFlag : number = 0; - // console.log(records.partners.length); - // console.log(records.partners); + + if(records.partners.length > 0){ let total = records.partners.map(shares => shares.shareholding).reduce((a, b) => a + +b, 0); @@ -1624,7 +1611,7 @@ export class BusinessInfoComponent implements OnInit { }); let merged = [].concat.apply([], setCityFilter); - // console.log(merged) + if(merged.length>0){ let check: any = merged.filter(function(fVal){ return existCities.some(function(sVal){ @@ -1698,9 +1685,7 @@ export class BusinessInfoComponent implements OnInit { } // flag: number = 0; // CheckExport(e,val){ -// console.log(e); -// console.log(val); -// console.log(this.) + // if(val == 1){ // e != "Within India" ? // this.flag++ :this.flag--; @@ -1746,13 +1731,13 @@ export class BusinessInfoComponent implements OnInit { // // this.counterForExportCart--; // } // // this.ExportFlag = this.counterForExportCart == 1 ? true : false ; -// console.log('this.domesticCounter : ',this.domesticCounter,', this.foreignCounter : ',this.foreignCounter); + // if(this.domesticCounter == 0 && this.foreignCounter == 0){ // this.ExportFlag = false; // }else if(this.foreignCounter >= 0) { // this.ExportFlag = true; // } -// console.log('Cuurent Flag Status : ',this.ExportFlag ); + // } ManufacturingCounterArray: any = []; @@ -1763,23 +1748,20 @@ ServiceCounterArray: any = []; CheckExport(value,stringFlag,index){ const parentControl = this.businessForm.controls['select_business_activity_type']; const childControl = parentControl.controls[0]; - // console.log('parentControl',parentControl); - // console.log('parentControl.controls',parentControl.controls); - // console.log('childControl',childControl.value); - // console.log('childControl',childControl.value.exist_status); + // childControl.forEach((datas,index) => { - // console.log(datas); + // // exist_status==true && event.value.type_of_activity_id - // console.log(datas[index].); - // console.log(datas[index].controls.exist_status.value); + + // }); - // console.log('CheckExport'); - // console.log(value,stringFlag,index); + + - // console.log(this.ManufacturingChecked , this.RetailedChecked , this.WholeSalesChecked , this.ServiceChecked); + if(!this.ManufacturingChecked){ if(stringFlag == 'MActivity' && value != "Within India"){ @@ -1831,20 +1813,19 @@ CheckExport(value,stringFlag,index){ } let SumOfManufacturingCounter = this.ManufacturingCounterArray.reduce((sum, val) => sum + +val, 0); - // console.log(SumOfManufacturingCounter,this.ManufacturingCounterArray); + let SumOfRetailCounter = this.RetailCounterArray.reduce((sum, val) => sum + +val, 0); - // console.log(SumOfRetailCounter , this.RetailCounterArray); + let SumOfWholeSaleCounter = this.WholeSaleCounterArray.reduce((sum, val) => sum + +val, 0); - // console.log(SumOfWholeSaleCounter,this.WholeSaleCounterArray); + let SumOfServiceCounter = this.ServiceCounterArray.reduce((sum, val) => sum + +val, 0); - // console.log(SumOfServiceCounter,this.ServiceCounterArray); + let overallCounter = SumOfManufacturingCounter + SumOfRetailCounter + SumOfWholeSaleCounter + SumOfServiceCounter ; this.ExportFlag = overallCounter > 0 ? true : false ; - // console.log('overallCounter , SumOfManufacturingCounter , SumOfRetailCounter , SumOfWholeSaleCounter , SumOfServiceCounter ' , overallCounter , SumOfManufacturingCounter , SumOfRetailCounter , SumOfWholeSaleCounter , SumOfServiceCounter); - // console.log('Current Flag Status : ',this.ExportFlag ); + } inWords(e,flag){ diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/dialogue/other-applicant-details/other-applicant-details.component.html b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/dialogue/other-applicant-details/other-applicant-details.component.html index 28a3a929b..d3df7802b 100755 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/dialogue/other-applicant-details/other-applicant-details.component.html +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/dialogue/other-applicant-details/other-applicant-details.component.html @@ -1,59 +1,71 @@

-
- {{pageTitle}} -
-
- -
+
+ {{pageTitle}} +
+
+ +

- - - - - - {{tl.name}} - - - - - + + + + + + {{tl.name}} + + + + + - + {{qual.qualification_name}} - - + + - +
-
- Is Person Met -
-
- Is Applicant -
-
- -
- - - -
- +
+ Is Person + Met +
+
+ Is + Applicant +
+ + +
+ + + +
+
- - - - + + + \ No newline at end of file diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/dialogue/other-applicant-details/other-applicant-details.component.ts b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/dialogue/other-applicant-details/other-applicant-details.component.ts index 4bc09b6bc..52303c04e 100755 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/dialogue/other-applicant-details/other-applicant-details.component.ts +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/dialogue/other-applicant-details/other-applicant-details.component.ts @@ -1,6 +1,6 @@ import { Component, OnInit, Input, Output, Inject } from '@angular/core'; import { FormBuilder, FormGroup, Validators, FormControl, FormArray } from '@angular/forms'; -import { MatDialog, MatDialogRef, MAT_DIALOG_DATA , DialogPosition} from '@angular/material'; +import { MatDialog, MatDialogRef, MAT_DIALOG_DATA, DialogPosition } from '@angular/material'; import { PdTrigerService } from './../../../../../../pd-service/pd-triger.service'; import { bool } from 'aws-sdk/clients/signer'; @@ -10,124 +10,124 @@ import { bool } from 'aws-sdk/clients/signer'; styleUrls: ['./other-applicant-details.component.scss'] }) export class OtherApplicantDetailsComponent implements OnInit { - pageTitle: string ="Add Name of Person(s) Met and Individual Loan Applicant(s) "; + pageTitle: string = "Add Name of Person(s) Met and Individual Loan Applicant(s) "; public _OtherForm: FormGroup; - applicantInfo:any={'pd_co_applicant_id':"0",'applicant_name':'','is_applicant':false,'is_person_met':false, applicant_title_name:'',age:'', qualification:'',course_name:''}; - titleList: any=[]; - qualificationList: any=[]; - //EditGeneralFormData: any=[]; - //EditFlag: boolean = false; + applicantInfo: any = { 'pd_co_applicant_id': "0", 'applicant_name': '', 'is_applicant': false, 'is_person_met': false, applicant_title_name: '', age: '', qualification: '', course_name: '' }; + titleList: any = []; + qualificationList: any = []; + //EditGeneralFormData: any=[]; + //EditFlag: boolean = false; + + constructor(private _fb: FormBuilder, + private _pd: PdTrigerService, + @Inject(MAT_DIALOG_DATA) public generalFormData: any, + private dialogRef: MatDialogRef) { + // if(generalFormData != ''){ + // this.EditGeneralFormData = generalFormData.value; + // this.EditFlag = true; + // } - constructor(private _fb: FormBuilder, - private _pd: PdTrigerService, - @Inject(MAT_DIALOG_DATA) public generalFormData : any, - private dialogRef: MatDialogRef) { - // if(generalFormData != ''){ - // this.EditGeneralFormData = generalFormData.value; - // this.EditFlag = true; - // } - } - ngOnInit() { + ngOnInit() { this.initFormDetails(null); - this.getMasterDetails('TITLES',1); - this.getMasterDetails('EDUQUALIFICATION',2); + this.getMasterDetails('TITLES', 1); + this.getMasterDetails('EDUQUALIFICATION', 2); } // get all master details - getMasterDetails(table:string,type:number){ + getMasterDetails(table: string, type: number) { this._pd.getAllMasterDatas(table).subscribe( data => { if (data.status == 200) { - if(type==1){ - this.titleList=data.records.filter(val=>val.isactive==1); + if (type == 1) { + this.titleList = data.records.filter(val => val.isactive == 1); } - if(type==2){ + if (type == 2) { this.qualificationList = data.records; } } - }); + }); } // init form - initFormDetails(data : any) { - if(data == null){ - this._OtherForm = this._fb.group({ - applicant_list: this._fb.array([this.createApplicant(this.applicantInfo)]), - }); - } - } - -// create applicant form array -createApplicant(elementValue:any){ - return this._fb.group({ - pd_co_applicant_id: [elementValue.pd_co_applicant_id], - applicant_title_name: [elementValue.applicant_title_name, Validators.required], - applicant_name:['',Validators.required], - is_applicant:[false], - is_person_met:[false], - age:[''], - qualification: [''], - course_name:[''] -}); -} - -// add more -addMoreApplicant(){ - if (this._OtherForm.invalid) { - this.validateAllFormFields(this._OtherForm); - return; - } - else{ - let relationControl = this._OtherForm.controls['applicant_list']; - relationControl.push(this.createApplicant(this.applicantInfo)); - } - -} - -// remove -removeApplicant(intex:number){ - let control = this._OtherForm.controls['applicant_list']; - control.removeAt(intex); -} - -// save applicant - saveApplicant(formData:any){ - if (this._OtherForm.invalid) { - this.validateAllFormFields(this._OtherForm); - return; - } - else{ - this.dialogRef.close({ - data:formData.applicant_list + initFormDetails(data: any) { + if (data == null) { + this._OtherForm = this._fb.group({ + applicant_list: this._fb.array([this.createApplicant(this.applicantInfo)]), }); - } + } + } + + // create applicant form array + createApplicant(elementValue: any) { + return this._fb.group({ + pd_co_applicant_id: [elementValue.pd_co_applicant_id], + applicant_title_name: [elementValue.applicant_title_name, Validators.required], + applicant_name: ['', Validators.required], + is_applicant: [false], + is_person_met: [false], + age: [''], + qualification: [''], + course_name: [''] + }); + } + + // add more + addMoreApplicant() { + if (this._OtherForm.invalid) { + this.validateAllFormFields(this._OtherForm); + return; + } + else { + let relationControl = this._OtherForm.controls['applicant_list']; + relationControl.push(this.createApplicant(this.applicantInfo)); } - // close dialogue - closeDialogue(){ + } + + // remove + removeApplicant(intex: number) { + let control = this._OtherForm.controls['applicant_list']; + control.removeAt(intex); + } + + // save applicant + saveApplicant(formData: any) { + if (this._OtherForm.invalid) { + this.validateAllFormFields(this._OtherForm); + return; + } + else { this.dialogRef.close({ - data:[] - }); + data: formData.applicant_list + }); } + } - // validate all form group and form array fields - validateAllFormFields(formGroup: any) { - Object.keys(formGroup.controls).forEach(field => { - const control = formGroup.get(field); - - if (control instanceof FormControl) { - control.markAsTouched({ onlySelf: true }); - } else if (control instanceof FormGroup) { - this.validateAllFormFields(control); - } else if (control instanceof FormArray) { - this.validateAllFormFields(control); - } + // close dialogue + closeDialogue() { + this.dialogRef.close({ + data: [] }); - } - /** On Key Press Event For Amount */ - keyPress(event: any) { + } + + // validate all form group and form array fields + validateAllFormFields(formGroup: any) { + Object.keys(formGroup.controls).forEach(field => { + const control = formGroup.get(field); + + if (control instanceof FormControl) { + control.markAsTouched({ onlySelf: true }); + } else if (control instanceof FormGroup) { + this.validateAllFormFields(control); + } else if (control instanceof FormArray) { + this.validateAllFormFields(control); + } + }); + } + /** On Key Press Event For Amount */ + keyPress(event: any) { const pattern = /[0-9]/; let inputChar = String.fromCharCode(event.charCode); diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/employment-info/employment-info.component.ts b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/employment-info/employment-info.component.ts index 9a8ed2977..8b799ce04 100755 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/employment-info/employment-info.component.ts +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/employment-info/employment-info.component.ts @@ -125,7 +125,7 @@ export class EmploymentInfoComponent implements OnInit { this.employmentForm = this.fb.group({ employer_name: ['', Validators.compose([Validators.required])], how_long_year: ['', Validators.compose([Validators.required])], - how_long_month: ['', Validators.compose([Validators.required])], + how_long_month: [''], was_met: [this.pd_cus_segment=='SAL-CHQ' ? 'No' : '', Validators.compose([Validators.required])], name_person_met: [''], designation_person_met: [''], diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/family-details/family-details.component.ts b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/family-details/family-details.component.ts index d9c1ae1ce..17bbd303f 100755 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/family-details/family-details.component.ts +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/family-details/family-details.component.ts @@ -369,13 +369,13 @@ export class FamilyDetailsComponent implements OnInit { this._pd.getFamilyDetails(this.pdid).subscribe(data=>{ console.clear(); - console.log('getFamilyDetails data',data); + // console.log('getFamilyDetails data',data); if(data.dataStatus == true){ let Temparr : any = []; - console.log('from_business_form',data.record.from_business_form); - console.log('from_general_form',data.record.from_general_form); + // console.log('from_business_form',data.record.from_business_form); + // console.log('from_general_form',data.record.from_general_form); if(data.record.from_general_form.length > 0){ let familyMembersGeneralForm = Object.keys(data.record.from_general_form).map(function (key) { @@ -840,7 +840,7 @@ removeFamilyMembers(inx,i) { records.pdid = this.pdid; records.formid = '6'; // records.fk_createdby = '251'; - console.log(JSON.stringify(records)); + // console.log(JSON.stringify(records)); this._pd.saveForm(records).subscribe(data => { // this.notifier.notify('success', 'Saved Successfully.'); if(data.status == 200) { diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/financial-info/financial-info.component.html b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/financial-info/financial-info.component.html index 2e5bf5841..b862690df 100755 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/financial-info/financial-info.component.html +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/financial-info/financial-info.component.html @@ -30,7 +30,7 @@
- + Yes No @@ -175,9 +175,9 @@

Financial as per Customer

- - - + + + Yes No @@ -248,7 +248,7 @@ - + @@ -286,7 +286,7 @@ - + diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/financial-info/financial-info.component.ts b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/financial-info/financial-info.component.ts index 10a9e7a0c..861edbb5e 100755 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/financial-info/financial-info.component.ts +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/financial-info/financial-info.component.ts @@ -58,6 +58,7 @@ export class FinancialInfoComponent implements OnInit { //isreadonly for edit(no of year Fields and Starting Years ) isReadOnly : boolean = false; + EditAble: boolean = true; isDisplay : boolean ; AV_netProfitAmtFrmInwords: any = []; AV_netProfitAmtToInwords: any = []; @@ -309,7 +310,7 @@ export class FinancialInfoComponent implements OnInit { } selectedProfitOrLossType(e,detail){ - // console.log(e); + if(e.value == 1){ detail.controls.financial_net_loss.setValue(''); detail.controls.financial_margin_of_loss.setValue(''); @@ -349,29 +350,20 @@ export class FinancialInfoComponent implements OnInit { selectedStatement(e :any):void{ - if(e.value == 'yes'){ + if(e == 'yes'){ this.isDisplay = true; this.financialForm.controls['is_financial_customer'].setValue(''); - const control = this.financialForm.controls['estimated_value']; - while (control.length !== 0) { - control.removeAt(0); - } - } - else if (e.value == 'no'){ + else if(e == 'no'){ this.isDisplay = false; + this.financialForm.controls['is_financial_customer'].setValue('no'); + this.selectedFinancialCustomer('no'); - const control = this.financialForm.controls['estimated_value']; - - while (control.length !== 0) { - control.removeAt(0); - } - const statementControl = this.financialForm.controls['date_per_financial']; - + while (statementControl.length !== 0) { statementControl.removeAt(0); } @@ -379,40 +371,26 @@ export class FinancialInfoComponent implements OnInit { this.financialForm.controls['financial_starting_year'].setValue(''); this.financialForm.controls['financial_no_of_year'].setValue(''); - // alert((new Date()).getFullYear()); - let year1 = (new Date()).getFullYear(); - let year2 = ((new Date()).getFullYear() + 1); - - let Year = year1 +'-'+ year2; - control.push(this.createValue('')); - + // let year1 = (new Date()).getFullYear(); + // let year2 = ((new Date()).getFullYear() + 1); + // let Year = year1 +'-'+ year2; + } + } /** fin customer data from Fin statement*/ selectedFinancialCustomer(e: any): void { - if(e.value == 'yes'){ + if(e == 'yes'){ const control = this.financialForm.controls['estimated_value']; while (control.length !== 0) { control.removeAt(0); } } - else if (e.value == 'no'){ - + else if (e == 'no'){ const control = this.financialForm.controls['estimated_value']; - - while (control.length !== 0) { - control.removeAt(0); - } - - let year1 = (new Date()).getFullYear(); - let year2 = ((new Date()).getFullYear() - 1); - - let Year = year2 +'-'+ year1; - - control.push(this.createValue(Year)); - + control.push(this.createValue('')); } } @@ -441,16 +419,12 @@ export class FinancialInfoComponent implements OnInit { // parentArray.value.forEach((val,index) => { // let annual_sale = val.financial_annual_sale; - // // console.log('Current Anual Sales',array.value[index].financial_annual_sale); - // // console.log('Current Index',index); - // // console.log('prev_annual_sale',prev_annual_sale); + // if (index != 0) { // let childArray : any = parentArray.controls[index]; - // // console.log('INX',index); - // // console.log('SALE',annual_sale); - + // let annual_sale_variation = (( annual_sale - prev_annual_sale)/prev_annual_sale) * 100 ; - // // console.log('annual_sale_variation',annual_sale_variation); + // childArray.controls.financial_annualsales_variation.setValue( // annual_sale_variation!= Infinity ? !(Number.isNaN(annual_sale_variation)) ? annual_sale_variation.toFixed(2) // : 0 @@ -481,8 +455,7 @@ export class FinancialInfoComponent implements OnInit { // let profit = detail.value.financial_net_profit; // let loss = detail.value.financial_net_loss; // let salary = detail.value.financial_annual_sale; - // // console.log('current profit',profit); - // // console.log('current loss',loss); + // if ( (profit != '' || loss != '') && index != 0) { // if(+profit > +salary){ @@ -495,13 +468,10 @@ export class FinancialInfoComponent implements OnInit { // let prev_profit = array.value[index - 1].financial_net_profit != '' ? array.value[index - 1].financial_net_profit : 0; // let prev_loss = array.value[index - 1].financial_net_loss !='' ? array.value[index - 1].financial_net_loss : 0 ; - // // console.log('prev_profit',prev_profit); - // // console.log('prev_loss',prev_loss); - + // loss = loss != 0 ? loss * (-1) : loss; - // // console.log('-1',loss); + // prev_loss = prev_loss != 0 ? prev_loss * (-1) : prev_loss ; - // // console.log('prev_loss',prev_loss); // let variation = (((profit != '' ? profit : loss ) - (prev_profit != '' ? prev_profit : prev_loss ))/ (prev_profit != '' ? Math.abs(prev_profit) : Math.abs(prev_loss))) * 100; @@ -552,8 +522,8 @@ export class FinancialInfoComponent implements OnInit { /** old code - calculating Sale PERCENTAGE for financial statement */ - // calMargin(index, detail) { - // console.log('detail', detail); + + // let salary = detail.value.financial_annual_sale; // let profit = detail.value.financial_net_profit; // if (salary != '' && profit != '') { @@ -634,10 +604,6 @@ export class FinancialInfoComponent implements OnInit { // variation_percent = (((profit_margin != '' ? profit_margin : loss_margin ) - (prev_profit_margin != '' ? prev_profit_margin : prev_loss_margin ))/ (prev_profit_margin != '' ? Math.abs(prev_profit_margin) : Math.abs(prev_loss_margin))) * 100; - // // console.log((profit_margin != '' ? profit_margin : loss_margin ) - (prev_profit_margin != '' ? prev_profit_margin : prev_loss_margin )); - // // console.log((((profit_margin != '' ? profit_margin : loss_margin ) - (prev_profit_margin != '' ? prev_profit_margin : prev_loss_margin ))/ (prev_profit_margin != '' ? Math.abs(prev_profit_margin) : Math.abs(prev_loss_margin)))); - // // console.log((((profit_margin != '' ? profit_margin : loss_margin ) - (prev_profit_margin != '' ? prev_profit_margin : prev_loss_margin ))/ (prev_profit_margin != '' ? Math.abs(prev_profit_margin) : Math.abs(prev_loss_margin))) * 100); - // detail.controls.financial_profit_to_sale_variation.setValue(variation_percent != Infinity ? variation_percent.toFixed(2) : 0); // } @@ -919,15 +885,10 @@ export class FinancialInfoComponent implements OnInit { childArray.controls.financial_variation.setValue(''); } else{ - // console.log('loss_amt = val.financial_net_loss;',val.financial_net_loss); - // console.log('loss_amt',loss_amt); - // console.log('loss_amt/annual_sale',loss_amt/annual_sale); - // console.log('(loss_amt/annual_sale) * 100',(loss_amt/annual_sale) * 100); - // console.log('(loss_amt/annual_sale) * 100 * (-1)',(loss_amt/annual_sale) * 100 * (-1)); + loss_margin = (val.financial_net_loss/val.financial_annual_sale) * 100 * (-1); - // console.log('loss_margin',loss_margin); childArray.controls.financial_margin_of_loss.setValue(loss_margin != Infinity ? !(Number.isNaN(loss_margin)) ? loss_margin.toFixed(2) : 0 : 0); @@ -965,12 +926,14 @@ export class FinancialInfoComponent implements OnInit { if(annual_sale != ''){ - let variation_percent : any ; - - variation_percent = (((profit_margin != '' ? profit_margin : loss_margin ) - (temp_prev_profit_margin != 0 ? temp_prev_profit_margin : temp_prev_loss_margin) / (temp_prev_profit_margin != 0 ? Math.abs(temp_prev_profit_margin) : Math.abs(temp_prev_loss_margin))) * 100); - let final_percent = variation_percent != Infinity ? !(Number.isNaN(variation_percent)) ? variation_percent != -Infinity ? variation_percent.toFixed(2) : 0 : 0 : 0 ; - childArray.controls.financial_profit_to_sale_variation.setValue(final_percent); + let a = (profit_margin != '' ? profit_margin : loss_margin ) - (temp_prev_profit_margin != 0 ? temp_prev_profit_margin : temp_prev_loss_margin); + let b = a / (temp_prev_profit_margin != 0 ? Math.abs(temp_prev_profit_margin) : Math.abs(temp_prev_loss_margin)); + let c = b * 100; + + let final_percent = c != Infinity ? !(Number.isNaN(c)) ? c != -Infinity ? c.toFixed(2) : 0 : 0 : 0 ; + + childArray.controls.financial_profit_to_sale_variation.setValue(final_percent); } } /**************************** Calculating Sales's Profit Variation - ENDS HERE **************************************************************/ diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/general-info/general-info.component.html b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/general-info/general-info.component.html index c0de40503..6baca4b47 100755 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/general-info/general-info.component.html +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/general-info/general-info.component.html @@ -1,197 +1,217 @@

-
- {{main_applicant}} ({{lender_applicant_id}}), {{customer_segment_abbr}} - {{subproduct_abbr}}
- {{pageTitle}} -
-
- -
+
+ {{main_applicant}} ({{lender_applicant_id}}), {{customer_segment_abbr}} - {{subproduct_abbr}}
+ {{pageTitle}} +
+
+ +

- - Name of Person(s) Met and Individual Loan Applicant(s) - - - - - Name - - - - - - - Is Person Met - - - - - - Is Applicant - - - + + + + Is Person Met + + + + + + Is Applicant + + + - - - - Age - - - - - - Qualification - - - {{qual.qualification_name}} - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + - Company/Firm + Company/Firm - -
- - - - - - Is Applicant + +
+ + + + + + + Is Applicant - - - {{entity.business_entity_type_name}} - - - - + + + {{entity.business_entity_type_name}} + + + + - - -

Number of Years For Which The Business Has Been Running

- - - Please Enter Correct Year - - - - - - - - - - -
-
- -
-
-
-
-
+ -
- - +

Number of Years For Which The Business Has Been Running

+ + + Please Enter Correct Year + + + + + + + + + + +
+
+ +
+
+
+
+
+ +
+ + + + +
- - - - - Relationship Between Individuals - - - - - Name - - - - {{details.value.applicant_name | titlecase}} - - - - Relation - - - Select - {{member.name + ' of' | titlecase}} - Not Applicable - - - - - - Relationship To - - - Select - - {{appc.applicant_name | titlecase}} - Not Applicable - - - - - - - - - - + + Relationship Between Individuals + + + + + Name + + + + {{details.value.applicant_name | titlecase}} + + + + Relation + + + Select + {{member.name + + ' of' | titlecase}} + Not Applicable + + + + + + Relationship To + + + Select + + {{appc.applicant_name | titlecase}} + Not Applicable + + + + + + + + + + @@ -203,72 +223,77 @@ - - - + + + Applicant - - - - {{bothC.applicant_name | titlecase}} - - + + + + {{bothC.applicant_name + | titlecase}} + + - Relation - - + Relation + + Select - {{comrelShip.name | titlecase}} + {{comrelShip.name | titlecase}} - Not Applicable + Not Applicable - + Company - - - - Select - - {{comp.company_name}} - - Not Applicable - - - - + - + - - - - + + + + - + - - - - +
-
- - Remarks - - -
-
- +
+ + Remarks + + +
+
+
- - - \ No newline at end of file + + \ No newline at end of file diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/general-info/general-info.component.ts b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/general-info/general-info.component.ts index 697d6b860..43ef3ef61 100755 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/general-info/general-info.component.ts +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/general-info/general-info.component.ts @@ -1,9 +1,9 @@ import { Component, OnInit, Input, Output, Inject } from '@angular/core'; import { FormBuilder, FormGroup, Validators, FormControl, FormArray } from '@angular/forms'; -import { MatDialog, MatDialogRef, MAT_DIALOG_DATA , MatTableDataSource} from '@angular/material'; +import { MatDialog, MatDialogRef, MAT_DIALOG_DATA, MatTableDataSource } from '@angular/material'; import { NotifierService } from 'angular-notifier'; import { PdTrigerService } from './../../../../../pd-service/pd-triger.service'; -import {OtherApplicantDetailsComponent} from './../dialogue/other-applicant-details/other-applicant-details.component'; +import { OtherApplicantDetailsComponent } from './../dialogue/other-applicant-details/other-applicant-details.component'; import { element } from '@angular/core/src/render3/instructions'; import { ELEMENT_PROBE_PROVIDERS } from '@angular/platform-browser/src/dom/debug/ng_probe'; import { DatePipe } from '@angular/common'; @@ -17,125 +17,151 @@ import { Options } from 'selenium-webdriver/edge'; providers: [SearchRelationPipe], }) export class GeneralInfoComponent implements OnInit { + + /* Declaration for Header Variables */ + pageTitle: string = "General Information"; + subproduct_abbr: any; customer_segment_abbr: any; lender_applicant_id: any; main_applicant: any; + + /* Declaration for Common Variables */ pipe = new DatePipe('en-US'); - pageTitle: string ="General Information"; - pdid : string; - form_id:number; - is_new : boolean; - count : number = 1; - private notifier: NotifierService; - public _generalForm: FormGroup; - displayedColumns = ['applicant_name','is_person_met','is_applicant','age','qualification','course_name','actions']; - public individualsSource= new MatTableDataSource(); - public relationSource= new MatTableDataSource(); - public CompanySource = new MatTableDataSource(); - secondDisplayedColumns = ['applicant_name','relation','relation_to']; - thridDisplayedColumns = ['applicant_name','company_relationship','relation_to_company']; - public pd_applicants_details: any; - relationShipList:any=[]; - companyRelationShipList:any=[]; - errorMessage:any; - individualsList: any=[]; - individualsListBothCase: any=[]; - companyList: any=[]; - qualificationList: any=[]; - businessEntityTypeList: any=[]; + + pdid: string; + form_id: number; + count: number = 1; + errorMessage: any; maxDate: any; - constructor(notifier: NotifierService,private _fb: FormBuilder,private _pd: PdTrigerService , private dialog: MatDialog, @Inject(MAT_DIALOG_DATA) public pd_all_details: any,private dialogRef: MatDialogRef) { + + public pd_applicants_details: any; + public _generalForm: FormGroup; + private notifier: NotifierService; + + + /* Declaration for DataTables */ + displayedColumns = ['applicant_name', 'is_person_met', 'is_applicant', 'age', 'qualification', 'course_name', 'actions']; + secondDisplayedColumns = ['applicant_name', 'relation', 'relation_to']; + thridDisplayedColumns = ['applicant_name', 'company_relationship', 'relation_to_company']; + + public individualsSource = new MatTableDataSource(); + public relationSource = new MatTableDataSource(); + public CompanySource = new MatTableDataSource(); + + /* Declaration for Dropdowns */ + relationShipList: any = []; + companyRelationShipList: any = []; + individualsList: any = []; + individualsListBothCase: any = []; + companyList: any = []; + qualificationList: any = []; + businessEntityTypeList: any = []; + + /********************** Declaration Section Ends Here *****************/ + + /** Constructor Section */ + constructor(notifier: NotifierService, private _fb: FormBuilder, private _pd: PdTrigerService, private dialog: MatDialog, @Inject(MAT_DIALOG_DATA) public pd_all_details: any, private dialogRef: MatDialogRef) { this.pdid = this.pd_all_details.pdmaster_details.pd_id; this.notifier = notifier; this.form_id = 18; this.pd_applicants_details = this.pd_all_details.pdapplicants_detials; - this.main_applicant = this.pd_all_details.pdmaster_details.main_applicant; - this.lender_applicant_id = this.pd_all_details.pdmaster_details.lender_applicant_id; - this.subproduct_abbr = this.pd_all_details.pdmaster_details.subproduct_abbr; - this.customer_segment_abbr = this.pd_all_details.pdmaster_details.customer_segment_abbr; - - } + this.main_applicant = this.pd_all_details.pdmaster_details.main_applicant; + this.lender_applicant_id = this.pd_all_details.pdmaster_details.lender_applicant_id; + this.subproduct_abbr = this.pd_all_details.pdmaster_details.subproduct_abbr; + this.customer_segment_abbr = this.pd_all_details.pdmaster_details.customer_segment_abbr; + } + /********************** Constructor Section Ends Here ****************/ + /** ng Oninit Section */ ngOnInit() { let get_max_date = this.pd_all_details.pdmaster_details.pd_date_of_initiation.split('/').reverse().join("/"); - this.maxDate = new Date(get_max_date); + this.maxDate = new Date(get_max_date); this.initFormDetails(); - this.getMasterDetails('RELATIONSHIPS',1); - this.getMasterDetails('COMPANYRELATIONSHIPS',2); - this.getMasterDetails('EDUQUALIFICATION',3); - this.getMasterDetails('BUSINESSENTITYTYPE',4); - // update data source table when change the individuals details - this._generalForm.controls['individuals'].valueChanges.subscribe(val=>{ + this.getMasterDetails('RELATIONSHIPS', 1); + this.getMasterDetails('COMPANYRELATIONSHIPS', 2); + this.getMasterDetails('EDUQUALIFICATION', 3); + this.getMasterDetails('BUSINESSENTITYTYPE', 4); + + // update data source table when change the individuals details + this._generalForm.controls['individuals'].valueChanges.subscribe(val => { let control = this._generalForm.controls['individuals']; - this.individualsSource.data =control.controls; - this.individualsList = control.value.filter(element =>element.is_applicant===true); - this.individualsListBothCase = control.value.filter(element =>element.is_applicant===true || element.is_person_met===true); - }); - // update company details - this._generalForm.controls['companies'].valueChanges.subscribe(val=>{ - let control = this._generalForm.controls['companies']; - this.companyList = control.value.filter(element =>element.company_name && element.is_active); - }); + this.individualsSource.data = control.controls; + this.individualsList = control.value.filter(element => element.is_applicant === true); + this.individualsListBothCase = control.value.filter(element => element.is_applicant === true || element.is_person_met === true); + }); - this._generalForm.controls['persons_with_relationships'].valueChanges.subscribe(val=>{ - let control = this._generalForm.controls['persons_with_relationships']; - this.relationSource.data =control.controls; - //this.individualsList = control.value.filter(element =>element.is_applicant===true); - }); + // update company details + this._generalForm.controls['companies'].valueChanges.subscribe(val => { + let control = this._generalForm.controls['companies']; + this.companyList = control.value.filter(element => element.company_name && element.is_active); + }); - // change relation with businees update dat sorce table - this._generalForm.controls['company_with_relationships'].valueChanges.subscribe(val=>{ - let ComapnyControl = this._generalForm.controls['company_with_relationships']; - this.CompanySource .data =ComapnyControl.controls; - }); + this._generalForm.controls['persons_with_relationships'].valueChanges.subscribe(val => { + let control = this._generalForm.controls['persons_with_relationships']; + this.relationSource.data = control.controls; + //this.individualsList = control.value.filter(element =>element.is_applicant===true); + }); + + // change relation with businees update dat sorce table + this._generalForm.controls['company_with_relationships'].valueChanges.subscribe(val => { + let ComapnyControl = this._generalForm.controls['company_with_relationships']; + this.CompanySource.data = ComapnyControl.controls; + }); } + /***************************** ng Oninit Section Ends Here **********************************/ - // init form + /** init form */ initFormDetails() { this._generalForm = this._fb.group({ - pdid:this.pdid, - formid:this.form_id, + pdid: this.pdid, + formid: this.form_id, //applicant_relation: this._fb.array([]), individuals: this._fb.array([]), companies: this._fb.array([]), persons_with_relationships: this._fb.array([]), company_with_relationships: this._fb.array([]), - general_remark:'' - }) - this.loadFormData(); -} -// get all master details - getMasterDetails(table:string,type:number){ + general_remark: '' + }) + this.loadFormData(); + } + /**************************** init form Ends Here **************/ + + + /*** get all master details **/ + getMasterDetails(table: string, type: number) { this._pd.getAllMasterDatas(table).subscribe( data => { if (data.status == 200) { - if(type==1){ - this.relationShipList=data.records.filter(item => item.isactive == 1); - + if (type == 1) { + this.relationShipList = data.records.filter(item => item.isactive == 1); //this.relationShipList.push({'relationship_id':"0",'name':'Not Applicable'}); } - if(type==2){ - this.companyRelationShipList=data.records.filter(item => item.isactive == 1); - this.companyRelationShipList=data.records.filter(item => item.name != 'Others'); + if (type == 2) { + this.companyRelationShipList = data.records.filter(item => item.isactive == 1); + this.companyRelationShipList = data.records.filter(item => item.name != 'Others'); } - if(type==3){ + if (type == 3) { this.qualificationList = data.records; } - if(type==4) { + if (type == 4) { this.businessEntityTypeList = data.records; } - - } - }, error => this.errorMessage = error); - } - // load form data + } + }, error => this.errorMessage = error); + } + /********************** get all master details Ends Here **************************/ + + /** load form data + * IF part => Fetch The DB Datas; + * Else Part => initial stage; + */ loadFormData() { let params: any = {}; - params.pd_id = this.pdid; - params.pd_form_id = '18'; + params.pd_id = this.pdid; + params.pd_form_id = '18'; let individualsControl = this._generalForm.controls['individuals']; let companyControl = this._generalForm.get('companies') as FormArray; //let relationControl = this._generalForm.controls['applicant_relation']; @@ -145,204 +171,223 @@ export class GeneralInfoComponent implements OnInit { //relationControl.controls = []; companyControl.controls = []; personsWithRelationshipsControl.controls = []; - let exist_individuals:any; - let exist_companies:any; - let exist_relation:any; - let exist_personsWithRelationships:any; - let exist_companyWithRelationships:any; + let exist_individuals: any; + let exist_companies: any; + let exist_relation: any; + let exist_personsWithRelationships: any; + let exist_companyWithRelationships: any; + this._pd.retriveForm(params).subscribe(data => { - console.log('data',data); - if(data.dataStatus) { - this._generalForm.controls['general_remark'].setValue(data.records.general_remark ? data.records.general_remark : ''); - - // create individuals - exist_individuals=Object.keys(data.records.individuals).map(function(key) { - return data.records.individuals[key]; - }); - console.log('exist_individuals',exist_individuals); - if(exist_individuals.length>0){ + + if (data.dataStatus) { + + this._generalForm.controls['general_remark'].setValue(data.records.general_remark ? data.records.general_remark : ''); + + // create individuals + exist_individuals = Object.keys(data.records.individuals).map(function (key) { + return data.records.individuals[key]; + }); + + if (exist_individuals.length > 0) { exist_individuals.forEach(element => { individualsControl.push(this.createIndividulas(element)) }); } // create persons with relationships - exist_personsWithRelationships=Object.keys(data.records.persons_with_relationships).map(function(key) { + exist_personsWithRelationships = Object.keys(data.records.persons_with_relationships).map(function (key) { return data.records.persons_with_relationships[key]; }); - if(exist_personsWithRelationships.length>0){ + if (exist_personsWithRelationships.length > 0) { exist_personsWithRelationships.forEach(element => { //individualsControl.push(this.createIndividulas(element)) personsWithRelationshipsControl.push(this.createPersonsWithRelationships(element)); }); } - exist_companyWithRelationships=Object.keys(data.records.company_with_relationships).map(function(key) { + exist_companyWithRelationships = Object.keys(data.records.company_with_relationships).map(function (key) { return data.records.company_with_relationships[key]; }); - if(exist_companyWithRelationships.length>0){ + + if (exist_companyWithRelationships.length > 0) { exist_companyWithRelationships.forEach(element => { //individualsControl.push(this.createIndividulas(element)) companyWithRelationshipsControl.push(this.createCompaniesRelationshipWithData(element)); }); } + else if(exist_companyWithRelationships.length == 0) { + companyWithRelationshipsControl.push(this.createCompaniesRelationship()); + } // create companies - exist_companies = Object.keys(data.records.companies).map(function(key) { + exist_companies = Object.keys(data.records.companies).map(function (key) { return data.records.companies[key]; + }); + if (exist_companies.length > 0) { + exist_companies.forEach((element, cindex) => { + companyControl.push(this.createCompanies(element)); + let otherControl: any = this._generalForm.get('companies') as FormArray; + otherControl = otherControl.controls[cindex]; + element.business_entity_type == '1' ? otherControl.addControl('business_entity_type_other', new FormControl(element.business_entity_type_other, Validators.required)) : otherControl.removeControl('business_entity_type_other'); + if (element.is_active == false) { + let control: any = this._generalForm.get('companies') as FormArray; + control.controls[cindex].controls.company_name.clearValidators(); + control.controls[cindex].controls.company_name.updateValueAndValidity(); + control.controls[cindex].controls.business_years.clearValidators(); + control.controls[cindex].controls.business_years.updateValueAndValidity(); + control.controls[cindex].controls.business_entity_type.clearValidators(); + control.controls[cindex].controls.business_entity_type.updateValueAndValidity(); + element.business_entity_type == '1' ? control.controls[cindex].controls.business_entity_type_other.clearValidators() : ''; + element.business_entity_type == '1' ? control.controls[cindex].controls.business_entity_type_other.updateValueAndValidity() : ''; + } + }); - if(exist_companies.length>0){ - exist_companies.forEach((element,cindex) => { - companyControl.push(this.createCompanies(element)); - let otherControl: any = this._generalForm.get('companies') as FormArray; - otherControl = otherControl.controls[cindex]; - element.business_entity_type=='1' ? otherControl.addControl('business_entity_type_other', new FormControl(element.business_entity_type_other, Validators.required)) : otherControl.removeControl('business_entity_type_other'); - if(element.is_active==false){ - let control: any = this._generalForm.get('companies') as FormArray; - control.controls[cindex].controls.company_name.clearValidators(); - control.controls[cindex].controls.company_name.updateValueAndValidity(); - control.controls[cindex].controls.business_years.clearValidators(); - control.controls[cindex].controls.business_years.updateValueAndValidity(); - control.controls[cindex].controls.business_entity_type.clearValidators(); - control.controls[cindex].controls.business_entity_type.updateValueAndValidity(); - element.business_entity_type=='1' ? control.controls[cindex].controls.business_entity_type_other.clearValidators() : ''; - element.business_entity_type=='1' ? control.controls[cindex].controls.business_entity_type_other.updateValueAndValidity() : ''; - } - - }); - } + } - // create relations - // exist_relation = Object.keys(data.records.applicant_relation).map(function(key) { - // return data.records.applicant_relation[key]; - // }); - // if(exist_relation.length>0){ - // exist_relation.forEach((element,index) => { - // relationControl.push(this.createApplicantRelation(element)); - // let innerrelControl:any = relationControl.controls[index].get('multiple_relation') as FormArray; - // element.multiple_relation.forEach((innereElement) => { - // innerrelControl.push(this.createMultipleRelation(innereElement)); - // }); - // let innercomrelControl:any = relationControl.controls[index].get('multiple_company_relation') as FormArray; - // element.multiple_company_relation.forEach((innerecomElement) => { - // innercomrelControl.push(this.createMultipleCompanyRelation(innerecomElement)); - // }); - // }); - // } + // create relations + // exist_relation = Object.keys(data.records.applicant_relation).map(function(key) { + // return data.records.applicant_relation[key]; + // }); + // if(exist_relation.length>0){ + // exist_relation.forEach((element,index) => { + // relationControl.push(this.createApplicantRelation(element)); + // let innerrelControl:any = relationControl.controls[index].get('multiple_relation') as FormArray; + // element.multiple_relation.forEach((innereElement) => { + // innerrelControl.push(this.createMultipleRelation(innereElement)); + // }); + // let innercomrelControl:any = relationControl.controls[index].get('multiple_company_relation') as FormArray; + // element.multiple_company_relation.forEach((innerecomElement) => { + // innercomrelControl.push(this.createMultipleCompanyRelation(innerecomElement)); + // }); + // }); + // } - } - else { - this.pd_applicants_details.forEach((element,key) => { - console.log('element element',element); - element.is_applicant=true; - element.is_person_met=false; - element.is_new=false; - element.individuals_order_id = key+1; - element.age = '', - element.qualification = '', - element.course_name = '', - individualsControl.push(this.createIndividulas(element)); - personsWithRelationshipsControl.push(this.createPersonsWithRelationships(element)); - //let relationControl = this._generalForm.controls['applicant_relation']; - // let applicant_details: any= {'pd_co_applicant_id':element.pd_co_applicant_id,'applicant_name':element.applicant_name, 'individula_order_id':relationControl.controls.length+1}; - // relationControl.push(this.createApplicantRelation(applicant_details)); - // let mulRelationControl = relationControl.controls[relationControl.controls.length-1].get('multiple_relation'); - // mulRelationControl.push(this.createMultipleRelation(applicant_details)) - // let mulCmyRelationControl = relationControl.controls[relationControl.controls.length-1].get('multiple_company_relation'); - // mulCmyRelationControl.push(this.createMultipleCompanyRelation(applicant_details)) - - // create companies - if(element.company_name!='' && element.company_name!=null){ - let setCompanyValues: any = {company_order_id :companyControl.controls.length+1,company_name:element.company_name,is_company_applicant:element.is_company_applicant,business_entity_type:element.business_entity_type,business_entity_type_other:element.business_entity_type_other,business_years:element.business_years,business_month:element.business_month,business_date_object:element.business_date_object,is_new:element.is_new,is_active:true} - companyControl.push(this.createCompanies(setCompanyValues)) - } - }); - // check company if null update one row - if(companyControl.controls.length ==0){ - let setCompanyValues: any = {company_order_id :companyControl.controls.length+1,company_name:'',is_company_applicant:false,business_entity_type:'',business_entity_type_other:'',business_years:'',business_month:'',business_date_object:'',is_active:true,is_new:false} - companyControl.push(this.createCompanies(setCompanyValues)) - - } - } - }, error => this.errorMessage = error); - } - // create individuals - createIndividulas(elementValue:any) { - return this._fb.group({ - pd_co_applicant_id: [elementValue.pd_co_applicant_id], - applicant_title_name: [elementValue.applicant_title_name], - applicant_name: [elementValue.applicant_name], - is_applicant:[elementValue.is_applicant], - is_person_met:[elementValue.is_person_met], - is_new:[elementValue.is_new], - individuals_order_id: [elementValue.individuals_order_id], - age: [elementValue.age], - qualification: [elementValue.qualification], - course_name:[elementValue.course_name] - }); - } - createPersonsWithRelationships(elementValue:any){ - return this._fb.group({ - pd_co_applicant_id: [elementValue.pd_co_applicant_id], - applicant_name: [elementValue.applicant_name], - relationship:[elementValue.relationship], - relation_to:[elementValue.relation_to], - individuals_order_id: [elementValue.individuals_order_id], - }); - } - // create companies - createCompanies(elementValue:any) { - return this._fb.group({ - company_order_id: [elementValue.company_order_id], - company_name: [elementValue.company_name,], - company_messrs_name: ['M/s'], - is_company_applicant:[elementValue.is_company_applicant], - business_entity_type :[elementValue.business_entity_type,Validators.required], - business_years: [elementValue.business_years, Validators.required], - business_month: [elementValue.business_month], - business_date_object: [elementValue.business_date_object], - is_active: [elementValue.is_active], - is_new:[elementValue.is_new], + else { + this.pd_applicants_details.forEach((element, key) => { + + element.is_applicant = true; + element.is_person_met = false; + element.is_new = false; + element.is_main_applicant = element.applicant_type == '1' ? true : false; + element.is_active = true; + element.individuals_order_id = key + 1; + element.age = '', + element.qualification = '', + element.course_name = '', + individualsControl.push(this.createIndividulas(element)); + personsWithRelationshipsControl.push(this.createPersonsWithRelationships(element)); + + //let relationControl = this._generalForm.controls['applicant_relation']; + // let applicant_details: any= {'pd_co_applicant_id':element.pd_co_applicant_id,'applicant_name':element.applicant_name, 'individula_order_id':relationControl.controls.length+1}; + // relationControl.push(this.createApplicantRelation(applicant_details)); + // let mulRelationControl = relationControl.controls[relationControl.controls.length-1].get('multiple_relation'); + // mulRelationControl.push(this.createMultipleRelation(applicant_details)) + // let mulCmyRelationControl = relationControl.controls[relationControl.controls.length-1].get('multiple_company_relation'); + // mulCmyRelationControl.push(this.createMultipleCompanyRelation(applicant_details)) + + // create companies + if (element.company_name != '' && element.company_name != null) { + let setCompanyValues: any = { company_order_id: companyControl.controls.length + 1, company_name: element.company_name, is_company_applicant: element.is_company_applicant, business_entity_type: element.business_entity_type, business_entity_type_other: element.business_entity_type_other, business_years: element.business_years, business_month: element.business_month, business_date_object: element.business_date_object, is_new: element.is_new, is_active: true } + companyControl.push(this.createCompanies(setCompanyValues)) + } + }); + companyWithRelationshipsControl.push(this.createCompaniesRelationship()); + // check company if null update one row + if (companyControl.controls.length == 0) { + let setCompanyValues: any = { company_order_id: companyControl.controls.length + 1, company_name: '', is_company_applicant: false, business_entity_type: '', business_entity_type_other: '', business_years: '', business_month: '', business_date_object: '', is_active: true, is_new: false } + companyControl.push(this.createCompanies(setCompanyValues)) + + } + } + }, error => this.errorMessage = error); + + } + /******************************* load form data Ends Here *************************/ + + // create individuals + createIndividulas(elementValue: any) { + + return this._fb.group({ + pd_co_applicant_id: [elementValue.pd_co_applicant_id], + applicant_title_name: [elementValue.applicant_title_name], + applicant_name: [elementValue.applicant_name], + is_applicant: [elementValue.is_applicant], + is_person_met: [elementValue.is_person_met], + is_new: [elementValue.is_new], + is_main_applicant: [elementValue.is_main_applicant], + is_active: [elementValue.is_active], + individuals_order_id: [elementValue.individuals_order_id], + age: [elementValue.age], + qualification: [elementValue.qualification], + course_name: [elementValue.course_name] }); - } + } - // createCompaniesRelationship(elementValue:any) { - // return this._fb.group({ - // applicant_name:[elementValue.applicant_name], - // company_relationship:[elementValue.company_relationship], - // relation_to_company:[elementValue.relation_to_company] - // }); - // } - - createCompaniesRelationship() { - return this._fb.group({ - applicant_name:[''], - company_relationship:[''], - relation_to_company:[''] + createPersonsWithRelationships(elementValue: any) { + return this._fb.group({ + pd_co_applicant_id: [elementValue.pd_co_applicant_id], + applicant_name: [elementValue.applicant_name], + relationship: [elementValue.relationship], + relation_to: [elementValue.relation_to], + individuals_order_id: [elementValue.individuals_order_id], + is_active:[elementValue.is_active] }); - } + } + + // create companies + createCompanies(elementValue: any) { + return this._fb.group({ + company_order_id: [elementValue.company_order_id], + company_name: [elementValue.company_name,], + company_messrs_name: ['M/s'], + is_company_applicant: [elementValue.is_company_applicant], + business_entity_type: [elementValue.business_entity_type, Validators.required], + business_years: [elementValue.business_years, Validators.required], + business_month: [elementValue.business_month], + business_date_object: [elementValue.business_date_object], + is_active: [elementValue.is_active], + is_new: [elementValue.is_new], - createCompaniesRelationshipWithData(elementValue:any) { - return this._fb.group({ - applicant_name:[elementValue.applicant_name], - company_relationship:[elementValue.company_relationship], - relation_to_company:[elementValue.relation_to_company] }); - } + } - // open other family family member details - addCompanyRelationshipDialogue() { - let control: any = this._generalForm.get('company_with_relationships') as FormArray; - //let setValues: any = { applicant_name:'', company_relationship:'',relation_to_company:''}; - control.push(this.createCompaniesRelationship()) - } + // createCompaniesRelationship(elementValue:any) { + // return this._fb.group({ + // applicant_name:[elementValue.applicant_name], + // company_relationship:[elementValue.company_relationship], + // relation_to_company:[elementValue.relation_to_company] + // }); + // } + + createCompaniesRelationship() { + return this._fb.group({ + applicant_name: [''], + company_relationship: [''], + relation_to_company: [''] + }); + } + + createCompaniesRelationshipWithData(elementValue: any) { + return this._fb.group({ + applicant_name: [elementValue.applicant_name], + company_relationship: [elementValue.company_relationship], + relation_to_company: [elementValue.relation_to_company] + }); + } + + // open other family family member details + addCompanyRelationshipDialogue() { + let control: any = this._generalForm.get('company_with_relationships') as FormArray; + //let setValues: any = { applicant_name:'', company_relationship:'',relation_to_company:''}; + control.push(this.createCompaniesRelationship()) + } // remove other famil membre - removeCompanyRelationship(indexValues){ + removeCompanyRelationship(indexValues) { let control: any = this._generalForm.get('company_with_relationships') as FormArray; control.removeAt(indexValues); // control.controls[indexValues].controls.company_name.clearValidators(); @@ -350,208 +395,276 @@ export class GeneralInfoComponent implements OnInit { //control.removeAt(indexValues); } - // add more companies - addMoreCompanies() { - let control: any = this._generalForm.get('companies') as FormArray; - let setValues: any = {company_order_id :control.controls.length+1,company_name:'',is_company_applicant:false,business_entity_type:'',business_entity_type_other:'',business_years:'',business_month:'',business_date_object:'',is_active:true,is_new: true} - control.push(this.createCompanies(setValues)) - } + // add more companies + addMoreCompanies() { + let control: any = this._generalForm.get('companies') as FormArray; + let setValues: any = { company_order_id: control.controls.length + 1, company_name: '', is_company_applicant: false, business_entity_type: '', business_entity_type_other: '', business_years: '', business_month: '', business_date_object: '', is_active: true, is_new: true } + control.push(this.createCompanies(setValues)) + } - // remove companies - removeCompanies(indexValues) { - this.count = this.count-1; - let control: any = this._generalForm.get('companies') as FormArray; - control.controls[indexValues].controls.is_active.setValue(false); - control.controls[indexValues].controls.company_name.clearValidators(); - control.controls[indexValues].controls.company_name.updateValueAndValidity(); - control.controls[indexValues].controls.business_years.clearValidators(); - control.controls[indexValues].controls.business_years.updateValueAndValidity(); - control.controls[indexValues].controls.business_entity_type.clearValidators(); - control.controls[indexValues].controls.business_entity_type.updateValueAndValidity(); - //control.removeAt(indexValues); - } + // remove companies + removeCompanies(indexValues) { + this.count = this.count - 1; + let control: any = this._generalForm.get('companies') as FormArray; + control.controls[indexValues].controls.is_active.setValue(false); + control.controls[indexValues].controls.company_name.clearValidators(); + control.controls[indexValues].controls.company_name.updateValueAndValidity(); + control.controls[indexValues].controls.business_years.clearValidators(); + control.controls[indexValues].controls.business_years.updateValueAndValidity(); + control.controls[indexValues].controls.business_entity_type.clearValidators(); + control.controls[indexValues].controls.business_entity_type.updateValueAndValidity(); + //control.removeAt(indexValues); + } - // create applicant form array - createApplicant(elementValue:any){ - return this._fb.group({ - pd_co_applicant_id: [elementValue.pd_co_applicant_id], - applicant_name: [elementValue.applicant_name], - company_name: [elementValue.company_name,], - exist_status:[elementValue.exist_status==1 && elementValue.pd_co_applicant_id > 0 ? true : false] - }); - } + // create applicant form array + createApplicant(elementValue: any) { + return this._fb.group({ + pd_co_applicant_id: [elementValue.pd_co_applicant_id], + applicant_name: [elementValue.applicant_name], + company_name: [elementValue.company_name,], + exist_status: [elementValue.exist_status == 1 && elementValue.pd_co_applicant_id > 0 ? true : false] + }); + } - // create applicant relation form array - createApplicantRelation(elementValue: any) { - return this._fb.group({ - pd_co_applicant_id: [elementValue.pd_co_applicant_id], - applicant_name: [elementValue.applicant_name], - multiple_relation: this._fb.array([]), - multiple_company_relation : this._fb.array([]), - individuals_order_id:[elementValue.individuals_order_id] - }); - } - // create multiple relation details - createMultipleRelation(elementValue: any) { - return this._fb.group({ - applicant_relation_to: [elementValue.applicant_relation_to], - relationship: [elementValue.relationship], - other_relationship:[elementValue.other_relationship] - }); - } + // create applicant relation form array + createApplicantRelation(elementValue: any) { + return this._fb.group({ + pd_co_applicant_id: [elementValue.pd_co_applicant_id], + applicant_name: [elementValue.applicant_name], + multiple_relation: this._fb.array([]), + multiple_company_relation: this._fb.array([]), + individuals_order_id: [elementValue.individuals_order_id] + }); + } + // create multiple relation details + createMultipleRelation(elementValue: any) { + return this._fb.group({ + applicant_relation_to: [elementValue.applicant_relation_to], + relationship: [elementValue.relationship], + other_relationship: [elementValue.other_relationship] + }); + } - // add more relation - addMoreRelation(rindex,mindex) { - let control: any = this._generalForm.get('applicant_relation') as FormArray; - control = control.controls[rindex].get('multiple_relation') as FormArray; - let setValues: any = {applicant_relation_to :'',relationship:'',other_relationship:''} - control.push(this.createMultipleRelation(setValues)) - } + // add more relation + addMoreRelation(rindex, mindex) { + let control: any = this._generalForm.get('applicant_relation') as FormArray; + control = control.controls[rindex].get('multiple_relation') as FormArray; + let setValues: any = { applicant_relation_to: '', relationship: '', other_relationship: '' } + control.push(this.createMultipleRelation(setValues)) + } - // remove relation - removeRelation(rindex,mindex) { - let control: any = this._generalForm.get('applicant_relation') as FormArray; - control = control.controls[rindex].get('multiple_relation') as FormArray; - control.removeAt(mindex); - } + // remove relation + removeRelation(rindex, mindex) { + let control: any = this._generalForm.get('applicant_relation') as FormArray; + control = control.controls[rindex].get('multiple_relation') as FormArray; + control.removeAt(mindex); + } - // create multiple company relation - createMultipleCompanyRelation(elementValue: any) { - return this._fb.group({ - company_name: [elementValue.company_name], - company_relationship: [elementValue.company_relationship], - company_other_relationship:[elementValue.company_other_relationship] - }); - } - // add more company relation - addMoreCompanyRelation(rindex,cindex) { - let control: any = this._generalForm.get('applicant_relation') as FormArray; - control = control.controls[rindex].get('multiple_company_relation') as FormArray; - let setValues: any = {company_name :'',company_relationship:'',company_other_relationship:''} - control.push(this.createMultipleCompanyRelation(setValues)) - } + // create multiple company relation + createMultipleCompanyRelation(elementValue: any) { + return this._fb.group({ + company_name: [elementValue.company_name], + company_relationship: [elementValue.company_relationship], + company_other_relationship: [elementValue.company_other_relationship] + }); + } + // add more company relation + addMoreCompanyRelation(rindex, cindex) { + let control: any = this._generalForm.get('applicant_relation') as FormArray; + control = control.controls[rindex].get('multiple_company_relation') as FormArray; + let setValues: any = { company_name: '', company_relationship: '', company_other_relationship: '' } + control.push(this.createMultipleCompanyRelation(setValues)) + } - // remove company relation - removeCompanyRelation(rindex,cindex) { - let control: any = this._generalForm.get('applicant_relation') as FormArray; - control = control.controls[rindex].get('multiple_company_relation') as FormArray; - control.removeAt(cindex); - } + // remove company relation + removeCompanyRelation(rindex, cindex) { + let control: any = this._generalForm.get('applicant_relation') as FormArray; + control = control.controls[rindex].get('multiple_company_relation') as FormArray; + control.removeAt(cindex); + } + + // add more individuals details + addMoreIndividuals() { + const dialogRef = this.dialog.open(OtherApplicantDetailsComponent, { + data: '', + width: '40%', + disableClose: true + }); + dialogRef.afterClosed() + .subscribe(dataresult => { + if (dataresult.data.length > 0) { + dataresult.data.forEach((element, index) => { + + let individualsControl = this._generalForm.controls['individuals']; + element.pd_co_applicant_id = this.count; + this.count = this.count + 1; + element.individuals_order_id = individualsControl.controls.length + 1; + element.is_new = true; + element.is_active = true; + element.is_main_applicant = false; + individualsControl.push(this.createIndividulas(element)); + let relationControl = this._generalForm.controls['persons_with_relationships']; + let applicant_details: any = { 'pd_co_applicant_id': element.pd_co_applicant_id, 'applicant_name': element.applicant_name, 'relationship': '', 'relation_to': '', 'individuals_order_id': element.individuals_order_id,'is_active': element.is_active }; + relationControl.push(this.createPersonsWithRelationships(applicant_details)); - // add more individuals details - addMoreIndividuals() { - const dialogRef = this.dialog.open(OtherApplicantDetailsComponent, { - data: '', - width:'40%', - disableClose: true }); - dialogRef.afterClosed() - .subscribe(dataresult => { - if(dataresult.data.length>0){ - dataresult.data.forEach((element,index) => { - console.log('element',element); - let individualsControl = this._generalForm.controls['individuals']; - element.pd_co_applicant_id = this.count; - this.count = this.count+1; - element.individuals_order_id = individualsControl.controls.length+1; - element.is_new=true; - individualsControl.push(this.createIndividulas(element)); - let relationControl = this._generalForm.controls['persons_with_relationships']; - let applicant_details: any= {'pd_co_applicant_id':element.pd_co_applicant_id,'applicant_name':element.applicant_name,'relationship':'','relation_to':'','individuals_order_id':element.individuals_order_id}; - relationControl.push(this.createPersonsWithRelationships(applicant_details)); - }); - - } - }); - - } + } + }); - // remove individuals - // removeIndividuals(findex){ - // let control = this._generalForm.controls['individuals']; - // control.removeAt(findex); - // } + } + + ApplicantName(event,coApplicantId){ + + + let relationControl = this._generalForm.controls['persons_with_relationships']; + let index1 = relationControl.value.map(data => data.pd_co_applicant_id).indexOf(coApplicantId); + + // details.value.applicant_name + let control = relationControl.controls[index1] as FormArray; + + control.controls['applicant_name'].setValue(event.target.value); + + // event.target.value + // controls.controls[index1].disable(); + // let personsWithRelationshipsControl : any = control.controls[index1]; + // personsWithRelationshipsControl.controls.is_applicant.setValue(false); + // control.markAsDirty({onlySelf:true}); + + // controls.removeAt(index1); + // let index1 = controls.value.map(data => data.applicant_name).indexOf(name); + } + + // remove individuals + // removeIndividuals(findex){ + // let control = this._generalForm.controls['individuals']; + // control.removeAt(findex); + // } - // remove individuals - removeIndividuals(findex,details){ + // remove individuals + removeIndividuals(findex, details) { - let control = this._generalForm.controls['individuals']; - let individualsControl : any = control.controls[findex]; - // individualsControl.controls.is_applicant.setValue(false); - - // console.log(control.controls[findex].value.is_active); - // .controls.is_active.setValue(false); - // console.log('control',control.dirty); - // console.log('control',control.dirty); - // control.markAsDirty({onlySelf:true}); - // console.log(control); - control.removeAt(findex); + let control = this._generalForm.controls['individuals']; + let individualsControl: any = control.controls[findex]; + individualsControl.controls.is_active.setValue(false); + // individualsControl.disable(); + // individualsControl.controls.is_applicant.setValue(false); + + // .controls.is_active.setValue(false); + + // control.markAsDirty({onlySelf:true}); + + control.removeAt(findex); - let controls = this._generalForm.controls['persons_with_relationships']; - - // console.log('control',control); - let name = details.value.applicant_name; - let index1 = controls.value.map(data => data.applicant_name).indexOf(name); - // let personsWithRelationshipsControl : any = control.controls[index1]; - // personsWithRelationshipsControl.controls.is_applicant.setValue(false); - // control.markAsDirty({onlySelf:true}); - // console.log('control',); - controls.removeAt(index1); + let controls = this._generalForm.controls['persons_with_relationships']; - } + + let name = details.value.applicant_name; + let index1 = controls.value.map(data => data.applicant_name).indexOf(name); + // controls.controls[index1].disable(); + // let personsWithRelationshipsControl : any = control.controls[index1]; + // personsWithRelationshipsControl.controls.is_applicant.setValue(false); + // control.markAsDirty({onlySelf:true}); + + controls.removeAt(index1); + + } // update personal relation updatePersonalRelation(indexVal) { let control: any = this._generalForm.controls['persons_with_relationships']; - control.controls[indexVal].value.relationship==0 ? control.controls[indexVal].controls['relation_to'].setValue('') : control.controls[indexVal].controls['relation_to'].setValue(control.controls[indexVal].value.relation_to); + control.controls[indexVal].value.relationship == 0 ? control.controls[indexVal].controls['relation_to'].setValue('') : control.controls[indexVal].controls['relation_to'].setValue(control.controls[indexVal].value.relation_to); } // update company relation updateCompanyRelation(indexVal) { - let control:any = this._generalForm.controls['company_with_relationships']; - control.controls[indexVal].value.company_relationship==0 ? control.controls[indexVal].controls['relation_to_company'].setValue('') : control.controls[indexVal].controls['relation_to_company'].setValue(control.controls[indexVal].value.relation_to_company); + let control: any = this._generalForm.controls['company_with_relationships']; + control.controls[indexVal].value.company_relationship == 0 ? control.controls[indexVal].controls['relation_to_company'].setValue('') : control.controls[indexVal].controls['relation_to_company'].setValue(control.controls[indexVal].value.relation_to_company); } - /** On Key Press Event For Amount */ - keyPress(event: any) { - const pattern = /[0-9]/; - - let inputChar = String.fromCharCode(event.charCode); - if (event.keyCode != 8 && !pattern.test(inputChar)) { - event.preventDefault(); - } - } - - // convert mkonth to year business has been running - ConvertMonthintoYearforBusiness(e,controlIndex){ - let control: any = this._generalForm.get('companies') as FormArray; - control = control.controls[controlIndex]; - let business_year = control.controls.business_years.value; - - let converted_month : number = e%12; - let converted_year : number = e/12; - - control.controls.business_years.setValue(+business_year + +Math.floor(converted_year)); - control.controls.business_month.setValue(Math.floor(converted_month)); + // submit form details + submitGeneralForm(formData: any) { + if (this._generalForm.invalid) { + this.validateAllFormFields(this._generalForm); + this.notifier.notify('warning', 'Please Fill All Mandatory Fields.!'); + return; + } + // else if(formData.applicant_relation.length==0){ + + // this.notifier.notify('warning', 'Please Choose Name of Person Met.!'); + // } + else { + let saveRecords: any = {} + saveRecords.pdid = formData.pdid; + saveRecords.formid = formData.formid; + saveRecords.individuals = formData.individuals; + saveRecords.companies = formData.companies; + saveRecords.persons_with_relationships = formData.persons_with_relationships; + saveRecords.company_with_relationships = formData.company_with_relationships; + //saveRecords.applicant_relation=formData.applicant_relation; + saveRecords.general_remark = formData.general_remark; + + this._pd.savePDFormDetailsWithID(saveRecords).subscribe( + dataresult => { + if (dataresult.status == 200) { + this.notifier.notify('success', 'Saved Successfully.'); + setTimeout(() => { + this.dialogRef.close(); + }, 3000); + + } + else { + this.notifier.notify('warning', 'Something Wents Wrong Try Again.!'); + // this.errorMessage = "Some Thing Wents Wrong Try Again !"; + } + }, error => { + this.notifier.notify('warning', 'Something Wents Wrong Try Again.!'); + // this.errorMessage = "Something Wents Wrong Try Again !"; + }); + } + } + /**************************** submit form details Ends Here ***********************/ + + /** On Key Press Event For Amount and Number Fields */ + keyPress(event: any) { + const pattern = /[0-9]/; + + let inputChar = String.fromCharCode(event.charCode); + if (event.keyCode != 8 && !pattern.test(inputChar)) { + event.preventDefault(); + } + } + + // convert month to year business has been running + ConvertMonthintoYearforBusiness(e, controlIndex) { + let control: any = this._generalForm.get('companies') as FormArray; + control = control.controls[controlIndex]; + let business_year = control.controls.business_years.value; + + let converted_month: number = e % 12; + let converted_year: number = e / 12; + + control.controls.business_years.setValue(+business_year + +Math.floor(converted_year)); + control.controls.business_month.setValue(Math.floor(converted_month)); + } getDateObjects(values: any, controlIndex) { let control: any = this._generalForm.get('companies') as FormArray; control = control.controls[controlIndex]; - let pd_initiation_date:string = this.pd_all_details.pdmaster_details.pd_date_of_initiation.split('/').reverse().join("/"); - let selected_date = this.pipe.transform(values, 'yyyy/MM/dd'); ; + let pd_initiation_date: string = this.pd_all_details.pdmaster_details.pd_date_of_initiation.split('/').reverse().join("/"); + let selected_date = this.pipe.transform(values, 'yyyy/MM/dd');; let diffInMs: number = Date.parse(pd_initiation_date) - Date.parse(selected_date); let diff: number = Math.floor(diffInMs / 1000); diff /= (60 * 60 * 24 * 30); - diff=Math.abs(Math.round(diff)); + diff = Math.abs(Math.round(diff)); control.controls['business_years'].setValue(0); control.controls['business_month'].setValue(0); - - if(diff){ + + if (diff) { control.controls['business_years'].setValue(Math.floor(diff / 12)); control.controls['business_month'].setValue(Math.floor(diff % 12)); } @@ -559,84 +672,28 @@ export class GeneralInfoComponent implements OnInit { } // check entity type and create other form control - checkEntityType(value,controlIndex) { + checkEntityType(value, controlIndex) { let control: any = this._generalForm.get('companies') as FormArray; control = control.controls[controlIndex]; - value=='1' ? control.addControl('business_entity_type_other', new FormControl('', Validators.required)) : control.removeControl('business_entity_type_other'); + value == '1' ? control.addControl('business_entity_type_other', new FormControl('', Validators.required)) : control.removeControl('business_entity_type_other'); } - // submit form details - submitGeneralForm(formData:any) { - if (this._generalForm.invalid) { - // console.log('if',this._generalForm.value); - this.validateAllFormFields(this._generalForm); - this.notifier.notify('warning', 'Please Fill All Mandatory Fields.!'); - return; - } - // else if(formData.applicant_relation.length==0){ - // console.log('else if',this._generalForm.value); - // this.notifier.notify('warning', 'Please Choose Name of Person Met.!'); - // } - else{ - let saveRecords:any = {} - saveRecords.pdid=formData.pdid; - saveRecords.formid=formData.formid; - saveRecords.individuals=formData.individuals; - saveRecords.companies=formData.companies; - saveRecords.persons_with_relationships=formData.persons_with_relationships; - saveRecords.company_with_relationships=formData.company_with_relationships; - //saveRecords.applicant_relation=formData.applicant_relation; - saveRecords.general_remark=formData.general_remark; - // console.log(saveRecords); - this._pd.savePDFormDetailsWithID(saveRecords).subscribe( - dataresult => { - if (dataresult.status == 200) { - this.notifier.notify('success', 'Saved Successfully.'); - setTimeout(() =>{ - this.dialogRef.close(); - },3000); - - } - else { - this.notifier.notify('warning', 'Something Wents Wrong Try Again.!'); - // this.errorMessage = "Some Thing Wents Wrong Try Again !"; - } - }, error => { - this.notifier.notify('warning', 'Something Wents Wrong Try Again.!'); - // this.errorMessage = "Something Wents Wrong Try Again !"; - }); - } - } - - // 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 6: this.placeholderName[i] = 'Quarterly Instalment Amount'; break; - // case 7: this.placeholderName[i] = 'Halfyearly Instalment Amount'; break; - // default : this.placeholderName[i] = ''; break; - // } - // } - - // validate all form group and form array fields -validateAllFormFields(formGroup: any) { - Object.keys(formGroup.controls).forEach(field => { + + // validate all form group and form array fields + validateAllFormFields(formGroup: any) { + Object.keys(formGroup.controls).forEach(field => { const control = formGroup.get(field); if (control instanceof FormControl) { - control.markAsTouched({ onlySelf: true }); - } else if (control instanceof FormGroup) { - this.validateAllFormFields(control); - } else if (control instanceof FormArray) { - this.validateAllFormFields(control); + control.markAsTouched({ onlySelf: true }); + } else if (control instanceof FormGroup) { + this.validateAllFormFields(control); + } else if (control instanceof FormArray) { + this.validateAllFormFields(control); } - }); -} -} - - + }); + } + /******************* validate all form group and form array fields ENd Here ********/ +} \ No newline at end of file diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/lender-representative/lender-representative.component.ts b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/lender-representative/lender-representative.component.ts index 903eb06ca..f2dc7f4de 100755 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/lender-representative/lender-representative.component.ts +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/lender-representative/lender-representative.component.ts @@ -47,7 +47,7 @@ export class LenderRepresentativeComponent implements OnInit { this.lender_applicant_id = this.pd_all_details.pdmaster_details.lender_applicant_id; this.subproduct_abbr = this.pd_all_details.pdmaster_details.subproduct_abbr; this.customer_segment_abbr = this.pd_all_details.pdmaster_details.customer_segment_abbr; - // console.log(this.main_applicant+','+this.lender_applicant_id+','+this.subproduct_abbr+','+this.customer_segment_abbr); + this.form_id = 15; this.notifier = notifier; } @@ -78,8 +78,6 @@ export class LenderRepresentativeComponent implements OnInit { }; // open() { -// // console.log('hai'); - // const config = new MatSnackBarConfig(); // config.duration = this.autoHide; // config.panelClass = this.addExtraClass ? ['party'] : null; diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/loan-details/loan-details.component.html b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/loan-details/loan-details.component.html index 99c3c1eb7..e848a68bd 100755 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/loan-details/loan-details.component.html +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/loan-details/loan-details.component.html @@ -1,303 +1,390 @@
-

-
- {{main_applicant}} ({{lender_applicant_id}}), {{customer_segment_abbr}} - {{subproduct_abbr}}
- {{pageTitle}} -
-
- -
-

+

+
+ {{main_applicant}} ({{lender_applicant_id}}), {{customer_segment_abbr}} - {{subproduct_abbr}}
+ {{pageTitle}} +
+
+ +
+

+ + - - - - -
-
- - - - - - {{"₹"}} {{loanAmtInWords}} Only - - - - {{ enduse.enduse_of_loan}} - - - - - Yes - No - - - - - - - - - - - {{"₹"}} {{balTxrfAmtInWords}} Only - - - - - {{ btLen.lender_name }} - - - - - - - - - - {{"₹"}} {{topUpAmtInWords}} Only - - - - {{ list.end_use_of_topup }} + + + + + + {{"₹"}} + {{balTxrfAmtInWords}} Only + + + + + {{ + btLen.lender_name }} + + + + + + + + + + {{"₹"}} + {{topUpAmtInWords}} Only + + + + + + {{ + list.end_use_of_topup }} + Child’s Marriage. + Furniture & Finishing of House Property. + Medical Expenses. + Paying Off Existing Loans. + Others. --> - - + + - - - + + + + + + {{"₹"}} + {{ownContributionInWords}} Only + + + + + {{ + sour.name }} + + + + + + + + + + + + - - {{"₹"}} {{ownContributionInWords}} Only + + {{"₹"}} + {{emiAmtInWords}} Only - - - - {{ sour.name }} + + + + + +

Details of Property being Mortgaged

+
+ + + + {{ + typeprop.property_name }} - - - - + + - - - - - - {{"₹"}} {{emiAmtInWords}} Only - - -
- - -

Details of Property being Mortgaged

- - - - {{ typeprop.property_name }} - - - - - - + + + + + {{val.name}} + + + + - - - - - {{val.name}} - - - - - - + - - - - + {{ status.applicant_name }} --> - + + + + + - - - {{ status.name }} - - + - - - {{"₹"}} {{emvAmtInWords}} Only - - - -
-
-
+ + + {{ + status.name }} + + + + + + {{"₹"}} + {{emvAmtInWords}} Only + + + + +
-
-
- - -
-
-
-
-
-
-
Image 1
-
-
-
-
-
-
-
Image 2
-
-
-
-
-
-
-
Image 3
-
-
-
-
-
-
-
Image 2
-
-
-
-
-
-
-
Image 3
-
-
-
-
-
-
-
Image 1
-
-
-
+
+ + + + +
+ - - - + +
+
+ + + - - - + + +
Remarks - - + +
- -
- -
-
- - \ No newline at end of file +
+ +
+
+ + + \ No newline at end of file diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/loan-details/loan-details.component.ts b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/loan-details/loan-details.component.ts index 3bbc9662b..1315da288 100755 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/loan-details/loan-details.component.ts +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/loan-details/loan-details.component.ts @@ -21,7 +21,7 @@ import { } from '@angular/material'; /** Service */ import { PdTrigerService } from '../../../../../pd-service/pd-triger.service'; -import {ActivatedRoute, Router} from '@angular/router'; +import { ActivatedRoute, Router } from '@angular/router'; @Component({ selector: 'app-loan-details', @@ -35,11 +35,11 @@ export class LoanDetailsComponent implements OnInit { main_applicant: any; public loanDetailsForm: FormGroup; private notifier: NotifierService; - - pdid: number; - form_id: number; - exist_loan_amt: any; - + + pdid: number; + form_id: number; + exist_loan_amt: any; + applicants: any; productAbbr: any; productID: any; @@ -48,12 +48,12 @@ export class LoanDetailsComponent implements OnInit { isOtherPurpose: boolean = false; isOtherSource: boolean = false; isPLSource: boolean = false; - mortageCheck : boolean = true; + mortageCheck: boolean = true; isContribution: boolean = false; - OtherOwnerFlag : boolean; + OtherOwnerFlag: boolean; - endUserList: any = []; - sourceList : any = []; + endUserList: any = []; + sourceList: any = []; ownerNames: any = []; m_endUseForLoan = []; m_endUseofLoad = []; @@ -63,75 +63,75 @@ export class LoanDetailsComponent implements OnInit { m_btLenderList = []; m_endUseOFTopUpList = []; // existCompanyList: any =[]; - CompanyApplicantGroupList: any=[]; - CompanyApplicantGroupList2: any=[]; + CompanyApplicantGroupList: any = []; + CompanyApplicantGroupList2: any = []; - mergeCompanyApplicant:any=[]; - existCompanyList:any=[]; - companies:any=[]; - loanAmtInWords : any; - balTxrfAmtInWords : any; - valAsPerAgmtInWords : any; - ownContributionInWords : any; + mergeCompanyApplicant: any = []; + existCompanyList: any = []; + companies: any = []; + loanAmtInWords: any; + balTxrfAmtInWords: any; + valAsPerAgmtInWords: any; + ownContributionInWords: any; topUpAmtInWords: any; - emiAmtInWords : any; - emvAmtInWords : any; - pageTitle: string ="Loan Details"; + emiAmtInWords: any; + emvAmtInWords: any; + pageTitle: string = "Loan Details"; mortageCardAccess: boolean; mortageAccess: boolean = false; - propertyType : any; + propertyType: any; - - constructor(notifier: NotifierService, - private fb: FormBuilder, + + constructor(notifier: NotifierService, + private fb: FormBuilder, private route: ActivatedRoute, private router: Router, private _pd: PdTrigerService, private dialogRef: MatDialogRef, - @Inject(MAT_DIALOG_DATA) public pd_all_details: any) { - - this.applicants = this.pd_all_details.pdapplicants_detials; - // this.applicants.push({'pd_co_applicant_id':'0','applicant_name':'Others'}); - this.applicants = this.applicants.filter(appt=>appt.applicant_type != 2) - // this.companies = this.pd_all_details.pdapplicants_detials.filter(appt=>appt.applicant_type == 2 ) - this.productAbbr = this.pd_all_details.pdmaster_details.product_abbr; - this.productID = this.pd_all_details.pdmaster_details.fk_product_id; - this.subProductName = this.pd_all_details.pdmaster_details.subproduct_name; - this.exist_loan_amt = this.pd_all_details.pdmaster_details.loan_amount != '' ? this.pd_all_details.pdmaster_details.loan_amount :''; - this.loanAmtInWords = this._pd.convertNumberToWords(this.exist_loan_amt); - this.form_id = 10; - this.pdid= this.pd_all_details.pdmaster_details.pd_id; - this.notifier = notifier; - this.main_applicant = this.pd_all_details.pdmaster_details.main_applicant; - this.lender_applicant_id = this.pd_all_details.pdmaster_details.lender_applicant_id; - this.subproduct_abbr = this.pd_all_details.pdmaster_details.subproduct_abbr; - this.customer_segment_abbr = this.pd_all_details.pdmaster_details.customer_segment_abbr; + @Inject(MAT_DIALOG_DATA) public pd_all_details: any) { - if(this.productAbbr == 'PL' || this.productAbbr == 'BL' || this.productAbbr == 'LAP'){ - this.isContribution = true; - } + this.applicants = this.pd_all_details.pdapplicants_detials; + // this.applicants.push({'pd_co_applicant_id':'0','applicant_name':'Others'}); + this.applicants = this.applicants.filter(appt => appt.applicant_type != 2) + // this.companies = this.pd_all_details.pdapplicants_detials.filter(appt=>appt.applicant_type == 2 ) + this.productAbbr = this.pd_all_details.pdmaster_details.product_abbr; + this.productID = this.pd_all_details.pdmaster_details.fk_product_id; + this.subProductName = this.pd_all_details.pdmaster_details.subproduct_name; + this.exist_loan_amt = this.pd_all_details.pdmaster_details.loan_amount != '' ? this.pd_all_details.pdmaster_details.loan_amount : ''; + this.loanAmtInWords = this._pd.convertNumberToWords(this.exist_loan_amt); + this.form_id = 10; + this.pdid = this.pd_all_details.pdmaster_details.pd_id; + this.notifier = notifier; + this.main_applicant = this.pd_all_details.pdmaster_details.main_applicant; + this.lender_applicant_id = this.pd_all_details.pdmaster_details.lender_applicant_id; + this.subproduct_abbr = this.pd_all_details.pdmaster_details.subproduct_abbr; + this.customer_segment_abbr = this.pd_all_details.pdmaster_details.customer_segment_abbr; + + if (this.productAbbr == 'PL' || this.productAbbr == 'BL' || this.productAbbr == 'LAP') { + this.isContribution = true; + } } public viewerOptions: any = { - navbar: false, - toolbar: { - zoomIn: 4, - zoomOut: 4, - oneToOne: 4, - reset: 4, - prev: 4, - play: { - show: 4, - size: 'large', - }, - next: 4, - rotateLeft: 4, - rotateRight: 4, - flipHorizontal: 4, - flipVertical: 4, - } -}; - ngOnInit() { + navbar: false, + toolbar: { + zoomIn: 4, + zoomOut: 4, + oneToOne: 4, + reset: 4, + prev: 4, + play: { + show: 4, + size: 'large', + }, + next: 4, + rotateLeft: 4, + rotateRight: 4, + flipHorizontal: 4, + flipVertical: 4, + } + }; + ngOnInit() { this.initloanDetailsForm(); this.getM_EndUseofLoad(); this.getM_EndUseForLoan(this.pdid); @@ -141,58 +141,58 @@ export class LoanDetailsComponent implements OnInit { this.getM_BTLenderList(); this.getM_EndUseofTopUpList(); - this._pd.getCompaniesListsForBusiness(this.pdid).subscribe(data=>{ - if(data.dataStatus){ - this.existCompanyList = data.records.filter(val =>val.is_active===true && val.is_company_applicant===true); + this._pd.getCompaniesListsForBusiness(this.pdid).subscribe(data => { + if (data.dataStatus) { + this.existCompanyList = data.records.filter(val => val.is_active === true && val.is_company_applicant === true); } - 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 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.listOfLanguagues.splice(this.listOfLanguagues.indexOf(languague), 1); + + 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.listOfLanguagues.splice(this.listOfLanguagues.indexOf(languague), 1); } - if(this.productAbbr != 'LAP'){ - this.mergeCompanyApplicant.push({groupName:'OTHERS',groupValues:[{id:0,name:'Not Yet Finalised',group_id:2}]}) + if (this.productAbbr != 'LAP') { + this.mergeCompanyApplicant.push({ groupName: 'OTHERS', groupValues: [{ id: 0, name: 'Not Yet Finalised', group_id: 2 }] }) } }) - + let params: any = {}; params.pd_id = this.pdid; params.pd_form_id = this.form_id; this._pd.retriveForm(params).subscribe(value => { // *ngIf="productAbbr === 'HL' || productAbbr === 'LL' || productAbbr === 'LAP' " if (value.status == 200) { - let result = Object.keys(value.records.end_use_group).map(function(key) { + let result = Object.keys(value.records.end_use_group).map(function (key) { return value.records.end_use_group[key]; }); let ownername: any = []; - if(value.records.owner_name_group != null){ - let owner = Object.keys(value.records.owner_name_group).map(function(key) { + if (value.records.owner_name_group != null) { + let owner = Object.keys(value.records.owner_name_group).map(function (key) { return value.records.owner_name_group[key]; }); - - owner.forEach(val => { - ownername.push(val.owner_name); - if(val.owner_name == 'Others'){ - this.OtherOwnerFlag = true; - } - else{ - this.OtherOwnerFlag = false; - } - }); + + owner.forEach(val => { + ownername.push(val.owner_name); + if (val.owner_name == 'Others') { + this.OtherOwnerFlag = true; + } + else { + this.OtherOwnerFlag = false; + } + }); } let enduse: any = []; @@ -202,13 +202,13 @@ export class LoanDetailsComponent implements OnInit { this.loanDetailsForm.controls['end_use'].setValue(enduse); this.endUserChange(enduse); - - - - this.loanDetailsForm.controls['loan_amount'].setValue(value.records.loan_amount); - if(value.records.loan_amount){ this.loanAmtInWords = this._pd.convertNumberToWords(value.records.loan_amount); } - + + + this.loanDetailsForm.controls['loan_amount'].setValue(value.records.loan_amount); + if (value.records.loan_amount) { this.loanAmtInWords = this._pd.convertNumberToWords(value.records.loan_amount); } + + if (value.records.end_use_other != null) { this.loanDetailsForm.controls['end_use_other'].setValue(value.records.end_use_other); } @@ -216,256 +216,256 @@ export class LoanDetailsComponent implements OnInit { // this.loanDetailsForm.controls['is_topup'].setValue(value.records.is_topup); if (value.records.balance_transfer_amount) { this.loanDetailsForm.controls['balance_transfer_amount'].setValue(value.records.balance_transfer_amount); - this.balTxrfAmtInWords = this._pd.convertNumberToWords(value.records.balance_transfer_amount); + this.balTxrfAmtInWords = this._pd.convertNumberToWords(value.records.balance_transfer_amount); } if (value.records.topup_amount) { this.loanDetailsForm.controls['topup_amount'].setValue(value.records.topup_amount); - this.topUpAmtInWords = this._pd.convertNumberToWords(value.records.topup_amount); - if(value.records.topup_amount > 0){ + this.topUpAmtInWords = this._pd.convertNumberToWords(value.records.topup_amount); + if (value.records.topup_amount > 0) { this.loanDetailsForm.controls['end_use_topup'].setValue(value.records.end_use_topup); if (value.records.end_use_topup == 1) { this.loanDetailsForm.controls['other_end_use_topup'].setValue(value.records.other_end_use_topup); } - } + } } - - + + if (value.records.lender) { this.loanDetailsForm.controls['lender'].setValue(value.records.lender); } if (value.records.other_bt_lender) { this.loanDetailsForm.controls['other_bt_lender'].setValue(value.records.other_bt_lender); } - if((this.isContribution == true) && (value.records.is_transfer != 'yes')){ + if ((this.isContribution == true) && (value.records.is_transfer != 'yes')) { this.loanDetailsForm.controls['own_contribution'].setValue(''); this.loanDetailsForm.controls['other_source'].setValue(''); this.loanDetailsForm.controls['source'].setValue(''); } - else{ - if(this.isContribution == false && value.records.is_transfer != 'yes'){ + else { + if (this.isContribution == false && value.records.is_transfer != 'yes') { - let source = Object.keys(value.records.source_group).map(function(key) { + let source = Object.keys(value.records.source_group).map(function (key) { return value.records.source_group[key]; }); - - - let dbsourcelist : any = []; + + + let dbsourcelist: any = []; source.forEach(val => { dbsourcelist.push(val.sources); }); - + this.loanDetailsForm.controls['own_contribution'].setValue(value.records.own_contribution); - if(value.records.own_contribution){ this.ownContributionInWords = this._pd.convertNumberToWords(value.records.own_contribution); } - + if (value.records.own_contribution) { this.ownContributionInWords = this._pd.convertNumberToWords(value.records.own_contribution); } + this.loanDetailsForm.controls['source'].setValue(dbsourcelist); this.sourceChange(dbsourcelist); - - if(value.records.other_source) { + + if (value.records.other_source) { // this.isOtherSource = true; this.loanDetailsForm.controls['other_source'].setValue(value.records.other_source); } - + // if(value.records.personal_loan_source) { // // this.isPLSource = true; // this.loanDetailsForm.controls['personal_loan_source'].setValue(value.records.personal_loan_source); // } } } - + // if (value.records.lender_name_type) { // this.loanDetailsForm.controls['lender_name_type'].setValue(value.records.lender_name_type); // } - if(value.records.emi_level){ + if (value.records.emi_level) { this.loanDetailsForm.controls['emi_level'].setValue(value.records.emi_level); - this.emiAmtInWords = this._pd.convertNumberToWords(value.records.emi_level); + this.emiAmtInWords = this._pd.convertNumberToWords(value.records.emi_level); } this.loanDetailsForm.controls['property_type'].setValue(value.records.property_type); this.propertyType = value.records.property_type; - - if(this.propertyType != null){ - this.mortage_type(this.propertyType); - } - - if(this.mortageCardAccess == true){ - this.loanDetailsForm.controls['property_type_others'].setValue(value.records.property_type_others); - this.loanDetailsForm.controls['owner_name'].setValue(ownername); - // this.loanDetailsForm.controls['other_owners_name'].setValue(value.records.other_owners_name); - this.loanDetailsForm.controls['construction_status'].setValue(value.records.construction_status); - // if(value.records.construction_status == 4 ){ - // this.loanDetailsForm.controls['percentage_of_construction'].setValue(value.records.percentage_of_construction); - // } - // else{ - // this.loanDetailsForm.controls['percentage_of_construction'].setValue(''); - // } - if(value.records.emv_per_customer != ''){ - this.loanDetailsForm.controls['emv_per_customer'].setValue(value.records.emv_per_customer); - this.emvAmtInWords = this._pd.convertNumberToWords(value.records.emv_per_customer); + if (this.propertyType != null) { + this.mortage_type(this.propertyType); } + if (this.mortageCardAccess == true) { + this.loanDetailsForm.controls['property_type_others'].setValue(value.records.property_type_others); + this.loanDetailsForm.controls['owner_name'].setValue(ownername); + // this.loanDetailsForm.controls['other_owners_name'].setValue(value.records.other_owners_name); + this.loanDetailsForm.controls['construction_status'].setValue(value.records.construction_status); + + // if(value.records.construction_status == 4 ){ + // this.loanDetailsForm.controls['percentage_of_construction'].setValue(value.records.percentage_of_construction); + // } + // else{ + // this.loanDetailsForm.controls['percentage_of_construction'].setValue(''); + // } + if (value.records.emv_per_customer != '') { + this.loanDetailsForm.controls['emv_per_customer'].setValue(value.records.emv_per_customer); + this.emvAmtInWords = this._pd.convertNumberToWords(value.records.emv_per_customer); + } + } - - - + + + // this.loanDetailsForm.controls['value_per_agreement'].setValue(value.records.value_per_agreement); // if(value.records.value_per_agreement){ this.valAsPerAgmtInWords = this._pd.convertNumberToWords(value.records.value_per_agreement); } this.loanDetailsForm.controls['loandetails_remarks'].setValue(value.records.loandetails_remarks); } }) - if(this.productAbbr == 'BL' || this.productAbbr == 'PL' || this.productAbbr == 'LL'){ + if (this.productAbbr == 'BL' || this.productAbbr == 'PL' || this.productAbbr == 'LL') { this.mortageCardAccess = false; this.loanDetailsForm.controls['owner_name'].setValue(''); this.loanDetailsForm.controls['owner_name'].clearValidators(); this.loanDetailsForm.controls['owner_name'].updateValueAndValidity(); - - }else{ + + } else { this.mortageCardAccess = true; this.loanDetailsForm.controls['owner_name'].setValidators([Validators.required]); this.loanDetailsForm.controls['owner_name'].updateValueAndValidity(); - + } } -// ============= + // ============= - getM_EndUseofLoad() { - //this._pd.getAllMasterDatas('ENDUSEOFLOAN').subscribe( + getM_EndUseofLoad() { + //this._pd.getAllMasterDatas('ENDUSEOFLOAN').subscribe( this._pd.getAllMasterDatas('SUBPRODUCTS').subscribe( - data => { - this.m_endUseofLoad = data.records.filter(data => data.isactive == 1 && data.fk_product_id == this.productID); - }, - error => { - // this.notifier.notify('warning', 'No Category Records Found.!'); - // this.m_assets_type = "No Category Records Found."; - } - ) - } - getM_EndUseForLoan(pdid) { - this._pd.getEndUseForLoan(pdid).subscribe( - data => { - this.m_endUseForLoan = data.records.filter(data => data.isactive == 1); - }, - error => { - // this.notifier.notify('warning', 'No Category Records Found.!'); - // this.m_assets_type = "No Category Records Found."; - } - ) - } - -getM_sourceofamount() { - this._pd.getAllMasterDatas('SOURCEOFBALANCETRANSFER').subscribe( - data => { - this.m_sourceofamount = data.records.filter(data => data.isactive == 1); - }, - error => { - // this.notifier.notify('warning', 'No Category Records Found.!'); - // this.m_assets_type = "No Category Records Found."; - } - ) - } - - getM_MortageTypeProperty() { - this._pd.getAllMasterDatas('MORTAGEPROPERTIES').subscribe( - data => { - if(data.dataStatus==true){ - let that = this; - this.m_mortageTypeProperty = data.records.filter( - function(data){ - - if(that.productAbbr != "LAP"){ - - if(data.group_name == that.productAbbr && data.isactive==1){ - return data; - } + data => { + this.m_endUseofLoad = data.records.filter(data => data.isactive == 1 && data.fk_product_id == this.productID); + }, + error => { + // this.notifier.notify('warning', 'No Category Records Found.!'); + // this.m_assets_type = "No Category Records Found."; } - else if(that.productAbbr == "LAP"){ - - if(data.group_name == that.productAbbr && data.sub_group_name == that.subProductName && data.isactive==1){ - - return data; - } - else if(data.group_name == that.productAbbr && data.sub_group_name != null && data.isactive==1) { - - return data; - } + ) + } + getM_EndUseForLoan(pdid) { + this._pd.getEndUseForLoan(pdid).subscribe( + data => { + this.m_endUseForLoan = data.records.filter(data => data.isactive == 1); + }, + error => { + // this.notifier.notify('warning', 'No Category Records Found.!'); + // this.m_assets_type = "No Category Records Found."; } - }); - this.m_mortageTypeProperty - // mortage_property_id">{{ typeprop.property_name - + ) + } + + getM_sourceofamount() { + this._pd.getAllMasterDatas('SOURCEOFBALANCETRANSFER').subscribe( + data => { + this.m_sourceofamount = data.records.filter(data => data.isactive == 1); + }, + error => { + // this.notifier.notify('warning', 'No Category Records Found.!'); + // this.m_assets_type = "No Category Records Found."; + } + ) + } + + getM_MortageTypeProperty() { + this._pd.getAllMasterDatas('MORTAGEPROPERTIES').subscribe( + data => { + if (data.dataStatus == true) { + let that = this; + this.m_mortageTypeProperty = data.records.filter( + function (data) { + + if (that.productAbbr != "LAP") { + + if (data.group_name == that.productAbbr && data.isactive == 1) { + return data; + } + } + else if (that.productAbbr == "LAP") { + + if (data.group_name == that.productAbbr && data.sub_group_name == that.subProductName && data.isactive == 1) { + + return data; + } + else if (data.group_name == that.productAbbr && data.sub_group_name != null && data.isactive == 1) { + + return data; + } + } + }); + this.m_mortageTypeProperty + // mortage_property_id">{{ typeprop.property_name + + } + }, + error => { + // this.notifier.notify('warning', 'No Category Records Found.!'); + // this.m_assets_type = "No Category Records Found."; + } + ) + } + + getM_StatusofCunstruction() { + this._pd.getAllMasterDatas('STATUSOFCONSTRUCTION').subscribe( + data => { + this.m_statusofCunstruction = data.records.filter(data => data.isactive == 1); + }, + error => { + // this.notifier.notify('warning', 'No Category Records Found.!'); + // this.m_assets_type = "No Category Records Found."; + } + ) + } + + getM_BTLenderList() { + this._pd.getAllMasterDatas('BTLENDERLIST').subscribe( + data => { + this.m_btLenderList = data.records.filter(data => data.isactive == 1); + // this.m_btLenderList = this.m_btLenderList.sort((a, b) => { + // if (a.lender_name > b.lender_name) { + // return 1; + // } + // if (a.lender_name < b.lender_name) { + // return -1; + // } + // return 0; + // }); + }) + } + + + getM_EndUseofTopUpList() { + this._pd.getAllMasterDatas('ENDUSEOFTOPUP').subscribe( + data => { + this.m_endUseOFTopUpList = data.records.filter(data => data.is_active == 1); + }) + } + + + + + // 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; } - }, - error => { - // this.notifier.notify('warning', 'No Category Records Found.!'); - // this.m_assets_type = "No Category Records Found."; - } - ) - } - getM_StatusofCunstruction() { - this._pd.getAllMasterDatas('STATUSOFCONSTRUCTION').subscribe( - data => { - this.m_statusofCunstruction = data.records.filter(data => data.isactive == 1); - }, - error => { - // this.notifier.notify('warning', 'No Category Records Found.!'); - // this.m_assets_type = "No Category Records Found."; - } - ) - } - - getM_BTLenderList(){ - this._pd.getAllMasterDatas('BTLENDERLIST').subscribe( - data => { - this.m_btLenderList = data.records.filter(data => data.isactive == 1); - // this.m_btLenderList = this.m_btLenderList.sort((a, b) => { - // if (a.lender_name > b.lender_name) { - // return 1; - // } - // if (a.lender_name < b.lender_name) { - // return -1; - // } - // return 0; - // }); - }) - } - - - getM_EndUseofTopUpList(){ - this._pd.getAllMasterDatas('ENDUSEOFTOPUP').subscribe( - data => { - this.m_endUseOFTopUpList = data.records.filter(data => data.is_active == 1); - }) - } - - - - -// 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; - } - - } -// ================== + // ================== public initloanDetailsForm(): void { this.loanDetailsForm = this.fb.group({ @@ -476,18 +476,18 @@ getM_sourceofamount() { //is_topup: [''], balance_transfer_amount: [''], topup_amount: [''], - end_use_topup:[''], - other_end_use_topup:[''], + end_use_topup: [''], + other_end_use_topup: [''], lender: [''], - other_bt_lender : [''], + other_bt_lender: [''], own_contribution: [''], source: [''], - other_source:[''], + other_source: [''], // personal_loan_source:[''], //lender_name_type: [''], emi_level: [''], property_type: [''], - property_type_others:[''], + property_type_others: [''], owner_name: [''], // other_owners_name :[''], construction_status: [''], @@ -511,22 +511,21 @@ getM_sourceofamount() { this.endUserList = []; let OthersAvaliable; event.forEach(option => { - // let othersData = this.m_endUseofLoad.filter(sub=>sub.subproduct_id==option)[0]; - let othersData = this.m_endUseForLoan.filter(sub=>sub.enduse_of_loan_id==option)[0]; - - OthersAvaliable = othersData.enduse_of_loan.substr(0,6).toLowerCase(); - - this.endUserList.push({ end_use: option }); + // let othersData = this.m_endUseofLoad.filter(sub=>sub.subproduct_id==option)[0]; + let othersData = this.m_endUseForLoan.filter(sub => sub.enduse_of_loan_id == option)[0]; + + OthersAvaliable = othersData.enduse_of_loan.substr(0, 6).toLowerCase(); + + this.endUserList.push({ end_use: option }); }); - if(OthersAvaliable == 'others') { + if (OthersAvaliable == 'others') { this.isOtherPurpose = true; this.loanDetailsForm.controls['end_use_other'].setValidators([Validators.required]); - - }else - { + + } else { this.loanDetailsForm.controls['end_use_other'].clearValidators(); - this.isOtherPurpose = false; + this.isOtherPurpose = false; } this.loanDetailsForm.controls['end_use_other'].updateValueAndValidity(); //this.isOtherPurpose = event.some(e => e == 'others') // this return true or false Only; @@ -534,67 +533,79 @@ getM_sourceofamount() { sourceChange(evt) { - - + + // this.isOtherSource = (evt.some(e => e == 4) == true) ? true : false ; // this.isPLSource = (evt.some(e => e == 3) == true) ? true : false ; this.isOtherSource = evt.some(e => e == 1) // this return true or false Only; // this.isPLSource = evt.some(e => e == 3) // this return true or false Only; - if(this.isOtherSource){ - this.loanDetailsForm.controls['other_source'].setValidators([Validators.required]); - this.loanDetailsForm.controls['other_source'].updateValueAndValidity(); - }else{ - this.loanDetailsForm.controls['other_source'].clearValidators(); - this.loanDetailsForm.controls['other_source'].updateValueAndValidity(); - } + if (this.isOtherSource) { + this.loanDetailsForm.controls['other_source'].setValidators([Validators.required]); + this.loanDetailsForm.controls['other_source'].updateValueAndValidity(); + } else { + this.loanDetailsForm.controls['other_source'].clearValidators(); + this.loanDetailsForm.controls['other_source'].updateValueAndValidity(); + } this.sourceList = []; evt.forEach(option => { - this.sourceList.push({source: option}); - }); + this.sourceList.push({ source: option }); + }); } ownerNameChange(event) { let EventValue; event.value.forEach(option => { EventValue = option; - if(EventValue == 'Others'){ + if (EventValue == 'Others') { this.OtherOwnerFlag = true; } - else{ + else { this.OtherOwnerFlag = false; } }); - + // this.ownerNames = []; // event.value.forEach(option => { // this.ownerNames.push({owner_name: option}); // }); } submitLoanDetails() { - - if(this.loanDetailsForm.controls['lender'].value == 1){ + + if ((this.isContribution == true) && (this.loanDetailsForm.controls['is_transfer'].value != 'yes')) { + this.loanDetailsForm.controls['own_contribution'].setValue(''); + this.loanDetailsForm.controls['own_contribution'].clearValidators(); + this.loanDetailsForm.controls['own_contribution'].updateValueAndValidity(); + this.loanDetailsForm.controls['other_source'].setValue(''); + this.loanDetailsForm.controls['other_source'].clearValidators(); + this.loanDetailsForm.controls['other_source'].updateValueAndValidity(); + this.loanDetailsForm.controls['source'].setValue(''); + this.loanDetailsForm.controls['source'].clearValidators(); + this.loanDetailsForm.controls['source'].updateValueAndValidity(); + } + + if (this.loanDetailsForm.controls['lender'].value == 1) { this.loanDetailsForm.controls['other_bt_lender'].setValidators([Validators.required]); this.loanDetailsForm.controls['other_bt_lender'].updateValueAndValidity(); } - else{ + else { this.loanDetailsForm.controls['other_bt_lender'].clearValidators(); this.loanDetailsForm.controls['other_bt_lender'].updateValueAndValidity(); } - if(this.loanDetailsForm.controls['end_use_topup'].value == 1){ + if (this.loanDetailsForm.controls['end_use_topup'].value == 1) { this.loanDetailsForm.controls['other_end_use_topup'].setValidators([Validators.required]); this.loanDetailsForm.controls['other_end_use_topup'].updateValueAndValidity(); } - else{ + else { this.loanDetailsForm.controls['other_end_use_topup'].clearValidators(); this.loanDetailsForm.controls['other_end_use_topup'].updateValueAndValidity(); } - + if (!this.loanDetailsForm.valid) { - this.notifier.notify('warning', 'Please Fill All Mandatory Fields.!'); - return; + this.notifier.notify('warning', 'Please Fill All Mandatory Fields.!'); + return; } let records: any = {}; @@ -602,85 +613,85 @@ getM_sourceofamount() { records.formid = this.form_id; records.fk_createdby = this.pdid; records.loan_amount = this.loanDetailsForm.controls['loan_amount'].value; - + // get end user final group data let dataEnd_user_data = []; this.loanDetailsForm.controls['end_use'].value.forEach(element => { - dataEnd_user_data.push({end_use: element}) + dataEnd_user_data.push({ end_use: element }) }); records.end_use_group = dataEnd_user_data; if (this.isOtherPurpose) { - records.end_use_other = this.loanDetailsForm.controls['end_use_other'].value; - }else{ records.end_use_other = null ;} + records.end_use_other = this.loanDetailsForm.controls['end_use_other'].value; + } else { records.end_use_other = null; } records.is_transfer = this.loanDetailsForm.controls['is_transfer'].value; // records.is_topup = this.loanDetailsForm.controls['is_topup'].value; // if((this.productAbbr != 'PL' || this.productAbbr != 'BL' || this.productAbbr != 'LAP') && (value.records.is_transfer != 'yes')){ if (this.loanDetailsForm.controls['is_transfer'].value == 'yes') { - records.balance_transfer_amount = this.loanDetailsForm.controls['balance_transfer_amount'].value; + records.balance_transfer_amount = this.loanDetailsForm.controls['balance_transfer_amount'].value; } - else if(this.loanDetailsForm.controls['is_transfer'].value == 'no'){ - if(this.isContribution){ + else if (this.loanDetailsForm.controls['is_transfer'].value == 'no') { + if (this.isContribution) { records.own_contribution = ''; - records.source_group = '' ; + records.source_group = ''; records.other_source = ''; } - else{ + else { records.own_contribution = this.loanDetailsForm.controls['own_contribution'].value; - // records.source = this.loanDetailsForm.controls['source'].value; - // if (this.loanDetailsForm.controls['source'].value == 'other') { - // records.lender_name_type = this.loanDetailsForm.controls['lender_name_type'].value; - // } - // if (this.loanDetailsForm.controls['source'].value == 4) { - // records.other_source = this.loanDetailsForm.controls['other_source'].value; - // } + // records.source = this.loanDetailsForm.controls['source'].value; + // if (this.loanDetailsForm.controls['source'].value == 'other') { + // records.lender_name_type = this.loanDetailsForm.controls['lender_name_type'].value; + // } + // if (this.loanDetailsForm.controls['source'].value == 4) { + // records.other_source = this.loanDetailsForm.controls['other_source'].value; + // } - let dataSource_list = []; - this.loanDetailsForm.controls['source'].value.forEach(element => { - dataSource_list.push({sources: element}) - }); - records.source_group = dataSource_list; + let dataSource_list = []; + this.loanDetailsForm.controls['source'].value.forEach(element => { + dataSource_list.push({ sources: element }) + }); + records.source_group = dataSource_list; - + + } } - } // if (this.loanDetailsForm.controls['is_topup'].value == 'yes') { - records.topup_amount = this.loanDetailsForm.controls['topup_amount'].value; + records.topup_amount = this.loanDetailsForm.controls['topup_amount'].value; // } - if(records.topup_amount > 0){ + if (records.topup_amount > 0) { records.end_use_topup = this.loanDetailsForm.controls['end_use_topup'].value; - if(records.end_use_topup == 1){ + if (records.end_use_topup == 1) { records.other_end_use_topup = this.loanDetailsForm.controls['other_end_use_topup'].value; } } - - + + if (this.loanDetailsForm.controls['is_transfer'].value == 'yes') { //this.loanDetailsForm.controls['is_topup'].value == 'yes' || records.lender = this.loanDetailsForm.controls['lender'].value; - if(this.loanDetailsForm.controls['lender'].value == 1){ + if (this.loanDetailsForm.controls['lender'].value == 1) { records.other_bt_lender = this.loanDetailsForm.controls['other_bt_lender'].value; } } - + records.emi_level = this.loanDetailsForm.controls['emi_level'].value; - if(this.mortageCardAccess == true){ + if (this.mortageCardAccess == true) { records.property_type = this.loanDetailsForm.controls['property_type'].value; records.property_type_others = this.loanDetailsForm.controls['property_type_others'].value; let dataOwner_name = []; this.loanDetailsForm.controls['owner_name'].value.forEach(element => { - dataOwner_name.push({owner_name: element}) - }); - records.owner_name_group = dataOwner_name; - records.construction_status = this.loanDetailsForm.controls['construction_status'].value; - records.emv_per_customer = this.loanDetailsForm.controls['emv_per_customer'].value; - }else{ + dataOwner_name.push({ owner_name: element }) + }); + records.owner_name_group = dataOwner_name; + records.construction_status = this.loanDetailsForm.controls['construction_status'].value; + records.emv_per_customer = this.loanDetailsForm.controls['emv_per_customer'].value; + } else { records.property_type = null; records.property_type_others = null; records.owner_name_group = null; @@ -688,23 +699,23 @@ getM_sourceofamount() { records.emv_per_customer = null; } - if(this.isOtherSource){ + if (this.isOtherSource) { records.other_source = this.loanDetailsForm.controls['other_source'].value; - }else{ records.other_source = ''; } + } else { records.other_source = ''; } records.emv_per_customer = this.loanDetailsForm.controls['emv_per_customer'].value; - + records.loandetails_remarks = this.loanDetailsForm.controls['loandetails_remarks'].value; this._pd.saveForm(records).subscribe(data => { - if(data.status == 200) { + if (data.status == 200) { this.notifier.notify('success', 'Saved Successfully.'); // this.dialogRef.close(); - setTimeout(() =>{ + setTimeout(() => { this.dialogRef.close(); - },3000); + }, 3000); } - else{ - this.notifier.notify('warning', 'Something Wents Wrong Try Again.!'); + else { + this.notifier.notify('warning', 'Something Wents Wrong Try Again.!'); } }, error => { this.notifier.notify('warning', 'Something Wents Wrong Try Again.!'); @@ -715,26 +726,26 @@ getM_sourceofamount() { Object.keys(formGroup.controls).forEach(field => { const control = formGroup.get(field); if (control instanceof FormControl) { - control.markAsTouched({onlySelf: true}); + control.markAsTouched({ onlySelf: true }); } else if (control instanceof FormGroup) { this.validateAllFormFields(control); } }); } - selectedBalancesTransferChanges(event: any){ - - if(event.value == 'no') { + selectedBalancesTransferChanges(event: any) { + + if (event.value == 'no') { // this.loanDetailsForm.controls['is_topup'].clearValidators(); // this.loanDetailsForm.controls['is_topup'].updateValueAndValidity(); - + this.loanDetailsForm.controls['source'].setValidators([Validators.required]); this.loanDetailsForm.controls['source'].updateValueAndValidity(); this.loanDetailsForm.controls['own_contribution'].setValidators([Validators.required]); this.loanDetailsForm.controls['own_contribution'].updateValueAndValidity(); } - else if(event.value == 'yes'){ + else if (event.value == 'yes') { // this.loanDetailsForm.controls['is_topup'].setValidators([Validators.required]); // this.loanDetailsForm.controls['is_topup'].updateValueAndValidity(); @@ -743,40 +754,40 @@ getM_sourceofamount() { this.loanDetailsForm.controls['own_contribution'].clearValidators(); this.loanDetailsForm.controls['own_contribution'].updateValueAndValidity(); - + } } - /** On Key Press Event For Amount */ - keyPress(event: any) { + /** On Key Press Event For Amount */ + keyPress(event: any) { const pattern = /[0-9]/; - + let inputChar = String.fromCharCode(event.charCode); if (event.keyCode != 8 && !pattern.test(inputChar)) { - event.preventDefault(); + event.preventDefault(); } - } - + } + /** To Convert Amount into Words */ - inWords(e,flag:number){ - switch(flag){ - case 1 : - this.loanAmtInWords = this._pd.convertNumberToWords(e.target.value); + inWords(e, flag: number) { + switch (flag) { + case 1: + this.loanAmtInWords = this._pd.convertNumberToWords(e.target.value); break; - case 2 : - this.balTxrfAmtInWords = this._pd.convertNumberToWords(e.target.value); + case 2: + this.balTxrfAmtInWords = this._pd.convertNumberToWords(e.target.value); break; - case 3 : - this.valAsPerAgmtInWords = this._pd.convertNumberToWords(e.target.value); + case 3: + this.valAsPerAgmtInWords = this._pd.convertNumberToWords(e.target.value); break; - case 4 : - this.ownContributionInWords = this._pd.convertNumberToWords(e.target.value); + case 4: + this.ownContributionInWords = this._pd.convertNumberToWords(e.target.value); break; - case 5 : - this.topUpAmtInWords = this._pd.convertNumberToWords(e.target.value); + case 5: + this.topUpAmtInWords = this._pd.convertNumberToWords(e.target.value); break; - case 6 : + case 6: this.emiAmtInWords = this._pd.convertNumberToWords(e.target.value); break; case 7: @@ -784,52 +795,49 @@ getM_sourceofamount() { break; default: break; - } } + } /** * mortage_type */ - mortage_type(mortage_value) - { - - //let mortagetypes = this.m_mortageTypeProperty.filter(mor=>mor.mortage_property_id==mortage_value)[0]; - let mortagetypes = this.m_mortageTypeProperty.filter(mor=>mor.mortage_property_id == mortage_value)[0]; - - if(mortagetypes.property_name=='Others (Please Specify)'){ - this.mortageAccess = true; - this.loanDetailsForm.controls['property_type_others'].setValidators([Validators.required]); - this.loanDetailsForm.controls['property_type_others'].updateValueAndValidity(); - }else{ - this.mortageAccess = false; - this.loanDetailsForm.controls['property_type_others'].clearValidators(); - this.loanDetailsForm.controls['property_type_others'].updateValueAndValidity(); - } - } + mortage_type(mortage_value) { - /** - * LoanCalculation - */ - loanCalc() - { - let BtAmount : number = +this.loanDetailsForm.value.balance_transfer_amount; - let loanAmount : number = +this.loanDetailsForm.value.loan_amount; - let topupAmt ; - if(BtAmount !=null && loanAmount !=null) - { - if(loanAmount >= BtAmount){ - topupAmt = loanAmount - BtAmount; - this.loanDetailsForm.controls['topup_amount'].setValue(topupAmt); - this.topUpAmtInWords = this._pd.convertNumberToWords(topupAmt); - } - else{ - this.notifier.notify('warning', 'Balances Transfer Amount is greater than Loan Amount Please check.!'); - this.loanDetailsForm.controls['balance_transfer_amount'].setValue(''); - this.balTxrfAmtInWords = ''; - this.loanDetailsForm.controls['topup_amount'].setValue(''); - this.topUpAmtInWords = ''; - } - } - } + //let mortagetypes = this.m_mortageTypeProperty.filter(mor=>mor.mortage_property_id==mortage_value)[0]; + let mortagetypes = this.m_mortageTypeProperty.filter(mor => mor.mortage_property_id == mortage_value)[0]; + + if (mortagetypes.property_name == 'Others (Please Specify)') { + this.mortageAccess = true; + this.loanDetailsForm.controls['property_type_others'].setValidators([Validators.required]); + this.loanDetailsForm.controls['property_type_others'].updateValueAndValidity(); + } else { + this.mortageAccess = false; + this.loanDetailsForm.controls['property_type_others'].clearValidators(); + this.loanDetailsForm.controls['property_type_others'].updateValueAndValidity(); + } + } + + /** + * LoanCalculation + */ + loanCalc() { + let BtAmount: number = +this.loanDetailsForm.value.balance_transfer_amount; + let loanAmount: number = +this.loanDetailsForm.value.loan_amount; + let topupAmt; + if (BtAmount != null && loanAmount != null) { + if (loanAmount >= BtAmount) { + topupAmt = loanAmount - BtAmount; + this.loanDetailsForm.controls['topup_amount'].setValue(topupAmt); + this.topUpAmtInWords = this._pd.convertNumberToWords(topupAmt); + } + else { + this.notifier.notify('warning', 'Balances Transfer Amount is greater than Loan Amount Please check.!'); + this.loanDetailsForm.controls['balance_transfer_amount'].setValue(''); + this.balTxrfAmtInWords = ''; + this.loanDetailsForm.controls['topup_amount'].setValue(''); + this.topUpAmtInWords = ''; + } + } + } } \ No newline at end of file diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/personal-info/personal-info.component.ts b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/personal-info/personal-info.component.ts index 90b5cc027..c06d1da6a 100755 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/personal-info/personal-info.component.ts +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/personal-info/personal-info.component.ts @@ -101,7 +101,7 @@ public viewerOptions: any = { this.getMasterDetails('EDUQUALIFICATION',3); this.getMasterDetails('NONINDIVIDUALENTITIES',4); this.mainApplicantDetails = this.pd_all_details.pdapplicants_detials.filter(item => item.applicant_type == 1); - // console.log(this.mainApplicantDetails) + this.coApplicantDetails = this.pd_all_details.pdapplicants_detials.filter(item => item.applicant_type == 0); } @@ -414,13 +414,10 @@ validateAllFormFields(formGroup: any) { // selectedAccTypeChanges(event: any){ -// console.log('First Time',event); -// console.log('First Time Value',event.value); + // if(event.value == 2) { // const control = this.bankingForm.controls['itemRows']; -// console.log('Inside If Condition'); -// console.log(control); -// console.log(control.controls); + // control.controls[0].get('limit').clearValidators(); // control.controls[0].get('limit').updateValueAndValidity(); @@ -430,7 +427,7 @@ validateAllFormFields(formGroup: any) { // // this.bankingForm.controls.get('limit').clearValidators(); // // this.bankingForm.controls.itemRows['controls'].get('limit').updateValueAndValidity(); // // const control = this.bankingForm.controls['itemRows']; -// // console.log(control.controls['limit'].value); + // } // else{ diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/rental-info/rental-info.component.ts b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/rental-info/rental-info.component.ts index 7e9d3ea84..1e8866ba7 100755 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/rental-info/rental-info.component.ts +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/rental-info/rental-info.component.ts @@ -87,13 +87,13 @@ export class RentalInfoComponent implements OnInit { control.push(this.createpropertyArray()); const parentControl = this.rentalForm.controls['rental_home']['controls'][index]; const sub = parentControl.controls['details_tenants']; - console.log('control', parentControl); + // console.log('control', parentControl); subArray = Object.keys(datas.details_tenants).map(function (key) { return datas.details_tenants[key]; }); if (subArray.length > 0) { subArray.forEach((val) => { - console.log('val', val); + // console.log('val', val); sub.push(this.createTenatsArray()); }) sub.removeAt(0); @@ -176,8 +176,8 @@ export class RentalInfoComponent implements OnInit { addTenant(parentIndex:number) { const parentControl = this.rentalForm.controls['rental_home']['controls'][parentIndex]; const control = parentControl.controls['details_tenants']; - console.log(parentControl); - console.log(control); + // console.log(parentControl); + // console.log(control); control.push(this.createTenatsArray()); }