stephanstapel / ZUGFeRD-csharp

C# assembly for creating and reading ZUGFeRD invoices
Apache License 2.0
139 stars 79 forks source link

X-Rechnung 3.1 UBL for Deutsche Bahn - tax rounding #262

Closed stephanstapel closed 1 month ago

stephanstapel commented 2 months ago

broken down from #254, submitted by @goedo

Tax.cs

  return System.Math.Round(0.01m * this.Percent * this.BasisAmount, 2, MidpointRounding.AwayFromZero);
stephanstapel commented 2 months ago

https://learn.microsoft.com/en-us/dotnet/api/system.midpointrounding?view=net-8.0

grafik

https://de.wikipedia.org/wiki/Rundung

grafik

stephanstapel commented 2 months ago

rounding rules from EN16931 https://github.com/stephanstapel/ZUGFeRD-csharp/issues/131

goedo commented 2 months ago

I'm still not sure if keeping

return 0.01m this.Percent this.BasisAmount;

could be better (in other places, I do the rounding).

Still not know how to fix

image

Could be related...

stephanstapel commented 1 month ago

This is the only piece of code where things are calculated. Fixed this.