This commit is contained in:
jstaerk
2025-08-04 10:18:03 +02:00
parent b3ee54effa
commit 74a939d1f1
2 changed files with 23 additions and 0 deletions

View File

@@ -71,6 +71,7 @@ public class ZUGFeRDInvoiceImporter {
protected CalculatedInvoice importedInvoice = null;
protected boolean recalcPrice = false;
protected boolean ignoreCalculationErrors = false;
protected boolean containsAXMLFileAttachment = false;
public ZUGFeRDInvoiceImporter() {
//constructor for extending classes
@@ -197,16 +198,31 @@ public class ZUGFeRDInvoiceImporter {
ignoreCalculationErrors = true;
}
/***
* if the file attachment is not in the list of allowed file names we can't import the XML,
* but the validator needs to know if maybe some other .xml-File is embedded because it would
* raise an additional notice that the filename is probably wrong
*
* @return
*/
public boolean hasXMLFileAttachment() {
return containsAXMLFileAttachment;
}
/***
* sets th pdf attachments, and if a file is recognized (e.g. a factur-x.xml) triggers processing
* @param names the Hashmap of String, PDComplexFileSpecification
* @throws IOException
*/
private void extractFiles(Map<String, PDComplexFileSpecification> names) throws IOException {
containsAXMLFileAttachment=false;
for (final String alias : names.keySet()) {
final PDComplexFileSpecification fileSpec = names.get(alias);
final String filename = fileSpec.getFilename();
if (filename.toUpperCase().endsWith(".XML")) {
containsAXMLFileAttachment=true;
}
/**
* filenames for invoice data (ZUGFeRD v1 and v2, Factur-X)
*/

View File

@@ -226,6 +226,13 @@ public class PDFValidator extends Validator {
}
if (!documentFilenameValid) {
if (zi.hasXMLFileAttachment()) {
context.addResultItem(new ValidationResultItem(
ESeverity.notice,
"Potentially incorrectly named XML file attachments detected"
).setSection(17).setPart(EPart.pdf));
}
context.addResultItem(new ValidationResultItem(
ESeverity.error,
"XMP Metadata: DocumentFileName contains invalid value"