manually applying @rchilumukoti patch, closes #491 (I hope)
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
- 481
|
||||
- 494
|
||||
- 391
|
||||
-
|
||||
- 491
|
||||
|
||||
2.14.0
|
||||
=======
|
||||
|
||||
@@ -37,7 +37,7 @@ public class LineCalculator {
|
||||
BigDecimal vatPercent = currentItem.getProduct().getVATPercent();
|
||||
if (vatPercent == null)
|
||||
vatPercent = BigDecimal.ZERO;
|
||||
BigDecimal multiplicator = vatPercent.divide(BigDecimal.valueOf(100));
|
||||
BigDecimal multiplicator = vatPercent.divide(BigDecimal.valueOf(100), RoundingMode.HALF_UP);
|
||||
priceGross = currentItem.getPrice(); // see https://github.com/ZUGFeRD/mustangproject/issues/159
|
||||
price = priceGross.subtract(allowance).add(charge);
|
||||
itemTotalNetAmount = currentItem.getQuantity().multiply(getPrice()).divide(currentItem.getBasisQuantity())
|
||||
|
||||
@@ -187,5 +187,18 @@ public class CalculationTest {
|
||||
assertEquals(valueOf(101.86).stripTrailingZeros(), calculator.getGrandTotal().stripTrailingZeros());
|
||||
}
|
||||
|
||||
/**
|
||||
* LineCalculator should not throw an exception when calculating a non-terminating decimal expansion
|
||||
*/
|
||||
@Test
|
||||
public void testNonTerminatingDecimalExpansion() {
|
||||
final Product product = new Product();
|
||||
final IZUGFeRDExportableItem currentItem = new Item().setPrice(valueOf(386.52))
|
||||
.setQuantity(BigDecimal.valueOf(31))
|
||||
.setBasisQuantity(BigDecimal.valueOf(366))
|
||||
.setProduct(product);
|
||||
final LineCalculator calculator = new LineCalculator(currentItem);
|
||||
assertEquals(BigDecimal.valueOf(32.74), calculator.getItemTotalNetAmount());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user