MIFOSX-1336 - updated scale values for money with multiples of roundoff
This commit is contained in:
+4
-5
@@ -69,7 +69,7 @@ public class Money implements Comparable<Money> {
|
|||||||
|
|
||||||
final BigDecimal amountZeroed = defaultToZeroIfNull(amount);
|
final BigDecimal amountZeroed = defaultToZeroIfNull(amount);
|
||||||
final BigDecimal amountStripped = amountZeroed.stripTrailingZeros();
|
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.
|
// round monetary amounts into multiplesof say 20/50.
|
||||||
if (inMultiplesOf != null && this.currencyDigitsAfterDecimal == 0 && inMultiplesOf > 0 && amountScaled.doubleValue() > 0) {
|
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;
|
final double ceilDiff = ceilingOfValue - existingVal;
|
||||||
|
|
||||||
if (ceilDiff > floorDiff) {
|
if (ceilDiff > floorDiff) {
|
||||||
this.amount = BigDecimal.valueOf(floorOfValue);
|
amountScaled = BigDecimal.valueOf(floorOfValue);
|
||||||
} else {
|
} 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) {
|
public static double ceiling(final double n, final double s) {
|
||||||
|
|||||||
Reference in New Issue
Block a user