Repository navigation
FINERACT-2455: WC - Undo disbursal reverses the discount fee and amortization journal entries - #6457
Conversation
198d6a0 to
2638919
Compare
ba48f33 to
24eef2c
Compare
galovics
left a comment
There was a problem hiding this comment.
The core fix looks right. reverseDisbursementTransactionAndResetBalance now reverses the live journal entries of every transaction it reverses (disbursement, discount fee, discount fee adjustment, amortization, amortization adjustment, accruals) instead of only the disbursement and accruals. It's safe over previously undone transactions because findJournalEntries filters on reversed=false, so nothing is double-mirrored, and skipping already-reversed transactions also fixes reversedOnDate/reversalExternalId being overwritten on ones undone earlier (C106725 covers it). Re-disbursal after undo starts clean. A few things I'd want before merge:
- The gate moved into the processor with no unit test.
isAccountingDisabledactually checks "the rule is not ACC_DEF_REV_AM", which is the same as "accounting disabled" only while this is the soleWorkingCapitalLoanAccountingProcessorimplementation. More importantly, this PR deletedverify(accountingProcessor, never()).postJournalEntries(...)fromWorkingCapitalLoanRecoveryPaymentWriteServiceTest- the only test of the "no accounting, no JEs" path - and nothing replaced it. Please add a unit test in the processor test with a non-accrual rule asserting nothing is posted; every caller depends on this gate now. And the guard move is only half done: the amortization service, the transaction processor, credit balance refund and the accrual service still check at the call site, so pick one layer or document the processor check as a safety net. It's also scope creep - the fix is ~5 lines, the refactor touches charge-off, write-off, recovery, reprocessing and amortization; I'd split it. peekfor side effects (WorkingCapitalLoanWritePlatformServiceImpl~L1302): mutation insideStream.peek(Sonar S3864), with trailing comments the formatter wrapped into a broken fragment. A plain loop reads better. The comment below it ("Reverse the journal entries of any charge accrual...") is now stale - that block only publishes the accrual adjustment events.- No reversal events for the reversed DISCOUNT_FEE / DISCOUNT_FEE_ADJUSTMENT / amortization transactions (only accruals get one), unlike
reverseLiveCorrectionsin the amortization service. Pre-existing, but this is the place to fix it, or ticket it. - Test gaps: C106721-C106725 assert journal entries after undo, which is the right level, but the scenario named for the "amortization adjustment journal entries" only asserts the reversed
DISCOUNT_FEE_ADJUSTMENTentries - that's the path where #6281 had the asymmetry, so assert the amortization adjustment entries too. Also no scenario re-disburses after an undo with a discount fee, and no unit test for the undo loop itself.
Housekeeping: squash the two commits, and drop the duplicate loan.getLoanProduct() stub in the processor test.
Recommendation: COMMENT
24eef2c to
1640f73
Compare
…tization journal entries Co-authored-by: Adam Saghy <adamsaghy@gmail.com>
…rsal reverses the discount fee and amortization journal entries Co-authored-by: Adam Saghy <adamsaghy@gmail.com>
1640f73 to
edd88a0
Compare
edd88a0 to
d05cd7a
Compare
d05cd7a to
edd88a0
Compare
depends on #6458
Description
Describe the changes made and why they were made. (Ignore if these details are present on the associated Apache Fineract JIRA ticket.)
Checklist
Please make sure these boxes are checked before submitting your pull request - thanks!
Your assigned reviewer(s) will follow our guidelines for code reviews.