diff --git a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/data/ChargeProductType.java b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/data/ChargeProductType.java index 44b502e03..47b8e52c9 100644 --- a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/data/ChargeProductType.java +++ b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/data/ChargeProductType.java @@ -31,7 +31,9 @@ public enum ChargeProductType { LOAN_INSTALLMENT_PERCENTAGE_FEE(9L), // LOAN_PERCENTAGE_LATE_FEE_AMOUNT_PLUS_INTEREST(10L), // CLIENT_TEST_CHARGE_FEE(11L), // - LOAN_DISBURSEMENT_CHARGE(12L); // + LOAN_DISBURSEMENT_CHARGE(12L), // + CHARGE_LOAN_TRANCHE_DISBURSEMENT_CHARGE_AMOUNT(13L), // + CHARGE_LOAN_TRANCHE_DISBURSEMENT_CHARGE_PERCENT(14L); // public final Long value; diff --git a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/initializer/global/ChargeGlobalInitializerStep.java b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/initializer/global/ChargeGlobalInitializerStep.java index 8cc0a305e..3a9a399af 100644 --- a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/initializer/global/ChargeGlobalInitializerStep.java +++ b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/initializer/global/ChargeGlobalInitializerStep.java @@ -55,6 +55,8 @@ public class ChargeGlobalInitializerStep implements FineractGlobalInitializerSte public static final String CHARGE_LOAN_INSTALLMENT_PERCENT_FEE = "Installment percentage fee"; public static final String CHARGE_CLIENT_FIXED_FEE = "Fixed fee for Client"; public static final String CHARGE_DISBURSEMENT_CHARGE = "Disbursement Charge"; + public static final String CHARGE_LOAN_TRANCHE_DISBURSEMENT_CHARGE_AMOUNT = "Tranche Disbursement Charge Amount"; + public static final String CHARGE_LOAN_TRANCHE_DISBURSEMENT_CHARGE_PERCENT = "Tranche Disbursement Charge Percent"; public static final Double CHARGE_AMOUNT_FLAT = 25D; public static final Double CHARGE_AMOUNT_PERCENTAGE = 5D; public static final Double CHARGE_AMOUNT_DISBURSEMENT_PERCENTAGE = 1.5D; @@ -155,6 +157,24 @@ public class ChargeGlobalInitializerStep implements FineractGlobalInitializerSte CHARGE_TIME_TYPE_DISBURSEMENT, CHARGE_CALCULATION_TYPE_FLAT, CHARGE_AMOUNT_FLAT, true, false); Response responseDisbursementCharge = chargesApi.createCharge(requestDisbursementCharge).execute(); TestContext.INSTANCE.set(TestContextKey.CHARGE_FOR_LOAN_DISBURSEMENT_CHARGE_CREATE_RESPONSE, responseDisbursementCharge); + + // Loan - Tranche Disbursement Charge (Flat) + ChargeRequest requestTrancheDisbursementCharge = defaultChargesRequest(CHARGE_APPLIES_TO_LOAN, + CHARGE_LOAN_TRANCHE_DISBURSEMENT_CHARGE_AMOUNT, CHARGE_TIME_TYPE_TRANCHE_DISBURSEMENT, CHARGE_CALCULATION_TYPE_FLAT, 10.0, + true, false); + Response responseTrancheDisbursementCharge = chargesApi.createCharge(requestTrancheDisbursementCharge) + .execute(); + TestContext.INSTANCE.set(TestContextKey.CHARGE_FOR_LOAN_TRANCHE_DISBURSEMENT_CHARGE_FLAT_CREATE_RESPONSE, + responseTrancheDisbursementCharge); + + // Loan - Tranche Disbursement Charge (%) + ChargeRequest requestTrancheDisbursementChargePercent = defaultChargesRequest(CHARGE_APPLIES_TO_LOAN, + CHARGE_LOAN_TRANCHE_DISBURSEMENT_CHARGE_PERCENT, CHARGE_TIME_TYPE_TRANCHE_DISBURSEMENT, + CHARGE_CALCULATION_TYPE_PERCENTAGE_DISBURSEMENT_AMOUNT, 2.0, true, false); + Response responseTrancheDisbursementChargePercent = chargesApi + .createCharge(requestTrancheDisbursementChargePercent).execute(); + TestContext.INSTANCE.set(TestContextKey.CHARGE_FOR_LOAN_TRANCHE_DISBURSEMENT_CHARGE_PERCENT_CREATE_RESPONSE, + responseTrancheDisbursementChargePercent); } public static ChargeRequest defaultChargesRequest(Enum appliesTo, String name, Integer chargeTimeType, diff --git a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/stepdef/loan/ChargeStepDef.java b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/stepdef/loan/ChargeStepDef.java index bf66a8e96..c2e588a4f 100644 --- a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/stepdef/loan/ChargeStepDef.java +++ b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/stepdef/loan/ChargeStepDef.java @@ -48,4 +48,18 @@ public class ChargeStepDef extends AbstractStepDef { .execute(); ErrorHelper.checkSuccessfulApiCall(responseDisbursementCharge); } + + @When("Admin updates charge {string} with {string} calculation type and {double} EUR amount") + public void updateChargeWithFlatAmount(String chargeType, String chargeCalculationType, double flatAmount) throws IOException { + ChargeRequest disbursementChargeUpdateRequest = new ChargeRequest(); + ChargeCalculationType chargeProductTypeValue = ChargeCalculationType.valueOf(chargeCalculationType); + disbursementChargeUpdateRequest.chargeCalculationType(chargeProductTypeValue.value).amount(flatAmount).locale("en"); + + ChargeProductType chargeProductType = ChargeProductType.valueOf(chargeType); + Long chargeId = chargeProductType.getValue(); + + Response responseDisbursementCharge = chargesApi.updateCharge(chargeId, disbursementChargeUpdateRequest) + .execute(); + ErrorHelper.checkSuccessfulApiCall(responseDisbursementCharge); + } } diff --git a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/support/TestContextKey.java b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/support/TestContextKey.java index 3665e7a53..e300220eb 100644 --- a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/support/TestContextKey.java +++ b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/support/TestContextKey.java @@ -168,6 +168,7 @@ public abstract class TestContextKey { public static final String CHARGE_FOR_LOAN_NSF_FEE_CREATE_RESPONSE = "ChargeForLoanNsfFeeCreateResponse"; public static final String CHARGE_FOR_LOAN_DISBURSEMENET_FEE_CREATE_RESPONSE = "ChargeForLoanDisbursementCreateResponse"; public static final String CHARGE_FOR_LOAN_TRANCHE_DISBURSEMENT_PERCENT_CREATE_RESPONSE = "ChargeForLoanTrancheDisbursementPercentCreateResponse"; + public static final String CHARGE_FOR_LOAN_TRANCHE_DISBURSEMENT_CHARGE_PERCENT_CREATE_RESPONSE = "ChargeForLoanTrancheDisbursementChargePercentCreateResponse"; public static final String CHARGE_FOR_LOAN_INSTALLMENT_FEE_CREATE_RESPONSE = "ChargeForLoanInstallmentCreateResponse"; public static final String CHARGE_FOR_CLIENT_FIXED_FEE_CREATE_RESPONSE = "ChargeForClientFixedFeeCreateResponse"; public static final String CHARGE_FOR_LOAN_DISBURSEMENT_CHARGE_CREATE_RESPONSE = "ChargeForLoanDisbursementChargeCreateResponse"; @@ -200,6 +201,7 @@ public abstract class TestContextKey { public static final String TRANSACTION_IDEMPOTENCY_KEY = "transactionIdempotencyKey"; public static final String LOAN_CHARGE_OFF_RESPONSE = "loanChargeOffResponse"; public static final String LOAN_CHARGE_OFF_UNDO_RESPONSE = "loanChargeOffUndoResponse"; + public static final String CHARGE_FOR_LOAN_TRANCHE_DISBURSEMENT_CHARGE_FLAT_CREATE_RESPONSE = "ChargeForLoanTrancheDisbursementChargeCreateResponse"; public static final String CREATED_SIMPLE_USER_RESPONSE = "createdSimpleUserResponse"; public static final String ASSET_EXTERNALIZATION_RESPONSE = "assetExternalizationResponse"; public static final String ASSET_EXTERNALIZATION_TRANSFER_EXTERNAL_ID_USER_GENERATED = "assetExternalizationTransferExternalIdUserGenerated"; diff --git a/fineract-e2e-tests-runner/src/test/resources/features/LoanCharge.feature b/fineract-e2e-tests-runner/src/test/resources/features/LoanCharge.feature index 8f95a4c16..38b3eadbf 100644 --- a/fineract-e2e-tests-runner/src/test/resources/features/LoanCharge.feature +++ b/fineract-e2e-tests-runner/src/test/resources/features/LoanCharge.feature @@ -4793,4 +4793,778 @@ Feature: LoanCharge | 25 February 2025 | Disbursement | 1000.0 | 0.0 | 0.0 | 0.0 | 0.0 | 1000.0 | | 28 March 2025 | Accrual | 25.0 | 0.0 | 0.0 | 25.0 | 0.0 | 0.0 | Then LoanAccrualTransactionCreatedBusinessEvent is raised on "28 March 2025" - Given Global configuration "enable-immediate-charge-accrual-post-maturity" is disabled \ No newline at end of file + Given Global configuration "enable-immediate-charge-accrual-post-maturity" is disabled + + @TestRailId:C3650 + Scenario: Tranche disbursement charges - disbursement flat charge + When Admin sets the business date to "01 January 2024" + When Admin creates a client with random data + When Admin updates charge "CHARGE_LOAN_TRANCHE_DISBURSEMENT_CHARGE_AMOUNT" with "FLAT" calculation type and 10.0 EUR amount + When Admin creates a fully customized loan with charges and disbursement details and 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 | 1st_tranche_disb_expected_date | 1st_tranche_disb_principal | 2nd_tranche_disb_expected_date | 2nd_tranche_disb_principal | + | LP2_ADV_PYMNT_INTEREST_DAILY_EMI_360_30_INTEREST_RECALC_DAILY_MULTIDISBURSE_EXPECT_TRANCHE | 01 January 2024 | 130 | 7 | DECLINING_BALANCE | DAILY | EQUAL_INSTALLMENTS | 6 | MONTHS | 1 | MONTHS | 6 | 0 | 0 | 0 | ADVANCED_PAYMENT_ALLOCATION | CHARGE_LOAN_TRANCHE_DISBURSEMENT_CHARGE_AMOUNT | 10.0 | 01 January 2024 | 100.0 | 03 March 2024 | 30.0 | + Then Loan Charges tab has the following data: + | Name | isPenalty | Payment due at | Due as of | Calculation type | Due | Paid | Waived | Outstanding | + | Tranche Disbursement Charge Amount | false | Tranche Disbursement | 01 January 2024 | Flat | 10.0 | 0.0 | 0.0 | 10.0 | + And Admin successfully approves the loan on "01 January 2024" with "130" 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 | | | 10.0 | | 10.0 | 10.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 | 10.0 | 0.0 | 112.05 | 10.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 | + | 01 January 2024 | Repayment (at time of disbursement) | 10.0 | 0.0 | 0.0 | 10.0 | 0.0 | 100.0 | false | false | + Then Loan Charges tab has the following data: + | Name | isPenalty | Payment due at | Due as of | Calculation type | Due | Paid | Waived | Outstanding | + | Tranche Disbursement Charge Amount | false | Tranche Disbursement | 01 January 2024 | Flat | 10.0 | 10.0 | 0.0 | 0.0 | + Then Loan Transactions tab has a "REPAYMENT_AT_DISBURSEMENT" transaction with date "01 January 2024" which has the following Journal entries: + | Type | Account code | Account name | Debit | Credit | + | INCOME | 404007 | Fee Income | | 10.0 | + | LIABILITY | 145023 | Suspense/Clearing account | 10.0 | | + # Add repayment on 01 February 2024 + 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 | | | 10.0 | | 10.0 | 10.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 | 10.0 | 0.0 | 112.05 | 27.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 January 2024 | Repayment (at time of disbursement) | 10.0 | 0.0 | 0.0 | 10.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 | + # Add repayment on 01 March 2024 + When Admin sets the business date to "01 March 2024" + And Customer makes "AUTOPAY" repayment on "01 March 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 | | | 10.0 | | 10.0 | 10.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 | 01 March 2024 | 67.05 | 16.52 | 0.49 | 0.0 | 0.0 | 17.01 | 17.01 | 0.0 | 0.0 | 0.0 | + | 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 | 10.0 | 0.0 | 112.05 | 44.02 | 0.0 | 0.0 | 68.03 | + 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 January 2024 | Repayment (at time of disbursement) | 10.0 | 0.0 | 0.0 | 10.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 | + | 01 March 2024 | Repayment | 17.01 | 16.52 | 0.49 | 0.0 | 0.0 | 67.05 | false | false | + # Add additional disbursement on 03 March 2024 + When Admin sets the business date to "03 March 2024" + And Admin successfully add disbursement detail to the loan on "03 March 2024" with 30 EUR transaction amount + And Admin successfully disburse the loan on "03 March 2024" with "30" 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 | | | 10.0 | | 10.0 | 10.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 | 01 March 2024 | 67.05 | 16.52 | 0.49 | 0.0 | 0.0 | 17.01 | 17.01 | 0.0 | 0.0 | 0.0 | + | | | 03 March 2024 | | 30.0 | | | 10.0 | | 10.0 | 10.0 | | | | + | 3 | 31 | 01 April 2024 | | 72.99 | 24.06 | 0.55 | 0.0 | 0.0 | 24.61 | 0.0 | 0.0 | 0.0 | 24.61 | + | 4 | 30 | 01 May 2024 | | 48.81 | 24.18 | 0.43 | 0.0 | 0.0 | 24.61 | 0.0 | 0.0 | 0.0 | 24.61 | + | 5 | 31 | 01 June 2024 | | 24.48 | 24.33 | 0.28 | 0.0 | 0.0 | 24.61 | 0.0 | 0.0 | 0.0 | 24.61 | + | 6 | 30 | 01 July 2024 | | 0.0 | 24.48 | 0.14 | 0.0 | 0.0 | 24.62 | 0.0 | 0.0 | 0.0 | 24.62 | + Then Loan Repayment schedule has the following data in Total row: + | Principal due | Interest | Fees | Penalties | Due | Paid | In advance | Late | Outstanding | + | 130.0 | 2.47 | 20.0 | 0.0 | 152.47 | 54.02 | 0.0 | 0.0 | 98.45 | + 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 January 2024 | Repayment (at time of disbursement) | 10.0 | 0.0 | 0.0 | 10.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 | + | 01 March 2024 | Repayment | 17.01 | 16.52 | 0.49 | 0.0 | 0.0 | 67.05 | false | false | + | 03 March 2024 | Disbursement | 30.0 | 0.0 | 0.0 | 0.0 | 0.0 | 97.05 | false | false | + | 03 March 2024 | Repayment (at time of disbursement) | 10.0 | 0.0 | 0.0 | 10.0 | 0.0 | 97.05 | false | false | + Then Loan Charges tab has the following data: + | Name | isPenalty | Payment due at | Due as of | Calculation type | Due | Paid | Waived | Outstanding | + | Tranche Disbursement Charge Amount | false | Tranche Disbursement | 03 March 2024 | Flat | 10.0 | 10.0 | 0.0 | 0.0 | + | Tranche Disbursement Charge Amount | false | Tranche Disbursement | 01 January 2024 | Flat | 10.0 | 10.0 | 0.0 | 0.0 | + Then Loan Transactions tab has a "REPAYMENT_AT_DISBURSEMENT" transaction with date "03 March 2024" which has the following Journal entries: + | Type | Account code | Account name | Debit | Credit | + | INCOME | 404007 | Fee Income | | 10.0 | + | LIABILITY | 145023 | Suspense/Clearing account | 10.0 | | + + @TestRailId:C3652 + Scenario: Tranche disbursement charges - disbursement percentage charge + When Admin sets the business date to "01 January 2024" + When Admin creates a client with random data + When Admin updates charge "CHARGE_LOAN_TRANCHE_DISBURSEMENT_CHARGE_PERCENT" with "PERCENTAGE_DISBURSEMENT_AMOUNT" calculation type and 1.0 % of transaction amount + When Admin creates a fully customized loan with charges and disbursement details and 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 | 1st_tranche_disb_expected_date | 1st_tranche_disb_principal | 2nd_tranche_disb_expected_date | 2nd_tranche_disb_principal | + | LP2_ADV_PYMNT_INTEREST_DAILY_EMI_360_30_INTEREST_RECALC_DAILY_MULTIDISBURSE_EXPECT_TRANCHE | 01 January 2024 | 130 | 7 | DECLINING_BALANCE | DAILY | EQUAL_INSTALLMENTS | 6 | MONTHS | 1 | MONTHS | 6 | 0 | 0 | 0 | ADVANCED_PAYMENT_ALLOCATION | CHARGE_LOAN_TRANCHE_DISBURSEMENT_CHARGE_PERCENT | 1.0 | 01 January 2024 | 100.0 | 03 March 2024 | 30.0 | + Then Loan Charges tab has the following data: + | Name | isPenalty | Payment due at | Due as of | Calculation type | Due | Paid | Waived | Outstanding | + | Tranche Disbursement Charge Percent | false | Tranche Disbursement | 01 January 2024 | % Disbursement Amount | 1.0 | 0.0 | 0.0 | 1.0 | + And Admin successfully approves the loan on "01 January 2024" with "130" 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 | | | 1.0 | | 1.0 | 1.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 | 1.0 | 0.0 | 103.05 | 1.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 | + | 01 January 2024 | Repayment (at time of disbursement) | 1.0 | 0.0 | 0.0 | 1.0 | 0.0 | 100.0 | false | false | + Then Loan Charges tab has the following data: + | Name | isPenalty | Payment due at | Due as of | Calculation type | Due | Paid | Waived | Outstanding | + | Tranche Disbursement Charge Percent | false | Tranche Disbursement | 01 January 2024 | % Disbursement Amount | 1.0 | 1.0 | 0.0 | 0.0 | + Then Loan Transactions tab has a "REPAYMENT_AT_DISBURSEMENT" transaction with date "01 January 2024" which has the following Journal entries: + | Type | Account code | Account name | Debit | Credit | + | INCOME | 404007 | Fee Income | | 1.0 | + | LIABILITY | 145023 | Suspense/Clearing account | 1.0 | | + # First repayment + 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 | | | 1.0 | | 1.0 | 1.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 | 1.0 | 0.0 | 103.05 | 18.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 January 2024 | Repayment (at time of disbursement) | 1.0 | 0.0 | 0.0 | 1.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 | + # Second repayment + When Admin sets the business date to "01 March 2024" + And Customer makes "AUTOPAY" repayment on "01 March 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 | | | 1.0 | | 1.0 | 1.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 | 01 March 2024 | 67.05 | 16.52 | 0.49 | 0.0 | 0.0 | 17.01 | 17.01 | 0.0 | 0.0 | 0.0 | + | 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 | 1.0 | 0.0 | 103.05 | 35.02 | 0.0 | 0.0 | 68.03 | + 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 January 2024 | Repayment (at time of disbursement) | 1.0 | 0.0 | 0.0 | 1.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 | + | 01 March 2024 | Repayment | 17.01 | 16.52 | 0.49 | 0.0 | 0.0 | 67.05 | false | false | + # Second disbursement + When Admin sets the business date to "03 March 2024" + And Admin successfully add disbursement detail to the loan on "03 March 2024" with 30 EUR transaction amount + When Admin successfully disburse the loan on "03 March 2024" with "30" 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 | | | 1.0 | | 1.0 | 1.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 | 01 March 2024 | 67.05 | 16.52 | 0.49 | 0.0 | 0.0 | 17.01 | 17.01 | 0.0 | 0.0 | 0.0 | + | | | 03 March 2024 | | 30.0 | | | 0.3 | | 0.3 | 0.3 | | | | + | 3 | 31 | 01 April 2024 | | 72.99 | 24.06 | 0.55 | 0.0 | 0.0 | 24.61 | 0.0 | 0.0 | 0.0 | 24.61 | + | 4 | 30 | 01 May 2024 | | 48.81 | 24.18 | 0.43 | 0.0 | 0.0 | 24.61 | 0.0 | 0.0 | 0.0 | 24.61 | + | 5 | 31 | 01 June 2024 | | 24.48 | 24.33 | 0.28 | 0.0 | 0.0 | 24.61 | 0.0 | 0.0 | 0.0 | 24.61 | + | 6 | 30 | 01 July 2024 | | 0.0 | 24.48 | 0.14 | 0.0 | 0.0 | 24.62 | 0.0 | 0.0 | 0.0 | 24.62 | + Then Loan Repayment schedule has the following data in Total row: + | Principal due | Interest | Fees | Penalties | Due | Paid | In advance | Late | Outstanding | + | 130.0 | 2.47 | 1.3 | 0.0 | 133.77 | 35.32 | 0.0 | 0.0 | 98.45 | + 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 January 2024 | Repayment (at time of disbursement) | 1.0 | 0.0 | 0.0 | 1.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 | + | 01 March 2024 | Repayment | 17.01 | 16.52 | 0.49 | 0.0 | 0.0 | 67.05 | false | false | + | 03 March 2024 | Disbursement | 30.0 | 0.0 | 0.0 | 0.0 | 0.0 | 97.05 | false | false | + | 03 March 2024 | Repayment (at time of disbursement) | 0.3 | 0.0 | 0.0 | 0.3 | 0.0 | 97.05 | false | false | + Then Loan Charges tab has the following data: + | Name | isPenalty | Payment due at | Due as of | Calculation type | Due | Paid | Waived | Outstanding | + | Tranche Disbursement Charge Percent | false | Tranche Disbursement | 03 March 2024 | % Disbursement Amount | 0.3 | 0.3 | 0.0 | 0.0 | + | Tranche Disbursement Charge Percent | false | Tranche Disbursement | 01 January 2024 | % Disbursement Amount | 1.0 | 1.0 | 0.0 | 0.0 | + Then Loan Transactions tab has a "REPAYMENT_AT_DISBURSEMENT" transaction with date "03 March 2024" which has the following Journal entries: + | Type | Account code | Account name | Debit | Credit | + | INCOME | 404007 | Fee Income | | 0.3 | + | LIABILITY | 145023 | Suspense/Clearing account | 0.3 | | + + @TestRailId:C3653 + Scenario: Tranche disbursement charges - flat and cash based accounting + When Admin sets the business date to "01 January 2024" + When Admin creates a client with random data + When Admin updates charge "CHARGE_LOAN_TRANCHE_DISBURSEMENT_CHARGE_AMOUNT" with "FLAT" calculation type and 0.02 EUR amount + When Admin creates a fully customized loan with charges and disbursement details and 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 | 1st_tranche_disb_expected_date | 1st_tranche_disb_principal | 2nd_tranche_disb_expected_date | 2nd_tranche_disb_principal | + | LP2_ADV_PYMNT_INTEREST_DAILY_EMI_360_30_INTEREST_RECALC_DAILY_MULTIDISBURSE_EXPECT_TRANCHE | 01 January 2024 | 200 | 7 | DECLINING_BALANCE | DAILY | EQUAL_INSTALLMENTS | 6 | MONTHS | 1 | MONTHS | 6 | 0 | 0 | 0 | ADVANCED_PAYMENT_ALLOCATION | CHARGE_LOAN_TRANCHE_DISBURSEMENT_CHARGE_AMOUNT | 0.02 | 01 January 2024 | 100.0 | 03 March 2024 | 100.0 | + Then Loan Charges tab has the following data: + | Name | isPenalty | Payment due at | Due as of | Calculation type | Due | Paid | Waived | Outstanding | + | Tranche Disbursement Charge Amount | false | Tranche Disbursement | 01 January 2024 | Flat | 0.02 | 0.0 | 0.0 | 0.02 | + And Admin successfully approves the loan on "01 January 2024" with "130" 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.02 | | 0.02 | 0.02 | | | | + | 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.02 | 0.0 | 102.07 | 0.02 | 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 | + | 01 January 2024 | Repayment (at time of disbursement) | 0.02 | 0.0 | 0.0 | 0.02 | 0.0 | 100.0 | false | false | + Then Loan Charges tab has the following data: + | Name | isPenalty | Payment due at | Due as of | Calculation type | Due | Paid | Waived | Outstanding | + | Tranche Disbursement Charge Amount | false | Tranche Disbursement | 01 January 2024 | Flat | 0.02 | 0.02 | 0.0 | 0.0 | + Then Loan Transactions tab has a "REPAYMENT_AT_DISBURSEMENT" transaction with date "01 January 2024" which has the following Journal entries: + | Type | Account code | Account name | Debit | Credit | + | INCOME | 404007 | Fee Income | | 0.02 | + | LIABILITY | 145023 | Suspense/Clearing account | 0.02 | | + # First repayment + 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.02 | | 0.02 | 0.02 | | | | + | 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.02 | 0.0 | 102.07 | 17.03 | 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 January 2024 | Repayment (at time of disbursement) | 0.02 | 0.0 | 0.0 | 0.02 | 0.0 | 100.0 | false | false | + | 01 February 2024 | Repayment | 17.01 | 16.43 | 0.58 | 0.0 | 0.0 | 83.57 | false | false | + # Second repayment + When Admin sets the business date to "01 March 2024" + And Customer makes "AUTOPAY" repayment on "01 March 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.02 | | 0.02 | 0.02 | | | | + | 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 | 01 March 2024 | 67.05 | 16.52 | 0.49 | 0.0 | 0.0 | 17.01 | 17.01 | 0.0 | 0.0 | 0.0 | + | 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.02 | 0.0 | 102.07 | 34.04 | 0.0 | 0.0 | 68.03 | + 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 January 2024 | Repayment (at time of disbursement) | 0.02 | 0.0 | 0.0 | 0.02 | 0.0 | 100.0 | false | false | + | 01 February 2024 | Repayment | 17.01 | 16.43 | 0.58 | 0.0 | 0.0 | 83.57 | false | false | + | 01 March 2024 | Repayment | 17.01 | 16.52 | 0.49 | 0.0 | 0.0 | 67.05 | false | false | + # Second disbursement + When Admin sets the business date to "03 March 2024" + And Admin successfully add disbursement detail to the loan on "03 March 2024" with 30 EUR transaction amount + When Admin successfully disburse the loan on "03 March 2024" with "30" 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.02 | | 0.02 | 0.02 | | | | + | 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 | 01 March 2024 | 67.05 | 16.52 | 0.49 | 0.0 | 0.0 | 17.01 | 17.01 | 0.0 | 0.0 | 0.0 | + | | | 03 March 2024 | | 30.0 | | | 0.02 | | 0.02 | 0.02 | | | | + | 3 | 31 | 01 April 2024 | | 72.99 | 24.06 | 0.55 | 0.0 | 0.0 | 24.61 | 0.0 | 0.0 | 0.0 | 24.61 | + | 4 | 30 | 01 May 2024 | | 48.81 | 24.18 | 0.43 | 0.0 | 0.0 | 24.61 | 0.0 | 0.0 | 0.0 | 24.61 | + | 5 | 31 | 01 June 2024 | | 24.48 | 24.33 | 0.28 | 0.0 | 0.0 | 24.61 | 0.0 | 0.0 | 0.0 | 24.61 | + | 6 | 30 | 01 July 2024 | | 0.0 | 24.48 | 0.14 | 0.0 | 0.0 | 24.62 | 0.0 | 0.0 | 0.0 | 24.62 | + Then Loan Repayment schedule has the following data in Total row: + | Principal due | Interest | Fees | Penalties | Due | Paid | In advance | Late | Outstanding | + | 130.0 | 2.47 | 0.04 | 0.0 | 132.51 | 34.06 | 0.0 | 0.0 | 98.45 | + 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 January 2024 | Repayment (at time of disbursement) | 0.02 | 0.0 | 0.0 | 0.02 | 0.0 | 100.0 | false | false | + | 01 February 2024 | Repayment | 17.01 | 16.43 | 0.58 | 0.0 | 0.0 | 83.57 | false | false | + | 01 March 2024 | Repayment | 17.01 | 16.52 | 0.49 | 0.0 | 0.0 | 67.05 | false | false | + | 03 March 2024 | Disbursement | 30.0 | 0.0 | 0.0 | 0.0 | 0.0 | 97.05 | false | false | + | 03 March 2024 | Repayment (at time of disbursement) | 0.02 | 0.0 | 0.0 | 0.02 | 0.0 | 97.05 | false | false | + Then Loan Charges tab has the following data: + | Name | isPenalty | Payment due at | Due as of | Calculation type | Due | Paid | Waived | Outstanding | + | Tranche Disbursement Charge Amount | false | Tranche Disbursement | 03 March 2024 | Flat | 0.02 | 0.02 | 0.0 | 0.0 | + | Tranche Disbursement Charge Amount | false | Tranche Disbursement | 01 January 2024 | Flat | 0.02 | 0.02 | 0.0 | 0.0 | + Then Loan Transactions tab has a "REPAYMENT_AT_DISBURSEMENT" transaction with date "03 March 2024" which has the following Journal entries: + | Type | Account code | Account name | Debit | Credit | + | INCOME | 404007 | Fee Income | | 0.02 | + | LIABILITY | 145023 | Suspense/Clearing account | 0.02 | | + + @TestRailId:C3654 + Scenario: Tranche disbursement charges - percentage disbursement and accrual based accounting + When Admin sets the business date to "01 January 2024" + When Admin creates a client with random data + When Admin updates charge "CHARGE_LOAN_TRANCHE_DISBURSEMENT_CHARGE_PERCENT" with "PERCENTAGE_DISBURSEMENT_AMOUNT" calculation type and 1.0 % of transaction amount + When Admin creates a fully customized loan with charges and disbursement details and 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 | 1st_tranche_disb_expected_date | 1st_tranche_disb_principal | 2nd_tranche_disb_expected_date | 2nd_tranche_disb_principal | + | LP2_ADV_PYMNT_INTEREST_DAILY_EMI_360_30_INTEREST_RECALC_DAILY_MULTIDISBURSE_EXPECT_TRANCHE | 01 January 2024 | 200 | 7 | DECLINING_BALANCE | DAILY | EQUAL_INSTALLMENTS | 6 | MONTHS | 1 | MONTHS | 6 | 0 | 0 | 0 | ADVANCED_PAYMENT_ALLOCATION | CHARGE_LOAN_TRANCHE_DISBURSEMENT_CHARGE_PERCENT | 1.0 | 01 January 2024 | 100.0 | 03 March 2024 | 100.0 | + Then Loan Charges tab has the following data: + | Name | isPenalty | Payment due at | Due as of | Calculation type | Due | Paid | Waived | Outstanding | + | Tranche Disbursement Charge Percent | false | Tranche Disbursement | 01 January 2024 | % Disbursement Amount | 1.0 | 0.0 | 0.0 | 1.0 | + And Admin successfully approves the loan on "01 January 2024" with "200" 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 | | | 1.0 | | 1.0 | 1.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 | 1.0 | 0.0 | 103.05 | 1.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 | + | 01 January 2024 | Repayment (at time of disbursement) | 1.0 | 0.0 | 0.0 | 1.0 | 0.0 | 100.0 | false | false | + Then Loan Charges tab has the following data: + | Name | isPenalty | Payment due at | Due as of | Calculation type | Due | Paid | Waived | Outstanding | + | Tranche Disbursement Charge Percent | false | Tranche Disbursement | 01 January 2024 | % Disbursement Amount | 1.0 | 1.0 | 0.0 | 0.0 | + Then Loan Transactions tab has a "REPAYMENT_AT_DISBURSEMENT" transaction with date "01 January 2024" which has the following Journal entries: + | Type | Account code | Account name | Debit | Credit | + | INCOME | 404007 | Fee Income | | 1.0 | + | LIABILITY | 145023 | Suspense/Clearing account | 1.0 | | + # First repayment + 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 | | | 1.0 | | 1.0 | 1.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 | 1.0 | 0.0 | 103.05 | 18.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 January 2024 | Repayment (at time of disbursement) | 1.0 | 0.0 | 0.0 | 1.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 | + # Second repayment + When Admin sets the business date to "01 March 2024" + And Customer makes "AUTOPAY" repayment on "01 March 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 | | | 1.0 | | 1.0 | 1.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 | 01 March 2024 | 67.05 | 16.52 | 0.49 | 0.0 | 0.0 | 17.01 | 17.01 | 0.0 | 0.0 | 0.0 | + | 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 | 1.0 | 0.0 | 103.05 | 35.02 | 0.0 | 0.0 | 68.03 | + 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 January 2024 | Repayment (at time of disbursement) | 1.0 | 0.0 | 0.0 | 1.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 | + | 01 March 2024 | Repayment | 17.01 | 16.52 | 0.49 | 0.0 | 0.0 | 67.05 | false | false | + # Second disbursement + When Admin sets the business date to "03 March 2024" + And Admin successfully add disbursement detail to the loan on "03 March 2024" with 100 EUR transaction amount + When Admin successfully disburse the loan on "03 March 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 | | | 1.0 | | 1.0 | 1.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 | 01 March 2024 | 67.05 | 16.52 | 0.49 | 0.0 | 0.0 | 17.01 | 17.01 | 0.0 | 0.0 | 0.0 | + | | | 03 March 2024 | | 100.0 | | | 1.0 | | 1.0 | 1.0 | | | | + | 3 | 31 | 01 April 2024 | | 125.62 | 41.43 | 0.94 | 0.0 | 0.0 | 42.37 | 0.0 | 0.0 | 0.0 | 42.37 | + | 4 | 30 | 01 May 2024 | | 83.98 | 41.64 | 0.73 | 0.0 | 0.0 | 42.37 | 0.0 | 0.0 | 0.0 | 42.37 | + | 5 | 31 | 01 June 2024 | | 42.1 | 41.88 | 0.49 | 0.0 | 0.0 | 42.37 | 0.0 | 0.0 | 0.0 | 42.37 | + | 6 | 30 | 01 July 2024 | | 0.0 | 42.1 | 0.25 | 0.0 | 0.0 | 42.35 | 0.0 | 0.0 | 0.0 | 42.35 | + Then Loan Repayment schedule has the following data in Total row: + | Principal due | Interest | Fees | Penalties | Due | Paid | In advance | Late | Outstanding | + | 200.0 | 3.48 | 2.0 | 0.0 | 205.48 | 36.02 | 0.0 | 0.0 | 169.46 | + 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 January 2024 | Repayment (at time of disbursement) | 1.0 | 0.0 | 0.0 | 1.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 | + | 01 March 2024 | Repayment | 17.01 | 16.52 | 0.49 | 0.0 | 0.0 | 67.05 | false | false | + | 03 March 2024 | Disbursement | 100.0 | 0.0 | 0.0 | 0.0 | 0.0 | 167.05 | false | false | + | 03 March 2024 | Repayment (at time of disbursement) | 1.0 | 0.0 | 0.0 | 1.0 | 0.0 | 167.05 | false | false | + Then Loan Charges tab has the following data: + | Name | isPenalty | Payment due at | Due as of | Calculation type | Due | Paid | Waived | Outstanding | + | Tranche Disbursement Charge Percent | false | Tranche Disbursement | 03 March 2024 | % Disbursement Amount | 1.0 | 1.0 | 0.0 | 0.0 | + | Tranche Disbursement Charge Percent | false | Tranche Disbursement | 01 January 2024 | % Disbursement Amount | 1.0 | 1.0 | 0.0 | 0.0 | + + Then Loan Transactions tab has a "REPAYMENT_AT_DISBURSEMENT" transaction with date "03 March 2024" which has the following Journal entries: + | Type | Account code | Account name | Debit | Credit | + | INCOME | 404007 | Fee Income | | 1.0 | + | LIABILITY | 145023 | Suspense/Clearing account | 1.0 | | + # Run income recognition for accrual test + And Admin runs the Accrual Activity Posting job + And Admin runs the Add Accrual Transactions job + And Admin runs the Add Accrual Transactions For Loans With Income Posted As Transactions job + And Admin runs the Add Periodic Accrual Transactions job + And Admin runs the Recalculate Interest for Loans job + 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 January 2024 | Repayment (at time of disbursement) | 1.0 | 0.0 | 0.0 | 1.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 | + | 01 March 2024 | Repayment | 17.01 | 16.52 | 0.49 | 0.0 | 0.0 | 67.05 | false | false | + | 03 March 2024 | Disbursement | 100.0 | 0.0 | 0.0 | 0.0 | 0.0 | 167.05 | false | false | + | 03 March 2024 | Repayment (at time of disbursement) | 1.0 | 0.0 | 0.0 | 1.0 | 0.0 | 167.05 | false | false | + | 03 March 2024 | Accrual | 1.1 | 0.0 | 1.1 | 0.0 | 0.0 | 0.0 | false | false | + Then Loan Transactions tab has a "ACCRUAL" transaction with date "03 March 2024" which has the following Journal entries: + | Type | Account code | Account name | Debit | Credit | + | ASSET | 112603 | Interest/Fee Receivable | 1.1 | | + | INCOME | 404000 | Interest Income | | 1.1 | + + @TestRailId:C3655 + Scenario: Disbursement charge - flat and accrual based accounting - undo disbursement + When Admin sets the business date to "01 January 2024" + When Admin creates a client with random data + When Admin updates charge "CHARGE_LOAN_TRANCHE_DISBURSEMENT_CHARGE_AMOUNT" with "FLAT" calculation type and 5.0 EUR amount + When Admin creates a fully customized loan with charges and disbursement details and 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 | 1st_tranche_disb_expected_date | 1st_tranche_disb_principal | 2nd_tranche_disb_expected_date | 2nd_tranche_disb_principal | + | LP2_ADV_PYMNT_INTEREST_DAILY_EMI_360_30_INTEREST_RECALC_DAILY_MULTIDISBURSE_EXPECT_TRANCHE | 01 January 2024 | 200 | 7 | DECLINING_BALANCE | DAILY | EQUAL_INSTALLMENTS | 6 | MONTHS | 1 | MONTHS | 6 | 0 | 0 | 0 | ADVANCED_PAYMENT_ALLOCATION | CHARGE_LOAN_TRANCHE_DISBURSEMENT_CHARGE_AMOUNT | 5.0 | 01 January 2024 | 100.0 | 03 March 2024 | 100.0 | + Then Loan Charges tab has the following data: + | Name | isPenalty | Payment due at | Due as of | Calculation type | Due | Paid | Waived | Outstanding | + | Tranche Disbursement Charge Amount | false | Tranche Disbursement | 01 January 2024 | Flat | 5.0 | 0.0 | 0.0 | 5.0 | + And Admin successfully approves the loan on "01 January 2024" with "200" 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 | | | 5.0 | | 5.0 | 5.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 | 5.0 | 0.0 | 107.05 | 5.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 | + | 01 January 2024 | Repayment (at time of disbursement) | 5.0 | 0.0 | 0.0 | 5.0 | 0.0 | 100.0 | false | false | + Then Loan Charges tab has the following data: + | Name | isPenalty | Payment due at | Due as of | Calculation type | Due | Paid | Waived | Outstanding | + | Tranche Disbursement Charge Amount | false | Tranche Disbursement | 01 January 2024 | Flat | 5.0 | 5.0 | 0.0 | 0.0 | + Then Loan Transactions tab has a "REPAYMENT_AT_DISBURSEMENT" transaction with date "01 January 2024" which has the following Journal entries: + | Type | Account code | Account name | Debit | Credit | + | INCOME | 404007 | Fee Income | | 5.0 | + | LIABILITY | 145023 | Suspense/Clearing account | 5.0 | | + # First repayment + 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 | | | 5.0 | | 5.0 | 5.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 | 5.0 | 0.0 | 107.05 | 22.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 January 2024 | Repayment (at time of disbursement) | 5.0 | 0.0 | 0.0 | 5.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 | + # Second repayment + When Admin sets the business date to "01 March 2024" + And Customer makes "AUTOPAY" repayment on "01 March 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 | | | 5.0 | | 5.0 | 5.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 | 01 March 2024 | 67.05 | 16.52 | 0.49 | 0.0 | 0.0 | 17.01 | 17.01 | 0.0 | 0.0 | 0.0 | + | 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 | 5.0 | 0.0 | 107.05 | 39.02 | 0.0 | 0.0 | 68.03 | + 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 January 2024 | Repayment (at time of disbursement) | 5.0 | 0.0 | 0.0 | 5.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 | + | 01 March 2024 | Repayment | 17.01 | 16.52 | 0.49 | 0.0 | 0.0 | 67.05 | false | false | + # Second disbursement + When Admin sets the business date to "03 March 2024" + And Admin successfully add disbursement detail to the loan on "03 March 2024" with 100 EUR transaction amount + When Admin successfully disburse the loan on "03 March 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 | | | 5.0 | | 5.0 | 5.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 | 01 March 2024 | 67.05 | 16.52 | 0.49 | 0.0 | 0.0 | 17.01 | 17.01 | 0.0 | 0.0 | 0.0 | + | | | 03 March 2024 | | 100.0 | | | 5.0 | | 5.0 | 5.0 | | | | + | 3 | 31 | 01 April 2024 | | 125.62 | 41.43 | 0.94 | 0.0 | 0.0 | 42.37 | 0.0 | 0.0 | 0.0 | 42.37 | + | 4 | 30 | 01 May 2024 | | 83.98 | 41.64 | 0.73 | 0.0 | 0.0 | 42.37 | 0.0 | 0.0 | 0.0 | 42.37 | + | 5 | 31 | 01 June 2024 | | 42.1 | 41.88 | 0.49 | 0.0 | 0.0 | 42.37 | 0.0 | 0.0 | 0.0 | 42.37 | + | 6 | 30 | 01 July 2024 | | 0.0 | 42.1 | 0.25 | 0.0 | 0.0 | 42.35 | 0.0 | 0.0 | 0.0 | 42.35 | + Then Loan Repayment schedule has the following data in Total row: + | Principal due | Interest | Fees | Penalties | Due | Paid | In advance | Late | Outstanding | + | 200.0 | 3.48 | 10.0 | 0.0 | 213.48 | 44.02 | 0.0 | 0.0 | 169.46 | + 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 January 2024 | Repayment (at time of disbursement) | 5.0 | 0.0 | 0.0 | 5.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 | + | 01 March 2024 | Repayment | 17.01 | 16.52 | 0.49 | 0.0 | 0.0 | 67.05 | false | false | + | 03 March 2024 | Disbursement | 100.0 | 0.0 | 0.0 | 0.0 | 0.0 | 167.05 | false | false | + | 03 March 2024 | Repayment (at time of disbursement) | 5.0 | 0.0 | 0.0 | 5.0 | 0.0 | 167.05 | false | false | + Then Loan Charges tab has the following data: + | Name | isPenalty | Payment due at | Due as of | Calculation type | Due | Paid | Waived | Outstanding | + | Tranche Disbursement Charge Amount | false | Tranche Disbursement | 03 March 2024 | Flat | 5.0 | 5.0 | 0.0 | 0.0 | + | Tranche Disbursement Charge Amount | false | Tranche Disbursement | 01 January 2024 | Flat | 5.0 | 5.0 | 0.0 | 0.0 | + Then Loan Transactions tab has a "REPAYMENT_AT_DISBURSEMENT" transaction with date "03 March 2024" which has the following Journal entries: + | Type | Account code | Account name | Debit | Credit | + | INCOME | 404007 | Fee Income | | 5.0 | + | LIABILITY | 145023 | Suspense/Clearing account | 5.0 | | + # Run income recognition for accrual test + When Admin sets the business date to "03 March 2024" + And Admin runs the Accrual Activity Posting job + And Admin runs the Add Accrual Transactions job + And Admin runs the Add Accrual Transactions For Loans With Income Posted As Transactions job + And Admin runs the Add Periodic Accrual Transactions job + And Admin runs the Recalculate Interest for Loans job + 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 January 2024 | Repayment (at time of disbursement) | 5.0 | 0.0 | 0.0 | 5.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 | + | 01 March 2024 | Repayment | 17.01 | 16.52 | 0.49 | 0.0 | 0.0 | 67.05 | false | false | + | 03 March 2024 | Disbursement | 100.0 | 0.0 | 0.0 | 0.0 | 0.0 | 167.05 | false | false | + | 03 March 2024 | Repayment (at time of disbursement) | 5.0 | 0.0 | 0.0 | 5.0 | 0.0 | 167.05 | false | false | + | 03 March 2024 | Accrual | 1.1 | 0.0 | 1.1 | 0.0 | 0.0 | 0.0 | false | false | + Then Loan Transactions tab has a "ACCRUAL" transaction with date "03 March 2024" which has the following Journal entries: + | ASSET | 112603 | Interest/Fee Receivable | 1.1 | | + | INCOME | 404000 | Interest Income | | 1.1 | + # Undo disbursement + When Admin successfully undo disbursal + Then Loan status has changed to "Active" + 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 | | | 5.0 | | 5.0 | | | | 5.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 | 5.0 | 0.0 | 107.05 | 0.0 | 0.0 | 0.0 | 107.05 | + + @Skip + @TestRailId:C3656 + Scenario: Disbursement charge - flat and accrual based accounting - undo last disbursement + When Admin sets the business date to "01 January 2024" + When Admin creates a client with random data + When Admin updates charge "CHARGE_LOAN_TRANCHE_DISBURSEMENT_CHARGE_AMOUNT" with "FLAT" calculation type and 5.0 EUR amount + When Admin creates a fully customized loan with charges and disbursement details and 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 | 1st_tranche_disb_expected_date | 1st_tranche_disb_principal | 2nd_tranche_disb_expected_date | 2nd_tranche_disb_principal | + | LP2_ADV_PYMNT_INTEREST_DAILY_EMI_360_30_INTEREST_RECALC_DAILY_MULTIDISBURSE_EXPECT_TRANCHE | 01 January 2024 | 200 | 7 | DECLINING_BALANCE | DAILY | EQUAL_INSTALLMENTS | 6 | MONTHS | 1 | MONTHS | 6 | 0 | 0 | 0 | ADVANCED_PAYMENT_ALLOCATION | CHARGE_LOAN_TRANCHE_DISBURSEMENT_CHARGE_AMOUNT | 5.0 | 01 January 2024 | 100.0 | 03 March 2024 | 100.0 | + Then Loan Charges tab has the following data: + | Name | isPenalty | Payment due at | Due as of | Calculation type | Due | Paid | Waived | Outstanding | + | Tranche Disbursement Charge Amount | false | Tranche Disbursement | 01 January 2024 | Flat | 5.0 | 0.0 | 0.0 | 5.0 | + And Admin successfully approves the loan on "01 January 2024" with "200" 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 | | | 5.0 | | 5.0 | 5.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 | 5.0 | 0.0 | 107.05 | 5.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 | + | 01 January 2024 | Repayment (at time of disbursement) | 5.0 | 0.0 | 0.0 | 5.0 | 0.0 | 100.0 | false | false | + Then Loan Charges tab has the following data: + | Name | isPenalty | Payment due at | Due as of | Calculation type | Due | Paid | Waived | Outstanding | + | Tranche Disbursement Charge Amount | false | Tranche Disbursement | 01 January 2024 | Flat | 5.0 | 5.0 | 0.0 | 0.0 | + Then Loan Transactions tab has a "REPAYMENT_AT_DISBURSEMENT" transaction with date "01 January 2024" which has the following Journal entries: + | Type | Account code | Account name | Debit | Credit | + | INCOME | 404007 | Fee Income | | 5.0 | + | LIABILITY | 145023 | Suspense/Clearing account | 5.0 | | + # First repayment + 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 | | | 5.0 | | 5.0 | 5.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 | 5.0 | 0.0 | 107.05 | 22.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 January 2024 | Repayment (at time of disbursement) | 5.0 | 0.0 | 0.0 | 5.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 | + # Second repayment + When Admin sets the business date to "01 March 2024" + And Customer makes "AUTOPAY" repayment on "01 March 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 | | | 5.0 | | 5.0 | 5.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 | 01 March 2024 | 67.05 | 16.52 | 0.49 | 0.0 | 0.0 | 17.01 | 17.01 | 0.0 | 0.0 | 0.0 | + | 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 | 5.0 | 0.0 | 107.05 | 39.02 | 0.0 | 0.0 | 68.03 | + 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 January 2024 | Repayment (at time of disbursement) | 5.0 | 0.0 | 0.0 | 5.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 | + | 01 March 2024 | Repayment | 17.01 | 16.52 | 0.49 | 0.0 | 0.0 | 67.05 | false | false | + # Second disbursement + When Admin sets the business date to "03 March 2024" + And Admin successfully add disbursement detail to the loan on "03 March 2024" with 100 EUR transaction amount + When Admin successfully disburse the loan on "03 March 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 | | | 5.0 | | 5.0 | 5.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 | 01 March 2024 | 67.05 | 16.52 | 0.49 | 0.0 | 0.0 | 17.01 | 17.01 | 0.0 | 0.0 | 0.0 | + | | | 03 March 2024 | | 100.0 | | | 5.0 | | 5.0 | 5.0 | | | | + | 3 | 31 | 01 April 2024 | | 125.62 | 41.43 | 0.94 | 0.0 | 0.0 | 42.37 | 0.0 | 0.0 | 0.0 | 42.37 | + | 4 | 30 | 01 May 2024 | | 83.98 | 41.64 | 0.73 | 0.0 | 0.0 | 42.37 | 0.0 | 0.0 | 0.0 | 42.37 | + | 5 | 31 | 01 June 2024 | | 42.1 | 41.88 | 0.49 | 0.0 | 0.0 | 42.37 | 0.0 | 0.0 | 0.0 | 42.37 | + | 6 | 30 | 01 July 2024 | | 0.0 | 42.1 | 0.25 | 0.0 | 0.0 | 42.35 | 0.0 | 0.0 | 0.0 | 42.35 | + Then Loan Repayment schedule has the following data in Total row: + | Principal due | Interest | Fees | Penalties | Due | Paid | In advance | Late | Outstanding | + | 200.0 | 3.48 | 10.0 | 0.0 | 213.48 | 44.02 | 0.0 | 0.0 | 169.46 | + 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 January 2024 | Repayment (at time of disbursement) | 5.0 | 0.0 | 0.0 | 5.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 | + | 01 March 2024 | Repayment | 17.01 | 16.52 | 0.49 | 0.0 | 0.0 | 67.05 | false | false | + | 03 March 2024 | Disbursement | 100.0 | 0.0 | 0.0 | 0.0 | 0.0 | 167.05 | false | false | + | 03 March 2024 | Repayment (at time of disbursement) | 5.0 | 0.0 | 0.0 | 5.0 | 0.0 | 167.05 | false | false | + Then Loan Charges tab has the following data: + | Name | isPenalty | Payment due at | Due as of | Calculation type | Due | Paid | Waived | Outstanding | + | Tranche Disbursement Charge Amount | false | Tranche Disbursement | 03 March 2024 | Flat | 5.0 | 5.0 | 0.0 | 0.0 | + | Tranche Disbursement Charge Amount | false | Tranche Disbursement | 01 January 2024 | Flat | 5.0 | 5.0 | 0.0 | 0.0 | + Then Loan Transactions tab has a "REPAYMENT_AT_DISBURSEMENT" transaction with date "03 March 2024" which has the following Journal entries: + | Type | Account code | Account name | Debit | Credit | + | INCOME | 404007 | Fee Income | | 5.0 | + | LIABILITY | 145023 | Suspense/Clearing account | 5.0 | | + # Run income recognition for accrual test + When Admin sets the business date to "03 March 2024" + And Admin runs the Accrual Activity Posting job + And Admin runs the Add Accrual Transactions job + And Admin runs the Add Accrual Transactions For Loans With Income Posted As Transactions job + And Admin runs the Add Periodic Accrual Transactions job + And Admin runs the Recalculate Interest for Loans job + 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 January 2024 | Repayment (at time of disbursement) | 5.0 | 0.0 | 0.0 | 5.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 | + | 01 March 2024 | Repayment | 17.01 | 16.52 | 0.49 | 0.0 | 0.0 | 67.05 | false | false | + | 03 March 2024 | Disbursement | 100.0 | 0.0 | 0.0 | 0.0 | 0.0 | 167.05 | false | false | + | 03 March 2024 | Repayment (at time of disbursement) | 5.0 | 0.0 | 0.0 | 5.0 | 0.0 | 167.05 | false | false | + | 03 March 2024 | Accrual | 1.1 | 0.0 | 1.1 | 0.0 | 0.0 | 0.0 | false | false | + Then Loan Transactions tab has a "ACCRUAL" transaction with date "03 March 2024" which has the following Journal entries: + | Type | Account code | Account name | Debit | Credit | + | ASSET | 112603 | Interest/Fee Receivable | 1.1 | | + | INCOME | 404000 | Interest Income | | 1.1 | + # Undo last disbursement + When Admin successfully undo last disbursal + Then Loan status has changed to "Active" + 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 | | | 5.0 | | 5.0 | 5.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 | 01 March 2024 | 67.05 | 16.52 | 0.49 | 0.0 | 0.0 | 17.01 | 17.01 | 0.0 | 0.0 | 0.0 | + | 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 | 5.0 | 0.0 | 107.05 | 39.02 | 0.0 | 0.0 | 68.03 | + 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 January 2024 | Repayment (at time of disbursement) | 5.0 | 0.0 | 0.0 | 5.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 | + | 01 March 2024 | Repayment | 17.01 | 16.52 | 0.49 | 0.0 | 0.0 | 67.05 | false | false | + | 03 March 2024 | Accrual | 1.1 | 0.0 | 1.1 | 0.0 | 0.0 | 0.0 | false | false | + Then Loan Charges tab has the following data: + | Name | isPenalty | Payment due at | Due as of | Calculation type | Due | Paid | Waived | Outstanding | + | Tranche Disbursement Charge Amount | false | Tranche Disbursement | 01 January 2024 | Flat | 5.0 | 5.0 | 0.0 | 0.0 | + Then Loan Transactions tab has a "DISBURSEMENT" transaction with date "01 January 2024" which has the following Journal entries: + | Type | Account code | Account name | Debit | Credit | + | ASSET | 112601 | Loans Receivable | 100.0 | | + | LIABILITY | 145023 | Suspense/Clearing account | | 100.0 | + Then Loan Transactions tab has a "REPAYMENT_AT_DISBURSEMENT" transaction with date "01 January 2024" which has the following Journal entries: + | Type | Account code | Account name | Debit | Credit | + | INCOME | 404007 | Fee Income | | 5.0 | + | LIABILITY | 145023 | Suspense/Clearing account | 5.0 | | diff --git a/fineract-loan/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/Loan.java b/fineract-loan/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/Loan.java index f82dab2ca..e5cdfcfee 100644 --- a/fineract-loan/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/Loan.java +++ b/fineract-loan/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/Loan.java @@ -967,8 +967,7 @@ public class Loan extends AbstractAuditableWithUTCDateTimeCustom { } private boolean hasDisbursementTransaction() { - return this.loanTransactions.stream() - .anyMatch(loanTransaction -> loanTransaction.isDisbursement() && loanTransaction.isNotReversed()); + return this.loanTransactions.stream().anyMatch(LoanTransaction::isDisbursement); } diff --git a/fineract-loan/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanBalanceService.java b/fineract-loan/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanBalanceService.java index 4b66cbd8c..cbacb2a24 100644 --- a/fineract-loan/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanBalanceService.java +++ b/fineract-loan/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanBalanceService.java @@ -95,25 +95,29 @@ public class LoanBalanceService { } loan.setTotalOverpaid(null); } else { - final Money overpaidBy = calculateTotalOverpayment(loan); - loan.setTotalOverpaid(null); - if (!overpaidBy.isLessThanZero()) { - loan.setTotalOverpaid(overpaidBy.getAmountDefaultedToNullIfZero()); - } - - final Money recoveredAmount = loan.calculateTotalRecoveredPayments(); - loan.setTotalRecovered(recoveredAmount.getAmountDefaultedToNullIfZero()); - - final Money principal = loan.getLoanRepaymentScheduleDetail().getPrincipal(); - final Money capitalizedIncome = capitalizedIncomeBalanceService.calculateCapitalizedIncome(loan); - final Money capitalizedIncomeAdjustment = capitalizedIncomeBalanceService.calculateCapitalizedIncomeAdjustment(loan); - loan.getSummary().updateSummary(loan.getCurrency(), principal, loan.getRepaymentScheduleInstallments(), - loan.getLoanCharges(), capitalizedIncome, capitalizedIncomeAdjustment); - loan.updateLoanOutstandingBalances(); + refreshSummaryAndBalancesForDisbursedLoan(loan); } }); } + public void refreshSummaryAndBalancesForDisbursedLoan(final Loan loan) { + final Money overpaidBy = calculateTotalOverpayment(loan); + loan.setTotalOverpaid(null); + if (!overpaidBy.isLessThanZero()) { + loan.setTotalOverpaid(overpaidBy.getAmountDefaultedToNullIfZero()); + } + + final Money recoveredAmount = loan.calculateTotalRecoveredPayments(); + loan.setTotalRecovered(recoveredAmount.getAmountDefaultedToNullIfZero()); + + final Money principal = loan.getLoanRepaymentScheduleDetail().getPrincipal(); + final Money capitalizedIncome = capitalizedIncomeBalanceService.calculateCapitalizedIncome(loan); + final Money capitalizedIncomeAdjustment = capitalizedIncomeBalanceService.calculateCapitalizedIncomeAdjustment(loan); + loan.getSummary().updateSummary(loan.getCurrency(), principal, loan.getRepaymentScheduleInstallments(), loan.getLoanCharges(), + capitalizedIncome, capitalizedIncomeAdjustment); + loan.updateLoanOutstandingBalances(); + } + public void updateLoanToLastDisbursalState(final Loan loan, final LoanDisbursementDetails disbursementDetail) { for (final LoanCharge charge : loan.getActiveCharges()) { if (charge.isOverdueInstallmentCharge()) { diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanDisbursementService.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanDisbursementService.java index 82d73a91d..366c9ebad 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanDisbursementService.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanDisbursementService.java @@ -187,13 +187,18 @@ public class LoanDisbursementService { final Integer installmentNumber = null; for (final LoanCharge charge : loan.getActiveCharges()) { LocalDate actualDisbursementDate = loan.getActualDisbursementDate(charge); + + boolean isDisbursementCharge = charge.getCharge().getChargeTimeType().equals(ChargeTimeType.DISBURSEMENT.getValue()) + && disbursedOn.equals(actualDisbursementDate) && !charge.isWaived() && !charge.isFullyPaid(); + + boolean isTrancheDisbursementCharge = charge.getCharge().getChargeTimeType() + .equals(ChargeTimeType.TRANCHE_DISBURSEMENT.getValue()) && disbursedOn.equals(actualDisbursementDate) + && !charge.isWaived() && !charge.isFullyPaid(); + /* * create a Charge applied transaction if Up front Accrual, None or Cash based accounting is enabled */ - if ((charge.getCharge().getChargeTimeType().equals(ChargeTimeType.DISBURSEMENT.getValue()) - && disbursedOn.equals(actualDisbursementDate) && !charge.isWaived() && !charge.isFullyPaid()) - || (charge.getCharge().getChargeTimeType().equals(ChargeTimeType.TRANCHE_DISBURSEMENT.getValue()) - && disbursedOn.equals(actualDisbursementDate) && !charge.isWaived() && !charge.isFullyPaid())) { + if (isDisbursementCharge || isTrancheDisbursementCharge) { if (totalFeeChargesDueAtDisbursement.isGreaterThanZero() && !charge.getChargePaymentMode().isPaymentModeAccountTransfer()) { charge.markAsFullyPaid(); // Add "Loan Charge Paid By" details to this transaction @@ -201,9 +206,16 @@ public class LoanDisbursementService { installmentNumber); chargesPayment.getLoanChargesPaid().add(loanChargePaidBy); disbursentMoney = disbursentMoney.plus(charge.amount()); + + // For tranche disbursement charges, we need to ensure they don't affect the loan schedule + if (isTrancheDisbursementCharge) { + charge.setOutstandingAmount(BigDecimal.ZERO); + charge.setPaid(true); + } } } else if (disbursedOn.equals(loan.getActualDisbursementDate()) && loan.isNoneOrCashOrUpfrontAccrualAccountingEnabledOnLoanProduct()) { + // Handle other charges with the standard approach loanChargeService.handleChargeAppliedTransaction(loan, charge, disbursedOn); } } diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanWritePlatformServiceJpaRepositoryImpl.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanWritePlatformServiceJpaRepositoryImpl.java index 8ebb5a70e..e5afb435d 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanWritePlatformServiceJpaRepositoryImpl.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanWritePlatformServiceJpaRepositoryImpl.java @@ -3061,7 +3061,8 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf existingTransactionIds.addAll(loanTransactionRepository.findTransactionIdsByLoan(loan)); existingReversedTransactionIds.addAll(loanTransactionRepository.findReversedTransactionIdsByLoan(loan)); if (!statusEnum.hasStateOf(currentStatus)) { - this.loanLifecycleStateMachine.transition(LoanEvent.LOAN_DISBURSAL_UNDO, loan); + this.loanLifecycleStateMachine.transition(LoanEvent.LOAN_DISBURSAL_UNDO, loan); // tis will update the loan + // status actualChanges.put(PARAM_STATUS, LoanEnumerations.status(loan.getLoanStatus())); final LocalDate actualDisbursementDate = loan.getDisbursementDate(); @@ -3082,7 +3083,6 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf } } final boolean isEmiAmountChanged = !loan.getLoanTermVariations().isEmpty(); - updateLoanToPreDisbursalState(loan); if (isScheduleRegenerateRequired || isDisbursedAmountChanged || isEmiAmountChanged || loan.isInterestBearingAndInterestRecalculationEnabled()) { @@ -3114,9 +3114,10 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf public void updateLoanToPreDisbursalState(final Loan loan) { loan.setActualDisbursementDate(null); - + loan.setDisbursedBy(null); loan.setAccruedTill(null); reverseExistingTransactions(loan); + BigDecimal principalForScheduleRegeneration = loan.getApprovedPrincipal(); for (final LoanCharge charge : loan.getActiveCharges()) { if (charge.isOverdueInstallmentCharge()) { @@ -3125,19 +3126,24 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf charge.resetToOriginal(loan.loanCurrency()); } } + + loan.getLoanRepaymentScheduleDetail().setPrincipal(principalForScheduleRegeneration); + final List installments = loan.getRepaymentScheduleInstallments(); for (final LoanRepaymentScheduleInstallment currentInstallment : installments) { currentInstallment.resetDerivedComponents(); } + for (LoanTermVariations variations : loan.getLoanTermVariations()) { if (variations.getOnLoanStatus().equals(LoanStatus.ACTIVE.getValue())) { variations.markAsInactive(); } } + final LoanRepaymentScheduleProcessingWrapper wrapper = new LoanRepaymentScheduleProcessingWrapper(); wrapper.reprocess(loan.getCurrency(), loan.getDisbursementDate(), loan.getRepaymentScheduleInstallments(), loan.getActiveCharges()); - loanBalanceService.updateLoanSummaryDerivedFields(loan); + loanBalanceService.refreshSummaryAndBalancesForDisbursedLoan(loan); } private void reverseExistingTransactions(final Loan loan) { @@ -3410,6 +3416,31 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf * Reverse only disbursement, accruals, and repayments at disbursal transactions */ public void reverseExistingTransactionsTillLastDisbursal(final Loan loan, final LoanTransaction lastDisbursalTransaction) { + LoanCharge chargeToDeactivate = null; + + for (final LoanCharge charge : loan.getCharges()) { + if (charge.isTrancheDisbursementCharge()) { + if (charge.getTrancheDisbursementCharge() != null + && charge.getTrancheDisbursementCharge().getloanDisbursementDetails() != null) { + + LocalDate expectedDate = charge.getTrancheDisbursementCharge().getloanDisbursementDetails().expectedDisbursementDate(); + LocalDate actualDate = charge.getTrancheDisbursementCharge().getloanDisbursementDetails().actualDisbursementDate(); + + if ((actualDate != null && actualDate.equals(lastDisbursalTransaction.getTransactionDate())) + || (expectedDate != null && expectedDate.equals(lastDisbursalTransaction.getTransactionDate()))) { + chargeToDeactivate = charge; + break; + } + } + } + } + + if (chargeToDeactivate != null) { + chargeToDeactivate.resetPaidAmount(loan.getCurrency()); + chargeToDeactivate.setActive(false); + } + + // Now reverse all relevant transactions for (final LoanTransaction transaction : loan.getLoanTransactions()) { if (!DateUtils.isBefore(transaction.getTransactionDate(), lastDisbursalTransaction.getTransactionDate()) && transaction.getId().compareTo(lastDisbursalTransaction.getId()) >= 0 @@ -3418,6 +3449,9 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf transaction.reverse(); } } + + loanBalanceService.updateLoanSummaryDerivedFields(loan); + if (loan.isAutoRepaymentForDownPaymentEnabled()) { // identify down-payment amount for the transaction BigDecimal disbursedAmountPercentageForDownPayment = loan.getLoanRepaymentScheduleDetail() @@ -3439,10 +3473,6 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf } } - /** - * Behaviour added to comply with capability of previous mifos product to support easier transition to fineract - * platform. - */ public void closeAsMarkedForReschedule(final Loan loan, final JsonCommand command, final Map changes) { final LocalDate rescheduledOn = command.localDateValueOfParameterNamed(TRANSACTION_DATE);