stephanstapel / ZUGFeRD-csharp

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

tradeLineItem.NetUnitPrice should be with 4 decimals #131

Closed Ernie-Ho closed 3 years ago

Ernie-Ho commented 3 years ago

In the new "ZUGFeRD-csharp-master\ZUGFeRD\InvoiceDescriptor21Writer.cs" the value of "tradeLineItem.NetUnitPrice" should be given with 4 decimals instead of 2. When calculating with percent rabates a difference occurs in "tradeLineItem.LineTotalAmount" and "tradeLineItem.NetUnitPrice". In "ZUGFeRD-csharp-master\ZUGFeRD\InvoiceDescriptor20Writer.cs" and "ZUGFeRD-csharp-master\ZUGFeRD\InvoiceDescriptor1Writer.cs" it's coded correct.

I run into this issue after switching to "Profile.XRechnung" and "ZUGFeRDVersion.Version21".

"ZUGFeRD-csharp-master\ZUGFeRD\InvoiceDescriptor21Writer.cs":

region NetPriceProductTradePrice

//Im Nettopreis sind alle Zu- und Abschläge enthalten, jedoch nicht die Umsatzsteuer. Writer.WriteStartElement("ram:NetPriceProductTradePrice", Profile.Basic | Profile.Comfort | Profile.Extended | Profile.XRechnung1 | Profile.XRechnung); _writeOptionalAmount(Writer, "ram:ChargeAmount", tradeLineItem.NetUnitPrice, 4);

stephanstapel commented 3 years ago

Hi,

dealing with digits has always been a hassle. I took a look into EN16931 which says:

image

If I understand correctly, the unit price (BT-146) is not mentioned here, right? If so, 4 digits should be no problem. For all other values, 2 digits should be the way to go. Do you share this opinion?

Ernie-Ho commented 3 years ago

Yes, I agree. It's just the "tradeLineItem.NetUnitPrice", which has to be given with 4 decimals. As far as I can see, it's indeed "BT-146". For all other values, 2 digit are OK. As said before, I run into this issue after switching to "Profile.XRechnung" and "ZUGFeRDVersion.Version21".

stephanstapel commented 3 years ago

I didn't care about the digits too much with ZUGFeRD 1.x and nobody was complaining either. That changed with version 2.1. Fixed now.