FINERACT-2389: EMI rounding handling

This commit is contained in:
Adam Saghy
2025-12-11 17:08:57 +01:00
parent 6d051f5a2f
commit c3ed5caab2
2 changed files with 18 additions and 6 deletions
@@ -1398,11 +1398,23 @@ public final class ProgressiveEMICalculator implements EMICalculator {
private Money applyInstallmentAmountInMultiplesOf(final ProgressiveLoanInterestScheduleModel scheduleModel,
final Money equalMonthlyInstallment) {
return scheduleModel.installmentAmountInMultiplesOf() != null
? Money.roundToMultiplesOf(equalMonthlyInstallment, scheduleModel.installmentAmountInMultiplesOf())
return scheduleModel.installmentAmountInMultiplesOf() != null && scheduleModel.installmentAmountInMultiplesOf() > 0
? safeRoundingForEMI(equalMonthlyInstallment, scheduleModel.installmentAmountInMultiplesOf())
: equalMonthlyInstallment;
}
/**
* Rounds the EMI to the nearest multiple of the given number. If the rounded EMI is zero, it adds one multiple of
* the given number to it.
*/
private Money safeRoundingForEMI(Money unRoundedEMI, Integer multiplesOf) {
Money roundedEMI = Money.roundToMultiplesOf(unRoundedEMI, multiplesOf);
if (roundedEMI.isZero()) {
roundedEMI = roundedEMI.add(BigDecimal.ONE.multiply(BigDecimal.valueOf(multiplesOf)));
}
return roundedEMI;
}
public EmiAdjustment getEmiAdjustment(final List<RepaymentPeriod> repaymentPeriods) {
for (int idx = repaymentPeriods.size() - 1; idx > 0; --idx) {
RepaymentPeriod lastPeriod = repaymentPeriods.get(idx);