From 500a25c3bd8bcf418adc8cdbc0d3d6a8d1563d1e Mon Sep 17 00:00:00 2001 From: Sebastian Sieber Date: Tue, 5 Nov 2024 12:32:43 +0100 Subject: [PATCH] Add ServiceLogisticsCharge to visualization (cherry picked from commit dd8a95ef4bf9e8bc47b411434136995a2df8b6f0) --- .../stylesheets/xrechnung-html.univ.xsl | 35 +++++++++++ .../ZUGFeRD/VisualizationTest.java | 60 ++++++++++++++++--- .../test/resources/factur-x-vis-ubl.en.html | 1 + 3 files changed, 89 insertions(+), 7 deletions(-) diff --git a/library/src/main/resources/stylesheets/xrechnung-html.univ.xsl b/library/src/main/resources/stylesheets/xrechnung-html.univ.xsl index 1856fd51..b252b0e0 100644 --- a/library/src/main/resources/stylesheets/xrechnung-html.univ.xsl +++ b/library/src/main/resources/stylesheets/xrechnung-html.univ.xsl @@ -1151,6 +1151,10 @@ function downloadData (element_id) {
+ +
+ +
@@ -1564,6 +1568,37 @@ function downloadData (element_id) {
+ + + +
+
+
+
+
+
:
+
+
+
+
+
+
netto
+
+
+
+
+
+
+
+
+
+
:
+
+
+
+
+
+ diff --git a/library/src/test/java/org/mustangproject/ZUGFeRD/VisualizationTest.java b/library/src/test/java/org/mustangproject/ZUGFeRD/VisualizationTest.java index a59199f4..c45f87df 100644 --- a/library/src/test/java/org/mustangproject/ZUGFeRD/VisualizationTest.java +++ b/library/src/test/java/org/mustangproject/ZUGFeRD/VisualizationTest.java @@ -66,6 +66,47 @@ public class VisualizationTest extends ResourceCase { .replace(" ", ""); // remove linebreaks as well... + } catch (UnsupportedOperationException e) { + fail("UnsupportedOperationException should not happen: " + e.getMessage()); + } catch (IllegalArgumentException e) { + fail("IllegalArgumentException should not happen: " + e.getMessage()); + } catch (TransformerException e) { + fail("TransformerException should not happen: " + e.getMessage()); + } catch (IOException e) { + fail("IOException should not happen: " + e.getMessage()); + } + + + assertNotNull(result); + // Reading ZUGFeRD + assertEquals(expected, result); + } + + public void testCIIVisualizationExtended() { + + // the writing part + String sourceFilename = "factur-x-extended.xml"; + File CIIinputFile = getResourceAsFile(sourceFilename); + + String expected = null; + String result = null; + try { + 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) + */ + result = zvi.visualize(CIIinputFile.getAbsolutePath(), ZUGFeRDVisualizer.Language.DE).replace("\r", "").replace("\n", "") + .replace("\t", "") + .replace(" ", ""); + + File expectedResult = getResourceAsFile("factur-x-vis-extended.de.html"); + expected = new String(Files.readAllBytes(expectedResult.toPath()), StandardCharsets.UTF_8) + .replace("\r", "") + .replace("\n", "") + .replace("\t", "") + .replace(" ", ""); + // remove linebreaks as well... + } catch (UnsupportedOperationException e) { fail("UnsupportedOperationException should not happen: " + e.getMessage()); } catch (IllegalArgumentException e) { @@ -124,6 +165,7 @@ public class VisualizationTest extends ResourceCase { } + assertNotNull(result); // Reading ZUGFeRD assertEquals(expected, result); @@ -141,10 +183,18 @@ public class VisualizationTest extends ResourceCase { /* remove file endings so that tests can also pass after checking out from git with arbitrary options (which may include CSRF changes) */ - result = zvi.visualize(UBLinputFile.getAbsolutePath(), ZUGFeRDVisualizer.Language.EN).replace("\r", "").replace("\n", "").replace("\t", "").replace(" ", ""); + result = zvi.visualize(UBLinputFile.getAbsolutePath(), ZUGFeRDVisualizer.Language.EN) + .replace("\r", "") + .replace("\n", "") + .replace("\t", "") + .replace(" ", ""); File expectedResult = getResourceAsFile("factur-x-vis-ubl-creditnote.en.html"); - expected = new String(Files.readAllBytes(expectedResult.toPath()), StandardCharsets.UTF_8).replace("\r", "").replace("\n", "").replace("\t", "").replace(" ", ""); + expected = new String(Files.readAllBytes(expectedResult.toPath()), StandardCharsets.UTF_8) + .replace("\r", "") + .replace("\n", "") + .replace("\t", "") + .replace(" ", ""); // remove linebreaks as well... } catch (UnsupportedOperationException e) { @@ -162,12 +212,12 @@ public class VisualizationTest extends ResourceCase { } + assertNotNull(result); // Reading ZUGFeRD assertEquals(expected, result); } - public void testUBLVisualizationBasic() { // the writing part @@ -198,10 +248,6 @@ public class VisualizationTest extends ResourceCase { fail("TransformerException should not happen: " + e.getMessage()); } catch (IOException e) { fail("IOException should not happen: " + e.getMessage()); - } catch (ParserConfigurationException e) { - fail("ParserConfigurationException should not happen: " + e.getMessage()); - } catch (SAXException e) { - fail("SAXException should not happen: " + e.getMessage()); } diff --git a/library/src/test/resources/factur-x-vis-ubl.en.html b/library/src/test/resources/factur-x-vis-ubl.en.html index 9dd2506a..34d420e8 100644 --- a/library/src/test/resources/factur-x-vis-ubl.en.html +++ b/library/src/test/resources/factur-x-vis-ubl.en.html @@ -2,6 +2,7 @@ + XRechnung