Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MIFOSX-2516: fix for Floating rates with multi tranche loan #11

Merged
merged 1 commit into from
Feb 23, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,51 +25,55 @@

public class FloatingRateDTO {

private final boolean isFloatingInterestRate;
private final LocalDate startDate;
private BigDecimal interestRateDiff;
private final Collection<FloatingRatePeriodData> baseLendingRatePeriods;
private final boolean isFloatingInterestRate;
private final LocalDate startDate;
private BigDecimal interestRateDiff;
private BigDecimal actualInterestRateDiff;
private final Collection<FloatingRatePeriodData> baseLendingRatePeriods;

public FloatingRateDTO(final boolean isFloatingInterestRate,
final LocalDate startDate, final BigDecimal interestRateDiff,
final Collection<FloatingRatePeriodData> baseLendingRatePeriods) {
this.isFloatingInterestRate = isFloatingInterestRate;
this.startDate = startDate;
this.interestRateDiff = interestRateDiff;
this.baseLendingRatePeriods = baseLendingRatePeriods;
}
public FloatingRateDTO(final boolean isFloatingInterestRate, final LocalDate startDate, final BigDecimal interestRateDiff,
final Collection<FloatingRatePeriodData> baseLendingRatePeriods) {
this.isFloatingInterestRate = isFloatingInterestRate;
this.startDate = startDate;
this.interestRateDiff = interestRateDiff;
this.actualInterestRateDiff = interestRateDiff;
this.baseLendingRatePeriods = baseLendingRatePeriods;
}

public BigDecimal fetchBaseRate(LocalDate date) {
BigDecimal rate = null;
for (FloatingRatePeriodData periodData : this.baseLendingRatePeriods) {
final LocalDate periodFromDate = new LocalDate(periodData.getFromDate());
if (periodFromDate.isBefore(date)
|| periodFromDate.isEqual(date)) {
rate = periodData.getInterestRate();
break;
}
}
return rate;
}
public BigDecimal fetchBaseRate(LocalDate date) {
BigDecimal rate = null;
for (FloatingRatePeriodData periodData : this.baseLendingRatePeriods) {
final LocalDate periodFromDate = new LocalDate(periodData.getFromDate());
if (periodFromDate.isBefore(date) || periodFromDate.isEqual(date)) {
rate = periodData.getInterestRate();
break;
}
}
return rate;
}

public void addInterestRateDiff(final BigDecimal diff) {
this.interestRateDiff = this.interestRateDiff.add(diff);
}
public void addInterestRateDiff(final BigDecimal diff) {
this.interestRateDiff = this.interestRateDiff.add(diff);
}

public boolean isFloatingInterestRate() {
return this.isFloatingInterestRate;
}
public boolean isFloatingInterestRate() {
return this.isFloatingInterestRate;
}

public LocalDate getStartDate() {
return this.startDate;
}
public LocalDate getStartDate() {
return this.startDate;
}

public BigDecimal getInterestRateDiff() {
return this.interestRateDiff;
}
public BigDecimal getInterestRateDiff() {
return this.interestRateDiff;
}

public Collection<FloatingRatePeriodData> getBaseLendingRatePeriods() {
return this.baseLendingRatePeriods;
}
public Collection<FloatingRatePeriodData> getBaseLendingRatePeriods() {
return this.baseLendingRatePeriods;
}

public void resetInterestRateDiff() {
this.interestRateDiff = this.actualInterestRateDiff;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public boolean isApplicable(final LocalDate fromDate) {
}

private boolean occursBefore(final LocalDate date, final LocalDate target) {
return target != null && target.isBefore(date);
return target != null && !target.isAfter(date);
}

public LocalDate getDateValue() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2597,6 +2597,7 @@ private BigDecimal constructFloatingInterestRates(final BigDecimal annualNominal
final boolean isSpecificToInstallment = false;
BigDecimal interestRate = annualNominalInterestRate;
if (loanProduct.isLinkedToFloatingInterestRate()) {
floatingRateDTO.resetInterestRateDiff();
Collection<FloatingRatePeriodData> applicableRates = loanProduct.fetchInterestRates(floatingRateDTO);
LocalDate interestRateStartDate = DateUtils.getLocalDateOfTenant();
for (FloatingRatePeriodData periodData : applicableRates) {
Expand Down