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 80f462762 FINERACT-1981: pay-off transaction for progressive loans
80f462762 is described below
commit 80f46276239622c4a8fbb41cab046873a5d62027
Author: Kristof Jozsa <[email protected]>
AuthorDate: Wed Aug 14 11:14:48 2024 +0200
FINERACT-1981: pay-off transaction for progressive loans
---
.../domain/ProgressiveLoanScheduleGenerator.java | 4 ++--
.../domain/ProgressiveLoanScheduleGeneratorTest.java | 18 +++++++++++++++++-
2 files changed, 19 insertions(+), 3 deletions(-)
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 e28da6996..c56db656b 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
@@ -264,10 +264,10 @@ public class ProgressiveLoanScheduleGenerator implements
LoanScheduleGenerator {
log.debug("calculating prepayment amount till rest frequency
date (Strategy B)");
OutstandingAmountsDTO outstandingAmounts = new
OutstandingAmountsDTO(currency);
loan.getRepaymentScheduleInstallments().forEach(installment ->
{
- boolean isPayoffAfterInstallmentFrom =
installment.getFromDate().isAfter(onDate);
+ boolean isPayoffBeforeInstallment =
installment.getFromDate().isBefore(onDate);
outstandingAmounts.plusPrincipal(installment.getPrincipalOutstanding(currency));
- if (!isPayoffAfterInstallmentFrom) {
+ if (isPayoffBeforeInstallment) {
outstandingAmounts.plusInterest(installment.getInterestOutstanding(currency));
} else {
log.debug("Payoff after installment {}, not counting
interest", installment.getDueDate());
diff --git
a/fineract-progressive-loan/src/test/java/org/apache/fineract/portfolio/loanaccount/loanschedule/domain/ProgressiveLoanScheduleGeneratorTest.java
b/fineract-progressive-loan/src/test/java/org/apache/fineract/portfolio/loanaccount/loanschedule/domain/ProgressiveLoanScheduleGeneratorTest.java
index 9da9156b1..214bff051 100644
---
a/fineract-progressive-loan/src/test/java/org/apache/fineract/portfolio/loanaccount/loanschedule/domain/ProgressiveLoanScheduleGeneratorTest.java
+++
b/fineract-progressive-loan/src/test/java/org/apache/fineract/portfolio/loanaccount/loanschedule/domain/ProgressiveLoanScheduleGeneratorTest.java
@@ -136,7 +136,7 @@ class ProgressiveLoanScheduleGeneratorTest {
}
@Test
- public void calculateSameDayPayoff() {
+ public void calculateSameDayPayoff_TILL_PRE_CLOSURE_DATE() {
LoanApplicationTerms terms = mock(LoanApplicationTerms.class);
when(terms.getPreClosureInterestCalculationStrategy()).thenReturn(TILL_PRE_CLOSURE_DATE);
@@ -151,6 +151,22 @@ class ProgressiveLoanScheduleGeneratorTest {
assertEquals(BigDecimal.valueOf(200.0).longValue(),
amounts.getTotalOutstanding().getAmount().longValue());
}
+ @Test
+ public void calculateSameDayPayoff_TILL_REST_FREQUENCY_DATE() {
+ LoanApplicationTerms terms = mock(LoanApplicationTerms.class);
+
when(terms.getPreClosureInterestCalculationStrategy()).thenReturn(TILL_REST_FREQUENCY_DATE);
+
+ Loan loan = prepareLoanWithInstallments(List.of(
+ new TestRow(LocalDate.of(2024, 1, 1), LocalDate.of(2024, 2,
1), BigDecimal.valueOf(102), BigDecimal.valueOf(100),
+ BigDecimal.valueOf(2), ZERO, ZERO, false),
+ new TestRow(LocalDate.of(2024, 2, 1), LocalDate.of(2024, 3,
1), BigDecimal.valueOf(102), BigDecimal.valueOf(100),
+ BigDecimal.valueOf(2), ZERO, ZERO, false)));
+
+ OutstandingAmountsDTO amounts =
generator.calculatePrepaymentAmount(usd, LocalDate.of(2024, 1, 1), terms,
MathContext.DECIMAL32,
+ loan, holidays, processor);
+ assertEquals(BigDecimal.valueOf(200.0).longValue(),
amounts.getTotalOutstanding().getAmount().longValue());
+ }
+
@NotNull
private Loan prepareLoanWithInstallments(List<TestRow> rows) {
Loan loan = mock(Loan.class);