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
234 stars 132 forks source link

4 decimal digits in prices #226

Open murygin opened 3 years ago

murygin commented 3 years ago

When I create an invoice, these prices have 4 decimal digits: /rsm:CrossIndustryInvoice[1]/rsm:SupplyChainTradeTransaction[1]/ram:IncludedSupplyChainTradeLineItem[1]/ram:SpecifiedLineTradeAgreement[1]/ram:GrossPriceProductTradePrice[1]/ram:ChargeAmount

The reason for this is that to output these prices the method org.mustangproject.ZUGFeRD.priceFormat(BigDecimal) is used to output these prices. This method uses XMLTools.nDigitFormat(value, 4); This behavior is hard coded. I cannot change to 2 decimal digits here.

If I validate the invoice with this tool: https://ecosio.com/de/peppol-und-xml-dokumente-online-validieren/ then errors are output.

Schematron (XSLT) - /en16931/1.3.3/ubl/xslt/EN16931-UBL-validation.xslt
Error
Location: XRechnung-anonym.xml
Element/context: /rsm:CrossIndustryInvoice[1]/rsm:SupplyChainTradeTransaction[1]/ram:IncludedSupplyChainTradeLineItem[1]/ram:SpecifiedLineTradeAgreement[1]/ram:GrossPriceProductTradePrice[1]/ram:ChargeAmount[1]
XPath test: string-length(substring-after(.,'.'))<=2
Error message: [UBL-DT-01]-Amounts shall be decimal up to two fraction digits

Shouldn't all prices always have only 2 decimal digits?

jstaerk commented 3 years ago

EN16931-1 chapter 6.5.12 talks of two, Factur-X 1.0.50, chapter 7.1.5 talks of four digits for the unit price amount. I'm trying to clarify.