FINERACT-2307: added e2e tests for disbursement with Capitalized Income amount calculation while approved over applied setting enabled

This commit is contained in:
mdmytriv
2025-06-05 14:57:00 +02:00
committed by Adam Saghy
parent 6e5c6c4913
commit 57ef4a2771
8 changed files with 232 additions and 1 deletions
@@ -0,0 +1,35 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.fineract.test.data;
public enum OverAppliedCalculationType {
PERCENTAGE("percentage"), //
FIXED_SIZE("flat"); //
public final String value;
OverAppliedCalculationType(String value) {
this.value = value;
}
public String getValue() {
return value;
}
}
@@ -130,6 +130,7 @@ public enum DefaultLoanProduct implements LoanProduct {
LP2_ADV_PYMNT_ZERO_INTEREST_CHARGE_OFF_DELINQUENT_REASON_INTEREST_RECALC_CAPITALIZED_INCOME, //
LP2_ADV_PYMNT_360_30_INTEREST_RECALCULATION_ZERO_INTEREST_CHARGE_OFF_ACCRUAL_ACTIVITY, //
LP2_ADV_PYMNT_INTEREST_DAILY_INTEREST_RECALCULATION_CONTRACT_TERMINATION, //
LP2_ADV_PYMNT_INTEREST_DAILY_RECALC_EMI_360_30_MULTIDISB_APPROVED_OVER_APPLIED_CAPITALIZED_INCOME, //
;
@Override
@@ -42,6 +42,7 @@ import org.apache.fineract.test.data.InterestCalculationPeriodTime;
import org.apache.fineract.test.data.InterestRateFrequencyType;
import org.apache.fineract.test.data.InterestRecalculationCompoundingMethod;
import org.apache.fineract.test.data.InterestType;
import org.apache.fineract.test.data.OverAppliedCalculationType;
import org.apache.fineract.test.data.PreClosureInterestCalculationRule;
import org.apache.fineract.test.data.RecalculationCompoundingFrequencyType;
import org.apache.fineract.test.data.RecalculationRestFrequencyType;
@@ -111,7 +112,7 @@ public class LoanProductsRequestFactory {
public static final Integer LOAN_ACCOUNTING_RULE = AccountingRule.ACCRUAL_PERIODIC.value;
public static final Integer LOAN_ACCOUNTING_RULE_NONE = AccountingRule.NONE.value;
public static final Integer CASH_ACCOUNTING_RULE = AccountingRule.CASH_BASED.value;
public static final String OVER_APPLIED_CALCULATION_TYPE = "percentage";
public static final String OVER_APPLIED_CALCULATION_TYPE = OverAppliedCalculationType.PERCENTAGE.value;
public static final Integer OVER_APPLIED_NUMBER = 50;
public static final Integer DELINQUENCY_BUCKET_ID = DelinquencyBucket.BASIC_DELINQUENCY_BUCKET.value;
public static final Integer PRE_CLOSURE_INTEREST_CALCULATION_RULE_TILL_PRE_CLOSE_DATE = PreClosureInterestCalculationRule.TILL_PRE_CLOSE_DATE.value;
@@ -68,6 +68,11 @@ public final class ErrorMessageHelper {
return "Loan can't be disbursed,disburse amount is exceeding approved principal ";
}
public static String addDisbursementExceedMaxAppliedAmountFailure(String totalDisbAmount, String maxDisbursalAmount) {
return String.format("Loan disbursal amount can't be greater than maximum applied loan amount calculation. "
+ "Total disbursed amount: %s Maximum disbursal amount: %s", totalDisbAmount, maxDisbursalAmount);
}
public static String disbursePastDateFailure(Integer loanId, String actualDisbursementDate) {
return String.format("The date on which a loan is disbursed cannot be before its approval date: %s", actualDisbursementDate);
}
@@ -47,6 +47,7 @@ import org.apache.fineract.test.data.ChargeProductType;
import org.apache.fineract.test.data.DaysInMonthType;
import org.apache.fineract.test.data.DaysInYearType;
import org.apache.fineract.test.data.InterestCalculationPeriodTime;
import org.apache.fineract.test.data.OverAppliedCalculationType;
import org.apache.fineract.test.data.RecalculationRestFrequencyType;
import org.apache.fineract.test.data.TransactionProcessingStrategyCode;
import org.apache.fineract.test.data.loanproduct.DefaultLoanProduct;
@@ -2698,6 +2699,42 @@ public class LoanProductGlobalInitializerStep implements FineractGlobalInitializ
TestContext.INSTANCE.set(
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_INTEREST_DAILY_INTEREST_RECALCULATION_CONTRACT_TERMINATION,
responseLoanProductsRequestAdvCustomContractTerminationProgressiveLoanScheduleIntRecalc);
// LP2 with progressive loan schedule + horizontal + interest EMI + 360/30
// + interest recalculation, preClosureInterestCalculationStrategy= till preclose,
// Frequency for recalculate Outstanding Principal: Daily, Frequency Interval for recalculation: 1
// multidisbursal that doesn't expect tranches with allowed approved/disbursed amount over applied amount
// capitalized income enabled
final String name108 = DefaultLoanProduct.LP2_ADV_PYMNT_INTEREST_DAILY_RECALC_EMI_360_30_MULTIDISB_APPROVED_OVER_APPLIED_CAPITALIZED_INCOME
.getName();
final PostLoanProductsRequest loanProductsRequestLP2ProgressiveAdvPymnt36030InterestRecalcMultidisbursalApprovedOverAppliedCapitalizedIncome = loanProductsRequestFactory
.defaultLoanProductsRequestLP2EmiCapitalizedIncome()//
.name(name108)//
.daysInYearType(DaysInYearType.DAYS360.value)//
.daysInMonthType(DaysInMonthType.DAYS30.value)//
.isInterestRecalculationEnabled(true)//
.preClosureInterestCalculationStrategy(1)//
.rescheduleStrategyMethod(4)//
.interestRecalculationCompoundingMethod(0)//
.recalculationRestFrequencyType(2)//
.recalculationRestFrequencyInterval(1)//
.allowApprovedDisbursedAmountsOverApplied(true).overAppliedCalculationType(OverAppliedCalculationType.PERCENTAGE.value)
.overAppliedNumber(50).paymentAllocation(List.of(//
createPaymentAllocation("DEFAULT", "NEXT_INSTALLMENT"), //
createPaymentAllocation("GOODWILL_CREDIT", "LAST_INSTALLMENT"), //
createPaymentAllocation("MERCHANT_ISSUED_REFUND", "REAMORTIZATION"), //
createPaymentAllocation("PAYOUT_REFUND", "NEXT_INSTALLMENT")))//
.multiDisburseLoan(true)//
.disallowExpectedDisbursements(true)//
.maxTrancheCount(10)//
.outstandingLoanBalance(10000.0);//
final Response<PostLoanProductsResponse> responseLoanProductsRequestLP2ProgressiveAdvPymnt36030InterestRecalcMultidisbursalApprovedOverAppliedCapitalizedIncome = loanProductsApi
.createLoanProduct(
loanProductsRequestLP2ProgressiveAdvPymnt36030InterestRecalcMultidisbursalApprovedOverAppliedCapitalizedIncome)
.execute();
TestContext.INSTANCE.set(
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_INTEREST_DAILY_RECALC_EMI_360_30_MULTIDISB_APPROVED_OVER_APPLIED_CAPITALIZED_INCOME,
responseLoanProductsRequestLP2ProgressiveAdvPymnt36030InterestRecalcMultidisbursalApprovedOverAppliedCapitalizedIncome);
}
public static AdvancedPaymentData createPaymentAllocation(String transactionType, String futureInstallmentAllocationRule,
@@ -1677,6 +1677,24 @@ public class LoanStepDef extends AbstractStepDef {
.isEqualTo(ErrorMessageHelper.addDisbursementExceedApprovedAmountFailure());
}
@Then("Admin fails to disburse the loan on {string} with {string} EUR trn amount with total disb amount {string} and max disb amount {string} due to exceed max applied amount")
public void disbursementForbiddenExceedMaxAppliedAmount(String actualDisbursementDate, String transactionAmount,
String totalDisbursalAmount, String maxDisbursalAmount) throws IOException {
Response<PostLoansResponse> loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
long loanId = loanResponse.body().getLoanId();
PostLoansLoanIdRequest disburseRequest = LoanRequestFactory.defaultLoanDisburseRequest()
.actualDisbursementDate(actualDisbursementDate).transactionAmount(new BigDecimal(transactionAmount));
Response<PostLoansLoanIdResponse> loanDisburseResponse = loansApi.stateTransitions(loanId, disburseRequest, "disburse").execute();
testContext().set(TestContextKey.LOAN_DISBURSE_RESPONSE, loanDisburseResponse);
ErrorResponse errorDetails = ErrorResponse.from(loanDisburseResponse);
assertThat(errorDetails.getHttpStatusCode())
.as(ErrorMessageHelper.addDisbursementExceedMaxAppliedAmountFailure(totalDisbursalAmount, maxDisbursalAmount))
.isEqualTo(403);
assertThat(errorDetails.getSingleError().getDeveloperMessage())
.isEqualTo(ErrorMessageHelper.addDisbursementExceedMaxAppliedAmountFailure(totalDisbursalAmount, maxDisbursalAmount));
}
@And("Admin does charge-off the loan on {string}")
public void chargeOffLoan(String transactionDate) throws IOException {
Response<PostLoansResponse> loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
@@ -148,6 +148,7 @@ public abstract class TestContextKey {
public static final String DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_INTEREST_DAILY_EMI_360_30_INTEREST_RECALC_DAILY_CASH_ACCOUNTING_DISBURSEMENT_CHARGES = "loanProductCreateResponseLP2AdvancedPaymentInterestDailyEmi36030InterestRecalculationDailyCashBasedDisbursementCharge";
public static final String DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_PROGRESSIVE_ADV_PYMNT_CAPITALIZED_INCOME = "loanProductCreateResponseLP2ProgressiveAdvancedPaymentCapitalizedIncome";
public static final String DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_INTEREST_DAILY_EMI_360_30_INTEREST_RECALC_DAILY_CAPITALIZED_INCOME_ADJ_CUSTOM_ALLOC = "loanProductCreateResponseLP2AdvancedPaymentInterestDailyEmi36030InterestRecalculationDailyCapitalizedIncomeAdjCustomAlloc";
public static final String DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_INTEREST_DAILY_RECALC_EMI_360_30_MULTIDISB_APPROVED_OVER_APPLIED_CAPITALIZED_INCOME = "loanProductCreateResponseLP2AdvancedPaymentInterestDailyEmi36030InterestRecalculationDailyMultidisbursalApprovedOVerAppliedAmountCapitalizedIncome";
public static final String DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_INTEREST_DAILY_EMI_360_30_INTEREST_RECALC_DAILY_CAPITALIZED_INCOME = "loanProductCreateResponseLP2ProgressiveAdvPayment36030InterestRecalcCapitalizedIncome";
public static final String DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_INTEREST_DAILY_EMI_360_30_INTEREST_RECALC_DAILY_CAPITALIZED_INCOME_FEE = "loanProductCreateResponseLP2ProgressiveAdvPayment36030InterestRecalcCapitalizedIncomeFee";
public static final String DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_INTEREST_DAILY_EMI_360_30_INTEREST_RECALC_DAILY_MULTIDISBURSAL_CAPITALIZED_INCOME = "loanProductCreateResponseLP2ProgressiveAdvPayment36030InterestRecalcMultidisbursalCapitalizedIncome";
@@ -357,6 +357,139 @@ Feature: Capitalized Income
Then Admin fails to disburse the loan on "04 January 2024" with "200" EUR transaction amount due to exceed approved amount
Then Capitalized income with payment type "AUTOPAY" on "04 January 2024" is forbidden with amount "200" while exceed approved amount
@TestRailId:C3723
Scenario: Verify capitalized income amount with disbursement amount calculation within approved over applied amount for multidisbursal loan - UC10
When Admin sets the business date to "1 January 2024"
And Admin creates a client with random data
And 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 | charge calculation type | charge amount % |
| LP2_ADV_PYMNT_INTEREST_DAILY_RECALC_EMI_360_30_MULTIDISB_APPROVED_OVER_APPLIED_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 |
And Admin successfully approves the loan on "1 January 2024" with "1500" amount and expected disbursement date on "1 January 2024"
And Admin successfully disburse the loan on "1 January 2024" with "1000" EUR transaction amount
Then Loan status will be "ACTIVE"
When Admin sets the business date to "2 January 2024"
And Admin adds capitalized income with "AUTOPAY" payment type to the loan on "2 January 2024" with "200" EUR transaction amount
And Admin successfully disburse the loan on "2 January 2024" with "200" 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 | | 1000.0 | | | 0.0 | | 0.0 | 0.0 | | | |
| | | 02 January 2024 | | 200.0 | | | 0.0 | | 0.0 | 0.0 | | | |
| | | 02 January 2024 | | 200.0 | | | 0.0 | | 0.0 | 0.0 | | | |
| 1 | 31 | 01 February 2024 | | 1169.98 | 230.02 | 8.09 | 0.0 | 0.0 | 238.11 | 0.0 | 0.0 | 0.0 | 238.11 |
| 2 | 29 | 01 March 2024 | | 938.69 | 231.29 | 6.82 | 0.0 | 0.0 | 238.11 | 0.0 | 0.0 | 0.0 | 238.11 |
| 3 | 31 | 01 April 2024 | | 706.06 | 232.63 | 5.48 | 0.0 | 0.0 | 238.11 | 0.0 | 0.0 | 0.0 | 238.11 |
| 4 | 30 | 01 May 2024 | | 472.07 | 233.99 | 4.12 | 0.0 | 0.0 | 238.11 | 0.0 | 0.0 | 0.0 | 238.11 |
| 5 | 31 | 01 June 2024 | | 236.71 | 235.36 | 2.75 | 0.0 | 0.0 | 238.11 | 0.0 | 0.0 | 0.0 | 238.11 |
| 6 | 30 | 01 July 2024 | | 0.0 | 236.71 | 1.38 | 0.0 | 0.0 | 238.09 | 0.0 | 0.0 | 0.0 | 238.09 |
And Loan Repayment schedule has the following data in Total row:
| Principal due | Interest | Fees | Penalties | Due | Paid | In advance | Late | Outstanding |
| 1400.0 | 28.64 | 0.0 | 0.0 | 1428.64 | 0.0 | 0.0 | 0.0 | 1428.64 |
And Loan Transactions tab has the following data:
| Transaction date | Transaction Type | Amount | Principal | Interest | Fees | Penalties | Loan Balance | Reverted |
| 01 January 2024 | Disbursement | 1000.0 | 0.0 | 0.0 | 0.0 | 0.0 | 1000.0 | false |
| 02 January 2024 | Capitalized Income | 200.0 | 200.0 | 0.0 | 0.0 | 0.0 | 1200.0 | false |
| 02 January 2024 | Disbursement | 200.0 | 0.0 | 0.0 | 0.0 | 0.0 | 1400.0 | false |
And Loan Transactions tab has a "CAPITALIZED_INCOME" transaction with date "02 January 2024" which has the following Journal entries:
| Type | Account code | Account name | Debit | Credit |
| ASSET | 112601 | Loans Receivable | 200.0 | |
| LIABILITY | 145024 | Deferred Capitalized Income | | 200.0 |
Then Admin fails to disburse the loan on "02 January 2024" with "200" EUR trn amount with total disb amount "1400" and max disb amount "1500" due to exceed max applied amount
Then Capitalized income with payment type "AUTOPAY" on "02 January 2024" is forbidden with amount "200" while exceed approved amount
When Admin successfully undo disbursal
Then Loan status will be "APPROVED"
When Admin sets the business date to "3 January 2024"
And Admin successfully disburse the loan on "3 January 2024" with "1000" EUR transaction amount
And Admin sets the business date to "4 January 2024"
And Admin adds capitalized income with "AUTOPAY" payment type to the loan on "4 January 2024" with "500" 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 |
| | | 03 January 2024 | | 1000.0 | | | 0.0 | | 0.0 | 0.0 | | | |
| | | 04 January 2024 | | 500.0 | | | 0.0 | | 0.0 | 0.0 | | | |
| 1 | 31 | 03 February 2024 | | 1253.55 | 246.45 | 8.66 | 0.0 | 0.0 | 255.11 | 0.0 | 0.0 | 0.0 | 255.11 |
| 2 | 29 | 03 March 2024 | | 1005.75 | 247.8 | 7.31 | 0.0 | 0.0 | 255.11 | 0.0 | 0.0 | 0.0 | 255.11 |
| 3 | 31 | 03 April 2024 | | 756.51 | 249.24 | 5.87 | 0.0 | 0.0 | 255.11 | 0.0 | 0.0 | 0.0 | 255.11 |
| 4 | 30 | 03 May 2024 | | 505.81 | 250.7 | 4.41 | 0.0 | 0.0 | 255.11 | 0.0 | 0.0 | 0.0 | 255.11 |
| 5 | 31 | 03 June 2024 | | 253.65 | 252.16 | 2.95 | 0.0 | 0.0 | 255.11 | 0.0 | 0.0 | 0.0 | 255.11 |
| 6 | 30 | 03 July 2024 | | 0.0 | 253.65 | 1.48 | 0.0 | 0.0 | 255.13 | 0.0 | 0.0 | 0.0 | 255.13 |
And Loan Repayment schedule has the following data in Total row:
| Principal due | Interest | Fees | Penalties | Due | Paid | In advance | Late | Outstanding |
| 1500.0 | 30.68 | 0.0 | 0.0 | 1530.68 | 0.0 | 0.0 | 0.0 | 1530.68 |
And Loan Transactions tab has the following data:
| Transaction date | Transaction Type | Amount | Principal | Interest | Fees | Penalties | Loan Balance | Reverted |
| 03 January 2024 | Disbursement | 1000.0 | 0.0 | 0.0 | 0.0 | 0.0 | 1000.0 | false |
| 04 January 2024 | Capitalized Income | 500.0 | 500.0 | 0.0 | 0.0 | 0.0 | 1500.0 | false |
Then Admin fails to disburse the loan on "04 January 2024" with "100" EUR trn amount with total disb amount "1100" and max disb amount "1500" due to exceed max applied amount
Then Capitalized income with payment type "AUTOPAY" on "04 January 2024" is forbidden with amount "100" while exceed approved amount
@TestRailId:C3730
Scenario: Verify capitalized income with disbursement amount calculation within approved amount for multidisbursal loan with undo capitalized income - UC11
When Admin sets the business date to "1 January 2024"
And Admin creates a client with random data
And 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 | charge calculation type | charge amount % |
| 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 |
And Admin successfully approves the loan on "1 January 2024" with "1000" amount and expected disbursement date on "1 January 2024"
And Admin successfully disburse the loan on "1 January 2024" with "500" EUR transaction amount
Then Loan status will be "ACTIVE"
When Admin sets the business date to "2 January 2024"
And Admin adds capitalized income with "AUTOPAY" payment type to the loan on "2 January 2024" with "150" EUR transaction amount
When Admin sets the business date to "3 January 2024"
And Admin successfully disburse the loan on "3 January 2024" with "250" 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 | | 500.0 | | | 0.0 | | 0.0 | 0.0 | | | |
| | | 02 January 2024 | | 150.0 | | | 0.0 | | 0.0 | 0.0 | | | |
| | | 03 January 2024 | | 250.0 | | | 0.0 | | 0.0 | 0.0 | | | |
| 1 | 31 | 01 February 2024 | | 752.07 | 147.93 | 5.13 | 0.0 | 0.0 | 153.06 | 0.0 | 0.0 | 0.0 | 153.06 |
| 2 | 29 | 01 March 2024 | | 603.4 | 148.67 | 4.39 | 0.0 | 0.0 | 153.06 | 0.0 | 0.0 | 0.0 | 153.06 |
| 3 | 31 | 01 April 2024 | | 453.86 | 149.54 | 3.52 | 0.0 | 0.0 | 153.06 | 0.0 | 0.0 | 0.0 | 153.06 |
| 4 | 30 | 01 May 2024 | | 303.45 | 150.41 | 2.65 | 0.0 | 0.0 | 153.06 | 0.0 | 0.0 | 0.0 | 153.06 |
| 5 | 31 | 01 June 2024 | | 152.16 | 151.29 | 1.77 | 0.0 | 0.0 | 153.06 | 0.0 | 0.0 | 0.0 | 153.06 |
| 6 | 30 | 01 July 2024 | | 0.0 | 152.16 | 0.89 | 0.0 | 0.0 | 153.05 | 0.0 | 0.0 | 0.0 | 153.05 |
And Loan Repayment schedule has the following data in Total row:
| Principal due | Interest | Fees | Penalties | Due | Paid | In advance | Late | Outstanding |
| 900.0 | 18.35 | 0.0 | 0.0 | 918.35 | 0.0 | 0.0 | 0.0 | 918.35 |
And Loan Transactions tab has the following data:
| Transaction date | Transaction Type | Amount | Principal | Interest | Fees | Penalties | Loan Balance | Reverted |
| 01 January 2024 | Disbursement | 500.0 | 0.0 | 0.0 | 0.0 | 0.0 | 500.0 | false |
| 02 January 2024 | Capitalized Income | 150.0 | 150.0 | 0.0 | 0.0 | 0.0 | 650.0 | false |
| 03 January 2024 | Disbursement | 250.0 | 0.0 | 0.0 | 0.0 | 0.0 | 900.0 | false |
And Loan Transactions tab has a "CAPITALIZED_INCOME" transaction with date "02 January 2024" which has the following Journal entries:
| Type | Account code | Account name | Debit | Credit |
| ASSET | 112601 | Loans Receivable | 150.0 | |
| LIABILITY | 145024 | Deferred Capitalized Income | | 150.0 |
Then Admin fails to disburse the loan on "02 January 2024" with "200" EUR transaction amount due to exceed approved amount
Then Capitalized income with payment type "AUTOPAY" on "02 January 2024" is forbidden with amount "200" while exceed approved amount
And Admin sets the business date to "4 January 2024"
# -- undo last disbursal -- #
When Admin successfully undo last disbursal
# -- undo capitalized income -- #
When Customer undo "1"th "Capitalized Income" transaction made on "02 January 2024"
And Admin successfully disburse the loan on "4 January 2024" with "200" EUR transaction amount
And Admin adds capitalized income with "AUTOPAY" payment type to the loan on "4 January 2024" with "200" 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 | | 500.0 | | | 0.0 | | 0.0 | 0.0 | | | |
| | | 04 January 2024 | | 200.0 | | | 0.0 | | 0.0 | 0.0 | | | |
| | | 04 January 2024 | | 200.0 | | | 0.0 | | 0.0 | 0.0 | | | |
| 1 | 31 | 01 February 2024 | | 751.98 | 148.02 | 5.02 | 0.0 | 0.0 | 153.04 | 0.0 | 0.0 | 0.0 | 153.04 |
| 2 | 29 | 01 March 2024 | | 603.33 | 148.65 | 4.39 | 0.0 | 0.0 | 153.04 | 0.0 | 0.0 | 0.0 | 153.04 |
| 3 | 31 | 01 April 2024 | | 453.81 | 149.52 | 3.52 | 0.0 | 0.0 | 153.04 | 0.0 | 0.0 | 0.0 | 153.04 |
| 4 | 30 | 01 May 2024 | | 303.42 | 150.39 | 2.65 | 0.0 | 0.0 | 153.04 | 0.0 | 0.0 | 0.0 | 153.04 |
| 5 | 31 | 01 June 2024 | | 152.15 | 151.27 | 1.77 | 0.0 | 0.0 | 153.04 | 0.0 | 0.0 | 0.0 | 153.04 |
| 6 | 30 | 01 July 2024 | | 0.0 | 152.15 | 0.89 | 0.0 | 0.0 | 153.04 | 0.0 | 0.0 | 0.0 | 153.04 |
And Loan Repayment schedule has the following data in Total row:
| Principal due | Interest | Fees | Penalties | Due | Paid | In advance | Late | Outstanding |
| 900.0 | 18.24 | 0.0 | 0.0 | 918.24 | 0.0 | 0.0 | 0.0 | 918.24 |
And Loan Transactions tab has the following data:
| Transaction date | Transaction Type | Amount | Principal | Interest | Fees | Penalties | Loan Balance | Reverted | Reverted |
| 01 January 2024 | Disbursement | 500.0 | 0.0 | 0.0 | 0.0 | 0.0 | 500.0 | false | false |
| 02 January 2024 | Capitalized Income | 150.0 | 150.0 | 0.0 | 0.0 | 0.0 | 650.0 | true | true |
| 04 January 2024 | Disbursement | 200.0 | 0.0 | 0.0 | 0.0 | 0.0 | 700.0 | false | false |
| 04 January 2024 | Capitalized Income | 200.0 | 200.0 | 0.0 | 0.0 | 0.0 | 900.0 | false | false |
Then Admin fails to disburse the loan on "04 January 2024" with "300" EUR transaction amount due to exceed approved amount
Then Capitalized income with payment type "AUTOPAY" on "04 January 2024" is forbidden with amount "300" while exceed approved amount
@TestRailId:C3646
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
When Admin sets the business date to "1 January 2024"