From 1675728563f02ca1c15ca6eec1b78dec9a32b5df Mon Sep 17 00:00:00 2001 From: jstaerk Date: Sun, 3 Jan 2021 10:47:03 +0100 Subject: [PATCH 1/2] Enabling functionality via Command line, changing POM so no errors occur --- History.md | 3 +- .../org/mustangproject/commandline/Main.java | 41 ++++++++++++++++++- library/pom.xml | 25 +++++------ 3 files changed, 55 insertions(+), 14 deletions(-) diff --git a/History.md b/History.md index 9227afca..52ab562d 100644 --- a/History.md +++ b/History.md @@ -1,6 +1,7 @@ 2.1.0 ======= - +- make IExportableTransaction.getZFAllowances() getZFCharges() and getZFLogisticsServiceCharges() and item.getItemAllowances, item.getItemCharges optional, correct getCurrency optionality + make IZUGFeRDExportableTradeParty name id zip location street mandatory - fixed a charge/allowance rounding error #212 - Corrected intra community supply tax exemption category code 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 5221d9a8..15bebf34 100755 --- a/Mustang-CLI/src/main/java/org/mustangproject/commandline/Main.java +++ b/Mustang-CLI/src/main/java/org/mustangproject/commandline/Main.java @@ -20,6 +20,7 @@ package org.mustangproject.commandline; import com.sanityinc.jargs.CmdLineParser; import com.sanityinc.jargs.CmdLineParser.Option; +import org.mustangproject.CII.CIIToUBL; import org.mustangproject.ZUGFeRD.*; import org.mustangproject.validator.Validator; import org.mustangproject.validator.ZUGFeRDValidator; @@ -46,7 +47,7 @@ public class Main { } private static String getUsage() { - return "Usage: --action metrics|combine|extract|a3only|validate|visualize [-d,--directory] [-l,--listfromstdin] [-i,--ignore fileextension, PDF/A errors] | [-h,--help] \r\n" + return "Usage: --action metrics|combine|extract|a3only|ubl|validate|visualize [-d,--directory] [-l,--listfromstdin] [-i,--ignore fileextension, PDF/A errors] | [-h,--help] \r\n" + " --action=metrics\n" + " -d, --directory count ZUGFeRD files in directory to be scanned\n" + " If it is a directory, it will recurse.\n" @@ -85,6 +86,9 @@ public class Main { + " [--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=ubl convert UN/CEFACT 2016b CII XML to UBL XML\n" + + " [--source ]: set input XML file\n" + + " [--out ]: set output 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" @@ -250,6 +254,38 @@ public class Main { Files.write(Paths.get(outName), xml.getBytes()); System.out.println("Written to " + outName); + } + + /*** + * converts from CII to UBL + * @param xmlName + * @param outName + * @throws IOException + * @throws TransformerException + */ + private static void performUBL(String xmlName, String outName) throws IOException, TransformerException { + + // Get params from user if not already defined + if (xmlName == null) { + xmlName = getFilenameFromUser("Factur-X XML source", "factur-x.xml", "xml", true, false); + } else { + System.out.println("Factur-X XML source set to " + xmlName); + } + if (outName == null) { + outName = getFilenameFromUser("UBL target", "ubl-invoice.xml", "xml", false, true); + } else { + System.out.println("UBL target to " + outName); + } + + // Verify params + ensureFileExists(xmlName); + ensureFileNotExists(outName); + + // All params are good! continue... + CIIToUBL c2u = new CIIToUBL(); + c2u.convert(new File(xmlName), new File(outName)); + System.out.println("Written to " + outName); + } /*** * the main function of the commandline tool... @@ -338,6 +374,9 @@ public class Main { } else if ((action!=null)&&(action.equals("upgrade"))) { performUpgrade(sourceName, outName); optionsRecognized=true; + } else if ((action!=null)&&(action.equals("ubl"))) { + performUBL(sourceName, outName); + optionsRecognized=true; } else if ((action!=null)&&(action.equals("validate"))) { optionsRecognized=performValidate(sourceName, noNotices!=null&&noNotices, parser.getOptionValue(logAppendOption)); } else if ((action!=null)&&(action.equals("validateExpectValid"))) { diff --git a/library/pom.xml b/library/pom.xml index 6686b648..649d4825 100644 --- a/library/pom.xml +++ b/library/pom.xml @@ -90,6 +90,12 @@ en16931-cii2ubl 1.2.5 + + + org.glassfish.jaxb + jaxb-runtime + 2.3.3 + com.helger @@ -115,6 +121,12 @@ 9.1.1 compile + + + jakarta.xml.bind + jakarta.xml.bind-api + 2.3.3 + @@ -124,12 +136,6 @@ maven-compiler-plugin 3.6.1 - - - true - org.mustangproject.toecount.Toecount - - jar-with-dependencies @@ -145,12 +151,7 @@ maven-shade-plugin 3.2.1 - true - - - org.mustangproject.toecount.Toecount - - + false false From 2defd02f1da14d8996c1f95e71058ccad9e49024 Mon Sep 17 00:00:00 2001 From: jstaerk Date: Tue, 19 Jan 2021 08:59:26 +0100 Subject: [PATCH 2/2] switch to cii2ubl 1.3.0, update commandline help, remove getZip in favor of getZIP --- History.md | 1 + .../src/main/java/org/mustangproject/commandline/Main.java | 2 ++ library/pom.xml | 2 +- library/src/main/java/org/mustangproject/TradeParty.java | 4 ---- 4 files changed, 4 insertions(+), 5 deletions(-) diff --git a/History.md b/History.md index 52ab562d..842d781e 100644 --- a/History.md +++ b/History.md @@ -4,6 +4,7 @@ make IZUGFeRDExportableTradeParty name id zip location street mandatory - fixed a charge/allowance rounding error #212 - Corrected intra community supply tax exemption category code +- removal of Tradeparty.getZip in favor of getZIP (as it's also setZIP) to avoid jackson errors 2.0.3 ======= 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 15bebf34..4cf0b397 100755 --- a/Mustang-CLI/src/main/java/org/mustangproject/commandline/Main.java +++ b/Mustang-CLI/src/main/java/org/mustangproject/commandline/Main.java @@ -94,6 +94,8 @@ public class Main { + " Additional parameters (optional - user will be prompted if not defined)\n" + " -d, --directory to check recursively\n" + " --action=visualize convert XML to HTML \n" + + " [--source ]: set input XML file\n" + + " [--out ]: set output HTML file\n" ; } diff --git a/library/pom.xml b/library/pom.xml index 649d4825..cf83c46b 100644 --- a/library/pom.xml +++ b/library/pom.xml @@ -88,7 +88,7 @@ com.helger en16931-cii2ubl - 1.2.5 + 1.3.0 diff --git a/library/src/main/java/org/mustangproject/TradeParty.java b/library/src/main/java/org/mustangproject/TradeParty.java index 5729fb53..0e906846 100644 --- a/library/src/main/java/org/mustangproject/TradeParty.java +++ b/library/src/main/java/org/mustangproject/TradeParty.java @@ -268,10 +268,6 @@ public class TradeParty implements IZUGFeRDExportableTradeParty { return vatID; } - public String getZip() { - return zip; - } - @Override public IZUGFeRDExportableContact getContact() { return contact;