Skip to content

Commit 5f223e5

Browse files
MarianaDmytrivBinariksgalovics
authored andcommitted
FINERACT-2181: added e2e automation tests for disbursement with Capitalized income amount calculation fix
1 parent 19270b7 commit 5f223e5

File tree

3 files changed

+135
-2
lines changed

3 files changed

+135
-2
lines changed

fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/helper/ErrorMessageHelper.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ public static String disburseDateFailure(Integer loanId) {
6464
return String.format("The date on which a loan with identifier : %s is disbursed cannot be in the future.", loanIdStr);
6565
}
6666

67+
public static String addDisbursementExceedApprovedAmountFailure() {
68+
return "Loan can't be disbursed,disburse amount is exceeding approved principal ";
69+
}
70+
6771
public static String disbursePastDateFailure(Integer loanId, String actualDisbursementDate) {
6872
return String.format("The date on which a loan is disbursed cannot be before its approval date: %s", actualDisbursementDate);
6973
}

fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/stepdef/loan/LoanStepDef.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1661,6 +1661,21 @@ public void disburseLoanFailureWithPastDate(String actualDisbursementDate, Strin
16611661
.isEqualTo(ErrorMessageHelper.disbursePastDateFailure((int) loanId, futureApproveDateISO));
16621662
}
16631663

1664+
@Then("Admin fails to disburse the loan on {string} with {string} EUR transaction amount due to exceed approved amount")
1665+
public void disbursementForbiddenExceedApprovedAmount(String actualDisbursementDate, String transactionAmount) throws IOException {
1666+
Response<PostLoansResponse> loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
1667+
long loanId = loanResponse.body().getLoanId();
1668+
PostLoansLoanIdRequest disburseRequest = LoanRequestFactory.defaultLoanDisburseRequest()
1669+
.actualDisbursementDate(actualDisbursementDate).transactionAmount(new BigDecimal(transactionAmount));
1670+
1671+
Response<PostLoansLoanIdResponse> loanDisburseResponse = loansApi.stateTransitions(loanId, disburseRequest, "disburse").execute();
1672+
testContext().set(TestContextKey.LOAN_DISBURSE_RESPONSE, loanDisburseResponse);
1673+
ErrorResponse errorDetails = ErrorResponse.from(loanDisburseResponse);
1674+
assertThat(errorDetails.getHttpStatusCode()).as(ErrorMessageHelper.addDisbursementExceedApprovedAmountFailure()).isEqualTo(403);
1675+
assertThat(errorDetails.getSingleError().getDeveloperMessage())
1676+
.isEqualTo(ErrorMessageHelper.addDisbursementExceedApprovedAmountFailure());
1677+
}
1678+
16641679
@And("Admin does charge-off the loan on {string}")
16651680
public void chargeOffLoan(String transactionDate) throws IOException {
16661681
Response<PostLoansResponse> loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);

fineract-e2e-tests-runner/src/test/resources/features/LoanCapitalizedIncome.feature

Lines changed: 116 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ Feature: Capitalized Income
6262
| LIABILITY | 145024 | Deferred Capitalized Income | | 100.0 |
6363

6464
@TestRailId:C3638
65-
Scenario: Verify capitalized income amount with disbursement amount calculation within approved amount amount for multidisbursal progressive loan - UC3
65+
Scenario: Verify capitalized income amount with disbursement amount calculation within approved amount for multidisbursal progressive loan - UC3
6666
When Admin sets the business date to "1 January 2024"
6767
And Admin creates a client with random data
6868
When Admin creates a fully customized loan with the following data:
@@ -177,7 +177,7 @@ Feature: Capitalized Income
177177
| LIABILITY | 145024 | Deferred Capitalized Income | | 200.0 |
178178

179179
@TestRailId:C3642
180-
Scenario: Verify capitalized income amount with disbursement amount calculation within approved amount amount for multidisbursal loan after undo disbursement - UC7
180+
Scenario: Verify capitalized income amount with disbursement amount calculation within approved amount for multidisbursal loan after undo disbursement - UC7
181181
When Admin sets the business date to "1 January 2024"
182182
And Admin creates a client with random data
183183
And Admin creates a fully customized loan with the following data:
@@ -243,6 +243,120 @@ Feature: Capitalized Income
243243
| ASSET | 112601 | Loans Receivable | 300.0 | |
244244
| LIABILITY | 145024 | Deferred Capitalized Income | | 300.0 |
245245

