klst-de / e-invoice

create xml invoice conforming to CIUS XRechnung or €uropean standard EN16931
Apache License 2.0
12 stars 6 forks source link

how to create Allowances And Charges? #25

Closed homebeaver closed 3 years ago

homebeaver commented 3 years ago

need an example.

homebeaver commented 3 years ago

here some examples:

        // BG-27 0..n LINE ALLOWANCES:
BigDecimal tenPerCent = new BigDecimal(10);
line.addAllowance(new Amount(new BigDecimal(6.00)), new Amount(new BigDecimal(60.00)), tenPerCent);
        // BG-28 0..n LINE CHARGES:
AllowancesAndCharges charge = line.createCharge(new Amount(new BigDecimal(6.00)), new Amount(new BigDecimal(60.00)), tenPerCent);
charge.setReasoncode("64");                // UNTDID 5189 code
charge.setReasonText("Special agreement");
line.addAllowanceCharge(charge);
...
line.setUnitPriceAllowance(new UnitPriceAmount(EUR, new BigDecimal(21.21)) // priceDiscount
                  ,new UnitPriceAmount(EUR, new BigDecimal(310))); // grossPrice

...
        // BG-20 0..n DOCUMENT LEVEL ALLOWANCE:
BigDecimal tenPerCent = new BigDecimal(10);
AllowancesAndCharges allowance = invoice.createAllowance(new Amount(new BigDecimal(31)), new Amount(new BigDecimal(310)), tenPerCent);
allowance.setReasoncode("64");
allowance.setReasonText("SPECIAL AGREEMENT");
allowance.setTaxType(TaxTypeCode.VAT);
allowance.setTaxCategoryCode(TaxCategoryCode.StandardRate);
allowance.setTaxPercentage(new BigDecimal(20));
invoice.addAllowanceCharge(allowance);
homebeaver commented 3 years ago

solved in 3.1.0