ZUGFeRD / ZUV

ZUgferd validator using Verapdf
Apache License 2.0
25 stars 5 forks source link

rounding errors when applying schematron #22

Closed jstaerk closed 5 years ago

jstaerk commented 5 years ago

ZUGFeRD-invoice_rabatte_4_abschlag_taxbasistotalamount.xml of the post in https://groups.google.com/forum/#!topic/zugferd/5k22Ph0F82g yields the schematron error Der Inhalt des Elementes „Invoice total amount without VAT“ (BT-109) entspricht der Summe aller Inhalte der Elemente „Invoice line net amount“ (BT-131) abzüglich der Summe aller in der Rechnung enthaltenen Nachlässe der Dokumentenebene „Sum of allowances on document level“ (BT-107) zuzüglich der Summe aller in der Rechnung enthaltenen Abgaben der Dokumentenebene „Sum of charges on document level“ (BT-108).

It seems to be a rounding error within the XSLT, Saxon, or both: I reduced the test in the XSLT file to ((ram:TaxBasisTotalAmount = ram:LineTotalAmount - ram:AllowanceTotalAmount) and not (ram:ChargeTotalAmount)) and added and with

ram:LineTotalAmount of 201.48 and ram:AllowanceTotalAmount 7.05 the result of the XSLT was 194.42999999999998 instead of 194.43, as in the document

jstaerk commented 5 years ago

In her invoice-3 the error Der Inhalt des Elementes „Amount due for payment“ (BT-115) entspricht dem Inhalt des Elementes „Invoice total VAT amount“ (BT-110) abzüglich dem Inhalt des Elementes „Paid amount“ (BT-113) zuzüglich dem Inhalt des Elementes „Rounding amount“ (BT-114) could also be a rounding issue because ram:GrandTotalAmount - ram:TotalPrepaidAmount value-ofs to 14.739999999999995

jstaerk commented 5 years ago

On 06.08. someone reported the same issue with total prepaid 17808.00 and grand total 18310.63. value-offing to 502.630000000001 . ram:GrandTotalAmount - ram:TotalPrepaidAmount is erroneous in that case,round(( ram:GrandTotalAmount - ram:TotalPrepaidAmount ) * 100) div 100 works. Next steps: check if misbehaviour and correction can be reproduced with the CEN schematron and upstream at least a issue if that is the case.

jstaerk commented 5 years ago

It does not happen on https://github.com/CenPC434/validation , I'll try to get in touch with somebody from ZUGFeRD RE Schematron

jstaerk commented 5 years ago

I just checked against Factur-X, https://services.fnfe-mpe.org/account/analysis?id=2342 and https://services.fnfe-mpe.org/account/analysis?id=2343 which also seem to show the error

jstaerk commented 5 years ago

prototype of [b40ad867] on http://mustangproject.org/files/ZUV-0.8.2-SNAPSHOT.jar

jstaerk commented 4 years ago

It has been fixed in zf 2.1 and the according fix is reflected in v0.9