Enabling functionality via Command line, changing POM so no errors occur

This commit is contained in:
jstaerk
2021-01-03 10:47:03 +01:00
parent 3d90d215b2
commit 1675728563
3 changed files with 55 additions and 14 deletions

View File

@@ -1,6 +1,7 @@
2.1.0 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 - fixed a charge/allowance rounding error #212
- Corrected intra community supply tax exemption category code - Corrected intra community supply tax exemption category code

View File

@@ -20,6 +20,7 @@ package org.mustangproject.commandline;
import com.sanityinc.jargs.CmdLineParser; import com.sanityinc.jargs.CmdLineParser;
import com.sanityinc.jargs.CmdLineParser.Option; import com.sanityinc.jargs.CmdLineParser.Option;
import org.mustangproject.CII.CIIToUBL;
import org.mustangproject.ZUGFeRD.*; import org.mustangproject.ZUGFeRD.*;
import org.mustangproject.validator.Validator; import org.mustangproject.validator.Validator;
import org.mustangproject.validator.ZUGFeRDValidator; import org.mustangproject.validator.ZUGFeRDValidator;
@@ -46,7 +47,7 @@ public class Main {
} }
private static String getUsage() { 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" + " --action=metrics\n"
+ " -d, --directory count ZUGFeRD files in directory to be scanned\n" + " -d, --directory count ZUGFeRD files in directory to be scanned\n"
+ " If it is a directory, it will recurse.\n" + " If it is a directory, it will recurse.\n"
@@ -85,6 +86,9 @@ public class Main {
+ " [--no-notices]: refrain from reporting notices\n" + " [--no-notices]: refrain from reporting notices\n"
+ " Additional parameters (optional - user will be prompted if not defined)\n" + " Additional parameters (optional - user will be prompted if not defined)\n"
+ " -d, --directory to check recursively \n" + " -d, --directory to check recursively \n"
+ " --action=ubl convert UN/CEFACT 2016b CII XML to UBL XML\n"
+ " [--source <filename>]: set input XML file\n"
+ " [--out <filename>]: set output XML file\n"
+ " --action=validateExpectInvalid validate directory expecting negative results \n" + " --action=validateExpectInvalid validate directory expecting negative results \n"
+ " [--no-notices]: refrain from reporting notices\n" + " [--no-notices]: refrain from reporting notices\n"
+ " Additional parameters (optional - user will be prompted if not defined)\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()); Files.write(Paths.get(outName), xml.getBytes());
System.out.println("Written to " + outName); 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... * the main function of the commandline tool...
@@ -338,6 +374,9 @@ public class Main {
} else if ((action!=null)&&(action.equals("upgrade"))) { } else if ((action!=null)&&(action.equals("upgrade"))) {
performUpgrade(sourceName, outName); performUpgrade(sourceName, outName);
optionsRecognized=true; optionsRecognized=true;
} else if ((action!=null)&&(action.equals("ubl"))) {
performUBL(sourceName, outName);
optionsRecognized=true;
} else if ((action!=null)&&(action.equals("validate"))) { } else if ((action!=null)&&(action.equals("validate"))) {
optionsRecognized=performValidate(sourceName, noNotices!=null&&noNotices, parser.getOptionValue(logAppendOption)); optionsRecognized=performValidate(sourceName, noNotices!=null&&noNotices, parser.getOptionValue(logAppendOption));
} else if ((action!=null)&&(action.equals("validateExpectValid"))) { } else if ((action!=null)&&(action.equals("validateExpectValid"))) {

View File

@@ -90,6 +90,12 @@
<artifactId>en16931-cii2ubl</artifactId> <artifactId>en16931-cii2ubl</artifactId>
<version>1.2.5</version> <version>1.2.5</version>
</dependency> </dependency>
<!-- https://mvnrepository.com/artifact/org.glassfish.jaxb/jaxb-runtime -->
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
<version>2.3.3</version>
</dependency>
<dependency> <dependency>
<groupId>com.helger</groupId> <groupId>com.helger</groupId>
@@ -115,6 +121,12 @@
<version>9.1.1</version> <version>9.1.1</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<!-- API -->
<dependency>
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
<version>2.3.3</version>
</dependency>
</dependencies> </dependencies>
<build> <build>
@@ -124,12 +136,6 @@
<artifactId>maven-compiler-plugin</artifactId> <artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version> <version>3.6.1</version>
<configuration> <configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>org.mustangproject.toecount.Toecount</mainClass>
</manifest>
</archive>
<descriptorRefs> <descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef> <descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs> </descriptorRefs>
@@ -145,12 +151,7 @@
<artifactId>maven-shade-plugin</artifactId> <artifactId>maven-shade-plugin</artifactId>
<version>3.2.1</version> <version>3.2.1</version>
<configuration> <configuration>
<shadedArtifactAttached>true</shadedArtifactAttached> <shadedArtifactAttached>false</shadedArtifactAttached>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>org.mustangproject.toecount.Toecount</mainClass>
</transformer>
</transformers>
<minimizeJar>false</minimizeJar><!-- no longer java 11 compatible if set to true because it removes e.g. javax/xml/bind/annotation/XmlSchema--> <minimizeJar>false</minimizeJar><!-- no longer java 11 compatible if set to true because it removes e.g. javax/xml/bind/annotation/XmlSchema-->
<filters> <filters>