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


##########
fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanWritePlatformServiceJpaRepositoryImpl.java:
##########
@@ -3061,9 +3063,19 @@ public void handleChargebackTransaction(final Loan loan, 
LoanTransaction chargeb
         loan.addLoanTransaction(chargebackTransaction);
         if (loan.isInterestBearing() && loan.isInterestRecalculationEnabled()) 
{
             final List<LoanTransaction> transactions = 
loanTransactionService.retrieveListOfTransactionsForReprocessing(loan);
-            
loanTransactionProcessingService.reprocessLoanTransactions(loan.getTransactionProcessingStrategyCode(),
-                    loan.getDisbursementDate(), transactions, 
loan.getCurrency(), loan.getRepaymentScheduleInstallments(),
-                    loan.getActiveCharges());
+            if 
(transactions.stream().filter(LoanTransaction::isNotReversed).filter(LoanTransaction::isReAge)
+                    .anyMatch(lt -> 
!lt.getTransactionDate().isAfter(lt.getLoan().getMaturityDate()))) {
+                final ScheduleGeneratorDTO scheduleGeneratorDTO = 
loanUtilService.buildScheduleGeneratorDTO(loan, null);
+                loanScheduleService.regenerateRepaymentSchedule(loan, 
scheduleGeneratorDTO);
+            }
+            ChangedTransactionDetail changedTransactionDetail = 
loanTransactionProcessingService.reprocessLoanTransactions(
+                    loan.getTransactionProcessingStrategyCode(), 
loan.getDisbursementDate(), transactions, loan.getCurrency(),
+                    loan.getRepaymentScheduleInstallments(), 
loan.getActiveCharges());
+            // todo check code if we can simplify it
+            if (changedTransactionDetail.getTransactionChanges() != null && 
!changedTransactionDetail.getTransactionChanges().isEmpty()) {
+                
changedTransactionDetail.getTransactionChanges().stream().filter(change -> 
change.getNewTransaction() != null)
+                        
.map(TransactionChangeData::getNewTransaction).forEach(loan::addLoanTransaction);
+            }

Review Comment:
   Why do we need all these logic?



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