allow new ZF2 profiles
This commit is contained in:
@@ -20,7 +20,11 @@ public class XMPSchemaZugferd extends XMPSchema {
|
|||||||
|
|
||||||
setAboutAsSimple("");
|
setAboutAsSimple("");
|
||||||
|
|
||||||
setTextPropertyValue("ConformanceLevel", conformanceLevel.name());
|
String conformanceLevelValue=conformanceLevel.name();
|
||||||
|
if (conformanceLevelValue.equals("BASICWL")) {
|
||||||
|
conformanceLevelValue="BASIC WL";
|
||||||
|
}
|
||||||
|
setTextPropertyValue("ConformanceLevel", conformanceLevelValue);
|
||||||
setTextPropertyValue("DocumentType", "INVOICE");
|
setTextPropertyValue("DocumentType", "INVOICE");
|
||||||
setTextPropertyValue("DocumentFileName", filename);
|
setTextPropertyValue("DocumentFileName", filename);
|
||||||
setTextPropertyValue("Version", "1.0");
|
setTextPropertyValue("Version", "1.0");
|
||||||
|
|||||||
@@ -182,6 +182,8 @@ public class ZUGFeRD2PullProvider implements IXMLProvider {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
String xml= "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" //$NON-NLS-1$
|
String xml= "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" //$NON-NLS-1$
|
||||||
|
|
||||||
+ "<rsm:CrossIndustryInvoice xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:rsm=\"urn:un:unece:uncefact:data:standard:CrossIndustryInvoice:100\""
|
+ "<rsm:CrossIndustryInvoice xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:rsm=\"urn:un:unece:uncefact:data:standard:CrossIndustryInvoice:100\""
|
||||||
@@ -191,7 +193,7 @@ public class ZUGFeRD2PullProvider implements IXMLProvider {
|
|||||||
+ " <rsm:ExchangedDocumentContext>\n" //$NON-NLS-1$
|
+ " <rsm:ExchangedDocumentContext>\n" //$NON-NLS-1$
|
||||||
+ " <ram:TestIndicator><udt:Indicator>"+testBooleanStr+"</udt:Indicator></ram:TestIndicator>\n" //$NON-NLS-1$
|
+ " <ram:TestIndicator><udt:Indicator>"+testBooleanStr+"</udt:Indicator></ram:TestIndicator>\n" //$NON-NLS-1$
|
||||||
+ " <ram:GuidelineSpecifiedDocumentContextParameter>\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$
|
+ " </ram:GuidelineSpecifiedDocumentContextParameter>\n" //$NON-NLS-1$
|
||||||
+ " </rsm:ExchangedDocumentContext>\n" //$NON-NLS-1$
|
+ " </rsm:ExchangedDocumentContext>\n" //$NON-NLS-1$
|
||||||
+ " <rsm:ExchangedDocument>\n" //$NON-NLS-1$
|
+ " <rsm:ExchangedDocument>\n" //$NON-NLS-1$
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package org.mustangproject.ZUGFeRD;
|
package org.mustangproject.ZUGFeRD;
|
||||||
|
|
||||||
public enum ZUGFeRDConformanceLevel {
|
public enum ZUGFeRDConformanceLevel {
|
||||||
BASIC, COMFORT, EXTENDED;
|
BASIC, COMFORT, EXTENDED, EN16931/*=Comfort*/, MINIMUM, BASICWL /*basic without lines, less than basic*/, CIUS
|
||||||
|
;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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";
|
|
||||||
}
|
|
||||||
@@ -13,6 +13,7 @@ import java.nio.file.Files;
|
|||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
|
|
||||||
|
import org.mustangproject.ZUGFeRD.ZUGFeRDConformanceLevel;
|
||||||
import org.mustangproject.ZUGFeRD.ZUGFeRDExporter;
|
import org.mustangproject.ZUGFeRD.ZUGFeRDExporter;
|
||||||
import org.mustangproject.ZUGFeRD.ZUGFeRDExporterFromA1Factory;
|
import org.mustangproject.ZUGFeRD.ZUGFeRDExporterFromA1Factory;
|
||||||
import org.mustangproject.ZUGFeRD.ZUGFeRDExporterFromA3Factory;
|
import org.mustangproject.ZUGFeRD.ZUGFeRDExporterFromA3Factory;
|
||||||
@@ -273,18 +274,62 @@ public class Toecount {
|
|||||||
outName = getFilenameFromUser("Ouput PDF", "invoice.ZUGFeRD.pdf", "pdf", false, true);
|
outName = getFilenameFromUser("Ouput PDF", "invoice.ZUGFeRD.pdf", "pdf", false, true);
|
||||||
String versionInput = "";
|
String versionInput = "";
|
||||||
try {
|
try {
|
||||||
versionInput = getStringFromUser("ZUGFeRD version", "1", "1|2");
|
versionInput = getStringFromUser("ZUGFeRD version (1 or 2)", "1", "1|2");
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// TODO Auto-generated catch block
|
// TODO Auto-generated catch block
|
||||||
e.printStackTrace();
|
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")
|
ZUGFeRDExporter ze = new ZUGFeRDExporterFromA3Factory().setProducer("Toecount")
|
||||||
.setCreator(System.getProperty("user.name")).load(pdfName);
|
.setCreator(System.getProperty("user.name")).setZUGFeRDConformanceLevel(profile).load(pdfName);
|
||||||
ze.setZUGFeRDVersion(Integer.valueOf(versionInput));
|
ze.setZUGFeRDVersion(zfIntVersion);
|
||||||
|
|
||||||
ze.setZUGFeRDXMLData(Files.readAllBytes(Paths.get(xmlName)));
|
ze.setZUGFeRDXMLData(Files.readAllBytes(Paths.get(xmlName)));
|
||||||
|
|
||||||
|
|||||||
@@ -51,13 +51,14 @@ public class MustangReaderWriterCustomXMLTest extends TestCase {
|
|||||||
InputStream SOURCE_PDF = this.getClass()
|
InputStream SOURCE_PDF = this.getClass()
|
||||||
.getResourceAsStream("/MustangGnuaccountingBeispielRE-20170509_505blanko.pdf");
|
.getResourceAsStream("/MustangGnuaccountingBeispielRE-20170509_505blanko.pdf");
|
||||||
|
|
||||||
ZUGFeRDExporter zea1 = new ZUGFeRDExporterFromA1Factory().setProducer("My Application").setCreator("Test")
|
ZUGFeRDExporter zea1 = new ZUGFeRDExporterFromA1Factory().setProducer("My Application").setCreator("Test").setZUGFeRDConformanceLevel(ZUGFeRDConformanceLevel.BASIC)
|
||||||
.load(SOURCE_PDF);
|
.load(SOURCE_PDF);
|
||||||
|
/* we have much more information than just in the basic profile (comfort or extended) but it's perfectly valid to provide more information, just not less. */
|
||||||
String ownZUGFeRDXML = "<rsm:CrossIndustryDocument xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:ram=\"urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:12\" xmlns:udt=\"urn:un:unece:uncefact:data:standard:UnqualifiedDataType:15\" xmlns:rsm=\"urn:ferd:CrossIndustryDocument:invoice:1p0\">\n"
|
String ownZUGFeRDXML = "<rsm:CrossIndustryDocument xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:ram=\"urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:12\" xmlns:udt=\"urn:un:unece:uncefact:data:standard:UnqualifiedDataType:15\" xmlns:rsm=\"urn:ferd:CrossIndustryDocument:invoice:1p0\">\n"
|
||||||
+ "<rsm:SpecifiedExchangedDocumentContext>\n" + "<ram:TestIndicator>\n"
|
+ "<rsm:SpecifiedExchangedDocumentContext>\n" + "<ram:TestIndicator>\n"
|
||||||
+ "<udt:Indicator>false</udt:Indicator>\n" + "</ram:TestIndicator>\n"
|
+ "<udt:Indicator>false</udt:Indicator>\n" + "</ram:TestIndicator>\n"
|
||||||
+ "<ram:GuidelineSpecifiedDocumentContextParameter>\n" + "<ram:ID>\n"
|
+ "<ram:GuidelineSpecifiedDocumentContextParameter>\n" + "<ram:ID>\n"
|
||||||
+ "urn:ferd:CrossIndustryDocument:invoice:1p0:extended\n" + "</ram:ID>\n"
|
+ "urn:ferd:CrossIndustryDocument:invoice:1p0:basic\n" + "</ram:ID>\n"
|
||||||
+ "</ram:GuidelineSpecifiedDocumentContextParameter>\n"
|
+ "</ram:GuidelineSpecifiedDocumentContextParameter>\n"
|
||||||
+ "</rsm:SpecifiedExchangedDocumentContext>\n" + "<rsm:HeaderExchangedDocument>\n"
|
+ "</rsm:SpecifiedExchangedDocumentContext>\n" + "<rsm:HeaderExchangedDocument>\n"
|
||||||
+ "<ram:ID>RE-20170509/505</ram:ID>\n" + "<ram:Name>RECHNUNG</ram:Name>\n"
|
+ "<ram:ID>RE-20170509/505</ram:ID>\n" + "<ram:Name>RECHNUNG</ram:Name>\n"
|
||||||
|
|||||||
@@ -366,7 +366,7 @@ public class MustangReaderWriterTest extends TestCase implements IZUGFeRDExporta
|
|||||||
try (InputStream SOURCE_PDF = this.getClass()
|
try (InputStream SOURCE_PDF = this.getClass()
|
||||||
.getResourceAsStream("/MustangGnuaccountingBeispielRE-20171118_506blanko.pdf");
|
.getResourceAsStream("/MustangGnuaccountingBeispielRE-20171118_506blanko.pdf");
|
||||||
|
|
||||||
ZUGFeRDExporter ze = new ZUGFeRDExporterFromA1Factory().load(SOURCE_PDF)) {
|
ZUGFeRDExporter ze = new ZUGFeRDExporterFromA1Factory().load(SOURCE_PDF)) {
|
||||||
ze.setZUGFeRDVersion(2);
|
ze.setZUGFeRDVersion(2);
|
||||||
|
|
||||||
ze.PDFattachZugferdFile(this);
|
ze.PDFattachZugferdFile(this);
|
||||||
@@ -379,6 +379,7 @@ public class MustangReaderWriterTest extends TestCase implements IZUGFeRDExporta
|
|||||||
String pdfContent = baos.toString("UTF-8");
|
String pdfContent = baos.toString("UTF-8");
|
||||||
assertFalse(pdfContent.indexOf("(via mustangproject.org") == -1);
|
assertFalse(pdfContent.indexOf("(via mustangproject.org") == -1);
|
||||||
|
|
||||||
|
assertFalse(pdfContent.indexOf("urn:cen.eu:en16931:2017:compliant:factur-x.eu:1p0:extended")==-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// now check the contents (like MustangReaderTest)
|
// now check the contents (like MustangReaderTest)
|
||||||
|
|||||||
Reference in New Issue
Block a user