allow Order-X XML to be added manually, have Order-X-Functionality in Commandline

This commit is contained in:
jstaerk
2022-01-10 16:08:09 +01:00
parent c7cf3a9df1
commit 9acab34f77
10 changed files with 69 additions and 25 deletions

View File

@@ -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) {