246+
@TestRailId:C3720
247+
Scenario: Verify capitalized income amount with disbursement amount calculation within approved amount for multidisbursal loan - UC8
248+
When Admin sets the business date to "1 January 2024"
249+
And Admin creates a client with random data
250+
And Admin creates a fully customized loan with the following data:
251+
| 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 | charge calculation type | charge amount % |
252+
| LP2_ADV_PYMNT_INTEREST_DAILY_EMI_360_30_INTEREST_RECALC_DAILY_MULTIDISBURSAL_CAPITALIZED_INCOME | 01 January 2024 | 1000 | 7 | DECLINING_BALANCE | DAILY | EQUAL_INSTALLMENTS | 6 | MONTHS | 1 | MONTHS | 6 | 0 | 0 | 0 | ADVANCED_PAYMENT_ALLOCATION | LOAN_DISBURSEMENT_CHARGE | 2 |
253+
And Admin successfully approves the loan on "1 January 2024" with "1000" amount and expected disbursement date on "1 January 2024"
254+
And Admin successfully disburse the loan on "1 January 2024" with "700" EUR transaction amount
255+
Then Loan status will be "ACTIVE"
256+
When Admin sets the business date to "2 January 2024"
257+
And Admin adds capitalized income with "AUTOPAY" payment type to the loan on "2 January 2024" with "200" EUR transaction amount
258+
Then Loan Repayment schedule has 6 periods, with the following data for periods:
259+
| Nr | Days | Date | Paid date | Balance of loan | Principal due | Interest | Fees | Penalties | Due | Paid | In advance | Late | Outstanding |
260+
| | | 01 January 2024 | | 700.0 | | | 0.0 | | 0.0 | 0.0 | | | |
261+
| | | 02 January 2024 | | 200.0 | | | 0.0 | | 0.0 | 0.0 | | | |
262+
| 1 | 31 | 01 February 2024 | | 752.14 | 147.86 | 5.21 | 0.0 | 0.0 | 153.07 | 0.0 | 0.0 | 0.0 | 153.07 |
263+
| 2 | 29 | 01 March 2024 | | 603.46 | 148.68 | 4.39 | 0.0 | 0.0 | 153.07 | 0.0 | 0.0 | 0.0 | 153.07 |
264+
| 3 | 31 | 01 April 2024 | | 453.91 | 149.55 | 3.52 | 0.0 | 0.0 | 153.07 | 0.0 | 0.0 | 0.0 | 153.07 |
265+
| 4 | 30 | 01 May 2024 | | 303.49 | 150.42 | 2.65 | 0.0 | 0.0 | 153.07 | 0.0 | 0.0 | 0.0 | 153.07 |
266+
| 5 | 31 | 01 June 2024 | | 152.19 | 151.3 | 1.77 | 0.0 | 0.0 | 153.07 | 0.0 | 0.0 | 0.0 | 153.07 |
267+
| 6 | 30 | 01 July 2024 | | 0.0 | 152.19 | 0.89 | 0.0 | 0.0 | 153.08 | 0.0 | 0.0 | 0.0 | 153.08 |
268+
And Loan Repayment schedule has the following data in Total row:
269+
| Principal due | Interest | Fees | Penalties | Due | Paid | In advance | Late | Outstanding |
270+
| 900.0 | 18.43 | 0.0 | 0.0 | 918.43 | 0.0 | 0.0 | 0.0 | 918.43 |
271+
And Loan Transactions tab has the following data:
272+
| Transaction date | Transaction Type | Amount | Principal | Interest | Fees | Penalties | Loan Balance | Reverted |
273+
| 01 January 2024 | Disbursement | 700.0 | 0.0 | 0.0 | 0.0 | 0.0 | 700.0 | false |
274+
| 02 January 2024 | Capitalized Income | 200.0 | 200.0 | 0.0 | 0.0 | 0.0 | 900.0 | false |
275+
And Loan Transactions tab has a "CAPITALIZED_INCOME" transaction with date "02 January 2024" which has the following Journal entries:
276+
| Type | Account code | Account name | Debit | Credit |
277+
| ASSET | 112601 | Loans Receivable | 200.0 | |
278+
| LIABILITY | 145024 | Deferred Capitalized Income | | 200.0 |
279+
Then Admin fails to disburse the loan on "02 January 2024" with "200" EUR transaction amount due to exceed approved amount
280+
Then Capitalized income with payment type "AUTOPAY" on "02 January 2024" is forbidden with amount "200" while exceed approved amount
281+
282+
@TestRailId:C3721
283+
Scenario: Verify capitalized income amount with disbursement amount calculation within approved amount for multidisbursal loan with undo last disbursal - UC9
284+
When Admin sets the business date to "1 January 2024"
285+
And Admin creates a client with random data
286+
And Admin creates a fully customized loan with the following data:
287+
| 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 | charge calculation type | charge amount % |
288+
| LP2_ADV_PYMNT_INTEREST_DAILY_EMI_360_30_INTEREST_RECALC_DAILY_MULTIDISBURSAL_CAPITALIZED_INCOME | 01 January 2024 | 1000 | 7 | DECLINING_BALANCE | DAILY | EQUAL_INSTALLMENTS | 6 | MONTHS | 1 | MONTHS | 6 | 0 | 0 | 0 | ADVANCED_PAYMENT_ALLOCATION | LOAN_DISBURSEMENT_CHARGE | 2 |
289+
And Admin successfully approves the loan on "1 January 2024" with "1000" amount and expected disbursement date on "1 January 2024"
290+
And Admin successfully disburse the loan on "1 January 2024" with "500" EUR transaction amount
291+
Then Loan status will be "ACTIVE"
292+
When Admin sets the business date to "2 January 2024"
293+
And Admin adds capitalized income with "AUTOPAY" payment type to the loan on "2 January 2024" with "150" EUR transaction amount
294+
When Admin sets the business date to "3 January 2024"
295+
And Admin successfully disburse the loan on "3 January 2024" with "250" EUR transaction amount
296+
And Admin adds capitalized income with "AUTOPAY" payment type to the loan on "3 January 2024" with "50" EUR transaction amount
297+
Then Loan Repayment schedule has 6 periods, with the following data for periods:
298+
| Nr | Days | Date | Paid date | Balance of loan | Principal due | Interest | Fees | Penalties | Due | Paid | In advance | Late | Outstanding |
299+
| | | 01 January 2024 | | 500.0 | | | 0.0 | | 0.0 | 0.0 | | | |
300+
| | | 02 January 2024 | | 150.0 | | | 0.0 | | 0.0 | 0.0 | | | |
301+
| | | 03 January 2024 | | 250.0 | | | 0.0 | | 0.0 | 0.0 | | | |
302+
| | | 03 January 2024 | | 50.0 | | | 0.0 | | 0.0 | 0.0 | | | |
303+
| 1 | 31 | 01 February 2024 | | 793.84 | 156.16 | 5.4 | 0.0 | 0.0 | 161.56 | 0.0 | 0.0 | 0.0 | 161.56 |
304+
| 2 | 29 | 01 March 2024 | | 636.91 | 156.93 | 4.63 | 0.0 | 0.0 | 161.56 | 0.0 | 0.0 | 0.0 | 161.56 |
305+
| 3 | 31 | 01 April 2024 | | 479.07 | 157.84 | 3.72 | 0.0 | 0.0 | 161.56 | 0.0 | 0.0 | 0.0 | 161.56 |
306+
| 4 | 30 | 01 May 2024 | | 320.3 | 158.77 | 2.79 | 0.0 | 0.0 | 161.56 | 0.0 | 0.0 | 0.0 | 161.56 |
307+
| 5 | 31 | 01 June 2024 | | 160.61 | 159.69 | 1.87 | 0.0 | 0.0 | 161.56 | 0.0 | 0.0 | 0.0 | 161.56 |
308+
| 6 | 30 | 01 July 2024 | | 0.0 | 160.61 | 0.94 | 0.0 | 0.0 | 161.55 | 0.0 | 0.0 | 0.0 | 161.55 |
309+
And Loan Repayment schedule has the following data in Total row:
310+
| Principal due | Interest | Fees | Penalties | Due | Paid | In advance | Late | Outstanding |
311+
| 950.0 | 19.35 | 0.0 | 0.0 | 969.35 | 0.0 | 0.0 | 0.0 | 969.35 |
312+
And Loan Transactions tab has the following data:
313+
| Transaction date | Transaction Type | Amount | Principal | Interest | Fees | Penalties | Loan Balance | Reverted |
314+
| 01 January 2024 | Disbursement | 500.0 | 0.0 | 0.0 | 0.0 | 0.0 | 500.0 | false |
315+
| 02 January 2024 | Capitalized Income | 150.0 | 150.0 | 0.0 | 0.0 | 0.0 | 650.0 | false |
316+
| 03 January 2024 | Disbursement | 250.0 | 0.0 | 0.0 | 0.0 | 0.0 | 900.0 | false |
317+
| 03 January 2024 | Capitalized Income | 50.0 | 50.0 | 0.0 | 0.0 | 0.0 | 950.0 | false |
318+
And Loan Transactions tab has a "CAPITALIZED_INCOME" transaction with date "02 January 2024" which has the following Journal entries:
319+
| Type | Account code | Account name | Debit | Credit |
320+
| ASSET | 112601 | Loans Receivable | 150.0 | |
321+
| LIABILITY | 145024 | Deferred Capitalized Income | | 150.0 |
322+
Then Admin fails to disburse the loan on "03 January 2024" with "100" EUR transaction amount due to exceed approved amount
323+
Then Capitalized income with payment type "AUTOPAY" on "03 January 2024" is forbidden with amount "100" while exceed approved amount
324+
# --- undo last disbursement --- #
325+
And Admin sets the business date to "4 January 2024"
326+
When Admin successfully undo last disbursal
327+
And Loan Transactions tab has the following data:
328+
| Transaction date | Transaction Type | Amount | Principal | Interest | Fees | Penalties | Loan Balance | Reverted |
329+
| 01 January 2024 | Disbursement | 500.0 | 0.0 | 0.0 | 0.0 | 0.0 | 500.0 | false |
330+
| 02 January 2024 | Capitalized Income | 150.0 | 150.0 | 0.0 | 0.0 | 0.0 | 650.0 | false |
331+
| 03 January 2024 | Capitalized Income | 50.0 | 50.0 | 0.0 | 0.0 | 0.0 | 700.0 | false |
332+
And Admin successfully disburse the loan on "4 January 2024" with "100" EUR transaction amount
333+
And Admin adds capitalized income with "AUTOPAY" payment type to the loan on "4 January 2024" with "100" EUR transaction amount
334+
Then Loan Repayment schedule has 6 periods, with the following data for periods:
335+
| Nr | Days | Date | Paid date | Balance of loan | Principal due | Interest | Fees | Penalties | Due | Paid | In advance | Late | Outstanding |
336+
| | | 01 January 2024 | | 500.0 | | | 0.0 | | 0.0 | 0.0 | | | |
337+
| | | 02 January 2024 | | 150.0 | | | 0.0 | | 0.0 | 0.0 | | | |
338+
| | | 03 January 2024 | | 50.0 | | | 0.0 | | 0.0 | 0.0 | | | |
339+
| | | 04 January 2024 | | 100.0 | | | 0.0 | | 0.0 | 0.0 | | | |
340+
| | | 04 January 2024 | | 100.0 | | | 0.0 | | 0.0 | 0.0 | | | |
341+
| 1 | 31 | 01 February 2024 | | 752.04 | 147.96 | 5.09 | 0.0 | 0.0 | 153.05 | 0.0 | 0.0 | 0.0 | 153.05 |
342+
| 2 | 29 | 01 March 2024 | | 603.38 | 148.66 | 4.39 | 0.0 | 0.0 | 153.05 | 0.0 | 0.0 | 0.0 | 153.05 |
343+
| 3 | 31 | 01 April 2024 | | 453.85 | 149.53 | 3.52 | 0.0 | 0.0 | 153.05 | 0.0 | 0.0 | 0.0 | 153.05 |
344+
| 4 | 30 | 01 May 2024 | | 303.45 | 150.4 | 2.65 | 0.0 | 0.0 | 153.05 | 0.0 | 0.0 | 0.0 | 153.05 |
345+
| 5 | 31 | 01 June 2024 | | 152.17 | 151.28 | 1.77 | 0.0 | 0.0 | 153.05 | 0.0 | 0.0 | 0.0 | 153.05 |
346+
| 6 | 30 | 01 July 2024 | | 0.0 | 152.17 | 0.89 | 0.0 | 0.0 | 153.06 | 0.0 | 0.0 | 0.0 | 153.06 |
347+
And Loan Repayment schedule has the following data in Total row:
348+
| Principal due | Interest | Fees | Penalties | Due | Paid | In advance | Late | Outstanding |
349+
| 900.0 | 18.31 | 0.0 | 0.0 | 918.31 | 0.0 | 0.0 | 0.0 | 918.31 |
350+
And Loan Transactions tab has the following data:
351+
| Transaction date | Transaction Type | Amount | Principal | Interest | Fees | Penalties | Loan Balance | Reverted |
352+
| 01 January 2024 | Disbursement | 500.0 | 0.0 | 0.0 | 0.0 | 0.0 | 500.0 | false |
353+
| 02 January 2024 | Capitalized Income | 150.0 | 150.0 | 0.0 | 0.0 | 0.0 | 650.0 | false |
354+
| 03 January 2024 | Capitalized Income | 50.0 | 50.0 | 0.0 | 0.0 | 0.0 | 700.0 | false |
355+
| 04 January 2024 | Disbursement | 100.0 | 0.0 | 0.0 | 0.0 | 0.0 | 800.0 | false |
356+
| 04 January 2024 | Capitalized Income | 100.0 | 100.0 | 0.0 | 0.0 | 0.0 | 900.0 | false |
357+
Then Admin fails to disburse the loan on "04 January 2024" with "200" EUR transaction amount due to exceed approved amount
358+
Then Capitalized income with payment type "AUTOPAY" on "04 January 2024" is forbidden with amount "200" while exceed approved amount
359+
246360
@TestRailId:C3646
247361
Scenario: As a user I want to add capitalized income to a progressive loan after disbursement and then make a full repayment - amortization in case of loan close event
248362
When Admin sets the business date to "1 January 2024"

0 commit comments

Comments
 (0)