FINERACT-2389: Pay-Off amount incorrectly calculated when downpayment

This commit is contained in:
Jose Alberto Hernandez
2025-11-19 16:45:47 +01:00
committed by Adam Saghy
parent 60526f0ce9
commit 2681ee3518
2 changed files with 9 additions and 1 deletions
@@ -1699,7 +1699,6 @@ Feature: Capitalized Income
| 100.0 | 83.33 | 16.67 | 0.0 | 0.0 |
When Loan Pay-off is made on "26 January 2024"
And Customer makes "AUTOPAY" repayment on "26 January 2024" with 225 EUR transaction amount
Then Loan is closed with zero outstanding balance and it's all installments have obligations met
@TestRailId:C3673
@@ -205,10 +205,19 @@ public class ProgressiveLoanScheduleGenerator implements LoanScheduleGenerator {
ProgressiveLoanInterestScheduleModel model = savedModel.orElseThrow();
OutstandingDetails outstandingAmounts = emiCalculator.getOutstandingAmountsTillDate(model, transactionDate);
// TODO: We should add all the past due outstanding amounts as well
OutstandingAmountsDTO result = new OutstandingAmountsDTO(currency) //
.principal(outstandingAmounts.getOutstandingPrincipal()) //
.interest(outstandingAmounts.getOutstandingInterest());//
if (loan.isProgressiveSchedule()) {
final LoanRepaymentScheduleInstallment downPaymentInstallment = loan.getRepaymentScheduleInstallments(i -> i.isDownPayment())
.stream().findFirst().orElse(null);
if (downPaymentInstallment != null) {
result.principal(downPaymentInstallment.getPrincipalOutstanding(loan.getCurrency())
.add(outstandingAmounts.getOutstandingPrincipal()));
}
}
// We need to deduct any paid amount if there is no interest recalculation
if (!loan.isInterestRecalculationEnabled()) {
BigDecimal paidInterest = installments.stream().map(LoanRepaymentScheduleInstallment::getInterestPaid).reduce(BigDecimal.ZERO,