manually applying @rchilumukoti patch, closes #491 (I hope)
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
- 481
|
- 481
|
||||||
- 494
|
- 494
|
||||||
- 391
|
- 391
|
||||||
-
|
- 491
|
||||||
|
|
||||||
2.14.0
|
2.14.0
|
||||||
=======
|
=======
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ public class LineCalculator {
|
|||||||
BigDecimal vatPercent = currentItem.getProduct().getVATPercent();
|
BigDecimal vatPercent = currentItem.getProduct().getVATPercent();
|
||||||
if (vatPercent == null)
|
if (vatPercent == null)
|
||||||
vatPercent = BigDecimal.ZERO;
|
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
|
priceGross = currentItem.getPrice(); // see https://github.com/ZUGFeRD/mustangproject/issues/159
|
||||||
price = priceGross.subtract(allowance).add(charge);
|
price = priceGross.subtract(allowance).add(charge);
|
||||||
itemTotalNetAmount = currentItem.getQuantity().multiply(getPrice()).divide(currentItem.getBasisQuantity())
|
itemTotalNetAmount = currentItem.getQuantity().multiply(getPrice()).divide(currentItem.getBasisQuantity())
|
||||||
|
|||||||
@@ -17,14 +17,14 @@ import java.text.SimpleDateFormat;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class CalculationTest {
|
public class CalculationTest {
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger (CalculationTest.class);
|
private static final Logger LOGGER = LoggerFactory.getLogger(CalculationTest.class);
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testLineCalculator_simpleAmounts_resultInValidVATAmount() {
|
public void testLineCalculator_simpleAmounts_resultInValidVATAmount() {
|
||||||
final IZUGFeRDExportableProduct product = new IZUGFeRDExportableProductImpl().setVatPercent(valueOf(16));
|
final IZUGFeRDExportableProduct product = new IZUGFeRDExportableProductImpl().setVatPercent(valueOf(16));
|
||||||
final IZUGFeRDExportableItem currentItem = new IZUGFeRDExportableItemImpl().setPrice(valueOf(100))
|
final IZUGFeRDExportableItem currentItem = new IZUGFeRDExportableItemImpl().setPrice(valueOf(100))
|
||||||
.setQuantity(TEN)
|
.setQuantity(TEN)
|
||||||
.setProduct(product);
|
.setProduct(product);
|
||||||
|
|
||||||
final LineCalculator calculator = new LineCalculator(currentItem);
|
final LineCalculator calculator = new LineCalculator(currentItem);
|
||||||
|
|
||||||
@@ -41,9 +41,9 @@ public class CalculationTest {
|
|||||||
final IZUGFeRDAllowanceCharge allowance = new IZUGFeRDAllowanceChargeImpl().setTotalAmount(valueOf(14.8730));
|
final IZUGFeRDAllowanceCharge allowance = new IZUGFeRDAllowanceChargeImpl().setTotalAmount(valueOf(14.8730));
|
||||||
|
|
||||||
final IZUGFeRDExportableItem currentItem = new IZUGFeRDExportableItemImpl().setPrice(valueOf(148.73))
|
final IZUGFeRDExportableItem currentItem = new IZUGFeRDExportableItemImpl().setPrice(valueOf(148.73))
|
||||||
.setQuantity(valueOf(12))
|
.setQuantity(valueOf(12))
|
||||||
.setItemAllowances(new IZUGFeRDAllowanceCharge[]{allowance})
|
.setItemAllowances(new IZUGFeRDAllowanceCharge[]{allowance})
|
||||||
.setProduct(product);
|
.setProduct(product);
|
||||||
|
|
||||||
final LineCalculator calculator = new LineCalculator(currentItem);
|
final LineCalculator calculator = new LineCalculator(currentItem);
|
||||||
|
|
||||||
@@ -60,10 +60,10 @@ public class CalculationTest {
|
|||||||
// 20 % charge
|
// 20 % charge
|
||||||
final IZUGFeRDAllowanceCharge charge = new IZUGFeRDAllowanceChargeImpl().setTotalAmount(valueOf(29.746));
|
final IZUGFeRDAllowanceCharge charge = new IZUGFeRDAllowanceChargeImpl().setTotalAmount(valueOf(29.746));
|
||||||
final IZUGFeRDExportableItem currentItem = new IZUGFeRDExportableItemImpl().setPrice(valueOf(148.73))
|
final IZUGFeRDExportableItem currentItem = new IZUGFeRDExportableItemImpl().setPrice(valueOf(148.73))
|
||||||
.setQuantity(valueOf(12))
|
.setQuantity(valueOf(12))
|
||||||
.setItemAllowances(new IZUGFeRDAllowanceCharge[]{allowance})
|
.setItemAllowances(new IZUGFeRDAllowanceCharge[]{allowance})
|
||||||
.setItemCharges(new IZUGFeRDAllowanceCharge[]{charge})
|
.setItemCharges(new IZUGFeRDAllowanceCharge[]{charge})
|
||||||
.setProduct(product);
|
.setProduct(product);
|
||||||
|
|
||||||
final LineCalculator calculator = new LineCalculator(currentItem);
|
final LineCalculator calculator = new LineCalculator(currentItem);
|
||||||
|
|
||||||
@@ -187,5 +187,18 @@ public class CalculationTest {
|
|||||||
assertEquals(valueOf(101.86).stripTrailingZeros(), calculator.getGrandTotal().stripTrailingZeros());
|
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