stephanstapel / ZUGFeRD-csharp

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

X-Rechnung 3.1 UBL for Deutsche Bahn - line total amount #260

Closed stephanstapel closed 4 months ago

stephanstapel commented 5 months ago

broken down from #254, submitted by @goedo

InvoiceDescriptor22Writer.cs, 404

                if (tradeLineItem.TaxCategoryCode != TaxCategoryCodes.O) // notwendig, damit die Validierung klappt
                {
                    Writer.WriteElementString("ram:RateApplicablePercent", _formatDecimal(tradeLineItem.TaxPercent));
                }
                //roger
                if (tradeLineItem.LineTotalAmount.HasValue) 
               // -->I had to add LineTotalAmount to desc.addtradeLineItem in InvoiceDescriptor.cs
                {
                    Writer.WriteStartElement("ram:BasisAmount", profile: Profile.Extended); // not in XRechnung, according to CII-SR-123
                    Writer.WriteValue(_formatDecimal(tradeLineItem.LineTotalAmount.Value, 2));
                    Writer.WriteEndElement();
                } // !roger
stephanstapel commented 5 months ago

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

@goedo: did you change anything else?

goedo commented 4 months ago

I h think this was because of some tests, in which tradeLineItem.LineTotalAmount hat no value (which should never happen. Basically, the "if" shall not be needed, because the content is needed in any case. Possibly because of my adding lineTotalAmount to the TradeLineItem (decimal? lineTotalAmount = null), in AddTradeLineItem (4 times after billingperiodend) , the situation in which it has no value never happens (becaus I provide a value, taken from the invoice data to be converted). Basically, the minimum data provision is net value and tax percent, so a linetotalamount should be calculatable from this net value. Possibly, instead of adding it (like I did), it could be calculated anywhere in the InvoiceDescriptor22Writer.cs ... still not 100% sure how to consolidate everything.

goedo commented 4 months ago

See #269 for additional info. For my scenarios, I have solved the issue, possibly shortsighted for a general approach...

stephanstapel commented 4 months ago

closed in #269