Skip to content

Commit

Permalink
Fix for FBR-104 (#219)
Browse files Browse the repository at this point in the history
  • Loading branch information
leonardohildt authored Oct 12, 2023
1 parent 4c23bb7 commit 195a32f
Showing 1 changed file with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
import java.time.MonthDay;
import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap;
Expand Down Expand Up @@ -832,6 +834,10 @@ public Pair<Integer, BigDecimal> getAddOnDisbursementChargeRate(LocalDate disbur
int defaultDays = LoanProductConstants.DEFAULT_LIMIT_OF_DAYS_FOR_ADDON;
int daysAddOnApplicable = 0;

// Sort the list by the minDay attribute
final Comparator<ChargeRange> orderByMinDay = Comparator.comparing(ChargeRange::getMinDay);
Collections.sort(this.chargeRanges, orderByMinDay);

if (isDisbursementCharge() && isAddOnDisbursementType() && this.chargeRanges != null && !this.chargeRanges.isEmpty()) {
// calculate days since disbursement date
int numberOfDays = Math.toIntExact(daysBetween(disbursementDate, firstRepaymentDate));
Expand All @@ -843,6 +849,10 @@ public Pair<Integer, BigDecimal> getAddOnDisbursementChargeRate(LocalDate disbur
&& (chargeRange.getMaxDay() != null && daysAddOnApplicable <= chargeRange.getMaxDay())) {
addOnDisbursementChargeRate = chargeRange.getFeeRate();
break;
} else if (chargeRange.getMinDay() != null && daysAddOnApplicable >= chargeRange.getMinDay()
&& (chargeRange.getMaxDay() == null)) {
addOnDisbursementChargeRate = chargeRange.getFeeRate();
break;
}
}
}
Expand Down

0 comments on commit 195a32f

Please sign in to comment.