FINERACT-1839: Fix N+1 installment due date
This commit is contained in:
committed by
Arnold Gálovics
parent
f1e70111b4
commit
001ad2fa1f
+5
-1
@@ -372,9 +372,13 @@ public abstract class AbstractLoanRepaymentScheduleTransactionProcessor implemen
|
|||||||
loanTransactionMapped = true;
|
loanTransactionMapped = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// If already exists an additional installment just update
|
// If already exists an additional installment just update the due date and
|
||||||
// principal from the Loan chargeback / CBR transaction
|
// principal from the Loan chargeback / CBR transaction
|
||||||
} else if (currentInstallment.isAdditional()) {
|
} else if (currentInstallment.isAdditional()) {
|
||||||
|
if (transactionDate.isAfter(currentInstallment.getDueDate())) {
|
||||||
|
currentInstallment.updateDueDate(transactionDate);
|
||||||
|
}
|
||||||
|
|
||||||
currentInstallment.updateCredits(transactionDate, transactionAmount);
|
currentInstallment.updateCredits(transactionDate, transactionAmount);
|
||||||
if (repaidAmount.isGreaterThanZero()) {
|
if (repaidAmount.isGreaterThanZero()) {
|
||||||
currentInstallment.payPrincipalComponent(loanTransaction.getTransactionDate(), repaidAmount);
|
currentInstallment.payPrincipalComponent(loanTransaction.getTransactionDate(), repaidAmount);
|
||||||
|
|||||||
+14
-2
@@ -143,7 +143,8 @@ public class LoanTransactionReverseReplayTest {
|
|||||||
/**
|
/**
|
||||||
* 1 create a loan account - approve and disburse // 2. make repayment (fully paid) // 3. add the charge greater
|
* 1 create a loan account - approve and disburse // 2. make repayment (fully paid) // 3. add the charge greater
|
||||||
* than the maturity date // 4. make 2nd payment with excess amount - the loan will move to overpaid state. // 5. Do
|
* than the maturity date // 4. make 2nd payment with excess amount - the loan will move to overpaid state. // 5. Do
|
||||||
* a CBR transaction // 6. reverse the 2nd payment // 7. check the repayment schedule due date. //
|
* a CBR transaction // 6. reverse the 2nd payment // 7. check the repayment schedule due date. 8. add chargeback
|
||||||
|
* for 1st repayment 9. check the repayment schedule due date //
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void loanTransactionReverseReplayWithAdditionalInstallmentAndChargesScheduleDueDateTest() {
|
public void loanTransactionReverseReplayWithAdditionalInstallmentAndChargesScheduleDueDateTest() {
|
||||||
@@ -167,8 +168,9 @@ public class LoanTransactionReverseReplayTest {
|
|||||||
ChargesHelper.getLoanSpecifiedDueDateJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT, "10", true));
|
ChargesHelper.getLoanSpecifiedDueDateJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT, "10", true));
|
||||||
|
|
||||||
// make repayment
|
// make repayment
|
||||||
|
String loanTransactionExternalIdStr = UUID.randomUUID().toString();
|
||||||
loanTransactionHelper.makeLoanRepayment(loanExternalIdStr, new PostLoansLoanIdTransactionsRequest().dateFormat(DATE_PATTERN)
|
loanTransactionHelper.makeLoanRepayment(loanExternalIdStr, new PostLoansLoanIdTransactionsRequest().dateFormat(DATE_PATTERN)
|
||||||
.transactionDate("03 October 2022").locale("en").transactionAmount(1000.0));
|
.transactionDate("03 October 2022").locale("en").transactionAmount(1000.0).externalId(loanTransactionExternalIdStr));
|
||||||
|
|
||||||
LocalDate targetDate = LocalDate.of(2022, 10, 10);
|
LocalDate targetDate = LocalDate.of(2022, 10, 10);
|
||||||
final String penaltyCharge1AddedDate = dateFormatter.format(targetDate);
|
final String penaltyCharge1AddedDate = dateFormatter.format(targetDate);
|
||||||
@@ -202,6 +204,16 @@ public class LoanTransactionReverseReplayTest {
|
|||||||
lastPeriodIndex = loansLoanIdResponse.getRepaymentSchedule().getPeriods().size() - 1;
|
lastPeriodIndex = loansLoanIdResponse.getRepaymentSchedule().getPeriods().size() - 1;
|
||||||
assertEquals(LocalDate.of(2022, 10, 10),
|
assertEquals(LocalDate.of(2022, 10, 10),
|
||||||
loansLoanIdResponse.getRepaymentSchedule().getPeriods().get(lastPeriodIndex).getDueDate());
|
loansLoanIdResponse.getRepaymentSchedule().getPeriods().get(lastPeriodIndex).getDueDate());
|
||||||
|
|
||||||
|
businessDateHelper.updateBusinessDate(new BusinessDateRequest().type(BusinessDateType.BUSINESS_DATE.getName())
|
||||||
|
.date("11 October 2022").dateFormat(DATE_PATTERN).locale("en"));
|
||||||
|
loanTransactionHelper.chargebackLoanTransaction(loanExternalIdStr, loanTransactionExternalIdStr,
|
||||||
|
new PostLoansLoanIdTransactionsTransactionIdRequest().locale("en").transactionAmount(100.0).paymentTypeId(1L));
|
||||||
|
|
||||||
|
loansLoanIdResponse = loanTransactionHelper.getLoanDetails(loanExternalIdStr);
|
||||||
|
lastPeriodIndex = loansLoanIdResponse.getRepaymentSchedule().getPeriods().size() - 1;
|
||||||
|
assertEquals(LocalDate.of(2022, 10, 11),
|
||||||
|
loansLoanIdResponse.getRepaymentSchedule().getPeriods().get(lastPeriodIndex).getDueDate());
|
||||||
} finally {
|
} finally {
|
||||||
GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE);
|
GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user