samchinmaya opened a new pull request, #6736:
URL: https://github.com/apache/fineract/pull/6736

   ## Description
   
   Jira: [FINERACT-2994](https://issues.apache.org/jira/browse/FINERACT-2994)
   
   With accrual (periodic) accounting on a savings product, 
`SavingsAccount.deposit()` and `withdraw()` call `accrualsForSavingsReverse()`, 
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 by `accrualsForSavingsReverse()` 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). `undoTransaction` in 
`SavingsAccountWritePlatformServiceJpaRepositoryImpl` already 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; the `fineract-savings` domain 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:
   
   | Case | develop: payable after undo → after next job | this PR | expected |
   |---|---|---|---|
   | Deposit 5000, undo the deposit (balance 0) | 96.80 → 96.80 | 0.00 → 0.00 | 
0.00 |
   | Deposit 10000, withdraw 4000 on 01 Aug, undo the withdrawal | 136.53 → 
136.53 | 50.84 → 193.54 | 193.54 (account with the same 10000 and no 
withdrawal) |
   
   Savings control GL = account balance and balanced entries in every step, 
before and after.
   
   ## Checklist
   
   - [x] Write the commit message as per [our 
guidelines](https://github.com/apache/fineract/blob/develop/CONTRIBUTING.md#pull-requests)
   - [x] Acknowledge that we will not review PRs that are not passing the build 
_("green")_ - it is your responsibility to get a proposed PR to pass the build, 
not primarily the project's maintainers.
   - [x] Create/update [unit or integration 
tests](https://fineract.apache.org/docs/current/#_testing) for verifying the 
changes made.
   - [x] Follow our [coding 
conventions](https://cwiki.apache.org/confluence/display/FINERACT/Coding+Conventions).
   - [ ] Add required Swagger annotation and update API documentation at 
fineract-provider/src/main/resources/static/legacy-docs/apiLive.htm with 
details of any API changes (no API change)
   - [x] [This PR must not be a "code 
dump"](https://cwiki.apache.org/confluence/display/FINERACT/Pull+Request+Size+Limit).
 Large changes can be made in a branch, with assistance. Ask for help on the 
[developer mailing list](https://fineract.apache.org/#contribute).
   - [x] If merging this PR resolves a JIRA issue, I will mark that issue as 
resolved and set "Fix Version/s" appropriately.
   - [x] I followed the [AI 
Policy](https://github.com/apache/fineract/blob/develop/CONTRIBUTING.md#ai-policy).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to