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:
@@ -412,7 +412,7 @@ public class Main {
|
|||||||
System.out.println("Source PDF set to " + pdfName);
|
System.out.println("Source PDF set to " + pdfName);
|
||||||
}
|
}
|
||||||
if (xmlName == null) {
|
if (xmlName == null) {
|
||||||
xmlName = getFilenameFromUser("ZUGFeRD XML", "ZUGFeRD-invoice.xml", "xml", false, true);
|
xmlName = getFilenameFromUser("ZUGFeRD XML", "factur-x.xml", "xml", false, true);
|
||||||
} else {
|
} else {
|
||||||
System.out.println("ZUGFeRD XML set to " + pdfName);
|
System.out.println("ZUGFeRD XML set to " + pdfName);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -176,14 +176,18 @@ public class ZUGFeRDExporter implements Closeable {
|
|||||||
* @param ver the zf/fx version
|
* @param ver the zf/fx version
|
||||||
* @return the filename of the file to be embedded
|
* @return the filename of the file to be embedded
|
||||||
*/
|
*/
|
||||||
public String getFilenameForVersion(int ver) {
|
public String getFilenameForVersion(int ver, ZUGFeRDConformanceLevel profile) {
|
||||||
if (isFacturX) {
|
if (isFacturX) {
|
||||||
return "factur-x.xml";
|
return "factur-x.xml";
|
||||||
} else {
|
} else {
|
||||||
if (ver==1) {
|
if (ver==1) {
|
||||||
return "ZUGFeRD-invoice.xml";
|
return "ZUGFeRD-invoice.xml";
|
||||||
} else {
|
} 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();
|
prepareDocument();
|
||||||
((IProfileProvider) xmlProvider).setProfile(profile);
|
((IProfileProvider) xmlProvider).setProfile(profile);
|
||||||
xmlProvider.generateXML(trans);
|
xmlProvider.generateXML(trans);
|
||||||
String filename = getFilenameForVersion(ZFVersion);
|
String filename = getFilenameForVersion(ZFVersion, profile);
|
||||||
PDFAttachGenericFile(doc, filename, "Alternative",
|
PDFAttachGenericFile(doc, filename, "Alternative",
|
||||||
"Invoice metadata conforming to ZUGFeRD standard (http://www.ferd-net.de/front_content.php?idcat=231&lang=4)",
|
"Invoice metadata conforming to ZUGFeRD standard (http://www.ferd-net.de/front_content.php?idcat=231&lang=4)",
|
||||||
"text/xml", xmlProvider.getXML());
|
"text/xml", xmlProvider.getXML());
|
||||||
@@ -597,7 +601,7 @@ public class ZUGFeRDExporter implements Closeable {
|
|||||||
if (attachZUGFeRDHeaders) {
|
if (attachZUGFeRDHeaders) {
|
||||||
XMPSchemaZugferd zf = new XMPSchemaZugferd(metadata, ZFVersion, isFacturX, profile,
|
XMPSchemaZugferd zf = new XMPSchemaZugferd(metadata, ZFVersion, isFacturX, profile,
|
||||||
getNamespaceForVersion(ZFVersion), getPrefixForVersion(ZFVersion),
|
getNamespaceForVersion(ZFVersion), getPrefixForVersion(ZFVersion),
|
||||||
getFilenameForVersion(ZFVersion));
|
getFilenameForVersion(ZFVersion, profile));
|
||||||
|
|
||||||
metadata.addSchema(zf);
|
metadata.addSchema(zf);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -135,7 +135,7 @@ public class ZUGFeRDImporter {
|
|||||||
/**
|
/**
|
||||||
* filenames for invoice data (ZUGFeRD v1 and v2, Factur-X)
|
* 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;
|
containsMeta = true;
|
||||||
|
|
||||||
PDEmbeddedFile embeddedFile = fileSpec.getEmbeddedFile();
|
PDEmbeddedFile embeddedFile = fileSpec.getEmbeddedFile();
|
||||||
|
|||||||
@@ -260,7 +260,7 @@ public class XMLValidator extends Validator {
|
|||||||
validateSchematron(zfXML, xsltFilename, 4, ESeverity.error);
|
validateSchematron(zfXML, xsltFilename, 4, ESeverity.error);
|
||||||
|
|
||||||
if (context.getVersion().equals("2")
|
if (context.getVersion().equals("2")
|
||||||
&& isEN16931) {
|
&& (isEN16931 || isXRechnung)) {
|
||||||
//additionally validate against CEN
|
//additionally validate against CEN
|
||||||
validateSchematron(zfXML, "/xslt/cii16931schematron/EN16931-CII-validation.xslt", 24, ESeverity.error);
|
validateSchematron(zfXML, "/xslt/cii16931schematron/EN16931-CII-validation.xslt", 24, ESeverity.error);
|
||||||
|
|
||||||
|
|||||||
@@ -42,15 +42,27 @@ public class ZUGFeRDValidatorTest extends ResourceCase {
|
|||||||
zfv = new ZUGFeRDValidator();
|
zfv = new ZUGFeRDValidator();
|
||||||
|
|
||||||
res = zfv.validate(tempFile.getAbsolutePath());
|
res = zfv.validate(tempFile.getAbsolutePath());
|
||||||
assertEquals(true, res.contains("status=\"valid\""));
|
assertThat(res).valueByXPath("/validation/summary/@status")
|
||||||
assertEquals(false, res.contains("status=\"invalid\""));
|
.isEqualTo("valid");
|
||||||
|
|
||||||
tempFile = getResourceAsFile("validAvoir_FR_type380_BASICWL.pdf");
|
tempFile = getResourceAsFile("validAvoir_FR_type380_BASICWL.pdf");
|
||||||
zfv = new ZUGFeRDValidator();
|
zfv = new ZUGFeRDValidator();
|
||||||
|
|
||||||
res = zfv.validate(tempFile.getAbsolutePath());
|
res = zfv.validate(tempFile.getAbsolutePath());
|
||||||
assertEquals(true, res.contains("status=\"valid\""));
|
assertThat(res).valueByXPath("/validation/summary/@status")
|
||||||
assertEquals(false, res.contains("status=\"invalid\""));
|
.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");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
BIN
validator/src/test/resources/invalidXRechnung.pdf
Normal file
BIN
validator/src/test/resources/invalidXRechnung.pdf
Normal file
Binary file not shown.
BIN
validator/src/test/resources/validXRechnung.pdf
Normal file
BIN
validator/src/test/resources/validXRechnung.pdf
Normal file
Binary file not shown.
Reference in New Issue
Block a user