diff --git a/History.md b/History.md index 701106d8..4a4c67a6 100644 --- a/History.md +++ b/History.md @@ -1,3 +1,6 @@ +- #678 +- #679 +- #681 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 073661c1..81a1716f 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..9115feb4 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); } @@ -812,9 +813,11 @@ public class ZUGFeRDInvoiceImporter { d.setPaymentMeansInformation(paymentMeansInformation); } zpp.getSender().addDebitDetails(d); + bankDetails.forEach(bankDetail -> zpp.getRecipient().addBankDetails(bankDetail)); + } else { + bankDetails.forEach(bankDetail -> zpp.getSender().addBankDetails(bankDetail)); } - bankDetails.forEach(bankDetail -> zpp.getSender().addBankDetails(bankDetail)); if (payeeNodes.getLength() > 0) { zpp.setPayee(new TradeParty(payeeNodes)); diff --git a/library/src/test/java/org/mustangproject/ZUGFeRD/ZF2ZInvoiceImporterTest.java b/library/src/test/java/org/mustangproject/ZUGFeRD/ZF2ZInvoiceImporterTest.java index 49c5ce78..02985e61 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); + } + + } @@ -445,6 +467,30 @@ public class ZF2ZInvoiceImporterTest extends ResourceCase { } + + @Test + public void testIBANparsing() throws XPathExpressionException, ParseException, FileNotFoundException { + + File inputFile = getResourceAsFile("cii/minimalDebit.xml"); + + ZUGFeRDInvoiceImporter importer = new ZUGFeRDInvoiceImporter(new FileInputStream(inputFile)); + Invoice invoice = importer.extractInvoice(); + assertEquals(1,invoice.getRecipient().getBankDetails().size()); + // IBAN belongs to recipient in invoice with sepa debit + assertEquals("DE21860000000086001055",invoice.getRecipient().getBankDetails().get(0).getIBAN()); + assertEquals(0,invoice.getSender().getBankDetails().size()); + + inputFile = getResourceAsFile("factur-x.xml"); + + importer = new ZUGFeRDInvoiceImporter(new FileInputStream(inputFile)); + invoice = importer.extractInvoice(); + assertEquals(1,invoice.getSender().getBankDetails().size()); + // IBAN belongs to sender in normal invoice + assertEquals("DE88200800000970375700",invoice.getSender().getBankDetails().get(0).getIBAN()); + assertEquals(0,invoice.getRecipient().getBankDetails().size()); + + } + @Test public void testImportPositionIncludedNotes() throws FileNotFoundException, XPathExpressionException, ParseException { File inputFile = getResourceAsFile("ZTESTZUGFERD_1_INVDSS_012015738820PDF-1.pdf"); 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; }