details:   https://code.tryton.org/tryton/commit/763adbca3986
branch:    default
user:      Cédric Krier <[email protected]>
date:      Tue Jul 28 19:27:57 2026 +0200
description:
        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
diffstat:

 modules/edocument_ubl/edocument.py |  8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diffs (25 lines):

diff -r ab9e3ff123d5 -r 763adbca3986 modules/edocument_ubl/edocument.py
--- a/modules/edocument_ubl/edocument.py        Tue Aug 04 14:15:47 2026 +0200
+++ b/modules/edocument_ubl/edocument.py        Tue Jul 28 19:27:57 2026 +0200
@@ -460,7 +460,9 @@
         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 @@
         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:

Reply via email to