Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import static java.util.Arrays.asList;
import static org.assertj.core.api.Assertions.assertThat;

import io.cucumber.java.After;
import io.cucumber.java.en.Given;
import io.cucumber.java.en.When;
import java.util.Collections;
Expand All @@ -42,6 +43,12 @@ public class GlobalConfigurationStepDef {
@Autowired
private FineractFeignClient fineractClient;

// restore the default even when a scenario fails mid-way, so the submitted-date setting cannot leak
@After("@WorkingCapitalLoanChargeAccrualFeature")
public void restoreChargeAccrualDateConfig() {
globalConfigurationHelper.setGlobalConfigValueString("charge-accrual-date", "due-date");
}

@Given("Global configuration {string} is disabled")
public void disableGlobalConfiguration(String configKey) {
globalConfigurationHelper.disableGlobalConfiguration(configKey, 0L);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@SerialChargeAccrualConfig
@LoanFeature
Feature: Loan - Part2

Expand Down Expand Up @@ -2577,5 +2578,4 @@ Feature: Loan - Part2
| Name | isPenalty | Payment due at | Due as of | Calculation type | Due | Paid | Waived | Outstanding |
| NSF fee | true | Specified due date | 17 October 2023 | Flat | 20.0 | 20.0 | 0.0 | 0.0 |
| NSF fee | true | Specified due date | 16 October 2023 | Flat | 20.0 | 20.0 | 0.0 | 0.0 |
| NSF fee | true | Specified due date | 17 September 2023 | Flat | 20.0 | 20.0 | 0.0 | 0.0 |

| NSF fee | true | Specified due date | 17 September 2023 | Flat | 20.0 | 20.0 | 0.0 | 0.0 |
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@SerialChargeAccrualConfig
@LoanAccrualActivityFeature
Feature: LoanAccrualActivity - Part1

Expand Down Expand Up @@ -5466,5 +5467,4 @@ Feature: LoanAccrualActivity - Part1
| 10 March 2025 | Accrual | 0.02 | 0.0 | 0.02 | 0.0 | 0.0 | 0.0 | false | false |
| 25 March 2025 | Accrual Activity | 0.44 | 0.0 | 0.44 | 0.0 | 0.0 | 0.0 | false | true |
And "Accrual Activity" transaction on "25 March 2025" got reverse-replayed on "28 March 2025"
And External ID of replayed "Accrual Activity" on "25 March 2025" is matching with "saved-external-id"

And External ID of replayed "Accrual Activity" on "25 March 2025" is matching with "saved-external-id"
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@SerialChargeAccrualConfig
@LoanAccrualFeature
Feature: LoanAccrualTransaction

Expand Down Expand Up @@ -1993,3 +1994,21 @@ Feature: LoanAccrualTransaction
| 18 November 2025 | Accrual Activity | 10.0 | 0.0 | 0.0 | 10.0 | 0.0 | 0.0 |
Then LoanAccrualTransactionCreatedBusinessEvent is raised on "17 November 2025"
Then LoanTransactionAccrualActivityPostBusinessEvent is raised on "18 November 2025"

@TestRailId:C85643
Scenario: Core parity - accrual is posted on early loan closure even when charge-accrual-date is submitted-date
When Global config "charge-accrual-date" value set to "due-date"
When Admin sets the business date to "01 June 2023"
When Admin creates a client with random data
When Admin creates a new default Loan with date: "01 June 2023"
And Admin successfully approves the loan on "01 June 2023" with "1000" amount and expected disbursement date on "01 June 2023"
When Admin successfully disburse the loan on "01 June 2023" with "1000" EUR transaction amount
When Admin adds "LOAN_SNOOZE_FEE" due date charge with "20 June 2023" due date and 10 EUR transaction amount
When Global config "charge-accrual-date" value set to "submitted-date"
When Admin sets the business date to "05 June 2023"
And Customer makes "AUTOPAY" repayment on "05 June 2023" with 1010 EUR transaction amount
Then Loan status will be "CLOSED_OBLIGATIONS_MET"
Then Loan Transactions tab has a transaction with date: "05 June 2023", and with the following data:
| Transaction Type | Amount | Principal | Interest | Fees | Penalties | Loan Balance |
| Accrual | 10.0 | 0.0 | 0.0 | 10.0 | 0.0 | 0.0 |
When Global config "charge-accrual-date" value set to "due-date"
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@SerialChargeAccrualConfig
@Repayment
Feature: LoanRepayment - Part3

Expand Down Expand Up @@ -3506,5 +3507,4 @@ Feature: LoanRepayment - Part3
| Transaction date | Transaction Type | Amount | Principal | Interest | Fees | Penalties | Loan Balance | Reverted | Replayed |
| 26 October 2025 | Disbursement | 4.0 | 0.0 | 0.0 | 0.0 | 0.0 | 4.0 | false | false |
| 27 October 2025 | Repayment | 4.0 | 4.0 | 0.0 | 0.0 | 0.0 | 0.0 | false | false |
Then Loan is closed with zero outstanding balance and it's all installments have obligations met

Then Loan is closed with zero outstanding balance and it's all installments have obligations met
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
@SerialChargeAccrualConfig
@WorkingCapital
@WorkingCapitalGoodwillCreditPaymentAllocationFeature
Feature: Working Capital Goodwill Credit Payment Allocation

# Pin the charge accrual date to due-date so the scenarios do not depend on the global config value left behind by a
# previously executed feature. The transaction assertions below expect the charge accrual to be posted by the COB on
# the charge due date; a leaked submitted-date value would instead accrue at charge-add time and break them.
Background:
Given Global config "charge-accrual-date" value set to "due-date"

@TestRailId:C85511
Scenario: Verify Working Capital Goodwill Credit transaction with fee and penalty added with DUE_FEE_PENALTY_PRINCIPAL allocation - UC1
Given Admin sets the business date to "01 January 2026"
Expand Down Expand Up @@ -182,6 +189,8 @@ Feature: Working Capital Goodwill Credit Payment Allocation
| transactionDate | type | transactionAmount | principalPortion | feeChargesPortion | penaltyChargesPortion | reversed |
| 01 January 2026 | Disbursement | 9000.0 | 9000.0 | 0.0 | 0.0 | false |
| 12 January 2026 | Goodwill Credit | 9040.0 | 9000.0 | 15.0 | 25.0 | false |
| 12 January 2026 | Accrual | 15.0 | 0.0 | 15.0 | 0.0 | false |
| 12 January 2026 | Accrual | 25.0 | 0.0 | 0.0 | 25.0 | false |

@TestRailId:C85517
Scenario: Verify Working Capital Goodwill Credit transaction that overpays loan with following CBR trn and with fee and penalty added with DUE_PRINCIPAL_FEE_PENALTY allocation - UC7
Expand Down Expand Up @@ -210,6 +219,8 @@ Feature: Working Capital Goodwill Credit Payment Allocation
| transactionDate | type | transactionAmount | principalPortion | feeChargesPortion | penaltyChargesPortion | reversed |
| 01 January 2026 | Disbursement | 9000.0 | 9000.0 | 0.0 | 0.0 | false |
| 12 January 2026 | Goodwill Credit | 9200.0 | 9000.0 | 15.0 | 25.0 | false |
| 12 January 2026 | Accrual | 15.0 | 0.0 | 15.0 | 0.0 | false |
| 12 January 2026 | Accrual | 25.0 | 0.0 | 0.0 | 25.0 | false |
# --- make CBR trn to refund overpaid amount --- #
And Customer makes credit balance refund on "12 January 2026" with 160.0 transaction amount on Working Capital loan
And Working capital loan account has the correct data:
Expand All @@ -219,6 +230,8 @@ Feature: Working Capital Goodwill Credit Payment Allocation
| transactionDate | type | transactionAmount | principalPortion | feeChargesPortion | penaltyChargesPortion | reversed |
| 01 January 2026 | Disbursement | 9000.0 | 9000.0 | 0.0 | 0.0 | false |
| 12 January 2026 | Goodwill Credit | 9200.0 | 9000.0 | 15.0 | 25.0 | false |
| 12 January 2026 | Accrual | 15.0 | 0.0 | 15.0 | 0.0 | false |
| 12 January 2026 | Accrual | 25.0 | 0.0 | 0.0 | 25.0 | false |
| 12 January 2026 | Credit Balance Refund | 160.0 | 160.0 | 0.0 | 0.0 | false |

@TestRailId:C85518
Expand All @@ -239,6 +252,7 @@ Feature: Working Capital Goodwill Credit Payment Allocation
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 |
| 10 January 2026 | Accrual | 100.0 | 0.0 | 100.0 | 0.0 | false |
| 20 January 2026 | Goodwill Credit | 100.0 | 0.0 | 100.0 | 0.0 | false |
And Working Capital Loan has charges with the following data:
| Charge Name | Due Date | Amount | Currency | isPenalty | Charge Time Type | Charge Calculation Type | Charge Payment mode |
Expand All @@ -251,6 +265,7 @@ Feature: Working Capital Goodwill Credit Payment Allocation
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 |
| 10 January 2026 | Accrual | 100.0 | 0.0 | 100.0 | 0.0 | false |
| 10 January 2026 | Goodwill Credit | 100.0 | 0.0 | 100.0 | 0.0 | false |
| 20 January 2026 | Goodwill Credit | 100.0 | 100.0 | 0.0 | 0.0 | false |
And Working Capital Loan has charges with the following data:
Expand Down Expand Up @@ -282,6 +297,7 @@ Feature: Working Capital Goodwill Credit Payment Allocation
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 |
| 10 January 2026 | Accrual | 100.0 | 0.0 | 100.0 | 0.0 | false |
| 11 January 2026 | Goodwill Credit | 30.0 | 0.0 | 30.0 | 0.0 | false |
| 11 January 2026 | Charge Adjustment | 70.0 | 0.0 | 70.0 | 0.0 | false |
And Working Capital Loan has charges with the following data:
Expand Down Expand Up @@ -823,6 +839,8 @@ Feature: Working Capital Goodwill Credit Payment Allocation
| transactionDate | type | transactionAmount | principalPortion | feeChargesPortion | penaltyChargesPortion | reversed |
| 01 January 2026 | Disbursement | 9000.0 | 9000.0 | 0.0 | 0.0 | false |
| 12 January 2026 | Goodwill Credit | 9040.0 | 9000.0 | 15.0 | 25.0 | false |
| 12 January 2026 | Accrual | 15.0 | 0.0 | 15.0 | 0.0 | false |
| 12 January 2026 | Accrual | 25.0 | 0.0 | 0.0 | 25.0 | false |

@TestRailId:C85525
Scenario: Verify Working Capital Goodwill Credit paid in excess follows the GOODWILL_CREDIT specific payment allocation rule with following CBR transaction - UC15
Expand All @@ -847,6 +865,8 @@ Feature: Working Capital Goodwill Credit Payment Allocation
| transactionDate | type | transactionAmount | principalPortion | feeChargesPortion | penaltyChargesPortion | reversed |
| 01 January 2026 | Disbursement | 9000.0 | 9000.0 | 0.0 | 0.0 | false |
| 12 January 2026 | Goodwill Credit | 9200.0 | 9000.0 | 15.0 | 25.0 | false |
| 12 January 2026 | Accrual | 15.0 | 0.0 | 15.0 | 0.0 | false |
| 12 January 2026 | Accrual | 25.0 | 0.0 | 0.0 | 25.0 | false |
# --- make CBR transaction to refund overpaid amount --- #
And Customer makes credit balance refund on "12 January 2026" with 160.0 transaction amount on Working Capital loan
And Working capital loan account has the correct data:
Expand All @@ -856,6 +876,8 @@ Feature: Working Capital Goodwill Credit Payment Allocation
| transactionDate | type | transactionAmount | principalPortion | feeChargesPortion | penaltyChargesPortion | reversed |
| 01 January 2026 | Disbursement | 9000.0 | 9000.0 | 0.0 | 0.0 | false |
| 12 January 2026 | Goodwill Credit | 9200.0 | 9000.0 | 15.0 | 25.0 | false |
| 12 January 2026 | Accrual | 15.0 | 0.0 | 15.0 | 0.0 | false |
| 12 January 2026 | Accrual | 25.0 | 0.0 | 0.0 | 25.0 | false |
| 12 January 2026 | Credit Balance Refund | 160.0 | 160.0 | 0.0 | 0.0 | false |

@TestRailId:C85526
Expand Down Expand Up @@ -892,6 +914,8 @@ Feature: Working Capital Goodwill Credit Payment Allocation
| transactionDate | type | transactionAmount | principalPortion | feeChargesPortion | penaltyChargesPortion | reversed |
| 01 January 2026 | Disbursement | 9000.0 | 9000.0 | 0.0 | 0.0 | false |
| 12 January 2026 | Goodwill Credit | 100.0 | 100.0 | 0.0 | 0.0 | false |
| 12 January 2026 | Accrual | 15.0 | 0.0 | 15.0 | 0.0 | false |
| 12 January 2026 | Accrual | 25.0 | 0.0 | 0.0 | 25.0 | false |
| 13 January 2026 | Repayment | 40.0 | 0.0 | 15.0 | 25.0 | false |
When Admin sets the business date to "15 January 2026"
And Admin runs inline COB job for Working Capital Loan by loanId
Expand All @@ -913,12 +937,14 @@ Feature: Working Capital Goodwill Credit Payment Allocation
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 |
| 10 January 2026 | Accrual | 100.0 | 0.0 | 100.0 | 0.0 | false |
| 20 January 2026 | Repayment | 100.0 | 0.0 | 100.0 | 0.0 | false |
# --- backdated goodwill credit triggers reprocessing: goodwill keeps its own DUE_PRINCIPAL-first rule (principal 100), repayment keeps DUE_FEE-first (fee 100) --- #
And Customer makes "GOODWILL_CREDIT" transaction on "15 January 2026" with 100.0 transaction amount on 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 |
| 10 January 2026 | Accrual | 100.0 | 0.0 | 100.0 | 0.0 | false |
| 15 January 2026 | Goodwill Credit | 100.0 | 100.0 | 0.0 | 0.0 | false |
| 20 January 2026 | Repayment | 100.0 | 0.0 | 100.0 | 0.0 | false |
And Working capital loan account has the correct data:
Expand Down Expand Up @@ -951,13 +977,17 @@ Feature: Working Capital Goodwill Credit Payment Allocation
| transactionDate | type | transactionAmount | principalPortion | feeChargesPortion | penaltyChargesPortion | reversed |
| 01 January 2026 | Disbursement | 9000.0 | 9000.0 | 0.0 | 0.0 | false |
| 12 January 2026 | Goodwill Credit | 270.0 | 270.0 | 0.0 | 0.0 | false |
| 12 January 2026 | Accrual | 15.0 | 0.0 | 15.0 | 0.0 | false |
| 12 January 2026 | Accrual | 25.0 | 0.0 | 0.0 | 25.0 | false |
| 15 January 2026 | Repayment | 40.0 | 0.0 | 15.0 | 25.0 | false |
# --- undo the goodwill credit: the repayment is replayed with its own REPAYMENT (DUE_FEE first) rule and keeps its portions --- #
When Customer undo "1"th "GOODWILL_CREDIT" transaction made on "12 January 2026" on 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 |
| 12 January 2026 | Goodwill Credit | 270.0 | 270.0 | 0.0 | 0.0 | true |
| 12 January 2026 | Accrual | 15.0 | 0.0 | 15.0 | 0.0 | false |
| 12 January 2026 | Accrual | 25.0 | 0.0 | 0.0 | 25.0 | false |
| 15 January 2026 | Repayment | 40.0 | 0.0 | 15.0 | 25.0 | false |
And Working capital loan account has the correct data:
| principal | totalPaidPrincipal | totalPaymentVolume | realizedIncome | unrealizedIncome | overpaymentAmount |
Expand Down Expand Up @@ -991,3 +1021,5 @@ Feature: Working Capital Goodwill Credit Payment Allocation
| transactionDate | type | transactionAmount | principalPortion | feeChargesPortion | penaltyChargesPortion | reversed |
| 01 January 2026 | Disbursement | 9000.0 | 9000.0 | 0.0 | 0.0 | false |
| 15 January 2026 | Goodwill Credit | 9020.0 | 9000.0 | 15.0 | 5.0 | false |
| 15 January 2026 | Accrual | 15.0 | 0.0 | 15.0 | 0.0 | false |
| 15 January 2026 | Accrual | 25.0 | 0.0 | 0.0 | 25.0 | false |
Loading
Loading