diff --git a/History.md b/History.md index b0b88931..72dcaa73 100644 --- a/History.md +++ b/History.md @@ -10,6 +10,8 @@ - add signature comment into xml - upgraded en16931 validation to 1.3.7 - upgraded xrechnung schematron to 1.6.1 +- changed PDF/A extension scheme name from ZUGFeRD to Factur-X +- corrected a possible nullpointerexception in contact.getPhone() vs. getName() (thanks to Chritoph W.) 2.3.3 ======= diff --git a/Mustang-CLI/pom.xml b/Mustang-CLI/pom.xml index 4adcd09b..37a7d292 100644 --- a/Mustang-CLI/pom.xml +++ b/Mustang-CLI/pom.xml @@ -113,8 +113,8 @@ - 1.7 - 1.7 + 8 + 8 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 51eeb88f..bd28c417 100755 --- a/Mustang-CLI/src/main/java/org/mustangproject/commandline/Main.java +++ b/Mustang-CLI/src/main/java/org/mustangproject/commandline/Main.java @@ -21,12 +21,12 @@ package org.mustangproject.commandline; import com.sanityinc.jargs.CmdLineParser; import com.sanityinc.jargs.CmdLineParser.Option; import org.mustangproject.CII.CIIToUBL; +import org.mustangproject.EStandard; import org.mustangproject.ZUGFeRD.*; import org.mustangproject.validator.Validator; import org.mustangproject.validator.ZUGFeRDValidator; import java.io.*; -import java.net.URL; import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Path; @@ -564,7 +564,7 @@ public class Main { if (format == null) { try { - format = getStringFromUser("Format (fx=Factur-X, zf=ZUGFeRD)", "zf", "fx|zf"); + format = getStringFromUser("Format (fx=Factur-X, zf=ZUGFeRD, ox=Order-X)", "zf", "fx|zf|ox"); } catch (Exception e) { LOGGER.error(e.getMessage(), e); } @@ -585,7 +585,7 @@ public class Main { if (zfProfile == null) { try { - if (format.equals("zf") && (zfIntVersion == 1)) { + if (format.equals("zf") && (zfIntVersion == 1) || (format.equals("ox"))) { zfProfile = getStringFromUser("Profile (b)asic, (c)omfort or ex(t)ended", "t", "B|b|C|c|T|t"); } else { zfProfile = getStringFromUser( @@ -609,13 +609,18 @@ public class Main { throw new Exception("Factur-X is only available in version 1 (roughly corresponding to ZF2)"); } - if ((format.equals("zf")) && (zfIntVersion == 1)) { + if (((format.equals("zf")) && (zfIntVersion == 1))||(format.equals("ox"))) { + EStandard standard=EStandard.facturx; + if (format.equals("ox")) { + standard=EStandard.orderx; + } + if (zfProfile.equals("b")) { - zfConformanceLevelProfile = Profiles.getByName("BASIC", zfIntVersion); + zfConformanceLevelProfile = Profiles.getByName(standard, "BASIC", zfIntVersion); } else if (zfProfile.equals("c")) { - zfConformanceLevelProfile = Profiles.getByName("COMFORT", zfIntVersion); + zfConformanceLevelProfile = Profiles.getByName(standard, "COMFORT", zfIntVersion); } else if (zfProfile.equals("t")) { - zfConformanceLevelProfile = Profiles.getByName("EXTENDED", zfIntVersion); + zfConformanceLevelProfile = Profiles.getByName(standard, "EXTENDED", zfIntVersion); } else { throw new Exception(String.format("Unknown ZUGFeRD profile '%s'", zfProfile)); } @@ -641,25 +646,33 @@ public class Main { throw new Exception(String.format("Unknown version '%i'", zfIntVersion)); } + IZUGFeRDExporter ze=null; // All params are good! continue... - ZUGFeRDExporterFromA1 ze = new ZUGFeRDExporterFromA1().setProducer("Mustang-cli") - .setZUGFeRDVersion(zfIntVersion) - .setCreator(System.getProperty("user.name")).setProfile(zfConformanceLevelProfile); + if (format.equals("ox")) { + ze = new OXExporterFromA1().setProducer("Mustang-cli") + .setZUGFeRDVersion(zfIntVersion) + .setCreator(System.getProperty("user.name")).setProfile(zfConformanceLevelProfile); + if (ignoreInputErrors) { + ((OXExporterFromA1)ze).ignorePDFAErrors(); + } - if (ignoreInputErrors) { - ze.ignorePDFAErrors(); + } else { + ze = new ZUGFeRDExporterFromA1().setProducer("Mustang-cli") + .setZUGFeRDVersion(zfIntVersion) + .setCreator(System.getProperty("user.name")).setProfile(zfConformanceLevelProfile); + if (ignoreInputErrors) { + ((ZUGFeRDExporterFromA1)ze).ignorePDFAErrors(); + } } ze = ze.load(pdfName); - if (!format.equals("fx")) { + if (format.equals("zf")) { ze.disableFacturX(); } ze.setXML(Files.readAllBytes(Paths.get(xmlName))); - ze.export(outName); - System.out.println("Written to " + outName); } catch (IOException e) { diff --git a/library/src/main/java/org/mustangproject/ZUGFeRD/CustomXMLProvider.java b/library/src/main/java/org/mustangproject/ZUGFeRD/CustomXMLProvider.java index 6da66898..706114a2 100644 --- a/library/src/main/java/org/mustangproject/ZUGFeRD/CustomXMLProvider.java +++ b/library/src/main/java/org/mustangproject/ZUGFeRD/CustomXMLProvider.java @@ -32,8 +32,11 @@ public class CustomXMLProvider implements IXMLProvider { public void setXML(byte[] newData) { String zf = new String(newData, StandardCharsets.UTF_8); - if (!zf.contains("CrossIndustry")) { - throw new RuntimeException("ZUGFeRD XML does not contain (\n" + " \n" + " \n" + - " ZUGFeRD PDFA Extension Schema\n" + + " Factur-X PDFA Extension Schema\n" + " urn:ferd:pdfa:CrossIndustryDocument:invoice:1p0#\n" + " zf\n" + " \n" +