FINERACT-2081: Fix progressive loan schedule for non-yearly interest rates

This commit is contained in:
adam.magyari
2024-10-01 13:54:02 +02:00
committed by Adam Saghy
parent 04ec56382a
commit 03d320e513
4 changed files with 173 additions and 3 deletions
@@ -44,13 +44,12 @@ public record ProgressiveLoanInterestScheduleModel(List<ProgressiveLoanInterestR
}
public BigDecimal getInterestRate(final LocalDate effectiveDate) {
return interestRates.isEmpty() ? loanProductRelatedDetail.getNominalInterestRatePerPeriod() : findInterestRate(effectiveDate);
return interestRates.isEmpty() ? loanProductRelatedDetail.getAnnualNominalInterestRate() : findInterestRate(effectiveDate);
}
private BigDecimal findInterestRate(final LocalDate effectiveDate) {
return interestRates.stream().filter(ir -> !ir.effectiveFrom().isAfter(effectiveDate))
.map(ProgressiveLoanInterestRate::interestRate).findFirst()
.orElse(loanProductRelatedDetail.getNominalInterestRatePerPeriod());
.map(ProgressiveLoanInterestRate::interestRate).findFirst().orElse(loanProductRelatedDetail.getAnnualNominalInterestRate());
}
public int getLoanTermInDays() {