Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FINERACT-1981: Interest recalculation - Progressive Loan Late Repayment Test Cases #4083

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -700,6 +700,93 @@ public void verifyEarlyLateRepaymentOnProgressiveLoanNextInstallmentAllocationRe
});
}

@Test
public void verifyEarlyLateRepaymentOnProgressiveLoanLastInstallmentAllocation() {
AtomicReference<Long> loanIdRef = new AtomicReference<>();
runAt("1 January 2024", () -> {
PostLoanProductsResponse loanProduct = loanProductHelper.createLoanProduct(create4IProgressive() //
.paymentAllocation(List.of(createDefaultPaymentAllocation(FuturePaymentAllocationRule.LAST_INSTALLMENT))) //
.recalculationRestFrequencyType(RecalculationRestFrequencyType.DAILY) //
);

Long loanId = applyAndApproveProgressiveLoan(client.getClientId(), loanProduct.getResourceId(), "1 January 2024", 100.0, 7.0, 6,
null);
loanIdRef.set(loanId);

disburseLoan(loanId, BigDecimal.valueOf(100), "1 January 2024");

GetLoansLoanIdResponse loanDetails = loanTransactionHelper.getLoanDetails(loanId);
logLoanDetails(loanDetails);

validateFullyUnpaidRepaymentPeriod(loanDetails, 1, "01 February 2024", 16.43, 0.0, 0.0, 0.58);
validateFullyUnpaidRepaymentPeriod(loanDetails, 2, "01 March 2024", 16.52, 0.0, 0.0, 0.49);
validateFullyUnpaidRepaymentPeriod(loanDetails, 3, "01 April 2024", 16.62, 0.0, 0.0, 0.39);
validateFullyUnpaidRepaymentPeriod(loanDetails, 4, "01 May 2024", 16.72, 0.0, 0.0, 0.29);
validateFullyUnpaidRepaymentPeriod(loanDetails, 5, "01 June 2024", 16.81, 0.0, 0.0, 0.20);
validateFullyUnpaidRepaymentPeriod(loanDetails, 6, "01 July 2024", 16.90, 0.0, 0.0, 0.10);

});
runAt("15 February 2024", () -> {
Long loanId = loanIdRef.get();

inlineLoanCOBHelper.executeInlineCOB(List.of(loanId));

loanTransactionHelper.makeLoanRepayment("15 February 2024", 34.02F, loanId.intValue());

GetLoansLoanIdResponse loanDetails = loanTransactionHelper.getLoanDetails(loanId);
logLoanDetails(loanDetails);

validateFullyPaidRepaymentPeriod(loanDetails, 1, "01 February 2024", 16.43, 0.0, 0.0, 0.58, 17.01);
validateFullyUnpaidRepaymentPeriod(loanDetails, 2, "01 March 2024", 16.53, 0.0, 0.0, 0.48);
validateFullyUnpaidRepaymentPeriod(loanDetails, 3, "01 April 2024", 16.72, 0.0, 0.0, 0.29);
validateFullyUnpaidRepaymentPeriod(loanDetails, 4, "01 May 2024", 16.82, 0.0, 0.0, 0.19);
validateFullyUnpaidRepaymentPeriod(loanDetails, 5, "01 June 2024", 16.49, 0.0, 0.0, 0.1);
validateFullyPaidRepaymentPeriod(loanDetails, 6, "01 July 2024", 17.01, 0.0, 0.0, 0.0, 0.0, 17.01);
});
}

@Test
public void verifyEarlyLateRepaymentOnProgressiveLoanNextInstallmentAllocationRepayDoubleOfEmi() {
AtomicReference<Long> loanIdRef = new AtomicReference<>();
runAt("1 January 2024", () -> {
PostLoanProductsResponse loanProduct = loanProductHelper.createLoanProduct(create4IProgressive());

Long loanId = applyAndApproveProgressiveLoan(client.getClientId(), loanProduct.getResourceId(), "1 January 2024", 100.0, 7.0, 6,
null);
loanIdRef.set(loanId);

disburseLoan(loanId, BigDecimal.valueOf(100), "1 January 2024");

GetLoansLoanIdResponse loanDetails = loanTransactionHelper.getLoanDetails(loanId);
logLoanDetails(loanDetails);

validateFullyUnpaidRepaymentPeriod(loanDetails, 1, "01 February 2024", 16.43, 0.0, 0.0, 0.58);
validateFullyUnpaidRepaymentPeriod(loanDetails, 2, "01 March 2024", 16.52, 0.0, 0.0, 0.49);
validateFullyUnpaidRepaymentPeriod(loanDetails, 3, "01 April 2024", 16.62, 0.0, 0.0, 0.39);
validateFullyUnpaidRepaymentPeriod(loanDetails, 4, "01 May 2024", 16.72, 0.0, 0.0, 0.29);
validateFullyUnpaidRepaymentPeriod(loanDetails, 5, "01 June 2024", 16.81, 0.0, 0.0, 0.20);
validateFullyUnpaidRepaymentPeriod(loanDetails, 6, "01 July 2024", 16.90, 0.0, 0.0, 0.10);

});
runAt("15 February 2024", () -> {
Long loanId = loanIdRef.get();

inlineLoanCOBHelper.executeInlineCOB(List.of(loanId));

loanTransactionHelper.makeLoanRepayment("15 February 2024", 34.02F, loanId.intValue());

GetLoansLoanIdResponse loanDetails = loanTransactionHelper.getLoanDetails(loanId);
logLoanDetails(loanDetails);

validateFullyPaidRepaymentPeriod(loanDetails, 1, "01 February 2024", 16.43, 0.0, 0.0, 0.58, 17.01);
validateFullyPaidRepaymentPeriod(loanDetails, 2, "01 March 2024", 16.73, 0.0, 0.0, 0.28, 0.0, 17.01);
validateFullyUnpaidRepaymentPeriod(loanDetails, 3, "01 April 2024", 16.42, 0.0, 0.0, 0.59);
validateFullyUnpaidRepaymentPeriod(loanDetails, 4, "01 May 2024", 16.72, 0.0, 0.0, 0.29);
validateFullyUnpaidRepaymentPeriod(loanDetails, 5, "01 June 2024", 16.81, 0.0, 0.0, 0.20);
validateFullyUnpaidRepaymentPeriod(loanDetails, 6, "01 July 2024", 16.89, 0.0, 0.0, 0.10);
});
}

@Test
public void verifyLoanInstallmentRecalculatedIfThereIsOverdueInstallmentOn4IProgressiveLoanCOBStepOnePaid() {
AtomicReference<Long> loanIdRef = new AtomicReference<>();
Expand Down
Loading