diff --git a/History.md b/History.md index 8c5d03fc..3a37564a 100644 --- a/History.md +++ b/History.md @@ -1,7 +1,8 @@ - support pdf export/visualization to PDF, thanks to Heavenfighter #387 allow embedd fonts from jar-file for pdf creation #388 - Fix #389: ClassCastException: ZUGFeRDExporterFromA3 - +- jakarta support #372 +- Upgrade to PDFBox 3 #373 2.11.0 ======= 2024-05-22 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 e9c9f4a2..60d066b1 100755 --- a/Mustang-CLI/src/main/java/org/mustangproject/commandline/Main.java +++ b/Mustang-CLI/src/main/java/org/mustangproject/commandline/Main.java @@ -331,31 +331,34 @@ public class Main { try { CommandLine cmd; CommandLineParser parser = new BasicParser(); + // create Options object Options options = new Options(); - options.addOption(new Option("h", "help", false, "display usage")); options.addOption(new Option("a", "action", true, "which action to perform")); options.addOption(new Option("f", "format", true, "which format to output")); - options.addOption(new Option("", "version", true, "which version of the standard to use")); - options.addOption(new Option("", "profile", true, "which profile of the standard to use")); - Option attachmentOpt = new Option("", "attachments", true, "File attachments"); + options.addOption(new Option("version", "version", true, "which version of the standard to use")); + options.addOption(new Option("profile", "profile", true, "which profile of the standard to use")); + Option attachmentOpt = new Option("attachments", "attachments", true, "File attachments"); attachmentOpt.setValueSeparator(','); attachmentOpt.setArgs(Option.UNLIMITED_VALUES); + options.addOption(attachmentOpt); - options.addOption(new Option("", "source",true, "which source file to use")); - options.addOption(new Option("", "source-xml",true, "which source file to use")); - options.addOption(new Option("", "language",true, "output language (en, de or fr)")); - options.addOption(new Option("", "out",true, "which output file to write to")); - options.addOption(new Option("", "no-notices",false, "suppress non-fatal errors")); - options.addOption(new Option("", "logAppend",true, "freeform text to be appended to log messages")); - options.addOption(new Option("", "disable-file-logging", false, "suppress logging to file")); + options.addOption(new Option("source", "source",true, "which source file to use")); + options.addOption(new Option("source-xml", "source-xml",true, "which source file to use")); + options.addOption(new Option("language", "language",true, "output language (en, de or fr)")); + options.addOption(new Option("out", "out",true, "which output file to write to")); + options.addOption(new Option("no-notices", "no-notices",false, "suppress non-fatal errors")); + options.addOption(new Option("logAppend", "logAppend",true, "freeform text to be appended to log messages")); + options.addOption(new Option("disable-file-logging", "disable-file-logging", false, "suppress logging to file")); options.addOption(new Option("d", "directory",true, "which directory to operate on")); options.addOption(new Option("i", "ignorefileextension",false, "ignore non-matching file extensions")); options.addOption(new Option("l", "listfromstdin",false, "take list of files from commandline")); + boolean optionsRecognized=false; String action = ""; - Boolean disableFileLogging = false; + + Boolean disableFileLogging = false; try { cmd = parser.parse(options, args); diff --git a/library/src/test/java/org/mustangproject/ZUGFeRD/PreValidationTest.java b/library/src/test/java/org/mustangproject/ZUGFeRD/PreValidationTest.java new file mode 100644 index 00000000..4798a4c0 --- /dev/null +++ b/library/src/test/java/org/mustangproject/ZUGFeRD/PreValidationTest.java @@ -0,0 +1,86 @@ + +/** + * ********************************************************************* + *
+ * Copyright 2019 Jochen Staerk + *
+ * Use is subject to license terms. + *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy + * of the License at http://www.apache.org/licenses/LICENSE-2.0. + *
+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + *
+ * See the License for the specific language governing permissions and + * limitations under the License. + *
+ * ********************************************************************** + */ +package org.mustangproject.ZUGFeRD; + +import junit.framework.TestCase; +import org.junit.FixMethodOrder; +import org.junit.runners.MethodSorters; +import org.mustangproject.*; + +import java.io.IOException; +import java.io.InputStream; +import java.math.BigDecimal; +import java.util.Date; + + + +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public class PreValidationTest extends TestCase { + final String TARGET_PDF = "./target/testout-Preval.pdf"; + final String SOURCE_PDF = "/veraPDFtestsuite6-7-11-t01-fail-a.pdf"; + + public void testFailIgnore() { + + // the writing part + + + boolean hasEx = false; + try (InputStream source = this.getClass() + .getResourceAsStream(SOURCE_PDF)) { + ZUGFeRDExporterFromA1 ze = new ZUGFeRDExporterFromA1().setProducer("My Application") + .setCreator(System.getProperty("user.name")).setZUGFeRDVersion(2) + .load(source); + ze.setTransaction(createInvoice()); + + ze.export(TARGET_PDF); + } catch (IOException e) { + hasEx = true; + } + assertTrue(hasEx); + hasEx = false; + try (InputStream source = this.getClass() + .getResourceAsStream(SOURCE_PDF)) { + ZUGFeRDExporterFromA1 ze = new ZUGFeRDExporterFromA1().setProducer("My Application").ignorePDFAErrors() + .setCreator(System.getProperty("user.name")).setZUGFeRDVersion(2) + .load(source); + ze.setTransaction(createInvoice()); + ze.export(TARGET_PDF); + } catch (IOException e) { + hasEx = true; + } + assertFalse(hasEx); + } + + private Invoice createInvoice() { + String orgname = "Test company"; + String number = "123"; + String amountStr = "1.00"; + BigDecimal amount = new BigDecimal(amountStr); + return new Invoice().setDueDate(new Date()).setIssueDate(new Date()).setDeliveryDate(new Date()) + .setSender(new TradeParty(orgname, "teststr", "55232", "teststadt", "DE").addTaxID("DE4711").addVATID("DE0815").setEmail("info@example.org").setContact(new Contact("Hans Test", "+49123456789", "test@example.org")).addBankDetails(new BankDetails("DE12500105170648489890", "COBADEFXXX"))) + .setRecipient(new TradeParty("Theodor Est", "Bahnstr. 42", "88802", "Spielkreis", "DE")) + .setReferenceNumber("991-01484-64")//leitweg-id + // not using any VAT, this is also a test of zero-rated goods: + .setNumber(number).addItem(new Item(new Product("Testprodukt", "", "C62", BigDecimal.ZERO), amount, new BigDecimal(1.0))); + } + +} diff --git a/library/src/test/resources/veraPDFtestsuite6-7-11-t01-fail-a.pdf b/library/src/test/resources/veraPDFtestsuite6-7-11-t01-fail-a.pdf new file mode 100644 index 00000000..9b8333b2 Binary files /dev/null and b/library/src/test/resources/veraPDFtestsuite6-7-11-t01-fail-a.pdf differ