diff --git a/History.md b/History.md index 8585c2f4..732fe79e 100644 --- a/History.md +++ b/History.md @@ -1,3 +1,18 @@ +2.19.0 +======= +- #893 Tradeparty globalID is not read from JSON +- #902 Tests to use definted TZ (UTC) +- #905 Parse product level charges/discounts into JSON +- #869 Import Account Holder returns SellerTradeParty.name instead of AccountHolder +- #861 Multiple problems with Product.CountryOfOrigin +- #908 Validation: Make clear when embedded file name is wrong +- #909 +- #913 downgrade PDF/A errors to warnings +- #821 +- #911 +- #912 + + 2.18.0 ======= 2025-07-14 diff --git a/Mustang-CLI/pom.xml b/Mustang-CLI/pom.xml index 3a2ae520..22f41162 100644 --- a/Mustang-CLI/pom.xml +++ b/Mustang-CLI/pom.xml @@ -106,8 +106,10 @@ org.apache.maven.plugins maven-surefire-plugin + 3.5.3 alphabetical + -Duser.timezone=UTC diff --git a/doc/ZUV-Architektur.graphml b/doc/ZUV-Architektur.graphml index f1e1e09d..cf52259e 100644 --- a/doc/ZUV-Architektur.graphml +++ b/doc/ZUV-Architektur.graphml @@ -1,6 +1,6 @@ - + @@ -13,43 +13,37 @@ - + - + - PDF+XML - - - - - - + PDF+XML - + - + - ZUGFeRD + ZUGFeRD - + - Folder 2 + Folder 2 @@ -62,73 +56,55 @@ - + - Schematron files - - - - - - + Schematron files - + - Schema files - - - - - - + Schema files - + - Codelist XMLs - - - - - - + Codelist XMLs - + - + - EN16931 + EN16931 - + - Folder 3 + Folder 3 @@ -141,57 +117,45 @@ - + - CEF Codelist Excel - - - - - - + CEF Codelist Excel - + - CEN Schematron - - - - - - + CEN Schematron - + - + - UN/CEFACT + UN/CEFACT - + - Folder 4 + Folder 4 @@ -204,16 +168,10 @@ - + - Schema files - - - - - - + Schema files @@ -222,39 +180,33 @@ - + - XML Report - - - - - - + XML Report - + - + - ZUV + ZUV - + - Folder 5 + Folder 5 @@ -267,167 +219,113 @@ - + - PH-Schematron - - - - - - + PH-Schematron - + - XML - - - - - - + XML - + - Metadata - - - - - - + Metadata - + - Metadata check - - - - - - + Metadata check - + - XSLT files - - - - - - + XSLT files - + - XSLT files - - - - - - + XSLT files - + - Additional data - - - - - - + Additional data - + - Additional data check - - - - - - + Additional data check - + - PH-Schematron - - - - - - + PH-Schematron - + - + - Mustangproject + Mustangproject - + - Folder 1 + Folder 1 @@ -440,57 +338,45 @@ - + - PDFBox - - - - - - + PDFBox - + - Mustang - - - - - - + Mustang - + - + - VeraPDF + VeraPDF - + - Folder 6 + Folder 6 @@ -503,16 +389,10 @@ - + - VeraPDF - - - - - - + VeraPDF @@ -521,74 +401,66 @@ - + - Schema check - - - - - - + Schema check - + - XSLT files - - - - - - + XSLT files - + - PH-Schematron - - - - - - + PH-Schematron + + + + + + + + + + + Intra-line calculation - - + - + - XRechnung + XRechnung - + - Folder 7 + Folder 7 @@ -599,19 +471,12 @@ - - + - Schematron - - - - - - + Schematron @@ -621,8 +486,8 @@ - - + + @@ -634,8 +499,8 @@ - - + + @@ -647,8 +512,8 @@ - - + + @@ -660,8 +525,8 @@ - - + + @@ -683,8 +548,8 @@ - - + + @@ -696,8 +561,8 @@ - - + + @@ -729,8 +594,8 @@ - - + + @@ -742,8 +607,8 @@ - - + + @@ -754,7 +619,10 @@ - + + + + @@ -764,9 +632,9 @@ - - - + + + @@ -777,11 +645,9 @@ - - - - - + + + @@ -792,9 +658,9 @@ - - - + + + @@ -805,9 +671,9 @@ - - - + + + @@ -818,9 +684,9 @@ - - - + + + @@ -831,9 +697,9 @@ - - - + + + @@ -844,9 +710,9 @@ - - - + + + @@ -858,8 +724,8 @@ - - + + @@ -871,8 +737,8 @@ - - + + @@ -884,8 +750,8 @@ - - + + @@ -896,9 +762,9 @@ - - - + + + @@ -910,8 +776,8 @@ - - + + @@ -923,8 +789,8 @@ - - + + @@ -933,13 +799,12 @@ - - + - - + + @@ -948,11 +813,13 @@ - - + - + + + + @@ -960,13 +827,12 @@ - - + - - + + @@ -975,11 +841,43 @@ - + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + diff --git a/doc/ZUV-Architektur.svg b/doc/ZUV-Architektur.svg index f3eda531..5b4bab18 100644 --- a/doc/ZUV-Architektur.svg +++ b/doc/ZUV-Architektur.svg @@ -1,1117 +1,6098 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + + + + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + - + - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - PDF+XML + PDF+XML - + - + - ZUGFeRD - + ZUGFeRD + - - - - - - - - - - - + + + + + + + + + + + - Schematron files + Schematron files - - - - - - - - - - - + + + + + + + + + + + - Schema files + Schema files - - - - - - - - - - - + + + + + + + + + + + - Codelist XMLs + Codelist XMLs - - + + - EN16931 - + EN16931 + - - - - - - - - - - - + + + + + + + + + + + - CEF Codelist Excel + CEF Codelist Excel - - - - - - - - - - - + + + + + + + + + + + - CEN Schematron + CEN Schematron - - + + - - + + - UN/CEFACT - + UN/CEFACT + - - - - - - - - - - - + + + + + + + + + + + - Schema files + Schema files - - - - + + + + - XML Report + XML Report - - + + - - + + - ZUV - + ZUV + - - - - - - - - - - - + + + + + + + + + + + - PH-Schematron + PH-Schematron - - - - - - - - - - - + + + + + + + + + + + - XML + XML - - - - - - - - - - - + + + + + + + + + + + - Metadata + Metadata - - - - - - - - - - - + + + + + + + + + + + - Metadata check + Metadata check - - - - - - - - - - - + + + + + + + + + + + - XSLT files + XSLT files - - - - - - - - - - - + + + + + + + + + + + - XSLT files + XSLT files - - - - - - - - - - - + + + + + + + + + + + - Additional data + Additional data - - - - - - - - - - - + + + + + + + + + + + - Additional data check + Additional data check - - - - - - - - - - - + + + + + + + + + + + - PH-Schematron + PH-Schematron - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + - Mustangproject - + Mustangproject + - - - - - - - - - - - + + + + + + + + + + + - PDFBox + PDFBox - - - - - - - - - - - + + + + + + + + + + + - Mustang + Mustang - - - - - - - - - - + + + + + + + + + + - - + + - VeraPDF - + VeraPDF + - - - - - - - - - - - + + + + + + + + + + + - VeraPDF + VeraPDF - - - - - - - - - - - + + + + + + + + + + + - Schema check + Schema check - - - - - - - - - - - + + + + + + + + + + + - XSLT files + XSLT files - - - - - - - - - - - + + + + + + + + + + + - PH-Schematron + PH-Schematron + + + + + + + + + + + + + + + + + + + Intra-line calculation - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + - - + + - XRechnung - + XRechnung + - - - - + + + + - Schematron + Schematron - - + + diff --git a/doc/development_documentation.md b/doc/development_documentation.md index c08c457c..b73b437f 100644 --- a/doc/development_documentation.md +++ b/doc/development_documentation.md @@ -57,12 +57,26 @@ to validate the XML part of the invoices. ![Architecture of the validator](ZUV-Architektur.svg "Graph of the architecture of the validator component") -## New build +## Aspects +Apart from the fact that apart from +* the code +* we need tests and apart from implementing it in -Target platform is java 1.17 +* the interface +* usually we need functionality in or via the invoice class. + +Reading should work for both +* CII and +* UBL + +And when writing, +* it should be readable as well, usually in the invoiceimporter, +* and it should be readable and writeable via Jackson (i.e. JSON) ## Build +Target platform is java 1.17 + The package can be build with ``` mvnw clean package @@ -184,7 +198,7 @@ maybe not yet even existing new release version: ``` cd validator/target -mvn install:install-file -Dfile=validator-2.17.0-SNAPSHOT-shaded.jar -Dclassifier=shaded -DgroupId="org.mustangproject" -DartifactId=validator -Dversion="2.17.0" -Dpackaging=jar -DgeneratePom=true +mvn install:install-file -Dfile="validator-2.17.0-SNAPSHOT-shaded.jar" -Dclassifier=shaded -DgroupId="org.mustangproject" -DartifactId=validator -Dversion="2.17.0" -Dpackaging=jar -DgeneratePom=true ``` In gradle you can use something like ``` diff --git a/library/pom.xml b/library/pom.xml index 55bf65f5..10442661 100644 --- a/library/pom.xml +++ b/library/pom.xml @@ -179,8 +179,10 @@ org.apache.maven.plugins maven-surefire-plugin + 3.5.3 alphabetical + -Duser.timezone=UTC diff --git a/library/src/main/java/org/mustangproject/Item.java b/library/src/main/java/org/mustangproject/Item.java index c062e620..b8afa6be 100644 --- a/library/src/main/java/org/mustangproject/Item.java +++ b/library/src/main/java/org/mustangproject/Item.java @@ -120,10 +120,16 @@ public class Item implements IZUGFeRDExportableItem { itemMap.getAsString("ID") .ifPresent(this::setId); - itemMap.getAsString("Note") .ifPresent(this::addNote); + if (product==null) { // CII + if (itemMap.getNode("SpecifiedTradeProduct").isPresent()) { + product = new Product(itemMap.getNode("SpecifiedTradeProduct").get()); + } else { + product = new Product(); + } + } itemMap.getAsNodeMap("SpecifiedLineTradeAgreement", "SpecifiedSupplyChainTradeAgreement").ifPresent(icnm -> { icnm.getAsNodeMap("BuyerOrderReferencedDocument") @@ -138,14 +144,29 @@ public class Item implements IZUGFeRDExportableItem { npptpNodes.getAsBigDecimal("ChargeAmount").ifPresent(this::setPrice); npptpNodes.getAsBigDecimal("BasisQuantity").ifPresent(this::setBasisQuantity); }); + icnm.getAsNodeMap("GrossPriceProductTradePrice").ifPresent(gpptpNodes -> { + gpptpNodes.getAsNodeMap("AppliedTradeAllowanceCharge").ifPresent(gpptpAtacNodes -> { + /** mustang attributes differences between net and gross price to the product */ + String chargeIndicator = gpptpAtacNodes.getAsStringOrNull("ChargeIndicator"); + if ((chargeIndicator != null)&&(gpptpAtacNodes.getAsBigDecimal("ActualAmount").isPresent())) { + BigDecimal actual = gpptpAtacNodes.getAsBigDecimal("ActualAmount").get(); + if (chargeIndicator.equals("true")) { + product.addCharge(new Charge(actual)); + setPrice(getPrice().subtract(actual)); // the gross price affects the net price, which is read, + // so if we do not ignore charges|allowances we have to re-compensate the net price + } else { + product.addAllowance(new Allowance(actual)); + setPrice(getPrice().add(actual)); + } + + } + }); + }); icnm.getAllNodes("AdditionalReferencedDocument").map(ReferencedDocument::fromNode). forEach(this::addReferencedDocument); }); - itemMap.getNode("SpecifiedTradeProduct").map(Product::new).ifPresent(this::setProduct);//CII - itemMap.getNode("SpecifiedTradeProduct").map(Product::new).ifPresent(this::setProduct);//UBL - // RequestedQuantity is for Order-X, BilledQuantity for FX and ZF itemMap.getAsNodeMap("SpecifiedLineTradeDelivery", "SpecifiedSupplyChainTradeDelivery") .flatMap(icnm -> icnm.getNode("BilledQuantity", "RequestedQuantity", "DespatchedQuantity")) @@ -182,7 +203,7 @@ public class Item implements IZUGFeRDExportableItem { } if (amountString != null) { izac.setTotalAmount(new BigDecimal(amountString)); - if (percentString!=null&&(!percentString.equals("0"))) { + if (percentString != null && (!percentString.equals("0"))) { izac.setTotalAmount(new BigDecimal(amountString).divide(getQuantity())); } } @@ -221,7 +242,7 @@ public class Item implements IZUGFeRDExportableItem { }); }); - itemMap.getAllNodes("AllowanceCharge").map(NodeMap::new).forEach(stac -> { //UBL + itemMap.getAllNodes("AllowanceCharge").map(NodeMap::new).forEach(stac -> { //CII String isChargeString = stac.getAsString("ChargeIndicator").get(); String percentString = stac.getAsStringOrNull("MultiplierFactorNumeric"); @@ -304,14 +325,16 @@ public class Item implements IZUGFeRDExportableItem { } @JsonIgnore - @Override public IZUGFeRDAllowanceCharge[] getAllowances() { // in JSON is already returned as itemAllowances (and only read from there) - IZUGFeRDAllowanceCharge[] izac=new IZUGFeRDAllowanceCharge[Allowances.size()]; + @Override + public IZUGFeRDAllowanceCharge[] getAllowances() { // in JSON is already returned as itemAllowances (and only read from there) + IZUGFeRDAllowanceCharge[] izac = new IZUGFeRDAllowanceCharge[Allowances.size()]; return Allowances.toArray(izac); } @JsonIgnore - @Override public IZUGFeRDAllowanceCharge[] getCharges() { // in JSON is already returned as itemAllowances (and only read from there) - IZUGFeRDAllowanceCharge[] izac=new IZUGFeRDAllowanceCharge[Charges.size()]; + @Override + public IZUGFeRDAllowanceCharge[] getCharges() { // in JSON is already returned as itemAllowances (and only read from there) + IZUGFeRDAllowanceCharge[] izac = new IZUGFeRDAllowanceCharge[Charges.size()]; return Charges.toArray(izac); } diff --git a/library/src/main/java/org/mustangproject/Product.java b/library/src/main/java/org/mustangproject/Product.java index 93e48a79..467fbb60 100644 --- a/library/src/main/java/org/mustangproject/Product.java +++ b/library/src/main/java/org/mustangproject/Product.java @@ -1,13 +1,10 @@ package org.mustangproject; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.*; import org.mustangproject.ZUGFeRD.IDesignatedProductClassification; import org.mustangproject.ZUGFeRD.IZUGFeRDExportableProduct; import org.mustangproject.util.NodeMap; import org.w3c.dom.Node; -import org.w3c.dom.NodeList; import java.math.BigDecimal; import java.util.ArrayList; @@ -107,7 +104,10 @@ public class Product implements IZUGFeRDExportableProduct { classifications.add(new DesignatedProductClassification(classCode, className))); }); - nodeMap.getAsString("OriginTradeCounty").ifPresent(this::setCountryOfOrigin); + nodeMap.getAsNodeMap("OriginTradeCountry") + .flatMap(nodes -> nodes.getNode("ID")) + .map(Node::getTextContent) + .ifPresent(this::setCountryOfOrigin); } /*** @@ -406,6 +406,16 @@ public class Product implements IZUGFeRDExportableProduct { return this; } + + /*** + * Jackson courtesy function, please use addCharge if you have the choice + * @return array of or null, if none + */ + public Product setCharges(ArrayList charges) { + this.charges=charges; + return this; + } + /*** * returns the AppliedTradeAllowanceCharges of this product which are actually Charges * @return array of or null, if none @@ -432,5 +442,13 @@ public class Product implements IZUGFeRDExportableProduct { return allowances.toArray(allowanceArr); } + /*** + * Jackson courtesy function, please use addAllowance if you have the choice + * @return array of or null, if none + */ + public Product setAllowances(ArrayList allowances) { + this.allowances=allowances; + return this; + } } diff --git a/library/src/main/java/org/mustangproject/TradeParty.java b/library/src/main/java/org/mustangproject/TradeParty.java index f25b4065..72cd1959 100644 --- a/library/src/main/java/org/mustangproject/TradeParty.java +++ b/library/src/main/java/org/mustangproject/TradeParty.java @@ -543,6 +543,32 @@ public class TradeParty implements IZUGFeRDExportableTradeParty { return this; } + /*** + * for jackson, primarily, use addGlobalID(SchemedID) instead + * @param ID the id part without scheme + * @return fluent setter + */ + public TradeParty setGlobalID(String ID) { + if (globalId==null) { + globalId=new SchemedID(); + } + globalId.setId(ID); + return this; + } + + /*** + * for jackson, primarily, use addGlobalID(SchemedID) instead + * @param scheme the scheme part without id + * @return fluent setter + */ + public TradeParty setGlobalIDScheme(String scheme) { + if (globalId==null) { + globalId=new SchemedID(); + } + globalId.setScheme(scheme); + return this; + } + public TradeParty addGlobalID(SchemedID schemedID) { globalId = schemedID; return this; diff --git a/library/src/main/java/org/mustangproject/ZUGFeRD/ValidationLogVisualizer.java b/library/src/main/java/org/mustangproject/ZUGFeRD/ValidationLogVisualizer.java index 7e7d8a17..17c3e1ea 100644 --- a/library/src/main/java/org/mustangproject/ZUGFeRD/ValidationLogVisualizer.java +++ b/library/src/main/java/org/mustangproject/ZUGFeRD/ValidationLogVisualizer.java @@ -130,9 +130,6 @@ public class ValidationLogVisualizer { TransformerFactory factory = TransformerFactory.newInstance(); factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true); - factory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true); - factory.setFeature("http://xml.org/sax/features/external-general-entities", false); - factory.setFeature("http://xml.org/sax/features/external-parameter-entities", false); Transformer transformer = factory.newTransformer(); // identity transformer // Step 5: Setup input and output for XSLT transformation diff --git a/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRD2PullProvider.java b/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRD2PullProvider.java index f990086a..28c390ac 100644 --- a/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRD2PullProvider.java +++ b/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRD2PullProvider.java @@ -219,7 +219,7 @@ public class ZUGFeRD2PullProvider implements IXMLProvider { xml += "" + XMLTools.encodeXML(party.getCountry()) + "" + ""; - if (party.getUriUniversalCommunicationID() != null && party.getUriUniversalCommunicationIDScheme() != null) { + if (party.getUriUniversalCommunicationID() != null && party.getUriUniversalCommunicationIDScheme() != null && (!isShipToTradeParty)) { xml += "" + "" + XMLTools.encodeXML(party.getUriUniversalCommunicationID()) @@ -462,10 +462,8 @@ public class ZUGFeRD2PullProvider implements IXMLProvider { } xml += "" + XMLTools.encodeXML(currentItem.getProduct().getName()) + ""; - if (currentItem.getProduct().getDescription() != null) { - xml += "" + - XMLTools.encodeXML(currentItem.getProduct().getDescription()) + - ""; + if (currentItem.getProduct().getDescription() != null && !currentItem.getProduct().getDescription().isEmpty()) { + xml += "" + XMLTools.encodeXML(currentItem.getProduct().getDescription()) + ""; } if (currentItem.getProduct().getClassifications() != null) { for (IDesignatedProductClassification classification : currentItem.getProduct().getClassifications()) { diff --git a/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDImporter.java b/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDImporter.java index af03cfa7..7de7415e 100644 --- a/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDImporter.java +++ b/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDImporter.java @@ -352,6 +352,16 @@ public class ZUGFeRDImporter extends ZUGFeRDInvoiceImporter { public String getHolder() { + if (importedInvoice!=null && importedInvoice.getTradeSettlement()!=null) { + for (IZUGFeRDTradeSettlement settlement : importedInvoice.getTradeSettlement()) { + if (settlement instanceof IZUGFeRDTradeSettlementPayment) { + String s = ((IZUGFeRDTradeSettlementPayment) settlement).getAccountName(); + if ( s != null ) { + return s; + } + } + } + } return extractString("//*[local-name() = 'SellerTradeParty']/*[local-name() = 'Name']"); } diff --git a/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDInvoiceImporter.java b/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDInvoiceImporter.java index ea4616fa..f2a8ae9a 100644 --- a/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDInvoiceImporter.java +++ b/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDInvoiceImporter.java @@ -1,6 +1,5 @@ package org.mustangproject.ZUGFeRD; -import javax.xml.XMLConstants; import org.apache.commons.io.IOUtils; import org.apache.pdfbox.Loader; import org.apache.pdfbox.pdmodel.PDDocument; @@ -9,8 +8,21 @@ import org.apache.pdfbox.pdmodel.PDEmbeddedFilesNameTreeNode; import org.apache.pdfbox.pdmodel.common.PDNameTreeNode; import org.apache.pdfbox.pdmodel.common.filespecification.PDComplexFileSpecification; import org.apache.pdfbox.pdmodel.common.filespecification.PDEmbeddedFile; -import org.mustangproject.*; +import org.mustangproject.Allowance; +import org.mustangproject.BankDetails; +import org.mustangproject.CalculatedInvoice; +import org.mustangproject.Charge; +import org.mustangproject.DirectDebit; +import org.mustangproject.EStandard; import org.mustangproject.Exceptions.StructureException; +import org.mustangproject.FileAttachment; +import org.mustangproject.IncludedNote; +import org.mustangproject.Invoice; +import org.mustangproject.Item; +import org.mustangproject.ReferencedDocument; +import org.mustangproject.SchemedID; +import org.mustangproject.TradeParty; +import org.mustangproject.XMLTools; import org.mustangproject.util.NodeMap; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -19,11 +31,19 @@ import org.w3c.dom.Node; import org.w3c.dom.NodeList; import org.xml.sax.SAXException; +import javax.xml.XMLConstants; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; -import javax.xml.xpath.*; -import java.io.*; +import javax.xml.xpath.XPath; +import javax.xml.xpath.XPathConstants; +import javax.xml.xpath.XPathExpression; +import javax.xml.xpath.XPathExpressionException; +import javax.xml.xpath.XPathFactory; +import java.io.BufferedInputStream; +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; import java.math.BigDecimal; import java.nio.charset.StandardCharsets; import java.nio.file.Files; @@ -31,7 +51,16 @@ import java.nio.file.Paths; import java.nio.file.StandardOpenOption; import java.text.ParseException; import java.text.SimpleDateFormat; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Base64; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import java.util.Set; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -71,6 +100,7 @@ public class ZUGFeRDInvoiceImporter { protected CalculatedInvoice importedInvoice = null; protected boolean recalcPrice = false; protected boolean ignoreCalculationErrors = false; + protected boolean containsAXMLFileAttachment = false; public ZUGFeRDInvoiceImporter() { //constructor for extending classes @@ -126,8 +156,7 @@ public class ZUGFeRDInvoiceImporter { if (Arrays.equals(pad, pdfSignature)) { // we have a pdf - try { - PDDocument doc = Loader.loadPDF(IOUtils.toByteArray(pdfStream)); + try (PDDocument doc = Loader.loadPDF(IOUtils.toByteArray(pdfStream))) { // PDDocumentInformation info = doc.getDocumentInformation(); final PDDocumentNameDictionary names = new PDDocumentNameDictionary(doc.getDocumentCatalog()); //start @@ -175,7 +204,7 @@ public class ZUGFeRDInvoiceImporter { containsMeta = true; try { setRawXML(XMLTools.getBytesFromStream(pdfStream)); - } catch(ParseException e) { + } catch (ParseException e) { LOGGER.error("Failed to parse PDF", e); } @@ -198,16 +227,32 @@ public class ZUGFeRDInvoiceImporter { ignoreCalculationErrors = true; } + + /*** + * if the file attachment is not in the list of allowed file names we can't import the XML, + * but the validator needs to know if maybe some other .xml-File is embedded because it would + * raise an additional notice that the filename is probably wrong + * + * @return + */ + public boolean hasXMLFileAttachment() { + return containsAXMLFileAttachment; + } + /*** * sets th pdf attachments, and if a file is recognized (e.g. a factur-x.xml) triggers processing * @param names the Hashmap of String, PDComplexFileSpecification * @throws IOException */ private void extractFiles(Map names) throws IOException { + containsAXMLFileAttachment = false; for (final String alias : names.keySet()) { final PDComplexFileSpecification fileSpec = names.get(alias); final String filename = fileSpec.getFilename(); + if (filename.toUpperCase().endsWith(".XML")) { + containsAXMLFileAttachment = true; + } /** * filenames for invoice data (ZUGFeRD v1 and v2, Factur-X) */ @@ -508,7 +553,8 @@ public class ZUGFeRDInvoiceImporter { for (int issueDateChildIndex = 0; issueDateChildIndex < issueDateTimeChilds.getLength(); issueDateChildIndex++) { if ((issueDateTimeChilds.item(issueDateChildIndex).getLocalName() != null) && (issueDateTimeChilds.item(issueDateChildIndex).getLocalName().equals("DateTimeString"))) { - issueDate = new SimpleDateFormat("yyyyMMdd").parse(XMLTools.trimOrNull(issueDateTimeChilds.item(issueDateChildIndex))); + String issueDateString = XMLTools.trimOrNull(issueDateTimeChilds.item(issueDateChildIndex)); + issueDate = parseDate(issueDateString, "yyyyMMdd"); } } } @@ -567,15 +613,15 @@ public class ZUGFeRDInvoiceImporter { 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.isEmpty()) { - issueDate = new SimpleDateFormat("yyyy-MM-dd").parse(issueDateStr); + issueDate = parseDate(issueDateStr, "yyyy-MM-dd"); } String dueDt = extractString("/*[local-name()=\"Invoice\" or local-name()=\"CreditNote\"]/*[local-name()=\"DueDate\"]").trim(); if (!dueDt.isEmpty()) { - dueDate = new SimpleDateFormat("yyyy-MM-dd").parse(dueDt); + dueDate = parseDate(dueDt, "yyyy-MM-dd"); } String deliveryDt = extractString("//*[local-name()=\"Delivery\"]/*[local-name()=\"ActualDeliveryDate\"]").trim(); if (!deliveryDt.isEmpty()) { - deliveryDate = new SimpleDateFormat("yyyy-MM-dd").parse(deliveryDt); + deliveryDate = parseDate(deliveryDt, "yyyy-MM-dd"); } } @@ -605,7 +651,8 @@ public class ZUGFeRDInvoiceImporter { for (int occurenceChildIndex = 0; occurenceChildIndex < occurenceChilds.getLength(); occurenceChildIndex++) { if ((occurenceChilds.item(occurenceChildIndex).getLocalName() != null) && (occurenceChilds.item(occurenceChildIndex).getLocalName().equals("DateTimeString"))) { - deliveryDate = new SimpleDateFormat("yyyyMMdd").parse(XMLTools.trimOrNull(occurenceChilds.item(occurenceChildIndex))); + String deliveryDateString = XMLTools.trimOrNull(occurenceChilds.item(occurenceChildIndex)); + deliveryDate = parseDate(deliveryDateString, "yyyyMMdd"); } } } @@ -699,7 +746,8 @@ public class ZUGFeRDInvoiceImporter { NodeList dueDateChilds = paymentTermChilds.item(paymentTermChildIndex).getChildNodes(); for (int dueDateChildIndex = 0; dueDateChildIndex < dueDateChilds.getLength(); dueDateChildIndex++) { if ((dueDateChilds.item(dueDateChildIndex).getLocalName() != null) && (dueDateChilds.item(dueDateChildIndex).getLocalName().equals("DateTimeString"))) { - dueDate = new SimpleDateFormat("yyyyMMdd").parse(XMLTools.trimOrNull(dueDateChilds.item(dueDateChildIndex))); + String dueDateString = XMLTools.trimOrNull(dueDateChilds.item(dueDateChildIndex)); + dueDate = parseDate(dueDateString, "yyyyMMdd"); } } } @@ -752,7 +800,7 @@ public class ZUGFeRDInvoiceImporter { if (BIC != null) { bd.setBIC(BIC); } - if (accountName!=null) { + if (accountName != null) { bd.setAccountName(accountName); } bankDetails.add(bd); @@ -788,7 +836,7 @@ public class ZUGFeRDInvoiceImporter { NodeList periodNodes = (NodeList) xpr.evaluate(getDocument(), XPathConstants.NODESET); for (int periodChildIndex = 0; periodChildIndex < periodNodes.getLength(); periodChildIndex++) { - String localName=periodNodes.item(periodChildIndex).getLocalName(); + String localName = periodNodes.item(periodChildIndex).getLocalName(); if ((localName != null) && (periodNodes.item(periodChildIndex).getLocalName().equals("StartDate"))) { deliveryPeriodStart = XMLTools.trimOrNull(periodNodes.item(periodChildIndex)); } @@ -839,7 +887,7 @@ public class ZUGFeRDInvoiceImporter { } if (IBAN != null) { BankDetails bd = new BankDetails(IBAN); - if (accountName!=null) { + if (accountName != null) { bd.setAccountName(accountName); } bankDetails.add(bd); @@ -989,7 +1037,7 @@ public class ZUGFeRDInvoiceImporter { } else if (chargeChildName.equals("ActualAmount") || chargeChildName.equals("Amount")) { chargeAmount = XMLTools.trimOrNull(chargeNodeChilds.item(chargeChildIndex)); - } else if (chargeChildName.equals("BasisAmount")) { + } else if (chargeChildName.equals("BasisAmount")) { basisAmount = XMLTools.trimOrNull(chargeNodeChilds.item(chargeChildIndex)); } else if (chargeChildName.equals("Reason") || chargeChildName.equals("AllowanceChargeReason")) { reason = XMLTools.trimOrNull(chargeNodeChilds.item(chargeChildIndex)); @@ -1104,6 +1152,18 @@ public class ZUGFeRDInvoiceImporter { } + private Date parseDate(String issueDateString, String datePattern) throws ParseException { + Date parsedDate = null; + if (issueDateString != null) { + try { + parsedDate = new SimpleDateFormat(datePattern).parse(issueDateString); + } catch (ParseException e) { + LOGGER.warn("Failed to parse date {} with pattern {}", issueDateString, datePattern, e); + } + } + return parsedDate; + } + protected Document getDocument() { return document; } @@ -1186,7 +1246,7 @@ public class ZUGFeRDInvoiceImporter { */ @Deprecated public List getFileAttachmentsXML() { - if (importedInvoice.getAdditionalReferencedDocuments()!=null) { + if (importedInvoice.getAdditionalReferencedDocuments() != null) { return new ArrayList<>(Arrays.asList(importedInvoice.getAdditionalReferencedDocuments())); } else { return new ArrayList<>(); @@ -1213,7 +1273,7 @@ public class ZUGFeRDInvoiceImporter { * sets the XML for the importer to parse * @param XML the UBL or CII */ - public void fromXML(String XML) throws ParseException{ + public void fromXML(String XML) throws ParseException { try { containsMeta = true; setRawXML(XML.getBytes(StandardCharsets.UTF_8)); diff --git a/library/src/test/java/org/mustangproject/ZUGFeRD/CalculationTest.java b/library/src/test/java/org/mustangproject/ZUGFeRD/CalculationTest.java index ebdcf643..f386d655 100644 --- a/library/src/test/java/org/mustangproject/ZUGFeRD/CalculationTest.java +++ b/library/src/test/java/org/mustangproject/ZUGFeRD/CalculationTest.java @@ -106,14 +106,14 @@ public class CalculationTest extends ResourceCase { Product product; Item item; - product = new Product("Pens", "", "H84", new BigDecimal(25)); + product = new Product("Pens", "", "H87", new BigDecimal(25)); product.addAllowance(new Allowance(new BigDecimal(1))); item = new Item(product, new BigDecimal("9.50"), new BigDecimal(25)); item.addCharge(new Charge(new BigDecimal(10)).setReasonCode("ZZZ").setReason("Zuschlag")); LineCalculator lc = new LineCalculator(item); assertEquals(new BigDecimal("222.50"), lc.getItemTotalNetAmount()); invoice.addItem(item); - product = new Product("Paper", "", "H84", new BigDecimal(25)); + product = new Product("Paper", "", "H87", new BigDecimal(25)); item = new Item(product, new BigDecimal("4.50"), new BigDecimal(15)); item.addAllowance(new Allowance().setPercent(new BigDecimal(5)).setReasonCode("ZZZ").setReason("Zuschlag")); lc = new LineCalculator(item); @@ -201,7 +201,7 @@ public class CalculationTest extends ResourceCase { Product product; Item item; - product = new Product("AAA", "", "H84", sales_tax_percent1).setSellerAssignedID("1AAA"); + product = new Product("AAA", "", "H87", sales_tax_percent1).setSellerAssignedID("1AAA"); item = new Item(product, new BigDecimal("4.750"), new BigDecimal(5.00)); // set values for additional charge and discount used for next lines @@ -218,19 +218,19 @@ public class CalculationTest extends ResourceCase { invoice.addItem(item); - product = new Product("BBB", "", "H84", sales_tax_percent1).setSellerAssignedID("2BBB"); + product = new Product("BBB", "", "H87", sales_tax_percent1).setSellerAssignedID("2BBB"); item = new Item(product, new BigDecimal("5.750"), new BigDecimal(4.00)); invoice.addItem(item); - product = new Product("CCC", "", "H84", sales_tax_percent1).setSellerAssignedID("3CCC"); + product = new Product("CCC", "", "H87", sales_tax_percent1).setSellerAssignedID("3CCC"); item = new Item(product, new BigDecimal("6.750"), new BigDecimal(3.00)); invoice.addItem(item); - product = new Product("DDD", "", "H84", sales_tax_percent1).setSellerAssignedID("4DDD"); + product = new Product("DDD", "", "H87", sales_tax_percent1).setSellerAssignedID("4DDD"); item = new Item(product, new BigDecimal("7.750"), new BigDecimal(2.00)); invoice.addItem(item); - product = new Product("EEE", "", "H84", sales_tax_percent1).setSellerAssignedID("5EEE"); + product = new Product("EEE", "", "H87", sales_tax_percent1).setSellerAssignedID("5EEE"); item = new Item(product, new BigDecimal("8.750"), new BigDecimal(1.00)); invoice.addItem(item); @@ -277,7 +277,7 @@ public class CalculationTest extends ResourceCase { Product product; Item item; - product = new Product("AAA", "", "H84", BigDecimal.ZERO); + product = new Product("AAA", "", "H87", BigDecimal.ZERO); item = new Item(product, new BigDecimal("1.10"), new BigDecimal(5.00)); item.addAllowance(new Allowance().setPercent(new BigDecimal(10)).setTaxPercent(BigDecimal.ZERO)); @@ -369,7 +369,7 @@ public class CalculationTest extends ResourceCase { Product product; Item item; - product = new Product("AAA", "", "H84", BigDecimal.ZERO); + product = new Product("AAA", "", "H87", BigDecimal.ZERO); item = new Item(product, new BigDecimal("1.00"), new BigDecimal(5.00)); item.addAllowance(new Allowance(new BigDecimal(1)).setTaxPercent(BigDecimal.ZERO)); diff --git a/library/src/test/java/org/mustangproject/ZUGFeRD/DeSerializationTest.java b/library/src/test/java/org/mustangproject/ZUGFeRD/DeSerializationTest.java index e527021e..6f0a910c 100644 --- a/library/src/test/java/org/mustangproject/ZUGFeRD/DeSerializationTest.java +++ b/library/src/test/java/org/mustangproject/ZUGFeRD/DeSerializationTest.java @@ -21,6 +21,13 @@ */ package org.mustangproject.ZUGFeRD; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.junit.FixMethodOrder; +import org.junit.runners.MethodSorters; +import org.mustangproject.*; +import org.mustangproject.ZUGFeRD.model.EventTimeCodeTypeConstants; + import java.io.File; import java.io.IOException; import java.math.BigDecimal; @@ -29,28 +36,11 @@ import java.nio.file.Files; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; -import java.util.TimeZone; import javax.xml.xpath.XPathExpressionException; -import org.junit.FixMethodOrder; -import org.junit.experimental.theories.FromDataPoints; -import org.junit.runners.MethodSorters; -import org.mustangproject.Allowance; -import org.mustangproject.BankDetails; -import org.mustangproject.CalculatedInvoice; -import org.mustangproject.CashDiscount; -import org.mustangproject.Charge; -import org.mustangproject.Contact; -import org.mustangproject.Invoice; -import org.mustangproject.Item; -import org.mustangproject.Product; -import org.mustangproject.SchemedID; -import org.mustangproject.TradeParty; -import org.mustangproject.ZUGFeRD.model.EventTimeCodeTypeConstants; +import static org.assertj.core.api.Assertions.assertThat; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; @FixMethodOrder(MethodSorters.NAME_ASCENDING) public class DeSerializationTest extends ResourceCase { @@ -71,6 +61,29 @@ public class DeSerializationTest extends ResourceCase { } + public void testProduct() throws IOException, XPathExpressionException, ParseException { + File inputCII = getResourceAsFile("Extended_fremdwaehrung.xml"); + var zii = new ZUGFeRDInvoiceImporter(); + zii.doIgnoreCalculationErrors(); + zii.fromXML(Files.readString(inputCII.toPath())); + var product = zii.extractInvoice() + .getZFItems()[0] + .getProduct(); + + assertThat(product.getCountryOfOrigin()).as("Product Country of origin") + .isEqualTo("DE"); + assertThat(product.getSellerAssignedID()).as("Product Seller assigned ID") + .isEqualTo("CO-123/V2A"); + assertThat(product.getBuyerAssignedID()).as("Product Buyer assigned ID") + .isEqualTo("Toolbox 0815"); + assertThat(product.getName()).as("Name") + .isEqualTo("Stahlcoil"); + + assertThat(product.getAttributes()).as("Product attributes") + .containsKey("LeoID") + .containsValue("704310.0105636504"); + } + public void testInvoiceLine() throws JsonProcessingException { File inputCII = getResourceAsFile("factur-x.xml"); boolean hasExceptions = false; @@ -414,10 +427,12 @@ public class DeSerializationTest extends ResourceCase { String number = "123"; String priceStr = "1.00"; String taxID = "9990815"; + BigDecimal price = new BigDecimal(priceStr); Invoice newInvoiceFromJSON = null; boolean hasExceptions = false; SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + String json = ""; try { SchemedID gtin = new SchemedID("0160", "2001015001325"); SchemedID gln = new SchemedID("0088", "4304171000002"); @@ -435,7 +450,7 @@ public class DeSerializationTest extends ResourceCase { .addCashDiscount(new CashDiscount(new BigDecimal(2), 14)) .setDeliveryDate(sdf.parse("2020-11-02")).setNumber(number).setVATDueDateTypeCode(EventTimeCodeTypeConstants.PAYMENT_DATE); ObjectMapper mapper = new ObjectMapper(); - String json = mapper.writeValueAsString(i); + json = mapper.writeValueAsString(i); newInvoiceFromJSON = mapper.readValue(json, Invoice.class); } catch (ParseException e) { hasExceptions = true; @@ -444,8 +459,34 @@ public class DeSerializationTest extends ResourceCase { } assertEquals(newInvoiceFromJSON.getBuyerOrderReferencedDocumentID(), "28934"); assertFalse(hasExceptions); + } + public void testFromJSON() throws JsonProcessingException { + String globalID = "4000001123452"; + String globalIDScheme = "0088"; + String itemDeliveryFrom="2022-01-28T23:00:00.000+00:00"; + String itemDeliveryTo="2022-01-30T23:00:00.000+00:00"; + String json="{\"number\":\"123\",\"buyerOrderReferencedDocumentID\":\"28934\",\"currency\":\"CHF\",\"issueDate\":1752744199178,\"dueDate\":1752744199178,\"deliveryDate\":1604271600000,\"sender\":{\"name\":\"Test company\",\"zip\":\"55232\",\"street\":\"teststr\",\"location\":\"teststadt\",\"country\":\"DE\",\"taxID\":\"9990815\",\"vatID\":\"DE0815\",\"id\":\"0009845\",\"globalID\":\""+globalID+"\",\"globalIDScheme\":\""+globalIDScheme+"\",\"email\":\"sender@test.org\",\"vatid\":\"DE0815\"},\"recipient\":{\"name\":\"Franz Müller\",\"zip\":\"55232\",\"street\":\"teststr.12\",\"location\":\"Entenhausen\",\"country\":\"DE\",\"vatID\":\"DE4711\",\"additionalAddress\":\"Hinterhaus 3\",\"contact\":{\"name\":\"Franz Müller\",\"phone\":\"01779999999\",\"email\":\"franz@mueller.de\",\"zip\":\"55232\",\"street\":\"teststr. 12\",\"location\":\"Entenhausen\",\"country\":\"DE\",\"fax\":\"++49555123456\"},\"globalID\":\"4304171000002\",\"globalIDScheme\":\"0088\",\"email\":\"recipient@test.org\",\"vatid\":\"DE4711\"},\"deliveryAddress\":{\"name\":\"just the other side of the street\",\"zip\":\"55232\",\"street\":\"teststr.12a\",\"location\":\"Entenhausen\",\"country\":\"DE\",\"vatID\":\"DE47110\",\"vatid\":\"DE47110\"},\"cashDiscounts\":[{\"percent\":2,\"days\":14}],\"notes\":[\"document level 1/2\",\"document level 2/2\"],\"sellerOrderReferencedDocumentID\":\"9384\",\"contractReferencedDocument\":\"376zreurzu0983\",\"valid\":true,\"vatdueDateTypeCode\":\"72\",\"zfitems\":[{\"price\":1.00,\"quantity\":1,\"basisQuantity\":1,\"detailedDeliveryPeriodFrom\":\""+itemDeliveryFrom+"\",\"detailedDeliveryPeriodTo\":\""+itemDeliveryTo+"\",\"id\":\"a123\",\"buyerOrderReferencedDocumentLineID\":\"xxx\",\"product\":{\"unit\":\"H87\",\"name\":\"Testprodukt\",\"sellerAssignedID\":\"4711\",\"taxCategoryCode\":\"S\",\"globalID\":\"2001015001325\",\"globalIDScheme\":\"0160\",\"intraCommunitySupply\":false,\"reverseCharge\":false,\"vatpercent\":16},\"notes\":[\"item level 1/1\"],\"notesWithSubjectCode\":[{\"content\":\"item level 1/1\"}],\"itemAllowances\":[{\"totalAmount\":0.0200000000000000004163336342344337026588618755340576171875,\"taxPercent\":16,\"reason\":\"item discount\",\"categoryCode\":\"S\"}],\"value\":1.00}],\"ownVATID\":\"DE0815\",\"detailedDeliveryPeriodFrom\":1601503200000,\"detailedDeliveryPeriodTo\":1601848800000,\"ownTaxID\":\"9990815\",\"ownZIP\":\"55232\",\"ownLocation\":\"teststadt\",\"zfallowances\":[{\"totalAmount\":0.200000000000000011102230246251565404236316680908203125,\"taxPercent\":16,\"reason\":\"discount\",\"categoryCode\":\"S\"}],\"ownStreet\":\"teststr\",\"zfcharges\":[{\"totalAmount\":0.5,\"taxPercent\":16,\"reason\":\"quick delivery charge\",\"categoryCode\":\"S\"}],\"ownCountry\":\"DE\"}"; + + ObjectMapper mapper = new ObjectMapper(); + Invoice fromJSON = mapper.readValue(json, Invoice.class); + assertEquals(globalID, fromJSON.getSender().getGlobalID()); + assertEquals(globalIDScheme, fromJSON.getSender().getGlobalIDScheme()); + SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd"); + assertEquals("2022-01-28", sdf.format(fromJSON.getZFItems()[0].getDetailedDeliveryPeriodFrom())); + assertEquals("2022-01-30", sdf.format(fromJSON.getZFItems()[0].getDetailedDeliveryPeriodTo())); + assertEquals("sender@test.org", fromJSON.getSender().getEmail()); + } + + public void testGrossFromJSON() throws JsonProcessingException { + + String json="{ \"documentCode\": \"380\", \"number\": \"123\", \"currency\": \"EUR\", \"paymentTermDescription\": \"Please remit until 28.07.2025\", \"issueDate\": 1753653600000, \"dueDate\": 1753653600000, \"sender\": { \"name\": \"Test company\", \"zip\": \"55232\", \"street\": \"teststr\", \"location\": \"teststadt\", \"country\": \"DE\", \"taxID\": \"4711\", \"vatID\": \"DE0815\", \"vatid\": \"DE0815\" }, \"recipient\": { \"name\": \"Franz Müller\", \"zip\": \"55232\", \"street\": \"teststr.12\", \"location\": \"Entenhausen\", \"country\": \"DE\", \"contact\": { \"name\": \"contact testname\", \"phone\": \"123456\", \"email\": \"contact.testemail@example.org\", \"fax\": \"0911623562\" } }, \"totalPrepaidAmount\": 0.00, \"lineTotalAmount\": 29.00, \"duePayable\": 34.51, \"grandTotal\": 34.51, \"taxBasis\": 29.00, \"valid\": true, \"zfitems\": [ { \"price\": 3.0000, \"quantity\": 10.0000, \"basisQuantity\": 1.0000, \"id\": \"1\", \"product\": { \"unit\": \"H87\", \"name\": \"Testprodukt\", \"taxCategoryCode\": \"S\", \"allowances\": [ { \"totalAmount\": 0.1000, \"categoryCode\": \"S\" } ], \"vatpercent\": 19.00, \"intraCommunitySupply\": false, \"reverseCharge\": false }, \"value\": 3.0000 } ], \"ownVATID\": \"DE0815\", \"ownTaxID\": \"4711\", \"ownLocation\": \"teststadt\", \"ownZIP\": \"55232\", \"ownCountry\": \"DE\", \"ownStreet\": \"teststr\"}"; + + ObjectMapper mapper = new ObjectMapper(); + CalculatedInvoice fromJSON = mapper.readValue(json, CalculatedInvoice.class); + fromJSON.calculate(); + assertEquals(new BigDecimal("34.51"),fromJSON.getDuePayable()); } public void testDueDateRoundtrip() throws JsonProcessingException { diff --git a/library/src/test/java/org/mustangproject/ZUGFeRD/XRTest.java b/library/src/test/java/org/mustangproject/ZUGFeRD/XRTest.java index 3a211610..42fd653c 100644 --- a/library/src/test/java/org/mustangproject/ZUGFeRD/XRTest.java +++ b/library/src/test/java/org/mustangproject/ZUGFeRD/XRTest.java @@ -106,6 +106,7 @@ public class XRTest extends TestCase { Invoice i = new Invoice().setDueDate(new Date()).setIssueDate(new Date()).setDeliveryDate(new Date()) .setSender(new TradeParty(orgname, "teststr", "55232", "teststadt", "DE").setEmail("sender@example.com").addTaxID("DE4711").addVATID("DE0815").setContact(new Contact("Hans Test", "+49123456789", "test@example.org")).addBankDetails(new BankDetails("DE12500105170648489890", "COBADEFXXX").setAccountName("kontoInhaber"))) .setRecipient(new TradeParty("Franz Müller", "teststr.12", "55232", "Entenhausen", "DE").setEmail("recipient@sample.org")) + .setDeliveryAddress(new TradeParty("Franz Müller", "teststr.12", "55232", "Entenhausen", "DE").setEmail("recipient@sample.org")) .addCashDiscount(new CashDiscount(new BigDecimal(2), 7)) .addCashDiscount(new CashDiscount(new BigDecimal(3), 14)) .setReferenceNumber("991-01484-64")//leitweg-id diff --git a/library/src/test/java/org/mustangproject/ZUGFeRD/ZF2PushTest.java b/library/src/test/java/org/mustangproject/ZUGFeRD/ZF2PushTest.java index a72a7953..72a4127f 100644 --- a/library/src/test/java/org/mustangproject/ZUGFeRD/ZF2PushTest.java +++ b/library/src/test/java/org/mustangproject/ZUGFeRD/ZF2PushTest.java @@ -53,6 +53,7 @@ public class ZF2PushTest extends TestCase { final String TARGET_ALLOWANCESPDF = "./target/testout-ZF2PushAllowances.pdf"; final String TARGET_CREDITNOTEPDF = "./target/testout-ZF2PushCreditNote.pdf"; final String TARGET_CORRECTIONPDF = "./target/testout-ZF2PushCorrection.pdf"; + final String TARGET_ITEMGROSS = "./target/testout-ZF2PushGross.pdf"; final String TARGET_ITEMCHARGESALLOWANCESPDF = "./target/testout-ZF2PushItemChargesAllowances.pdf"; final String TARGET_CHARGESALLOWANCESPDF = "./target/testout-ZF2PushChargesAllowances.pdf"; final String TARGET_RELATIVECHARGESALLOWANCESPDF = "./target/testout-ZF2PushRelativeChargesAllowances.pdf"; @@ -114,8 +115,8 @@ public class ZF2PushTest extends TestCase { ZUGFeRDImporter zi = new ZUGFeRDImporter(TARGET_PDF); assertTrue(zi.getUTF8().contains("DE88200800000970375700")); //the iban assertTrue(zi.getUTF8().contains("Max Mustermann")); //account holder - assertTrue(zi.getUTF8().contains("DueDateDateTime")); //account holder - assertTrue(zi.getUTF8().contains("20201212")); //account holder + assertTrue(zi.getUTF8().contains("DueDateDateTime")); + assertTrue(zi.getUTF8().contains("20201212")); assertTrue(zi.getUTF8().contains(" CO-123/V2A Toolbox 0815 Stahlcoil + + LeoID + 704310.0105636504 + DE diff --git a/validator/pom.xml b/validator/pom.xml index f5b5281a..57866cba 100644 --- a/validator/pom.xml +++ b/validator/pom.xml @@ -129,8 +129,10 @@ org.apache.maven.plugins maven-surefire-plugin + 3.5.3 alphabetical + -Duser.timezone=UTC diff --git a/validator/src/main/java/org/mustangproject/validator/PDFValidator.java b/validator/src/main/java/org/mustangproject/validator/PDFValidator.java index 05380d17..f8fe6156 100644 --- a/validator/src/main/java/org/mustangproject/validator/PDFValidator.java +++ b/validator/src/main/java/org/mustangproject/validator/PDFValidator.java @@ -228,6 +228,13 @@ public class PDFValidator extends Validator { } if (!documentFilenameValid) { + if (zi.hasXMLFileAttachment()) { + context.addResultItem(new ValidationResultItem( + ESeverity.notice, + "Potentially incorrectly named XML file attachments detected" + ).setSection(17).setPart(EPart.pdf)); + } + context.addResultItem(new ValidationResultItem( ESeverity.error, "XMP Metadata: DocumentFileName contains invalid value" diff --git a/validator/src/main/java/org/mustangproject/validator/XMLValidator.java b/validator/src/main/java/org/mustangproject/validator/XMLValidator.java index d125cd7d..5e8ce312 100644 --- a/validator/src/main/java/org/mustangproject/validator/XMLValidator.java +++ b/validator/src/main/java/org/mustangproject/validator/XMLValidator.java @@ -228,14 +228,8 @@ public class XMLValidator extends Validator { isExtended = contextProfile.contains("extended"); validateSchema(zfXML.getBytes(StandardCharsets.UTF_8), "OX_10/comfort/SCRDMCCBDACIOMessageStructure_100pD20B.xsd", 99, EPart.ox); xsltFilename = "/xslt/OX_10/comfort/SCRDMCCBDACIOMessageStructure_100pD20B_COMFORT.xslt"; - - } else if ("SCRDMCCBDACIOMessageStructure".equalsIgnoreCase(rootLocalName)) { - context.setGeneration("1"); - isOrderX = true; - validateSchema(zfXML.getBytes(StandardCharsets.UTF_8), "OX_10/comfort/SCRDMCCBDACIOMessageStructure_100pD20B.xsd", 99, EPart.ox); - xsltFilename = "/xslt/OX_10/comfort/SCRDMCCBDACIOMessageStructure_100pD20B_COMFORT.xslt"; - - } else if ("CrossIndustryInvoice".equalsIgnoreCase(rootLocalName)) { // ZUGFeRD 2.0 or Factur-X + + } else if (root.getLocalName().equalsIgnoreCase("CrossIndustryInvoice")) { // ZUGFeRD 2.0 or Factur-X context.setGeneration("2"); isMiniumum = contextProfile.contains("minimum"); diff --git a/validator/src/main/java/org/mustangproject/validator/ZUGFeRDValidator.java b/validator/src/main/java/org/mustangproject/validator/ZUGFeRDValidator.java index a64efdce..bb5e9576 100644 --- a/validator/src/main/java/org/mustangproject/validator/ZUGFeRDValidator.java +++ b/validator/src/main/java/org/mustangproject/validator/ZUGFeRDValidator.java @@ -204,10 +204,6 @@ public class ZUGFeRDValidator { context.clearCustomXML(); } - if ((isPDF) && (!pdfValidity)) { - context.setInvalid(); - } - } } catch (IrrecoverableValidationError | IOException irx) { LOGGER.info(irx.getMessage()); @@ -337,7 +333,7 @@ public class ZUGFeRDValidator { + " Signature:" + Signature + " Checksum:" + sha1Checksum + " Profile:" + context.getProfile() + " Version:" + context.getGeneration() + " Took:" + duration + "ms Errors:[" + context.getCSVResult() + "] ErrorIDs: [" + context.getCSVIDResult() + "]" + toBeAppended); - wasCompletelyValid = ((pdfValidity) && (xmlValidity)); + wasCompletelyValid = xmlValidity; return sw.toString(); } 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 index 14b1a296..84b8788d 100644 --- a/validator/src/main/resources/xslt/XR_30/XRechnung-CII-validation.xslt +++ b/validator/src/main/resources/xslt/XR_30/XRechnung-CII-validation.xslt @@ -30,6 +30,12 @@ indent="yes"/> + + + + @@ -120,6 +126,25 @@ + + + + + + + + + + + + + + + + + @@ -245,7 +270,7 @@   @@ -272,7 +297,7 @@ variable-pattern - + @@ -281,7 +306,7 @@ peppol-cii-pattern-1 - + @@ -290,7 +315,7 @@ peppol-cii-pattern-0-a - + @@ -299,7 +324,7 @@ peppol-cii-pattern-0-b - + @@ -308,7 +333,7 @@ cii-pattern - + @@ -317,45 +342,67 @@ cii-extension-pattern - + + + + + + cii-cvd-pattern + cii-cvd-pattern + + + - Schematron Version @xr-schematron.version.full@ - XRechnung @xrechnung.version@ compatible - CII + Schematron Version 2.4.0 - XRechnung 3.0.2 compatible - CII + + + - + select="'(^|\r?\n)#(SKONTO)#TAGE=([0-9]+#PROZENT=[0-9]+\.[0-9]{2})(#BASISBETRAG=-?[0-9]+\.[0-9]{2})?#$'"/> + + + select="' 0002 0003 0004 0005 0006 0007 0008 0009 0010 0011 0012 0013 0014 0015 0016 0017 0018 0019 0020 0021 0022 0023 0024 0025 0026 0027 0028 0029 0030 0031 0032 0033 0034 0035 0036 0037 0038 0039 0040 0041 0042 0043 0044 0045 0046 0047 0048 0049 0050 0051 0052 0053 0054 0055 0056 0057 0058 0059 0060 0061 0062 0063 0064 0065 0066 0067 0068 0069 0070 0071 0072 0073 0074 0075 0076 0077 0078 0079 0080 0081 0082 0083 0084 0085 0086 0087 0088 0089 0090 0091 0093 0094 0095 0096 0097 0098 0099 0100 0101 0102 0104 0105 0106 0107 0108 0109 0110 0111 0112 0113 0114 0115 0116 0117 0118 0119 0120 0121 0122 0123 0124 0125 0126 0127 0128 0129 0130 0131 0132 0133 0134 0135 0136 0137 0138 0139 0140 0141 0142 0143 0144 0145 0146 0147 0148 0149 0150 0151 0152 0153 0154 0155 0156 0157 0158 0159 0160 0161 0162 0163 0164 0165 0166 0167 0168 0169 0170 0171 0172 0173 0174 0175 0176 0177 0178 0179 0180 0183 0184 0185 0186 0187 0188 0189 0190 0191 0192 0193 0194 0195 0196 0197 0198 0199 0200 0201 0202 0203 0204 0205 0206 0207 0208 0209 0210 0211 0212 0213 0214 0215 0216 0217 0218 0219 0220 0221 0222 0223 0224 0225 0226 0227 0228 0229 0230 0231 0232 0233 0234 0235 0236 0237 0238 0239 0240'"/> + select="' 0002 0007 0009 0037 0060 0088 0096 0097 0106 0130 0135 0142 0147 0151 0154 0158 0170 0177 0183 0184 0188 0190 0191 0192 0193 0194 0195 0196 0198 0199 0200 0201 0202 0203 0204 0205 0208 0209 0210 0211 0212 0213 0215 0216 0217 0218 0219 0220 0221 0225 0230 0240 0235 9910 9913 9914 9915 9918 9919 9920 9922 9923 9924 9925 9926 9927 9928 9929 9930 9931 9932 9933 9934 9935 9936 9937 9938 9939 9940 9941 9942 9943 9944 9945 9946 9947 9948 9949 9950 9951 9952 9953 9957 9959 AN AQ AS AU EM '"/> - - - + + + + + + + + - + @@ -365,7 +412,7 @@ PEPPOL-EN16931-R001 - warning + fatal @@ -373,12 +420,12 @@ - + + mode="M27"> @@ -388,7 +435,7 @@ PEPPOL-EN16931-R005 - warning + fatal @@ -403,7 +450,7 @@ PEPPOL-EN16931-R053 - warning + fatal @@ -418,7 +465,7 @@ PEPPOL-EN16931-R054 - warning + fatal @@ -433,18 +480,18 @@ PEPPOL-EN16931-R055 - warning + fatal - + Invoice total VAT amount and Invoice total VAT amount in accounting currency MUST have the same operational sign - + - + @@ -453,7 +500,7 @@ PEPPOL-EN16931-R010 - warning + fatal @@ -461,10 +508,10 @@ - + - + @@ -473,7 +520,7 @@ PEPPOL-EN16931-R020 - warning + fatal @@ -481,12 +528,12 @@ - + + mode="M27"> @@ -495,7 +542,7 @@ PEPPOL-EN16931-R041 - warning + fatal @@ -504,12 +551,12 @@ - + + mode="M27"> @@ -518,7 +565,7 @@ PEPPOL-EN16931-R042 - warning + fatal @@ -527,22 +574,22 @@ - + + mode="M27"> - + + test="not(ram:CalculationPercent and ram:BasisAmount) or u:slack(if (ram:ActualAmount) then ram:ActualAmount else 0, (xs:decimal(ram:BasisAmount) * xs:decimal(ram:CalculationPercent)) div 100, $slackValue)"> PEPPOL-EN16931-R040 - warning + fatal @@ -557,7 +604,7 @@ PEPPOL-EN16931-R043-1 - warning + fatal @@ -565,10 +612,10 @@ - + - + @@ -578,7 +625,7 @@ PEPPOL-EN16931-R043-2 - warning + fatal @@ -586,12 +633,12 @@ - + + mode="M27"> @@ -601,7 +648,7 @@ PEPPOL-EN16931-R061 - warning + fatal @@ -609,12 +656,12 @@ - + + mode="M27"> @@ -624,7 +671,7 @@ PEPPOL-EN16931-R110 - warning + fatal @@ -632,12 +679,12 @@ - + + mode="M27"> @@ -647,7 +694,7 @@ PEPPOL-EN16931-R111 - warning + fatal @@ -655,12 +702,12 @@ - + + mode="M27"> PEPPOL-EN16931-R101 - warning + fatal @@ -690,12 +737,12 @@ - + + mode="M27"> @@ -705,7 +752,7 @@ PEPPOL-EN16931-R121 - warning + fatal @@ -713,12 +760,12 @@ - + + mode="M27"> @@ -728,7 +775,7 @@ PEPPOL-EN16931-R130 - warning + fatal @@ -736,17 +783,17 @@ - + - - - + + + + mode="M28"> @@ -755,7 +802,7 @@ PEPPOL-EN16931-R008 - warning + fatal @@ -763,17 +810,17 @@ - + - - - + + + + mode="M29"> @@ -783,7 +830,7 @@ PEPPOL-EN16931-R044 - warning + fatal @@ -793,12 +840,12 @@ - + + test="not(ram:ChargeAmount) or xs:decimal(../ram:NetPriceProductTradePrice/ram:ChargeAmount) = xs:decimal(ram:ChargeAmount) - u:decimalOrZero(ram:AppliedTradeAllowanceCharge/ram:ActualAmount[1])"> PEPPOL-EN16931-R046 - warning + fatal @@ -806,15 +853,15 @@ - + - - - + + + - + - + + test="not((rsm:SupplyChainTradeTransaction/ram:IncludedSupplyChainTradeLineItem/ram:SpecifiedLineTradeSettlement/ram:ApplicableTradeTax/ram:TypeCode = 'VAT' and rsm:SupplyChainTradeTransaction/ram:IncludedSupplyChainTradeLineItem/ram:SpecifiedLineTradeSettlement/ram:ApplicableTradeTax/ram:CategoryCode = ('S', 'Z', 'E', 'AE', 'K', 'G', 'L', 'M')) or (rsm:SupplyChainTradeTransaction/ram:ApplicableHeaderTradeSettlement/ram:SpecifiedTradeAllowanceCharge/ram:CategoryTradeTax = 'VAT' and rsm:SupplyChainTradeTransaction/ram:ApplicableHeaderTradeSettlement/ram:SpecifiedTradeAllowanceCharge/ram:CategoryTradeTax/ram:CategoryCode = ('S', 'Z', 'E', 'AE', 'K', 'G', 'L', 'M')) or (rsm:SupplyChainTradeTransaction/ram:IncludedSupplyChainTradeLineItem/ram:SpecifiedLineTradeSettlement/ram:ApplicableTradeTax/ram:TypeCode = 'VAT' and rsm:SupplyChainTradeTransaction/ram:IncludedSupplyChainTradeLineItem/ram:SpecifiedLineTradeSettlement/ram:ApplicableTradeTax/ram:CategoryCode = ('S', 'Z', 'E', 'AE', 'K', 'G', 'L', 'M'))) or ((rsm:SupplyChainTradeTransaction/ram:ApplicableHeaderTradeAgreement/ram:SellerTradeParty/ram:SpecifiedTaxRegistration/ram:ID[normalize-space(@schemeID)='VA' or normalize-space(@schemeID)='FC'][boolean(normalize-space(.))], rsm:SupplyChainTradeTransaction/ram:ApplicableHeaderTradeAgreement/ram:SellerTaxRepresentativeTradeParty))"> BR-DE-16 fatal @@ -904,10 +951,10 @@ - + + test="normalize-space(rsm:ExchangedDocument/ram:TypeCode) = ('326', '380', '384', '389', '381', '875', '876', '877')"> BR-DE-17 warning @@ -953,10 +1000,10 @@ - + + test="not(normalize-space(rsm:ExchangedDocument/ram:TypeCode) = '384') or (rsm:SupplyChainTradeTransaction/ram:ApplicableHeaderTradeSettlement/ram:InvoiceReferencedDocument)"> BR-DE-26 warning @@ -966,20 +1013,20 @@ - + + priority="1012" + mode="M30"> - + + test="ram:GuidelineSpecifiedDocumentContextParameter/ram:ID = $XR-CIUS-ID or ram:GuidelineSpecifiedDocumentContextParameter/ram:ID = $XR-EXTENSION-ID or ram:GuidelineSpecifiedDocumentContextParameter/ram:ID = $XR-CVD-ID"> BR-DE-21 warning @@ -989,12 +1036,12 @@ - + + priority="1011" + mode="M30"> @@ -1011,12 +1058,12 @@ - + + priority="1010" + mode="M30"> @@ -1049,12 +1096,12 @@ - + + priority="1009" + mode="M30"> @@ -1132,12 +1179,12 @@ - + + priority="1008" + mode="M30"> @@ -1170,12 +1217,35 @@ - + + + + + + + + + + + BR-TMP-2 + warning + + + + [BR-TMP-2] BT-124 "External document location" muss eine absolute URL mit gültigem Schema enthalten. + + + + + priority="1006" + mode="M30"> @@ -1208,20 +1278,20 @@ - + - + + context="/rsm:CrossIndustryInvoice/rsm:SupplyChainTradeTransaction/ram:ApplicableHeaderTradeSettlement/ram:SpecifiedTradeSettlementPaymentMeans[normalize-space(ram:TypeCode) = ('30','58')]"/> - + + test="not(normalize-space(ram:TypeCode) = '58') or matches(normalize-space(replace(ram:PayeePartyCreditorFinancialAccount/ram:IBANID, '([ \n\r\t\s])', '')), '^[A-Z]{2}[0-9]{2}[a-zA-Z0-9]{0,30}$') and xs:integer(string-join(for $cp in string-to-codepoints(concat(substring(normalize-space(replace(ram:PayeePartyCreditorFinancialAccount/ram:IBANID, '([ \n\r\t\s])', '')),5),upper-case(substring(normalize-space(replace(ram:PayeePartyCreditorFinancialAccount/ram:IBANID, '([ \n\r\t\s])', '')),1,2)),substring(normalize-space(replace(ram:PayeePartyCreditorFinancialAccount/ram:IBANID, '([ \n\r\t\s])', '')),3,2))) return (if($cp > 64) then string($cp - 55) else string($cp - 48)),'')) mod 97 = 1"> BR-DE-19 warning @@ -1261,14 +1331,14 @@ - + - + + context="/rsm:CrossIndustryInvoice/rsm:SupplyChainTradeTransaction/ram:ApplicableHeaderTradeSettlement/ram:SpecifiedTradeSettlementPaymentMeans[normalize-space(ram:TypeCode) = ('48','54','55')]"/> @@ -1299,20 +1369,20 @@ - + - + + context="/rsm:CrossIndustryInvoice/rsm:SupplyChainTradeTransaction/ram:ApplicableHeaderTradeSettlement/ram:SpecifiedTradeSettlementPaymentMeans[normalize-space(ram:TypeCode) = '59']"/> - + + test="not(normalize-space(ram:TypeCode) = '59') or matches(normalize-space(replace(ram:PayerPartyDebtorFinancialAccount/ram:IBANID, '([ \n\r\t\s])', '')), '^[A-Z]{2}[0-9]{2}[a-zA-Z0-9]{0,30}$') and xs:decimal(string-join(for $cp in string-to-codepoints(concat(substring(normalize-space(replace(ram:PayerPartyDebtorFinancialAccount/ram:IBANID, '([ \n\r\t\s])', '')),5),upper-case(substring(normalize-space(replace(ram:PayerPartyDebtorFinancialAccount/ram:IBANID, '([ \n\r\t\s])', '')),1,2)),substring(normalize-space(replace(ram:PayerPartyDebtorFinancialAccount/ram:IBANID, '([ \n\r\t\s])', '')),3,2))) return (if($cp > 64) then string($cp - 55) else string($cp - 48)),'')) mod 97 = 1"> BR-DE-20 warning @@ -1352,12 +1422,12 @@ - + + priority="1002" + mode="M30"> @@ -1375,19 +1445,67 @@ - + - - - + + + + + + + + + BR-DE-TMP-32 + information + + + + + [BR-DE-TMP-32] Eine Rechnung sollte zur Angabe des Liefer-/Leistungsdatums entweder BT-72 "Actual delivery date", BG-14 "Invoicing period" oder in jeder Rechnungsposition BG-26 "Invoice line period" enthalten. + + + + + + + + + + + + + + + BR-TMP-3 + fatal + + + + [BR-TMP-3] If both elements to which BT-149 and BT-150 can be mapped are present, both must be equal. + + + + + + + + + priority="1006" + mode="M31"> @@ -1407,12 +1525,12 @@ - + + priority="1005" + mode="M31"> @@ -1432,12 +1550,12 @@ - + + priority="1004" + mode="M31"> @@ -1457,12 +1575,12 @@ - + + priority="1003" + mode="M31"> @@ -1482,12 +1600,12 @@ - + + priority="1002" + mode="M31"> @@ -1507,12 +1625,12 @@ - + + priority="1001" + mode="M31"> @@ -1532,10 +1650,248 @@ - + - - - + + + + + + + + + BR-DEX-01 + fatal + + + + [BR-DEX-01] Das Element + + "Attached Document" (BT-125) benutzt einen nicht zulässigen MIME-Code: + + . Im Falle einer Extension darf zusätzlich zu der Liste der mime codes (definiert in Abschnitt 8.2, "Binary Object") der MIME-Code application/xml genutzt werden. + + + + + + + + + + + + + + + + + + + + BR-DE-CVD-03 + fatal + + + + + [BR-DE-CVD-03] In einer Rechnung muss mindestens eine + + INVOICE LINE (BG-25) enthalten sein, in der der Scheme identifier von + + "Item classification identifier" (BT-158) den Wert 'CVD' und der + + "Item attribute name" (BT-160) den Wert 'cva' enthält. + + + + + + + + + + + + + + + BR-DE-CVD-06-b + fatal + + + + + [BR-DE-CVD-06-b] Wenn + + "Item attribute name" (BT-160) mit dem Wert 'cva' angegeben ist, muss in derselben Rechnungszeile genau ein + + "Item classification identifier" (BT-158) mit dem Scheme identifier 'CVD' vorhanden sein. + + + + + + + + + + BR-DE-CVD-06-a + fatal + + + + + [BR-DE-CVD-06-a] Wenn der Scheme identifier von + + "Item classification identifier" (BT-158) mit dem Wert 'CVD' angegeben ist, muss in derselben Rechnungszeile genau ein + + "Item attribute name" (BT-160) mit dem Wert 'cva' vorhanden sein. + + + + + + + + + + + + + + + BR-TMP-CVD-01 + fatal + + + + + [BR-TMP-CVD-01] Das Bildungsschema für + + "Item classification identifier" (BT-158) ist aus der Codeliste UNTDID 7143 zu wählen. + + + + + + + + + + BR-DE-CVD-04 + fatal + + + + + [BR-DE-CVD-04] Ein + + "Item classification identifier" (BT-158) mit dem Scheme identifier 'CVD' muss einen Wert aus der Liste der zulässigen Fahrzeugkategorien enthalten. + + + + + + + + + + + + + + + BR-DE-CVD-05 + fatal + + + + + [BR-DE-CVD-05] Wenn innerhalb von + + ITEM ATTRIBUTES (BG-32) der + + "Item attribute name" (BT-160) den Wert 'cva' hat, muss der + + "Item attribute value" (BT-161) einen der zulässigen Werte enthalten. + + + + + + + + + + + + + + + BR-DE-CVD-01 + fatal + + + + + [BR-DE-CVD-01] Das Element + + "Contract reference" (BT-12) muss übermittelt werden. + + + + + + + + + + BR-DE-CVD-02 + fatal + + + + + [BR-DE-CVD-02] Das Element + + "Tender or lot reference" (BT-17) muss übermittelt werden. + + + + + + + + + diff --git a/validator/src/main/resources/xslt/XR_30/XRechnung-UBL-validation.xslt b/validator/src/main/resources/xslt/XR_30/XRechnung-UBL-validation.xslt index f77bc205..76e093d0 100644 --- a/validator/src/main/resources/xslt/XR_30/XRechnung-UBL-validation.xslt +++ b/validator/src/main/resources/xslt/XR_30/XRechnung-UBL-validation.xslt @@ -132,6 +132,25 @@ select=" (number($digits[8])*2) + (number($digits[7])*4) + (number($digits[6])*8) + (number($digits[5])*16) + (number($digits[4])*32) + (number($digits[3])*64) + (number($digits[2])*128) + (number($digits[1])*256) "/> + + + + + + + + + + + + + + + + + @@ -257,7 +276,7 @@   @@ -289,7 +308,7 @@ variable-pattern - + @@ -298,7 +317,7 @@ peppol-ubl-pattern-1 - + @@ -307,7 +326,7 @@ peppol-ubl-pattern-2 - + @@ -316,7 +335,7 @@ ubl-pattern - + @@ -325,18 +344,33 @@ ubl-extension-pattern - + + + + + + ubl-cvd-pattern + ubl-cvd-pattern + + + - Schematron Version @xr-schematron.version.full@ - XRechnung @xrechnung.version@ compatible - UBL - Invoice / Creditnote + Schematron Version 2.4.0 - XRechnung 3.0.2 compatible - UBL - Invoice / Creditnote + + + + + - + select="'(^|\r?\n)#(SKONTO)#TAGE=([0-9]+#PROZENT=[0-9]+\.[0-9]{2})(#BASISBETRAG=-?[0-9]+\.[0-9]{2})?#$'"/> + + + select="' 0002 0003 0004 0005 0006 0007 0008 0009 0010 0011 0012 0013 0014 0015 0016 0017 0018 0019 0020 0021 0022 0023 0024 0025 0026 0027 0028 0029 0030 0031 0032 0033 0034 0035 0036 0037 0038 0039 0040 0041 0042 0043 0044 0045 0046 0047 0048 0049 0050 0051 0052 0053 0054 0055 0056 0057 0058 0059 0060 0061 0062 0063 0064 0065 0066 0067 0068 0069 0070 0071 0072 0073 0074 0075 0076 0077 0078 0079 0080 0081 0082 0083 0084 0085 0086 0087 0088 0089 0090 0091 0093 0094 0095 0096 0097 0098 0099 0100 0101 0102 0104 0105 0106 0107 0108 0109 0110 0111 0112 0113 0114 0115 0116 0117 0118 0119 0120 0121 0122 0123 0124 0125 0126 0127 0128 0129 0130 0131 0132 0133 0134 0135 0136 0137 0138 0139 0140 0141 0142 0143 0144 0145 0146 0147 0148 0149 0150 0151 0152 0153 0154 0155 0156 0157 0158 0159 0160 0161 0162 0163 0164 0165 0166 0167 0168 0169 0170 0171 0172 0173 0174 0175 0176 0177 0178 0179 0180 0183 0184 0185 0186 0187 0188 0189 0190 0191 0192 0193 0194 0195 0196 0197 0198 0199 0200 0201 0202 0203 0204 0205 0206 0207 0208 0209 0210 0211 0212 0213 0214 0215 0216 0217 0218 0219 0220 0221 0222 0223 0224 0225 0226 0227 0228 0229 0230 0231 0232 0233 0234 0235 0236 0237 0238 0239 0240'"/> + select="' 0002 0007 0009 0037 0060 0088 0096 0097 0106 0130 0135 0142 0147 0151 0154 0158 0170 0177 0183 0184 0188 0190 0191 0192 0193 0194 0195 0196 0198 0199 0200 0201 0202 0203 0204 0205 0208 0209 0210 0211 0212 0213 0215 0216 0217 0218 0219 0220 0221 0225 0230 0240 0235 9910 9913 9914 9915 9918 9919 9920 9922 9923 9924 9925 9926 9927 9928 9929 9930 9931 9932 9933 9934 9935 9936 9937 9938 9939 9940 9941 9942 9943 9944 9945 9946 9947 9948 9949 9950 9951 9952 9953 9957 9959 AN AQ AS AU EM '"/> - - - + + + + + + + + + mode="M36"> @@ -389,17 +434,17 @@ - + - - - + + + + mode="M37"> @@ -461,10 +506,10 @@ - + - + @@ -481,12 +526,12 @@ - + + mode="M37"> @@ -503,12 +548,12 @@ - + + mode="M37"> @@ -525,12 +570,12 @@ - + + mode="M37"> @@ -547,12 +592,12 @@ - + + mode="M37"> @@ -569,20 +614,20 @@ - + + mode="M37"> - + + test="not(cbc:MultiplierFactorNumeric and cbc:BaseAmount) or u:slack(if (cbc:Amount) then cbc:Amount else 0, (xs:decimal(cbc:BaseAmount) * xs:decimal(cbc:MultiplierFactorNumeric)) div 100, $slackValue)"> PEPPOL-EN16931-R040 fatal @@ -607,12 +652,12 @@ - + + mode="M37"> @@ -630,12 +675,12 @@ - + + mode="M37"> @@ -653,12 +698,12 @@ - + + mode="M37"> @@ -676,12 +721,12 @@ - + + mode="M37"> - + + test="u:slack($lineExtensionAmount, ($quantity * ($priceAmount div $baseQuantity)) + $chargesTotal - $allowancesTotal, $slackValue)"> PEPPOL-EN16931-R120 fatal @@ -741,10 +786,10 @@ - + - + @@ -777,12 +822,12 @@ - + + mode="M37"> - + - - - + + + - + @@ -876,10 +921,10 @@ select="('326', '380', '384', '389', '381', '875', '876', '877')"/> - + + test="normalize-space(cbc:InvoiceTypeCode) = $supportedInvAndCNTypeCodes or normalize-space(cbc:CreditNoteTypeCode) = $supportedInvAndCNTypeCodes"> BR-DE-17 warning @@ -910,10 +955,10 @@ - + + test="cbc:CustomizationID = $XR-CIUS-ID or cbc:CustomizationID = $XR-EXTENSION-ID or cbc:CustomizationID = $XR-CVD-ID"> BR-DE-21 warning @@ -940,10 +985,10 @@ - + + test="((not(normalize-space(cbc:InvoiceTypeCode) = '384' or normalize-space(cbc:CreditNoteTypeCode) = '384') or (cac:BillingReference/cac:InvoiceDocumentReference)))"> BR-DE-26 warning @@ -983,12 +1028,52 @@ - + + + + + + BR-DE-TMP-32 + information + + + + + [BR-DE-TMP-32] Eine Rechnung sollte zur Angabe des Liefer-/Leistungsdatums entweder BT-72 "Actual delivery date", BG-14 "Invoicing period" oder in jeder Rechnungsposition BG-26 "Invoice line period" enthalten. + + + + + + + + + + + + + + + BR-TMP-2 + warning + + + + [BR-TMP-2] BT-124 "External document location" muss eine absolute URL mit gültigem Schema enthalten. + + + + + mode="M38"> @@ -1005,12 +1090,12 @@ - + + mode="M38"> @@ -1043,12 +1128,12 @@ - + + mode="M38"> @@ -1126,12 +1211,12 @@ - + + mode="M38"> @@ -1164,12 +1249,12 @@ - + + mode="M38"> @@ -1202,20 +1287,20 @@ - + - + mode="M38"> + context="/ubl:Invoice/cac:PaymentMeans[normalize-space(cbc:PaymentMeansCode) = ('30','58')] | /cn:CreditNote/cac:PaymentMeans[normalize-space(cbc:PaymentMeansCode) = ('30','58')]"/> - + + test="not(normalize-space(cbc:PaymentMeansCode) = '58') or matches(normalize-space(replace(cac:PayeeFinancialAccount/cbc:ID, '([ \n\r\t\s])', '')), '^[A-Z]{2}[0-9]{2}[a-zA-Z0-9]{0,30}$') and xs:integer(string-join(for $cp in string-to-codepoints(concat(substring(normalize-space(replace(cac:PayeeFinancialAccount/cbc:ID, '([ \n\r\t\s])', '')),5),upper-case(substring(normalize-space(replace(cac:PayeeFinancialAccount/cbc:ID, '([ \n\r\t\s])', '')),1,2)),substring(normalize-space(replace(cac:PayeeFinancialAccount/cbc:ID, '([ \n\r\t\s])', '')),3,2))) return (if($cp > 64) then string($cp - 55) else string($cp - 48)),'')) mod 97 = 1"> BR-DE-19 warning @@ -1255,14 +1340,14 @@ - + - + mode="M38"> + context="/ubl:Invoice/cac:PaymentMeans[normalize-space(cbc:PaymentMeansCode) = ('48','54','55')] |/cn:CreditNote/cac:PaymentMeans[normalize-space(cbc:PaymentMeansCode) = ('48','54','55')]"/> @@ -1292,20 +1377,20 @@ - + - + mode="M38"> + context="/ubl:Invoice/cac:PaymentMeans[normalize-space(cbc:PaymentMeansCode) = '59'] | /cn:CreditNote/cac:PaymentMeans[normalize-space(cbc:PaymentMeansCode) = '59']"/> - + + test="not(normalize-space(cbc:PaymentMeansCode) = '59') or matches(normalize-space(replace(cac:PaymentMandate/cac:PayerFinancialAccount/cbc:ID, '([ \n\r\t\s])', '')), '^[A-Z]{2}[0-9]{2}[a-zA-Z0-9]{0,30}$') and xs:decimal(string-join(for $cp in string-to-codepoints(concat(substring(normalize-space(replace(cac:PaymentMandate/cac:PayerFinancialAccount/cbc:ID, '([ \n\r\t\s])', '')),5),upper-case(substring(normalize-space(replace(cac:PaymentMandate/cac:PayerFinancialAccount/cbc:ID, '([ \n\r\t\s])', '')),1,2)),substring(normalize-space(replace(cac:PaymentMandate/cac:PayerFinancialAccount/cbc:ID, '([ \n\r\t\s])', '')),3,2))) return (if($cp > 64) then string($cp - 55) else string($cp - 48)),'')) mod 97 = 1"> BR-DE-20 warning @@ -1344,12 +1429,12 @@ - + + mode="M38"> @@ -1367,11 +1452,11 @@ - + - - - + + + + mode="M39"> @@ -1401,18 +1486,18 @@ - + - + - + + test="(every $invoiceline in /ubl:Invoice/cac:InvoiceLine[ exists (./cac:SubInvoiceLine) ] satisfies $invoiceline/xs:decimal(cbc:LineExtensionAmount) = sum($invoiceline/cac:SubInvoiceLine/xs:decimal(cbc:LineExtensionAmount))) and (count( //cac:SubInvoiceLine [count(cac:SubInvoiceLine) > 0 and xs:decimal(cbc:LineExtensionAmount) = sum(cac:SubInvoiceLine/xs:decimal(cbc:LineExtensionAmount))]) = count(//cac:SubInvoiceLine [count(cac:SubInvoiceLine) > 0]))"> BR-DEX-02 warning @@ -1440,12 +1525,12 @@ - + + mode="M39"> - [BR-DEX-09] Amount due for payment (BT-115) = Invoice total amount with VAT (BT-112) - Paid amount (BT-113) + Rounding amount (BT-114) - Σ Third party payment amount (BT-DEX-002). + [BR-DEX-09] Amount due for payment (BT-115) = Invoice total amount with VAT (BT-112) - Paid amount (BT-113) + Rounding amount (BT-114) + Σ Third party payment amount (BT-DEX-002). - + + mode="M39"> @@ -1494,12 +1579,12 @@ - + + mode="M39"> @@ -1519,12 +1604,12 @@ - + + mode="M39"> @@ -1544,12 +1629,12 @@ - + + mode="M39"> @@ -1569,12 +1654,12 @@ - + + mode="M39"> @@ -1594,12 +1679,12 @@ - + + mode="M39"> @@ -1677,10 +1762,213 @@ - + - - - + + + + + + + + + + + + + + + BR-DE-CVD-02 + fatal + + + + + [BR-DE-CVD-02] Das Element + + "Tender or lot reference" (BT-17) muss übermittelt werden. + + + + + + + + + + BR-DE-CVD-01 + fatal + + + + + [BR-DE-CVD-01] Das Element + + "Contract reference" (BT-12) muss übermittelt werden. + + + + + + + + + + BR-DE-CVD-03 + fatal + + + + + [BR-DE-CVD-03] In einer Rechnung muss mindestens eine + + INVOICE LINE (BG-25) enthalten sein, in der der Scheme identifier von + + "Item classification identifier" (BT-158) den Wert 'CVD' und der + + "Item attribute name" (BT-160) den Wert 'cva' enthält. + + + + + + + + + + + + + + + BR-DE-CVD-06-a + fatal + + + + + [BR-DE-CVD-06-a] Wenn der Scheme identifier von + + "Item classification identifier" (BT-158) mit dem Wert 'CVD' angegeben ist, muss in derselben Rechnungszeile genau ein + + "Item attribute name" (BT-160) mit dem Wert 'cva' vorhanden sein. + + + + + + + + + + BR-DE-CVD-06-b + fatal + + + + + [BR-DE-CVD-06-b] Wenn + + "Item attribute name" (BT-160) mit dem Wert 'cva' angegeben ist, muss in derselben Rechnungszeile genau ein + + "Item classification identifier" (BT-158) mit dem Scheme identifier 'CVD' vorhanden sein. + + + + + + + + + + + + + + + BR-TMP-CVD-01 + fatal + + + + + [BR-TMP-CVD-01] Das Bildungsschema für + + "Item classification identifier" (BT-158) ist aus der Codeliste UNTDID 7143 zu wählen. + + + + + + + + + + BR-DE-CVD-04 + fatal + + + + + [BR-DE-CVD-04] Ein + + "Item classification identifier" (BT-158) mit dem Scheme identifier 'CVD' muss einen Wert aus der Liste der zulässigen Fahrzeugkategorien enthalten. + + + + + + + + + + + + + + + BR-DE-CVD-05 + fatal + + + + + [BR-DE-CVD-05] Wenn innerhalb von + + ITEM ATTRIBUTES (BG-32) der + + "Item attribute name" (BT-160) den Wert 'cva' hat, muss der + + "Item attribute value" (BT-161) einen der zulässigen Werte enthalten. + + + + + + + + + diff --git a/validator/src/test/java/org/mustangproject/validator/LibraryTest.java b/validator/src/test/java/org/mustangproject/validator/LibraryTest.java index 1cf5fd12..62850db3 100644 --- a/validator/src/test/java/org/mustangproject/validator/LibraryTest.java +++ b/validator/src/test/java/org/mustangproject/validator/LibraryTest.java @@ -177,6 +177,9 @@ public class LibraryTest extends ResourceCase { assertThat(res).valueByXPath("count(//error)") .asInt() .isEqualTo(0); + assertThat(res).valueByXPath("count(//warning)") + .asInt() + .isEqualTo(0); assertThat(res).valueByXPath("/validation/summary/@status") .asString() .isEqualTo("valid");// expect to be valid because XR notices are, well, only notices diff --git a/validator/src/test/java/org/mustangproject/validator/ResourceCase.java b/validator/src/test/java/org/mustangproject/validator/ResourceCase.java index 621da5ef..589d72e3 100644 --- a/validator/src/test/java/org/mustangproject/validator/ResourceCase.java +++ b/validator/src/test/java/org/mustangproject/validator/ResourceCase.java @@ -17,8 +17,7 @@ public class ResourceCase extends TestCase { private static final Logger LOGGER = LoggerFactory.getLogger(ResourceCase.class.getCanonicalName()); // log output is public static File getResourceAsFile(String resourcePath) { - try { - InputStream in = ClassLoader.getSystemClassLoader().getResourceAsStream(resourcePath); + try(InputStream in = ClassLoader.getSystemClassLoader().getResourceAsStream(resourcePath)) { if (in == null) { return null; } @@ -42,8 +41,7 @@ public class ResourceCase extends TestCase { } public static byte[] getResourceAsByteArray(String resourcePath) { - try { - InputStream in = ClassLoader.getSystemClassLoader().getResourceAsStream(resourcePath); + try(InputStream in = ClassLoader.getSystemClassLoader().getResourceAsStream(resourcePath)) { if (in == null) { return null; } diff --git a/validator/src/test/java/org/mustangproject/validator/ZUGFeRDValidatorTest.java b/validator/src/test/java/org/mustangproject/validator/ZUGFeRDValidatorTest.java index ec938490..4adb787b 100644 --- a/validator/src/test/java/org/mustangproject/validator/ZUGFeRDValidatorTest.java +++ b/validator/src/test/java/org/mustangproject/validator/ZUGFeRDValidatorTest.java @@ -31,7 +31,7 @@ public class ZUGFeRDValidatorTest extends ResourceCase { .isEqualTo("valid"); assertThat(res).valueByXPath("/validation/summary/@status") - .isEqualTo("invalid"); + .isEqualTo("valid"); tempFile = getResourceAsFile("validAvoir_FR_type380_BASICWL.pdf"); @@ -103,7 +103,7 @@ public class ZUGFeRDValidatorTest extends ResourceCase { .isEqualTo("valid"); assertThat(res).valueByXPath("/validation/summary/@status") - .isEqualTo("invalid"); + .isEqualTo("valid"); fileBytes = getResourceAsByteArray("validAvoir_FR_type380_BASICWL.pdf"); @@ -216,10 +216,10 @@ public class ZUGFeRDValidatorTest extends ResourceCase { assertThat(res).valueByXPath("count(//error)") .asInt() - .isEqualTo(2); + .isEqualTo(5); assertThat(res).valueByXPath("count(//warning)") .asInt() - .isEqualTo(3); + .isEqualTo(1); assertThat(res).valueByXPath("count(//notice)") .asInt() @@ -250,7 +250,7 @@ public class ZUGFeRDValidatorTest extends ResourceCase { assertThat(res).valueByXPath("count(//notice)") .asInt() - .isEqualTo(12); // 12 notices RE XRechnung 3.0 + .isEqualTo(9); // 9 notices RE XRechnung 3.0 assertThat(res).valueByXPath("/validation/summary/@status") .asString() .isEqualTo("valid");// expect to be valid because XR notices are, well, only notices diff --git a/validator/src/test/resources/CII_XRechnung_with_Peppol_violation.xml b/validator/src/test/resources/CII_XRechnung_with_Peppol_violation.xml index 8e023db5..71efa791 100644 --- a/validator/src/test/resources/CII_XRechnung_with_Peppol_violation.xml +++ b/validator/src/test/resources/CII_XRechnung_with_Peppol_violation.xml @@ -93,6 +93,9 @@ Stadt DE + + muster@example.com + diff --git a/validator/src/test/resources/validXRV30.xml b/validator/src/test/resources/validXRV30.xml index 8587992c..adffb992 100644 --- a/validator/src/test/resources/validXRV30.xml +++ b/validator/src/test/resources/validXRV30.xml @@ -89,6 +89,14 @@ S 7 + + + 20160101 + + + 20161231 + + 26.07