Normalize the quantity before calculating the number of digits when parsing UBL

Trailing zero in the quantity should not require a bigger precision for the
unit.

Closes #14973
(grafted from 763adbca3986db5acffd5631821fe9647bb5b2f4)

--HG--
branch : 8.0
This commit is contained in:
Cédric Krier
2026-07-28 19:27:57 +02:00
parent ad7f66c3ca
commit 187fc8a245
+6 -2
View File
@@ -460,7 +460,9 @@ class Invoice(Model):
if (invoiced_quantity := invoice_line.find('./{*}InvoicedQuantity')
) is not None:
line.quantity = float(invoiced_quantity.text)
digits = -Decimal(invoiced_quantity.text).as_tuple().exponent
digits = (
-Decimal(invoiced_quantity.text)
.normalize().as_tuple().exponent)
if (unit_code := invoiced_quantity.get('unitCode')) not in {
None, 'ZZ', 'XZZ'}:
try:
@@ -771,7 +773,9 @@ class Invoice(Model):
if (credited_quantity := credit_note_line.find('./{*}CreditedQuantity')
) is not None:
line.quantity = -float(credited_quantity.text)
digits = -Decimal(credited_quantity.text).as_tuple().exponent
digits = (
-Decimal(credited_quantity.text)
.normalize().as_tuple().exponent)
if (unit_code := credited_quantity.get('unitCode')) not in {
None, 'ZZ', 'XZZ'}:
try: