Adjust CalculationTest.java.
This commit is contained in:
@@ -98,105 +98,93 @@ public class CalculationTest {
|
||||
}
|
||||
|
||||
/* trade party (sender) */
|
||||
|
||||
TradeParty sender = new TradeParty("Maier GmbH", "Musterweg 5", "11111", "Testung", "DE");
|
||||
sender.addVATID("DE2222222222");
|
||||
invoice.setSender(sender);
|
||||
/* trade party (recipient) */
|
||||
|
||||
/* 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 */
|
||||
|
||||
/* item */
|
||||
Product product;
|
||||
Item item;
|
||||
BigDecimal item_increase = BigDecimal.ZERO;
|
||||
BigDecimal item_discount = BigDecimal.ZERO;
|
||||
|
||||
product = new Product("AAA", "", "H84", sales_tax_percent1).setSellerAssignedID("1AAA");
|
||||
item = new Item(product, new BigDecimal("4.750"), new BigDecimal(5.00));
|
||||
|
||||
item_discount = new BigDecimal("10.00");
|
||||
|
||||
// set values for additional charge and discount used for next lines
|
||||
BigDecimal item_increase = BigDecimal.ZERO;
|
||||
BigDecimal item_discount = BigDecimal.valueOf(10.00);
|
||||
|
||||
/* lines */
|
||||
if (item_increase.compareTo(BigDecimal.ZERO) > 0) {
|
||||
item.addCharge(new Charge().setPercent(item_increase).setTaxPercent(sales_tax_percent1).setCategoryCode("ZZZ").setReason("Zuschlag"));
|
||||
item.addCharge(new Charge().setPercent(item_increase).setTaxPercent(sales_tax_percent1).setReasonCode("ZZZ").setReason("Zuschlag"));
|
||||
}
|
||||
|
||||
if (item_discount.compareTo(BigDecimal.ZERO) > 0) {
|
||||
item.addAllowance(new Allowance().setPercent(item_discount).setTaxPercent(sales_tax_percent1).setCategoryCode("95").setReason("Rabatt"));
|
||||
item.addAllowance(new Allowance().setPercent(item_discount).setTaxPercent(sales_tax_percent1).setReasonCode("95").setReason("Rabatt"));
|
||||
}
|
||||
|
||||
invoice.addItem(item);
|
||||
|
||||
// reset values for additional charge and discount used for next lines
|
||||
item_increase = BigDecimal.ZERO;
|
||||
item_discount = BigDecimal.ZERO;
|
||||
|
||||
product = new Product("BBB", "", "H84", sales_tax_percent1).setSellerAssignedID("2BBB");
|
||||
item = new Item(product, new BigDecimal("5.750"), new BigDecimal(4.00));
|
||||
item_discount = BigDecimal.ZERO;
|
||||
if (item_increase.compareTo(BigDecimal.ZERO) > 0) {
|
||||
item.addCharge(new Charge().setPercent(item_increase).setTaxPercent(sales_tax_percent1).setCategoryCode("ZZZ").setReason("Zuschlag"));
|
||||
item.addCharge(new Charge().setPercent(item_increase).setTaxPercent(sales_tax_percent1).setReasonCode("ZZZ").setReason("Zuschlag"));
|
||||
}
|
||||
if (item_discount.compareTo(BigDecimal.ZERO) > 0) {
|
||||
item.addAllowance(new Allowance().setPercent(item_discount).setTaxPercent(sales_tax_percent1).setCategoryCode("95").setReason("Rabatt"));
|
||||
item.addAllowance(new Allowance().setPercent(item_discount).setTaxPercent(sales_tax_percent1).setReasonCode("95").setReason("Rabatt"));
|
||||
}
|
||||
|
||||
invoice.addItem(item);
|
||||
|
||||
product = new Product("CCC", "", "H84", sales_tax_percent1).setSellerAssignedID("3CCC");
|
||||
item = new Item(product, new BigDecimal("6.750"), new BigDecimal(3.00));
|
||||
item_discount = new BigDecimal("10.00");
|
||||
if (item_increase.compareTo(BigDecimal.ZERO) > 0) {
|
||||
item.addCharge(new Charge().setPercent(item_increase).setTaxPercent(sales_tax_percent1).setCategoryCode("ZZZ").setReason("Zuschlag"));
|
||||
item.addCharge(new Charge().setPercent(item_increase).setTaxPercent(sales_tax_percent1).setReasonCode("ZZZ").setReason("Zuschlag"));
|
||||
}
|
||||
|
||||
if (item_discount.compareTo(BigDecimal.ZERO) > 0) {
|
||||
item.addAllowance(new Allowance().setPercent(item_discount).setTaxPercent(sales_tax_percent1).setCategoryCode("95").setReason("Rabatt"));
|
||||
item.addAllowance(new Allowance().setPercent(item_discount).setTaxPercent(sales_tax_percent1).setReasonCode("95").setReason("Rabatt"));
|
||||
}
|
||||
|
||||
invoice.addItem(item);
|
||||
|
||||
|
||||
product = new Product("DDD", "", "H84", sales_tax_percent1).setSellerAssignedID("4DDD");
|
||||
item = new Item(product, new BigDecimal("7.750"), new BigDecimal(2.00));
|
||||
|
||||
item_discount = BigDecimal.ZERO;
|
||||
|
||||
|
||||
if (item_increase.compareTo(BigDecimal.ZERO) > 0) {
|
||||
item.addCharge(new Charge().setPercent(item_increase).setTaxPercent(sales_tax_percent1).setCategoryCode("ZZZ").setReason("Zuschlag"));
|
||||
item.addCharge(new Charge().setPercent(item_increase).setTaxPercent(sales_tax_percent1).setReasonCode("ZZZ").setReason("Zuschlag"));
|
||||
}
|
||||
|
||||
if (item_discount.compareTo(BigDecimal.ZERO) > 0) {
|
||||
item.addAllowance(new Allowance().setPercent(item_discount).setTaxPercent(sales_tax_percent1).setCategoryCode("95").setReason("Rabatt"));
|
||||
item.addAllowance(new Allowance().setPercent(item_discount).setTaxPercent(sales_tax_percent1).setReasonCode("95").setReason("Rabatt"));
|
||||
}
|
||||
|
||||
invoice.addItem(item);
|
||||
|
||||
|
||||
product = new Product("EEE", "", "H84", sales_tax_percent1).setSellerAssignedID("5EEE");
|
||||
item = new Item(product, new BigDecimal("8.750"), new BigDecimal(1.00));
|
||||
|
||||
item_discount = BigDecimal.ZERO;
|
||||
|
||||
|
||||
if (item_increase.compareTo(BigDecimal.ZERO) > 0) {
|
||||
item.addCharge(new Charge().setPercent(item_increase).setTaxPercent(sales_tax_percent1).setCategoryCode("ZZZ").setReason("Zuschlag"));
|
||||
item.addCharge(new Charge().setPercent(item_increase).setTaxPercent(sales_tax_percent1).setReasonCode("ZZZ").setReason("Zuschlag"));
|
||||
}
|
||||
|
||||
if (item_discount.compareTo(BigDecimal.ZERO) > 0) {
|
||||
item.addAllowance(new Allowance().setPercent(item_discount).setTaxPercent(sales_tax_percent1).setCategoryCode("95").setReason("Rabatt"));
|
||||
item.addAllowance(new Allowance().setPercent(item_discount).setTaxPercent(sales_tax_percent1).setReasonCode("95").setReason("Rabatt"));
|
||||
|
||||
}
|
||||
invoice.addItem(item);
|
||||
|
||||
if (total_increase_percent.compareTo(BigDecimal.ZERO) > 0) {
|
||||
invoice.addCharge(new Charge().setPercent(total_increase_percent).setTaxPercent(sales_tax_percent1).setCategoryCode("ZZZ").setReason("Zuschläge"));
|
||||
}
|
||||
// reset values for additional charge and discount used on invoice level
|
||||
item_increase = BigDecimal.valueOf(3.50);
|
||||
item_discount = BigDecimal.valueOf(10.00);
|
||||
|
||||
if (total_increase_percent.compareTo(BigDecimal.ZERO) > 0) {
|
||||
invoice.addCharge(new Charge().setPercent(total_increase_percent).setTaxPercent(sales_tax_percent1).setReasonCode("ZZZ").setReason("Zuschläge"));
|
||||
}
|
||||
if (total_discount_percent.compareTo(BigDecimal.ZERO) > 0) {
|
||||
invoice.addAllowance(new Allowance().setPercent(total_discount_percent).setTaxPercent(sales_tax_percent1).setCategoryCode("95").setReason("Rabatte"));
|
||||
invoice.addAllowance(new Allowance().setPercent(total_discount_percent).setTaxPercent(sales_tax_percent1).setReasonCode("95").setReason("Rabatte"));
|
||||
}
|
||||
TransactionCalculator calculator = new TransactionCalculator(invoice);
|
||||
assertEquals(valueOf(99.54).stripTrailingZeros(), calculator.getGrandTotal().stripTrailingZeros());
|
||||
assertEquals(valueOf(101.86).stripTrailingZeros(), calculator.getGrandTotal().stripTrailingZeros());
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user