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


##########
fineract-provider/src/main/java/org/apache/fineract/portfolio/delinquency/service/DelinquencyWritePlatformServiceImpl.java:
##########
@@ -242,37 +276,89 @@ public int compare(DelinquencyRange o1, DelinquencyRange 
o2) {
         }
     }
 
-    private boolean isOverlaped(DelinquencyRange o1, DelinquencyRange o2) {
-        return Math.max(o1.getMinimumAgeDays(), o2.getMinimumAgeDays()) <= 
Math.min(o1.getMaximumAgeDays(), o2.getMaximumAgeDays());
+    private boolean isOverlapped(DelinquencyRange o1, DelinquencyRange o2) {
+        if (o2.getMaximumAgeDays() != null) { // Max Age undefined - Last one
+            return Math.max(o1.getMinimumAgeDays(), o2.getMinimumAgeDays()) <= 
Math.min(o1.getMaximumAgeDays(), o2.getMaximumAgeDays());
+        } else {
+            return Math.max(o1.getMinimumAgeDays(), o2.getMinimumAgeDays()) <= 
Math.min(o1.getMaximumAgeDays(), o2.getMinimumAgeDays());
+        }
+    }
+
+    private Map<String, Object> lookUpDelinquencyRange(final Loan loan, final 
DelinquencyBucket delinquencyBucket, long ageDays) {
+        Map<String, Object> changes = new HashMap<>();
+
+        if (ageDays <= 0) { // No Delinquency
+            log.info("Loan {} without delinquency range with {} days", 
loan.getId(), ageDays);
+            changes = setLoanDelinquencyTag(loan, null);
+
+        } else {
+            for (DelinquencyRange delinquencyRange : 
delinquencyBucket.getRanges()) {
+                if (delinquencyRange.getMaximumAgeDays() == null) {
+                    if (delinquencyRange.getMinimumAgeDays() <= ageDays) {
+                        log.info("Loan {} with delinquency range {} with {} 
days", loan.getId(), delinquencyRange.getClassification(),
+                                ageDays);
+                        changes = setLoanDelinquencyTag(loan, 
delinquencyRange.getId());
+                        break;

Review Comment:
   I've updated that, but honestly I don't think that it can add some value, 
because the range are not overlapped, the break is more to avoid the range 
validation of the rest ranges once time that you have find the right range



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