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
commit 007187111d06cd88049b724659aa00af191fdba5 Author: Rustam Zeinalov <[email protected]> AuthorDate: Wed Jan 28 12:55:22 2026 +0100 FINERACT-2413: added e2e test for handling multiple re-amortization on the loan --- .../fineract/test/helper/ErrorMessageHelper.java | 4 + .../stepdef/loan/LoanReAmortizationStepDef.java | 17 +++ .../resources/features/LoanReAmortization.feature | 143 ++++++++++++++++++++- 3 files changed, 161 insertions(+), 3 deletions(-) diff --git a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/helper/ErrorMessageHelper.java b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/helper/ErrorMessageHelper.java index 745ff7b13b..cc84aa03fc 100644 --- a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/helper/ErrorMessageHelper.java +++ b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/helper/ErrorMessageHelper.java @@ -994,4 +994,8 @@ public final class ErrorMessageHelper { public static String reAmortizeClosedLoanFailure() { return "Loan re-amortization can only be done on active loans"; } + + public static String reAmortizeSameDateFailure() { + return "Validation errors: [id] Loan reamortization can only be done once a day. There has already been a reamortization done for today"; + } } diff --git a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/stepdef/loan/LoanReAmortizationStepDef.java b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/stepdef/loan/LoanReAmortizationStepDef.java index f28fc92686..54365c0963 100644 --- a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/stepdef/loan/LoanReAmortizationStepDef.java +++ b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/stepdef/loan/LoanReAmortizationStepDef.java @@ -70,6 +70,18 @@ public class LoanReAmortizationStepDef extends AbstractStepDef { testContext().set(TestContextKey.LOAN_REAMORTIZATION_RESPONSE, response); } + @When("Admin creates a Loan re-amortization transaction on current business date with reAmortizationInterestHandling {string} should FAIL") + public void createLoanReAmortizationWithInterestHandlingShouldFail(final String reAmortizationInterestHandling) { + final PostLoansResponse loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE); + final Long loanId = loanResponse.getLoanId(); + + final PostLoansLoanIdTransactionsRequest reAmortizationRequest = LoanRequestFactory.defaultLoanReAmortizationRequest() + .reAmortizationInterestHandling(reAmortizationInterestHandling); + + fail(() -> fineractClient.loanTransactions().executeLoanTransaction(loanId, reAmortizationRequest, + Map.of("command", "reAmortize"))); + } + @When("Admin creates a Loan re-amortization transaction on current business date with reAmortizationInterestHandling {string}") public void createLoanReAmortizationWithInterestHandling(final String reAmortizationInterestHandling) { final PostLoansResponse loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE); @@ -157,6 +169,11 @@ public class LoanReAmortizationStepDef extends AbstractStepDef { reAmortizationFailure(ErrorMessageHelper.reAmortizeClosedLoanFailure()); } + @When("Admin creates a Loan re-amortization transaction on current business date is forbidden as re-amortization already done for today") + public void reAmortizationSameDateFailure() { + reAmortizationFailure(ErrorMessageHelper.reAmortizeSameDateFailure()); + } + @When("Admin creates re-amortization trn on current business date with reAmortizationInterestHandling {string} is forbidden as loan was closed") public void reAmortizationWithInterestHandlingClosedLoanFailure(final String reAmortizationInterestHandling) { reAmortizationInterestHandlingLoanLoanFailure(reAmortizationInterestHandling, ErrorMessageHelper.reAmortizeClosedLoanFailure()); diff --git a/fineract-e2e-tests-runner/src/test/resources/features/LoanReAmortization.feature b/fineract-e2e-tests-runner/src/test/resources/features/LoanReAmortization.feature index 26d3ad54e3..0080cfa064 100644 --- a/fineract-e2e-tests-runner/src/test/resources/features/LoanReAmortization.feature +++ b/fineract-e2e-tests-runner/src/test/resources/features/LoanReAmortization.feature @@ -1798,9 +1798,7 @@ Feature: LoanReAmortization When Loan Pay-off is made on "15 March 2024" Then Loan is closed with zero outstanding balance and it's all installments have obligations met - #will be handled in separate story - @Skip - @TestRailId:C4310 @AdvancedPaymentAllocation + @TestRailId:C4310 @AdvancedPaymentAllocation @MultiReAmortization Scenario: Verify multiple Re-amortizations on the same loan - Interest calculation: Default Behavior - Multiple Re-amortizations on the same loan When Admin sets the business date to "01 January 2024" When Admin creates a client with random data @@ -1857,6 +1855,31 @@ Feature: LoanReAmortization When Loan Pay-off is made on "15 May 2024" Then Loan is closed with zero outstanding balance and it's all installments have obligations met + @AdvancedPaymentAllocation @MultiReAmortization + Scenario: Verify multiple Re-amortizations on the same loan - Interest calculation: Equal Amortization Behavior - Multiple Re-amortizations on the same loan + When Admin sets the business date to "01 January 2024" + When Admin creates a client with random data + When Admin creates a fully customized loan with the following data: + | LoanProduct | submitted on date | with Principal | ANNUAL interest rate % | interest type | interest calculation period | amortization type | loanTermFrequency | loanTermFrequencyType | repaymentEvery | repaymentFrequencyType | numberOfRepayments | graceOnPrincipalPayment | graceOnInterestPayment | interest free period | Payment strategy | + | LP2_ADV_CUSTOM_PMT_ALLOC_PROGRESSIVE_LOAN_SCHEDULE_HORIZONTAL | 01 January 2024 | 100 | 7 | DECLINING_BALANCE | DAILY | EQUAL_INSTALLMENTS | 6 | MONTHS | 1 | MONTHS | 6 | 0 | 0 | 0 | ADVANCED_PAYMENT_ALLOCATION | + And Admin successfully approves the loan on "01 January 2024" with "100" amount and expected disbursement date on "01 January 2024" + When Admin successfully disburse the loan on "01 January 2024" with "100" EUR transaction amount + When Admin sets the business date to "01 February 2024" + And Customer makes "AUTOPAY" repayment on "01 February 2024" with 17.01 EUR transaction amount + + When Admin sets the business date to "15 March 2024" + And Admin creates a Loan re-amortization transaction on current business date with reAmortizationInterestHandling "EQUAL_AMORTIZATION_INTEREST_SPLIT" + + When Admin sets the business date to "01 May 2024" + And Admin creates a Loan re-amortization transaction on current business date with reAmortizationInterestHandling "DEFAULT" should FAIL + And Admin creates a Loan re-amortization transaction on current business date with reAmortizationInterestHandling "EQUAL_AMORTIZATION_INTEREST_SPLIT" + + # --- close the loan --- # + When Admin sets the business date to "15 May 2024" + When Loan Pay-off is made on "15 May 2024" + Then Loan is closed with zero outstanding balance and it's all installments have obligations met + + @TestRailId:C4311 @AdvancedPaymentAllocation Scenario: Verify Re-amortization with overdue penalties - Interest calculation: Default Behavior - Re-amortization with overdue penalties When Admin sets the business date to "01 January 2024" @@ -6591,3 +6614,117 @@ Feature: LoanReAmortization When Admin sets the business date to "01 June 2024" When Loan Pay-off is made on "01 June 2024" Then Loan is closed with zero outstanding balance and it's all installments have obligations met + + @TestRailId:C4581 @AdvancedPaymentAllocation @MultiReAmortization + Scenario: Verify multiple Re-amortizations on a loan without repayment between them - principal and interest - UC1 + When Admin sets the business date to "01 January 2024" + When Admin creates a client with random data + When Admin creates a fully customized loan with the following data: + | LoanProduct | submitted on date | with Principal | ANNUAL interest rate % | interest type | interest calculation period | amortization type | loanTermFrequency | loanTermFrequencyType | repaymentEvery | repaymentFrequencyType | numberOfRepayments | graceOnPrincipalPayment | graceOnInterestPayment | interest free period | Payment strategy | + | LP2_ADV_CUSTOM_PMT_ALLOC_PROGRESSIVE_LOAN_SCHEDULE_HORIZONTAL | 01 January 2024 | 100 | 7 | DECLINING_BALANCE | DAILY | EQUAL_INSTALLMENTS | 6 | MONTHS | 1 | MONTHS | 6 | 0 | 0 | 0 | ADVANCED_PAYMENT_ALLOCATION | + And Admin successfully approves the loan on "01 January 2024" with "100" amount and expected disbursement date on "01 January 2024" + When Admin successfully disburse the loan on "01 January 2024" with "100" EUR transaction amount + Then Loan Repayment schedule has 6 periods, with the following data for periods: + | Nr | Days | Date | Paid date | Balance of loan | Principal due | Interest | Fees | Penalties | Due | Paid | In advance | Late | Outstanding | + | | | 01 January 2024 | | 100.0 | | | 0.0 | | 0.0 | 0.0 | | | | + | 1 | 31 | 01 February 2024 | | 83.57 | 16.43 | 0.58 | 0.0 | 0.0 | 17.01 | 0.0 | 0.0 | 0.0 | 17.01 | + | 2 | 29 | 01 March 2024 | | 67.05 | 16.52 | 0.49 | 0.0 | 0.0 | 17.01 | 0.0 | 0.0 | 0.0 | 17.01 | + | 3 | 31 | 01 April 2024 | | 50.43 | 16.62 | 0.39 | 0.0 | 0.0 | 17.01 | 0.0 | 0.0 | 0.0 | 17.01 | + | 4 | 30 | 01 May 2024 | | 33.71 | 16.72 | 0.29 | 0.0 | 0.0 | 17.01 | 0.0 | 0.0 | 0.0 | 17.01 | + | 5 | 31 | 01 June 2024 | | 16.9 | 16.81 | 0.2 | 0.0 | 0.0 | 17.01 | 0.0 | 0.0 | 0.0 | 17.01 | + | 6 | 30 | 01 July 2024 | | 0.0 | 16.9 | 0.1 | 0.0 | 0.0 | 17.0 | 0.0 | 0.0 | 0.0 | 17.0 | + Then Loan Repayment schedule has the following data in Total row: + | Principal due | Interest | Fees | Penalties | Due | Paid | In advance | Late | Outstanding | + | 100.0 | 2.05 | 0.0 | 0.0 | 102.05 | 0.0 | 0.0 | 0.0 | 102.05 | + Then Loan Transactions tab has the following data: + | Transaction date | Transaction Type | Amount | Principal | Interest | Fees | Penalties | Loan Balance | Reverted | Replayed | + | 01 January 2024 | Disbursement | 100.0 | 0.0 | 0.0 | 0.0 | 0.0 | 100.0 | false | false | + When Admin sets the business date to "01 February 2024" + And Customer makes "AUTOPAY" repayment on "01 February 2024" with 17.01 EUR transaction amount + Then Loan Repayment schedule has 6 periods, with the following data for periods: + | Nr | Days | Date | Paid date | Balance of loan | Principal due | Interest | Fees | Penalties | Due | Paid | In advance | Late | Outstanding | + | | | 01 January 2024 | | 100.0 | | | 0.0 | | 0.0 | 0.0 | | | | + | 1 | 31 | 01 February 2024 | 01 February 2024 | 83.57 | 16.43 | 0.58 | 0.0 | 0.0 | 17.01 | 17.01 | 0.0 | 0.0 | 0.0 | + | 2 | 29 | 01 March 2024 | | 67.05 | 16.52 | 0.49 | 0.0 | 0.0 | 17.01 | 0.0 | 0.0 | 0.0 | 17.01 | + | 3 | 31 | 01 April 2024 | | 50.43 | 16.62 | 0.39 | 0.0 | 0.0 | 17.01 | 0.0 | 0.0 | 0.0 | 17.01 | + | 4 | 30 | 01 May 2024 | | 33.71 | 16.72 | 0.29 | 0.0 | 0.0 | 17.01 | 0.0 | 0.0 | 0.0 | 17.01 | + | 5 | 31 | 01 June 2024 | | 16.9 | 16.81 | 0.2 | 0.0 | 0.0 | 17.01 | 0.0 | 0.0 | 0.0 | 17.01 | + | 6 | 30 | 01 July 2024 | | 0.0 | 16.9 | 0.1 | 0.0 | 0.0 | 17.0 | 0.0 | 0.0 | 0.0 | 17.0 | + Then Loan Repayment schedule has the following data in Total row: + | Principal due | Interest | Fees | Penalties | Due | Paid | In advance | Late | Outstanding | + | 100.0 | 2.05 | 0.0 | 0.0 | 102.05 | 17.01 | 0.0 | 0.0 | 85.04 | + Then Loan Transactions tab has the following data: + | Transaction date | Transaction Type | Amount | Principal | Interest | Fees | Penalties | Loan Balance | Reverted | Replayed | + | 01 January 2024 | Disbursement | 100.0 | 0.0 | 0.0 | 0.0 | 0.0 | 100.0 | false | false | + | 01 February 2024 | Repayment | 17.01 | 16.43 | 0.58 | 0.0 | 0.0 | 83.57 | false | false | + When Admin sets the business date to "15 March 2024" + When Admin creates a Loan re-amortization transaction on current business date + Then Loan Repayment schedule has 6 periods, with the following data for periods: + | Nr | Days | Date | Paid date | Balance of loan | Principal due | Interest | Fees | Penalties | Due | Paid | In advance | Late | Outstanding | + | | | 01 January 2024 | | 100.0 | | | 0.0 | | 0.0 | 0.0 | | | | + | 1 | 31 | 01 February 2024 | 01 February 2024 | 83.57 | 16.43 | 0.58 | 0.0 | 0.0 | 17.01 | 17.01 | 0.0 | 0.0 | 0.0 | + | 2 | 29 | 01 March 2024 | 15 March 2024 | 83.57 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | + | 3 | 31 | 01 April 2024 | | 63.23 | 20.34 | 0.98 | 0.0 | 0.0 | 21.32 | 0.0 | 0.0 | 0.0 | 21.32 | + | 4 | 30 | 01 May 2024 | | 42.28 | 20.95 | 0.37 | 0.0 | 0.0 | 21.32 | 0.0 | 0.0 | 0.0 | 21.32 | + | 5 | 31 | 01 June 2024 | | 21.21 | 21.07 | 0.25 | 0.0 | 0.0 | 21.32 | 0.0 | 0.0 | 0.0 | 21.32 | + | 6 | 30 | 01 July 2024 | | 0.0 | 21.21 | 0.12 | 0.0 | 0.0 | 21.33 | 0.0 | 0.0 | 0.0 | 21.33 | + Then Loan Repayment schedule has the following data in Total row: + | Principal due | Interest | Fees | Penalties | Due | Paid | In advance | Late | Outstanding | + | 100.0 | 2.3 | 0.0 | 0.0 | 102.3 | 17.01 | 0.0 | 0.0 | 85.29 | + Then Loan Transactions tab has the following data: + | Transaction date | Transaction Type | Amount | Principal | Interest | Fees | Penalties | Loan Balance | Reverted | Replayed | + | 01 January 2024 | Disbursement | 100.0 | 0.0 | 0.0 | 0.0 | 0.0 | 100.0 | false | false | + | 01 February 2024 | Repayment | 17.01 | 16.43 | 0.58 | 0.0 | 0.0 | 83.57 | false | false | + | 15 March 2024 | Re-amortize | 17.01 | 16.52 | 0.49 | 0.0 | 0.0 | 0.0 | false | false | + When Admin sets the business date to "01 May 2024" + When Admin creates a Loan re-amortization transaction on current business date + Then Loan Repayment schedule has 6 periods, with the following data for periods: + | Nr | Days | Date | Paid date | Balance of loan | Principal due | Interest | Fees | Penalties | Due | Paid | In advance | Late | Outstanding | + | | | 01 January 2024 | | 100.0 | | | 0.0 | | 0.0 | 0.0 | | | | + | 1 | 31 | 01 February 2024 | 01 February 2024 | 83.57 | 16.43 | 0.58 | 0.0 | 0.0 | 17.01 | 17.01 | 0.0 | 0.0 | 0.0 | + | 2 | 29 | 01 March 2024 | 15 March 2024 | 83.57 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | + | 3 | 31 | 01 April 2024 | 01 May 2024 | 83.57 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | + | 4 | 30 | 01 May 2024 | 01 May 2024 | 83.57 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | + | 5 | 31 | 01 June 2024 | | 42.64 | 40.93 | 1.96 | 0.0 | 0.0 | 42.89 | 0.0 | 0.0 | 0.0 | 42.89 | + | 6 | 30 | 01 July 2024 | | 0.0 | 42.64 | 0.25 | 0.0 | 0.0 | 42.89 | 0.0 | 0.0 | 0.0 | 42.89 | + Then Loan Repayment schedule has the following data in Total row: + | Principal due | Interest | Fees | Penalties | Due | Paid | In advance | Late | Outstanding | + | 100.0 | 2.79 | 0.0 | 0.0 | 102.79 | 17.01 | 0.0 | 0.0 | 85.78 | + Then Loan Transactions tab has the following data: + | Transaction date | Transaction Type | Amount | Principal | Interest | Fees | Penalties | Loan Balance | Reverted | Replayed | + | 01 January 2024 | Disbursement | 100.0 | 0.0 | 0.0 | 0.0 | 0.0 | 100.0 | false | false | + | 01 February 2024 | Repayment | 17.01 | 16.43 | 0.58 | 0.0 | 0.0 | 83.57 | false | false | + | 15 March 2024 | Re-amortize | 17.01 | 16.52 | 0.49 | 0.0 | 0.0 | 0.0 | false | false | + | 01 May 2024 | Re-amortize | 42.64 | 41.17 | 1.47 | 0.0 | 0.0 | 0.0 | false | false | + + When Loan Pay-off is made on "01 May 2024" + Then Loan is closed with zero outstanding balance and it's all installments have obligations met + + @TestRailId:C4582 @AdvancedPaymentAllocation @MultiReAmortization + Scenario: Verify Re-amortization on the same date is forbidden + When Admin sets the business date to "01 January 2024" + When Admin creates a client with random data + When Admin creates a fully customized loan with the following data: + | LoanProduct | submitted on date | with Principal | ANNUAL interest rate % | interest type | interest calculation period | amortization type | loanTermFrequency | loanTermFrequencyType | repaymentEvery | repaymentFrequencyType | numberOfRepayments | graceOnPrincipalPayment | graceOnInterestPayment | interest free period | Payment strategy | + | LP2_ADV_CUSTOM_PMT_ALLOC_PROGRESSIVE_LOAN_SCHEDULE_HORIZONTAL | 01 January 2024 | 100 | 7 | DECLINING_BALANCE | DAILY | EQUAL_INSTALLMENTS | 6 | MONTHS | 1 | MONTHS | 6 | 0 | 0 | 0 | ADVANCED_PAYMENT_ALLOCATION | + And Admin successfully approves the loan on "01 January 2024" with "100" amount and expected disbursement date on "01 January 2024" + When Admin successfully disburse the loan on "01 January 2024" with "100" EUR transaction amount + When Admin sets the business date to "01 February 2024" + And Customer makes "AUTOPAY" repayment on "01 February 2024" with 17.01 EUR transaction amount + When Admin sets the business date to "15 March 2024" + When Admin creates a Loan re-amortization transaction on current business date + Then Loan Repayment schedule has 6 periods, with the following data for periods: + | Nr | Days | Date | Paid date | Balance of loan | Principal due | Interest | Fees | Penalties | Due | Paid | In advance | Late | Outstanding | + | | | 01 January 2024 | | 100.0 | | | 0.0 | | 0.0 | 0.0 | | | | + | 1 | 31 | 01 February 2024 | 01 February 2024 | 83.57 | 16.43 | 0.58 | 0.0 | 0.0 | 17.01 | 17.01 | 0.0 | 0.0 | 0.0 | + | 2 | 29 | 01 March 2024 | 15 March 2024 | 83.57 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | + | 3 | 31 | 01 April 2024 | | 63.23 | 20.34 | 0.98 | 0.0 | 0.0 | 21.32 | 0.0 | 0.0 | 0.0 | 21.32 | + | 4 | 30 | 01 May 2024 | | 42.28 | 20.95 | 0.37 | 0.0 | 0.0 | 21.32 | 0.0 | 0.0 | 0.0 | 21.32 | + | 5 | 31 | 01 June 2024 | | 21.21 | 21.07 | 0.25 | 0.0 | 0.0 | 21.32 | 0.0 | 0.0 | 0.0 | 21.32 | + | 6 | 30 | 01 July 2024 | | 0.0 | 21.21 | 0.12 | 0.0 | 0.0 | 21.33 | 0.0 | 0.0 | 0.0 | 21.33 | + Then Loan Transactions tab has the following data: + | Transaction date | Transaction Type | Amount | Principal | Interest | Fees | Penalties | Loan Balance | Reverted | Replayed | + | 01 January 2024 | Disbursement | 100.0 | 0.0 | 0.0 | 0.0 | 0.0 | 100.0 | false | false | + | 01 February 2024 | Repayment | 17.01 | 16.43 | 0.58 | 0.0 | 0.0 | 83.57 | false | false | + | 15 March 2024 | Re-amortize | 17.01 | 16.52 | 0.49 | 0.0 | 0.0 | 0.0 | false | false | + When Admin creates a Loan re-amortization transaction on current business date is forbidden as re-amortization already done for today
