FINERACT-2221: Fix - Interest not counted towards totalUnpaidPayableNotDueInterest after partial repayment

This commit is contained in:
Adam Saghy
2025-03-24 14:23:00 +01:00
parent 2251ee0da6
commit b2af4a635c
11 changed files with 261 additions and 46 deletions
@@ -182,6 +182,16 @@ public class ProgressiveLoanScheduleGenerator implements LoanScheduleGenerator {
.principal(outstandingAmounts.getOutstandingPrincipal()) //
.interest(outstandingAmounts.getOutstandingInterest());//
// 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,
BigDecimal::add);
BigDecimal paidPrincipal = installments.stream().map(LoanRepaymentScheduleInstallment::getPrincipal).reduce(BigDecimal.ZERO,
BigDecimal::add);
result.principal().minus(paidPrincipal);
result.interest().minus(paidInterest);
}
installments.forEach(installment -> {
if (installment.isAdditional()) {
result.plusPrincipal(installment.getPrincipalOutstanding(currency))
@@ -298,7 +298,7 @@ public class ProgressiveLoanInterestScheduleModel {
* @return
*/
public Money getTotalDueInterest() {
return repaymentPeriods().stream().map(RepaymentPeriod::getCalculatedDueInterest).reduce(zero(), Money::plus);
return repaymentPeriods().stream().map(RepaymentPeriod::getDueInterest).reduce(zero(), Money::plus);
}
/**