This is an automated email from the ASF dual-hosted git repository.
adamsaghy pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/fineract.git
The following commit(s) were added to refs/heads/develop by this push:
new e967426db FINERACT-2081: Loan Unpaid Payable Interest fix to include
amount paid
e967426db is described below
commit e967426db70bdbdf133dd2cd1354ff17fe9450f4
Author: Jose Alberto Hernandez <[email protected]>
AuthorDate: Fri Aug 2 15:17:42 2024 -0600
FINERACT-2081: Loan Unpaid Payable Interest fix to include amount paid
---
.../fineract/portfolio/loanaccount/data/LoanSummaryData.java | 7 +++++++
.../AdvancedPaymentAllocationLoanRepaymentScheduleTest.java | 2 +-
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git
a/fineract-loan/src/main/java/org/apache/fineract/portfolio/loanaccount/data/LoanSummaryData.java
b/fineract-loan/src/main/java/org/apache/fineract/portfolio/loanaccount/data/LoanSummaryData.java
index 9adb59de0..46567bf17 100644
---
a/fineract-loan/src/main/java/org/apache/fineract/portfolio/loanaccount/data/LoanSummaryData.java
+++
b/fineract-loan/src/main/java/org/apache/fineract/portfolio/loanaccount/data/LoanSummaryData.java
@@ -26,6 +26,7 @@ import lombok.Builder;
import lombok.Data;
import lombok.experimental.Accessors;
import org.apache.fineract.infrastructure.core.service.DateUtils;
+import org.apache.fineract.infrastructure.core.service.MathUtil;
import org.apache.fineract.organisation.monetary.data.CurrencyData;
import org.apache.fineract.organisation.monetary.domain.Money;
import org.apache.fineract.organisation.monetary.domain.MoneyHelper;
@@ -260,6 +261,12 @@ public class LoanSummaryData {
remainingDays--;
}
+ totalAccruedInterest =
totalAccruedInterest.subtract(period.getInterestPaid()).subtract(period.getInterestWaived());
+ if (MathUtil.isLessThanZero(totalAccruedInterest)) {
+ // Set Zero If the Interest Paid + Waived is greather than
Interest Accrued
+ totalAccruedInterest = BigDecimal.ZERO;
+ }
+
return Money.of(currency, totalAccruedInterest).getAmount();
}
diff --git
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/AdvancedPaymentAllocationLoanRepaymentScheduleTest.java
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/AdvancedPaymentAllocationLoanRepaymentScheduleTest.java
index f12f9fa93..be43cc313 100644
---
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/AdvancedPaymentAllocationLoanRepaymentScheduleTest.java
+++
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/AdvancedPaymentAllocationLoanRepaymentScheduleTest.java
@@ -4739,7 +4739,7 @@ public class
AdvancedPaymentAllocationLoanRepaymentScheduleTest extends BaseLoan
addRepaymentForLoan(createdLoanId.get(), 20.50, "30 January 2024");
loanDetails =
loanTransactionHelper.getLoanDetails(createdLoanId.get());
assertEquals(BigDecimal.ZERO,
loanDetails.getSummary().getTotalUnpaidPayableDueInterest().stripTrailingZeros());
- assertEquals(new BigDecimal("0.97"),
loanDetails.getSummary().getTotalUnpaidPayableNotDueInterest().stripTrailingZeros());
+ assertEquals(new BigDecimal("0.05"),
loanDetails.getSummary().getTotalUnpaidPayableNotDueInterest().stripTrailingZeros());
});
// Not Due and Due Interest