details:   https://code.tryton.org/tryton/commit/f4703a362c8f
branch:    7.8
user:      Cédric Krier <[email protected]>
date:      Mon Mar 02 15:23:13 2026 +0100
description:
        Use currency rounding when currency has no cash rounding set

        Closes #14638
        (grafted from c2e82186e7089618939ae9270490a68d2ca17622)
diffstat:

 modules/account_cash_rounding/currency.py                                      
           |  6 +++++-
 
modules/account_cash_rounding/tests/scenario_account_cash_rounding_alternate_currency.rst
 |  2 +-
 2 files changed, 6 insertions(+), 2 deletions(-)

diffs (24 lines):

diff -r e7be0aff52f0 -r f4703a362c8f modules/account_cash_rounding/currency.py
--- a/modules/account_cash_rounding/currency.py Mon Mar 09 10:54:45 2026 +0100
+++ b/modules/account_cash_rounding/currency.py Mon Mar 02 15:23:13 2026 +0100
@@ -15,4 +15,8 @@
         digits=(None, Eval('digits', None)))
 
     def cash_round(self, amount, rounding=ROUND_HALF_EVEN):
-        return self._round(amount, self.cash_rounding, rounding)
+        if self.cash_rounding is not None:
+            factor = self.cash_rounding
+        else:
+            factor = self.rounding
+        return self._round(amount, factor, rounding)
diff -r e7be0aff52f0 -r f4703a362c8f 
modules/account_cash_rounding/tests/scenario_account_cash_rounding_alternate_currency.rst
--- 
a/modules/account_cash_rounding/tests/scenario_account_cash_rounding_alternate_currency.rst
 Mon Mar 09 10:54:45 2026 +0100
+++ 
b/modules/account_cash_rounding/tests/scenario_account_cash_rounding_alternate_currency.rst
 Mon Mar 02 15:23:13 2026 +0100
@@ -105,6 +105,6 @@
 
     >>> line_to_pay, = invoice.lines_to_pay
     >>> line_to_pay.debit, line_to_pay.credit
-    (Decimal('21.02'), Decimal('0'))
+    (Decimal('21.02'), Decimal('0.00'))
     >>> line_to_pay.amount_second_currency
     Decimal('42.05')

Reply via email to