diff --git a/History.md b/History.md index 701106d8..6a8f4be3 100644 --- a/History.md +++ b/History.md @@ -1,3 +1,5 @@ +- #678 +- #679 2.16.0 ======= diff --git a/Mustang-CLI/pom.xml b/Mustang-CLI/pom.xml index 9b5e3bc9..9d83688f 100644 --- a/Mustang-CLI/pom.xml +++ b/Mustang-CLI/pom.xml @@ -3,7 +3,7 @@ org.mustangproject core - 2.15.3-SNAPSHOT + 2.16.1-SNAPSHOT 4.0.0 org.mustangproject @@ -12,7 +12,7 @@ should also work for XRechnung/CII. jar - 2.15.3-SNAPSHOT + 2.16.1-SNAPSHOT UTF-8 11 @@ -23,7 +23,7 @@ org.mustangproject validator - 2.15.3-SNAPSHOT + 2.16.1-SNAPSHOT diff --git a/library/pom.xml b/library/pom.xml index 8b5b3370..b00935f6 100644 --- a/library/pom.xml +++ b/library/pom.xml @@ -3,13 +3,13 @@ org.mustangproject core - 2.15.3-SNAPSHOT + 2.16.1-SNAPSHOT 4.0.0 org.mustangproject library - 2.15.3-SNAPSHOT + 2.16.1-SNAPSHOT jar Library to write, read and validate e-invoices (Factur-X, ZUGFeRD, Order-X, XRechnung/CII) FOSS Java library to read, write and validate european electronic invoices and orders in the UN/CEFACT diff --git a/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDInvoiceImporter.java b/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDInvoiceImporter.java index de66b35d..b9d3f5c1 100644 --- a/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDInvoiceImporter.java +++ b/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDInvoiceImporter.java @@ -309,7 +309,7 @@ public class ZUGFeRDInvoiceImporter { List includedNotes = new ArrayList<>(); //UBL... - XPathExpression UBLNotesEx = xpath.compile("/*[local-name()=\"Invoice\"]/*[local-name()=\"Note\"]"); + XPathExpression UBLNotesEx = xpath.compile("/*[local-name()=\"Invoice\" or local-name()=\"CreditNote\"]/*[local-name()=\"Note\"]"); NodeList UBLNotesNd = (NodeList) UBLNotesEx.evaluate(getDocument(), XPathConstants.NODESET); if ((UBLNotesNd != null) && (UBLNotesNd.getLength() > 0)) { for (int nodeIndex = 0; nodeIndex < UBLNotesNd.getLength(); nodeIndex++) { @@ -556,15 +556,16 @@ public class ZUGFeRDInvoiceImporter { } zpp.addNotes(includedNotes); String rootNode = extractString("local-name(/*)"); - if (rootNode.equals("Invoice")) { + if (rootNode.equals("Invoice")||rootNode.equals("CreditNote")) { // UBL... - number = extractString("//*[local-name()=\"Invoice\"]/*[local-name()=\"ID\"]").trim(); - typeCode = extractString("//*[local-name()=\"Invoice\"]/*[local-name()=\"InvoiceTypeCode\"]").trim(); - String issueDateStr = extractString("//*[local-name()=\"Invoice\"]/*[local-name()=\"IssueDate\"]").trim(); + // //*[local-name()="Invoice" or local-name()="CreditNote"] + number = extractString("/*[local-name()=\"Invoice\" or local-name()=\"CreditNote\"]/*[local-name()=\"ID\"]").trim(); + typeCode = extractString("/*[local-name()=\"Invoice\" or local-name()=\"CreditNote\"]/*[local-name()=\"InvoiceTypeCode\"]").trim(); + String issueDateStr = extractString("/*[local-name()=\"Invoice\" or local-name()=\"CreditNote\"]/*[local-name()=\"IssueDate\"]").trim(); if (issueDateStr.length()>0) { issueDate = new SimpleDateFormat("yyyy-MM-dd").parse(issueDateStr); } - String dueDt = extractString("//*[local-name()=\"Invoice\"]/*[local-name()=\"DueDate\"]").trim(); + String dueDt = extractString("/*[local-name()=\"Invoice\" or local-name()=\"CreditNote\"]/*[local-name()=\"DueDate\"]").trim(); if (dueDt.length() > 0) { dueDate = new SimpleDateFormat("yyyy-MM-dd").parse(dueDt); } diff --git a/library/src/test/java/org/mustangproject/ZUGFeRD/ZF2ZInvoiceImporterTest.java b/library/src/test/java/org/mustangproject/ZUGFeRD/ZF2ZInvoiceImporterTest.java index 49c5ce78..11daecf0 100644 --- a/library/src/test/java/org/mustangproject/ZUGFeRD/ZF2ZInvoiceImporterTest.java +++ b/library/src/test/java/org/mustangproject/ZUGFeRD/ZF2ZInvoiceImporterTest.java @@ -375,7 +375,7 @@ public class ZF2ZInvoiceImporterTest extends ResourceCase { } - public void testImportMinimum() { + public void testImportMinimum() { File CIIinputFile = getResourceAsFile("cii/facturFrMinimum.xml"); try { ZUGFeRDInvoiceImporter zii = new ZUGFeRDInvoiceImporter(new FileInputStream(CIIinputFile)); @@ -394,6 +394,28 @@ public class ZF2ZInvoiceImporterTest extends ResourceCase { } + } + + public void testImportUBLCreditnote() { // Confirm some basics also work with UBL credit notes + File CIIinputFile = getResourceAsFile("ubl/UBL-CreditNote-2.1-Example.ubl.xml"); + try { + ZUGFeRDInvoiceImporter zii = new ZUGFeRDInvoiceImporter(new FileInputStream(CIIinputFile)); + + + CalculatedInvoice i = new CalculatedInvoice(); + zii.extractInto(i); + assertEquals("TOSL108", i.getNumber()); + assertEquals("729", i.getGrandTotal().toString()); + + } catch (IOException e) { + fail("IOException not expected"); + } catch (XPathExpressionException e) { + throw new RuntimeException(e); + } catch (ParseException e) { + throw new RuntimeException(e); + } + + } diff --git a/pom.xml b/pom.xml index 9dade18f..03f326a5 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 org.mustangproject core - 2.15.3-SNAPSHOT pom + 2.16.1-SNAPSHOT pom Mustang diff --git a/validator/pom.xml b/validator/pom.xml index 67d7ca94..d8820ab1 100644 --- a/validator/pom.xml +++ b/validator/pom.xml @@ -3,7 +3,7 @@ org.mustangproject core - 2.15.3-SNAPSHOT + 2.16.1-SNAPSHOT 4.0.0 org.mustangproject @@ -11,7 +11,7 @@ Library to validate e-invoices (ZUGFeRD, Factur-X and Xrechnung) jar - 2.15.3-SNAPSHOT + 2.16.1-SNAPSHOT @@ -38,7 +38,7 @@ ${project.groupId} library - 2.15.3-SNAPSHOT + 2.16.1-SNAPSHOT org.dom4j diff --git a/validator/src/main/java/org/mustangproject/validator/ValidationContext.java b/validator/src/main/java/org/mustangproject/validator/ValidationContext.java index 73b95f2e..ce3cde48 100644 --- a/validator/src/main/java/org/mustangproject/validator/ValidationContext.java +++ b/validator/src/main/java/org/mustangproject/validator/ValidationContext.java @@ -70,7 +70,7 @@ public class ValidationContext { } public ValidationContext setProfile(String profile) { - this.profile = profile; + this.profile = profile.trim(); return this; }