Ri changes
This commit is contained in:
parent
fd69b0bfd4
commit
9da5f83517
@ -261,15 +261,14 @@
|
||||
<div fxLayout="row wrap" class="align-margin" *ngFor="let fUnits of floor.controls.floor_unit_details['controls']; let fu=index;" [formGroupName]="fu">
|
||||
<mat-form-field style="width:46%" appearance="outline">
|
||||
<mat-label>Rent per Unit</mat-label>
|
||||
<input OnlyNumber matInput autocomplete="off" placeholder="" formControlName="rent_per_unit" (keyup)="calculateSameRentAmt(floor.value,f)" required>
|
||||
<input OnlyNumber matInput autocomplete="off" placeholder="" formControlName="rent_per_unit" (keyup)="calculateFloorRentAmt(floor.value,f)" required>
|
||||
<mat-hint align="start" style="font-size:90%" *ngIf="fUnits.value.rent_per_unit != ''">{{"₹"}} {{fUnits.value.rent_per_unit | numberToWords}} Only</mat-hint>
|
||||
|
||||
</mat-form-field>
|
||||
<mat-form-field style="width:46%" appearance="outline">
|
||||
<mat-label>Amount</mat-label>
|
||||
<input OnlyNumber matInput autocomplete="off" placeholder="" formControlName="amount" readonly required>
|
||||
<mat-label>Total Rent Amount</mat-label>
|
||||
<input OnlyNumber matInput autocomplete="off" placeholder="" formControlName="amount" readonly>
|
||||
<mat-hint align="start" style="font-size:90%" *ngIf="fUnits.value.amount != ''">{{"₹"}} {{fUnits.value.amount | numberToWords}} Only</mat-hint>
|
||||
|
||||
</mat-form-field>
|
||||
</div>
|
||||
</div>
|
||||
@ -280,18 +279,27 @@
|
||||
<div class="rent-unit" fxFlex.xs="100" fxFlex.sm="45" fxFlex.md="45" fxFlex.lg="45" fxFlex.xl="45" *ngFor="let fUnits of floor.controls.floor_unit_details['controls']; let fu=index;" [formGroupName]="fu">
|
||||
<mat-form-field style="width:100%" appearance="outline">
|
||||
<mat-label>Rent Unit {{fu+1}} </mat-label>
|
||||
<input OnlyNumber matInput autocomplete="off" placeholder="" formControlName="amount" required>
|
||||
<mat-hint align="start" style="font-size:90%" *ngIf="fUnits.value.amount != ''">{{"₹"}} {{fUnits.value.amount | numberToWords}} Only</mat-hint>
|
||||
<input OnlyNumber matInput autocomplete="off" placeholder="" formControlName="rent_per_unit" (keyup)="calculateFloorRentAmt(floor.value,f)" required>
|
||||
<mat-hint align="start" style="font-size:90%" *ngIf="fUnits.value.rent_per_unit != ''">{{"₹"}} {{fUnits.value.rent_per_unit | numberToWords}} Only</mat-hint>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
</div>
|
||||
</ng-container>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- end floor unit array details-->
|
||||
|
||||
</mat-card-content>
|
||||
<mat-card-actions *ngIf="floor.value.unit_rent_difference_options==0">
|
||||
<div fxFlex="100" class="total-rent-amt">
|
||||
<mat-form-field style="width:96%" appearance="outline">
|
||||
<mat-label>Total Rent Amount</mat-label>
|
||||
<input OnlyNumber matInput autocomplete="off" placeholder="" formControlName="floor_rent_amount" readonly>
|
||||
<mat-hint align="start" style="font-size:90%" *ngIf="floor.value.floor_rent_amount != ''">{{"₹"}} {{floor.value.floor_rent_amount | numberToWords}} Only</mat-hint>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
|
||||
</mat-card-actions>
|
||||
</mat-card>
|
||||
</ng-container>
|
||||
<!-- end floor details -->
|
||||
|
||||
@ -14,4 +14,8 @@
|
||||
}
|
||||
.rent-unit {
|
||||
margin-left: 2%;
|
||||
margin-top: 1%;
|
||||
}
|
||||
.total-rent-amt{
|
||||
margin-left: 2%;
|
||||
}
|
||||
|
||||
@ -719,6 +719,7 @@ createFloorDetails(details){
|
||||
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{
|
||||
@ -727,6 +728,7 @@ createFloorDetails(details){
|
||||
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: [''],
|
||||
});
|
||||
}
|
||||
|
||||
@ -758,13 +760,14 @@ generateFloorUnit(values:any, index:number){
|
||||
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.calculateSameRentAmt(control.value,index);
|
||||
this.calculateFloorRentAmt(values,index);
|
||||
}
|
||||
else {
|
||||
control.controls = [];
|
||||
@ -778,27 +781,43 @@ createFloorUnitDetails(type:number){
|
||||
if(type==1){
|
||||
return this._fb.group({
|
||||
rent_per_unit: ['', Validators.compose([Validators.required])],
|
||||
amount: ['', Validators.compose([Validators.required])],
|
||||
amount: [''],
|
||||
});
|
||||
}
|
||||
else if(type==2){
|
||||
return this._fb.group({
|
||||
amount: ['', Validators.compose([Validators.required])],
|
||||
rent_per_unit: ['', Validators.compose([Validators.required])],
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
// calculate same rent amount
|
||||
calculateSameRentAmt(values: any, index: number){
|
||||
calculateFloorRentAmt(values: any, index: number){
|
||||
if(values.unit_rent_difference_options=="1"){
|
||||
let control: any = <FormArray>this._rentalForm.controls['multistoried_building_details'];
|
||||
control = control.controls[index];
|
||||
control= <FormArray> control.controls['floor_unit_details'];
|
||||
if(control.value[control.value.length-1].rent_per_unit>0 && values.no_units_in_floor>0){
|
||||
control.controls[control.value.length-1].controls['amount'].setValue(control.value[control.value.length-1].rent_per_unit * values.no_units_in_floor);
|
||||
let unitcontrol = control.controls[index];
|
||||
unitcontrol= <FormArray> 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{
|
||||
control.controls[control.value.length-1].controls['amount'].setValue('');
|
||||
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 = <FormArray>this._rentalForm.controls['multistoried_building_details'];
|
||||
let unitcontrol = control.controls[index];
|
||||
unitcontrol= <FormArray> 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('');
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user