allow new ZF2 profiles

This commit is contained in:
Jochen Stärk
2017-11-27 18:31:14 +01:00
parent 0f4dbc1bb5
commit b557dc752c
7 changed files with 65 additions and 17 deletions

View File

@@ -20,7 +20,11 @@ public class XMPSchemaZugferd extends XMPSchema {
setAboutAsSimple("");
setTextPropertyValue("ConformanceLevel", conformanceLevel.name());
String conformanceLevelValue=conformanceLevel.name();
if (conformanceLevelValue.equals("BASICWL")) {
conformanceLevelValue="BASIC WL";
}
setTextPropertyValue("ConformanceLevel", conformanceLevelValue);
setTextPropertyValue("DocumentType", "INVOICE");
setTextPropertyValue("DocumentFileName", filename);
setTextPropertyValue("Version", "1.0");

View File

@@ -181,6 +181,8 @@ public class ZUGFeRD2PullProvider implements IXMLProvider {
+ "</ram:IncludedCINote>\n";
}
String xml= "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" //$NON-NLS-1$
@@ -191,7 +193,7 @@ public class ZUGFeRD2PullProvider implements IXMLProvider {
+ " <rsm:ExchangedDocumentContext>\n" //$NON-NLS-1$
+ " <ram:TestIndicator><udt:Indicator>"+testBooleanStr+"</udt:Indicator></ram:TestIndicator>\n" //$NON-NLS-1$
+ " <ram:GuidelineSpecifiedDocumentContextParameter>\n" //$NON-NLS-1$
+ " <ram:ID>urn:ferd:CrossIndustryDocument:invoice:1p0:comfort</ram:ID>\n" //$NON-NLS-1$
+ " <ram:ID>urn:cen.eu:en16931:2017:compliant:factur-x.eu:1p0:extended</ram:ID>\n" //$NON-NLS-1$
+ " </ram:GuidelineSpecifiedDocumentContextParameter>\n" //$NON-NLS-1$
+ " </rsm:ExchangedDocumentContext>\n" //$NON-NLS-1$
+ " <rsm:ExchangedDocument>\n" //$NON-NLS-1$

View File

@@ -1,5 +1,6 @@
package org.mustangproject.ZUGFeRD;
public enum ZUGFeRDConformanceLevel {
BASIC, COMFORT, EXTENDED;
BASIC, COMFORT, EXTENDED, EN16931/*=Comfort*/, MINIMUM, BASICWL /*basic without lines, less than basic*/, CIUS
;
}

View File

@@ -1,6 +0,0 @@
package org.mustangproject.ZUGFeRD.model;
public class DocumentContextParameterTypeConstants {
public static final String COMFORT = "urn:ferd:CrossIndustryDocument:invoice:1p0:comfort";
public static final String EXTENDED = "urn:ferd:CrossIndustryDocument:invoice:1p0:extended";
}

View File

@@ -13,6 +13,7 @@ import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import org.mustangproject.ZUGFeRD.ZUGFeRDConformanceLevel;
import org.mustangproject.ZUGFeRD.ZUGFeRDExporter;
import org.mustangproject.ZUGFeRD.ZUGFeRDExporterFromA1Factory;
import org.mustangproject.ZUGFeRD.ZUGFeRDExporterFromA3Factory;
@@ -273,18 +274,62 @@ public class Toecount {
outName = getFilenameFromUser("Ouput PDF", "invoice.ZUGFeRD.pdf", "pdf", false, true);
String versionInput = "";
try {
versionInput = getStringFromUser("ZUGFeRD version", "1", "1|2");
versionInput = getStringFromUser("ZUGFeRD version (1 or 2)", "1", "1|2");
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
// get version
// get profile
String profileInput = "";
int zfIntVersion=Integer.valueOf(versionInput);
ZUGFeRDConformanceLevel profile=ZUGFeRDConformanceLevel.EXTENDED;
if (zfIntVersion==1) {
try {
profileInput = getStringFromUser("ZUGFeRD profile b)asic, c)omfort or e)xtended", "e", "B|b|C|c|E|e").toLowerCase();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if (profileInput.equals("b")) {
profile=ZUGFeRDConformanceLevel.BASIC;
} else if (profileInput.equals("c")) {
profile=ZUGFeRDConformanceLevel.COMFORT;
} else if (profileInput.equals("e")) {
profile=ZUGFeRDConformanceLevel.EXTENDED;
}
} else if (zfIntVersion==2) {
try {
profileInput = getStringFromUser("ZUGFeRD profile [M]INIMUM, BASIC [W]L, [B]ASIC,\n" +
"[C]IUS, [E]N16931, E[X]TENDED", "E", "M|m|W|w|B|b|C|c|E|e|X|x|").toLowerCase();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if (profileInput.equals("m")) {
profile=ZUGFeRDConformanceLevel.MINIMUM;
} else if (profileInput.equals("w")) {
profile=ZUGFeRDConformanceLevel.BASICWL;
} else if (profileInput.equals("b")) {
profile=ZUGFeRDConformanceLevel.BASIC;
} else if (profileInput.equals("c")) {
profile=ZUGFeRDConformanceLevel.CIUS;
} else if (profileInput.equals("e")) {
profile=ZUGFeRDConformanceLevel.EN16931;
} else if (profileInput.equals("x")) {
profile=ZUGFeRDConformanceLevel.EXTENDED;
}
}
ZUGFeRDExporter ze = new ZUGFeRDExporterFromA3Factory().setProducer("Toecount")
.setCreator(System.getProperty("user.name")).load(pdfName);
ze.setZUGFeRDVersion(Integer.valueOf(versionInput));
.setCreator(System.getProperty("user.name")).setZUGFeRDConformanceLevel(profile).load(pdfName);
ze.setZUGFeRDVersion(zfIntVersion);
ze.setZUGFeRDXMLData(Files.readAllBytes(Paths.get(xmlName)));