Skip to content
Merged
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 @@ -4110,6 +4110,8 @@ private void assertBalanceFieldEquals(final String field, final String expected)
final GetBalance balance = retrieveLoanDetails(getCreatedLoanId()).getBalance();
assertNotNull(balance, "Balance payload should not be null");
final BigDecimal actual = switch (field) {
case "totalDiscountFee" -> balance.getTotalDiscountFee();
case "totalDiscountFeeAdjustment" -> balance.getTotalDiscountFeeAdjustment();
case "overpaymentAmount" -> balance.getOverpaymentAmount();
case "principalOutstanding" -> balance.getPrincipalOutstanding();
case "totalPaidPrincipal" -> balance.getPrincipalPaid();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -449,3 +449,64 @@ Feature: Working Capital Loan Charge-off
| 10 January 2026 | Repayment | 60.0 | 60.0 | 0.0 | 0.0 | false |
| 15 January 2026 | Charge-off | 60.0 | 60.0 | 0.0 | 0.0 | true |
Then Working Capital loan status will be "CLOSED_OBLIGATIONS_MET"

@TestRailId:C106729
Scenario: Verify Working Capital Charge-off transactions - Backdated discount fee adjustment on a re-charged-off loan should correct realized income
# Step 1: WC loan 9000 / total payment volume 100000 / rate 18, approve and disburse on 01 January 2026 with discount 1000.
When Admin sets the business date to "01 January 2026"
And Admin creates a client with random data
And Admin creates a working capital loan with the following data:
| LoanProduct | submittedOnDate | expectedDisbursementDate | principalAmount | totalPaymentVolume | periodPaymentRate | discount |
| WCLP_ADVANCED_ACCOUNTING | 01 January 2026 | 01 January 2026 | 9000 | 100000 | 18 | 1000 |
And Admin successfully approves the working capital loan on "01 January 2026" with "9000" amount and expected disbursement date on "01 January 2026"
And Admin successfully disburse the Working Capital loan on "01 January 2026" with "9000" EUR transaction amount and "1000" discount amount
And Admin loads discount fee transaction from Working Capital loan for adjustment

# Step 2: 02 January 2026 -> run COB for 01 January (no amortization); repayment 50.
And Admin sets the business date to "02 January 2026"
And Admin runs inline COB job for Working Capital Loan by loanId
When Customer makes "REPAYMENT" transaction on "02 January 2026" with 50.0 transaction amount on Working Capital loan

# Step 3: 04 January 2026 -> run COB (amortization 9.61); charge off (9950, final amortization 990.39 to charge-off expense).
And Admin sets the business date to "04 January 2026"
And Admin runs inline COB job for Working Capital Loan by loanId
When Admin charges off the Working Capital loan on "04 January 2026"

# Step 4: 05 January 2026 -> repayment 9950 dated 03 January 2026 (charge-off is lifted, loan CLOSED, amortization 990.39 posted to income, realized 1000.00).
And Admin sets the business date to "05 January 2026"
And Admin runs inline COB job for Working Capital Loan by loanId
When Customer makes "REPAYMENT" transaction on "03 January 2026" with 9950.0 transaction amount on Working Capital loan

# Step 5: Undo that repayment (loan ACTIVE, outstanding 9950, not charged off, realized still 1000.00).
When Customer undo "1"th "Repayment" transaction made on "03 January 2026" on Working Capital loan

# Step 6: Charge off again on 05 January 2026 (no final amortization, deferred income already 0).
When Admin charges off the Working Capital loan on "05 January 2026"

# Step 7: Discount fee adjustment 100 dated 03 January 2026 (before the charge-off date, accepted).
And Admin adds Discount fee adjustment with "100" amount on transaction date "03 January 2026" on Working Capital loan account for last discount

# Step 8: Run COB on the following days.
And Admin sets the business date to "06 January 2026"
And Admin runs inline COB job for Working Capital Loan by loanId

And Working Capital loan balance payload contains the following fields:
| field | value |
| totalDiscountFee | 1000.0 |
| totalDiscountFeeAdjustment | 100.0 |
| realizedIncome | 900.0 |
| unrealizedIncome | 0.0 |

# Step 9: Undo the Discount Fee adjustment
When Admin undo the Discount fee adjustment with "100.0" amount on Working Capital loan account

# Step 10: Run COB on the following days.
And Admin sets the business date to "07 January 2026"
And Admin runs inline COB job for Working Capital Loan by loanId

And Working Capital loan balance payload contains the following fields:
| field | value |
| totalDiscountFee | 1000.0 |
| totalDiscountFeeAdjustment | 0.0 |
| realizedIncome | 1000.0 |
| unrealizedIncome | 0.0 |
Original file line number Diff line number Diff line change
Expand Up @@ -2793,3 +2793,74 @@ Feature: Working Capital Charge-Off Accounting Entries
| principal | totalPaidPrincipal | realizedIncome | unrealizedIncome | overpaymentAmount | chargedOff |
| 9005.0 | 50.0 | 5.0 | 0.0 | 0.0 | true |
Then Admin closes the Working Capital loan with all obligations met with a full repayment on "04 February 2026"

@TestRailId:C106730
Scenario: Verify Working Capital charge-off accounting: backdated discount fee adjustment on a re-charged-off loan without a linked final amortization posts the correction to charge-off expense and undo restores it - UC57
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_ADVANCED_ACCOUNTING | 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 Customer makes repayment on "02 January 2026" with 50 transaction amount on Working Capital loan
And Admin sets the business date to "03 January 2026"
And Admin runs inline COB job for Working Capital Loan by loanId
# --- First charge-off: the unreleased discount 990.39 moves to charge-off expense --- #
When Admin sets the business date to "04 January 2026"
And Admin charges off the Working Capital loan on "04 January 2026"
And Working capital loan account has the correct data:
| principal | totalPaidPrincipal | realizedIncome | unrealizedIncome | overpaymentAmount | chargedOff |
| 10000.0 | 50.0 | 1000.0 | 0.0 | 0.0 | true |
# --- Backdated payoff lifts the charge-off and closes the loan; the whole discount is realized as income --- #
When Admin sets the business date to "05 January 2026"
And Customer makes repayment on "03 January 2026" with 9950 transaction amount on Working Capital loan
Then Working Capital loan status will be "CLOSED_OBLIGATIONS_MET"
And Working capital loan account has the correct data:
| principal | totalPaidPrincipal | realizedIncome | unrealizedIncome | overpaymentAmount | chargedOff |
| 10000.0 | 10000.0 | 1000.0 | 0.0 | 0.0 | false |
# --- Undo the payoff and charge off again: deferred income is already 0, so no final amortization is linked to this charge-off --- #
When Customer undo "1"th "Repayment" transaction made on "03 January 2026" on Working Capital loan
Then Working Capital loan status will be "ACTIVE"
And Admin charges off the Working Capital loan on "05 January 2026"
And Working capital loan account has the correct data:
| principal | totalPaidPrincipal | realizedIncome | unrealizedIncome | overpaymentAmount | chargedOff |
| 10000.0 | 50.0 | 1000.0 | 0.0 | 0.0 | true |
# --- Backdated discount fee adjustment: realized income must drop to the net discount even without a linked final amortization --- #
And Admin adds Discount fee adjustment with "100" amount on transaction date "03 January 2026" on Working Capital loan account for last discount
Then Working capital loan account has the correct data:
| principal | totalPaidPrincipal | realizedIncome | unrealizedIncome | overpaymentAmount | chargedOff |
| 9900.0 | 50.0 | 900.0 | 0.0 | 0.0 | true |
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 |
| EXPENSE | 744007 | Credit Loss/Bad Debt | 100.0 | |
| LIABILITY | 240005 | Deferred Interest Revenue | | 100.0 |
And 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 |
| 02 January 2026 | Discount Fee Amortization | 9.61 | | | | false |
| 03 January 2026 | Repayment | 9950.0 | 9950.0 | 0.0 | 0.0 | true |
| 03 January 2026 | Discount Fee Amortization | 990.39 | | | | false |
| 03 January 2026 | Discount Fee Adjustment | 100.0 | 100.0 | 0.0 | 0.0 | false |
| 04 January 2026 | Charge-off | 9950.0 | 9950.0 | 0.0 | 0.0 | true |
| 04 January 2026 | Discount Fee Amortization | 990.39 | | | | true |
| 05 January 2026 | Charge-off | 9850.0 | 9850.0 | 0.0 | 0.0 | false |
| 05 January 2026 | Discount Fee Amortization Adjustment | 100.0 | | | | false |
# --- Later COB runs change nothing on the charged-off loan --- #
When Admin sets the business date to "07 January 2026"
And Admin runs inline COB job for Working Capital Loan by loanId
And Working capital loan account has the correct data:
| principal | totalPaidPrincipal | realizedIncome | unrealizedIncome | overpaymentAmount | chargedOff |
| 9900.0 | 50.0 | 900.0 | 0.0 | 0.0 | true |
# --- Undo of the adjustment restores the previous state --- #
When Admin undo the Discount fee adjustment with "100.0" amount on Working Capital loan account
Then Working capital loan account has the correct data:
| principal | totalPaidPrincipal | realizedIncome | unrealizedIncome | overpaymentAmount | chargedOff |
| 10000.0 | 50.0 | 1000.0 | 0.0 | 0.0 | true |
Then Working Capital Loan Transactions tab has a reversed "DISCOUNT_FEE_AMORTIZATION_ADJUSTMENT" transaction with date "05 January 2026" which has the following Journal entries:
| Type | Account code | Account name | Debit | Credit |
| EXPENSE | 744007 | Credit Loss/Bad Debt | 100.0 | |
| LIABILITY | 240005 | Deferred Interest Revenue | | 100.0 |
| EXPENSE | 744007 | Credit Loss/Bad Debt | | 100.0 |
| LIABILITY | 240005 | Deferred Interest Revenue | 100.0 | |
Loading