Repository navigation
FINERACT-2994: Reverse savings accruals when a transaction is undone - #6736
Open
samchinmaya wants to merge 1 commit into
Open
samchinmaya wants to merge 1 commit into
samchinmaya wants to merge 1 commit into
Conversation
A new deposit or withdrawal reverses the accruals dated on or after it, so they are booked again from the new balance. Undoing a transaction did not, and the accrual job only adds accruals after the last one, so accruals on money that was no longer there stayed in Interest Payable and Interest Expense. The undo methods now reverse those accruals too. Assisted-By: claude-opus-5-5
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Jira: FINERACT-2994
With accrual (periodic) accounting on a savings product,
SavingsAccount.deposit()andwithdraw()callaccrualsForSavingsReverse(), which reverses the accruals dated on or after the new transaction so the accrual job books them again from the new balance. The undo methods (undoTransaction(Long),undoSavingsTransaction(Long),undoTransaction(SavingsAccountTransaction)) only reversed the transaction itself. The accrual job only adds accruals after the last one, so accruals on money that was no longer there stayed in Interest Payable and Interest Expense.This PR moves the reversal loop into
reverseAccrualsFrom(date, backdatedTxnsAllowedTill)(used byaccrualsForSavingsReverse()as before) and calls it from the three undo methods with the undone transaction's date (not when the undone transaction is itself an accrual).undoTransactioninSavingsAccountWritePlatformServiceJpaRepositoryImplalready collects the reversed transactions before and after and posts their journal entry reversals, so the reversed accruals get reversal entries.Tests: new
SavingsAccountUndoTransactionAccrualTest(2 tests): undoing a deposit reverses the accruals on and after its date and keeps the earlier one, with the normal and the pivot-date transaction lists. Both fail on the old code; thefineract-savingsdomain tests pass.Manual check on a jibBuildTar image of this branch vs
apache/fineract:0df2ef786f(develop), PostgreSQL. Savings product with accounting rule 3, 6% nominal annual interest; accounts activated 01 July 2026; "Add Accrual Transactions For Savings" run after each step:Savings control GL = account balance and balanced entries in every step, before and after.
Checklist