diff --git a/src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-interest-rate-chart-step/fixed-deposit-account-interest-rate-chart-step.component.ts b/src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-interest-rate-chart-step/fixed-deposit-account-interest-rate-chart-step.component.ts index beff3f51d..a8ebfa8de 100644 --- a/src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-interest-rate-chart-step/fixed-deposit-account-interest-rate-chart-step.component.ts +++ b/src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-interest-rate-chart-step/fixed-deposit-account-interest-rate-chart-step.component.ts @@ -334,14 +334,18 @@ export class FixedDepositAccountInterestRateChartStepComponent implements OnChan const frequencyId = this.resolveFrequencyId(this.tenurePeriodUnit); if (this.principalAmount && this.principalAmount > 0) { - // Convert tenure to months for backend API - let tenureInMonths = 0; + // Convert tenure to months for backend API. A Days tenure under 30 days rounds down to 0 + // months, which the backend rejects -- send it as tenureInDays instead in that case. + let tenureInMonths: number | undefined; + let tenureInDays: number | undefined; if (this.tenurePeriodUnit === 'Years') { tenureInMonths = this.tenureValue * 12; } else if (this.tenurePeriodUnit === 'Months') { tenureInMonths = this.tenureValue; - } else { + } else if (enteredDays >= 30) { tenureInMonths = Math.floor(enteredDays / 30); + } else { + tenureInDays = enteredDays; } // Map compounding period type id → months (0=Daily, 1=Daily, 4=Monthly, 5=Quarterly, 6=SemiAnnual, 7=Annual) @@ -395,6 +399,7 @@ export class FixedDepositAccountInterestRateChartStepComponent implements OnChan principalAmount: this.principalAmount, annualInterestRate: rate, tenureInMonths, + tenureInDays, interestCompoundingPeriodInMonths: compMonths, // 0 = daily, now supported by backend interestPostingPeriodInMonths: postMonths, submittedOnDate: submittedOnDateStr, @@ -417,7 +422,8 @@ export class FixedDepositAccountInterestRateChartStepComponent implements OnChan Math.round(this.principalAmount * Math.pow(1 + r / daysInYearVal, enteredDays) * 100) / 100; } else { const n = 12 / compMonths; - const totalCompoundings = Math.floor(tenureInMonths / compMonths); + const effectiveMonths = tenureInMonths ?? enteredDays / 30; + const totalCompoundings = Math.floor(effectiveMonths / compMonths); const rPerCompounding = rate / (n * 100); result.maturityAmount = Math.round(this.principalAmount * Math.pow(1 + rPerCompounding, totalCompoundings) * 100) / 100; diff --git a/src/app/deposits/fixed-deposits/fixed-deposits.service.ts b/src/app/deposits/fixed-deposits/fixed-deposits.service.ts index dd82ede92..b0257e1bc 100644 --- a/src/app/deposits/fixed-deposits/fixed-deposits.service.ts +++ b/src/app/deposits/fixed-deposits/fixed-deposits.service.ts @@ -133,7 +133,8 @@ export class FixedDepositsService { calculateFixedDepositInterest(params: { principalAmount: number; annualInterestRate: number; - tenureInMonths: number; + tenureInMonths?: number; + tenureInDays?: number; // alternative to tenureInMonths, for sub-month FD Single tenures interestCompoundingPeriodInMonths: number; interestPostingPeriodInMonths: number; submittedOnDate?: string; // yyyy-MM-dd — enables exact calendar calculation