diff --git a/src/app/deposits/fixed-deposits/create-fixed-deposit-account/create-fixed-deposit-account.component.ts b/src/app/deposits/fixed-deposits/create-fixed-deposit-account/create-fixed-deposit-account.component.ts index f788ed178..2761036f7 100644 --- a/src/app/deposits/fixed-deposits/create-fixed-deposit-account/create-fixed-deposit-account.component.ts +++ b/src/app/deposits/fixed-deposits/create-fixed-deposit-account/create-fixed-deposit-account.component.ts @@ -70,7 +70,7 @@ export class CreateFixedDepositAccountComponent { /** Fixed Deposit Account Product Template */ fixedDepositsAccountProductTemplate: any; /** Tenure selected from the interest rate chart step */ - selectedTenure: { depositPeriod: number; depositPeriodFrequencyId: number } | null = null; + selectedTenure: { depositPeriod: number; depositPeriodFrequencyId: number; depositAmount?: number } | null = null; /** * Fetches FD account template from `resolve` @@ -94,7 +94,7 @@ export class CreateFixedDepositAccountComponent { this.fixedDepositsAccountProductTemplate = $event; } - onTenureSelected($event: { depositPeriod: number; depositPeriodFrequencyId: number }) { + onTenureSelected($event: { depositPeriod: number; depositPeriodFrequencyId: number; depositAmount?: number }) { this.selectedTenure = $event; } @@ -129,12 +129,59 @@ export class CreateFixedDepositAccountComponent { const locale = this.settingsService.language.code; const dateFormat = this.settingsService.dateFormat; const monthDayFormat = 'dd MMMM'; + const pt = this.fixedDepositsAccountProductTemplate; + + // Terms — pulled from product template + const terms: any = {}; + if (pt?.nominalAnnualInterestRate != null) terms.nominalAnnualInterestRate = pt.nominalAnnualInterestRate; + if (pt?.interestCompoundingPeriodType?.id != null) + terms.interestCompoundingPeriodType = pt.interestCompoundingPeriodType.id; + if (pt?.interestPostingPeriodType?.id != null) terms.interestPostingPeriodType = pt.interestPostingPeriodType.id; + if (pt?.interestCalculationType?.id != null) terms.interestCalculationType = pt.interestCalculationType.id; + if (pt?.interestCalculationDaysInYearType?.id != null) + terms.interestCalculationDaysInYearType = pt.interestCalculationDaysInYearType.id; + + // Deposit amount: Prefer user input from Rate Calculator, fallback to product template + if (this.selectedTenure?.depositAmount != null) { + terms.depositAmount = this.selectedTenure.depositAmount; + } else if (pt?.depositAmount != null) { + terms.depositAmount = pt.depositAmount; + } + + if (pt?.minDepositAmount != null) terms.minDepositAmount = pt.minDepositAmount; + if (pt?.maxDepositAmount != null) terms.maxDepositAmount = pt.maxDepositAmount; + + // Settings — pulled from product template + const settings: any = {}; + if (pt?.lockinPeriodFrequency != null) settings.lockinPeriodFrequency = pt.lockinPeriodFrequency; + if (pt?.lockinPeriodFrequencyType?.id != null) settings.lockinPeriodFrequencyType = pt.lockinPeriodFrequencyType.id; + if (pt?.minDepositTerm != null) settings.minDepositTerm = pt.minDepositTerm; + if (pt?.minDepositTermType?.id != null) settings.minDepositTermTypeId = pt.minDepositTermType.id; + if (pt?.inMultiplesOfDepositTerm != null) settings.inMultiplesOfDepositTerm = pt.inMultiplesOfDepositTerm; + if (pt?.inMultiplesOfDepositTermType?.id != null) + settings.inMultiplesOfDepositTermTypeId = pt.inMultiplesOfDepositTermType.id; + if (pt?.maxDepositTerm != null) settings.maxDepositTerm = pt.maxDepositTerm; + if (pt?.maxDepositTermType?.id != null) settings.maxDepositTermTypeId = pt.maxDepositTermType.id; + if (pt?.preClosurePenalApplicable != null) settings.preClosurePenalApplicable = pt.preClosurePenalApplicable; + if (pt?.preClosurePenalInterest != null) settings.preClosurePenalInterest = pt.preClosurePenalInterest; + if (pt?.preClosurePenalInterestOnType?.id != null) + settings.preClosurePenalInterestOnTypeId = pt.preClosurePenalInterestOnType.id; + if (pt?.maturityInstructionId != null) settings.maturityInstructionId = pt.maturityInstructionId; + if (pt?.transferInterestToSavings != null) settings.transferInterestToSavings = pt.transferInterestToSavings; + if (pt?.withHoldTax != null) settings.withHoldTax = pt.withHoldTax; + + // Charges — from product template if not overridden in details + const rawCharges: any[] = + (this.fixedDepositAccount.charges?.length ? this.fixedDepositAccount.charges : pt?.charges) ?? []; + const fixedDepositAccount = { ...this.fixedDepositAccount, + ...terms, + ...settings, ...(this.selectedTenure ?? {}), clientId: this.fixedDepositsAccountTemplate.clientId, - charges: this.fixedDepositAccount.charges.map((charge: any) => ({ - chargeId: charge.id, + charges: rawCharges.map((charge: any) => ({ + chargeId: charge.chargeId ?? charge.id, amount: charge.amount, dueDate: charge.dueDate && this.dateUtils.formatDate(charge.dueDate, dateFormat), feeOnMonthDay: @@ -142,7 +189,7 @@ export class CreateFixedDepositAccountComponent { feeInterval: charge.feeInterval })), submittedOnDate: this.dateUtils.formatDate(this.fixedDepositAccount.submittedOnDate, dateFormat), - charts: [{ chartSlabs: this.fixedDepositsAccountProductTemplate.accountChart?.chartSlabs ?? [] }], + charts: [{ chartSlabs: pt?.accountChart?.chartSlabs ?? [] }], dateFormat, monthDayFormat, locale diff --git a/src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-currency-step/fixed-deposit-account-currency-step.component.html b/src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-currency-step/fixed-deposit-account-currency-step.component.html index 5f920e61b..4255fbc5a 100644 --- a/src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-currency-step/fixed-deposit-account-currency-step.component.html +++ b/src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-currency-step/fixed-deposit-account-currency-step.component.html @@ -55,11 +55,9 @@
Allow account holders to designate individuals to receive funds in the event of account holder's death.
- - {{ fixedDepositsAccountProductTemplate?.nominationFacility ? 'Yes' : 'No' }} - +