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


##########
fineract-loan/src/main/java/org/apache/fineract/portfolio/delinquency/helper/DelinquencyEffectivePauseHelperImpl.java:
##########
@@ -93,11 +93,17 @@ public Long 
getPausedDaysWithinRange(List<LoanDelinquencyActionData> effectiveDe
     private Optional<LoanDelinquencyAction> 
findMatchingResume(LoanDelinquencyAction pause, List<LoanDelinquencyAction> 
resumes) {
         if (resumes != null && !resumes.isEmpty()) {
             for (LoanDelinquencyAction resume : resumes) {
-                if (!pause.getStartDate().isAfter(resume.getStartDate()) && 
!resume.getStartDate().isAfter(pause.getEndDate())) {
+                if (isCreatedBefore(pause, resume) && 
!pause.getStartDate().isAfter(resume.getStartDate())
+                        && !resume.getStartDate().isAfter(pause.getEndDate())) 
{
                     return Optional.of(resume);
                 }
             }
         }
         return Optional.empty();
     }
+
+    // Without ids the creation order is unknown, so the resume applies to any 
pause containing its date.
+    private boolean isCreatedBefore(LoanDelinquencyAction pause, 
LoanDelinquencyAction resume) {

Review Comment:
   Nit: in production every action passed here comes from 
`findByLoanOrderById`, so ids are never null. The null fallback only exists for 
test fixtures built without ids. Could we give those fixtures ids and simplify 
this to `pause.getId() < resume.getId()`? Then production code doesn't carry a 
branch just for the tests.



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