diff --git a/src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-maturity-terms-step/fixed-deposit-account-maturity-terms-step.component.html b/src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-maturity-terms-step/fixed-deposit-account-maturity-terms-step.component.html index 17d6f00d7..bb548478e 100644 --- a/src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-maturity-terms-step/fixed-deposit-account-maturity-terms-step.component.html +++ b/src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-maturity-terms-step/fixed-deposit-account-maturity-terms-step.component.html @@ -7,17 +7,29 @@ -->
-

{{ 'labels.heading.For Pre-mature closure' | translate }}

+

{{ 'labels.heading.Maturity Instructions' | translate }}

{{ 'labels.inputs.Maturity Instructions' | translate }} + -- Not selected (decide later via FD Dashboard) -- @for (maturityInstruction of maturityInstructionOptions; track maturityInstruction) { {{ maturityInstruction.value | translateKey: 'catalogs' }} } + @if (closureSettingsForm.value.maturityInstructionId) { + + } @if (closureSettingsForm.contains('transferToSavingsId')) { @@ -28,8 +40,8 @@ savings
-

{{ 'labels.inputs.Transfer to savings account' | translate }}

- Maturity proceeds will be credited to this account +

{{ transferAccountCardTitle }}

+ {{ transferAccountCardSubtitle }}
@@ -69,7 +81,7 @@ } @else { - {{ 'labels.inputs.Transfer to savings account' | translate }} + {{ transferAccountCardTitle }} @for (account of savingsAccountsData; track account) { @@ -77,13 +89,15 @@ } - Transfer to savings account is required + {{ transferAccountCardTitle }} is required } } +

{{ 'labels.heading.For Pre-mature closure' | translate }}

+ {{ 'labels.inputs.Apply Penal Interest (less)' | translate }} diff --git a/src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-maturity-terms-step/fixed-deposit-account-maturity-terms-step.component.ts b/src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-maturity-terms-step/fixed-deposit-account-maturity-terms-step.component.ts index bce8468a1..d4552f9d1 100644 --- a/src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-maturity-terms-step/fixed-deposit-account-maturity-terms-step.component.ts +++ b/src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-maturity-terms-step/fixed-deposit-account-maturity-terms-step.component.ts @@ -11,6 +11,7 @@ import { Component, Input, OnChanges, SimpleChanges, inject } from '@angular/cor import { UntypedFormGroup, UntypedFormBuilder, UntypedFormControl, Validators } from '@angular/forms'; import { MatCheckbox } from '@angular/material/checkbox'; import { MatIcon } from '@angular/material/icon'; +import { MatIconButton } from '@angular/material/button'; import { STANDALONE_SHARED_IMPORTS } from 'app/standalone-shared.module'; /** @@ -25,7 +26,8 @@ import { STANDALONE_SHARED_IMPORTS } from 'app/standalone-shared.module'; imports: [ ...STANDALONE_SHARED_IMPORTS, MatCheckbox, - MatIcon + MatIcon, + MatIconButton ] }) export class FixedDepositAccountMaturityTermsStepComponent implements OnChanges { @@ -53,9 +55,12 @@ export class FixedDepositAccountMaturityTermsStepComponent implements OnChanges preClosurePenalInterestOnTypeId: [''] }); this.closureSettingsForm.get('maturityInstructionId').valueChanges.subscribe((value: number) => { - // 200 = Transfer to Savings -- Withdraw Deposit (100) needs no target account, and both - // Reinvest options (300/400) open a brand-new FD instead, so they ignore this field too. - if (value === 200) { + // 200 = Transfer to Savings -- the whole matured balance goes here. 400 = Reinvest Principal + // Only -- the principal rolls into a new FD, but the leftover interest still needs the same + // kind of target so it isn't left stranded on the closed account (a real gap the account used + // to silently hit before this field also asked for it here). Reinvest Principal + Interest + // (300) rolls the whole balance into the same account, so it never needs a target at all. + if (value === 200 || value === 400) { this.closureSettingsForm.addControl( 'transferToSavingsId', new UntypedFormControl(this.linkedSavingsAccountId ?? '', Validators.required) @@ -91,15 +96,48 @@ export class FixedDepositAccountMaturityTermsStepComponent implements OnChanges }); } } + // Editing an existing account: its own already-saved Maturity Instructions choice lives on + // `fixedDepositsAccountTemplate` (the real account+template GET, FixedDepositAccountData's + // `onAccountClosure`) -- NOT on `fixedDepositsAccountProductTemplate`, which is only the blank + // per-product default template refetched from the Product dropdown's own productId (via + // getFixedDepositsAccountTemplate(clientId, productId)) and carries no account-specific data at + // all. This was never read from the right place before, so Edit always opened onto a blank + // picker even for an account that really does have an instruction saved. `.dirty` guards it the + // same way the penal-interest fields above do, so a maker's own in-progress edit here is never + // silently overwritten if this input fires again mid-edit. + if (this.fixedDepositsAccountTemplate && !this.closureSettingsForm.get('maturityInstructionId').dirty) { + this.closureSettingsForm + .get('maturityInstructionId') + ?.setValue(this.fixedDepositsAccountTemplate.onAccountClosure?.id ?? ''); + const transferControl = this.closureSettingsForm.get('transferToSavingsId'); + if (transferControl) { + transferControl.setValue( + this.fixedDepositsAccountTemplate.transferToSavingsId ?? this.linkedSavingsAccountId ?? '' + ); + } + } } - /** The linked-savings account for the transfer-to-savings maturity instruction, once picked. */ + /** The linked-savings account for the transfer-to-savings / reinvest-principal-only-interest + * maturity instruction, once picked. */ get selectedTransferAccount(): any { const id = this.closureSettingsForm.value.transferToSavingsId; if (!id) return null; return this.savingsAccountsData.find((account: any) => account.id === id) ?? null; } + get transferAccountCardTitle(): string { + return this.closureSettingsForm.value.maturityInstructionId === 400 + ? 'Interest payout account' + : 'Transfer to savings account'; + } + + get transferAccountCardSubtitle(): string { + return this.closureSettingsForm.value.maturityInstructionId === 400 + ? 'The principal renews into a new FD; interest earned is paid out to this account.' + : 'Maturity proceeds will be credited to this account.'; + } + clearTransferAccount(): void { this.closureSettingsForm.get('transferToSavingsId')?.setValue(''); }