FINERACT-2615: Support undoing of Account transfer from Loan account to Savings account#6144
Open
AshharAhmadKhan wants to merge 1 commit into
Conversation
…to Savings account Implements undo for Loan-to-Savings account transfers, which previously threw UnsupportedOperationException. Reverses the savings deposit via SavingsAccountWritePlatformService.undoTransaction and reverses the loan refund transaction via LoanAccountDomainService.reverseTransfer, then marks the AccountTransferTransaction as reversed so repeated undo attempts are correctly rejected. Adds unit test coverage for the new undo branch and an e2e scenario (TestRailId C80938) mirroring the existing Savings-to-Loan undo test.
AshharAhmadKhan
force-pushed
the
FINERACT-2615-undo-loan-to-savings-transfer
branch
from
July 17, 2026 17:23
c20fbd3 to
bf761a3
Compare
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.
JIRA
https://issues.apache.org/jira/browse/FINERACT-2615
Problem
AccountTransfersWritePlatformServiceImpl.undoTransfer(...)did not support Loan-to-Savings transfers and immediately threw anUnsupportedOperationException.As a result, users could successfully perform transfers such as loan refunds from a loan account to a savings account, but attempting to undo the transfer failed. Both the loan and savings accounts remained affected because the transfer could not be reversed.
Fix
Added undo support for Loan-to-Savings transfers.
The implementation now reverses both sides of the transfer:
SavingsAccountWritePlatformService.undoTransaction(...).LoanAccountDomainService.reverseTransfer(...).AccountTransferTransactionas reversed, ensuring repeated undo attempts are correctly rejected witherror.msg.account.transfer.already.reversed.Why
reverseTransfer(...)instead ofadjustLoanTransaction(...)?An earlier implementation (#5877) attempted to mirror the existing Savings-to-Loan undo path by calling
LoanAdjustmentService.adjustLoanTransaction(...).That approach cannot handle Loan-to-Savings transfers because
adjustLoanTransaction(...)only permits repayment-like transaction types (REPAYMENT,DOWN_PAYMENT,MERCHANT_ISSUED_REFUND, etc.). The loan-side transaction created by a Loan-to-Savings transfer is a plainREFUND, so callingadjustLoanTransaction(...)results in anInvalidLoanTransactionTypeException.LoanAccountDomainService.reverseTransfer(...)is already used elsewhere inAccountTransfersWritePlatformServiceImpl(undoTransactions(), invoked byreverseAllTransactions(...)andreverseTransfersWithFromAccountType(...)) to reverse this exact type of transaction, making it the correct and consistent implementation here.Tests
AccountTransferTransactionis marked as reversed after undo.error.msg.account.transfer.already.reversed.