closes #960
This commit is contained in:
@@ -73,7 +73,7 @@ public class LineCalculator {
|
||||
}
|
||||
if (currentItem.getProduct().getCharges()!=null) {
|
||||
for (IZUGFeRDAllowanceCharge ccaf : currentItem.getProduct().getCharges()) {
|
||||
delta = delta.subtract(ccaf.getTotalAmount(currentItem));
|
||||
delta = delta.add(ccaf.getTotalAmount(currentItem));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -249,6 +249,54 @@ public class CalculationTest extends ResourceCase {
|
||||
assertEquals(valueOf(101.85).stripTrailingZeros(), calculator.getGrandTotal().stripTrailingZeros());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNullifyingAllowancesCharges() {
|
||||
SimpleDateFormat sqlDate = new SimpleDateFormat("yyyy-MM-dd");
|
||||
|
||||
|
||||
Invoice invoice = new Invoice();
|
||||
invoice.setDocumentName("Rechnung");
|
||||
invoice.setNumber("777777");
|
||||
try {
|
||||
invoice.setIssueDate(sqlDate.parse("2020-12-31"));
|
||||
invoice.setDetailedDeliveryPeriod(sqlDate.parse("2020-12-01 - 2020-12-31".split(" - ")[0]), sqlDate.parse("2020-12-01 - 2020-12-31".split(" - ")[1]));
|
||||
invoice.setDeliveryDate(sqlDate.parse("2020-12-31"));
|
||||
invoice.setDueDate(sqlDate.parse("2021-01-15"));
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("Failed to set dates", e);
|
||||
|
||||
}
|
||||
|
||||
/* trade party (sender) */
|
||||
TradeParty sender = new TradeParty("Maier GmbH", "Musterweg 5", "11111", "Testung", "DE");
|
||||
sender.addVATID("DE2222222222");
|
||||
invoice.setSender(sender);
|
||||
|
||||
/* trade party (recipient) */
|
||||
TradeParty recipient = new TradeParty("Teston GmbH" + " " + "Zentrale" + " " + "", "Testweg 5", "11111", "Testung", "DE");
|
||||
recipient.setID("111111");
|
||||
recipient.addVATID("DE111111111");
|
||||
invoice.setRecipient(recipient);
|
||||
|
||||
/* item */
|
||||
Product product;
|
||||
Item item;
|
||||
BigDecimal amount=new BigDecimal("10.00");
|
||||
|
||||
product = new Product("AAA", "", "H87", BigDecimal.ZERO).setSellerAssignedID("1AAA");
|
||||
product.addCharge(new Charge(amount).setReasonCode("ZZZ").setReason("Zuschlag"));
|
||||
product.addAllowance((Allowance) new Allowance(amount).setReasonCode("95").setReason("Rabatt"));
|
||||
item = new Item(product, new BigDecimal("4.750"), new BigDecimal(1.00));
|
||||
|
||||
// set values for additional charge and discount used for next lines
|
||||
item.addCharge(new Charge(amount).setReasonCode("ZZZ").setReason("Zuschlag"));
|
||||
item.addAllowance((Allowance) new Allowance(amount).setReasonCode("95").setReason("Rabatt"));
|
||||
invoice.addItem(item);
|
||||
|
||||
TransactionCalculator calculator = new TransactionCalculator(invoice);
|
||||
assertEquals(valueOf(4.750).stripTrailingZeros(), calculator.getGrandTotal().stripTrailingZeros());
|
||||
}
|
||||
|
||||
public void testSimpleItemPercentAllowance() {
|
||||
/***
|
||||
* a product with net 1.10 and qty 5 and relative item allowance of 10% should return 5 as line and grand total
|
||||
|
||||
Reference in New Issue
Block a user