From bd41cb4c6bca961e4c33750c11884e3b0de88abe Mon Sep 17 00:00:00 2001 From: Oleksii Novikov Date: Mon, 14 Sep 2026 12:48:04 +0300 Subject: [PATCH 1/2] FINERACT-2455: WC - No accruals in case no accounting is configured --- .../test/stepdef/common/OfficeStepDef.java | 20 ++++++++ ...italDiscountAdjustmentBackdateUndo.feature | 51 +++++++++++++++++++ .../WorkingCapitalLoanChargeAccrual.feature | 24 +++++++++ ...kingCapitalLoanChargeOffAccounting.feature | 19 +++++++ ...ngCapitalLoanWritePlatformServiceImpl.java | 8 ++- 5 files changed, 120 insertions(+), 2 deletions(-) diff --git a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/stepdef/common/OfficeStepDef.java b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/stepdef/common/OfficeStepDef.java index 94215d5a4c2..b68bb3c5fac 100644 --- a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/stepdef/common/OfficeStepDef.java +++ b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/stepdef/common/OfficeStepDef.java @@ -19,11 +19,15 @@ package org.apache.fineract.test.stepdef.common; import static org.apache.fineract.client.feign.util.FeignCalls.ok; +import static org.assertj.core.api.Assertions.assertThat; import io.cucumber.java.en.When; import java.time.LocalDate; +import java.time.format.DateTimeFormatter; +import java.util.Locale; import lombok.RequiredArgsConstructor; import org.apache.fineract.client.feign.FineractFeignClient; +import org.apache.fineract.client.models.PostGlClosuresRequest; import org.apache.fineract.client.models.PostOfficesRequest; import org.apache.fineract.client.models.PostOfficesResponse; import org.apache.fineract.test.helper.Utils; @@ -33,6 +37,8 @@ @RequiredArgsConstructor public class OfficeStepDef extends AbstractStepDef { + private static final DateTimeFormatter FORMATTER = DateTimeFormatter.ofPattern("dd MMMM yyyy", Locale.ENGLISH); + private final FineractFeignClient fineractClient; @When("Admin creates a new office") @@ -47,4 +53,18 @@ public void createNewOffice() { final PostOfficesResponse response = ok(() -> fineractClient.offices().createOffice(request)); testContext().set(TestContextKey.OFFICE_CREATE_RESPONSE, response); } + + @When("Admin closes accounting for the last created office on {string}") + public void closeAccountingForLastCreatedOffice(final String closingDate) { + final PostOfficesResponse office = testContext().get(TestContextKey.OFFICE_CREATE_RESPONSE); + assertThat(office).as("No office was created. Use 'Admin creates a new office' step first.").isNotNull(); + final PostGlClosuresRequest request = new PostGlClosuresRequest()// + .officeId(office.getOfficeId())// + .closingDate(LocalDate.parse(closingDate, FORMATTER))// + .comments("Accounting closure")// + .dateFormat("yyyy-MM-dd")// + .locale("en");// + + ok(() -> fineractClient.accountingClosure().createGLClosure(request)); + } } diff --git a/fineract-e2e-tests-runner/src/test/resources/features/WorkingCapitalDiscountAdjustmentBackdateUndo.feature b/fineract-e2e-tests-runner/src/test/resources/features/WorkingCapitalDiscountAdjustmentBackdateUndo.feature index 22bcd09c4f2..3c4cc2cac6f 100644 --- a/fineract-e2e-tests-runner/src/test/resources/features/WorkingCapitalDiscountAdjustmentBackdateUndo.feature +++ b/fineract-e2e-tests-runner/src/test/resources/features/WorkingCapitalDiscountAdjustmentBackdateUndo.feature @@ -178,6 +178,57 @@ Feature: Working Capital Discount Adjustment Backdated and Undo | LIABILITY | 240005 | Deferred Interest Revenue | 28.7 | | | INCOME | 404000 | Interest Income | | 28.7 | + Scenario: Full discount adjustment on a product without accounting posts an amortization adjustment with no journal entries; undo reverses both even when accounting is closed for the office + When Admin sets the business date to "01 January 2026" + And Admin creates a new office + And Admin creates a client with random data in the last created office + And Admin creates a working capital loan with the following data: + | LoanProduct | submittedOnDate | expectedDisbursementDate | principalAmount | totalPaymentVolume | periodPaymentRate | discount | + | WCLP | 01 January 2026 | 01 January 2026 | 9000 | 100000 | 18 | | + Then Working capital loan creation was successful + Then Admin successfully approves the working capital loan on "01 January 2026" with "9000" amount and expected disbursement date on "01 January 2026" + Then Admin successfully disburse the Working Capital loan on "01 January 2026" with "9000" EUR transaction amount + Then Admin successfully add discount with "1000" amount on Working Capital loan account + And Admin loads discount fee transaction from Working Capital loan for adjustment + When Admin sets the business date to "02 January 2026" + And Customer makes repayment on "02 January 2026" with 50 transaction amount on Working Capital loan + When Admin sets the business date to "03 January 2026" + And Customer makes repayment on "03 January 2026" with 50 transaction amount on Working Capital loan + When Admin sets the business date to "04 January 2026" + And Customer makes repayment on "04 January 2026" with 50 transaction amount on Working Capital loan + When Admin sets the business date to "05 January 2026" + When Admin runs inline COB job for Working Capital Loan + And Admin adds Discount fee adjustment with "1000" amount on transaction date "05 January 2026" on Working Capital loan account for last discount + When Admin sets the business date to "06 January 2026" + When Admin runs inline COB job for Working Capital Loan + Then Working Capital Loan has transactions: + | transactionDate | type | transactionAmount | principalPortion | feeChargesPortion | penaltyChargesPortion | reversed | + | 01 January 2026 | Disbursement | 9000.0 | 9000.0 | 0.0 | 0.0 | false | + | 01 January 2026 | Discount Fee | 1000.0 | 1000.0 | 0.0 | 0.0 | false | + | 02 January 2026 | Repayment | 50.0 | 50.0 | 0.0 | 0.0 | false | + | 03 January 2026 | Repayment | 50.0 | 50.0 | 0.0 | 0.0 | false | + | 04 January 2026 | Repayment | 50.0 | 50.0 | 0.0 | 0.0 | false | + | 04 January 2026 | Discount Fee Amortization | 28.70 | | | | false | + | 05 January 2026 | Discount Fee Adjustment | 1000.0 | 1000.0 | 0.0 | 0.0 | false | + | 05 January 2026 | Discount Fee Amortization Adjustment | 28.70 | | | | false | + Then Working Capital Loan Transactions tab has a "DISCOUNT_FEE_AMORTIZATION" transaction with date "04 January 2026" which has the following Journal entries: + | Type | Account code | Account name | Debit | Credit | + Then Working Capital Loan Transactions tab has a "DISCOUNT_FEE_AMORTIZATION_ADJUSTMENT" transaction with date "05 January 2026" which has the following Journal entries: + | Type | Account code | Account name | Debit | Credit | + When Admin closes accounting for the last created office on "06 January 2026" + When Admin undo the last Discount fee adjustment on Working Capital loan account + Then Working Capital Loan has transactions: + | transactionDate | type | transactionAmount | principalPortion | feeChargesPortion | penaltyChargesPortion | reversed | + | 01 January 2026 | Disbursement | 9000.0 | 9000.0 | 0.0 | 0.0 | false | + | 01 January 2026 | Discount Fee | 1000.0 | 1000.0 | 0.0 | 0.0 | false | + | 02 January 2026 | Repayment | 50.0 | 50.0 | 0.0 | 0.0 | false | + | 03 January 2026 | Repayment | 50.0 | 50.0 | 0.0 | 0.0 | false | + | 04 January 2026 | Repayment | 50.0 | 50.0 | 0.0 | 0.0 | false | + | 04 January 2026 | Discount Fee Amortization | 28.70 | | | | false | + | 05 January 2026 | Discount Fee Adjustment | 1000.0 | 1000.0 | 0.0 | 0.0 | true | + | 05 January 2026 | Discount Fee Amortization Adjustment | 28.70 | | | | true | + Then Admin closes the Working Capital loan with a full repayment on "06 January 2026" + @TestRailId:C83068 Scenario: Multiple backdated discount fee adjustments are allowed; undo of the last one restores its share of the discount When Admin sets the business date to "01 January 2026" diff --git a/fineract-e2e-tests-runner/src/test/resources/features/WorkingCapitalLoanChargeAccrual.feature b/fineract-e2e-tests-runner/src/test/resources/features/WorkingCapitalLoanChargeAccrual.feature index 1db73722ca9..0da061baa3b 100644 --- a/fineract-e2e-tests-runner/src/test/resources/features/WorkingCapitalLoanChargeAccrual.feature +++ b/fineract-e2e-tests-runner/src/test/resources/features/WorkingCapitalLoanChargeAccrual.feature @@ -512,6 +512,30 @@ Feature: Working Capital Loan Charge Accrual | 50.0 | 50.0 | 0.0 | 30.0 | 30.0 | 0.0 | And Admin sets the business date to "20 October 2026" Then Admin closes the Working Capital loan with a full repayment on "20 October 2026" + And Working Capital Loan has transactions: + | transactionDate | type | transactionAmount | principalPortion | feeChargesPortion | penaltyChargesPortion | reversed | + | 01 October 2026 | Disbursement | 9000.0 | 9000.0 | 0.0 | 0.0 | false | + | 20 October 2026 | Repayment | 9080.0 | 9000.0 | 50.0 | 30.0 | false | + + Scenario: Verify no accrual or accrual adjustment is created for Working Capital loan charges in real time and on undo disbursal when product accounting rule is NONE + Given Admin sets the business date to "01 May 2027" + And Admin creates a client with random data and creates-approves-disburses a working capital loan with the following data: + | LoanProduct | submittedOnDate | expectedDisbursementDate | principalAmount | totalPayment | periodPaymentRate | discount | + | WCLP | 01 May 2027 | 01 May 2027 | 9000 | 100000 | 18 | 0 | + When Global config "charge-accrual-date" value set to "submitted-date" + When Global config "wcl-charge-accrual-time" value set to "real-time" + And Admin sets the business date to "10 May 2027" + And Admin adds "WORKING_CAPITAL_SPECIFIED_DUE_DATE_FEE" specified due date charge to working capital loan with "20 May 2027" due date and 100.0 transaction amount + Then Working Capital Loan has transactions: + | transactionDate | type | transactionAmount | principalPortion | feeChargesPortion | penaltyChargesPortion | reversed | + | 01 May 2027 | Disbursement | 9000.0 | 9000.0 | 0.0 | 0.0 | false | + When Admin successfully undo Working Capital disbursal + Then Working Capital Loan has transactions: + | transactionDate | type | transactionAmount | principalPortion | feeChargesPortion | penaltyChargesPortion | reversed | + | 01 May 2027 | Disbursement | 9000.0 | 9000.0 | 0.0 | 0.0 | true | + And Admin successfully disburse the Working Capital loan on "10 May 2027" with "9000" EUR transaction amount + And Admin sets the business date to "15 May 2027" + Then Admin closes the Working Capital loan with a full repayment on "15 May 2027" @TestRailId:C85643 Scenario: Verify pending charge accrual is posted at closure even when charge-accrual-date is submitted-date diff --git a/fineract-e2e-tests-runner/src/test/resources/features/WorkingCapitalLoanChargeOffAccounting.feature b/fineract-e2e-tests-runner/src/test/resources/features/WorkingCapitalLoanChargeOffAccounting.feature index 1c3b7bf4286..5fde9137d69 100644 --- a/fineract-e2e-tests-runner/src/test/resources/features/WorkingCapitalLoanChargeOffAccounting.feature +++ b/fineract-e2e-tests-runner/src/test/resources/features/WorkingCapitalLoanChargeOffAccounting.feature @@ -771,6 +771,25 @@ Feature: Working Capital Charge-Off Accounting Entries | Type | Account code | Account name | Debit | Credit | Then Admin closes the Working Capital loan with all obligations met with a full repayment on "10 January 2026" + Scenario: Verify Working Capital charge-off on a product without accounting posts the final discount fee amortization with no journal entries + Given Admin sets the business date to "01 January 2026" + And Admin creates a client with random data and creates-approves-disburses a working capital loan with the following data: + | LoanProduct | submittedOnDate | expectedDisbursementDate | principalAmount | totalPayment | periodPaymentRate | discount | + | WCLP | 01 January 2026 | 01 January 2026 | 9000 | 100000 | 18 | 0 | + And Admin adds Discount fee with "1000" amount on Working Capital loan account for last disbursement + When Admin sets the business date to "02 January 2026" + And Admin runs inline COB job for Working Capital Loan by loanId + And Admin charges off the Working Capital loan on "02 January 2026" + Then Working Capital Loan has transactions: + | transactionDate | type | transactionAmount | principalPortion | feeChargesPortion | penaltyChargesPortion | reversed | + | 01 January 2026 | Disbursement | 9000.0 | 9000.0 | 0.0 | 0.0 | false | + | 01 January 2026 | Discount Fee | 1000.0 | 1000.0 | 0.0 | 0.0 | false | + | 02 January 2026 | Charge-off | 10000.0 | 10000.0 | 0.0 | 0.0 | false | + | 02 January 2026 | Discount Fee Amortization | 1000.0 | | | | false | + Then Working Capital Loan Transactions tab has a "DISCOUNT_FEE_AMORTIZATION" transaction with date "02 January 2026" which has the following Journal entries: + | Type | Account code | Account name | Debit | Credit | + Then Admin closes the Working Capital loan with all obligations met with a full repayment on "02 January 2026" + @TestRailId:C94033 Scenario: Verify Working Capital charge-off accounting - UC24: backdated repayment before charge-off keeps regular JE and restates charge-off Given Admin sets the business date to "01 January 2026" diff --git a/fineract-working-capital-loan/src/main/java/org/apache/fineract/portfolio/workingcapitalloan/service/WorkingCapitalLoanWritePlatformServiceImpl.java b/fineract-working-capital-loan/src/main/java/org/apache/fineract/portfolio/workingcapitalloan/service/WorkingCapitalLoanWritePlatformServiceImpl.java index e8962b68503..73e6d12d14d 100644 --- a/fineract-working-capital-loan/src/main/java/org/apache/fineract/portfolio/workingcapitalloan/service/WorkingCapitalLoanWritePlatformServiceImpl.java +++ b/fineract-working-capital-loan/src/main/java/org/apache/fineract/portfolio/workingcapitalloan/service/WorkingCapitalLoanWritePlatformServiceImpl.java @@ -1309,7 +1309,9 @@ private WorkingCapitalLoanTransaction reverseDisbursementTransactionAndResetBala // Reverse the journal entries of any charge accrual so the recognized income/receivable is backed out with the // disbursement; marking the transaction reversed alone would leave the GL postings in place. - accrualsToReverse.forEach(accrual -> accountingProcessor.postReversalJournalEntries(loan, accrual)); + if (loan.getLoanProduct().getAccountingRule().isAccrualWithDeferredRevenueAmortization()) { + accrualsToReverse.forEach(accrual -> accountingProcessor.postReversalJournalEntries(loan, accrual)); + } accrualsToReverse.forEach(accrual -> businessEventNotifierService .notifyPostBusinessEvent(new WorkingCapitalLoanAccrualAdjustmentTransactionBusinessEvent(accrual, loan.getId()))); @@ -1365,7 +1367,9 @@ private void reverseDiscountFeeAmortizationAdjustments(final WorkingCapitalLoan LoanTransactionType.DISCOUNT_FEE_AMORTIZATION_ADJUSTMENT).forEach(relation -> { final WorkingCapitalLoanTransaction txn = relation.getFromTransaction(); reverseTransaction(txn); - accountingProcessor.postReversalJournalEntries(loan, txn); + if (loan.getLoanProduct().getAccountingRule().isAccrualWithDeferredRevenueAmortization()) { + accountingProcessor.postReversalJournalEntries(loan, txn); + } }); // Realized income is recomputed from the (now-reversed) transactions by its single owner, not adjusted here. discountFeeAmortizationService.recalculateRealizedIncome(loan); From 31dd361be5acf39e2f90514be3a1b1b40f858330 Mon Sep 17 00:00:00 2001 From: Rustam Zeinalov Date: Fri, 18 Sep 2026 13:26:03 +0200 Subject: [PATCH 2/2] FINERACT-2455: Added e2e tests for validating WC - No accruals in case no accounting is configured --- .../WorkingCapitalLoanAccountStepDef.java | 12 ++++ ...italDiscountAdjustmentBackdateUndo.feature | 53 ++++++++++++++- .../WorkingCapitalLoanChargeAccrual.feature | 65 +++++++++++++++++++ ...kingCapitalLoanChargeOffAccounting.feature | 1 + 4 files changed, 130 insertions(+), 1 deletion(-) diff --git a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/stepdef/loan/WorkingCapitalLoanAccountStepDef.java b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/stepdef/loan/WorkingCapitalLoanAccountStepDef.java index 25cf20bffd9..ffcf7c93130 100644 --- a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/stepdef/loan/WorkingCapitalLoanAccountStepDef.java +++ b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/stepdef/loan/WorkingCapitalLoanAccountStepDef.java @@ -1603,6 +1603,18 @@ public void undoDisbursalWCLoanByexternalId() { checkChangesExpectedStatus(TestContextKey.LOAN_UNDO_DISBURSE_RESPONSE, APPROVED); } + @Then("Undo Working Capital disbursal results an error with the following data:") + public void undoDisbursalWCLoanResultsAnError(final DataTable table) { + final PostWorkingCapitalLoansLoanIdRequest undoDisbursalRequest = workingCapitalLoanRequestFactory + .defaultWorkingCapitalLoanUndoDisburseRequest(); + + final CallFailedRuntimeException exception = fail(() -> fineractClient.workingCapitalLoans() + .stateTransitionWorkingCapitalLoanById(getCreatedLoanId(), "undodisbursal", undoDisbursalRequest)); + + verifyErrorResponse(exception, table); + log.info("Verified working capital loan undo disbursal failed with expected error"); + } + @Then("Working Capital disbursal transaction business event is raised") public void workingCapitalDisbursalTransactionBusinessEventIsRaised() { eventCheckHelper.workingCapitalLoanDisbursalTransactionEventCheck(getCreatedLoanId()); diff --git a/fineract-e2e-tests-runner/src/test/resources/features/WorkingCapitalDiscountAdjustmentBackdateUndo.feature b/fineract-e2e-tests-runner/src/test/resources/features/WorkingCapitalDiscountAdjustmentBackdateUndo.feature index 3c4cc2cac6f..e85969ecada 100644 --- a/fineract-e2e-tests-runner/src/test/resources/features/WorkingCapitalDiscountAdjustmentBackdateUndo.feature +++ b/fineract-e2e-tests-runner/src/test/resources/features/WorkingCapitalDiscountAdjustmentBackdateUndo.feature @@ -178,7 +178,8 @@ Feature: Working Capital Discount Adjustment Backdated and Undo | LIABILITY | 240005 | Deferred Interest Revenue | 28.7 | | | INCOME | 404000 | Interest Income | | 28.7 | - Scenario: Full discount adjustment on a product without accounting posts an amortization adjustment with no journal entries; undo reverses both even when accounting is closed for the office + @TestRailId:C106704 + Scenario: Verify full discount adjustment on a product without accounting posts an amortization adjustment with no journal entries; undo reverses both even when accounting is closed for the office When Admin sets the business date to "01 January 2026" And Admin creates a new office And Admin creates a client with random data in the last created office @@ -510,3 +511,53 @@ Feature: Working Capital Discount Adjustment Backdated and Undo Then Admin successfully approves the working capital loan on "01 January 2026" with "100" amount and expected disbursement date on "01 January 2026" Then Admin successfully disburse the Working Capital loan on "01 January 2026" with "100" EUR transaction amount Then Undo discount fee adjustment with a non-existent transaction id on Working Capital loan account failed as not found with status code 400 + + @TestRailId:C106709 + Scenario: Verify undo of a repayment on a product without accounting succeeds when accounting is closed for the office + When Admin sets the business date to "01 January 2026" + And Admin creates a new office + And Admin creates a client with random data in the last created office + And Admin creates a working capital loan with the following data: + | LoanProduct | submittedOnDate | expectedDisbursementDate | principalAmount | totalPaymentVolume | periodPaymentRate | discount | + | WCLP | 01 January 2026 | 01 January 2026 | 9000 | 100000 | 18 | | + Then Working capital loan creation was successful + Then Admin successfully approves the working capital loan on "01 January 2026" with "9000" amount and expected disbursement date on "01 January 2026" + Then Admin successfully disburse the Working Capital loan on "01 January 2026" with "9000" EUR transaction amount + Then Admin successfully add discount with "1000" amount on Working Capital loan account + When Admin sets the business date to "02 January 2026" + And Customer makes repayment on "02 January 2026" with 50 transaction amount on Working Capital loan + Then Working Capital Loan Transactions tab has a "REPAYMENT" transaction with date "02 January 2026" which has the following Journal entries: + | Type | Account code | Account name | Debit | Credit | + When Admin closes accounting for the last created office on "02 January 2026" + When Customer undo "1"th working capital transaction made on "02 January 2026" + Then Working Capital Loan has transactions: + | transactionDate | type | transactionAmount | principalPortion | feeChargesPortion | penaltyChargesPortion | reversed | + | 01 January 2026 | Disbursement | 9000.0 | 9000.0 | 0.0 | 0.0 | false | + | 01 January 2026 | Discount Fee | 1000.0 | 1000.0 | 0.0 | 0.0 | false | + | 02 January 2026 | Repayment | 50.0 | 50.0 | 0.0 | 0.0 | true | + Then Working Capital Loan Transactions tab has a reversed "REPAYMENT" transaction with date "02 January 2026" which has the following Journal entries: + | Type | Account code | Account name | Debit | Credit | + Then Admin closes the Working Capital loan with a full repayment on "02 January 2026" + + @TestRailId:C106709 + Scenario: Verify undo disbursal on a product without accounting succeeds when accounting is closed for the office + When Admin sets the business date to "01 January 2026" + And Admin creates a new office + And Admin creates a client with random data in the last created office + And Admin creates a working capital loan with the following data: + | LoanProduct | submittedOnDate | expectedDisbursementDate | principalAmount | totalPaymentVolume | periodPaymentRate | discount | + | WCLP | 01 January 2026 | 01 January 2026 | 9000 | 100000 | 18 | | + Then Working capital loan creation was successful + Then Admin successfully approves the working capital loan on "01 January 2026" with "9000" amount and expected disbursement date on "01 January 2026" + Then Admin successfully disburse the Working Capital loan on "01 January 2026" with "9000" EUR transaction amount + Then Admin successfully add discount with "1000" amount on Working Capital loan account + When Admin closes accounting for the last created office on "01 January 2026" + When Admin successfully undo Working Capital disbursal + Then Working Capital Loan has transactions: + | transactionDate | type | transactionAmount | principalPortion | feeChargesPortion | penaltyChargesPortion | reversed | + | 01 January 2026 | Disbursement | 9000.0 | 9000.0 | 0.0 | 0.0 | true | + | 01 January 2026 | Discount Fee | 1000.0 | 1000.0 | 0.0 | 0.0 | true | + Then Working Capital Loan Transactions tab has a reversed "DISBURSEMENT" transaction with date "01 January 2026" which has the following Journal entries: + | Type | Account code | Account name | Debit | Credit | + Then Working Capital Loan Transactions tab has a reversed "DISCOUNT_FEE" transaction with date "01 January 2026" which has the following Journal entries: + | Type | Account code | Account name | Debit | Credit | diff --git a/fineract-e2e-tests-runner/src/test/resources/features/WorkingCapitalLoanChargeAccrual.feature b/fineract-e2e-tests-runner/src/test/resources/features/WorkingCapitalLoanChargeAccrual.feature index 0da061baa3b..16740fa30b9 100644 --- a/fineract-e2e-tests-runner/src/test/resources/features/WorkingCapitalLoanChargeAccrual.feature +++ b/fineract-e2e-tests-runner/src/test/resources/features/WorkingCapitalLoanChargeAccrual.feature @@ -517,6 +517,7 @@ Feature: Working Capital Loan Charge Accrual | 01 October 2026 | Disbursement | 9000.0 | 9000.0 | 0.0 | 0.0 | false | | 20 October 2026 | Repayment | 9080.0 | 9000.0 | 50.0 | 30.0 | false | + @TestRailId:C106705 Scenario: Verify no accrual or accrual adjustment is created for Working Capital loan charges in real time and on undo disbursal when product accounting rule is NONE Given Admin sets the business date to "01 May 2027" And Admin creates a client with random data and creates-approves-disburses a working capital loan with the following data: @@ -925,3 +926,67 @@ Feature: Working Capital Loan Charge Accrual # --- Refund remaining overpayment to close --- And Customer makes credit balance refund on "05 September 2028" with 60.0 transaction amount on Working Capital loan Then Working Capital loan status will be "CLOSED_OBLIGATIONS_MET" + + @TestRailId:C106707 + Scenario: Verify no accrual is created via the closure path when a charge is added to an overpaid Working Capital loan under real-time and submitted-date when product accounting rule is NONE + Given Admin sets the business date to "01 September 2028" + And Admin creates a client with random data and creates-approves-disburses a working capital loan with the following data: + | LoanProduct | submittedOnDate | expectedDisbursementDate | principalAmount | totalPayment | periodPaymentRate | discount | + | WCLP | 01 September 2028 | 01 September 2028 | 9000 | 100000 | 18 | 0 | + When Global config "charge-accrual-date" value set to "submitted-date" + When Global config "wcl-charge-accrual-time" value set to "real-time" + And Admin sets the business date to "05 September 2028" + And Admin runs inline COB job for Working Capital Loan by loanId + And Customer makes repayment on "05 September 2028" with 9100.0 transaction amount on Working Capital loan + Then Working Capital loan status will be "OVERPAID" + And Admin adds "WORKING_CAPITAL_SPECIFIED_DUE_DATE_FEE" specified due date charge to working capital loan with "20 September 2028" due date and 40.0 transaction amount + Then Working Capital loan status will be "OVERPAID" + And Working Capital Loan has transactions: + | transactionDate | type | transactionAmount | principalPortion | feeChargesPortion | penaltyChargesPortion | reversed | + | 01 September 2028 | Disbursement | 9000.0 | 9000.0 | 0.0 | 0.0 | false | + | 05 September 2028 | Repayment | 9100.0 | 9000.0 | 40.0 | 0.0 | false | + And Working Capital Loan Transactions tab has a "REPAYMENT" transaction with date "05 September 2028" which has the following Journal entries: + | Type | Account code | Account name | Debit | Credit | + And Working Capital Loan charge balances has the following data: + | Fee Amount | Fee Outstanding | Fee Paid | Penalty Amount | Penalty Outstanding | Penalty Paid | + | 40.0 | 0.0 | 40.0 | 0.0 | 0.0 | 0.0 | + And Customer makes credit balance refund on "05 September 2028" with 60.0 transaction amount on Working Capital loan + Then Working Capital loan status will be "CLOSED_OBLIGATIONS_MET" + And Working Capital Loan has transactions: + | transactionDate | type | transactionAmount | principalPortion | feeChargesPortion | penaltyChargesPortion | reversed | + | 01 September 2028 | Disbursement | 9000.0 | 9000.0 | 0.0 | 0.0 | false | + | 05 September 2028 | Repayment | 9100.0 | 9000.0 | 40.0 | 0.0 | false | + | 05 September 2028 | Credit Balance Refund | 60.0 | 0.0 | 0.0 | 0.0 | false | + + @TestRailId:C106708 + Scenario: Verify undo disbursal with a live charge accrual is rejected when accounting is closed for the office on a product with accounting + When Admin sets the business date to "01 March 2026" + And Admin creates a new office + And Admin creates a client with random data in the last created office + And Admin creates a working capital loan with the following data: + | LoanProduct | submittedOnDate | expectedDisbursementDate | principalAmount | totalPaymentVolume | periodPaymentRate | discount | + | WCLP_ACC_DEF_REV_AM | 01 March 2026 | 01 March 2026 | 9000 | 100000 | 18 | | + Then Working capital loan creation was successful + Then Admin successfully approves the working capital loan on "01 March 2026" with "9000" amount and expected disbursement date on "01 March 2026" + Then Admin successfully disburse the Working Capital loan on "01 March 2026" with "9000" EUR transaction amount + When Global config "charge-accrual-date" value set to "submitted-date" + When Global config "wcl-charge-accrual-time" value set to "real-time" + And Admin sets the business date to "10 March 2026" + And Admin adds "WORKING_CAPITAL_SPECIFIED_DUE_DATE_FEE" specified due date charge to working capital loan with "20 March 2026" due date and 100.0 transaction amount + Then Working Capital Loan has transactions: + | transactionDate | type | transactionAmount | principalPortion | feeChargesPortion | penaltyChargesPortion | reversed | + | 01 March 2026 | Disbursement | 9000.0 | 9000.0 | 0.0 | 0.0 | false | + | 10 March 2026 | Accrual | 100.0 | 0.0 | 100.0 | 0.0 | false | + When Admin closes accounting for the last created office on "10 March 2026" + Then Undo Working Capital disbursal results an error with the following data: + | httpCode | message | + | 403 | Journal entry cannot be made prior to last account closing date for the branch | + Then Working Capital loan status will be "ACTIVE" + And Working Capital Loan has transactions: + | transactionDate | type | transactionAmount | principalPortion | feeChargesPortion | penaltyChargesPortion | reversed | + | 01 March 2026 | Disbursement | 9000.0 | 9000.0 | 0.0 | 0.0 | false | + | 10 March 2026 | Accrual | 100.0 | 0.0 | 100.0 | 0.0 | false | + And Working Capital Loan Transactions tab has a "ACCRUAL" transaction with date "10 March 2026" which has the following Journal entries: + | Type | Account code | Account name | Debit | Credit | + | ASSET | 112603 | Interest/Fee Receivable | 100.0 | | + | INCOME | 404007 | Fee Income | | 100.0 | diff --git a/fineract-e2e-tests-runner/src/test/resources/features/WorkingCapitalLoanChargeOffAccounting.feature b/fineract-e2e-tests-runner/src/test/resources/features/WorkingCapitalLoanChargeOffAccounting.feature index 5fde9137d69..91b2a059118 100644 --- a/fineract-e2e-tests-runner/src/test/resources/features/WorkingCapitalLoanChargeOffAccounting.feature +++ b/fineract-e2e-tests-runner/src/test/resources/features/WorkingCapitalLoanChargeOffAccounting.feature @@ -771,6 +771,7 @@ Feature: Working Capital Charge-Off Accounting Entries | Type | Account code | Account name | Debit | Credit | Then Admin closes the Working Capital loan with all obligations met with a full repayment on "10 January 2026" + @TestRailId:C106706 Scenario: Verify Working Capital charge-off on a product without accounting posts the final discount fee amortization with no journal entries Given Admin sets the business date to "01 January 2026" And Admin creates a client with random data and creates-approves-disburses a working capital loan with the following data: