adding null check for fixed deposit suggested amount for failing test cases

This commit is contained in:
Vishwas Babu A J
2014-04-30 17:40:33 +05:30
parent 656fc88aae
commit 508fe4b60d
@@ -59,14 +59,15 @@ public class InterestRateChartSlabFields {
// //
} }
public static InterestRateChartSlabFields createNew(String description, final SavingsPeriodFrequencyType periodFrequencyType, Integer fromPeriod, Integer toPeriod, public static InterestRateChartSlabFields createNew(String description, final SavingsPeriodFrequencyType periodFrequencyType,
BigDecimal amountRangeFrom, BigDecimal amountRangeTo, BigDecimal annualInterestRate, String currencyCode) { Integer fromPeriod, Integer toPeriod, BigDecimal amountRangeFrom, BigDecimal amountRangeTo, BigDecimal annualInterestRate,
String currencyCode) {
return new InterestRateChartSlabFields(description, periodFrequencyType, fromPeriod, toPeriod, amountRangeFrom, amountRangeTo, return new InterestRateChartSlabFields(description, periodFrequencyType, fromPeriod, toPeriod, amountRangeFrom, amountRangeTo,
annualInterestRate, currencyCode); annualInterestRate, currencyCode);
} }
private InterestRateChartSlabFields(String description, final SavingsPeriodFrequencyType periodFrequencyType, Integer fromPeriod, Integer toPeriod, private InterestRateChartSlabFields(String description, final SavingsPeriodFrequencyType periodFrequencyType, Integer fromPeriod,
BigDecimal amountRangeFrom, BigDecimal amountRangeTo, BigDecimal annualInterestRate, String currencyCode) { Integer toPeriod, BigDecimal amountRangeFrom, BigDecimal amountRangeTo, BigDecimal annualInterestRate, String currencyCode) {
this.description = description; this.description = description;
this.periodType = (periodFrequencyType == null) ? null : periodFrequencyType.getValue(); this.periodType = (periodFrequencyType == null) ? null : periodFrequencyType.getValue();
this.fromPeriod = fromPeriod; this.fromPeriod = fromPeriod;
@@ -167,9 +168,7 @@ public class InterestRateChartSlabFields {
public boolean isPeriodOverlapping(InterestRateChartSlabFields that) { public boolean isPeriodOverlapping(InterestRateChartSlabFields that) {
if (that.toPeriod == null) { if (that.toPeriod == null) {
if (this.toPeriod == null){ if (this.toPeriod == null) { return true; }
return true;
}
return that.fromPeriod <= this.toPeriod; return that.fromPeriod <= this.toPeriod;
} }
return this.fromPeriod <= that.toPeriod && that.fromPeriod <= this.toPeriod; return this.fromPeriod <= that.toPeriod && that.fromPeriod <= this.toPeriod;
@@ -212,6 +211,11 @@ public class InterestRateChartSlabFields {
} }
public boolean isAmountBetween(final BigDecimal depositAmount) { public boolean isAmountBetween(final BigDecimal depositAmount) {
if (amountRangeFrom != null && amountRangeTo != null) {
return depositAmount.compareTo(amountRangeFrom) >= 0 && depositAmount.compareTo(amountRangeTo) <= 0; return depositAmount.compareTo(amountRangeFrom) >= 0 && depositAmount.compareTo(amountRangeTo) <= 0;
} else if (amountRangeFrom != null) {
return depositAmount.compareTo(amountRangeFrom) >= 0;
} else if (amountRangeTo != null) { return depositAmount.compareTo(amountRangeTo) <= 0; }
return true;
} }
} }