Allow cash rounding with opposite method
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
* Allow cash rounding with opposite method
|
||||
* Add support for Python 3.14
|
||||
* Remove support for Python 3.9
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
from decimal import ROUND_HALF_EVEN
|
||||
|
||||
from trytond.model import fields
|
||||
from trytond.modules.currency import ROUNDING_OPPOSITES
|
||||
from trytond.pool import PoolMeta
|
||||
from trytond.pyson import Eval
|
||||
|
||||
@@ -14,7 +15,9 @@ class Currency(metaclass=PoolMeta):
|
||||
"Cash Rounding Factor",
|
||||
digits=(None, Eval('digits', None)))
|
||||
|
||||
def cash_round(self, amount, rounding=ROUND_HALF_EVEN):
|
||||
def cash_round(self, amount, rounding=ROUND_HALF_EVEN, opposite=False):
|
||||
if opposite:
|
||||
rounding = ROUNDING_OPPOSITES[rounding]
|
||||
if self.cash_rounding is not None:
|
||||
factor = self.cash_rounding
|
||||
else:
|
||||
|
||||
@@ -1,2 +1,11 @@
|
||||
# This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
# this repository contains the full copyright notices and license terms.
|
||||
|
||||
__all__ = ['ROUNDING_OPPOSITES']
|
||||
|
||||
|
||||
def __getattr__(name):
|
||||
if name == 'ROUNDING_OPPOSITES':
|
||||
from .currency import ROUNDING_OPPOSITES
|
||||
return ROUNDING_OPPOSITES
|
||||
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
|
||||
|
||||
Reference in New Issue
Block a user