allow Order-X XML to be added manually, have Order-X-Functionality in Commandline
This commit is contained in:
@@ -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
|
||||
=======
|
||||
|
||||
@@ -113,8 +113,8 @@
|
||||
<!-- http://stackoverflow.com/questions/574594/how-can-i-create-an-executable-jar-with-dependencies-using-maven
|
||||
mvn clean compile assembly:single -->
|
||||
<!-- or whatever version you use -->
|
||||
<source>1.7</source>
|
||||
<target>1.7</target>
|
||||
<source>8</source>
|
||||
<target>8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<!-- /ZUV -->
|
||||
|
||||
@@ -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")
|
||||
if (format.equals("ox")) {
|
||||
ze = new OXExporterFromA1().setProducer("Mustang-cli")
|
||||
.setZUGFeRDVersion(zfIntVersion)
|
||||
.setCreator(System.getProperty("user.name")).setProfile(zfConformanceLevelProfile);
|
||||
|
||||
if (ignoreInputErrors) {
|
||||
ze.ignorePDFAErrors();
|
||||
((OXExporterFromA1)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) {
|
||||
|
||||
@@ -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 (<rsm:)CrossIndustry and can thus not be valid");
|
||||
/**
|
||||
* rsm:CrossIndustry is ZF/FX/XR (CII 2016b) and rsm:SCRDMCCBDACIOMessageStructure is of course Order-X (CIO 2021)
|
||||
*/
|
||||
if ((!zf.contains("rsm:CrossIndustry")) && (!zf.contains("rsm:SCRDMCCBDACIOMessageStructure"))) {
|
||||
throw new RuntimeException("ZUGFeRD XML does not contain <rsm:CrossIndustry or <rsm:SCRDMCCBDACIOMessageStructure and can thus not be valid");
|
||||
}
|
||||
|
||||
zugferdData = newData;
|
||||
|
||||
@@ -38,6 +38,22 @@ public class OXExporterFromA1 extends OXExporterFromA3 implements IZUGFeRDExport
|
||||
private static boolean isValidA1(DataSource dataSource) throws IOException {
|
||||
return getPDFAParserValidationResult(new PreflightParser(dataSource));
|
||||
}
|
||||
/***
|
||||
* internal helper function: get namespace for order-x
|
||||
* @param ver the order-x version
|
||||
* @return the URN of the namespace
|
||||
*/
|
||||
public String getNamespaceForVersion(int ver) {
|
||||
return "urn:factur-x:pdfa:CrossIndustryDocument:1p0#";
|
||||
}
|
||||
/***
|
||||
* internal helper: returns the namespace prefix for the given order-x version number
|
||||
* @param ver the ox version
|
||||
* @return the namespace prefix as string, without colon
|
||||
*/
|
||||
public String getPrefixForVersion(int ver) {
|
||||
return "fx";
|
||||
}
|
||||
|
||||
private static boolean getPDFAParserValidationResult(PreflightParser parser) throws IOException {
|
||||
/*
|
||||
|
||||
@@ -393,15 +393,17 @@ public class OXExporterFromA3 extends ZUGFeRDExporterFromA3 {
|
||||
XMPSchemaZugferd zf = new XMPSchemaZugferd(metadata, 1, true, xmlProvider.getProfile(),
|
||||
"urn:factur-x:pdfa:CrossIndustryDocument:1p0#", "fx",
|
||||
"order-x.xml");
|
||||
zf.setType("ORDER");
|
||||
|
||||
metadata.addSchema(zf);
|
||||
}
|
||||
|
||||
// also add the schema extensions...
|
||||
XMPSchemaPDFAExtensions pdfaex = new XMPSchemaPDFAExtensions(this, metadata, 1, attachZUGFeRDHeaders);
|
||||
pdfaex.setZUGFeRDVersion(1);
|
||||
metadata.addSchema(pdfaex);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Embeds the Zugferd XML structure in a file named ZUGFeRD-invoice.xml.
|
||||
|
||||
@@ -116,7 +116,7 @@ public class XMPSchemaPDFAExtensions extends PDFAExtensionSchema {
|
||||
addProperty(newBag);
|
||||
if (withZF) {
|
||||
TextType pdfa1 = new TextType(metadata, xmlns_pdfaSchema, prefix_pdfaSchema, PDFASchemaType.SCHEMA,
|
||||
"ZUGFeRD PDFA Extension Schema");
|
||||
"Factur-X PDFA Extension Schema");
|
||||
li.addProperty(pdfa1);
|
||||
|
||||
pdfa1 = new TextType(metadata, xmlns_pdfaSchema, prefix_pdfaSchema, PDFASchemaType.NAMESPACE_URI,
|
||||
|
||||
@@ -56,4 +56,13 @@ public class XMPSchemaZugferd extends XMPSchema {
|
||||
}
|
||||
setTextPropertyValue("Version", version);
|
||||
}
|
||||
|
||||
/***
|
||||
* Specify a custom XMP metadata document type
|
||||
* @param type INVOICE or ORDER
|
||||
*/
|
||||
public XMPSchemaZugferd setType(String type) {
|
||||
setTextPropertyValue("DocumentType", type);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -168,7 +168,6 @@ public class ZUGFeRDExporterFromA3 extends XRExporter implements IZUGFeRDExporte
|
||||
return "urn:ferd:pdfa:CrossIndustryDocument:invoice:1p0#";
|
||||
} else if (ver == 2) {
|
||||
return "urn:zugferd:pdfa:CrossIndustryDocument:invoice:2p0#";
|
||||
|
||||
} else {
|
||||
throw new IllegalArgumentException("Version not supported");
|
||||
}
|
||||
|
||||
@@ -234,7 +234,7 @@ public class MustangReaderWriterTest extends MustangReaderTestCase {
|
||||
" <pdfaExtension:schemas>\n" +
|
||||
" <rdf:Bag>\n" +
|
||||
" <rdf:li rdf:parseType=\"Resource\">\n" +
|
||||
" <pdfaSchema:schema>ZUGFeRD PDFA Extension Schema</pdfaSchema:schema>\n" +
|
||||
" <pdfaSchema:schema>Factur-X PDFA Extension Schema</pdfaSchema:schema>\n" +
|
||||
" <pdfaSchema:namespaceURI>urn:ferd:pdfa:CrossIndustryDocument:invoice:1p0#</pdfaSchema:namespaceURI>\n" +
|
||||
" <pdfaSchema:prefix>zf</pdfaSchema:prefix>\n" +
|
||||
" <pdfaSchema:property>\n" +
|
||||
|
||||
Reference in New Issue
Block a user