MIFOSX-1336 - updated scale values for money with multiples of roundoff

This commit is contained in:
Pramod Nuthakki
2014-06-17 16:03:34 +05:30
parent fcaad335f0
commit b66e289df8
@@ -69,7 +69,7 @@ public class Money implements Comparable<Money> {
final BigDecimal amountZeroed = defaultToZeroIfNull(amount);
final BigDecimal amountStripped = amountZeroed.stripTrailingZeros();
final BigDecimal amountScaled = amountStripped.setScale(this.currencyDigitsAfterDecimal, RoundingMode.HALF_EVEN);
BigDecimal amountScaled = amountStripped;
// round monetary amounts into multiplesof say 20/50.
if (inMultiplesOf != null && this.currencyDigitsAfterDecimal == 0 && inMultiplesOf > 0 && amountScaled.doubleValue() > 0) {
@@ -81,13 +81,12 @@ public class Money implements Comparable<Money> {
final double ceilDiff = ceilingOfValue - existingVal;
if (ceilDiff > floorDiff) {
this.amount = BigDecimal.valueOf(floorOfValue);
amountScaled = BigDecimal.valueOf(floorOfValue);
} else {
this.amount = BigDecimal.valueOf(ceilingOfValue);
amountScaled = BigDecimal.valueOf(ceilingOfValue);
}
} else {
this.amount = amountScaled;
}
this.amount = amountScaled.setScale(this.currencyDigitsAfterDecimal, RoundingMode.HALF_EVEN);
}
public static double ceiling(final double n, final double s) {