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


##########
fineract-loan/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/transactionprocessor/AbstractLoanRepaymentScheduleTransactionProcessor.java:
##########
@@ -546,12 +547,21 @@ private List<LoanTransaction> 
getMergedTransactionList(List<LoanTransaction> tra
     protected void createNewTransaction(LoanTransaction loanTransaction, 
LoanTransaction newLoanTransaction,
             ChangedTransactionDetail changedTransactionDetail) {
         
loanChargeValidator.validateRepaymentTypeTransactionNotBeforeAChargeRefund(loanTransaction.getLoan(),
 loanTransaction, "reversed");
+
+        // Save external ID before clearing it to check if this was a 
user-initiated transaction
+        ExternalId originalExternalId = loanTransaction.getExternalId();
+
         loanTransaction.reverse();
         loanTransaction.updateExternalId(null);
         
newLoanTransaction.copyLoanTransactionRelations(loanTransaction.getLoanTransactionRelations());
-        // Adding Replayed relation from newly created transaction to reversed 
transaction
-        newLoanTransaction.getLoanTransactionRelations().add(
-                LoanTransactionRelation.linkToTransaction(newLoanTransaction, 
loanTransaction, LoanTransactionRelationTypeEnum.REPLAYED));
+
+        // Create REPLAYED relation for user-initiated transactions (those 
with external IDs)
+        // This distinguishes legitimate business operations from internal 
processing artifacts
+        if (originalExternalId != null) {

Review Comment:
   external id has not much to do whether it is business operation or internal 
processing... not necessarily enabled external id for loan 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