From b9b2b810a7d52ad3a3aa26ec509c51f1955bcbf9 Mon Sep 17 00:00:00 2001 From: jstaerk Date: Mon, 6 Oct 2025 13:31:05 +0200 Subject: [PATCH] working on potential wrong calculation --- .../ZUGFeRD/CalculationTest.java | 34 ++ .../EN16931_1_Teilrechnung_corrected.xml | 379 ++++++++++++++++++ 2 files changed, 413 insertions(+) create mode 100644 library/src/test/resources/EN16931_1_Teilrechnung_corrected.xml diff --git a/library/src/test/java/org/mustangproject/ZUGFeRD/CalculationTest.java b/library/src/test/java/org/mustangproject/ZUGFeRD/CalculationTest.java index 30448728..6f90dc6b 100644 --- a/library/src/test/java/org/mustangproject/ZUGFeRD/CalculationTest.java +++ b/library/src/test/java/org/mustangproject/ZUGFeRD/CalculationTest.java @@ -165,6 +165,40 @@ public class CalculationTest extends ResourceCase { } + @Test + public void testRounding() { +/*** xml of official fx sample with allowances and charges + * 10x100 with 10% and 50€ item discount =850€ + * +8,75 charges on document level=858,75, +19%VAT=1021,91 + * prepaid 500->due payable=521,91 + */ + File inputCII = getResourceAsFile("EN16931_1_Teilrechnung_corrected.xml"); + + ZUGFeRDInvoiceImporter zii = new ZUGFeRDInvoiceImporter(); + Invoice invoice = null; + zii.doIgnoreCalculationErrors(); + boolean hasExceptions = false; + try { + zii.setInputStream(new FileInputStream(inputCII)); + + invoice = zii.extractInvoice(); + } catch (XPathExpressionException | ParseException e) { +// handle Exceptions + hasExceptions = true; + } catch (FileNotFoundException e) { + hasExceptions = true; + } + assertFalse(hasExceptions); + // Reading ZUGFeRD + + final TransactionCalculator calculator = new TransactionCalculator(invoice); + + assertEquals(valueOf(147.59).stripTrailingZeros(), calculator.getDuePayable().stripTrailingZeros()); + + + } + + @Test public void testTotalCalculatorGrandTotalRounding() { SimpleDateFormat sqlDate = new SimpleDateFormat("yyyy-MM-dd"); diff --git a/library/src/test/resources/EN16931_1_Teilrechnung_corrected.xml b/library/src/test/resources/EN16931_1_Teilrechnung_corrected.xml new file mode 100644 index 00000000..8ffdde89 --- /dev/null +++ b/library/src/test/resources/EN16931_1_Teilrechnung_corrected.xml @@ -0,0 +1,379 @@ + + + + + + + + + + + urn:cen.eu:en16931:2017 + + + + 471102 + 380 + + 20180605 + + + Rechnung gemäß Bestellung Nr. 2018-471331 vom 01.03.2018. + + + Es bestehen Rabatt- und Bonusvereinbarungen. + AAK + + + Lieferant GmbH +Lieferantenstraße 20 +80333 München +Deutschland +Geschäftsführer: Hans Muster +Handelsregisternummer: H A 123 + + REG + + + + + + 1 + + Wir erlauben uns Ihnen folgende Positionen aus der Lieferung Nr. 2018-51112 in Rechnung zu stellen: + + + + 4012345001235 + KR3M + + Kunstrasen grün 3m breit + 300cm x 100 cm + + + + 4.0000 + + + false + + 0.6667 + + + + 3.3333 + + + + 3.0000 + + + + VAT + S + 19.00 + + + 10.00 + + + + + + 2 + + Bestellt wurden 5 kg Schweinesteak. Mit dieser Rechnung werden nur die bereits gelieferten Steaks berechnet. Die noch offenen 4 kg Schweinesteak werden separat geliefert und berechnet. + + + + 4000050986428 + SFK5 + + Schweinesteak + Schweinesteak aus Deutschland + + + + 5.5000 + + + 5.5000 + + + + 1.0000 + + + + VAT + S + 7.00 + + + 5.50 + + + + + + 3 + + + 4000001234561 + GTRWA5 + + Mineralwasser Medium +12 x 1,0l PET + + + + + 5.4900 + + + 5.4900 + + + + 20.0000 + + + + VAT + S + 7.00 + + + 109.80 + + + + + + 4 + + + 4000001234578 + PFA5 + + Pfand + + + + 2.7700 + + + 2.7700 + + + + 20.0000 + + + + VAT + S + 19.00 + + + 55.46 + + + + + + 549910 + 4000001123452 + Lieferant GmbH + + 80333 + Lieferantenstraße 20 + München + DE + + + 201/113/40209 + + + DE123456789 + + + + GE2020211 + Kunden AG Mitte + + 69876 + Kundenstraße 15 + Frankfurt + DE + + + + 2018-471331 + + + + + + 20180603 + + + + + EUR + + 7.91 + VAT + 113.03 + S + 7.00 + + + 12.25 + VAT + 64.46 + S + 19.00 + + + + false + + 10.00 + 1.00 + Sondernachlass + + VAT + S + 19.00 + + + + + false + + 115.30 + 8.07 + Sondernachlass + + VAT + S + 7.00 + + + + + true + + 115.30 + 5.80 + Versandkosten + + VAT + S + 7.00 + + + + Zahlbar innerhalb 30 Tagen netto bis 04.07.2018, 3% Skonto innerhalb 10 Tagen bis 15.06.2018 + + + 180.70 + 5.80 + 9.07 + 177.43 + 20.16 + 197.59 + 50.00 + 147.59 + + + +