From c43988f388a716c5c72bbdc55c721c4813aeac0f Mon Sep 17 00:00:00 2001 From: jstaerk Date: Thu, 1 Oct 2020 13:55:04 +0200 Subject: [PATCH 1/2] support --logAppend --- .../org/mustangproject/commandline/Main.java | 26 +++++++++++-------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/Mustang-CLI/src/main/java/org/mustangproject/commandline/Main.java b/Mustang-CLI/src/main/java/org/mustangproject/commandline/Main.java index d1cf0a2f..c7b16f32 100755 --- a/Mustang-CLI/src/main/java/org/mustangproject/commandline/Main.java +++ b/Mustang-CLI/src/main/java/org/mustangproject/commandline/Main.java @@ -55,17 +55,17 @@ public class Main { + " [-i, --ignorefileextension] Check for all files (*.*) instead of PDF files only (*.pdf) in metrics, ignore PDF/A input file errors in combine\n" + "\n" + "* Merge actions\n" + " extract extract ZUGFeRD PDF to XML file\n" + " Additional parameters (optional - user will be prompted if not defined)\n" - + " [--source ]: set input PDF file\n" - + " [--out ]: set output XML file\n" + + " [--source=]: set input PDF file\n" + + " [--out=]: set output XML file\n" + " a3only upgrade from PDF/A1 to A3 only (no ZUGFeRD data attached)\n" + " Additional parameters (optional - user will be prompted if not defined)\n" - + " [--source ]: set input PDF file\n" - + " [--out ]: set output PDF file\n" + + " [--source=]: set input PDF file\n" + + " [--out=]: set output PDF file\n" + " combine combine XML and PDF file to ZUGFeRD PDF file\n" + " Additional parameters (optional - user will be prompted if not defined)\n" - + " [--source ]: set input PDF file\n" - + " [--source-xml ]: set input XML file\n" - + " [--out ]: set output PDF file\n" + + " [--source=]: set input PDF file\n" + + " [--source-xml=]: set input XML file\n" + + " [--out=]: set output PDF file\n" + " [--format ]: set ZUGFeRD or FacturX\n" + " [--version <1|2>]: set ZUGFeRD version\n" + " [--profile <...>]: set ZUGFeRD profile\n" @@ -73,8 +73,9 @@ public class Main { + " For ZUGFeRD v2: INIMUM, BASIC L, ASIC, IUS, N16931, Rechnung, EXENDED " + " validate validate XML or PDF file \n" + " [--no-notices]: refrain from reporting notices\n" + + " [--logAppend=]: text to be added to log line\n" + " Additional parameters (optional - user will be prompted if not defined)\n" - + " [--source ]: input PDF or XML file\n" + + " [--source=]: input PDF or XML file\n" + " validateExpectValid validate directory expecting positive results \n" + " [--no-notices]: refrain from reporting notices\n" + " Additional parameters (optional - user will be prompted if not defined)\n" @@ -238,7 +239,7 @@ public class Main { // --out: output file Option outOption = parser.addStringOption("out"); Option noNoticesOption = parser.addBooleanOption("no-notices"); - + Option logAppendOption = parser.addStringOption("logAppend"); // Command: Combining PDF and XML // --combine @@ -303,7 +304,7 @@ public class Main { performVisualization(sourceName, outName); optionsRecognized=true; } else if ((action!=null)&&(action.equals("validate"))) { - optionsRecognized=performValidate(sourceName, noNotices!=null&&noNotices); + optionsRecognized=performValidate(sourceName, noNotices!=null&&noNotices, parser.getOptionValue(logAppendOption)); } else if ((action!=null)&&(action.equals("validateExpectValid"))) { optionsRecognized=performValidateExpect(true, directoryName); } else if ((action!=null)&&(action.equals("validateExpectInvalid"))) { @@ -320,12 +321,15 @@ public class Main { } - private static boolean performValidate(String sourceName, boolean noNotices) { + private static boolean performValidate(String sourceName, boolean noNotices, String logAppend) { boolean optionsRecognized; if (sourceName == null) { sourceName = getFilenameFromUser("Source PDF or XML", "invoice.pdf", "pdf|xml", true, false); } ZUGFeRDValidator zfv=new ZUGFeRDValidator(); + if ((logAppend!=null)&&(logAppend.length()>0)) { + zfv.setLogAppend(logAppend); + } if (noNotices) { zfv.disableNotices(); } From 399d671f19ef132b9e1d7f9392c89d805c5757ac Mon Sep 17 00:00:00 2001 From: jstaerk Date: Thu, 1 Oct 2020 13:55:26 +0200 Subject: [PATCH 2/2] Taxnumber correction --- .../org/mustangproject/ZUGFeRD/ZUGFeRD2PullProvider.java | 7 +++++++ .../test/java/org/mustangproject/ZUGFeRD/ZF2PushTest.java | 4 +++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRD2PullProvider.java b/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRD2PullProvider.java index f3709e01..3e3b18d2 100644 --- a/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRD2PullProvider.java +++ b/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRD2PullProvider.java @@ -263,6 +263,13 @@ public class ZUGFeRD2PullProvider implements IXMLProvider { + "\n" + " \n"; } + if (party.getTaxID() != null) { + xml += " \n" + + " " + XMLTools.encodeXML(party.getTaxID()) + + "\n" + + " \n"; + + } return xml; } diff --git a/library/src/test/java/org/mustangproject/ZUGFeRD/ZF2PushTest.java b/library/src/test/java/org/mustangproject/ZUGFeRD/ZF2PushTest.java index c0bb2fce..5a4d33c5 100644 --- a/library/src/test/java/org/mustangproject/ZUGFeRD/ZF2PushTest.java +++ b/library/src/test/java/org/mustangproject/ZUGFeRD/ZF2PushTest.java @@ -86,6 +86,7 @@ public class ZF2PushTest extends TestCase { String orgname = "Test company"; String number = "123"; String amountStr = "1.00"; + String taxID="9990815"; BigDecimal amount = new BigDecimal(amountStr); try (InputStream SOURCE_PDF = this.getClass() .getResourceAsStream("/MustangGnuaccountingBeispielRE-20170509_505blanko.pdf"); @@ -97,7 +98,7 @@ public class ZF2PushTest extends TestCase { byte[] b={12,13}; ze.attachFile("one.pdf", b, "Application/PDF", "Alternative"); ze.attachFile("two.pdf", b, "Application/PDF", "Alternative"); - ze.setTransaction(new Invoice().setDueDate(new Date()).setIssueDate(new Date()).setDeliveryDate(new Date()).setSender(new TradeParty(orgname,"teststr", "55232","teststadt","DE").addTaxID("0815")).setOwnVATID("DE0815").setRecipient(new TradeParty("Franz Müller", "teststr.12", "55232", "Entenhausen", "DE").addVATID("DE4711").setContact(new Contact("Franz Müller","01779999999", "franz@mueller.de", "teststr. 12", "55232", "Entenhausen", "DE"))).setNumber(number).addItem(new Item(new Product("Testprodukt", "", "C62", new BigDecimal(19)), amount, new BigDecimal(1.0))) + ze.setTransaction(new Invoice().setDueDate(new Date()).setIssueDate(new Date()).setDeliveryDate(new Date()).setSender(new TradeParty(orgname,"teststr", "55232","teststadt","DE").addTaxID(taxID)).setOwnVATID("DE0815").setRecipient(new TradeParty("Franz Müller", "teststr.12", "55232", "Entenhausen", "DE").addVATID("DE4711").setContact(new Contact("Franz Müller","01779999999", "franz@mueller.de", "teststr. 12", "55232", "Entenhausen", "DE"))).setNumber(number).addItem(new Item(new Product("Testprodukt", "", "C62", new BigDecimal(19)), amount, new BigDecimal(1.0))) ); String theXML = new String(ze.getProvider().getXML()); @@ -111,6 +112,7 @@ public class ZF2PushTest extends TestCase { ZUGFeRDImporter zi = new ZUGFeRDImporter(TARGET_ATTACHMENTSPDF); assertTrue(zi.getUTF8().contains("EUR")); + assertTrue(zi.getUTF8().contains(taxID)); // Reading ZUGFeRD assertEquals("1.19", zi.getAmount());