details:   https://code.tryton.org/tryton/commit/d2070e01273b
branch:    8.0
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
        (grafted from 763adbca3986db5acffd5631821fe9647bb5b2f4)
diffstat:

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

diffs (25 lines):

diff -r 40bcb0aa9e39 -r d2070e01273b modules/edocument_ubl/edocument.py
--- a/modules/edocument_ubl/edocument.py        Tue Aug 04 12:24:26 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