ZUGFeRD/ZUV

rounding errors when applying schematron

jstaerk opened this issue · 6 comments

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 <xsl:value-of select="ram:LineTotalAmount - ram:AllowanceTotalAmount"/> 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

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

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.

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

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