diff --git a/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDExporterFromA3.java b/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDExporterFromA3.java index f74f8d00..6106215f 100644 --- a/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDExporterFromA3.java +++ b/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDExporterFromA3.java @@ -116,7 +116,7 @@ public class ZUGFeRDExporterFromA3 extends XRExporter implements IZUGFeRDExporte protected int ZFVersion = DefaultZUGFeRDVersion; private boolean attachZUGFeRDHeaders = true; - // Specific metaData version in case of XRechnung. We need it to be settable + // Specific metaData version in case of XRechnung. We need it to be settable // by the caller if necessary. protected String XRechnungVersion = null; // Default XRechnung as of late 2021 is 2p0 @@ -169,11 +169,9 @@ public class ZUGFeRDExporterFromA3 extends XRExporter implements IZUGFeRDExporte public String getNamespaceForVersion(int ver) { // In the case of XRechnung, it is the same as Factur-X if ((ver >= 2) && (this.profile != null) && - this.profile.getName().equalsIgnoreCase(Profiles.getByName("XRECHNUNG").getName())) - { - return "urn:factur-x:pdfa:CrossIndustryDocument:invoice:1p0#"; - } else - if (isFacturX) { + this.profile == Profiles.getByName("XRECHNUNG")) { + return "urn:factur-x:pdfa:CrossIndustryDocument:invoice:1p0#"; + } else if (isFacturX) { return "urn:factur-x:pdfa:CrossIndustryDocument:invoice:1p0#"; } else if (ver == 1) { return "urn:ferd:pdfa:CrossIndustryDocument:invoice:1p0#"; @@ -191,12 +189,10 @@ public class ZUGFeRDExporterFromA3 extends XRExporter implements IZUGFeRDExporte */ public String getPrefixForVersion(int ver) { // In the case of XRechnung, it is the same as Factur-X - if ((ver >= 2) && (this.profile != null) && - this.profile.getName().equalsIgnoreCase(Profiles.getByName("XRECHNUNG").getName())) - { + if ((this.profile != null) && + this.profile == Profiles.getByName("XRECHNUNG")) { return "fx"; - } else - if (isFacturX) { + } else if (isFacturX) { return "fx"; } else { return "zf"; @@ -211,21 +207,19 @@ public class ZUGFeRDExporterFromA3 extends XRExporter implements IZUGFeRDExporte * @return the filename of the file to be embedded */ public String getFilenameForVersion(int ver, Profile profile) { - boolean isXRechnung = - (ver >= 2) && (this.profile != null) && - this.profile.getName().equalsIgnoreCase(Profiles.getByName("XRECHNUNG").getName()); + boolean isXRechnung = (this.profile != null) && + this.profile == Profiles.getByName("XRECHNUNG"); - if (isFacturX && (!isXRechnung)) { + if (isFacturX) { return "factur-x.xml"; + } else if (isXRechnung) { + return "xrechnung.xml"; } else { + if (ver == 1) { return "ZUGFeRD-invoice.xml"; } else { - if (isXRechnung) { - return "xrechnung.xml"; - } else { - return "zugferd-invoice.xml"; - } + return "zugferd-invoice.xml"; } } } @@ -250,10 +244,9 @@ public class ZUGFeRDExporterFromA3 extends XRExporter implements IZUGFeRDExporte * * @param XRechnungVersion the XRechnung version */ - public void setXRechnungSpecificVersion(String XRechnungVersion) - { - this.XRechnungVersion = XRechnungVersion; - } + public void setXRechnungSpecificVersion(String XRechnungVersion) { + this.XRechnungVersion = XRechnungVersion; + } /*** @@ -520,14 +513,13 @@ public class ZUGFeRDExporterFromA3 extends XRExporter implements IZUGFeRDExporte */ protected void addXMP(XMPMetadata metadata) { - String metaDataVersion = null; // default will be used + String metaDataVersion = null; // default will be used - // The XRechnung version may be settable from outside. - if ((this.XRechnungVersion != null) && (this.profile != null) && - this.profile.getName().equalsIgnoreCase(Profiles.getByName("XRECHNUNG").getName())) - { - metaDataVersion = this.XRechnungVersion; - } + // The XRechnung version may be settable from outside. + if ((this.XRechnungVersion != null) && (this.profile != null) && + this.profile.getName().equalsIgnoreCase(Profiles.getByName("XRECHNUNG").getName())) { + metaDataVersion = this.XRechnungVersion; + } if (attachZUGFeRDHeaders) { XMPSchemaZugferd zf = new XMPSchemaZugferd(metadata, ZFVersion, isFacturX, xmlProvider.getProfile(), @@ -543,8 +535,7 @@ public class ZUGFeRDExporterFromA3 extends XRExporter implements IZUGFeRDExporte } private void removeCidSet(PDDocumentCatalog catalog, PDDocument doc) - throws IOException - { + throws IOException { // https://github.com/ZUGFeRD/mustangproject/issues/249 COSName cidSet = COSName.getPDFName("CIDSet"); @@ -631,18 +622,16 @@ public class ZUGFeRDExporterFromA3 extends XRExporter implements IZUGFeRDExporte xmlProvider.generateXML(trans); String filename = getFilenameForVersion(ZFVersion, xmlProvider.getProfile()); - String relationship = "Alternative"; - // ZUGFeRD 2.1.1 Technical Supplement | Part A | 2.2.2. Data Relationship - // See documentation ZUGFeRD211_EN/Documentation/ZUGFeRD-2.1.1 - Specification_TA_Part-A.pdf - // https://www.ferd-net.de/standards/zugferd-2.1.1/index.html - if (ZFVersion >= 2) - { - if (this.profile.getName().equalsIgnoreCase(Profiles.getByName("MINIMUM").getName()) || - this.profile.getName().equalsIgnoreCase(Profiles.getByName("BASICWL").getName())) - { - relationship = "Data"; - } - } + String relationship = "Alternative"; + // ZUGFeRD 2.1.1 Technical Supplement | Part A | 2.2.2. Data Relationship + // See documentation ZUGFeRD211_EN/Documentation/ZUGFeRD-2.1.1 - Specification_TA_Part-A.pdf + // https://www.ferd-net.de/standards/zugferd-2.1.1/index.html + if (ZFVersion >= 2) { + if (this.profile == Profiles.getByName("MINIMUM") || + this.profile == Profiles.getByName("BASICWL")) { + relationship = "Data"; + } + } PDFAttachGenericFile(doc, filename, relationship, "Invoice metadata conforming to ZUGFeRD standard (http://www.ferd-net.de/front_content.php?idcat=231&lang=4)", @@ -660,8 +649,7 @@ public class ZUGFeRDExporterFromA3 extends XRExporter implements IZUGFeRDExporte * Otherwise creates XMPMetadata. */ protected XMPMetadata getXmpMetadata() - throws IOException - { + throws IOException { PDMetadata meta = doc.getDocumentCatalog().getMetadata(); if ((meta != null) && (meta.getLength() > 0)) { try { @@ -803,8 +791,7 @@ public class ZUGFeRDExporterFromA3 extends XRExporter implements IZUGFeRDExporte * Adds an OutputIntent and the sRGB color profile if no OutputIntent exist */ protected void addSRGBOutputIntend() - throws IOException - { + throws IOException { if (!doc.getDocumentCatalog().getOutputIntents().isEmpty()) { return; }