diff --git a/mifosng-provider/src/main/java/org/mifosplatform/organisation/monetary/domain/Money.java b/mifosng-provider/src/main/java/org/mifosplatform/organisation/monetary/domain/Money.java index 14d0147f0..e9e300185 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/organisation/monetary/domain/Money.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/organisation/monetary/domain/Money.java @@ -69,7 +69,7 @@ public class Money implements Comparable { 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 { 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) {