From e1991b2b2816790191849c68a773dc02b371cc18 Mon Sep 17 00:00:00 2001 From: jstaerk Date: Fri, 4 Oct 2024 16:33:36 +0200 Subject: [PATCH] recipient.id --- .../java/org/mustangproject/TradeParty.java | 15 +- .../ZUGFeRD/ZF2ZInvoiceImporterTest.java | 45 ++- ...sed_onTest_EeISI_300_CENfullmodel2.cii.xml | 353 ++++++++++++++++++ ...sed_onTest_EeISI_300_CENfullmodel2.ubl.xml | 2 +- 4 files changed, 407 insertions(+), 8 deletions(-) create mode 100644 library/src/test/resources/not_validating_full_invoice_based_onTest_EeISI_300_CENfullmodel2.cii.xml diff --git a/library/src/main/java/org/mustangproject/TradeParty.java b/library/src/main/java/org/mustangproject/TradeParty.java index e67567e4..46a457c5 100644 --- a/library/src/main/java/org/mustangproject/TradeParty.java +++ b/library/src/main/java/org/mustangproject/TradeParty.java @@ -89,6 +89,19 @@ public class TradeParty implements IZUGFeRDExportableTradeParty { } } + if (currentTopElementName.equals("PartyIdentification")) { + + NodeList partyName = party.item(partyIndex).getChildNodes(); + for (int partyNameIndex = 0; partyNameIndex < partyName.getLength(); partyNameIndex++) { + if (partyName.item(partyNameIndex).getLocalName() != null) { + if (partyName.item(partyNameIndex).getLocalName().equals("ID")) { + setID(partyName.item(partyNameIndex).getTextContent()); + } + + } + } + } + // UBL only: formally it can have a name as well but BT27 party name *should* be stored in // so overwrite if one exists if (currentTopElementName.equals("PartyLegalEntity")) { @@ -311,7 +324,7 @@ public class TradeParty implements IZUGFeRDExportableTradeParty { NodeList itemChilds = currentItemNode.getChildNodes(); for (int itemChildIndex = 0; itemChildIndex < itemChilds.getLength(); itemChildIndex++) { if (itemChilds.item(itemChildIndex).getLocalName() != null) { - if (itemChilds.item(itemChildIndex).getLocalName().equals("ID")) { + if (itemChilds.item(itemChildIndex).getLocalName().equals("GlobalID")) { setID(itemChilds.item(itemChildIndex).getTextContent()); } if (itemChilds.item(itemChildIndex).getLocalName().equals("Name")) { diff --git a/library/src/test/java/org/mustangproject/ZUGFeRD/ZF2ZInvoiceImporterTest.java b/library/src/test/java/org/mustangproject/ZUGFeRD/ZF2ZInvoiceImporterTest.java index 175aa9f1..505c9029 100644 --- a/library/src/test/java/org/mustangproject/ZUGFeRD/ZF2ZInvoiceImporterTest.java +++ b/library/src/test/java/org/mustangproject/ZUGFeRD/ZF2ZInvoiceImporterTest.java @@ -42,9 +42,23 @@ import java.util.Arrays; public class ZF2ZInvoiceImporterTest extends ResourceCase { - public void testInvoiceImport() { + public void testInvoiceImportSupportCase145() { - ZUGFeRDInvoiceImporter zii = new ZUGFeRDInvoiceImporter("./target/testout-ZF2new.pdf"); + ZUGFeRDInvoiceImporter zii = new ZUGFeRDInvoiceImporter("C:\\Users\\jstaerk\\workspace\\XMLExamples\\zfdiverses\\20241004_\\IGEPA-Rechnung_41102839_00200_20240918.PDF"); + boolean hasExceptions = false; + Invoice invoice = null; + try { + invoice = zii.extractInvoice(); + } catch (XPathExpressionException | ParseException e) { + hasExceptions = true; + } + assertFalse(hasExceptions); + + } + + public void testInvoiceImport() { + + ZUGFeRDInvoiceImporter zii = new ZUGFeRDInvoiceImporter("./target/testout-ZF2new.pdf"); boolean hasExceptions = false; Invoice invoice = null; @@ -318,12 +332,30 @@ public class ZF2ZInvoiceImporterTest extends ResourceCase { } -/* + public void testEEISI_300_cii_Import() { boolean hasExceptions = false; File input = getResourceAsFile("not_validating_full_invoice_based_onTest_EeISI_300_CENfullmodel2.ubl.xml"); + File inputCorrect = getResourceAsFile("not_validating_full_invoice_based_onTest_EeISI_300_CENfullmodel2.cii.xml"); + ZUGFeRDInvoiceImporter cii = new ZUGFeRDInvoiceImporter(); + try { + cii.fromXML(new String(Files.readAllBytes(inputCorrect.toPath()), StandardCharsets.UTF_8)); + + } catch (IOException e) { + hasExceptions = true; + } + + Invoice ciiinvoice = null; + try { + ciiinvoice = cii.extractInvoice(); + + } catch (XPathExpressionException e) { + throw new RuntimeException(e); + } catch (ParseException e) { + throw new RuntimeException(e); + } ZUGFeRDInvoiceImporter zii = new ZUGFeRDInvoiceImporter(); try { zii.fromXML(new String(Files.readAllBytes(input.toPath()), StandardCharsets.UTF_8)); @@ -335,11 +367,12 @@ public class ZF2ZInvoiceImporterTest extends ResourceCase { Invoice invoice = null; try { invoice = zii.extractInvoice(); - assertEquals("Seller contact point",invoice.getSender().getName()); + assertEquals("Seller name",invoice.getSender().getName()); + assertEquals(ciiinvoice.getRecipient().getID(),invoice.getRecipient().getID()); /* Seller contact point +41 345 654455 - seller@contact.de);* + seller@contact.de);*/ } catch (XPathExpressionException | ParseException e) { hasExceptions = true; } @@ -349,5 +382,5 @@ public class ZF2ZInvoiceImporterTest extends ResourceCase { } -*/ + } diff --git a/library/src/test/resources/not_validating_full_invoice_based_onTest_EeISI_300_CENfullmodel2.cii.xml b/library/src/test/resources/not_validating_full_invoice_based_onTest_EeISI_300_CENfullmodel2.cii.xml new file mode 100644 index 00000000..94a81f4c --- /dev/null +++ b/library/src/test/resources/not_validating_full_invoice_based_onTest_EeISI_300_CENfullmodel2.cii.xml @@ -0,0 +1,353 @@ + + + + + BT-23 Business Process Type + + + urn:cen.eu:en16931:2017 + + + + Test_EeISI_100 + 380 + + 20181112 + + + invoice note text + #AAA# + + + invoice note text 2 + #AAA# + + + + + + 1a + + Invoice line note + + + + Item standar identifier + Item seller's identifier + Item buyer's identifier + Item name + Item description + + Color + Red + + + Size + L + + + Item classification identifier0 + + + IT + + + + + 12345 + + + 11.00 + 1.00 + + + 10.00 + 1.00 + + + + 10.00 + + + + VAT + S + 5.00 + + + + 20181112 + + + 20181130 + + + + 1000.00 + + + Line object identifier + 130 + + + + 6789 + + + + + + 1b + + + Item name 2 + + + + 10.00 + + + + 10.00 + + + + VAT + E + 0.00 + + + 1000.00 + + + + + 123 + + Seller identifier 1 + Seller identifier 2 + Seller name + Seller additional legal information + + Seller legal identifier + Seller trading name + + + Seller contact point + + +41 345 654455 + + + seller@contact.de + + + + 12345 + Seller address line 1 + Seller address line 2 + Seller address line 3 + Seller city + DE + Seller country subdivision + + + Seller electronic address + + + DE12345677 + + + DE49294093 + + + + Buyer identifier + Buyer name + + Buyer legal registration identifier + Buyer trading name + + + Buyer contact point + + +353 2948584 + + + buyer@contact.ie + + + + 34562 + Buyer address line 1 + Buyer address line 2 + Buyer address line 3 + Buyer city + IE + Buyer country subdivision + + + Buyer electronic address + + + IE394838894 + + + + Tax representative name + + 23455 + Tax representative address line 1 + Tax representative address line 2 + Tax representative address line 3 + Tax representative city + DE + Tax representative country subdivision + + + DE3949053 + + + + def + + + abc + + + 789 + + + Supporting document ref + External document location + 916 + Supporting document descr + ZGVmYXVsdA== + + + rst + 130 + 0090 + + + 456 + Project reference + + + + + deliver location identifier + Deliver to party name + + 98765 + Deliver to address line 1 + Deliver to address line 2 + Deliver to address line 3 + Deliver to city + IE + Deliver to country subdivision + + + + + 20181204 + + + + lmn + + + ghi + + + + Bank assigned creditor identifier + Remittance information + NOK + EUR + + Payee identifier + Payee name + + Payee legal registration identifier + + + + 4 + SEPA + + 1234 + Payment card holder name + + + Debited account identifier + + + IT1212341234123412 + Payment account name + + + BSCTCH22 + + + IT1212341234123413 + Payment account name 2 + + + BSCTCH22 + + + + 50.00 + VAT + 1000.00 + S + 29 + 5.00 + + + 0.00 + VAT + Exemtion reason text + 1000.00 + E + Exemption reason code + 29 + 0.00 + + + + 20181112 + + + 20181130 + + + + total amount + + 20181130 + + Mandate reference identifier + + + 200.00 + 200.00 + 50.00 + 46.00 + 0.00 + 205.00 + 0.00 + 205.00 + + + abc123 + + 20181004 + + + + uvz + + + + diff --git a/library/src/test/resources/not_validating_full_invoice_based_onTest_EeISI_300_CENfullmodel2.ubl.xml b/library/src/test/resources/not_validating_full_invoice_based_onTest_EeISI_300_CENfullmodel2.ubl.xml index 7e71103c..1654b0ac 100644 --- a/library/src/test/resources/not_validating_full_invoice_based_onTest_EeISI_300_CENfullmodel2.ubl.xml +++ b/library/src/test/resources/not_validating_full_invoice_based_onTest_EeISI_300_CENfullmodel2.ubl.xml @@ -112,7 +112,7 @@ Buyer electronic address - 0190:Buyer identifier + Buyer identifier Buyer trading name