diff --git a/History.md b/History.md index 77915c86..b8be1ce9 100644 --- a/History.md +++ b/History.md @@ -10,6 +10,9 @@ - make document charges and allowances serializable - 523 - 530 +- 532 support validation warnings! +- 534 new signature +- 2.14.2 diff --git a/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDInvoiceImporter.java b/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDInvoiceImporter.java index ff8093ec..901f1b96 100644 --- a/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDInvoiceImporter.java +++ b/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDInvoiceImporter.java @@ -358,6 +358,7 @@ public class ZUGFeRDInvoiceImporter { if (rootNode.equals("Invoice")) { // UBL... number = extractString("//*[local-name()=\"Invoice\"]/*[local-name()=\"ID\"]").trim(); + typeCode = extractString("//*[local-name()=\"Invoice\"]/*[local-name()=\"InvoiceTypeCode\"]").trim(); issueDate = new SimpleDateFormat("yyyy-MM-dd").parse(extractString("//*[local-name()=\"Invoice\"]/*[local-name()=\"IssueDate\"]").trim()); String dueDt = extractString("//*[local-name()=\"Invoice\"]/*[local-name()=\"DueDate\"]").trim(); if (dueDt.length() > 0) { diff --git a/library/src/test/java/org/mustangproject/ZUGFeRD/DeSerializationTest.java b/library/src/test/java/org/mustangproject/ZUGFeRD/DeSerializationTest.java index 85b8534c..7c6d409d 100644 --- a/library/src/test/java/org/mustangproject/ZUGFeRD/DeSerializationTest.java +++ b/library/src/test/java/org/mustangproject/ZUGFeRD/DeSerializationTest.java @@ -186,5 +186,4 @@ public class DeSerializationTest extends TestCase { } - } diff --git a/library/src/test/java/org/mustangproject/ZUGFeRD/ZF2ZInvoiceImporterTest.java b/library/src/test/java/org/mustangproject/ZUGFeRD/ZF2ZInvoiceImporterTest.java index 72b3d378..08fddcad 100644 --- a/library/src/test/java/org/mustangproject/ZUGFeRD/ZF2ZInvoiceImporterTest.java +++ b/library/src/test/java/org/mustangproject/ZUGFeRD/ZF2ZInvoiceImporterTest.java @@ -21,6 +21,7 @@ */ package org.mustangproject.ZUGFeRD; +import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import org.mustangproject.*; @@ -351,34 +352,79 @@ public class ZF2ZInvoiceImporterTest extends ResourceCase { } - public void testEEISI_300_cii_Import() { + + + + public void testImportMinimum() { + File CIIinputFile = getResourceAsFile("cii/facturFrMinimum.xml"); + try { + ZUGFeRDInvoiceImporter zii = new ZUGFeRDInvoiceImporter(new FileInputStream(CIIinputFile)); + + + CalculatedInvoice i=new CalculatedInvoice(); + zii.extractInto(i); + assertEquals("671.15", i.getGrandTotal().toString()); + + } catch (IOException e) { + fail("IOException not expected"); + } catch (XPathExpressionException e) { + throw new RuntimeException(e); + } catch (ParseException e) { + throw new RuntimeException(e); + } + + + } + + + public void testEEISI_300_cii_Import() throws XPathExpressionException, ParseException { boolean hasExceptions = false; - /* File input = getResourceAsFile("not_validating_full_invoice_based_onTest_EeISI_300_CENfullmodel.cii.xml"); + File inputCII = getResourceAsFile("not_validating_full_invoice_based_onTest_EeISI_300_CENfullmodel.cii.xml"); + File inputUBL = getResourceAsFile("not_validating_full_invoice_based_onTest_EeISI_300_CENfullmodel.ubl.xml"); ZUGFeRDInvoiceImporter zii = new ZUGFeRDInvoiceImporter(); try { - zii.fromXML(new String(Files.readAllBytes(input.toPath()), StandardCharsets.UTF_8)); + zii.fromXML(new String(Files.readAllBytes(inputCII.toPath()), StandardCharsets.UTF_8)); } catch (IOException e) { hasExceptions = true; } - Invoice invoice = null; + Invoice invoiceUBL = null; + invoiceUBL = zii.extractInvoice(); + try { - invoice = zii.extractInvoice(); - assertEquals("Seller contact point",invoice.getSender().getName()); + zii.fromXML(new String(Files.readAllBytes(inputUBL.toPath()), StandardCharsets.UTF_8)); + + } catch (IOException e) { + hasExceptions = true; + } + + Invoice invoiceCII = null; + try { + invoiceCII = zii.extractInvoice(); + ObjectMapper mapper = new ObjectMapper(); + String ubl=mapper.writeValueAsString(invoiceUBL); + String cii=mapper.writeValueAsString(invoiceCII); + + assertEquals(cii,ubl); + + /* Seller contact point +41 345 654455 - seller@contact.de);* + seller@contact.de);*/ } catch (XPathExpressionException | ParseException e) { hasExceptions = true; + } catch (JsonProcessingException e) { + throw new RuntimeException(e); } assertFalse(hasExceptions); - TransactionCalculator tc = new TransactionCalculator(invoice); + + TransactionCalculator tc = new TransactionCalculator(invoiceCII); assertEquals(new BigDecimal("205.00"), tc.getGrandTotal()); -*/ + } diff --git a/library/src/test/resources/cii/facturFrMinimum.xml b/library/src/test/resources/cii/facturFrMinimum.xml new file mode 100644 index 00000000..dacf0d03 --- /dev/null +++ b/library/src/test/resources/cii/facturFrMinimum.xml @@ -0,0 +1,56 @@ + + + + + urn:factur-x.eu:1p0:minimum + + + + FA-2017-0010 + 380 + + 20171113 + + + + + + Au bon moulin + + 99999999800010 + + + FR + + + FR11999999998 + + + + Ma jolie boutique + + 78787878400035 + + + FR + + + FR19787878784 + + + + PO445 + + + + + EUR + + 624.90 + 46.25 + 671.15 + 470.15 + + + + diff --git a/library/src/test/resources/not_validating_full_invoice_based_onTest_EeISI_300_CENfullmodel.cii.xml b/library/src/test/resources/not_validating_full_invoice_based_onTest_EeISI_300_CENfullmodel.cii.xml index 33678310..1b88d4d4 100644 --- a/library/src/test/resources/not_validating_full_invoice_based_onTest_EeISI_300_CENfullmodel.cii.xml +++ b/library/src/test/resources/not_validating_full_invoice_based_onTest_EeISI_300_CENfullmodel.cii.xml @@ -1,415 +1,415 @@ - - - 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 - - - false - - 1.00 - - - - 10.00 - 1.00 - - - - 10.00 - - - - VAT - S - 5.00 - - - + xmlns:qdt="urn:un:unece:uncefact:data:standard:QualifiedDataType:100" + xmlns:ram="urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100" + xmlns:udt="urn:un:unece:uncefact:data:standard:UnqualifiedDataType:100"> + + + BT-23 Business Process Type + + + urn:cen.eu:en16931:2017 + + + + Test_EeISI_100 + 380 + 20181112 - - - 20181130 - - - - - false - - 1.00 - 1000.00 - 10.00 - 95 - Invoice line allowance reason - - - - true - - 1.00 - 1000.00 - 10.00 - AAA - Invoice line charge reason - - - 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 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 - AAA - - - 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 - - - - - - - 50.00 - VAT - 1000.00 - S - - 5.00 - - - 0.00 - VAT - Exemtion reason text - 1000.00 - E - VATEX-EU-O - 29 - 0.00 - - - - 20181112 - - - 20181130 - - - - - false - - 1.00 - 1000.00 - 10.00 - 95 - Doc allowance reason text - - VAT - S - 5.00 - - - - - true - - 1.00 - 1000.00 - 10.00 - AAA - Doc charge reason text - - VAT - S - 5.00 - - - - total amount - - 20181130 - - Mandate reference identifier - - - 2000.00 - 10.00 - 10.00 - 2000.00 - 50.00 - 46.00 - 0.00 - 2050.00 - 0.00 - 2050.00 - - - abc123 - - 20181004 - - - - uvz - - - - \ No newline at end of file + + + 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 + + + false + + 1.00 + + + + 10.00 + 1.00 + + + + 10.00 + + + + VAT + S + 5.00 + + + + 20181112 + + + 20181130 + + + + + false + + 1.00 + 100.00 + 10.00 + 95 + Invoice line allowance reason + + + + true + + 1.00 + 100.00 + 10.00 + AAA + Invoice line charge reason + + + 100.00 + + + Line object identifier + 130 + + + 6789 + + + + + + 1b + + + Item name 2 + + + + 10.00 + + + + 10.00 + + + + VAT + E + 0.00 + + + 100.00 + + + + + 123 + + Seller identifier 1 + Seller identifier 2 + Seller name + Seller additional legal information + + + 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 + AAA + + + 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 + + + + + + + 5.00 + VAT + 100.00 + S + + 5.00 + + + 0.00 + VAT + Exemtion reason text + 100.00 + E + VATEX-EU-O + 29 + 0.00 + + + + 20181112 + + + 20181130 + + + + + false + + 1.00 + 100.00 + 10.00 + 95 + Doc allowance reason text + + VAT + S + 5.00 + + + + + true + + 1.00 + 100.00 + 10.00 + AAA + Doc charge reason text + + VAT + S + 5.00 + + + + total amount + + 20181130 + + Mandate reference identifier + + + 200.00 + 10.00 + 10.00 + 200.00 + 5.00 + 4.60 + 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_CENfullmodel.ubl.xml b/library/src/test/resources/not_validating_full_invoice_based_onTest_EeISI_300_CENfullmodel.ubl.xml index a314773a..6aec88d9 100644 --- a/library/src/test/resources/not_validating_full_invoice_based_onTest_EeISI_300_CENfullmodel.ubl.xml +++ b/library/src/test/resources/not_validating_full_invoice_based_onTest_EeISI_300_CENfullmodel.ubl.xml @@ -1,404 +1,365 @@ - - urn:cen.eu:en16931:2017 - BT-23 Business Process Type - 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 - 35 - - - abc - def - - - - abc123 - 2018-10-04 - - - - lmn - - - ghi - - - opq - - - 789 - - - rst - 130 - - - Supporting document ref - Supporting document descr - - ZGVmYXVsdA== - - External document location - - - - - 456 - - - - Seller electronic address + + 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 + + + + - Seller identifier 1 - - - Seller identifier 2 - - - Bank assigned creditor identifier + Payee identifier - Seller trading name + Payee name + + + + + Tax representative name - Seller address line 1 - Seller address line 2 - Seller city - 12345 - Seller country subdivision + Tax representative address line 1 + Tax representative address line 2 + Tax representative city + 23455 + Tax representative country subdivision - Seller address line 3 + Tax representative address line 3 DE - DE12345677 + DE3949053 VAT - - DE49294093 - - NOVAT - - - - Seller name - Seller legal identifier - Seller additional legal information - - - Seller contact point - +41 345 654455 - seller@contact.de - - - - - - Buyer electronic address - - 0190: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 - - - Payee legal registration identifier - - - - - 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 - - - - - 4 - Remittance information - - 1234 - mandatory network id - Payment card holder name - - - IT1212341234123412 - Payment account name - - BSCTCH22 - - - - IT1212341234123413 - Payment account name 2 - - BSCTCH22 - - - - Mandate reference identifier - - Debited account identifier - - - - - total amount - - - false - 55 - Doc allowance reason text - 1.0000 - 10.00 - 1000.00 - - S - 5.00 - - VAT - - - - - true - AAA - Doc charge reason text - 1.0000 - 10.00 - 1000.00 - - S - 5.00 - - VAT - - - - - 46.00 - - - 50.00 - - 1000.00 - 50.00 - - S - 5.00 - - VAT - - - - - 1000.00 - 0.00 - - E - 0.00 - Exemption reason code - Exemtion reason text - - VAT - - - - - - 2000.00 - 2000.00 - 2050.00 - 10.00 - 10.00 - 2050.00 - - - 1a - Invoice line note - 10.00000000 - 1000.00 - 6789 - - 2018-11-12 - 2018-11-30 - - - 12345 - - - Line object identifier - 130 - + + + 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 - 55 - Invoice line allowance reason - 1 + 95 + Doc allowance reason text + 1.00 10 1000 + + S + 5 + + VAT + + true AAA - Invoice line charge reason - 1 + Doc charge reason text + 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.00 + 5 VAT - - - Color - Red - - - Size - L - - - - 10.00 - 1.00 + + + + 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 - 1 - 11 + 95 + Invoice line allowance reason + 1.00 + 10 + 1000 - - - - 1b - 10.00000000 - 1000.00 - - Item name 2 - - E - 0.00 - - VAT - - - - - 10.00 - - - + + 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 + + + diff --git a/validator/src/test/java/org/mustangproject/validator/ZUGFeRDValidatorTest.java b/validator/src/test/java/org/mustangproject/validator/ZUGFeRDValidatorTest.java index 3293ebf3..3519fe45 100644 --- a/validator/src/test/java/org/mustangproject/validator/ZUGFeRDValidatorTest.java +++ b/validator/src/test/java/org/mustangproject/validator/ZUGFeRDValidatorTest.java @@ -214,6 +214,9 @@ public class ZUGFeRDValidatorTest extends ResourceCase { assertThat(res).valueByXPath("count(//error)") .asInt() .isEqualTo(3); + assertThat(res).valueByXPath("count(//warning)") + .asInt() + .isEqualTo(1); assertThat(res).valueByXPath("count(//notice)") .asInt()