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 63776d73..60eea2d4 100755 --- a/Mustang-CLI/src/main/java/org/mustangproject/commandline/Main.java +++ b/Mustang-CLI/src/main/java/org/mustangproject/commandline/Main.java @@ -601,8 +601,10 @@ public class Main { if (zfProfile == null) { try { - if ((format.equals("zf") && (zfIntVersion == 1)) || (format.equals("ox") || (format.equals("dx")))) { + 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 if ( (format.equals("dx"))) { + zfProfile = getStringFromUser("Profile (p)ilot", "p", "P|p"); } else { zfProfile = getStringFromUser( "Profile [M]INIMUM, BASIC [W]L, [B]ASIC,\n" + "[C]IUS, [E]N16931, EX[T]ENDED or [X]RECHNUNG", "E", @@ -627,14 +629,17 @@ public class Main { throw new Exception("Factur-X is only available in version 1 (roughly corresponding to ZF2)"); } - if (((format.equals("zf")) && (zfIntVersion == 1))||(format.equals("ox")||(format.equals("dx")))) { - EStandard standard=EStandard.facturx; + EStandard standard=EStandard.facturx; + if (format.equals("dx")) { + standard=EStandard.deliverx; + + zfConformanceLevelProfile = Profiles.getByName(standard, "PILOT", 1); + } + else if (((format.equals("zf")) && (zfIntVersion == 1))||(format.equals("ox"))) { if (format.equals("ox")) { standard=EStandard.orderx; } - if (format.equals("dx")) { - standard=EStandard.deliverx; - } + if (zfProfile.equals("b")) { zfConformanceLevelProfile = Profiles.getByName(standard, "BASIC", zfIntVersion); @@ -681,6 +686,7 @@ public class Main { ze = new DXExporterFromA1().setProducer("Mustang-cli") .setZUGFeRDVersion(zfIntVersion) .setCreator(System.getProperty("user.name")).setProfile(zfConformanceLevelProfile); + if (ignoreInputErrors) { ((DXExporterFromA1)ze).ignorePDFAErrors(); } @@ -704,11 +710,13 @@ public class Main { } ze.setXML(Files.readAllBytes(Paths.get(xmlName))); + ze.export(outName); System.out.println("Written to " + outName); - } catch (IOException e) { + } catch (Exception e) { LOGGER.error(e.getMessage(), e); + System.err.println(e.getMessage()); } } diff --git a/library/src/main/java/org/mustangproject/ZUGFeRD/CustomXMLProvider.java b/library/src/main/java/org/mustangproject/ZUGFeRD/CustomXMLProvider.java index 706114a2..45f79f2f 100644 --- a/library/src/main/java/org/mustangproject/ZUGFeRD/CustomXMLProvider.java +++ b/library/src/main/java/org/mustangproject/ZUGFeRD/CustomXMLProvider.java @@ -33,10 +33,11 @@ public class CustomXMLProvider implements IXMLProvider { public void setXML(byte[] newData) { String zf = new String(newData, StandardCharsets.UTF_8); /** - * rsm:CrossIndustry is ZF/FX/XR (CII 2016b) and rsm:SCRDMCCBDACIOMessageStructure is of course Order-X (CIO 2021) + * rsm:CrossIndustry is ZF/FX/XR (CII 2016b),rsm:SCRDMCCBDACIOMessageStructure is Order-X (CIO 2021) and + * SCRDMCCBDACIDAMessageStructure is Despatch Advice */ - if ((!zf.contains("rsm:CrossIndustry")) && (!zf.contains("rsm:SCRDMCCBDACIOMessageStructure"))) { - throw new RuntimeException("ZUGFeRD XML does not contain additionalXMLs = new HashMap(); @@ -396,15 +396,15 @@ public class DXExporterFromA3 extends ZUGFeRDExporterFromA3 { } /** - * Sets the property orderXDocumentType. + * Sets the property for DocumentType. * - * @param orderXDocumentType new value. Expected: ORDER, ORDER_RESPONSE, or ORDER_CHANGE + * @param * * @return this exporter */ - public DXExporterFromA3 setOrderXDocumentType(String orderXDocumentType) + public DXExporterFromA3 setDocumentType(String DocumentType) { - this.orderXDocumentType = orderXDocumentType; + this.deliverXDocumentType = DocumentType; return this; } @@ -426,9 +426,9 @@ public class DXExporterFromA3 extends ZUGFeRDExporterFromA3 { if (attachZUGFeRDHeaders) { XMPSchemaZugferd zf = new XMPSchemaZugferd(metadata, 1, true, xmlProvider.getProfile(), - "urn:factur-x:pdfa:CrossIndustryDocument:1p0#", "fx", - "deliver-x.xml"); - zf.setType(this.orderXDocumentType); + "urn:facturx:pdfa:CrossIndustryDocument:despatchadvice:1p0#", "fx", + "cida.xml"); + zf.setType(this.deliverXDocumentType); metadata.addSchema(zf); // also add the schema extensions... @@ -457,9 +457,9 @@ public class DXExporterFromA3 extends ZUGFeRDExporterFromA3 { public IExporter prepare() throws IOException { prepareDocument(); xmlProvider.generateXML(trans); - String filename = "deliver-x.xml"; + String filename = "cida.xml"; PDFAttachGenericFile(doc, filename, "Alternative", - "Order metadata conforming to the Order-X standard (https://www.ferd-net.de/standards/order-x/index.html)", + "Delivery metadata", "text/xml", xmlProvider.getXML()); for (FileAttachment attachment : fileAttachments) { diff --git a/library/src/main/java/org/mustangproject/ZUGFeRD/Profiles.java b/library/src/main/java/org/mustangproject/ZUGFeRD/Profiles.java index b2be449d..2e81bb18 100644 --- a/library/src/main/java/org/mustangproject/ZUGFeRD/Profiles.java +++ b/library/src/main/java/org/mustangproject/ZUGFeRD/Profiles.java @@ -51,11 +51,7 @@ public class Profiles { }).collect(Collectors.toMap(data -> (String) data[0], data -> (Profile) data[1])); static Map dx1Map = Stream.of(new Object[][]{ - {"BASIC", new Profile("BASIC", "urn:order-x.eu:1p0:basic")}, - {"COMFORT", new Profile("COMFORT", "urn:order-x.eu:1p0:comfort")}, - {"EXTENDED", new Profile("EXTENDED", "urn:order-x.eu:1p0:extended")}, - - + {"PILOT", new Profile("PILOT", "urn:facturx:pdfa:CrossIndustryDocument:despatchadvice:1p0#")} }).collect(Collectors.toMap(data -> (String) data[0], data -> (Profile) data[1])); diff --git a/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDImporter.java b/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDImporter.java index c6777343..21615e52 100644 --- a/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDImporter.java +++ b/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDImporter.java @@ -149,7 +149,7 @@ public class ZUGFeRDImporter { /** * filenames for invoice data (ZUGFeRD v1 and v2, Factur-X) */ - if ((filename.equals("ZUGFeRD-invoice.xml") || (filename.equals("zugferd-invoice.xml")) || filename.equals("factur-x.xml")) || filename.equals("xrechnung.xml") || filename.equals("order-x.xml") || filename.equals("deliver-x.xml")) { + if ((filename.equals("ZUGFeRD-invoice.xml") || (filename.equals("zugferd-invoice.xml")) || filename.equals("factur-x.xml")) || filename.equals("xrechnung.xml") || filename.equals("order-x.xml") || filename.equals("cida.xml")) { containsMeta = true; final PDEmbeddedFile embeddedFile = fileSpec.getEmbeddedFile();