ConnectingEurope/eInvoicing-EN16931

commercial calculation requires xs:decimal insted of xs:double

LRabeDE opened this issue · 0 comments

With the current approach, numbers from a XML document are converted to xs:double for further use (fn:number). Using this type (xs: double) does not allow the accuracy of calculations required for the commercial sector. I added a sample invoice for demonstration.
example for type problem.zip In this example the following elements are leading to a validation problem in the Context of BR-S-09:

<cac:TaxTotal> <cbc:TaxAmount currencyID="EUR">5.65</cbc:TaxAmount> <cac:TaxSubtotal> <cbc:TaxableAmount currencyID="EUR">29.75</cbc:TaxableAmount> <cbc:TaxAmount currencyID="EUR">1.79</cbc:TaxAmount> <cac:TaxCategory> <cbc:ID>S</cbc:ID> <cbc:Percent>6</cbc:Percent> <cac:TaxScheme> <cbc:ID>VAT</cbc:ID> </cac:TaxScheme> </cac:TaxCategory> </cac:TaxSubtotal> </cac:TaxTotal>

From my point of view, it seems necessary to type all values used for the calculation as xs:decimal. The following (dirty) example in XSLT shows how the underlying calculation of the BR-S-09 should be adjusted to solve the problem.

<xsl:when test="xs:decimal(../cbc:TaxAmount) = (round(((xs:decimal(../cbc:TaxableAmount)) * (xs:decimal(cbc:Percent) div 100)) * 10 * 10) div 100 )"/>

Note: this is NOT a specific Problem of the implementation of the BR-S-09 in UBL but (at least to my understandig) a common implementation problem.