From 7b7a0f54f22d71cc3f0f94f7d30f92422c3fc763 Mon Sep 17 00:00:00 2001 From: jstaerk Date: Tue, 28 Oct 2025 10:57:58 +0100 Subject: [PATCH] star ubl testing 128 --- .../main/java/org/mustangproject/Item.java | 12 + .../ZUGFeRD/ZF2ZInvoiceImporterTest.java | 31 +- library/src/test/resources/bt17/factur-x.xml | 230 ----------- .../src/test/resources/bt17/responseDate.xml | 182 --------- .../bt17-response_1760553749128.cii.xml} | 0 library/src/test/resources/ubl/BT-128.ubl.xml | 365 ++++++++++++++++++ 6 files changed, 401 insertions(+), 419 deletions(-) delete mode 100644 library/src/test/resources/bt17/factur-x.xml delete mode 100644 library/src/test/resources/bt17/responseDate.xml rename library/src/test/resources/{bt17/response_1760553749128.xml => cii/bt17-response_1760553749128.cii.xml} (100%) create mode 100644 library/src/test/resources/ubl/BT-128.ubl.xml diff --git a/library/src/main/java/org/mustangproject/Item.java b/library/src/main/java/org/mustangproject/Item.java index 719caf83..54dfa708 100644 --- a/library/src/main/java/org/mustangproject/Item.java +++ b/library/src/main/java/org/mustangproject/Item.java @@ -88,6 +88,9 @@ public class Item implements IZUGFeRDExportableItem { icnm.getAsNodeMap("ClassifiedTaxCategory") .flatMap(m -> m.getAsBigDecimal("Percent")) .ifPresent(product::setVATPercent); + + + }); itemMap.getAsNodeMap("AssociatedDocumentLineDocument") .flatMap(icnm -> icnm.getAsString("LineID")) @@ -129,6 +132,15 @@ public class Item implements IZUGFeRDExportableItem { product = new Product(); } } + itemMap.getAsNodeMap("DocumentReference").ifPresent(drnm -> { + // BT-128 + ReferencedDocument rd=getTenderReferencedDocument(); + if (rd==null) { + rd=new ReferencedDocument(); + } + drnm.getAsString("ID").ifPresent(rd::setIssuerAssignedID); + drnm.getAsString("DocumentTypeCode").ifPresent(rd::setTypeCode); + }); itemMap.getAsNodeMap("SpecifiedLineTradeAgreement", "SpecifiedSupplyChainTradeAgreement").ifPresent(icnm -> { icnm.getAsNodeMap("BuyerOrderReferencedDocument") diff --git a/library/src/test/java/org/mustangproject/ZUGFeRD/ZF2ZInvoiceImporterTest.java b/library/src/test/java/org/mustangproject/ZUGFeRD/ZF2ZInvoiceImporterTest.java index cf16512c..e946dbf1 100644 --- a/library/src/test/java/org/mustangproject/ZUGFeRD/ZF2ZInvoiceImporterTest.java +++ b/library/src/test/java/org/mustangproject/ZUGFeRD/ZF2ZInvoiceImporterTest.java @@ -207,7 +207,7 @@ public class ZF2ZInvoiceImporterTest extends ResourceCase { public void testBT17InvoiceImport() { boolean hasExceptions = false; Invoice invoice = null; -/* + ZUGFeRDInvoiceImporter zii = new ZUGFeRDInvoiceImporter("./target/testout-ZF2PushEdge.pdf"); try { @@ -218,13 +218,11 @@ public class ZF2ZInvoiceImporterTest extends ResourceCase { assertFalse(hasExceptions); SimpleDateFormat sdf=new SimpleDateFormat("YYYY-mm-dd"); // Reading ZUGFeRD - assertEquals("90-kl-98798-C", invoice.getTenderReferencedDocument().getID()); - assertNotNull(invoice.getTenderReferencedDocument().getDate()); - assertEquals("2025", sdf.format(invoice.getTenderReferencedDocument().getDate())); -*/ - ZUGFeRDInvoiceImporter zii = new ZUGFeRDInvoiceImporter(); + assertEquals("90-kl-98798-C", invoice.getTenderReferencedDocument().getIssuerAssignedID()); + assertNotNull(invoice.getTenderReferencedDocument().getFormattedIssueDateTime()); + assertEquals("2025", sdf.format(invoice.getTenderReferencedDocument().getFormattedIssueDateTime())); try { - zii.setInputStream(new FileInputStream(getResourceAsFile("bt17/response_1760553749128.xml"))); + zii.setInputStream(new FileInputStream(getResourceAsFile("cii/bt17-response_1760553749128.cii"))); invoice = zii.extractInvoice(); } catch (XPathExpressionException | ParseException | FileNotFoundException e) { hasExceptions = true; @@ -235,6 +233,25 @@ public class ZF2ZInvoiceImporterTest extends ResourceCase { } + public void testBT128InvoiceImport() { + boolean hasExceptions = false; + Invoice invoice = null; + + ZUGFeRDInvoiceImporter zii = new ZUGFeRDInvoiceImporter(); + try { + zii.setInputStream(new FileInputStream(getResourceAsFile("ubl/BT-128.ubl.xml"))); + + invoice = zii.extractInvoice(); + } catch (XPathExpressionException | ParseException | FileNotFoundException e) { + hasExceptions = true; + } + assertFalse(hasExceptions); + SimpleDateFormat sdf=new SimpleDateFormat("YYYY-mm-dd"); + // Reading ZUGFeRD + assertEquals("90-kl-98798-C1", invoice.getZFItems()[0].getTenderReferencedDocument().getIssuerAssignedID()); + assertEquals("AAG", invoice.getZFItems()[0].getTenderReferencedDocument().getReferenceTypeCode()); + + } public void testZF1Import() { diff --git a/library/src/test/resources/bt17/factur-x.xml b/library/src/test/resources/bt17/factur-x.xml deleted file mode 100644 index 592bff46..00000000 --- a/library/src/test/resources/bt17/factur-x.xml +++ /dev/null @@ -1,230 +0,0 @@ - - - - - - - - urn:cen.eu:en16931:2017#conformant#urn:factur-x.eu:1p0:extended - - - - 123 - Rechnung - 380 - - 20251017 - - - document level 1/2 - - - document level 2/2 - - - - - - a123 - - item level 1/1 - - - - 2001015001325 - 4711 - Testprodukt - - - - orderId - xxx - - - 1.0000 - 1.0000 - - - - 1.0000 - - - - VAT - S - 16.00 - - - - 20200113 - - - 20200115 - - - - - false - - 0.02 - item discount - - - 0.98 - - - - - - 0009845 - Test company - - 55232 - teststr - teststadt - DE - - - sender@test.org - - - DE0815 - - - 9990815 - - - - 4304171000002 - Franz Müller - - Franz Müller - - 01779999999 - - - ++49555123456 - - - franz@mueller.de - - - - 55232 - teststr.12 - Hinterhaus 3 - Entenhausen - DE - - - recipient@test.org - - - DE4711 - - - - 9384 - - - 28934 - - - 376zreurzu0983 - - - 90-kl-98798-C - 50 - - - - - just the other side of the street - - 55232 - teststr.12a - Entenhausen - DE - - - - - 20201102 - - - - - Verwendungszweck - CHF - - 0.20 - VAT - 1.28 - S - 72 - 16.00 - - - - 20201001 - - - 20201005 - - - - - true - - 0.50 - quick delivery charge - - VAT - S - 16.00 - - - - - false - - 0.20 - discount - - VAT - S - 16.00 - - - - Please remit until 17.10.2025 - - 20251017 - - - - Cash Discount - - 14 - 2.000 - - - - 0.98 - 0.50 - 0.20 - 1.28 - 0.20 - 1.48 - 0.00 - 1.48 - - - abc123 - - - abcd1234 - - - - diff --git a/library/src/test/resources/bt17/responseDate.xml b/library/src/test/resources/bt17/responseDate.xml deleted file mode 100644 index 2f7d04da..00000000 --- a/library/src/test/resources/bt17/responseDate.xml +++ /dev/null @@ -1,182 +0,0 @@ - - - urn:cen.eu:en16931:2017#conformant#urn:factur-x.eu:1p0:extended - RE-20170509/505 - 2017-05-09 - 2022-02-28 - 380 - USD - AB321 - - 123 - - - Testing1 - 2018-10-04 - - - - - Ecke 12 - Stadthausen - 12345 - - DE - - - - DE0815 - - VAT - - - - 0815 - - FC - - - - Bei Spiel GmbH - - - - - - - Bahnstr. 42 - Hinterhaus - Spielkreis - 88802 - - Zweiter Stock - - - DE - - - - DE999999999 - - VAT - - - - Theodor Est - - - - - 2017-05-07 - - - Bahnstr. 42 - Hinterhaus - Spielkreis - 88802 - - Zweiter Stock - - - DE - - - - - - Theodor Est - - - - - 54 - - - 14 Tage 2% Skonto, 30 Tage rein netto - - - 0 - - 337.6 - 0 - - K - 0 - Intra-community supply - - VAT - - - - - - 337.6 - 337.6 - 337.6 - 0 - 0 - 0 - 337.6 - - - 1 - 1 - 1.6 - - 1825 - 130 - - - Künstlerische Gestaltung (Stunde): Einer Beispielrechnung - - K - 0 - - VAT - - - - - 160 - 100 - - - - 2 - 400 - 316 - - Bestellerweiterung für E&F Umbau - - K - 0 - - VAT - - - - - 0.79 - 1 - - - - 3 - 200 - 20 - - Heiße Luft pro Liter - - K - 0 - - VAT - - - - - 0.1 - 1 - - - \ No newline at end of file diff --git a/library/src/test/resources/bt17/response_1760553749128.xml b/library/src/test/resources/cii/bt17-response_1760553749128.cii.xml similarity index 100% rename from library/src/test/resources/bt17/response_1760553749128.xml rename to library/src/test/resources/cii/bt17-response_1760553749128.cii.xml diff --git a/library/src/test/resources/ubl/BT-128.ubl.xml b/library/src/test/resources/ubl/BT-128.ubl.xml new file mode 100644 index 00000000..30ab45f4 --- /dev/null +++ b/library/src/test/resources/ubl/BT-128.ubl.xml @@ -0,0 +1,365 @@ + + + urn:cen.eu:en16931:2017#compliant#urn:fdc:peppol.eu:2017:poacc:billing:3.0 + urn:fdc:peppol.eu:2017:poacc:billing:01:1.0 + Test_EeISI_100 + 2018-11-12 + 2018-11-30 + 380 + #AAA#invoice note text + #AAA#invoice note text 2 + EUR + NOK + uvz + 123 + + 2018-11-12 + 2018-11-30 + + + abc + def + + + + abc123 + 2018-10-04 + + + + lmn + + + ghi + + + 789 + + + Supporting document ref + Supporting document descr + + ZGVmYXVsdA== + + External document location + + + + + rst + 130 + + + 456 + + + + Seller electronic address + + Seller identifier 1 + + + Seller identifier 2 + + + Seller trading name + + + Seller address line 1 + Seller address line 2 + Seller city + 12345 + Seller country subdivision + + Seller address line 3 + + + DE + + + + DE12345677 + + VAT + + + + DE49294093 + + FC + + + + Seller name + Seller additional legal information + + + Seller contact point + +41 345 654455 + seller@contact.de + + + + + + Buyer electronic address + + Buyer identifier + + + Buyer trading name + + + Buyer address line 1 + Buyer address line 2 + Buyer city + 34562 + Buyer country subdivision + + Buyer address line 3 + + + IE + + + + IE394838894 + + VAT + + + + Buyer name + Buyer legal registration identifier + + + Buyer contact point + +353 2948584 + buyer@contact.ie + + + + + + Payee identifier + + + Payee name + + + + + Tax representative name + + + Tax representative address line 1 + Tax representative address line 2 + Tax representative city + 23455 + Tax representative country subdivision + + Tax representative address line 3 + + + DE + + + + DE3949053 + + VAT + + + + + 2018-12-04 + + deliver location identifier + + Deliver to address line 1 + Deliver to address line 2 + Deliver to city + 98765 + Deliver to country subdivision + + Deliver to address line 3 + + + IE + + + + + + Deliver to party name + + + + + total amount + + + false + 95 + Doc allowance reason text + 1.00 + 10 + 1000 + + S + 5 + + VAT + + + + + true + AAA + Doc charge reason text + 1.00 + 10 + 1000 + + S + 5 + + VAT + + + + + 50 + + 1000 + 50 + + S + 5 + + VAT + + + + + 1000 + 0 + + E + 0 + VATEX-EU-O + Exemtion reason text + + VAT + + + + + + 46 + + + 200 + 200 + 205 + 10 + 10 + 0 + 205 + + + 1a + Invoice line note + 10 + 1000 + 6789 + + 2018-11-12 + 2018-11-30 + + + 12345 + + + Line object identifier + 130 + + + false + 95 + Invoice line allowance reason + 1.00 + 10 + 1000 + + + true + AAA + Invoice line charge reason + 1.00 + 10 + 1000 + + + Item description + Item name + + Item buyer's identifier + + + Item seller's identifier + + + Item standar identifier + + + IT + + + Item classification identifier0 + + + S + 5 + + VAT + + + + Color + Red + + + Size + L + + + + 10 + 1 + + false + 1 + 11 + + + + + 1b + 10 + 1000 + + Item name 2 + + E + 0 + + VAT + + + + + 10 + + +