AshharAhmadKhan opened a new pull request, #6144: URL: https://github.com/apache/fineract/pull/6144
## JIRA https://issues.apache.org/jira/browse/FINERACT-2615 ## Problem `AccountTransfersWritePlatformServiceImpl.undoTransfer(...)` did not support **Loan-to-Savings** transfers and immediately threw an `UnsupportedOperationException`. 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: - Undoes the savings-side deposit through `SavingsAccountWritePlatformService.undoTransaction(...)`. - Reverses the loan-side refund through `LoanAccountDomainService.reverseTransfer(...)`. - Marks the corresponding `AccountTransferTransaction` as reversed, ensuring repeated undo attempts are correctly rejected with `error.msg.account.transfer.already.reversed`. ## Why `reverseTransfer(...)` instead of `adjustLoanTransaction(...)`? 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 plain `REFUND`, so calling `adjustLoanTransaction(...)` results in an `InvalidLoanTransactionTypeException`. `LoanAccountDomainService.reverseTransfer(...)` is already used elsewhere in `AccountTransfersWritePlatformServiceImpl` (`undoTransactions()`, invoked by `reverseAllTransactions(...)` and `reverseTransfersWithFromAccountType(...)`) to reverse this exact type of transaction, making it the correct and consistent implementation here. ## Tests - Verified Loan-to-Savings transfers can now be successfully undone. - Verified both the loan and savings sides are correctly reversed. - Verified the `AccountTransferTransaction` is marked as reversed after undo. - Added a regression test confirming a second undo attempt is rejected with `error.msg.account.transfer.already.reversed`. -- 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]
