From d2ae0778b9cadc70d68f1c1fcc476fc991ef990f Mon Sep 17 00:00:00 2001 From: jstaerk Date: Fri, 24 Nov 2023 13:53:36 +0100 Subject: [PATCH] working on #347 --- History.md | 3 + doc/development_documentation.md | 8 +- .../ZUGFeRD/VisualizationTest.java | 8 +- .../validator/XMLValidator.java | 5 +- .../xslt/XR_30/XRechnung-CII-validation.xslt | 1541 +++++++++++++++++ 5 files changed, 1555 insertions(+), 10 deletions(-) create mode 100644 validator/src/main/resources/xslt/XR_30/XRechnung-CII-validation.xslt diff --git a/History.md b/History.md index f1ed8282..604ccbfc 100644 --- a/History.md +++ b/History.md @@ -1,4 +1,7 @@ + Missing closing tag in BankDetails when there's no BIC number #339 +Have a way to merge to PDF file without knowing if it is A-1 or A-3 #341 +Be able to validate XR 3.0 #347 2.8.0 ======= diff --git a/doc/development_documentation.md b/doc/development_documentation.md index 9e6c30e3..30a27c9b 100644 --- a/doc/development_documentation.md +++ b/doc/development_documentation.md @@ -17,7 +17,8 @@ You may already start developing what you wanted. Of course you can use any edit 2. fork -Once you can build, the idea is that you contribute patches via pull requests. For this you need a GitHub account and a personal copy of the repository to store your changes in. Just click fork on the mustangproject. On your copy you will have git write access. My suggestion as git client is sourcetree (I can send you instructions how to set it up). +Once you can build, the idea is that you contribute patches via pull requests. For this you need a GitHub account and a personal copy of the repository to store your changes in. Just click fork on the mustangproject. On your copy you will have git write access. My suggestion as git client is sourcetree. +There is a documentation [how to create pull requests from forks to the original repo](https://docs.github.com/de/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request-from-a-fork). 3. branch @@ -212,9 +213,8 @@ Afterwards you can access the release page and update the documentation, e.g. up ## Regular updates -XRechnung from https://github.com/itplr-kosit/xrechnung-schematron, -put in schematro, have xslt generated, potentially manually include -the included file +Take the most recent XRechnung release from https://github.com/itplr-kosit/xrechnung-schematron, +extract, rename xsl file to xslt, move to new version dir and add a if where the version is determined :-) ## Release process diff --git a/library/src/test/java/org/mustangproject/ZUGFeRD/VisualizationTest.java b/library/src/test/java/org/mustangproject/ZUGFeRD/VisualizationTest.java index 5a25099c..08f08276 100644 --- a/library/src/test/java/org/mustangproject/ZUGFeRD/VisualizationTest.java +++ b/library/src/test/java/org/mustangproject/ZUGFeRD/VisualizationTest.java @@ -144,9 +144,9 @@ out from git with arbitrary options (which may include CSRF changes) assertEquals(expected, result); } - public void testPDFVisualization() { +/* public void testPDFVisualization() { - // the writing part + // the writing part CIIToUBL c2u = new CIIToUBL(); String sourceFilename = "factur-x.xml"; File CIIinputFile = getResourceAsFile(sourceFilename); @@ -157,7 +157,7 @@ public void testPDFVisualization() { ZUGFeRDVisualizer zvi = new ZUGFeRDVisualizer(); /* remove file endings so that tests can also pass after checking out from git with arbitrary options (which may include CSRF changes) - */ + * zvi.toPDF(CIIinputFile.getAbsolutePath(), "c:\\users\\jstaerk\\temp\\fopy2.pdf"); } catch (UnsupportedOperationException e) { fail("UnsupportedOperationException should not happen: "+e.getMessage()); @@ -168,6 +168,6 @@ out from git with arbitrary options (which may include CSRF changes) // assertNotNull(result); // Reading ZUGFeRD // assertEquals(expected, result); - } + }*/ } diff --git a/validator/src/main/java/org/mustangproject/validator/XMLValidator.java b/validator/src/main/java/org/mustangproject/validator/XMLValidator.java index 478a86c0..4ff5b010 100644 --- a/validator/src/main/java/org/mustangproject/validator/XMLValidator.java +++ b/validator/src/main/java/org/mustangproject/validator/XMLValidator.java @@ -377,9 +377,10 @@ public void validateXR(String xml, ESeverity errorImpact) throws IrrecoverableVa validateSchematron(xml, "/xslt/XR_21/XRechnung-CII-validation.xslt", 27, errorImpact); } else if (xml.contains(":xrechnung_2.2")) { // This is the default check which is also run on en16931 files to generate notices. validateSchematron(xml, "/xslt/XR_22/XRechnung-CII-validation.xslt", 27, errorImpact); - } else { // This is the default check which is also run on en16931 files to generate notices. - // As of the next version this should probably if (xml.contains(":xrechnung_2.3")) + } else if (xml.contains(":xrechnung_2.3")) { // This is the default check which is also run on en16931 files to generate notices. validateSchematron(xml, "/xslt/XR_23/XRechnung-CII-validation.xslt", 27, errorImpact); + } else { // This is the default check which is also run on en16931 files to generate notices. + validateSchematron(xml, "/xslt/XR_30/XRechnung-CII-validation.xslt", 27, errorImpact); } } diff --git a/validator/src/main/resources/xslt/XR_30/XRechnung-CII-validation.xslt b/validator/src/main/resources/xslt/XR_30/XRechnung-CII-validation.xslt new file mode 100644 index 00000000..14b1a296 --- /dev/null +++ b/validator/src/main/resources/xslt/XR_30/XRechnung-CII-validation.xslt @@ -0,0 +1,1541 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 + + + + + + + + + ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + / + + + + + + *: + + [namespace-uri()=' + + '] + + + + [ + + ] + + + + / + + @ + + + @*[local-name()=' + + ' and namespace-uri()=' + + '] + + + + + + + + / + + + [ + + ] + + + + /@ + + + + + + + / + + + [ + + ] + + + + /@ + + + + + + + + + + + + + + + + + + + + + + + . + + + + U + + U + + + + U. + + n + + + + U. + + _ + + _ + + + + + + + + +   +   +   + + + + + + + + + + + + + variable-pattern + variable-pattern + + + + + + + + peppol-cii-pattern-1 + peppol-cii-pattern-1 + + + + + + + + peppol-cii-pattern-0-a + peppol-cii-pattern-0-a + + + + + + + + peppol-cii-pattern-0-b + peppol-cii-pattern-0-b + + + + + + + + cii-pattern + cii-pattern + + + + + + + + cii-extension-pattern + cii-extension-pattern + + + + + + + Schematron Version @xr-schematron.version.full@ - XRechnung @xrechnung.version@ compatible - CII + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + PEPPOL-EN16931-R001 + warning + + + + Business process MUST be provided. + + + + + + + + + + + + + + PEPPOL-EN16931-R005 + warning + + + + VAT accounting currency code MUST be different from invoice currency code when provided. + + + + + + + + + PEPPOL-EN16931-R053 + warning + + + + No more than one tax total amount must be provided where currency id equals document currency code. + + + + + + + + + PEPPOL-EN16931-R054 + warning + + + + Only one tax total amount must be provided where currency id equals tax currency code, if tax currency code (BT-6) is provided. + + + + + + + + + PEPPOL-EN16931-R055 + warning + + + + + + + + + + + + + + + + + + PEPPOL-EN16931-R010 + warning + + + + Buyer electronic address MUST be provided + + + + + + + + + + + + + + PEPPOL-EN16931-R020 + warning + + + + Seller electronic address MUST be provided + + + + + + + + + + + + + + PEPPOL-EN16931-R041 + warning + + + + Allowance/charge base + amount MUST be provided when allowance/charge percentage is provided. + + + + + + + + + + + + + + PEPPOL-EN16931-R042 + warning + + + + Allowance/charge percentage + MUST be provided when allowance/charge base amount is provided. + + + + + + + + + + + + + + PEPPOL-EN16931-R040 + warning + + + + Allowance/charge amount must equal base amount * percentage/100 if base amount and percentage exists + + + + + + + + + PEPPOL-EN16931-R043-1 + warning + + + + Allowance/charge ChargeIndicator value MUST equal 'true' or 'false' + + + + + + + + + + + + + + PEPPOL-EN16931-R043-2 + warning + + + + Allowance/charge ChargeIndicator value MUST equal 'true' or 'false' + + + + + + + + + + + + + + PEPPOL-EN16931-R061 + warning + + + + Mandate reference MUST be provided for direct debit. + + + + + + + + + + + + + + PEPPOL-EN16931-R110 + warning + + + + Start date of line period MUST be within invoice period. + + + + + + + + + + + + + + PEPPOL-EN16931-R111 + warning + + + + End date of line period MUST be within invoice period. + + + + + + + + + + + + + + + + + + + + PEPPOL-EN16931-R101 + warning + + + + Element Additional referenced document can only be used for Invoice line object. + + + + + + + + + + + + + + PEPPOL-EN16931-R121 + warning + + + + Base quantity MUST be a positive number above zero. + + + + + + + + + + + + + + PEPPOL-EN16931-R130 + warning + + + + Unit code of price base quantity MUST be same as invoiced quantity. + + + + + + + + + + + + + + + + + + + PEPPOL-EN16931-R008 + warning + + + + Document MUST not contain empty elements. + + + + + + + + + + + + + + + + + + + PEPPOL-EN16931-R044 + warning + + + + Charge on price level is NOT allowed. Only value 'false' allowed. + + + + + + + + + PEPPOL-EN16931-R046 + warning + + + + Item net price MUST equal (Gross price - Allowance amount) when gross price is provided. + + + + + + + + + + + + + + + + + + + + + + + BR-DE-30 + fatal + + + + [BR-DE-30] Wenn "DIRECT DEBIT" BG-19 vorhanden ist, dann muss "Bank assigned creditor identifier" BT-90 übermittelt werden. + + + + + + + + + BR-DE-31 + fatal + + + + [BR-DE-31] Wenn "DIRECT DEBIT" BG-19 vorhanden ist, dann muss "Debited account identifier" BT-91 übermittelt werden. + + + + + + + + + BR-DE-1 + fatal + + + + [BR-DE-1] Eine Rechnung (INVOICE) muss Angaben zu "PAYMENT INSTRUCTIONS" (BG-16) enthalten. + + + + + + + + + BR-DE-15 + fatal + + + + [BR-DE-15] Das Element "Buyer reference" (BT-10) muss übermittelt werden. + + + + + + + + + BR-DE-16 + fatal + + + + [BR-DE-16] Wenn in einer Rechnung die Steuercodes S, Z, E, AE, K, G, L oder M verwendet werden, muss mindestens eines der Elemente "Seller VAT identifier" (BT-31), "Seller tax registration identifier" (BT-32) + oder "SELLER TAX REPRESENTATIVE PARTY" (BG-11) übermittelt werden. + + + + + + + + + + BR-DE-17 + warning + + + + [BR-DE-17] Mit dem Element "Invoice type code" (BT-3) sollen ausschließlich folgende Codes aus der Codeliste UNTDID 1001 übermittelt werden: 326 (Partial invoice), 380 (Commercial invoice), 384 (Corrected invoice), 389 (Self-billed invoice) und 381 (Credit note),875 (Partial construction invoice), 876 (Partial final construction invoice), 877 (Final construction invoice). + + + + + + + + + BR-DE-18 + fatal + + + + [BR-DE-18] Skonto Zeilen in + + muessen diesem regulärem Ausdruck entsprechen: + + . Die Informationen zur Gewährung von Skonto müssen wie folgt im Element "Payment terms" (BT-20) übermittelt werden: Anzugeben ist im ersten Segment "SKONTO", im zweiten "TAGE=n", im dritten "PROZENT=n". Prozentzahlen sind ohne Vorzeichen sowie mit Punkt getrennt von zwei Nachkommastellen anzugeben. Liegt dem zu berechnenden Betrag nicht BT-115, "fälliger Betrag" zugrunde, sondern nur ein Teil des fälligen Betrags der Rechnung, ist der Grundwert zur Berechnung von Skonto als viertes Segment "BASISBETRAG=n" gemäß dem semantischen Datentypen Amount anzugeben. Jeder Eintrag beginnt mit einer #, die Segmente sind mit einer # getrennt und eine Zeile schließt mit einer # ab. Am Ende einer vollständigen Skontoangabe muss ein XML-konformer Zeilenumbruch folgen. Alle Angaben zur Gewährung von Skonto müssen in Großbuchstaben gemacht werden. Zusätzliches Whitespace (Leerzeichen, Tabulatoren oder Zeilenumbrüche) ist nicht zulässig. Andere Zeichen oder Texte als in den oberen Vorgaben genannt sind nicht zulässig. + + + + + + + + + BR-DE-22 + fatal + + + + [BR-DE-22] Not all filename attributes of the embeddedDocumentBinaryObject elements are unique + + + + + + + + + BR-DE-26 + warning + + + + [BR-DE-26] Wenn im Element Invoice type code (BT-3) der Code 384 (Corrected invoice) übergeben wird, soll PRECEDING INVOICE REFERENCE BG-3 mind. einmal vorhanden sein. + + + + + + + + + + + + + + BR-DE-21 + warning + + + + [BR-DE-21] Das Element "Specification identifier" (BT-24) soll syntaktisch der Kennung des Standards XRechnung entsprechen. + + + + + + + + + + + + + + BR-DE-2 + fatal + + + + [BR-DE-2] Die Gruppe "SELLER CONTACT" (BG-6) muss übermittelt werden. + + + + + + + + + + + + + + BR-DE-3 + fatal + + + + [BR-DE-3] Das Element "Seller city" (BT-37) muss übermittelt werden. + + + + + + + + + BR-DE-4 + fatal + + + + [BR-DE-4] Das Element "Seller post code" (BT-38) muss übermittelt werden. + + + + + + + + + + + + + + BR-DE-5 + fatal + + + + [BR-DE-5] Das Element "Seller contact point" (BT-41) muss übermittelt werden. + + + + + + + + + BR-DE-6 + fatal + + + + [BR-DE-6] Das Element "Seller contact telephone number" (BT-42) muss übermittelt werden. + + + + + + + + + BR-DE-7 + fatal + + + + [BR-DE-7] Das Element "Seller contact email address" (BT-43) muss übermittelt werden. + + + + + + + + + BR-DE-27 + warning + + + + [BR-DE-27] In BT-42 sollen mindestens drei Ziffern enthalten sein. + + + + + + + + + BR-DE-28 + warning + + + + [BR-DE-28] In BT-43 soll genau ein @-Zeichen enthalten sein, welches nicht von einem Leerzeichen, einem Punkt, aber mindestens zwei Zeichen auf beiden Seiten flankiert werden soll. Ein Punkt sollte nicht am Anfang oder am Ende stehen. + + + + + + + + + + + + + + BR-DE-8 + fatal + + + + [BR-DE-8] Das Element "Buyer city" (BT-52) muss übermittelt werden. + + + + + + + + + BR-DE-9 + fatal + + + + [BR-DE-9] Das Element "Buyer post code" (BT-53) muss übermittelt werden. + + + + + + + + + + + + + + BR-DE-10 + fatal + + + + [BR-DE-10] Das Element "Deliver to city" (BT-77) muss übermittelt werden, wenn die Gruppe "DELIVER TO ADDRESS" (BG-15) übermittelt wird. + + + + + + + + + BR-DE-11 + fatal + + + + [BR-DE-11] Das Element "Deliver to post code" (BT-78) muss übermittelt werden, wenn die Gruppe "DELIVER TO ADDRESS" (BG-15) übermittelt wird. + + + + + + + + + + + + + + BR-DE-19 + warning + + + + [BR-DE-19] "Payment account identifier" (BT-84) soll eine korrekte IBAN enthalten, wenn in "Payment means type code" (BT-81) mit dem Code 58 SEPA als Zahlungsmittel gefordert wird. + + + + + + + + + BR-DE-23-a + fatal + + + + [BR-DE-23-a] Wenn BT-81 "Payment means type code" einen Schlüssel für Überweisungen enthält (30, 58), muss BG-17 "CREDIT TRANSFER" übermittelt werden. + + + + + + + + + BR-DE-23-b + fatal + + + + [BR-DE-23-b] Wenn BT-81 "Payment means type code" einen Schlüssel für Überweisungen enthält (30, 58), dürfen BG-18 und BG-19 nicht übermittelt werden. + + + + + + + + + + + + + + BR-DE-24-a + fatal + + + + [BR-DE-24-a] Wenn BT-81 "Payment means type code" einen Schlüssel für Kartenzahlungen enthält (48, 54, 55), muss genau BG-18 "PAYMENT CARD INFORMATION" übermittelt werden. + + + + + + + + + BR-DE-24-b + fatal + + + + [BR-DE-24-b] Wenn BT-81 "Payment means type code" einen Schlüssel für Kartenzahlungen enthält (48, 54, 55), dürfen BG-17 und BG-19 nicht übermittelt werden. + + + + + + + + + + + + + + BR-DE-20 + warning + + + + [BR-DE-20] "Debited account identifier" (BT-91) soll eine korrekte IBAN enthalten, wenn in "Payment means type code" (BT-81) mit dem Code 59 SEPA als Zahlungsmittel gefordert wird. + + + + + + + + + BR-DE-25-a + fatal + + + + [BR-DE-25-a] Wenn BT-81 "Payment means type code" einen Schlüssel für Lastschriften enthält (59), muss genau BG-19 "DIRECT DEBIT" übermittelt werden. + + + + + + + + + BR-DE-25-b + fatal + + + + [BR-DE-25-b] Wenn BT-81 "Payment means type code" einen Schlüssel für Lastschriften enthält (59), dürfen BG-17 und BG-18 nicht übermittelt werden. + + + + + + + + + + + + + + BR-DE-14 + fatal + + + + [BR-DE-14] Das Element "VAT category rate" (BT-119) muss übermittelt werden. + + + + + + + + + + + + + + + + + + + + BR-DEX-15 + warning + + + + + [BR-DEX-15] This CII file might use the concept of Sub Invoice Lines. However XRechnung does not support this. + + + + + + + + + + + + + + + BR-DEX-04 + fatal + + + + [BR-DEX-04] Any scheme identifier in + + MUST be coded using one of the ISO 6523 ICD list. + + + + + + + + + + + + + + BR-DEX-05 + fatal + + + + [BR-DEX-05] Any scheme identifier in + + MUST be coded using one of the ISO 6523 ICD list. + + + + + + + + + + + + + + BR-DEX-06 + fatal + + + + [BR-DEX-06] Any scheme identifier in + + MUST be coded using one of the ISO 6523 ICD list. + + + + + + + + + + + + + + BR-DEX-07 + fatal + + + + [BR-DEX-07] Any scheme identifier for an Endpoint Identifier in + + MUST belong to the CEF EAS code list. + + + + + + + + + + + + + + BR-DEX-08 + fatal + + + + [BR-DEX-08] Any scheme identifier for a Delivery location identifier in + + MUST be coded using one of the ISO 6523 ICD list. + + + + + + + + + +