Determine base lending rate correctly based on the order of rate periods
This commit is contained in:
+4
-2
@@ -29,10 +29,12 @@ public class FloatingRateDTO {
|
|||||||
public BigDecimal fetchBaseRate(LocalDate date) {
|
public BigDecimal fetchBaseRate(LocalDate date) {
|
||||||
BigDecimal rate = null;
|
BigDecimal rate = null;
|
||||||
for (FloatingRatePeriodData periodData : this.baseLendingRatePeriods) {
|
for (FloatingRatePeriodData periodData : this.baseLendingRatePeriods) {
|
||||||
if (date.isBefore(new LocalDate(periodData.getFromDate()))) {
|
final LocalDate periodFromDate = new LocalDate(periodData.getFromDate());
|
||||||
|
if (periodFromDate.isBefore(date)
|
||||||
|
|| periodFromDate.isEqual(date)) {
|
||||||
|
rate = periodData.getInterestRate();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
rate = periodData.getInterestRate();
|
|
||||||
}
|
}
|
||||||
return rate;
|
return rate;
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -139,7 +139,7 @@ public class FloatingRatesReadPlatformServiceImpl implements
|
|||||||
final String sql = "select "
|
final String sql = "select "
|
||||||
+ ratePeriodMapper.schema()
|
+ ratePeriodMapper.schema()
|
||||||
+ " where period.is_active = 1 and period.floating_rates_id = ? "
|
+ " where period.is_active = 1 and period.floating_rates_id = ? "
|
||||||
+ " order by period.from_date ";
|
+ " order by period.from_date desc ";
|
||||||
ratePeriods = jdbcTemplate.query(sql, ratePeriodMapper,
|
ratePeriods = jdbcTemplate.query(sql, ratePeriodMapper,
|
||||||
new Object[] { id });
|
new Object[] { id });
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -62,8 +62,8 @@ public class LoanTermVariationsData implements Comparable<LoanTermVariationsData
|
|||||||
return occursOnDayFromAndUpTo(fromDate, dueDate, this.termVariationApplicableFrom);
|
return occursOnDayFromAndUpTo(fromDate, dueDate, this.termVariationApplicableFrom);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean occursOnDayFromAndUpTo(final LocalDate fromInclusive, final LocalDate upToNotInclusive, final LocalDate target) {
|
private boolean occursOnDayFromAndUpTo(final LocalDate fromNotInclusive, final LocalDate upToInclusive, final LocalDate target) {
|
||||||
return target != null && !target.isBefore(fromInclusive) && target.isBefore(upToNotInclusive);
|
return target != null && target.isAfter(fromNotInclusive) && !target.isAfter(upToInclusive);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isApplicable(final LocalDate fromDate) {
|
public boolean isApplicable(final LocalDate fromDate) {
|
||||||
|
|||||||
+1
-1
@@ -2582,7 +2582,7 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
LoanTermVariationsData loanTermVariation = new LoanTermVariationsData(
|
LoanTermVariationsData loanTermVariation = new LoanTermVariationsData(
|
||||||
LoanEnumerations.loanvariationType(LoanTermVariationType.INTEREST_RATE), periodData.getFromDateAsLocalDate(),
|
LoanEnumerations.loanvariationType(LoanTermVariationType.INTEREST_RATE), periodData.getFromDateAsLocalDate(),
|
||||||
periodData.getInterestRate(), dateValue, isSpecificToInstallment);
|
periodData.getInterestRate(), dateValue, isSpecificToInstallment);
|
||||||
if (interestRateStartDate.isAfter(periodData.getFromDateAsLocalDate())) {
|
if (!interestRateStartDate.isBefore(periodData.getFromDateAsLocalDate())) {
|
||||||
interestRateStartDate = periodData.getFromDateAsLocalDate();
|
interestRateStartDate = periodData.getFromDateAsLocalDate();
|
||||||
interestRate = periodData.getInterestRate();
|
interestRate = periodData.getInterestRate();
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -366,7 +366,7 @@ public class LoanScheduleAssembler {
|
|||||||
LoanTermVariationsData loanTermVariation = new LoanTermVariationsData(
|
LoanTermVariationsData loanTermVariation = new LoanTermVariationsData(
|
||||||
LoanEnumerations.loanvariationType(LoanTermVariationType.INTEREST_RATE), periodData.getFromDateAsLocalDate(),
|
LoanEnumerations.loanvariationType(LoanTermVariationType.INTEREST_RATE), periodData.getFromDateAsLocalDate(),
|
||||||
periodData.getInterestRate(), dateValue, isSpecificToInstallment);
|
periodData.getInterestRate(), dateValue, isSpecificToInstallment);
|
||||||
if (interestRateStartDate.isAfter(periodData.getFromDateAsLocalDate())) {
|
if (!interestRateStartDate.isBefore(periodData.getFromDateAsLocalDate())) {
|
||||||
interestRateStartDate = periodData.getFromDateAsLocalDate();
|
interestRateStartDate = periodData.getFromDateAsLocalDate();
|
||||||
annualNominalInterestRate = periodData.getInterestRate();
|
annualNominalInterestRate = periodData.getInterestRate();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user