From cc226275b8dc04aa6768c90bc6d8263b9a8d5ac8 Mon Sep 17 00:00:00 2001 From: "venbatechnologies@gmail.com" Date: Fri, 8 Mar 2019 14:53:12 +0530 Subject: [PATCH] changes:ps --- .../edit-pd-master.component.ts | 3 +- .../general-info/general-info.component.html | 30 +++- .../general-info/general-info.component.ts | 140 ++++++++++++------ 3 files changed, 122 insertions(+), 51 deletions(-) diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/edit-pd-master/edit-pd-master.component.ts b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/edit-pd-master/edit-pd-master.component.ts index 0c4cb638d..8b262d4df 100755 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/edit-pd-master/edit-pd-master.component.ts +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/edit-pd-master/edit-pd-master.component.ts @@ -231,7 +231,8 @@ export class EditPdMasterComponent implements OnInit { this.customerSegmentList=this.customerSegmentAllList; } else if(productID == '4'){ - this.customerSegmentList=this.customerSegmentAllList.filter(s => (s.customer_segment).includes('Self')); + let filtered = this.customerSegmentAllList.filter(s => (s.customer_segment).includes('Self')); + this.customerSegmentList = filtered; } } 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 d4f878cd9..69e5101f0 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 @@ -2,7 +2,7 @@

- {{main_applicant}} ({{lender_applicant_id}}), {{customer_segment_abbr}} - {{subproduct_abbr}}
+ {{main_applicant}} ({{lender_applicant_id}}), {{customer_segment_abbr}} - {{subproduct_abbr}}
{{pageTitle}}
@@ -96,8 +96,23 @@ + + + Number of Years for which rental income is being received + + + Please Enter Correct Year + + + + + + + - + Company/Firm @@ -118,20 +133,19 @@ - +

Number of Years For Which The Business Has Been Running

- + Please Enter Correct Year + autocomplete="off" OnlyNumber type="text" (change)="ConvertMonthintoYearforBusiness($event.target.value,c,1)"> - + Relationship of Individuals to Company / Firm 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 3ed3dc937..f901f5362 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 @@ -125,6 +125,8 @@ export class GeneralInfoComponent implements OnInit { companies: this._fb.array([]), persons_with_relationships: this._fb.array([]), company_with_relationships: this._fb.array([]), + rental_income_rcv_in_years: '', + rental_income_rcv_in_month: '', general_remark: '' }) this.loadFormData(); @@ -213,42 +215,53 @@ export class GeneralInfoComponent implements OnInit { return data.records.company_with_relationships[key]; }); + if(this.customer_segment_abbr != 'SE-RI'){ - 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()); - } + 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) { - 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() : ''; - } + // create companies + 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() : ''; + } - }); + }); + } + + this._generalForm.controls['rental_income_rcv_in_years'].setValue(null); + this._generalForm.controls['rental_income_rcv_in_month'].setValue(null); } + else if(this.customer_segment_abbr == 'SE-RI'){ + // companyWithRelationshipsControl.push(this.createCompaniesRelationship()); + // companyControl.push(this.createCompanies('')); + this._generalForm.controls['rental_income_rcv_in_years'].setValue(data.records.rental_income_rcv_in_years ? data.records.rental_income_rcv_in_years : ''); + this._generalForm.controls['rental_income_rcv_in_month'].setValue(data.records.rental_income_rcv_in_month ? data.records.rental_income_rcv_in_month : ''); + } // create relations // exist_relation = Object.keys(data.records.applicant_relation).map(function(key) { // return data.records.applicant_relation[key]; @@ -589,6 +602,27 @@ export class GeneralInfoComponent implements OnInit { // submit form details submitGeneralForm(formData: any) { + + if(this.customer_segment_abbr != 'SE-RI'){ + this._generalForm.controls['rental_income_rcv_in_years'].clearValidators(); + this._generalForm.controls['rental_income_rcv_in_years'].updateValueAndValidity(); + } + // 0th index of companies formArray only - required removed + // greater than zero means not applicable here + if(this.customer_segment_abbr == 'SE-RI'){ + let otherControl: any = this._generalForm.get('companies') as FormArray; + otherControl = otherControl.controls[0]; + // otherControl.controls.business_entity_type_other.clearValidators(); + // otherControl.controls.business_entity_type_other.updateValueAndValidity(); + + otherControl.controls.business_years.clearValidators(); + otherControl.controls.business_years.updateValueAndValidity(); + + otherControl.controls.business_entity_type.clearValidators(); + otherControl.controls.business_entity_type.updateValueAndValidity(); + + } + if (this._generalForm.invalid) { this.disableAfterSubmit = false; this.validateAllFormFields(this._generalForm); @@ -605,12 +639,26 @@ export class GeneralInfoComponent implements OnInit { 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; + if(this.customer_segment_abbr != 'SE-RI'){ + saveRecords.companies = formData.companies; + saveRecords.company_with_relationships = formData.company_with_relationships; + saveRecords.rental_income_rcv_in_years = null; + saveRecords.rental_income_rcv_in_month = null; + //saveRecords.applicant_relation=formData.applicant_relation; + } + else if(this.customer_segment_abbr == 'SE-RI'){ + saveRecords.companies = []; + saveRecords.company_with_relationships = []; + saveRecords.rental_income_rcv_in_years = formData.rental_income_rcv_in_years; + saveRecords.rental_income_rcv_in_month = formData.rental_income_rcv_in_month; + //saveRecords.applicant_relation=formData.applicant_relation; + } + saveRecords.general_remark = formData.general_remark; + // console.log('saveRecords',saveRecords); + // return; this._pd.savePDFormDetailsWithID(saveRecords).subscribe( dataresult => { if (dataresult.status == 200) { @@ -635,16 +683,24 @@ export class GeneralInfoComponent implements OnInit { /**************************** submit form details Ends Here ***********************/ // 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; + ConvertMonthintoYearforBusiness(e, controlIndex,flag) { - let converted_month: number = e % 12; - let converted_year: number = e / 12; + 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)); + if(flag == 1){ + let control: any = this._generalForm.get('companies') as FormArray; + control = control.controls[controlIndex]; + let business_year = control.controls.business_years.value; + control.controls.business_years.setValue(+business_year + +Math.floor(converted_year)); + control.controls.business_month.setValue(Math.floor(converted_month)); + } + + if(flag == 2){ + let ri_year = this._generalForm.controls.rental_income_rcv_in_years.value; + this._generalForm.controls['rental_income_rcv_in_years'].setValue(+ri_year + +Math.floor(converted_year)); + this._generalForm.controls['rental_income_rcv_in_month'].setValue(Math.floor(converted_month)); + } }