Add SubInvoiceLine support for ZUGFeRD Extended profile

- Parse ParentLineID and LineStatusReasonCode from XML
  - Filter GROUP/INFORMATION lines from calculation (only DETAIL counts)
  - Add hierarchy validation for GROUP line totals
  - Add tests for sub invoice line import and validation
This commit is contained in:
Andreas Reichmann
2025-12-08 20:43:14 +01:00
parent 6900f5f433
commit 0be3e04a2a
6 changed files with 294 additions and 5 deletions

View File

@@ -373,4 +373,28 @@ public class XMLValidatorTest extends ResourceCase {
}
public void testSubInvoiceLineHierarchy() {
final ValidationContext ctx = new ValidationContext(null);
final XMLValidator xv = new XMLValidator(ctx);
final XPathEngine xpath = new JAXPXPathEngine();
// test invalid hierarchy: GROUP sum does not match DETAIL children sum
// GROUP 01 has LineTotalAmount=999, but children sum to 1050 (600+450)
File tempFile = getResourceAsFile("invalidSubInvoiceLineHierarchy.xml");
try {
xv.setFilename(tempFile.getAbsolutePath());
xv.validate();
String s = "<validation>" + xv.getXMLResult() + "</validation>";
// hierarchy mismatch should produce at least one warning
assertThat(s).valueByXPath("count(//warning)")
.asInt()
.isGreaterThanOrEqualTo(1);
} catch (final IrrecoverableValidationError e) {
// ignore, will be in XML output anyway
}
}
}