Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ArithmetricException on ZUGFeRDImporter, but not ZUGFeRDValidator #764

Open
Matthias-SP opened this issue Mar 5, 2025 · 0 comments
Open

Comments

@Matthias-SP
Copy link

Hello everyone,

I recently upgraded to org.mustangproject.validator 2.16.3 using maven. I'm not sure if this issue was also part of an earlier version, but I do remember this exception showing up once or twice when I was on an older version aswell (around 2.15 I think)

I encounter the following issue when I import a default PDF from ferd-net.de.

My Download might be a bit older, see XML comment:
Version of the File 2.3.0 - 18.09.2024.

I basically just call

ZUGFeRDImporter importer = new ZUGFeRDImporter(input.getAsInputStream());
and the following exception appears:

14:34:13,755 ERROR [org.mustangproject.ZUGFeRD.ZUGFeRDInvoiceImporter] (Debug-Thread-1) Failed to parse PDF: org.mustangproject.ZUGFeRD.ZUGFeRDExportException: org.mustangproject.Exceptions.ArithmetricException: Could not reproduce the invoice. Payable total in XML is 521.91, but calculated total is 581.41 with tax basis 908.75 and with positions 900.00 = 900.00
at org.mustangproject.ZUGFeRD.ZUGFeRDInvoiceImporter.setRawXML(ZUGFeRDInvoiceImporter.java:247)
at org.mustangproject.ZUGFeRD.ZUGFeRDInvoiceImporter.setRawXML(ZUGFeRDInvoiceImporter.java:258)
at org.mustangproject.ZUGFeRD.ZUGFeRDInvoiceImporter.extractFiles(ZUGFeRDInvoiceImporter.java:219)
at org.mustangproject.ZUGFeRD.ZUGFeRDInvoiceImporter.extractLowLevel(ZUGFeRDInvoiceImporter.java:154)
at org.mustangproject.ZUGFeRD.ZUGFeRDInvoiceImporter.setInputStream(ZUGFeRDInvoiceImporter.java:99)
at org.mustangproject.ZUGFeRD.ZUGFeRDInvoiceImporter.(ZUGFeRDInvoiceImporter.java:85)
at org.mustangproject.ZUGFeRD.ZUGFeRDImporter.(ZUGFeRDImporter.java:43)

as this is the last step of importing / parsing the XML, and the Exception is wrapped into a runtime exception, my code still works, as I do not use the Invoice class that could not have be created.

however, when I validate this PDF, I get no validation issues:

Code:

 ZUGFeRDValidator validator = new ZUGFeRDValidator();
String validationResultXml = validator.validate(input.getAsInputStream(), config.getFileName());

Result:

<?xml version="1.0" encoding="UTF-8"?>
<validation datetime="2025-03-05 15:16:12" filename="example.pdf">
   <pdf>ValidationResult [flavour=3b, totalAssertions=18397, assertions=[], isCompliant=true]
    <info>
         <signature>unknown</signature>
         <duration unit="ms">197</duration>
      </info>
      <summary status="valid"/>
   </pdf>
   <xml>
      <info>
         <version>2</version>
         <profile>urn:cen.eu:en16931:2017#conformant#urn:factur-x.eu:1p0:extended</profile>
         <validator version="2.16.3"/>
         <rules>
            <fired>142</fired>
            <failed>0</failed>
         </rules>
         <duration unit="ms">361</duration>
      </info>
      <summary status="valid"/>
   </xml>
   <summary status="valid"/>
</validation>

So know I'm curious if there is

  • a calculation issue, or a missed field for this calculation
  • a validation issue where this calculation is not executed / not checked
  • the XML in the PDF is actually faulty, and this exception is wanted - but why not part of the validator?
  • or something in between, or actually expected behavior. I don't know

For me, it would seems logical that if I get an exception for just importing the PDF, I should also get an Exception regarding the validation.

I hope the title and description is good enough, I tried to follow common sense and did not find any open or closed issue mentioning this exact problem. Like I said, maybe the input is actually wrong, but I'm not that familiar with all of the code and electronic invoice standards (yet)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant