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


##########
fineract-provider/src/main/java/org/apache/fineract/portfolio/delinquency/service/DelinquencyWritePlatformServiceImpl.java:
##########
@@ -134,8 +146,72 @@ public CommandProcessingResult 
deleteDelinquencyBucket(Long delinquencyBucketId,
                         "Data integrity issue with resource: " + 
delinquencyBucket.getId());
             }
             repositoryBucket.delete(delinquencyBucket);
+            return new 
CommandProcessingResultBuilder().withCommandId(command.commandId()).withEntityId(delinquencyBucket.getId()).build();
         }
-        return new 
CommandProcessingResultBuilder().withCommandId(command.commandId()).withEntityId(delinquencyBucket.getId()).build();
+        return new 
CommandProcessingResultBuilder().withCommandId(command.commandId()).withEntityId(delinquencyBucketId).build();
+    }
+
+    @Override
+    public LoanScheduleDelinquencyData 
calculateDelinquencyData(LoanScheduleDelinquencyData 
loanScheduleDelinquencyData) {
+        final LocalDate businessDate = DateUtils.getBusinessLocalDate();
+        Loan loan = loanScheduleDelinquencyData.getLoan();
+        if (loan == null) {
+            loan = 
this.loanRepository.findOneWithNotFoundDetection(loanScheduleDelinquencyData.getLoanId());
+        }
+
+        final Integer graceOnArrearAgeing = 
loan.getLoanProduct().getLoanProductRelatedDetail().getGraceOnArrearsAgeing();
+        final LocalDate overdueSinceDate = getOverdueSinceDate(loan, 
businessDate, graceOnArrearAgeing);
+        final Long overdueDays = calculateOverdueDays(businessDate, 
overdueSinceDate);
+        return new LoanScheduleDelinquencyData(loan.getId(), 
loan.getLoanProduct().getId(), overdueSinceDate, overdueDays, loan);
+    }
+
+    private LocalDate getOverdueSinceDate(final Loan loan, final LocalDate 
businessDate, final Integer graceOnArrearAgeing) {
+        final LoanRepaymentScheduleInstallment loanRepaymentSchedule = 
this.loanRepaymentScheduleInstallmentRepository

Review Comment:
   You can fetch the requested instalment by iterating through on the loan 
instalments, you do not need to go to DB to fetch it. Please amend this 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