budaidev commented on code in PR #5845:
URL: https://github.com/apache/fineract/pull/5845#discussion_r3237064291


##########
fineract-provider/src/main/java/org/apache/fineract/portfolio/account/api/AccountTransfersApiResource.java:
##########
@@ -152,4 +153,18 @@ public CommandProcessingResult 
templateRefundByTransferPost(@Parameter(hidden =
                 
.withJson(toApiJsonSerializer.serialize(accountTransferRequest)).build();
         return 
commandsSourceWritePlatformService.logCommandSource(commandRequest);
     }
+
+    @DELETE

Review Comment:
   From REST perspective an undo operation is not exactly a deletion, but a 
reversal. So far we used undo command with POST query, I don't know how would 
this fit into the existing structure



##########
fineract-provider/src/main/java/org/apache/fineract/portfolio/account/service/AccountTransfersWritePlatformServiceImpl.java:
##########
@@ -493,6 +498,48 @@ public AccountTransferDetails 
repayLoanWithTopup(AccountTransferDTO accountTrans
         return accountTransferDetails;
     }
 
+    @Override
+    public CommandProcessingResult undo(JsonCommand command) {
+        AccountTransferDetails accountTransferDetails = 
accountTransferDetailRepository.findById(command.entityId())
+                .orElseThrow(() -> new 
AccountTransferNotFoundException(command.entityId()));
+
+        final PaymentDetail paymentDetail = null;
+
+        PortfolioAccountType fromAccountType = 
accountTransferDetails.fromLoanAccount() != null ? PortfolioAccountType.LOAN
+                : accountTransferDetails.fromSavingsAccount() != null ? 
PortfolioAccountType.SAVINGS : throwUnsupported();
+
+        PortfolioAccountType toAccountType = 
accountTransferDetails.toLoanAccount() != null ? PortfolioAccountType.LOAN
+                : accountTransferDetails.toSavingsAccount() != null ? 
PortfolioAccountType.SAVINGS : throwUnsupported();
+
+        if (isSavingsToSavingsAccountTransfer(fromAccountType, toAccountType)) 
{
+            throw new UnsupportedOperationException("Undo Savings to Savings 
Account Transfer is not implemented");
+        } else if (isSavingsToLoanAccountTransfer(fromAccountType, 
toAccountType)) {
+            
accountTransferDetails.getAccountTransferTransactions().forEach(transaction -> {

Review Comment:
   since the command structure is not idempotent by default, would it make 
sense to check if we already had an undo for these transactions? 



-- 
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