feat: add edit recurring deposit account (#1023)

Fixes: #1017
This commit is contained in:
Muskan Khedia
2020-07-08 12:57:21 +05:30
committed by GitHub
parent 74b219fe00
commit fc2b352311
16 changed files with 438 additions and 18 deletions
@@ -1,5 +1,5 @@
/** Angular Imports */
import { Component, OnInit, Input } from '@angular/core';
import { Component, OnInit, Input, OnChanges } from '@angular/core';
import { FormControl } from '@angular/forms';
import { MatDialog } from '@angular/material';
@@ -21,7 +21,7 @@ import { InputBase } from 'app/shared/form-dialog/formfield/model/input-base';
templateUrl: './recurring-deposits-account-charges-step.component.html',
styleUrls: ['./recurring-deposits-account-charges-step.component.scss']
})
export class RecurringDepositsAccountChargesStepComponent implements OnInit {
export class RecurringDepositsAccountChargesStepComponent implements OnInit, OnChanges {
@Input() recurringDepositsAccountTemplate: any;
@Input() recurringDepositsAccountProductTemplate: any;
@@ -31,28 +31,43 @@ export class RecurringDepositsAccountChargesStepComponent implements OnInit {
/** Charges Data */
chargeData: any;
/** Charges Data Source */
chargesDataSource: {}[];
chargesDataSource: {}[] = [];
/** Charges table columns */
displayedColumns: string[] = ['name', 'chargeCalculationType', 'amount', 'chargeTimeType', 'date', 'repaymentsEvery', 'action'];
/** Component is pristine if there has been no changes by user interaction */
pristine = true;
/** For Edit Recurring Deposits Account Form */
isChargesPatched = false;
constructor(public dialog: MatDialog,
private datePipe: DatePipe) {
}
ngOnInit() {
this.chargeData = this.recurringDepositsAccountTemplate.chargeOptions;
this.chargesDataSource = [];
this.currencyCode.valueChanges.subscribe(() => this.chargesDataSource = []);
this.currencyCode.valueChanges.subscribe(() => {
if (!this.isChargesPatched && this.recurringDepositsAccountTemplate.charges) {
this.chargesDataSource = this.recurringDepositsAccountTemplate.charges.map((charge: any) => ({ ...charge, id: charge.chargeId })) || [];
this.isChargesPatched = true;
} else {
this.chargesDataSource = [];
}
});
}
ngOnChanges() {
if (this.recurringDepositsAccountProductTemplate) {
this.chargeData = this.recurringDepositsAccountProductTemplate.chargeOptions;
}
}
/**
* Add a charge
*/
addCharge(charge: any) {
this.chargesDataSource = this.chargesDataSource.concat([charge.value]);
charge.value = '';
this.pristine = false;
}
/**
@@ -168,6 +183,7 @@ export class RecurringDepositsAccountChargesStepComponent implements OnInit {
if (response.delete) {
this.chargesDataSource.splice(this.chargesDataSource.indexOf(charge), 1);
this.chargesDataSource = this.chargesDataSource.concat([]);
this.pristine = false;
}
});
}
@@ -27,6 +27,8 @@ export class RecurringDepositsAccountDetailsStepComponent implements OnInit {
productData: any;
/** Field Officer Data */
fieldOfficerData: any;
/** For edit recurring deposits form */
isFieldOfficerPatched = false;
/** Recurring Deposits Account Details Form */
recurringDepositAccountDetailsForm: FormGroup;
@@ -77,7 +79,12 @@ export class RecurringDepositsAccountDetailsStepComponent implements OnInit {
this.recurringDepositsService.getRecurringDepositsAccountTemplate(clientId, productId).subscribe((response: any) => {
this.recurringDepositsAccountProductTemplate.emit(response);
this.fieldOfficerData = response.fieldOfficerOptions;
this.recurringDepositAccountDetailsForm.get('fieldOfficerId').patchValue('');
if (!this.isFieldOfficerPatched && this.recurringDepositsAccountTemplate.fieldOfficerId) {
this.recurringDepositAccountDetailsForm.get('fieldOfficerId').patchValue(this.recurringDepositsAccountTemplate.fieldOfficerId);
this.isFieldOfficerPatched = true;
} else {
this.recurringDepositAccountDetailsForm.get('fieldOfficerId').patchValue('');
}
});
});
}
@@ -35,6 +35,11 @@
<span fxFlex="60%">{{ recurringDepositsAccountProductTemplate.currency.decimalPlaces }}</span>
</div>
<div fxFlexFill>
<span fxFlex="40%">Currency In Multiples Of</span>
<span fxFlex="60%">{{ recurringDepositsAccountProductTemplate.currency.inMultiplesOf }}</span>
</div>
<h3 class="mat-h3" fxFlexFill>Terms</h3>
<mat-divider fxFlexFill></mat-divider>
@@ -151,9 +151,9 @@
</mat-select>
</mat-form-field>
<!-- <mat-divider fxFlex="98%"></mat-divider> -->
<mat-divider fxFlex="98%"></mat-divider>
<!-- <h4 fxFlex="23%" class="mat-h4">For Pre-mature closure</h4>
<h4 fxFlex="98%" class="mat-h4">For Pre-mature closure</h4>
<mat-checkbox fxFlex="73%" labelPosition="before" formControlName="preClosurePenalApplicable" class="margin-v">
Apply Penal Interest (less)
@@ -172,9 +172,27 @@
{{ preClosurePenalInterestOnType.value }}
</mat-option>
</mat-select>
</mat-form-field> -->
</mat-form-field>
<mat-divider fxFlex="98%"></mat-divider>
<!-- <mat-divider fxFlex="98%"></mat-divider> -->
<mat-form-field fxFlex="48%">
<mat-label>Minimum Balance For Interest Calculation</mat-label>
<input type="number" matInput formControlName="minBalanceForInterestCalculation">
</mat-form-field>
<ng-container *ngIf="taxGroup">
<h4 fxFlex="98%" class="mat-h4">Tax Group</h4>
<mat-checkbox fxFlex="48%" labelPosition="before" formControlName="withHoldTax" class="margin-v">
Is Withhold Tax Applicable?
</mat-checkbox>
<mat-form-field fxFlex="48%" *ngIf="recurringDepositAccountSettingsForm.controls.taxGroupId">
<mat-label>Tax Group</mat-label>
<input type="text" matInput formControlName="taxGroupId">
</mat-form-field>
</ng-container>
</div>
@@ -28,6 +28,10 @@ export class RecurringDepositsAccountSettingsStepComponent implements OnInit, On
lockinPeriodFrequencyTypeData: any;
/** Period Frequency Type Data */
periodFrequencyTypeData: any;
/** Preclosure Penal Interest Type on Data */
preClosurePenalInterestOnTypeData: any;
/** Tax Group */
taxGroup: any;
/**
* @param {FormBuilder} formBuilder Form Builder
@@ -52,7 +56,26 @@ export class RecurringDepositsAccountSettingsStepComponent implements OnInit, On
'inMultiplesOfDepositTermTypeId': this.recurringDepositsAccountProductTemplate.inMultiplesOfDepositTermType ? this.recurringDepositsAccountProductTemplate.inMultiplesOfDepositTermType.id : '',
'maxDepositTerm': this.recurringDepositsAccountProductTemplate.maxDepositTerm,
'maxDepositTermTypeId': this.recurringDepositsAccountProductTemplate.maxDepositTermType ? this.recurringDepositsAccountProductTemplate.maxDepositTermType.id : '',
'preClosurePenalApplicable': this.recurringDepositsAccountProductTemplate.preClosurePenalApplicable,
'preClosurePenalInterest': this.recurringDepositsAccountProductTemplate.preClosurePenalInterest,
'preClosurePenalInterestOnTypeId': this.recurringDepositsAccountProductTemplate.preClosurePenalInterestOnType ? this.recurringDepositsAccountProductTemplate.preClosurePenalInterestOnType.id : '',
'minBalanceForInterestCalculation': this.recurringDepositsAccountProductTemplate.minBalanceForInterestCalculation,
});
if (this.recurringDepositsAccountProductTemplate.withHoldTax) {
this.recurringDepositAccountSettingsForm.addControl('withHoldTax', new FormControl(false));
this.recurringDepositAccountSettingsForm.get('withHoldTax').valueChanges.subscribe((value: boolean) => {
if (value) {
this.recurringDepositAccountSettingsForm.addControl('taxGroupId', new FormControl({ value: '', disabled: true }));
this.recurringDepositAccountSettingsForm.get('taxGroupId').patchValue(this.recurringDepositsAccountProductTemplate.taxGroup && this.recurringDepositsAccountProductTemplate.taxGroup.name);
} else {
this.recurringDepositAccountSettingsForm.removeControl('taxGroupId');
}
});
this.recurringDepositAccountSettingsForm.get('withHoldTax').patchValue(this.recurringDepositsAccountTemplate.withHoldTax);
} else {
this.recurringDepositAccountSettingsForm.removeControl('withHoldTax');
}
this.taxGroup = this.recurringDepositsAccountProductTemplate.taxGroup;
this.setOptions();
}
}
@@ -62,6 +85,7 @@ export class RecurringDepositsAccountSettingsStepComponent implements OnInit, On
this.recurringDepositAccountSettingsForm.patchValue({
'lockinPeriodFrequency': this.recurringDepositsAccountTemplate.lockinPeriodFrequency,
'lockinPeriodFrequencyType': this.recurringDepositsAccountTemplate.lockinPeriodFrequencyType && this.recurringDepositsAccountTemplate.lockinPeriodFrequencyType.id,
'mandatoryRecommendedDepositAmount': this.recurringDepositsAccountProductTemplate.mandatoryRecommendedDepositAmount,
});
}
}
@@ -88,7 +112,11 @@ export class RecurringDepositsAccountSettingsStepComponent implements OnInit, On
'inMultiplesOfDepositTerm': [{ value: '', disabled: true }],
'inMultiplesOfDepositTermTypeId': [{ value: '', disabled: true }],
'maxDepositTerm': [{ value: '', disabled: true }],
'maxDepositTermTypeId': [{ value: '', disabled: true }]
'maxDepositTermTypeId': [{ value: '', disabled: true }],
'preClosurePenalApplicable': [{ value: '', disabled: true }],
'preClosurePenalInterest': [{ value: '', disabled: true }],
'preClosurePenalInterestOnTypeId': [{ value: '', disabled: true }],
'minBalanceForInterestCalculation': [{ value: '', disabled: true }]
});
}
@@ -98,6 +126,7 @@ export class RecurringDepositsAccountSettingsStepComponent implements OnInit, On
setOptions() {
this.lockinPeriodFrequencyTypeData = this.recurringDepositsAccountProductTemplate.lockinPeriodFrequencyTypeOptions;
this.periodFrequencyTypeData = this.recurringDepositsAccountProductTemplate.periodFrequencyTypeOptions;
this.preClosurePenalInterestOnTypeData = this.recurringDepositsAccountProductTemplate.preClosurePenalInterestOnTypeOptions;
}
/**