josehernandezfintecheandomx commented on code in PR #2668:
URL: https://github.com/apache/fineract/pull/2668#discussion_r1005795645


##########
fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanAccountDomainServiceJpa.java:
##########
@@ -541,13 +542,16 @@ public void recalculateAccruals(Loan loan) {
 
     @Override
     public void setLoanDelinquencyTag(final Loan loan, final LocalDate 
transactionDate) {
-        // Revalidate the Delinquency Classification
-        final Long ageOfOverdueDays = 
loan.getAgeOfOverdueDays(transactionDate);
-        log.debug("Loan {} with {} days and current classification {}", 
loan.getId(), ageOfOverdueDays);
-        if (ageOfOverdueDays > 0L) { // If loan is overdue
-            
this.delinquencyWritePlatformService.applyDelinquencyTagToLoan(loan, 
ageOfOverdueDays);
+        LoanScheduleDelinquencyData loanDelinquencyData = new 
LoanScheduleDelinquencyData(loan.getId(), loan.getLoanProduct().getId(),
+                transactionDate, null, loan);
+        loanDelinquencyData = 
this.delinquencyWritePlatformService.calculateDelinquencyData(loanDelinquencyData);
+        log.debug("Processing Loan {} with {} overdue days since date {}", 
loanDelinquencyData.getLoanId(),
+                loanDelinquencyData.getOverdueDays(), 
loanDelinquencyData.getOverdueSinceDate());
+        // Set or Unset the Delinquency Classification Tag
+        if (loanDelinquencyData.getOverdueDays() > 0) {
+            
this.delinquencyWritePlatformService.applyDelinquencyTagToLoan(loanDelinquencyData.getLoan(),
 transactionDate);
         } else {
-            
this.delinquencyWritePlatformService.removeDelinquencyTagToLoan(loan);
+            
this.delinquencyWritePlatformService.removeDelinquencyTagToLoan(loanDelinquencyData.getLoan());

Review Comment:
   The Loan is passed in the loanDelinquencyData, so we don't need to load and 
reload the Loan in different parts



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