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


##########
fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/reaging/LoanReAgingServiceImpl.java:
##########
@@ -95,16 +95,24 @@ public CommandProcessingResult reAge(Long loanId, 
JsonCommand command) {
         LoanReAgeParameter reAgeParameter = 
createReAgeParameter(reAgeTransaction, command);
         reAgeTransaction.setLoanReAgeParameter(reAgeParameter);
         loanTransactionRepository.saveAndFlush(reAgeTransaction);
-
-        if 
(reAgeTransaction.getTransactionDate().isBefore(reAgeTransaction.getSubmittedOnDate()))
 {
+        loan.addLoanTransaction(reAgeTransaction);
+        final LoanRepaymentScheduleTransactionProcessor 
loanRepaymentScheduleTransactionProcessor = 
loanRepaymentScheduleTransactionProcessorFactory
+                .determineProcessor(loan.transactionProcessingStrategy());
+        if 
(reAgeTransaction.getTransactionDate().isBefore(reAgeTransaction.getSubmittedOnDate())
+                && !loan.isInterestBearingAndInterestRecalculationEnabled()) {
             
reprocessLoanTransactionsService.reprocessTransactionsWithPostTransactionChecks(loan,
 reAgeTransaction.getTransactionDate());
+        } else if (loan.isInterestBearingAndInterestRecalculationEnabled()) {
+            if (loan.isProgressiveSchedule() && 
((loan.hasChargeOffTransaction() && loan.hasAccelerateChargeOffStrategy())
+                    || loan.hasContractTerminationTransaction()
+                    || (loan.isInterestRecalculationEnabled() && 
loan.hasReAgingTransaction()))) {
+                final ScheduleGeneratorDTO scheduleGeneratorDTO = 
loanUtilService.buildScheduleGeneratorDTO(loan, null);
+                loanScheduleService.regenerateRepaymentSchedule(loan, 
scheduleGeneratorDTO);
+            }
+            reprocessLoanTransactionsService.reprocessTransactions(loan);

Review Comment:
   I dont think we should add reage txn to the loan before the reprocessing, 
hence it might be flushed during the 
`loanUtilService.buildScheduleGeneratorDTO` or 
`loanScheduleService.regenerateRepaymentSchedule` and in that case, it will be 
immediately reverse-replayed. 
   
   I would rather provide transaction list to the 
`reprocessLoanTransactionsService.reprocessTransactions` and only after it was 
reprocessed to be added to the loan (if needed)



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