corrected filename for xrechnung profile, now no longer bypassing XR checks for XR profile, now also allow for import of xrechnung profile, add test files and tests

This commit is contained in:
Jochen Stärk
2020-06-20 09:44:36 +02:00
parent b5006c3161
commit 36048decd1
7 changed files with 27 additions and 11 deletions

View File

@@ -412,7 +412,7 @@ public class Main {
System.out.println("Source PDF set to " + pdfName);
}
if (xmlName == null) {
xmlName = getFilenameFromUser("ZUGFeRD XML", "ZUGFeRD-invoice.xml", "xml", false, true);
xmlName = getFilenameFromUser("ZUGFeRD XML", "factur-x.xml", "xml", false, true);
} else {
System.out.println("ZUGFeRD XML set to " + pdfName);
}

View File

@@ -176,14 +176,18 @@ public class ZUGFeRDExporter implements Closeable {
* @param ver the zf/fx version
* @return the filename of the file to be embedded
*/
public String getFilenameForVersion(int ver) {
public String getFilenameForVersion(int ver, ZUGFeRDConformanceLevel profile) {
if (isFacturX) {
return "factur-x.xml";
} else {
if (ver==1) {
return "ZUGFeRD-invoice.xml";
} else {
return "zugferd-invoice.xml";
if (profile==ZUGFeRDConformanceLevel.XRECHNUNG) {
return "xrechnung.xml";
} else {
return "zugferd-invoice.xml";
}
}
}
}
@@ -402,7 +406,7 @@ public class ZUGFeRDExporter implements Closeable {
prepareDocument();
((IProfileProvider) xmlProvider).setProfile(profile);
xmlProvider.generateXML(trans);
String filename = getFilenameForVersion(ZFVersion);
String filename = getFilenameForVersion(ZFVersion, profile);
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());
@@ -597,7 +601,7 @@ public class ZUGFeRDExporter implements Closeable {
if (attachZUGFeRDHeaders) {
XMPSchemaZugferd zf = new XMPSchemaZugferd(metadata, ZFVersion, isFacturX, profile,
getNamespaceForVersion(ZFVersion), getPrefixForVersion(ZFVersion),
getFilenameForVersion(ZFVersion));
getFilenameForVersion(ZFVersion, profile));
metadata.addSchema(zf);
}

View File

@@ -135,7 +135,7 @@ public class ZUGFeRDImporter {
/**
* filenames for invoice data (ZUGFeRD v1 and v2, Factur-X)
*/
if ((filename.equals("ZUGFeRD-invoice.xml") || (filename.equals("zugferd-invoice.xml")) || filename.equals("factur-x.xml"))) { //$NON-NLS-1$
if ((filename.equals("ZUGFeRD-invoice.xml") || (filename.equals("zugferd-invoice.xml")) || filename.equals("factur-x.xml")) || filename.equals("xrechnung.xml")) { //$NON-NLS-1$
containsMeta = true;
PDEmbeddedFile embeddedFile = fileSpec.getEmbeddedFile();

View File

@@ -260,7 +260,7 @@ public class XMLValidator extends Validator {
validateSchematron(zfXML, xsltFilename, 4, ESeverity.error);
if (context.getVersion().equals("2")
&& isEN16931) {
&& (isEN16931 || isXRechnung)) {
//additionally validate against CEN
validateSchematron(zfXML, "/xslt/cii16931schematron/EN16931-CII-validation.xslt", 24, ESeverity.error);

View File

@@ -42,15 +42,27 @@ public class ZUGFeRDValidatorTest extends ResourceCase {
zfv = new ZUGFeRDValidator();
res = zfv.validate(tempFile.getAbsolutePath());
assertEquals(true, res.contains("status=\"valid\""));
assertEquals(false, res.contains("status=\"invalid\""));
assertThat(res).valueByXPath("/validation/summary/@status")
.isEqualTo("valid");
tempFile = getResourceAsFile("validAvoir_FR_type380_BASICWL.pdf");
zfv = new ZUGFeRDValidator();
res = zfv.validate(tempFile.getAbsolutePath());
assertEquals(true, res.contains("status=\"valid\""));
assertEquals(false, res.contains("status=\"invalid\""));
assertThat(res).valueByXPath("/validation/summary/@status")
.isEqualTo("valid");
tempFile = getResourceAsFile("validXRechnung.pdf");
zfv = new ZUGFeRDValidator();
res = zfv.validate(tempFile.getAbsolutePath());
assertThat(res).valueByXPath("/validation/summary/@status")
.isEqualTo("valid");
tempFile = getResourceAsFile("invalidXRechnung.pdf");
zfv = new ZUGFeRDValidator();
res = zfv.validate(tempFile.getAbsolutePath());
assertThat(res).valueByXPath("/validation/summary/@status")
.isEqualTo("invalid");
}

Binary file not shown.

Binary file not shown.