FINERACT-1981: pay-off transaction for progressive loans
This commit is contained in:
committed by
Adam Saghy
parent
5ebd3429c6
commit
80f4627623
+2
-2
@@ -264,10 +264,10 @@ public class ProgressiveLoanScheduleGenerator implements LoanScheduleGenerator {
|
|||||||
log.debug("calculating prepayment amount till rest frequency date (Strategy B)");
|
log.debug("calculating prepayment amount till rest frequency date (Strategy B)");
|
||||||
OutstandingAmountsDTO outstandingAmounts = new OutstandingAmountsDTO(currency);
|
OutstandingAmountsDTO outstandingAmounts = new OutstandingAmountsDTO(currency);
|
||||||
loan.getRepaymentScheduleInstallments().forEach(installment -> {
|
loan.getRepaymentScheduleInstallments().forEach(installment -> {
|
||||||
boolean isPayoffAfterInstallmentFrom = installment.getFromDate().isAfter(onDate);
|
boolean isPayoffBeforeInstallment = installment.getFromDate().isBefore(onDate);
|
||||||
|
|
||||||
outstandingAmounts.plusPrincipal(installment.getPrincipalOutstanding(currency));
|
outstandingAmounts.plusPrincipal(installment.getPrincipalOutstanding(currency));
|
||||||
if (!isPayoffAfterInstallmentFrom) {
|
if (isPayoffBeforeInstallment) {
|
||||||
outstandingAmounts.plusInterest(installment.getInterestOutstanding(currency));
|
outstandingAmounts.plusInterest(installment.getInterestOutstanding(currency));
|
||||||
} else {
|
} else {
|
||||||
log.debug("Payoff after installment {}, not counting interest", installment.getDueDate());
|
log.debug("Payoff after installment {}, not counting interest", installment.getDueDate());
|
||||||
|
|||||||
+17
-1
@@ -136,7 +136,7 @@ class ProgressiveLoanScheduleGeneratorTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void calculateSameDayPayoff() {
|
public void calculateSameDayPayoff_TILL_PRE_CLOSURE_DATE() {
|
||||||
LoanApplicationTerms terms = mock(LoanApplicationTerms.class);
|
LoanApplicationTerms terms = mock(LoanApplicationTerms.class);
|
||||||
when(terms.getPreClosureInterestCalculationStrategy()).thenReturn(TILL_PRE_CLOSURE_DATE);
|
when(terms.getPreClosureInterestCalculationStrategy()).thenReturn(TILL_PRE_CLOSURE_DATE);
|
||||||
|
|
||||||
@@ -151,6 +151,22 @@ class ProgressiveLoanScheduleGeneratorTest {
|
|||||||
assertEquals(BigDecimal.valueOf(200.0).longValue(), amounts.getTotalOutstanding().getAmount().longValue());
|
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
|
@NotNull
|
||||||
private Loan prepareLoanWithInstallments(List<TestRow> rows) {
|
private Loan prepareLoanWithInstallments(List<TestRow> rows) {
|
||||||
Loan loan = mock(Loan.class);
|
Loan loan = mock(Loan.class);
|
||||||
|
|||||||
Reference in New Issue
Block a user