issues fixes : ps
This commit is contained in:
parent
c0394be0db
commit
92a089ce51
@ -192,12 +192,14 @@
|
||||
formControlName="amount_paid_through_bank" OnlyNumber type="text" autocomplete="off" (change)="ValidateNetSalary()">
|
||||
<mat-hint align="start" style="font-size:90%" *ngIf="employmentForm.controls['amount_paid_through_bank'].value != ''">{{"₹"}} {{employmentForm.controls['amount_paid_through_bank'].value | numberToWords}} Only</mat-hint>
|
||||
<mat-error *ngIf="employmentForm.controls.amount_paid_through_bank.hasError('max')">Given Value is More than Net Salary</mat-error>
|
||||
<mat-error *ngIf="employmentForm.controls.amount_paid_through_bank.hasError('min')">Given Value is Less than Net Salary</mat-error>
|
||||
</mat-form-field>
|
||||
<mat-form-field style="width: 33%">
|
||||
<input matInput placeholder="Amount paid in Cash"
|
||||
formControlName="amount_paid_in_cash" OnlyNumber type="text" autocomplete="off" (change)="ValidateNetSalary()">
|
||||
<mat-hint align="start" style="font-size:90%" *ngIf="employmentForm.controls['amount_paid_in_cash'].value != ''">{{"₹"}} {{employmentForm.controls['amount_paid_in_cash'].value | numberToWords}} Only</mat-hint>
|
||||
<mat-error *ngIf="employmentForm.controls.amount_paid_in_cash.hasError('max')">Given Value is More than Net Salary</mat-error>
|
||||
<mat-error *ngIf="employmentForm.controls.amount_paid_in_cash.hasError('min')">Given Value is Less than Net Salary</mat-error>
|
||||
</mat-form-field>
|
||||
<mat-form-field style="width: 33%" *ngIf="employmentForm.controls['amount_paid_in_cash'].value != '' && employmentForm.controls['amount_paid_in_cash'].value != 0">
|
||||
<mat-select placeholder="Is the Amount is Validated or Not" formControlName="check_validated">
|
||||
|
||||
@ -305,16 +305,16 @@ export class EmploymentInfoComponent implements OnInit {
|
||||
// let cash_amount = this.employmentForm.controls['amount_paid_in_cash'].value;
|
||||
let bank_amount = this.employmentForm.controls['amount_paid_through_bank'].value;
|
||||
|
||||
this.employmentForm.controls['amount_paid_through_bank'].setValidators([Validators.max(salary)]);
|
||||
this.employmentForm.controls['amount_paid_through_bank'].setValidators([Validators.max(salary),Validators.min(0)]);
|
||||
this.employmentForm.controls['amount_paid_through_bank'].updateValueAndValidity();
|
||||
let maxamt = salary-bank_amount
|
||||
if(maxamt >= 0 ){
|
||||
this.employmentForm.controls['amount_paid_in_cash'].setValue(maxamt);
|
||||
this.employmentForm.controls['amount_paid_in_cash'].setValidators([Validators.max(salary-bank_amount)]);
|
||||
let Remainamt = salary-bank_amount
|
||||
if(Remainamt >= 0 ){
|
||||
this.employmentForm.controls['amount_paid_in_cash'].setValue(Remainamt);
|
||||
this.employmentForm.controls['amount_paid_in_cash'].setValidators([Validators.max(salary-bank_amount),Validators.min(salary-bank_amount)]);
|
||||
}
|
||||
else{
|
||||
this.employmentForm.controls['amount_paid_in_cash'].setValue('0');
|
||||
this.employmentForm.controls['amount_paid_in_cash'].setValidators([Validators.max(0)]);
|
||||
this.employmentForm.controls['amount_paid_in_cash'].setValidators([Validators.max(0),Validators.min(0)]);
|
||||
}
|
||||
this.employmentForm.controls['amount_paid_in_cash'].updateValueAndValidity();
|
||||
|
||||
|
||||
@ -358,7 +358,7 @@ export class GeneralInfoComponent implements OnInit {
|
||||
createCompanies(elementValue: any) {
|
||||
return this._fb.group({
|
||||
company_order_id: [elementValue.company_order_id],
|
||||
company_name: [elementValue.company_name,],
|
||||
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],
|
||||
@ -603,28 +603,38 @@ export class GeneralInfoComponent implements OnInit {
|
||||
// submit form details
|
||||
temp: number = 0;
|
||||
submitGeneralForm(formData: any) {
|
||||
|
||||
console.log('formData',formData);
|
||||
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
|
||||
// SE-RI means Companies Control Required Removed.
|
||||
if (this.customer_segment_abbr == 'SE-RI') {
|
||||
let otherControl: any = this._generalForm.get('companies') as FormArray;
|
||||
if (otherControl.controls.length > 0) {
|
||||
otherControl = otherControl.controls[0];
|
||||
// otherControl.controls.business_entity_type_other.clearValidators();
|
||||
// otherControl.controls.business_entity_type_other.updateValueAndValidity();
|
||||
let CompanyCtrl: any = this._generalForm.get('companies') as FormArray;
|
||||
let CompanyCtrlLength : any = CompanyCtrl.controls.length;
|
||||
if (CompanyCtrlLength > 0) {
|
||||
let cnt = 0;
|
||||
while(cnt < CompanyCtrlLength){
|
||||
|
||||
otherControl.controls.business_years.clearValidators();
|
||||
otherControl.controls.business_years.updateValueAndValidity();
|
||||
let CompanyChildCtrl : any = CompanyCtrl.controls[cnt];
|
||||
|
||||
otherControl.controls.business_entity_type.clearValidators();
|
||||
otherControl.controls.business_entity_type.updateValueAndValidity();
|
||||
CompanyChildCtrl.controls.company_name.clearValidators();
|
||||
CompanyChildCtrl.controls.company_name.updateValueAndValidity();
|
||||
|
||||
CompanyChildCtrl.controls.business_entity_type.clearValidators();
|
||||
CompanyChildCtrl.controls.business_entity_type.updateValueAndValidity();
|
||||
|
||||
// CompanyChildCtrl.controls.business_entity_type_other.clearValidators();
|
||||
// CompanyChildCtrl.controls.business_entity_type_other.updateValueAndValidity();
|
||||
|
||||
CompanyChildCtrl.controls.business_years.clearValidators();
|
||||
CompanyChildCtrl.controls.business_years.updateValueAndValidity();
|
||||
|
||||
cnt++;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
if (this._generalForm.invalid) {
|
||||
this.disableAfterSubmit = false;
|
||||
this.validateAllFormFields(this._generalForm);
|
||||
|
||||
@ -349,17 +349,24 @@
|
||||
</mat-option>
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
|
||||
<mat-form-field style="width:29%;" appearance="outline" *ngIf="units.controls['amount_received_bank']">
|
||||
<mat-label>Amount Received in Bank</mat-label>
|
||||
<input matInput OnlyNumber autocomplete="off" placeholder="" formControlName="amount_received_bank" (keyup)="ValidatedRentAmount(units.value,u,1)" required>
|
||||
<mat-hint align="start" style="font-size:90%" *ngIf="units.value.amount_received_bank != ''">{{"₹"}} {{units.value.amount_received_bank | numberToWords}} Only</mat-hint>
|
||||
<mat-error *ngIf="units.controls['amount_received_bank'].hasError('max')">Given Value Is More Than Rent Amount</mat-error>
|
||||
<mat-error *ngIf="units.controls['amount_received_bank'].hasError('min')">Given Value Is Less Than Rent Amount</mat-error>
|
||||
</mat-form-field>
|
||||
|
||||
<mat-form-field style="width:29%;" appearance="outline" *ngIf="units.controls['amount_received_cash']">
|
||||
<mat-label>Amount Received in Cash</mat-label>
|
||||
<input matInput OnlyNumber autocomplete="off" placeholder="" formControlName="amount_received_cash" required>
|
||||
<mat-hint align="start" style="font-size:90%" *ngIf="units.value.amount_received_cash != ''">{{"₹"}} {{units.value.amount_received_cash | numberToWords}} Only</mat-hint>
|
||||
<mat-error *ngIf="units.controls['amount_received_cash'].hasError('max')">Given Value Is More Than Rent Amount</mat-error>
|
||||
<mat-error *ngIf="units.controls['amount_received_cash'].hasError('min')">Given Value Is Less Than Rent Amount</mat-error>
|
||||
</mat-form-field>
|
||||
|
||||
<mat-form-field style="width:29%;" appearance="outline" *ngIf="units.controls['amount_received_bank']">
|
||||
<mat-label>Amount Received in Bank</mat-label>
|
||||
<input matInput OnlyNumber autocomplete="off" placeholder="" formControlName="amount_received_bank" required>
|
||||
<mat-hint align="start" style="font-size:90%" *ngIf="units.value.amount_received_bank != ''">{{"₹"}} {{units.value.amount_received_bank | numberToWords}} Only</mat-hint>
|
||||
</mat-form-field>
|
||||
|
||||
<mat-form-field style="width:30%;" appearance="outline" *ngIf="units.controls['payment_received_reason']">
|
||||
<mat-label>Reason for Receiving Multiple Payment Mode</mat-label>
|
||||
<textarea matInput placeholder="" formControlName="payment_received_reason" required></textarea>
|
||||
@ -587,25 +594,30 @@
|
||||
</mat-option>
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
<mat-form-field style="width:29%;" appearance="outline" *ngIf="units.controls['amount_received_bank_per_met']">
|
||||
<mat-label>Amount Paid in Bank</mat-label>
|
||||
<input matInput OnlyNumber autocomplete="off" placeholder="" formControlName="amount_received_bank_per_met" (keyup)="ValidatedRentAmount(units.value,u,2)" required>
|
||||
<mat-hint align="start" style="font-size:90%" *ngIf="units.value.amount_received_bank_per_met != ''">{{"₹"}} {{units.value.amount_received_bank_per_met | numberToWords}} Only</mat-hint>
|
||||
<mat-error *ngIf="units.controls['amount_received_bank_per_met'].hasError('max')">Given Value Is More Than Rent Amount</mat-error>
|
||||
<mat-error *ngIf="units.controls['amount_received_bank_per_met'].hasError('min')">Given Value Is Less Than Rent Amount</mat-error>
|
||||
</mat-form-field>
|
||||
<mat-form-field style="width:29%;" appearance="outline" *ngIf="units.controls['amount_received_cash_per_met']">
|
||||
<mat-label>Amount Paid in Cash</mat-label>
|
||||
<input matInput OnlyNumber autocomplete="off" placeholder="" formControlName="amount_received_cash_per_met" required>
|
||||
<mat-hint align="start" style="font-size:90%" *ngIf="units.value.amount_received_cash_per_met != ''">{{"₹"}} {{units.value.amount_received_cash_per_met | numberToWords}} Only</mat-hint>
|
||||
<mat-error *ngIf="units.controls['amount_received_cash_per_met'].hasError('max')">Given Value Is More Than Rent Amount</mat-error>
|
||||
<mat-error *ngIf="units.controls['amount_received_cash_per_met'].hasError('min')">Given Value Is Less Than Rent Amount</mat-error>
|
||||
</mat-form-field>
|
||||
|
||||
<mat-form-field style="width:29%;" appearance="outline" *ngIf="units.controls['amount_received_bank_per_met']">
|
||||
<mat-label>Amount Paid in Bank</mat-label>
|
||||
<input matInput OnlyNumber autocomplete="off" placeholder="" formControlName="amount_received_bank_per_met" required>
|
||||
<mat-hint align="start" style="font-size:90%" *ngIf="units.value.amount_received_bank_per_met != ''">{{"₹"}} {{units.value.amount_received_bank_per_met | numberToWords}} Only</mat-hint>
|
||||
</mat-form-field>
|
||||
|
||||
<mat-form-field style="width:30%;" appearance="outline" *ngIf="units.controls['payment_received_reason_per_met']">
|
||||
<mat-label>Reason for Paid Multiple Payment Mode</mat-label>
|
||||
<textarea matInput placeholder="" formControlName="payment_received_reason_per_met" required></textarea>
|
||||
</mat-form-field>
|
||||
|
||||
<!-- start validate appplicant/agreement payment options -->
|
||||
<mat-form-field style="width:100%" appearance="outline" *ngIf="(units.value.monthly_rent_amount>0 && units.value.paid_monthly_rent_per_met>0 && units.value.payment_mode!='' && units.value.payment_mode_per_met!='') && (units.value.monthly_rent_amount!=units.value.paid_monthly_rent_per_met || units.value.payment_mode.id!=units.value.payment_mode_per_met.id)">
|
||||
<mat-label>What is the Reason for Difference in Rent Amount or Mode of Payment</mat-label>
|
||||
<mat-form-field style="width:100%" appearance="outline" *ngIf="(units.value.monthly_rent_amount>0 && units.value.paid_monthly_rent_per_met>0 && units.value.payment_mode!='' && units.value.payment_mode_per_met!='') && (units.value.monthly_rent_amount!=units.value.paid_monthly_rent_per_met) && units.value.payment_mode_per_met.id != 2 "><!-- || units.value.payment_mode.id!=units.value.payment_mode_per_met.id -->
|
||||
<mat-label>What is the Reason for Difference in Rent Amount</mat-label><!-- or Mode of Payment -->
|
||||
<input matInput autocomplete="off" placeholder="" formControlName="payment_difference_per_met">
|
||||
</mat-form-field>
|
||||
<!-- end -->
|
||||
|
||||
@ -5,7 +5,8 @@ import { DatePipe } from '@angular/common';
|
||||
import { Pipe, PipeTransform } from '@angular/core';
|
||||
import { NotifierService } from 'angular-notifier';
|
||||
import { PdTrigerService } from './../../../../../pd-service/pd-triger.service';
|
||||
|
||||
/**sweet alert */
|
||||
import Swal from 'sweetalert2';
|
||||
@Component({
|
||||
selector: 'app-rental-verification',
|
||||
templateUrl: './rental-verification.component.html',
|
||||
@ -41,6 +42,8 @@ export class RentalVerificationComponent implements OnInit {
|
||||
//floorList: any=[{id:1,name:"Ground Floor"},{id:1,name:"First Floor"},{id:1,name:"Second Floor"},{id:1,name:"Third Floor"}]
|
||||
//unitMeasurementList: any=[{id:2,name:"Square Feet"},{id:3,name:"Square Yards"},{id:4,name:"Square Meters"},{id:5,name:"Acres"},{id:6,name:"Hectares"},{id:1,name:"Others (Please Specify)"}];
|
||||
unitMeasurementList: any=[];
|
||||
SwalButtonText: string;
|
||||
SwalMessage: string;
|
||||
public viewerOptions: any = {
|
||||
navbar: false,
|
||||
toolbar: {
|
||||
@ -306,6 +309,26 @@ loadFormData(){
|
||||
element.amount_received_bank ? control.controls[index].addControl('amount_received_bank', new FormControl('', Validators.required)) : control.controls[index].removeControl('amount_received_bank');
|
||||
element.payment_received_reason ? control.controls[index].addControl('payment_received_reason', new FormControl('', Validators.required)) : control.controls[index].removeControl('payment_received_reason');
|
||||
|
||||
if(element.payment_mode){
|
||||
let ChildCtrl : any = control.controls[index];
|
||||
console.log('asdasdasdasdasdads',element.payment_mode,'else if 2');
|
||||
if(element.payment_mode.id == 1 && element.amount_received_cash){
|
||||
console.log('asdasdasdasdasdads',element.payment_mode,'else if 2');
|
||||
ChildCtrl.controls['amount_received_cash'].setValidators([Validators.required,Validators.max(element.monthly_rent_amount),Validators.min(element.monthly_rent_amount)]);
|
||||
ChildCtrl.controls['amount_received_cash'].updateValueAndValidity();
|
||||
}
|
||||
else if(element.payment_mode.id == 2 && element.amount_received_bank){
|
||||
console.log('asdasdasdasdasdads',element.payment_mode,'else if 2');
|
||||
ChildCtrl.controls['amount_received_bank'].setValidators([Validators.required,Validators.max(element.monthly_rent_amount),Validators.min(element.monthly_rent_amount)]);
|
||||
ChildCtrl.controls['amount_received_bank'].updateValueAndValidity();
|
||||
}
|
||||
else if(element.payment_mode.id == 3 && element.amount_received_bank && element.amount_received_cash){
|
||||
console.log('asdasdasdasdasdads',element.payment_mode,'else if 2');
|
||||
this.ValidatedRentAmount(element,index,1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// unit of other measurement
|
||||
element.other_unit_measurement ? control.controls[index].addControl('other_unit_measurement', new FormControl('', Validators.required)) : control.controls[index].removeControl('other_unit_measurement');
|
||||
// rent agreement seen
|
||||
@ -340,14 +363,36 @@ loadFormData(){
|
||||
element.paid_monthly_rent_per_met ? control.controls[index].addControl('paid_monthly_rent_per_met', new FormControl('', Validators.required)) : control.controls[index].removeControl('paid_monthly_rent_per_met');
|
||||
element.period_of_stay_per_met ? control.controls[index].addControl('period_of_stay_per_met', new FormControl('', Validators.required)) : control.controls[index].removeControl('period_of_stay_per_met');
|
||||
element.payment_mode_per_met ? control.controls[index].addControl('payment_mode_per_met', new FormControl('', Validators.required)) : control.controls[index].removeControl('payment_mode_per_met');
|
||||
element.amount_received_cash_per_met ? control.controls[index].addControl('amount_received_cash_per_met', new FormControl('', Validators.required)) : control.controls[index].removeControl('amount_received_cash_per_met');
|
||||
element.amount_received_bank_per_met ? control.controls[index].addControl('amount_received_bank_per_met', new FormControl('', Validators.required)) : control.controls[index].removeControl('amount_received_bank_per_met');
|
||||
element.payment_received_reason ? control.controls[index].addControl('payment_received_reason', new FormControl('', Validators.required)) : control.controls[index].removeControl('payment_received_reason');
|
||||
element.amount_received_cash_per_met ? control.controls[index].addControl('amount_received_cash_per_met', new FormControl('')) : control.controls[index].removeControl('amount_received_cash_per_met');
|
||||
element.amount_received_bank_per_met ? control.controls[index].addControl('amount_received_bank_per_met', new FormControl('')) : control.controls[index].removeControl('amount_received_bank_per_met');
|
||||
element.payment_received_reason_per_met ? control.controls[index].addControl('payment_received_reason_per_met', new FormControl('', Validators.required)) : control.controls[index].removeControl('payment_received_reason_per_met');
|
||||
element.payment_difference_per_met ? control.controls[index].addControl('payment_difference_per_met', new FormControl('')) : control.controls[index].removeControl('payment_difference_per_met');
|
||||
|
||||
if(element.payment_mode_per_met){
|
||||
|
||||
let ChildCtrl : any = control.controls[index];
|
||||
if(element.payment_mode_per_met.id == 1){
|
||||
console.log('asdasdasdasdasdads',element.payment_mode_per_met,'if');
|
||||
ChildCtrl.controls['amount_received_cash_per_met'].setValidators([Validators.required,Validators.max(element.paid_monthly_rent_per_met),Validators.min(element.paid_monthly_rent_per_met)]);
|
||||
ChildCtrl.controls['amount_received_cash_per_met'].updateValueAndValidity();
|
||||
}
|
||||
else if(element.payment_mode_per_met.id == 2){
|
||||
console.log('asdasdasdasdasdads',element.payment_mode_per_met,'else if 1');
|
||||
ChildCtrl.controls['amount_received_bank_per_met'].setValidators([Validators.required,Validators.max(element.paid_monthly_rent_per_met),Validators.min(element.paid_monthly_rent_per_met)]);
|
||||
ChildCtrl.controls['amount_received_bank_per_met'].updateValueAndValidity();
|
||||
}
|
||||
else if(element.payment_mode_per_met.id == 3){
|
||||
console.log('asdasdasdasdasdads',element.payment_mode_per_met,'else if 2');
|
||||
this.ValidatedRentAmount(element,index,2);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
this._rentalForm.patchValue(rentalVal);
|
||||
|
||||
}
|
||||
else{
|
||||
let control: any = <FormArray>this._rentalForm.controls['property_unit_details'];
|
||||
@ -389,15 +434,18 @@ addMoreUnitDetails(){
|
||||
|
||||
// generate payment dynamic fields
|
||||
generatePaymentOptions(value:any,index:number,type: number){
|
||||
console.log(value,index,type);
|
||||
if(type==1){
|
||||
let control: any = <FormArray>this._rentalForm.controls['property_unit_details'];
|
||||
let monthlyrentamt : number = value.monthly_rent_amount ;
|
||||
console.log('monthlyrentamt',monthlyrentamt);
|
||||
if(value && value.payment_mode.id==1){
|
||||
control.controls[index].addControl('amount_received_cash', new FormControl(value.amount_received_cash ? value.amount_received_cash : '', Validators.required));
|
||||
control.controls[index].addControl('amount_received_cash', new FormControl(value.amount_received_cash ? value.amount_received_cash : '', [Validators.required,Validators.max(monthlyrentamt),Validators.min(monthlyrentamt)]));
|
||||
control.controls[index].removeControl('amount_received_bank');
|
||||
control.controls[index].removeControl('payment_received_reason');
|
||||
}
|
||||
else if(value && value.payment_mode.id==2){
|
||||
control.controls[index].addControl('amount_received_bank', new FormControl(value.amount_received_bank ? value.amount_received_bank : '', Validators.required));
|
||||
control.controls[index].addControl('amount_received_bank', new FormControl(value.amount_received_bank ? value.amount_received_bank : '', [Validators.required,Validators.max(monthlyrentamt),Validators.min(monthlyrentamt)]));
|
||||
control.controls[index].removeControl('amount_received_cash');
|
||||
control.controls[index].removeControl('payment_received_reason');
|
||||
}
|
||||
@ -414,13 +462,14 @@ addMoreUnitDetails(){
|
||||
}
|
||||
else if(type==2){
|
||||
let control: any = <FormArray>this._rentalForm.controls['property_unit_details'];
|
||||
let paidmonthlyrentamt : any = value.paid_monthly_rent_per_met ;
|
||||
if(value && value.payment_mode_per_met.id==1){
|
||||
control.controls[index].addControl('amount_received_cash_per_met', new FormControl(value.amount_received_cash_per_met ? value.amount_received_cash_per_met : '', Validators.required));
|
||||
control.controls[index].addControl('amount_received_cash_per_met', new FormControl(value.amount_received_cash_per_met ? value.amount_received_cash_per_met : '', [Validators.required,Validators.max(paidmonthlyrentamt),Validators.min(paidmonthlyrentamt)]));
|
||||
control.controls[index].removeControl('amount_received_bank_per_met');
|
||||
control.controls[index].removeControl('payment_received_reason_per_met');
|
||||
}
|
||||
else if(value && value.payment_mode_per_met.id==2){
|
||||
control.controls[index].addControl('amount_received_bank_per_met', new FormControl(value.amount_received_bank_per_met ? value.amount_received_bank_per_met : '', Validators.required));
|
||||
control.controls[index].addControl('amount_received_bank_per_met', new FormControl(value.amount_received_bank_per_met ? value.amount_received_bank_per_met : '', [Validators.required,Validators.max(paidmonthlyrentamt),Validators.min(paidmonthlyrentamt)]));
|
||||
control.controls[index].removeControl('amount_received_cash_per_met');
|
||||
control.controls[index].removeControl('payment_received_reason_per_met');
|
||||
}
|
||||
@ -434,10 +483,75 @@ addMoreUnitDetails(){
|
||||
control.controls[index].removeControl('amount_received_bank_per_met');
|
||||
control.controls[index].removeControl('payment_received_reason_per_met');
|
||||
}
|
||||
control.controls[index].payment_difference_per_met.setValue('');
|
||||
control.controls[index].payment_difference_per_met.updateValueAndValidity();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
ValidatedRentAmount(value:any,index:number,type: number){
|
||||
let control: any = <FormArray>this._rentalForm.controls['property_unit_details'];
|
||||
if(type==1){
|
||||
if(value && value.payment_mode.id==3){
|
||||
let ChildCtrl : any = control.controls[index];
|
||||
ChildCtrl.controls['amount_received_bank'].clearValidators();
|
||||
ChildCtrl.controls['amount_received_bank'].updateValueAndValidity();
|
||||
ChildCtrl.controls['amount_received_cash'].clearValidators();;
|
||||
ChildCtrl.controls['amount_received_cash'].updateValueAndValidity();
|
||||
let monthlyrentamt : any = value.monthly_rent_amount ;
|
||||
console.log('monthlyrentamt',monthlyrentamt);
|
||||
|
||||
if(monthlyrentamt != ''){
|
||||
|
||||
let bank_amount = value.amount_received_bank;
|
||||
|
||||
ChildCtrl.controls['amount_received_bank'].setValidators([Validators.required,Validators.max(monthlyrentamt),Validators.min(0)]);
|
||||
ChildCtrl.controls['amount_received_bank'].updateValueAndValidity();
|
||||
let maxamt = monthlyrentamt-bank_amount
|
||||
if(maxamt >= 0 ){
|
||||
ChildCtrl.controls['amount_received_cash'].setValue(maxamt);
|
||||
ChildCtrl.controls['amount_received_cash'].setValidators([Validators.required,Validators.max(monthlyrentamt-bank_amount),Validators.min(monthlyrentamt-bank_amount)]);
|
||||
}
|
||||
else{
|
||||
ChildCtrl.controls['amount_received_cash'].setValue(0);
|
||||
ChildCtrl.controls['amount_received_cash'].setValidators([Validators.max(0),Validators.min(0)]);
|
||||
}
|
||||
ChildCtrl.controls['amount_received_cash'].updateValueAndValidity();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
if(type==2){
|
||||
|
||||
if(value && value.payment_mode.id==3){
|
||||
let ChildCtrl : any = control.controls[index];
|
||||
ChildCtrl.controls['amount_received_bank_per_met'].clearValidators();
|
||||
ChildCtrl.controls['amount_received_bank_per_met'].updateValueAndValidity();
|
||||
ChildCtrl.controls['amount_received_cash_per_met'].clearValidators();;
|
||||
ChildCtrl.controls['amount_received_cash_per_met'].updateValueAndValidity();
|
||||
let paidmonthlyrentamt : any = value.paid_monthly_rent_per_met;
|
||||
console.log(paidmonthlyrentamt,type);
|
||||
|
||||
if(paidmonthlyrentamt != ''){
|
||||
|
||||
let bank_amount = value.amount_received_bank;
|
||||
ChildCtrl.controls['amount_received_bank_per_met'].setValidators([Validators.required,Validators.max(paidmonthlyrentamt),Validators.min(0)]);
|
||||
ChildCtrl.controls['amount_received_bank_per_met'].updateValueAndValidity();
|
||||
let remainingAmt = paidmonthlyrentamt-bank_amount
|
||||
if(remainingAmt >= 0 ){
|
||||
ChildCtrl.controls['amount_received_cash_per_met'].setValue(remainingAmt);
|
||||
ChildCtrl.controls['amount_received_cash_per_met'].setValidators([Validators.required,Validators.max(paidmonthlyrentamt-bank_amount),Validators.min(paidmonthlyrentamt-bank_amount)]);
|
||||
}
|
||||
else{
|
||||
ChildCtrl.controls['amount_received_cash_per_met'].setValue(0);
|
||||
ChildCtrl.controls['amount_received_cash_per_met'].setValidators([Validators.max(0),Validators.min(0)]);
|
||||
}
|
||||
ChildCtrl.controls['amount_received_cash_per_met'].updateValueAndValidity();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
// tenant/lessees options
|
||||
generateTenantOptions(value:any,index:number){
|
||||
let control: any = <FormArray>this._rentalForm.controls['property_unit_details'];
|
||||
@ -616,7 +730,8 @@ generateAgreementOtherOwners(value:any,index:number) {
|
||||
// validate agreement amount
|
||||
validateAgreementAmt(actualRent:number,agreementRent:number){
|
||||
if(actualRent>0 && agreementRent>0){
|
||||
return (actualRent >= agreementRent) ? Number(actualRent) - Number(agreementRent) : Number(agreementRent) - Number(actualRent);
|
||||
let calculatedValue = (actualRent >= agreementRent) ? Number(actualRent) - Number(agreementRent) : Number(agreementRent) - Number(actualRent)
|
||||
return Math.abs(calculatedValue);
|
||||
}
|
||||
else{
|
||||
return "0";
|
||||
@ -838,12 +953,58 @@ calculateFloorRentAmt(values: any, index: number){
|
||||
|
||||
// save rental form
|
||||
saveRental(formData: any) {
|
||||
console.log('formData',formData);
|
||||
console.log('formData.multistoried_building_details',formData.multistoried_building_details);
|
||||
|
||||
let ApplicantRentAmt : any ;
|
||||
let TenantRentAmt : any ;
|
||||
let TempArray1 : any = [];
|
||||
let TempArray2 : any = [];
|
||||
|
||||
if(formData.property_unit_details.length > 0){
|
||||
console.log('formData.property_unit_details',formData.property_unit_details);
|
||||
console.log('formData.property_unit_details',formData.property_unit_details.length);
|
||||
formData.property_unit_details.forEach((data,index) => {
|
||||
TempArray1[index] = data.monthly_rent_amount;
|
||||
ApplicantRentAmt = TempArray1.reduce((sum, val) => sum + +val, 0);
|
||||
TempArray2[index] = data.paid_monthly_rent_per_met;
|
||||
TenantRentAmt = TempArray2.reduce((sum, val) => sum + +val, 0);
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
let FloorsTotalRentAmt : any ;
|
||||
let Array : any = [];
|
||||
if(formData.multistoried_building_details.length > 0){
|
||||
formData.multistoried_building_details.forEach((val,index) => {
|
||||
// console.log('val.floor_rent_amount',val.floor_rent_amount,index);
|
||||
Array[index] = val.floor_rent_amount;
|
||||
FloorsTotalRentAmt = Array.reduce((sum, val) => sum + +val, 0);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if (this._rentalForm.invalid) {
|
||||
this.validateAllFormFields(this._rentalForm);
|
||||
this.notifier.notify('warning', 'Please Fill All Mandatory Fields.!');
|
||||
this.notifier.notify('warning', 'Please Fill/Correct All Mandatory Fields.!');
|
||||
return;
|
||||
}
|
||||
else {
|
||||
Swal({
|
||||
title: 'Confirm The Rent Amount',
|
||||
type: 'info',
|
||||
html: 'Rent as Per Tenant = '+TenantRentAmt+ '<br>'+'Rent as Per Applicant =' + ApplicantRentAmt ,
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: '#3085d6',
|
||||
cancelButtonColor: '#d33',
|
||||
confirmButtonText: 'Confirm',
|
||||
// cancelButtonText:'Cancel And Correct',
|
||||
}).then((result) => {
|
||||
if (result.value) {
|
||||
// Swal(result.value);
|
||||
// return;
|
||||
this._pd.savePDFormDetailsWithID(formData).subscribe(
|
||||
dataresult => {
|
||||
if (dataresult.status == 200) {
|
||||
@ -855,13 +1016,21 @@ saveRental(formData: any) {
|
||||
}
|
||||
else {
|
||||
this.notifier.notify('warning', 'Something Wents Wrong Try Again.!');
|
||||
return;
|
||||
// this.errorMessage = "Some Thing Wents Wrong Try Again !";
|
||||
}
|
||||
}, error => {
|
||||
this.notifier.notify('warning', 'Something Wents Wrong Try Again.!');
|
||||
return;
|
||||
// this.errorMessage = "Something Wents Wrong Try Again !";
|
||||
});
|
||||
}
|
||||
else{
|
||||
// Swal('Sorry Try Again !');
|
||||
return;
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// validate all form group and form array fields
|
||||
|
||||
Loading…
Reference in New Issue
Block a user