diff --git a/fineract-e2e-tests-runner/src/test/resources/features/LoanCapitalizedIncome.feature b/fineract-e2e-tests-runner/src/test/resources/features/LoanCapitalizedIncome.feature index f9d35d130..5a6896172 100644 --- a/fineract-e2e-tests-runner/src/test/resources/features/LoanCapitalizedIncome.feature +++ b/fineract-e2e-tests-runner/src/test/resources/features/LoanCapitalizedIncome.feature @@ -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 diff --git a/fineract-progressive-loan/src/main/java/org/apache/fineract/portfolio/loanaccount/loanschedule/domain/ProgressiveLoanScheduleGenerator.java b/fineract-progressive-loan/src/main/java/org/apache/fineract/portfolio/loanaccount/loanschedule/domain/ProgressiveLoanScheduleGenerator.java index 71c2fa731..590c9e606 100644 --- a/fineract-progressive-loan/src/main/java/org/apache/fineract/portfolio/loanaccount/loanschedule/domain/ProgressiveLoanScheduleGenerator.java +++ b/fineract-progressive-loan/src/main/java/org/apache/fineract/portfolio/loanaccount/loanschedule/domain/ProgressiveLoanScheduleGenerator.java @@ -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,