adamsaghy commented on code in PR #3269:
URL: https://github.com/apache/fineract/pull/3269#discussion_r1238591658


##########
fineract-investor/src/main/java/org/apache/fineract/investor/service/ExternalAssetOwnersWriteServiceImpl.java:
##########
@@ -150,6 +170,27 @@ private ExternalAssetOwnerTransfer 
fetchAndValidateEffectiveTransferForBuyback(f
         return effectiveTransfers.get(0);
     }
 
+    private ExternalAssetOwnerTransfer 
fetchAndValidateEffectiveTransferForCancel(final Long transferId) {
+        ExternalAssetOwnerTransfer selectedTransfer = 
externalAssetOwnerTransferRepository.findById(transferId)
+                .orElseThrow(() -> new 
ExternalAssetOwnerInitiateTransferException(
+                        String.format("This loan cannot be cancel, transfer 
with id %s does not exist", transferId)));
+
+        List<ExternalAssetOwnerTransfer> effective = 
externalAssetOwnerTransferRepository
+                .findEffectiveTransfers(selectedTransfer.getLoanId(), 
selectedTransfer.getSettlementDate());
+        if (effective.size() == 0) {
+            throw new ExternalAssetOwnerInitiateTransferException(
+                    String.format("This loan cannot be cancel, there is no 
effective transfer for this loan"));
+        } else if (!effective.get(0).getId().equals(selectedTransfer.getId())) 
{
+            throw new ExternalAssetOwnerInitiateTransferException(
+                    String.format("This loan cannot be cancel, selected 
transfer is not effective or not the latest"));

Review Comment:
   This loan cannot be cancel, selected transfer is not effective or not the 
latest. Since there was effective ones, it's only could be the latter one:
   This loan cannot be cancel, selected transfer is not effective or not the 
latest -> This loan cannot be cancelled, selected transfer is not the latest



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