Skip to content

Commit 2681ee3

Browse files
Jose Alberto Hernandezadamsaghy
authored andcommitted
FINERACT-2389: Pay-Off amount incorrectly calculated when downpayment
1 parent 60526f0 commit 2681ee3

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

fineract-e2e-tests-runner/src/test/resources/features/LoanCapitalizedIncome.feature

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1699,7 +1699,6 @@ Feature: Capitalized Income
16991699
| 100.0 | 83.33 | 16.67 | 0.0 | 0.0 |
17001700

17011701
When Loan Pay-off is made on "26 January 2024"
1702-
And Customer makes "AUTOPAY" repayment on "26 January 2024" with 225 EUR transaction amount
17031702
Then Loan is closed with zero outstanding balance and it's all installments have obligations met
17041703

17051704
@TestRailId:C3673

fineract-progressive-loan/src/main/java/org/apache/fineract/portfolio/loanaccount/loanschedule/domain/ProgressiveLoanScheduleGenerator.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,10 +205,19 @@ public OutstandingAmountsDTO calculatePrepaymentAmount(MonetaryCurrency currency
205205
ProgressiveLoanInterestScheduleModel model = savedModel.orElseThrow();
206206
OutstandingDetails outstandingAmounts = emiCalculator.getOutstandingAmountsTillDate(model, transactionDate);
207207
// TODO: We should add all the past due outstanding amounts as well
208+
208209
OutstandingAmountsDTO result = new OutstandingAmountsDTO(currency) //
209210
.principal(outstandingAmounts.getOutstandingPrincipal()) //
210211
.interest(outstandingAmounts.getOutstandingInterest());//
211212

213+
if (loan.isProgressiveSchedule()) {
214+
final LoanRepaymentScheduleInstallment downPaymentInstallment = loan.getRepaymentScheduleInstallments(i -> i.isDownPayment())
215+
.stream().findFirst().orElse(null);
216+
if (downPaymentInstallment != null) {
217+
result.principal(downPaymentInstallment.getPrincipalOutstanding(loan.getCurrency())
218+
.add(outstandingAmounts.getOutstandingPrincipal()));
219+
}
220+
}
212221
// We need to deduct any paid amount if there is no interest recalculation
213222
if (!loan.isInterestRecalculationEnabled()) {
214223
BigDecimal paidInterest = installments.stream().map(LoanRepaymentScheduleInstallment::getInterestPaid).reduce(BigDecimal.ZERO,

0 commit comments

Comments
 (0)