Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Comment on lines +207 to +213

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🔴 Critical | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Map the target component and nearby relevant symbols first
ast-grep outline src/app/loans/loans-account-stepper/loans-account-terms-step/loans-account-terms-step.component.ts --view expanded

printf '\n--- related component search ---\n'
rg -n "isLoanProduct|isWorkingCapital|loansAccountProductTemplate|loansAccountTermsData|ngOnChanges" src/app/loans -g '*.ts'

Repository: openMF/web-app

Length of output: 50370


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Inspect the relevant section of the component with line numbers.
sed -n '180,380p' src/app/loans/loans-account-stepper/loans-account-terms-step/loans-account-terms-step.component.ts | cat -n

Repository: openMF/web-app

Length of output: 12744


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Inspect the analogous creation component for how it branches on product type.
sed -n '1,260p' src/app/loans/create-loans-account/create-loans-account.component.ts | cat -n

Repository: openMF/web-app

Length of output: 11861


🏁 Script executed:

#!/bin/bash
set -euo pipefail

python3 - <<'PY'
from pathlib import Path
p = Path('src/app/loans/loans-account-stepper/loans-account-terms-step/loans-account-terms-step.component.ts')
text = p.read_text()
for start in [180, 200, 320, 340]:
    print(f"\n--- lines {start}-{start+40} ---")
    for i, line in enumerate(text.splitlines(), 1):
        if start <= i <= start + 40:
            print(f"{i:4}: {line}")
PY

Repository: openMF/web-app

Length of output: 10482


Restrict this branch to loan products and only run it on loansAccountProductTemplate changes.
if (this.loansAccountProductTemplate) makes the working-capital else if unreachable, and !templateChange resets loansAccountTermsData on unrelated @Input() updates. Gate this on this.loanProductService.isLoanProduct and move the assignment inside if (templateChange).

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@src/app/loans/loans-account-stepper/loans-account-terms-step/loans-account-terms-step.component.ts`
around lines 207 - 213, The loansAccountProductTemplate branch currently
captures working-capital products and updates loansAccountTermsData on unrelated
input changes. In the relevant input-change handler, gate this branch with
loanProductService.isLoanProduct, require changes['loansAccountProductTemplate']
before assigning loansAccountTermsData, and preserve the initial-load loan
template override within that change-specific block so the working-capital
else-if remains reachable.

// 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.
Expand Down
Loading