diff --git a/History.md b/History.md index 3e81c674..6a637848 100644 --- a/History.md +++ b/History.md @@ -6,6 +6,8 @@ - jakarta support #372 - Upgrade to PDFBox 3 #373 - #397 +- #392 CLI: action combine: --ignorefileextension to ignore PDF/A input file errors dosen't work +- for CLI combine, fx is now default 2.11.0 ======= 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 60d066b1..4e09d3de 100755 --- a/Mustang-CLI/src/main/java/org/mustangproject/commandline/Main.java +++ b/Mustang-CLI/src/main/java/org/mustangproject/commandline/Main.java @@ -36,64 +36,65 @@ import java.util.ArrayList; public class Main { private static org.slf4j.Logger LOGGER; // log output + private static void printUsage() { System.err.println(getUsage()); } private static String getUsage() { return "Usage: --action metrics|combine|extract|a3only|ubl|validate|validateExpectInvalid|validateExpectValid|visualize [-d,--directory] [-l,--listfromstdin] [-i,--ignore fileextension, PDF/A errors] [--disable-file-logging] | [-h,--help] \r\n" - + " --action license display open source license and notice\n" - + " --action metrics\n" - + " -d, --directory count ZUGFeRD files in directory to be scanned\n" - + " If it is a directory, it will recurse.\n" - + " -l, --listfromstdin count ZUGFeRD files from a list of linefeed separated files on runtime.\n" - + " It will start once a blank line has been entered.\n" + "\n" - + " Additional parameter for both count operations\n" - + " [-i, --ignorefileextension] Check for all files (*.*) instead of PDF files only (*.pdf) in metrics, ignore PDF/A input file errors in combine\n" - + " [--disable-file-logging] disable logging to file.\n" - + " --action extract extract Factur-X 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" - + " --action 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" - + " --action combine combine XML and PDF file to Factur-X 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" - + " [--format ]: set Factur-X, ZUGFeRD, Order-X or Cross Industry Despatch Advice\n" - + " [--version <1|2>]: set ZUGFeRD version\n" - + " [--profile <...>]: set ZUGFeRD profile\n" - + " For ZUGFeRD v1 or Order-X: ASIC, OMFORT or EXENDED\n" - + " For ZUGFeRD v2: INIMUM, BASIC L, ASIC, IUS, N16931, Rechnung, EXENDED\n" - + " [--attachments ]: list of file attachments (passing a single empty file name prevents prompting)\n" - + " --action ubl convert UN/CEFACT 2016b CII XML to UBL XML\n" - + " [--source ]: set input XML file\n" - + " [--out ]: set output XML file\n" - + " --action upgrade upgrade ZUGFeRD XML to ZUGFeRD 2 XML\n" - + " Additional parameters (optional - user will be prompted if not defined)\n" - + " [--source ]: set input XML ZUGFeRD 1 file\n" - + " [--out ]: set output XML ZUGFeRD 2 file\n" - + " --action 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" - + " --action validateExpectInvalid validate directory expecting negative results \n" - + " [--no-notices]: refrain from reporting notices\n" - + " Additional parameters (optional - user will be prompted if not defined)\n" - + " -d, --directory to check recursively\n" - + " --action 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" - + " -d, --directory to check recursively \n" - + " --action visualize convert XML to HTML \n" - + " [--language ]: set output lang (en, fr or de)\n" - + " [--source ]: set input XML file\n" - + " [--out ]: set output HTML file\n" + + " --action license display open source license and notice\n" + + " --action metrics\n" + + " -d, --directory count ZUGFeRD files in directory to be scanned\n" + + " If it is a directory, it will recurse.\n" + + " -l, --listfromstdin count ZUGFeRD files from a list of linefeed separated files on runtime.\n" + + " It will start once a blank line has been entered.\n" + "\n" + + " Additional parameter for both count operations\n" + + " [-i, --ignorefileextension] Check for all files (*.*) instead of PDF files only (*.pdf) in metrics, ignore PDF/A input file errors in combine\n" + + " [--disable-file-logging] disable logging to file.\n" + + " --action extract extract Factur-X 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" + + " --action 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" + + " --action combine combine XML and PDF file to Factur-X 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" + + " [--format ]: set Factur-X, ZUGFeRD, Order-X or Cross Industry Despatch Advice\n" + + " [--version <1|2>]: set ZUGFeRD version\n" + + " [--profile <...>]: set ZUGFeRD profile\n" + + " For ZUGFeRD v1 or Order-X: ASIC, OMFORT or EXENDED\n" + + " For ZUGFeRD v2: INIMUM, BASIC L, ASIC, IUS, N16931, Rechnung, EXENDED\n" + + " [--attachments ]: list of file attachments (passing a single empty file name prevents prompting)\n" + + " --action ubl convert UN/CEFACT 2016b CII XML to UBL XML\n" + + " [--source ]: set input XML file\n" + + " [--out ]: set output XML file\n" + + " --action upgrade upgrade ZUGFeRD XML to ZUGFeRD 2 XML\n" + + " Additional parameters (optional - user will be prompted if not defined)\n" + + " [--source ]: set input XML ZUGFeRD 1 file\n" + + " [--out ]: set output XML ZUGFeRD 2 file\n" + + " --action 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" + + " --action validateExpectInvalid validate directory expecting negative results \n" + + " [--no-notices]: refrain from reporting notices\n" + + " Additional parameters (optional - user will be prompted if not defined)\n" + + " -d, --directory to check recursively\n" + + " --action 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" + + " -d, --directory to check recursively \n" + + " --action visualize convert XML to HTML \n" + + " [--language ]: set output lang (en, fr or de)\n" + + " [--source ]: set input XML file\n" + + " [--out ]: set output HTML file\n" + " --action pdf convert XML to PDF \n" + " [--source ]: set input XML file\n" + " [--out ]: set output PDF file\n" @@ -344,18 +345,18 @@ public class Main { attachmentOpt.setArgs(Option.UNLIMITED_VALUES); options.addOption(attachmentOpt); - 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("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")); + 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; + boolean optionsRecognized = false; String action = ""; Boolean disableFileLogging = false; @@ -367,7 +368,7 @@ public class Main { String directoryName = cmd.getOptionValue("directory"); Boolean filesFromStdIn = cmd.hasOption("listfromstdin");//((Number)cmdLine.getParsedOptionValue("integer-option")).intValue(); Boolean ignoreFileExt = cmd.hasOption("ignorefileextension"); - Boolean helpRequested = cmd.hasOption("help") || ((action!=null)&&(action.equals("help"))); + Boolean helpRequested = cmd.hasOption("help") || ((action != null) && (action.equals("help"))); disableFileLogging = cmd.hasOption("disable-file-logging"); String sourceName = cmd.getOptionValue("source"); @@ -383,14 +384,12 @@ public class Main { String[] attachmentFilenames = cmd.hasOption("attachments") ? cmd.getOptionValues("attachments") : null; - - - ArrayList attachments=new ArrayList <>(); + ArrayList attachments = new ArrayList<>(); /* setting system property to disable FILE appender and suppress creation of files and folders. */ - System.setProperty("FILE_APPENDER_ENABLED", ((Boolean)(disableFileLogging==false)).toString()); + System.setProperty("FILE_APPENDER_ENABLED", ((Boolean) (disableFileLogging == false)).toString()); LOGGER = LoggerFactory.getLogger(org.slf4j.Logger.ROOT_LOGGER_NAME); @@ -600,7 +599,7 @@ public class Main { if (format == null) { try { - format = getStringFromUser("Format (fx=Factur-X, zf=ZUGFeRD, ox=Order-X, da=Cross Industry Despatch Advice)", "zf", "fx|zf|ox|da"); + format = getStringFromUser("Format (fx=Factur-X, zf=ZUGFeRD, ox=Order-X, da=Cross Industry Despatch Advice)", "fx", "fx|zf|ox|da"); } catch (Exception e) { LOGGER.error(e.getMessage(), e); } @@ -610,7 +609,7 @@ public class Main { if (zfVersion == null) { try { - zfVersion = getStringFromUser("Version (1 or 2)", Integer.toString(ZUGFeRDExporterFromA3.DefaultZUGFeRDVersion), "1|2"); + zfVersion = getStringFromUser("Version (1 or 2)", "1", "1|2");//fx default version is 1 } catch (Exception e) { LOGGER.error(e.getMessage(), e); } @@ -694,41 +693,33 @@ public class Main { IZUGFeRDExporter ze = null; // All params are good! continue... if (format.equals("ox")) { - ze = new OXExporterFromA1().setProducer("Mustang-cli") - .setZUGFeRDVersion(zfIntVersion) - .setCreator(System.getProperty("user.name")).setProfile(zfConformanceLevelProfile); + ze = new OXExporterFromA1(); if (ignoreInputErrors) { ((OXExporterFromA1) ze).ignorePDFAErrors(); } - } else if (format.equals("da")) { - ze = new DXExporterFromA1().setProducer("Mustang-cli") - .setZUGFeRDVersion(zfIntVersion) - .setCreator(System.getProperty("user.name")).setProfile(zfConformanceLevelProfile); - + ze = new DXExporterFromA1(); if (ignoreInputErrors) { ((DXExporterFromA1) ze).ignorePDFAErrors(); } - } else { if (format.equals("fx")) { - zfIntVersion=2;// actually we are talking of generation, not version + zfIntVersion = 2;// actually we are talking of generation, not version // so even if someone correctly requested factur-x 1 internally we call it zugferd 2 :-( } - ze = new ZUGFeRDExporterFromPDFA().load(pdfName); - - ze.setProducer("Mustang-cli") - .setZUGFeRDVersion(zfIntVersion) - .setCreator(System.getProperty("user.name")).setProfile(zfConformanceLevelProfile); + ze = new ZUGFeRDExporterFromPDFA(); if (ignoreInputErrors) { - ((ZUGFeRDExporterFromA1) ze).ignorePDFAErrors(); + ((ZUGFeRDExporterFromPDFA)ze).ignorePDFAErrors(); } } for (FileAttachment attachment : attachments) { ((ZUGFeRDExporterFromA3) ze).attachFile(attachment.getFilename(), attachment.getData(), attachment.getMimetype(), attachment.getRelation()); } -// ze = ze.load(pdfName); + ze.load(pdfName); + ze.setProducer("Mustang-cli") + .setZUGFeRDVersion(zfIntVersion) + .setCreator(System.getProperty("user.name")).setProfile(zfConformanceLevelProfile); if (format.equals("zf")) { ze.disableFacturX(); diff --git a/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDExporterFromA1.java b/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDExporterFromA1.java index 72bda71d..be7ecd7c 100644 --- a/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDExporterFromA1.java +++ b/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDExporterFromA1.java @@ -31,12 +31,6 @@ import org.mustangproject.EStandard; import jakarta.activation.DataSource; public class ZUGFeRDExporterFromA1 extends ZUGFeRDExporterFromA3 implements IZUGFeRDExporter { - protected boolean ignorePDFAErrors = false; - - public ZUGFeRDExporterFromA1 ignorePDFAErrors() { - this.ignorePDFAErrors = true; - return this; - } private static boolean isValidA1(DataSource dataSource) throws IOException { return getPDFAParserValidationResult(PreflightParserHelper.createPreflightParser(dataSource)); diff --git a/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDExporterFromA3.java b/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDExporterFromA3.java index 64efd879..8ce96b92 100644 --- a/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDExporterFromA3.java +++ b/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDExporterFromA3.java @@ -80,7 +80,12 @@ public class ZUGFeRDExporterFromA3 extends XRExporter implements IZUGFeRDExporte private boolean isFacturX = true; public static final int DefaultZUGFeRDVersion = 2; + protected boolean ignorePDFAErrors = false; + public ZUGFeRDExporterFromA3 ignorePDFAErrors() { + this.ignorePDFAErrors = true; + return this; + } protected PDFAConformanceLevel conformanceLevel = PDFAConformanceLevel.UNICODE; protected ArrayList fileAttachments = new ArrayList(); diff --git a/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDExporterFromPDFA.java b/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDExporterFromPDFA.java index dfddc090..bd722bbf 100644 --- a/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDExporterFromPDFA.java +++ b/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDExporterFromPDFA.java @@ -49,14 +49,28 @@ public class ZUGFeRDExporterFromPDFA implements IZUGFeRDExporter { protected IZUGFeRDExporter theExporter; + protected boolean ignorePDFAErrors = false; + + public ZUGFeRDExporterFromPDFA ignorePDFAErrors() { + this.ignorePDFAErrors = true; + return this; + } protected void determineAndSetExporter(int PDFAVersion) { if (PDFAVersion == 3) { theExporter = new ZUGFeRDExporterFromA3(); + if (ignorePDFAErrors) { + ((ZUGFeRDExporterFromA3)theExporter).ignorePDFAErrors(); + } } else if (PDFAVersion == 1) { theExporter = new ZUGFeRDExporterFromA1(); + if (ignorePDFAErrors) { + ((ZUGFeRDExporterFromA1)theExporter).ignorePDFAErrors(); + } } else { throw new IllegalArgumentException("PDF-A version not supported"); } + + } protected IZUGFeRDExporter getExporter() { if (theExporter==null) { diff --git a/library/src/test/java/org/mustangproject/ZUGFeRD/PreValidationTest.java b/library/src/test/java/org/mustangproject/ZUGFeRD/PreValidationTest.java index 4798a4c0..ba7f0e35 100644 --- a/library/src/test/java/org/mustangproject/ZUGFeRD/PreValidationTest.java +++ b/library/src/test/java/org/mustangproject/ZUGFeRD/PreValidationTest.java @@ -59,10 +59,11 @@ public class PreValidationTest extends TestCase { 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()); + ZUGFeRDExporterFromA1 ze = new ZUGFeRDExporterFromA1(); + ze.ignorePDFAErrors().load(source); + + ze.setProducer("My Application").setCreator(System.getProperty("user.name")).setZUGFeRDVersion(2). + setTransaction(createInvoice()); ze.export(TARGET_PDF); } catch (IOException e) { hasEx = true; diff --git a/library/src/test/java/org/mustangproject/ZUGFeRD/ZF2EdgeTest.java b/library/src/test/java/org/mustangproject/ZUGFeRD/ZF2EdgeTest.java index 67013f69..02ecaef3 100644 --- a/library/src/test/java/org/mustangproject/ZUGFeRD/ZF2EdgeTest.java +++ b/library/src/test/java/org/mustangproject/ZUGFeRD/ZF2EdgeTest.java @@ -293,12 +293,15 @@ public class ZF2EdgeTest extends MustangReaderTestCase implements IExportableTra // the writing part - try (InputStream SOURCE_PDF = this.getClass() + try { + InputStream SOURCE_PDF = this.getClass() .getResourceAsStream("/MustangGnuaccountingBeispielRE-20170509_505blanko.pdf"); - ZUGFeRDExporterFromA1 ze = new ZUGFeRDExporterFromA1().setProducer("My Application") - .setCreator(System.getProperty("user.name")).setZUGFeRDVersion(2).setProfile(Profiles.getByName("Extended")).ignorePDFAErrors() - .load(SOURCE_PDF)) { + ZUGFeRDExporterFromA1 ze = new ZUGFeRDExporterFromA1();ze.ignorePDFAErrors(); + ze.load(SOURCE_PDF); + ze.setProducer("My Application") + .setCreator(System.getProperty("user.name")).setZUGFeRDVersion(2).setProfile(Profiles.getByName("Extended")); + ze.setTransaction(this); String theXML = new String(ze.getProvider().getXML(), StandardCharsets.UTF_8); assertTrue(theXML.contains("")); // maybe add a direct debit mandate to the class in the future then this would fail assertTrue(zi.getUTF8().contains("Hinterhaus")); assertThat(zi.getUTF8()).valueByXPath("//*[local-name()='BuyerTradeParty']/*[local-name()='GlobalID'][@schemeID=0088]").asString() - .isEqualTo("4304171000002"); + .isEqualTo("4304171000002"); assertThat(zi.getUTF8()).valueByXPath("//*[local-name()='SpecifiedTradeProduct']/*[local-name()='GlobalID'][@schemeID=0160]").asString() - .isEqualTo("2001015001325"); + .isEqualTo("2001015001325"); assertTrue(zi.getUTF8().contains("2001015001325")); assertTrue(zi.getUTF8().contains("4304171000002")); assertTrue(zi.getUTF8().contains("0088")); @@ -477,7 +498,7 @@ public class ZF2PushTest extends TestCase { assertTrue(zi.getUTF8().contains("++49555123456")); assertTrue(zi.getUTF8().contains("Cash Discount")); // default description for cash discounts assertThat(zi.getUTF8()).valueByXPath("//*[local-name()='ApplicableTradeTax']/*[local-name()='DueDateTypeCode']").asString() - .isEqualTo(EventTimeCodeTypeConstants.PAYMENT_DATE); + .isEqualTo(EventTimeCodeTypeConstants.PAYMENT_DATE); ZUGFeRDInvoiceImporter zii = new ZUGFeRDInvoiceImporter(TARGET_PUSHEDGE); try { @@ -496,7 +517,6 @@ public class ZF2PushTest extends TestCase { } - } public void testAllowancesExport() { @@ -504,16 +524,20 @@ public class ZF2PushTest extends TestCase { String orgname = "Test company"; String number = "123"; BigDecimal qty = new BigDecimal("20"); - try (InputStream SOURCE_PDF = this.getClass() + try { + InputStream SOURCE_PDF = this.getClass() .getResourceAsStream("/MustangGnuaccountingBeispielRE-20170509_505blanko.pdf"); - ZUGFeRDExporterFromA1 ze = new ZUGFeRDExporterFromA1().setProducer("My Application") - .setCreator(System.getProperty("user.name")).setZUGFeRDVersion(2).setProfile(Profiles.getByName("en16931")).ignorePDFAErrors() - .load(SOURCE_PDF)) { + ZUGFeRDExporterFromA1 ze = new ZUGFeRDExporterFromA1(); + ze.ignorePDFAErrors().load(SOURCE_PDF); + + ze.setProducer("My Application") + .setCreator(System.getProperty("user.name")).setZUGFeRDVersion(2).setProfile(Profiles.getByName("en16931")); + ze.setTransaction(new Invoice().setDueDate(new Date()).setIssueDate(new Date()).setDeliveryDate(new Date()).setSender(new TradeParty(orgname, "teststr", "55232", "teststadt", "DE")).setOwnTaxID("4711").setOwnVATID("DE0815").setRecipient(new TradeParty("Franz Müller", "teststr.12", "55232", "Entenhausen", "DE")).setNumber(number) - .addItem(new Item(new Product("Testprodukt", "", "C62", new BigDecimal(19)), new BigDecimal(500.0), qty).addAllowance(new Allowance(new BigDecimal(300)).setTaxPercent(new BigDecimal(19)))) - .addAllowance(new Allowance(new BigDecimal(600)).setTaxPercent(new BigDecimal(19))) + .addItem(new Item(new Product("Testprodukt", "", "C62", new BigDecimal(19)), new BigDecimal(500.0), qty).addAllowance(new Allowance(new BigDecimal(300)).setTaxPercent(new BigDecimal(19)))) + .addAllowance(new Allowance(new BigDecimal(600)).setTaxPercent(new BigDecimal(19))) ); String theXML = new String(ze.getProvider().getXML()); @@ -547,18 +571,22 @@ public class ZF2PushTest extends TestCase { String number = "123"; String priceStr = "3.00"; BigDecimal price = new BigDecimal(priceStr); - try (InputStream SOURCE_PDF = this.getClass() + try { + InputStream SOURCE_PDF = this.getClass() .getResourceAsStream("/MustangGnuaccountingBeispielRE-20170509_505blanko.pdf"); - ZUGFeRDExporterFromA1 ze = new ZUGFeRDExporterFromA1().setProducer("My Application") - .setCreator(System.getProperty("user.name")).setZUGFeRDVersion(2).setProfile(Profiles.getByName("extended")).ignorePDFAErrors() - .load(SOURCE_PDF)) { + ZUGFeRDExporterFromA1 ze = new ZUGFeRDExporterFromA1(); + ze.ignorePDFAErrors() + .load(SOURCE_PDF); + + ze.setProducer("My Application") + .setCreator(System.getProperty("user.name")).setZUGFeRDVersion(2).setProfile(Profiles.getByName("extended")); ze.setTransaction(new Invoice().setCurrency("CHF").setDueDate(new Date()).setIssueDate(new Date()).setDeliveryDate(new Date()).setSender(new TradeParty(orgname, "teststr", "55232", "teststadt", "DE")).setOwnTaxID("4711").setOwnVATID("DE0815").setRecipient(new TradeParty("Franz Müller", "teststr.12", "55232", "Entenhausen", "DE")).setNumber(number) - .addItem(new Item(new Product("Testprodukt", "", "C62", new BigDecimal(19)), price, new BigDecimal(1.0))) - .addItem(new Item(new Product("Testprodukt", "", "C62", new BigDecimal(19)), price, new BigDecimal(1.0))) - .addItem(new Item(new Product("Testprodukt", "", "C62", new BigDecimal(19)), price, new BigDecimal(1.0)).addCharge(new Charge().setPercent(new BigDecimal(50)).setTaxPercent(new BigDecimal(19)))) - .addAllowance(new Allowance().setPercent(new BigDecimal(50)).setTaxPercent(new BigDecimal(19))) + .addItem(new Item(new Product("Testprodukt", "", "C62", new BigDecimal(19)), price, new BigDecimal(1.0))) + .addItem(new Item(new Product("Testprodukt", "", "C62", new BigDecimal(19)), price, new BigDecimal(1.0))) + .addItem(new Item(new Product("Testprodukt", "", "C62", new BigDecimal(19)), price, new BigDecimal(1.0)).addCharge(new Charge().setPercent(new BigDecimal(50)).setTaxPercent(new BigDecimal(19)))) + .addAllowance(new Allowance().setPercent(new BigDecimal(50)).setTaxPercent(new BigDecimal(19))) ); String theXML = new String(ze.getProvider().getXML()); @@ -599,17 +627,20 @@ public class ZF2PushTest extends TestCase { String priceStr = "1.00"; BigDecimal price = new BigDecimal(priceStr); BigDecimal qty = new BigDecimal(-1.0); - try (InputStream SOURCE_PDF = this.getClass() + try { + InputStream SOURCE_PDF = this.getClass() .getResourceAsStream("/MustangGnuaccountingBeispielRE-20170509_505blanko.pdf"); - ZUGFeRDExporterFromA1 ze = new ZUGFeRDExporterFromA1().setProducer("My Application") - .setCreator(System.getProperty("user.name")).setZUGFeRDVersion(2).ignorePDFAErrors() - .load(SOURCE_PDF)) { + ZUGFeRDExporterFromA1 ze = new ZUGFeRDExporterFromA1(); + ze.ignorePDFAErrors() + .load(SOURCE_PDF); + ze.setProducer("My Application") + .setCreator(System.getProperty("user.name")).setZUGFeRDVersion(2); // no due date, since we are not expecting money Invoice i = new Invoice().setIssueDate(new Date()).setDetailedDeliveryPeriod(new Date(), new Date()).setDeliveryDate(new Date()).setSender(new TradeParty(orgname, "teststr", "55232", "teststadt", "DE").addTaxID("4711").addVATID("DE0815")).setRecipient(new TradeParty("Franz Müller", "teststr.12", "55232", "Entenhausen", "DE").addVATID("DE0815")).setNumber(number) - .addItem(new Item(new Product("Testprodukt", "", "C62", new BigDecimal(19)), price, qty)) - .addItem(new Item(new Product("Testprodukt", "", "C62", new BigDecimal(19)), price, qty)) - .addItem(new Item(new Product("Testprodukt", "", "C62", new BigDecimal(19)), price, qty)).setCorrection("0815"); + .addItem(new Item(new Product("Testprodukt", "", "C62", new BigDecimal(19)), price, qty)) + .addItem(new Item(new Product("Testprodukt", "", "C62", new BigDecimal(19)), price, qty)) + .addItem(new Item(new Product("Testprodukt", "", "C62", new BigDecimal(19)), price, qty)).setCorrection("0815"); ze.setTransaction(i); String theXML = new String(ze.getProvider().getXML()); assertTrue(theXML.contains("