switch to new profiles (the old ones did not work)
This commit is contained in:
@@ -43,6 +43,7 @@ public class Invoice implements IExportableTransaction {
|
||||
Charges = new ArrayList<IZUGFeRDAllowanceCharge>(), LogisticsServiceCharges = new ArrayList<IZUGFeRDAllowanceCharge>();
|
||||
protected IZUGFeRDTradeSettlement[] getTradeSettlement = null;
|
||||
protected IZUGFeRDPaymentTerms paymentTerms = null;
|
||||
private Profile profile;
|
||||
|
||||
|
||||
public Invoice() {
|
||||
@@ -72,6 +73,7 @@ public class Invoice implements IExportableTransaction {
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getNumber() {
|
||||
return number;
|
||||
@@ -482,4 +484,5 @@ public class Invoice implements IExportableTransaction {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,9 +18,10 @@
|
||||
*********************************************************************** */
|
||||
package org.mustangproject.ZUGFeRD;
|
||||
|
||||
public class CustomXMLProvider implements IXMLProvider, IProfileProvider {
|
||||
public class CustomXMLProvider implements IXMLProvider {
|
||||
|
||||
protected byte[] zugferdData;
|
||||
protected Profile profile=Profiles.getByName("EN16931");
|
||||
|
||||
@Override
|
||||
public byte[] getXML() {
|
||||
@@ -49,13 +50,11 @@ public class CustomXMLProvider implements IXMLProvider, IProfileProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getProfile() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
public Profile getProfile() {
|
||||
return profile;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setProfile(Profiles level) {
|
||||
// TODO Auto-generated method stub
|
||||
public void setProfile(Profile level) {
|
||||
profile=level;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -435,4 +435,6 @@ public interface IExportableTransaction {
|
||||
default Date getOccurrencePeriodTo() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
/** **********************************************************************
|
||||
*
|
||||
* Copyright 2018 Jochen Staerk
|
||||
*
|
||||
* Use is subject to license terms.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||
* use this file except in compliance with the License. You may obtain a copy
|
||||
* of the License at http://www.apache.org/licenses/LICENSE-2.0.
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*********************************************************************** */
|
||||
package org.mustangproject.ZUGFeRD;
|
||||
|
||||
public interface IProfileProvider {
|
||||
|
||||
public String getProfile();
|
||||
|
||||
public void setProfile(Profiles level);
|
||||
|
||||
}
|
||||
@@ -26,4 +26,9 @@ public interface IXMLProvider {
|
||||
|
||||
public void generateXML(IExportableTransaction trans);
|
||||
|
||||
public void setProfile(Profile p);
|
||||
|
||||
public Profile getProfile();
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ public interface IZUGFeRDExporter extends Closeable, IExporter {
|
||||
public boolean ensurePDFIsValid(final DataSource dataSource) throws IOException;
|
||||
public IZUGFeRDExporter setXML(byte[] zugferdData) throws IOException;
|
||||
public IZUGFeRDExporter disableFacturX();
|
||||
public IZUGFeRDExporter setProfile(Profiles zugferdConformanceLevel);
|
||||
// public IZUGFeRDExporter setProfile(Profile zugferdConformanceLevel);
|
||||
public String getNamespaceForVersion(int ver);
|
||||
public String getPrefixForVersion(int ver) ;
|
||||
public IZUGFeRDExporter disableAutoClose(boolean disableAutoClose);
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package org.mustangproject.ZUGFeRD;
|
||||
|
||||
public class Profile {
|
||||
protected String name, id;
|
||||
|
||||
public Profile(String name, String ID) {
|
||||
this.name = name;
|
||||
this.id = ID;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getID() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getXMPName() {
|
||||
if (name.equals("BASICWL")) {
|
||||
return "BASIC WL";
|
||||
} else if (name.equals("EN16931")) {
|
||||
return "EN 16931";
|
||||
} else {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,23 +1,59 @@
|
||||
/** **********************************************************************
|
||||
*
|
||||
/**
|
||||
* *********************************************************************
|
||||
* <p>
|
||||
* Copyright 2018 Jochen Staerk
|
||||
*
|
||||
* <p>
|
||||
* Use is subject to license terms.
|
||||
*
|
||||
* <p>
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||
* use this file except in compliance with the License. You may obtain a copy
|
||||
* of the License at http://www.apache.org/licenses/LICENSE-2.0.
|
||||
*
|
||||
* <p>
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
* <p>
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*********************************************************************** */
|
||||
* <p>
|
||||
* **********************************************************************
|
||||
*/
|
||||
package org.mustangproject.ZUGFeRD;
|
||||
|
||||
public enum Profiles {
|
||||
BASIC, COMFORT, EXTENDED, EN16931/*=Comfort*/, MINIMUM, BASICWL /*basic without lines, less than basic*/, CIUS, XRECHNUNG
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class Profiles {
|
||||
static Map<String, Profile> zf2Map = Stream.of(new Object[][]{
|
||||
{"MINIMUM", new Profile("MINIMUM", "urn:factur-x.eu:1p0:minimum")},
|
||||
{"BASICWL", new Profile("BASICWL", "urn:factur-x.eu:1p0:basicwl")},
|
||||
{"BASIC", new Profile("BASIC", "urn:cen.eu:en16931:2017#compliant#urn:factur-x.eu:1p0:basic")},
|
||||
{"EN16931", new Profile("EN16931", "urn:cen.eu:en16931:2017")},
|
||||
{"EXTENDED", new Profile("EXTENDED", "urn:cen.eu:en16931:2017#conformant#urn:factur-x.eu:1p0:extended")},
|
||||
{"XRECHNUNG", new Profile("XRECHNUNG", "XRECHNUNG")}
|
||||
|
||||
}).collect(Collectors.toMap(data -> (String) data[0], data -> (Profile) data[1]));
|
||||
static Map<String, Profile> zf1Map = Stream.of(new Object[][]{
|
||||
{"BASIC", new Profile("BASIC", "urn:ferd:CrossIndustryDocument:invoice:1p0:basic")},
|
||||
{"COMFORT", new Profile("COMFORT", "urn:ferd:CrossIndustryDocument:invoice:1p0:comfort")},
|
||||
{"EXTENDED", new Profile("EXTENDED", "urn:ferd:CrossIndustryDocument:invoice:1p0:extended")},
|
||||
|
||||
|
||||
}).collect(Collectors.toMap(data -> (String) data[0], data -> (Profile) data[1]));
|
||||
|
||||
|
||||
public static Profile getByName(String name, int version) {
|
||||
if (version==1) {
|
||||
return zf1Map.get(name);
|
||||
} else {
|
||||
return zf2Map.get(name);
|
||||
}
|
||||
}
|
||||
public static Profile getByName(String name) {
|
||||
return getByName(name, ZUGFeRDExporterFromA3.DefaultZUGFeRDVersion);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -41,17 +41,12 @@ public class XMPSchemaZugferd extends XMPSchema {
|
||||
* @param prefix the xml namespace prefix for the XMP, zf for ZUGFeRD, fx for Factur-X
|
||||
* @param filename the filename of the invoice
|
||||
*/
|
||||
public XMPSchemaZugferd(XMPMetadata metadata, int zfVersion, boolean isFacturX, Profiles conformanceLevel, String URN, String prefix, String filename) {
|
||||
public XMPSchemaZugferd(XMPMetadata metadata, int zfVersion, boolean isFacturX, Profile conformanceLevel, String URN, String prefix, String filename) {
|
||||
super(metadata, URN, prefix, "ZUGFeRD Schema");
|
||||
|
||||
setAboutAsSimple("");
|
||||
|
||||
String conformanceLevelValue = conformanceLevel.name();
|
||||
if (conformanceLevelValue.equals("BASICWL")) {
|
||||
conformanceLevelValue = "BASIC WL";
|
||||
} else if (conformanceLevelValue.equals("EN16931")) {
|
||||
conformanceLevelValue = "EN 16931";
|
||||
}
|
||||
String conformanceLevelValue = conformanceLevel.getXMPName();
|
||||
setTextPropertyValue("ConformanceLevel", conformanceLevelValue);
|
||||
setTextPropertyValue("DocumentType", "INVOICE");
|
||||
setTextPropertyValue("DocumentFileName", filename);
|
||||
|
||||
@@ -35,21 +35,17 @@ import java.util.HashMap;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class ZUGFeRD1PullProvider implements IXMLProvider, IProfileProvider {
|
||||
public class ZUGFeRD1PullProvider implements IXMLProvider {
|
||||
|
||||
|
||||
//// MAIN CLASS
|
||||
|
||||
protected byte[] zugferdData;
|
||||
private IExportableTransaction trans;
|
||||
private Profiles level;
|
||||
private String paymentTermsDescription;
|
||||
SimpleDateFormat zugferdDateFormat = new SimpleDateFormat("yyyyMMdd");
|
||||
protected Profile profile=Profiles.getByName("COMFORT",1);
|
||||
|
||||
@Override
|
||||
public void setProfile(Profiles level) {
|
||||
this.level = level;
|
||||
}
|
||||
|
||||
/**
|
||||
* enables the flag to indicate a test invoice in the XML structure
|
||||
@@ -73,6 +69,12 @@ public class ZUGFeRD1PullProvider implements IXMLProvider, IProfileProvider {
|
||||
return XMLTools.nDigitFormat(value, 4);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Profile getProfile() {
|
||||
return profile;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] getXML() {
|
||||
|
||||
@@ -152,11 +154,6 @@ public class ZUGFeRD1PullProvider implements IXMLProvider, IProfileProvider {
|
||||
return hm;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getProfile() {
|
||||
return "urn:ferd:CrossIndustryDocument:invoice:1p0:comfort";
|
||||
}
|
||||
|
||||
protected String getTradePartyAsXML(IZUGFeRDExportableTradeParty contact) {
|
||||
String xml = " <ram:Name>" + XMLTools.encodeXML(contact.getName()) + "</ram:Name>\n" //$NON-NLS-2$
|
||||
// + " <DefinedTradeContact>\n"
|
||||
@@ -242,7 +239,7 @@ public class ZUGFeRD1PullProvider implements IXMLProvider, IProfileProvider {
|
||||
// <ram:TestIndicator><udt:Indicator>"+testBooleanStr+"</udt:Indicator></ram:TestIndicator>\n"
|
||||
//
|
||||
+ " <ram:GuidelineSpecifiedDocumentContextParameter>\n"
|
||||
+ " <ram:ID>" + getProfile() + "</ram:ID>\n"
|
||||
+ " <ram:ID>" + getProfile().getID() + "</ram:ID>\n"
|
||||
+ " </ram:GuidelineSpecifiedDocumentContextParameter>\n"
|
||||
+ " </rsm:SpecifiedExchangedDocumentContext>\n"
|
||||
+ " <rsm:HeaderExchangedDocument>\n"
|
||||
@@ -541,6 +538,11 @@ public class ZUGFeRD1PullProvider implements IXMLProvider, IProfileProvider {
|
||||
} // $NON-NLS-1$
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setProfile(Profile p) {
|
||||
profile=p;
|
||||
}
|
||||
|
||||
private String buildPaymentTermsXml() {
|
||||
String paymentTermsXml = "<ram:SpecifiedTradePaymentTerms>";
|
||||
|
||||
|
||||
@@ -38,19 +38,15 @@ import org.dom4j.io.XMLWriter;
|
||||
import org.mustangproject.Invoice;
|
||||
import org.mustangproject.XMLTools;
|
||||
|
||||
public class ZUGFeRD2PullProvider implements IXMLProvider, IProfileProvider {
|
||||
public class ZUGFeRD2PullProvider implements IXMLProvider {
|
||||
|
||||
//// MAIN CLASS
|
||||
protected SimpleDateFormat zugferdDateFormat = new SimpleDateFormat("yyyyMMdd");
|
||||
protected byte[] zugferdData;
|
||||
private IExportableTransaction trans;
|
||||
private Profiles level;
|
||||
private String paymentTermsDescription;
|
||||
protected Profile profile=Profiles.getByName("EN16931");
|
||||
|
||||
@Override
|
||||
public void setProfile(Profiles level) {
|
||||
this.level = level;
|
||||
}
|
||||
|
||||
/**
|
||||
* enables the flag to indicate a test invoice in the XML structure
|
||||
@@ -155,9 +151,8 @@ public class ZUGFeRD2PullProvider implements IXMLProvider, IProfileProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getProfile() {
|
||||
// return "urn:cen.eu:en16931:2017#compliant#urn:xoev-de:kosit:standard:xrechnung_1.2";
|
||||
return "urn:cen.eu:en16931:2017";
|
||||
public Profile getProfile() {
|
||||
return profile;
|
||||
}
|
||||
|
||||
protected String getTradePartyAsXML(IZUGFeRDExportableTradeParty party) {
|
||||
@@ -272,7 +267,7 @@ public class ZUGFeRD2PullProvider implements IXMLProvider, IProfileProvider {
|
||||
// <ram:TestIndicator><udt:Indicator>"+testBooleanStr+"</udt:Indicator></ram:TestIndicator>\n"
|
||||
//
|
||||
+ " <ram:GuidelineSpecifiedDocumentContextParameter>\n"
|
||||
+ " <ram:ID>" + getProfile() + "</ram:ID>\n"
|
||||
+ " <ram:ID>" + getProfile().getID() + "</ram:ID>\n"
|
||||
+ " </ram:GuidelineSpecifiedDocumentContextParameter>\n"
|
||||
+ " </rsm:ExchangedDocumentContext>\n"
|
||||
+ " <rsm:ExchangedDocument>\n"
|
||||
@@ -539,6 +534,11 @@ public class ZUGFeRD2PullProvider implements IXMLProvider, IProfileProvider {
|
||||
} // $NON-NLS-1$
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setProfile(Profile p) {
|
||||
profile=p;
|
||||
}
|
||||
|
||||
private String buildPaymentTermsXml() {
|
||||
String paymentTermsXml = "<ram:SpecifiedTradePaymentTerms>";
|
||||
|
||||
|
||||
@@ -68,6 +68,14 @@ public class ZUGFeRDExporterFromA1 extends ZUGFeRDExporterFromA3 implements IZUG
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public ZUGFeRDExporterFromA1 setProfile(Profile p) {
|
||||
return (ZUGFeRDExporterFromA1)super.setProfile(p);
|
||||
}
|
||||
public ZUGFeRDExporterFromA1 setProfile(String profileName) {
|
||||
return (ZUGFeRDExporterFromA1)super.setProfile(profileName);
|
||||
}
|
||||
|
||||
public boolean ensurePDFIsValid(final DataSource dataSource) throws IOException {
|
||||
if (!ignorePDFAErrors && !isValidA1(dataSource)) {
|
||||
throw new IOException("File is not a valid PDF/A input file");
|
||||
@@ -106,9 +114,6 @@ public class ZUGFeRDExporterFromA1 extends ZUGFeRDExporterFromA3 implements IZUG
|
||||
return (ZUGFeRDExporterFromA1) super.setXML(zugferdData);
|
||||
}
|
||||
|
||||
public ZUGFeRDExporterFromA1 setProfile(Profiles zugferdConformanceLevel){
|
||||
return (ZUGFeRDExporterFromA1) super.setProfile(zugferdConformanceLevel);
|
||||
}
|
||||
public ZUGFeRDExporterFromA1 disableAutoClose(boolean disableAutoClose){
|
||||
return (ZUGFeRDExporterFromA1) super.disableAutoClose(disableAutoClose);
|
||||
}
|
||||
|
||||
@@ -53,7 +53,6 @@ public class ZUGFeRDExporterFromA3 extends XRExporter implements IZUGFeRDExporte
|
||||
|
||||
public static final int DefaultZUGFeRDVersion = 2;
|
||||
|
||||
protected Profiles profile = Profiles.EXTENDED;
|
||||
protected PDFAConformanceLevel conformanceLevel = PDFAConformanceLevel.UNICODE;
|
||||
protected ArrayList<FileAttachment> fileAttachments = new ArrayList<FileAttachment>();
|
||||
|
||||
@@ -62,7 +61,7 @@ public class ZUGFeRDExporterFromA3 extends XRExporter implements IZUGFeRDExporte
|
||||
|
||||
private boolean disableAutoClose;
|
||||
private boolean fileAttached = false;
|
||||
|
||||
private Profile profile = null;
|
||||
private boolean documentPrepared = false;
|
||||
|
||||
/**
|
||||
@@ -113,6 +112,23 @@ public class ZUGFeRDExporterFromA3 extends XRExporter implements IZUGFeRDExporte
|
||||
return xmlProvider;
|
||||
}
|
||||
|
||||
public ZUGFeRDExporterFromA3 setProfile(Profile p) {
|
||||
this.profile=p;
|
||||
if (xmlProvider!=null) {
|
||||
xmlProvider.setProfile(p);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public ZUGFeRDExporterFromA3 setProfile(String profilename) {
|
||||
this.profile=Profiles.getByName(profilename);
|
||||
|
||||
if (xmlProvider!=null) {
|
||||
xmlProvider.setProfile(this.profile);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public ZUGFeRDExporterFromA3 addAdditionalFile(String name, byte[] content) {
|
||||
fileAttachments.add(new FileAttachment(name, "text/xml", "Supplement", content).setDescription("ZUGFeRD extension/additional data"));
|
||||
return this;
|
||||
@@ -154,14 +170,14 @@ public class ZUGFeRDExporterFromA3 extends XRExporter implements IZUGFeRDExporte
|
||||
* @param ver the zf/fx version
|
||||
* @return the filename of the file to be embedded
|
||||
*/
|
||||
public String getFilenameForVersion(int ver, Profiles profile) {
|
||||
public String getFilenameForVersion(int ver, Profile profile) {
|
||||
if (isFacturX) {
|
||||
return "factur-x.xml";
|
||||
} else {
|
||||
if (ver == 1) {
|
||||
return "ZUGFeRD-invoice.xml";
|
||||
} else {
|
||||
if (profile == Profiles.XRECHNUNG) {
|
||||
if (profile.getName().equals("XRECHNUNG")) {
|
||||
return "xrechnung.xml";
|
||||
} else {
|
||||
return "zugferd-invoice.xml";
|
||||
@@ -190,6 +206,7 @@ public class ZUGFeRDExporterFromA3 extends XRExporter implements IZUGFeRDExporte
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Makes A PDF/A3a-compliant document from a PDF-A1 compliant document (on the
|
||||
* metadata level, this will not e.g. convert graphics to JPG-2000)
|
||||
@@ -207,6 +224,9 @@ public class ZUGFeRDExporterFromA3 extends XRExporter implements IZUGFeRDExporte
|
||||
ensurePDFisUpgraded = false;
|
||||
}
|
||||
|
||||
public void attachFile(FileAttachment file) {
|
||||
fileAttachments.add(file);
|
||||
}
|
||||
public void attachFile(String filename, byte[] data, String mimetype, String relation) {
|
||||
FileAttachment fa=new FileAttachment(filename, mimetype, relation, data);
|
||||
fileAttachments.add(fa);
|
||||
@@ -349,8 +369,8 @@ public class ZUGFeRDExporterFromA3 extends XRExporter implements IZUGFeRDExporte
|
||||
public ZUGFeRDExporterFromA3 setXML(byte[] zugferdData) throws IOException {
|
||||
CustomXMLProvider cus = new CustomXMLProvider();
|
||||
cus.setXML(zugferdData);
|
||||
this.xmlProvider = cus;
|
||||
setTransaction(null);
|
||||
this.setXMLProvider(cus);
|
||||
prepare();
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -375,15 +395,6 @@ public class ZUGFeRDExporterFromA3 extends XRExporter implements IZUGFeRDExporte
|
||||
return buffer.toByteArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the ZUGFeRD conformance level (override).
|
||||
*
|
||||
* @param zugferdConformanceLevel the new conformance level
|
||||
*/
|
||||
public ZUGFeRDExporterFromA3 setProfile(Profiles zugferdConformanceLevel) {
|
||||
this.profile = zugferdConformanceLevel;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* All files are PDF/A-3, setConformance refers to the level conformance.
|
||||
@@ -434,9 +445,9 @@ public class ZUGFeRDExporterFromA3 extends XRExporter implements IZUGFeRDExporte
|
||||
protected void addXMP(XMPMetadata metadata) {
|
||||
|
||||
if (attachZUGFeRDHeaders) {
|
||||
XMPSchemaZugferd zf = new XMPSchemaZugferd(metadata, ZFVersion, isFacturX, profile,
|
||||
XMPSchemaZugferd zf = new XMPSchemaZugferd(metadata, ZFVersion, isFacturX, xmlProvider.getProfile(),
|
||||
getNamespaceForVersion(ZFVersion), getPrefixForVersion(ZFVersion),
|
||||
getFilenameForVersion(ZFVersion, profile));
|
||||
getFilenameForVersion(ZFVersion, xmlProvider.getProfile()));
|
||||
|
||||
metadata.addSchema(zf);
|
||||
}
|
||||
@@ -513,10 +524,13 @@ public class ZUGFeRDExporterFromA3 extends XRExporter implements IZUGFeRDExporte
|
||||
*/
|
||||
public IExporter setTransaction(IExportableTransaction trans) throws IOException {
|
||||
this.trans = trans;
|
||||
return prepare();
|
||||
}
|
||||
|
||||
public IExporter prepare() throws IOException{
|
||||
prepareDocument();
|
||||
((IProfileProvider) xmlProvider).setProfile(profile);
|
||||
xmlProvider.generateXML(trans);
|
||||
String filename = getFilenameForVersion(ZFVersion, profile);
|
||||
String filename = getFilenameForVersion(ZFVersion, xmlProvider.getProfile());
|
||||
PDFAttachGenericFile(doc, filename, "Alternative",
|
||||
"Invoice metadata conforming to ZUGFeRD standard (http://www.ferd-net.de/front_content.php?idcat=231&lang=4)",
|
||||
"text/xml", xmlProvider.getXML());
|
||||
@@ -563,16 +577,22 @@ public class ZUGFeRDExporterFromA3 extends XRExporter implements IZUGFeRDExporte
|
||||
return this;
|
||||
}
|
||||
|
||||
protected void setXMLProvider(IXMLProvider p) {
|
||||
this.xmlProvider = p;
|
||||
if (profile!=null) {
|
||||
xmlProvider.setProfile(profile);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public ZUGFeRDExporterFromA3 setZUGFeRDVersion(int version) {
|
||||
this.ZFVersion = version;
|
||||
if (version == 1) {
|
||||
ZUGFeRD1PullProvider z1p = new ZUGFeRD1PullProvider();
|
||||
disableFacturX();
|
||||
this.xmlProvider = z1p;
|
||||
setXMLProvider(z1p);
|
||||
} else if (version == 2) {
|
||||
ZUGFeRD2PullProvider z2p = new ZUGFeRD2PullProvider();
|
||||
this.xmlProvider = z2p;
|
||||
setXMLProvider(z2p);
|
||||
} else {
|
||||
throw new IllegalArgumentException("Version not supported");
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ public class BackwardCompatibilityTest extends TestCase implements IExportableTr
|
||||
try (InputStream SOURCE_PDF = this.getClass()
|
||||
.getResourceAsStream("/MustangGnuaccountingBeispielRE-20190610_507blanko.pdf");
|
||||
|
||||
IZUGFeRDExporter ze = new ZUGFeRDExporterFromA1().setZUGFeRDVersion(1).setProfile(Profiles.EN16931).load(SOURCE_PDF)) {
|
||||
IZUGFeRDExporter ze = new ZUGFeRDExporterFromA1().setZUGFeRDVersion(1).setProfile("EN16931").load(SOURCE_PDF)) {
|
||||
|
||||
ze.setTransaction(this);
|
||||
ze.disableAutoClose(true);
|
||||
@@ -96,7 +96,7 @@ public class BackwardCompatibilityTest extends TestCase implements IExportableTr
|
||||
try (InputStream SOURCE_PDF = this.getClass()
|
||||
.getResourceAsStream("/MustangGnuaccountingBeispielRE-20190610_507blanko.pdf");
|
||||
|
||||
IZUGFeRDExporter ze = new ZUGFeRDExporterFromA1().setZUGFeRDVersion(2).setProfile(Profiles.EN16931).load(SOURCE_PDF)) {
|
||||
IZUGFeRDExporter ze = new ZUGFeRDExporterFromA1().setZUGFeRDVersion(2).setProfile("EN16931").load(SOURCE_PDF)) {
|
||||
|
||||
ze.setTransaction(this);
|
||||
ze.disableAutoClose(true);
|
||||
@@ -134,7 +134,7 @@ public class BackwardCompatibilityTest extends TestCase implements IExportableTr
|
||||
try (InputStream SOURCE_PDF = this.getClass()
|
||||
.getResourceAsStream("/MustangGnuaccountingBeispielRE-20190610_507blanko.pdf");
|
||||
|
||||
IZUGFeRDExporter ze = new ZUGFeRDExporterFromA1().setZUGFeRDVersion(2).setProfile(Profiles.EN16931).load(SOURCE_PDF)) {
|
||||
IZUGFeRDExporter ze = new ZUGFeRDExporterFromA1().setZUGFeRDVersion(2).setProfile("EN16931").load(SOURCE_PDF)) {
|
||||
|
||||
ze.setTransaction(this);
|
||||
ze.disableAutoClose(true);
|
||||
|
||||
@@ -43,6 +43,7 @@ public class IExportableTransactionImpl implements IExportableTransaction {
|
||||
private String currency;
|
||||
private String paymentTermDescription;
|
||||
private String referenceNumber;
|
||||
private Profile profile;
|
||||
|
||||
@Override
|
||||
public String getNumber() {
|
||||
@@ -149,7 +150,6 @@ public class IExportableTransactionImpl implements IExportableTransaction {
|
||||
return referenceNumber;
|
||||
}
|
||||
|
||||
|
||||
public IExportableTransactionImpl setNumber(String number) {
|
||||
this.number = number;
|
||||
return this;
|
||||
|
||||
@@ -31,13 +31,13 @@ import java.nio.charset.StandardCharsets;
|
||||
|
||||
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
|
||||
public class MustangReaderWriterCustomXMLTest extends TestCase {
|
||||
|
||||
/**
|
||||
* Create the test case
|
||||
*
|
||||
* @param testName name of the test case
|
||||
*/
|
||||
public MustangReaderWriterCustomXMLTest(String testName) {
|
||||
|
||||
super(testName);
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ public class MustangReaderWriterCustomXMLTest extends TestCase {
|
||||
try {
|
||||
InputStream SOURCE_PDF = this.getClass().getResourceAsStream("/MustangGnuaccountingBeispielRE-20170509_505blanko.pdf");
|
||||
|
||||
IZUGFeRDExporter zea1 = new ZUGFeRDExporterFromA1().setProducer("My Application").setCreator("Test").setProfile(Profiles.EN16931)
|
||||
IZUGFeRDExporter zea1 = new ZUGFeRDExporterFromA1().setProducer("My Application").setCreator("Test").setProfile(Profiles.getByName("EN16931"))
|
||||
.load(SOURCE_PDF);
|
||||
|
||||
final byte[] UTF8ByteOrderMark = new byte[]{(byte) 0xef, (byte) 0xbb, (byte) 0xbf};
|
||||
@@ -301,7 +301,7 @@ public class MustangReaderWriterCustomXMLTest extends TestCase {
|
||||
.setProducer("My Application")
|
||||
.setCreator("Test")
|
||||
.setZUGFeRDVersion(1)
|
||||
.setProfile(Profiles.BASIC)
|
||||
.setProfile(Profiles.getByName("BASIC",1))
|
||||
.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"
|
||||
|
||||
@@ -150,6 +150,7 @@ public class MustangReaderWriterEdgeTest extends MustangReaderTestCase {
|
||||
return "AB321";
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create the test case
|
||||
*
|
||||
|
||||
@@ -358,7 +358,7 @@ public class MustangReaderWriterTest extends MustangReaderTestCase {
|
||||
try (InputStream SOURCE_PDF = this.getClass()
|
||||
.getResourceAsStream("/MustangGnuaccountingBeispielRE-20190610_507blanko.pdf");
|
||||
|
||||
IZUGFeRDExporter ze = new ZUGFeRDExporterFromA1().setZUGFeRDVersion(2).setProfile(Profiles.EN16931).load(SOURCE_PDF)) {
|
||||
IZUGFeRDExporter ze = new ZUGFeRDExporterFromA1().setZUGFeRDVersion(2).setProfile(Profiles.getByName("EN16931")).load(SOURCE_PDF)) {
|
||||
|
||||
ze.setTransaction(this);
|
||||
ze.disableAutoClose(true);
|
||||
@@ -402,7 +402,7 @@ public class MustangReaderWriterTest extends MustangReaderTestCase {
|
||||
try (InputStream SOURCE_PDF = this.getClass()
|
||||
.getResourceAsStream("/MustangGnuaccountingBeispielRE-20190610_507blanko.pdf");
|
||||
|
||||
IZUGFeRDExporter ze = new ZUGFeRDExporterFromA1().setZUGFeRDVersion(1).setProfile(Profiles.COMFORT).load(SOURCE_PDF)) {
|
||||
IZUGFeRDExporter ze = new ZUGFeRDExporterFromA1().setZUGFeRDVersion(1).setProfile(Profiles.getByName("COMFORT",1)).load(SOURCE_PDF)) {
|
||||
|
||||
ze.setTransaction(this);
|
||||
ze.disableAutoClose(true);
|
||||
@@ -430,7 +430,7 @@ public class MustangReaderWriterTest extends MustangReaderTestCase {
|
||||
try (InputStream SOURCE_PDF = this.getClass()
|
||||
.getResourceAsStream("/MustangGnuaccountingBeispielRE-20171118_506blanko.pdf");
|
||||
|
||||
ZUGFeRDExporterFromA1 ze = new ZUGFeRDExporterFromA1().setZUGFeRDVersion(2).setProfile(Profiles.EN16931).load(SOURCE_PDF)) {
|
||||
ZUGFeRDExporterFromA1 ze = new ZUGFeRDExporterFromA1().setZUGFeRDVersion(2).setProfile(Profiles.getByName("EN16931")).load(SOURCE_PDF)) {
|
||||
ByteArrayOutputStream result = new ByteArrayOutputStream();
|
||||
byte[] buffer = new byte[1024];
|
||||
int length;
|
||||
|
||||
@@ -134,7 +134,7 @@ public class ZF2PushTest extends TestCase {
|
||||
.getResourceAsStream("/MustangGnuaccountingBeispielRE-20170509_505blanko.pdf");
|
||||
|
||||
ZUGFeRDExporterFromA1 ze = new ZUGFeRDExporterFromA1().setProducer("My Application")
|
||||
.setCreator(System.getProperty("user.name")).setZUGFeRDVersion(2).ignorePDFAErrors()
|
||||
.setCreator(System.getProperty("user.name")).setZUGFeRDVersion(2).setProfile("EXTENDED").ignorePDFAErrors()
|
||||
.load(SOURCE_PDF)) {
|
||||
// ze.setTransaction(new Invoice().setDueDate(new Date()).setIssueDate(new Date()).setDeliveryDate(new Date()).setSender(new TradeParty(orgname,"teststr", "55232","teststadt","DE")).setOwnTaxID("4711").setOwnVATID("DE0815").setRecipient(new TradeParty("Franz Müller", "teststr.12", "55232", "Entenhausen", "DE")).setNumber(number)
|
||||
// .addItem(new Item(new Product("Testprodukt", "", "C62", new BigDecimal(19)), amount, new BigDecimal(1.0)).addAllowance(new Allowance().setPercent(new BigDecimal(50)))));
|
||||
|
||||
@@ -168,7 +168,7 @@ public class ZF2Test extends MustangReaderTestCase {
|
||||
.getResourceAsStream("/MustangGnuaccountingBeispielRE-20170509_505PDFA3.pdf");
|
||||
|
||||
ZUGFeRDExporterFromA3 ze = new ZUGFeRDExporterFromA3().setProducer("My Application")
|
||||
.setCreator(System.getProperty("user.name")).setZUGFeRDVersion(2).setProfile(Profiles.EN16931)
|
||||
.setCreator(System.getProperty("user.name")).setZUGFeRDVersion(2).setProfile("EN16931")
|
||||
.load(SOURCE_PDF)) {
|
||||
|
||||
ze.setTransaction(this);
|
||||
|
||||
Reference in New Issue
Block a user