fix: Prevent account transfer charges when no savings account is linked (#2364)

- Added getter to check if a savings account is linked (loansSavingsAccountLinked).
- Filtered out charges with 'Account transfer' payment mode when no savings account is linked.
This commit is contained in:
Abhinav R Cillanki
2025-03-27 21:35:33 -06:00
committed by GitHub
parent ff927ffecf
commit 2aae48c8d3
3 changed files with 13 additions and 0 deletions
@@ -53,6 +53,7 @@
[loansAccountProductTemplate]="loansAccountProductTemplate"
[loansAccountTemplate]="loansAccountTemplate"
[loansAccountFormValid]="loansAccountFormValid"
[loansSavingsAccountLinked]="loansSavingsAccountLinked"
>
</mifosx-loans-account-charges-step>
</mat-step>
@@ -119,6 +119,10 @@ export class CreateLoansAccountComponent {
return this.loansAccountDetailsForm.valid && this.loansAccountTermsForm.valid;
}
get loansSavingsAccountLinked() {
return this.loansAccountDetailsStep.loansAccountDetailsForm.get('linkAccountId').value;
}
/** Gets principal Amount */
get loanPrincipal() {
return this.loansAccountTermsStep.loansAccountTermsForm.value.principal;
@@ -34,6 +34,8 @@ export class LoansAccountChargesStepComponent implements OnInit, OnChanges {
@Input() loansAccountFormValid: boolean;
/** active Client Members in case of GSIM Account */
@Input() activeClientMembers?: any;
// returns the chosen savings account linked to the loan account
@Input() loansSavingsAccountLinked: any;
/** Charges Data */
chargeData: any;
@@ -111,6 +113,12 @@ export class LoansAccountChargesStepComponent implements OnInit, OnChanges {
if (this.loansAccountProductTemplate) {
this.loanPurposeOptions = this.loansAccountProductTemplate.loanPurposeOptions;
this.chargeData = this.loansAccountProductTemplate.chargeOptions;
// filter chargeData to have charges that have chargePaymentMode not 'Account Transfer' if loansSavingsAccountLinked is false
if (!this.loansSavingsAccountLinked) {
this.chargeData = this.chargeData.filter(
(charge: any) => charge.chargePaymentMode?.value != 'Account transfer'
);
}
if (this.loansAccountProductTemplate.overdueCharges) {
this.overDueChargesDataSource = this.loansAccountProductTemplate.overdueCharges;
}