From 6e0381cfcb8ce94dc50758f65114af2f4dd3823e Mon Sep 17 00:00:00 2001 From: "venbatechnologies@gmail.com" Date: Tue, 26 Mar 2019 14:42:18 +0530 Subject: [PATCH] merge : ps --- .../rental-verification.component.html | 112 +++++++++- .../rental-verification.component.scss | 11 +- .../rental-verification.component.ts | 211 ++++++++++++++---- 3 files changed, 281 insertions(+), 53 deletions(-) diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/rental-verification/rental-verification.component.html b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/rental-verification/rental-verification.component.html index 4f8281d89..d9454d6b6 100644 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/rental-verification/rental-verification.component.html +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/rental-verification/rental-verification.component.html @@ -178,7 +178,7 @@ - + Type of Units as per Loan Applicants @@ -193,19 +193,117 @@ Specify Other Unit Type - - No of Floors - - - + Tot No of Units - + + No of Floors + + + + + Total Area Given on Rent + + + + + + + Unit of Measurement + + + {{unitM.name}} + + + + + + Other Unit of Measurement + + + + + + + + + + + Floor Level Name + + + + + + No of Units + + + + Is Rent Same for All Units + + Yes + No + + + + + +
+ + +
+
+ + Rent per Unit + + {{"₹"}} {{fUnits.value.rent_per_unit | numberToWords}} Only + + + + Total Rent Amount + + {{"₹"}} {{fUnits.value.amount | numberToWords}} Only + +
+
+
+ + +
+
+ + Rent Unit {{fu+1}} + + {{"₹"}} {{fUnits.value.rent_per_unit | numberToWords}} Only + +
+
+
+
+ + + +
+ +
+ + Total Rent Amount + + {{"₹"}} {{floor.value.floor_rent_amount | numberToWords}} Only + +
+ +
+
+
+ + diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/rental-verification/rental-verification.component.scss b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/rental-verification/rental-verification.component.scss index 2fd9cea87..13b8a16c4 100644 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/rental-verification/rental-verification.component.scss +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/rental-verification/rental-verification.component.scss @@ -9,6 +9,13 @@ justify-content: center !important; } .align-margin { - margin-left: 4%; - margin-right: 4%; + margin-left: 2%; + margin-right: 2%; +} +.rent-unit { + margin-left: 2%; + margin-top: 1%; +} +.total-rent-amt{ + margin-left: 1%; } diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/rental-verification/rental-verification.component.ts b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/rental-verification/rental-verification.component.ts index 27fef38fe..8b191e58a 100644 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/rental-verification/rental-verification.component.ts +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/rental-verification/rental-verification.component.ts @@ -152,9 +152,13 @@ export class RentalVerificationComponent implements OnInit { }); // observe unit type changes - this._rentalForm.controls['unit_type'].valueChanges.subscribe(val => { + this._rentalForm.controls['unit_type'].valueChanges.subscribe(val => { val.id==1 ? this._rentalForm.addControl('other_unit_type', new FormControl('', Validators.required)) : this._rentalForm.removeControl('other_unit_type'); - val.group_id==1 && val.id==7 ? this._rentalForm.addControl('no_floor', new FormControl('')) : val.group_id==2 && val.id==7 ? this._rentalForm.addControl('no_floor', new FormControl('')) : this._rentalForm.removeControl('no_floor'); + val.group_id==1 && val.id==6 ? this._rentalForm.removeControl('no_units') : val.group_id==2 && val.id==7 ? this._rentalForm.removeControl('no_units') : this._rentalForm.addControl('no_units', new FormControl('')); + val.group_id==1 && val.id==6 ? this._rentalForm.addControl('no_floor', new FormControl('',Validators.required)) : val.group_id==2 && val.id==7 ? this._rentalForm.addControl('no_floor', new FormControl('',Validators.required)) : this._rentalForm.removeControl('no_floor'); + val.group_id==1 && val.id==6 ? this._rentalForm.addControl('multistoried_total_area', new FormControl('',Validators.required)) : val.group_id==2 && val.id==7 ? this._rentalForm.addControl('multistoried_total_area', new FormControl('',Validators.required)) : this._rentalForm.removeControl('multistoried_total_area'); + val.group_id==1 && val.id==6 ? this._rentalForm.addControl('multistoried_uom', new FormControl('',Validators.required)) : val.group_id==2 && val.id==7 ? this._rentalForm.addControl('multistoried_uom', new FormControl('',Validators.required)) : this._rentalForm.removeControl('multistoried_uom'); + val.group_id==1 && val.id==6 ? '' : val.group_id==2 && val.id==7 ? '' : this._rentalForm.setControl('multistoried_building_details', this._fb.array([])); }); // observe visit address @@ -206,6 +210,7 @@ export class RentalVerificationComponent implements OnInit { nature_property: ['',Validators.required], unit_type:['',Validators.required], no_units:[''], + multistoried_building_details: this._fb.array([]), property_unit_details : this._fb.array([]), done_third_party_check :['',Validators.required], rental_remark: [''], @@ -267,7 +272,24 @@ loadFormData(){ rentalVal.formid = this.form_id; rentalVal.other_name_person_type ? this._rentalForm.addControl('other_name_person_type', new FormControl('', Validators.required)): this._rentalForm.removeControl('other_name_person_type'); rentalVal.other_sighted_documents ? this._rentalForm.addControl('other_sighted_documents', new FormControl('', Validators.required)) : this._rentalForm.removeControl('other_sighted_documents'); - + + //get Multistoried Building Details + if(data.records.multistoried_building_details){ + let selectedMultistoriedBuilding = Object.keys(data.records.multistoried_building_details).map(function (key) { + return data.records.multistoried_building_details[key]; + }); + if(selectedMultistoriedBuilding.length>0){ + let control: any = this._rentalForm.controls['multistoried_building_details']; + selectedMultistoriedBuilding.forEach((floorElement,floorIndex)=>{ + control.push(this.createFloorDetails('')); + let unitControl = control.controls[floorIndex]; + unitControl= unitControl.controls['floor_unit_details']; + floorElement.floor_unit_details.forEach((unitElement,unitIndex) => { + floorElement.unit_rent_difference_options=="0" ? unitControl.push(this.createFloorUnitDetails(2)) : unitControl.push(this.createFloorUnitDetails(1)); + }); + }); + } + } // get property unit details if(data.records.property_unit_details){ let selectedUnitDetails = Object.keys(data.records.property_unit_details).map(function (key) { @@ -439,6 +461,10 @@ generateTenantOptions(value:any,index:number){ value.unit_measurement.id=="1" ? control.controls[index].addControl('other_unit_measurement', new FormControl('', Validators.required)) : control.controls[index].removeControl('other_unit_measurement'); } +// generate multistoried other uom +generateMultistoriedOtherUOM(value: any){ + value.multistoried_uom.id=="1" ? this._rentalForm.addControl('multistoried_other_uom', new FormControl('', Validators.required)) : this._rentalForm.removeControl('multistoried_other_uom'); +} // generate Rent AgreementSeen generateRentAgreementSeen(value: any,index:number){ let control: any = this._rentalForm.controls['property_unit_details']; @@ -657,50 +683,147 @@ else { } // generate floor rows -// generateFloor(e:any): void{ -// let control = this._rentalForm.controls['floor_details']; -// if(e.target.value && Math.round(e.target.value)!=0){ +generateFloor(e:any): void{ + let control = this._rentalForm.controls['multistoried_building_details']; + if(e.target.value && Math.round(e.target.value)!=0){ -// if(Math.round(e.target.value) > this._rentalForm.value.floor_details.length){ -// let rowValue = Math.round(e.target.value)-this._rentalForm.value.floor_details.length; -// for(let i=rowValue;i>0;i--){ -// control.push(this.createFloorDetails('')); -// } -// } -// else if(Math.round(e.target.value) < this._rentalForm.value.floor_details.length){ -// let rowValue = this._rentalForm.value.floor_details.length-Math.round(e.target.value); -// for(let i=rowValue;i>0;i--){ -// control.removeAt(this._rentalForm.value.floor_details.length-1); -// } -// } -// } -// else if(e.target.value && Math.round(e.target.value)==0){ -// control.controls = []; -// control.setValue([]); -// } -// else{ -// control.controls = []; -// control.setValue([]); -// } -// e.stopPropagation(); -// } + if(Math.round(e.target.value) > this._rentalForm.value.multistoried_building_details.length){ + let rowValue = Math.round(e.target.value)-this._rentalForm.value.multistoried_building_details.length; + for(let i=rowValue;i>0;i--){ + control.push(this.createFloorDetails('')); + } + } + else if(Math.round(e.target.value) < this._rentalForm.value.multistoried_building_details.length){ + let rowValue = this._rentalForm.value.multistoried_building_details.length-Math.round(e.target.value); + for(let i=rowValue;i>0;i--){ + control.removeAt(this._rentalForm.value.multistoried_building_details.length-1); + } + } + } + else if(e.target.value && Math.round(e.target.value)==0){ + control.controls = []; + control.setValue([]); + } + else{ + control.controls = []; + control.setValue([]); + } + e.stopPropagation(); +} // create floor details -// createFloorDetails(details){ -// if(details){ -// return this._fb.group({ -// floor_level: [this._rentalForm.value.floor_details.length==0 ? 'Ground Floor' : this._rentalForm.value.floor_details.length+' Floor', Validators.compose([Validators.required])], -// no_units_on_floor: ['', Validators.compose([Validators.required])], -// }); -// } -// else{ -// return this._fb.group({ -// floor_level: [this._rentalForm.value.floor_details.length==0 ? 'Ground Floor' : this._rentalForm.value.floor_details.length+' Floor', Validators.compose([Validators.required])], -// no_units_in_floor: ['', Validators.compose([Validators.required])], -// }); -// } - -// } +createFloorDetails(details){ + if(details){ + return this._fb.group({ + floor_level: [this._rentalForm.value.multistoried_building_details.length==0 ? 'Ground Floor' : this._rentalForm.value.multistoried_building_details.length+' Floor', Validators.compose([Validators.required])], + no_units_in_floor: ['', Validators.compose([Validators.required])], + unit_rent_difference_options : ['', Validators.compose([Validators.required])], + floor_unit_details : this._fb.array([]), + floor_rent_amount: [''], + }); + } + else{ + return this._fb.group({ + floor_level: [this._rentalForm.value.multistoried_building_details.length==0 ? 'Ground Floor' : this._rentalForm.value.multistoried_building_details.length+' Floor', Validators.compose([Validators.required])], + no_units_in_floor: ['', Validators.compose([Validators.required])], + unit_rent_difference_options : ['', Validators.compose([Validators.required])], + floor_unit_details : this._fb.array([]), + floor_rent_amount: [''], + }); + } + +} + +// generate floor unit details +generateFloorUnit(values:any, index:number){ + let control: any = this._rentalForm.controls['multistoried_building_details']; + control = control.controls[index]; + control= control.controls['floor_unit_details']; + if(values.no_units_in_floor>0 && values.unit_rent_difference_options=="0"){ + if(Math.round(values.no_units_in_floor) > control.value.length){ + let rowValue = Math.round(values.no_units_in_floor)-control.value.length; + for(let i=rowValue;i>0;i--){ + control.push(this.createFloorUnitDetails(2)); + } + } + else if(Math.round(values.no_units_in_floor) < control.value.length){ + let rowValue = control.value.length-Math.round(values.no_units_in_floor); + for(let i=rowValue;i>0;i--){ + control.removeAt(control.value.length-1); + } + } + else if(Math.round(values.no_units_in_floor)==0){ + control.controls = []; + control.setValue([]); + } + else{ + control.controls = []; + control.setValue([]); + } + this.calculateFloorRentAmt(values,index); + + } + else if(values.no_units_in_floor>0 && values.unit_rent_difference_options=="1") { + control.controls = []; + control.setValue([]); + control.push(this.createFloorUnitDetails(1)); + this.calculateFloorRentAmt(values,index); + } + else { + control.controls = []; + control.setValue([]); + } + +} + +// create floor unit details +createFloorUnitDetails(type:number){ + if(type==1){ + return this._fb.group({ + rent_per_unit: ['', Validators.compose([Validators.required])], + amount: [''], + }); + } + else if(type==2){ + return this._fb.group({ + rent_per_unit: ['', Validators.compose([Validators.required])], + }); + } + +} +// calculate same rent amount +calculateFloorRentAmt(values: any, index: number){ + if(values.unit_rent_difference_options=="1"){ + let control: any = this._rentalForm.controls['multistoried_building_details']; + let unitcontrol = control.controls[index]; + unitcontrol= unitcontrol.controls['floor_unit_details']; + if(unitcontrol.value[unitcontrol.value.length-1].rent_per_unit>0 && values.no_units_in_floor>0){ + unitcontrol.controls[unitcontrol.value.length-1].controls['amount'].setValue(unitcontrol.value[unitcontrol.value.length-1].rent_per_unit * values.no_units_in_floor); + control.controls[index].controls['floor_rent_amount'].setValue(unitcontrol.value[unitcontrol.value.length-1].rent_per_unit * values.no_units_in_floor); + } + else{ + unitcontrol.controls[unitcontrol.value.length-1].controls['amount'].setValue(''); + control.controls[index].controls['floor_rent_amount'].setValue(''); + + } + } + else if(values.unit_rent_difference_options=="0"){ + let control: any = this._rentalForm.controls['multistoried_building_details']; + let unitcontrol = control.controls[index]; + unitcontrol= unitcontrol.controls['floor_unit_details']; + // console.log(unitcontrol) + let getunitValues = unitcontrol.value.filter(val=>val.rent_per_unit!=''); + if(getunitValues.length>0){ + control.controls[index].controls['floor_rent_amount'].setValue(getunitValues.map(mval=>mval.rent_per_unit).reduce((acc, val) => Number(acc) + Number(val), 0)); + } + else{ + control.controls[index].controls['floor_rent_amount'].setValue(''); + + } + } + +} + // compare objects for merge two master table details compareObjects(o1: any, o2: any) { if(o1.id == o2.id && o1.group_id == o2.group_id)