40 lines
1.2 KiB
Python
40 lines
1.2 KiB
Python
"""Dominican invoice tax rounding policy.
|
|
|
|
Tryton's generic taxable mixin compensates the aggregate currency-rounding
|
|
remainder on the first non-zero tax. That keeps the rounded aggregate equal
|
|
to the aggregate of the unrounded taxes, but it can change the reported value
|
|
of a specific Dominican tax (ITBIS, ISC or CDT).
|
|
|
|
Dominican fiscal documents state every tax in currency precision. Each tax
|
|
must therefore retain its own rounded result; no residual is redistributed
|
|
between different tax liabilities or tax credits.
|
|
"""
|
|
|
|
from trytond.model import fields
|
|
from trytond.pool import PoolMeta
|
|
|
|
|
|
def round_taxes_independently(currency, taxes):
|
|
"""Round every tax amount without reallocating the aggregate residual."""
|
|
if not currency:
|
|
return
|
|
for taxline in taxes.values():
|
|
taxline.amount = currency.round(taxline.amount)
|
|
|
|
|
|
class IndependentTaxRoundingMixin:
|
|
|
|
__slots__ = ()
|
|
|
|
@fields.depends('currency')
|
|
def _round_taxes(self, taxes):
|
|
round_taxes_independently(self.currency, taxes)
|
|
|
|
|
|
class Invoice(IndependentTaxRoundingMixin, metaclass=PoolMeta):
|
|
__name__ = 'account.invoice'
|
|
|
|
|
|
class InvoiceLine(IndependentTaxRoundingMixin, metaclass=PoolMeta):
|
|
__name__ = 'account.invoice.line'
|