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:
@@ -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
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user