ZUGFeRD / mustangproject

Open Source Java e-Invoicing library, validator and tool (Factur-X/ZUGFeRD, UNCEFACT/CII XRechnung)
http://www.mustangproject.org
Apache License 2.0
237 stars 132 forks source link

Possible rounding problem in sum line? #234

Closed schnobbl closed 3 years ago

schnobbl commented 3 years ago

Hi Folks,

we created a zugferd invoice with profile "Xrechnung". It seems that that the total amount gross is not calculated correctly.

The positions:

2 × Monat dom001 domain 6,9900 13,9800 2 × Monat dom001 domain (discount) -2,0970 -4,1940 2 × Monat dom001 domain 6,9900 13,9800 2 × Monat dom001 domain (discount) -2,0970 -4,1940 2 × Monat dom001 domain 6,9900 13,9800 2 × Monat dom001 domain (discount) -2,0970 -4,1940 2 × Monat dom001 domain 6,9900 13,9800 2 × Monat dom001 domain (discount) -2,0970 -4,1940 2 × Monat dom001 domain 6,9900 13,9800 2 × Monat dom001 domain (discount) -2,0970 -4,1940 2 × Monat dom001 domain 6,9900 13,9800 2 × Monat dom001 domain (discount) -2,0970 -4,1940

Sum net: 58,72 Sum gross: 69,87

Inside the factur-x.xml the sums differ. We had a integration test for this. running against an older version of mustang this was fine. Since update zu 2.1.1 our test is red.

Any ideas? Thanks, Norbert

jstaerk commented 3 years ago

assuming you're on 19% VAT 58,72*1,19 seems to amount to 69,8768 which IMO would be rounded to 69,88 Eur?

schnobbl commented 3 years ago

The net amount is shown to the customer on the invoice with only 2 decimal places, sorry for the confusion. We build the net sum total by sum up all positioins total (BigDecimal, 4 decimal places). Then the Gross total sum is calculated. In the last step this total gross amound is rounded for 2 decimal places.

so sum net in real is: 58,716

jstaerk commented 3 years ago

sums and AFAIK also the tax base amount are two digits (Factur-X Specification 1.0.50, chap 7.1.5) and I believe something similar is mentioned in EN16931-1 Chap. 6.5.12 (https://www.beuth.de/en/standard/din-en-16931-1/314992770), in which case IMO the 69,88 would be correct?

schnobbl commented 3 years ago

ok you are right. rounding on position sum line has only 2 digits. This is a major difference to older mustang lib versions. I will close this issue. Thx