From efcc641c2e46a62802120c986662860f43c4f96c Mon Sep 17 00:00:00 2001 From: iaitsupport <75412352+iaitsupport@users.noreply.github.com> Date: Wed, 15 Jul 2026 17:45:04 +0300 Subject: [PATCH] Update loans-account-terms-step.component.ts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `Angular`'s `SimpleChanges` object tells us, for the `loansAccountProductTemplate` input specifically, whether this is the **first** time it changed (`isFirstChange()`). Behavior now: | Scenario | `isInitialLoad` | Data used | |---|---|---| | Edit page opens for the first time | `true` | `loansAccountTemplate` (the loan's own current data) — same as before, unchanged behavior | | User picks a different product afterward | `false` | `loansAccountProductTemplate` (the freshly-fetched template for the newly selected product) — **this is the fix** | --- .../loans-account-terms-step.component.ts | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/app/loans/loans-account-stepper/loans-account-terms-step/loans-account-terms-step.component.ts b/src/app/loans/loans-account-stepper/loans-account-terms-step/loans-account-terms-step.component.ts index 2ba0fb5d5b..3e2afc7946 100644 --- a/src/app/loans/loans-account-stepper/loans-account-terms-step/loans-account-terms-step.component.ts +++ b/src/app/loans/loans-account-stepper/loans-account-terms-step/loans-account-terms-step.component.ts @@ -204,12 +204,13 @@ export class LoansAccountTermsStepComponent extends LoanProductBaseComponent imp * Executes on change of input values */ ngOnChanges(changes: SimpleChanges) { - if (this.loanProductService.isLoanProduct) { - if (this.loansAccountProductTemplate) { - this.loansAccountTermsData = this.loansAccountProductTemplate; - if (this.loanId != null && this.loansAccountTemplate?.accountNo) { - this.loansAccountTermsData = this.loansAccountTemplate; - } + if (this.loansAccountProductTemplate) { + const templateChange = changes['loansAccountProductTemplate']; + const isInitialLoad = !templateChange || templateChange.isFirstChange(); + this.loansAccountTermsData = this.loansAccountProductTemplate; + if (isInitialLoad && this.loanId != null && this.loansAccountTemplate?.accountNo) { + this.loansAccountTermsData = this.loansAccountTemplate; + } // Resolve the currency from the finalized terms data (the account template in edit mode), // matching ngOnInit and the non-loan-product branch, so the amount field reflects the // account currency instead of the product template currency.