This commit is contained in:
jstaerk
2025-06-30 10:53:52 +02:00
parent 1b174e243f
commit 8ce3d21eae
7 changed files with 32 additions and 27 deletions

View File

@@ -420,23 +420,17 @@ public class XMLValidator extends Validator {
private void checkArithmetrics(ValidationContext context) {
ZUGFeRDInvoiceImporter zi=new ZUGFeRDInvoiceImporter();
try {
zi.setRawXML(zfXML.getBytes());
zi.fromXML(zfXML);
CalculatedInvoice ci=new CalculatedInvoice();
zi.extractInto(ci);
TransactionCalculator tc=new TransactionCalculator(ci);
if (tc.getGrandTotal().compareTo(ci.getGrandTotal())!=0) {
}
} catch ( ArithmetricException e) {
try {
context.addResultItem(new ValidationResultItem(ESeverity.warning, "Can not arithmetrically reproduce the invoice.").setSection(10));
context.addResultItem(new ValidationResultItem(ESeverity.warning, "Arithmetical issue:"+e.getMessage()).setSection(10));
} catch (IrrecoverableValidationError ie) {
LOGGER.error(ie.getMessage(), ie);
}
} catch ( IOException e) {
LOGGER.error(e.getMessage(), e);
} catch (XPathExpressionException e) {
LOGGER.error(e.getMessage(), e);
} catch (ParseException e) {

View File

@@ -297,7 +297,7 @@ public class XMLValidatorTest extends ResourceCase {
String s="<validation>" + xv.getXMLResult() + "</validation>";
Source source = Input.fromString(s).build();
String content = xpath.evaluate("/validation/summary/@status", source);
assertEquals("invalid", content);
assertEquals("valid", content);
assertThat(s).valueByXPath("count(//warning)")
.asInt()
.isEqualTo(1);

View File

@@ -219,7 +219,7 @@ public class ZUGFeRDValidatorTest extends ResourceCase {
.isEqualTo(2);
assertThat(res).valueByXPath("count(//warning)")
.asInt()
.isEqualTo(2);
.isEqualTo(3);
assertThat(res).valueByXPath("count(//notice)")
.asInt()