changeset 0dc546d3cbff in modules/account:default
details: https://hg.tryton.org/modules/account?cmd=changeset;node=0dc546d3cbff
description:
Allow setting the tax date on taxable lines
We add a taxing date to the invoice line which allow overriding the
value of
the invoice.
When crediting an invoice, the original tax date of each line is stored
on the
credit line so the tax are computed the same way.
issue9520
review323791002
diffstat:
CHANGELOG | 1 +
tax.py | 8 +++++---
tests/test_account.py | 4 ++--
3 files changed, 8 insertions(+), 5 deletions(-)
diffs (68 lines):
diff -r 864068d0f1ff -r 0dc546d3cbff CHANGELOG
--- a/CHANGELOG Sat Sep 05 22:21:38 2020 +0200
+++ b/CHANGELOG Sat Sep 05 23:37:58 2020 +0200
@@ -1,3 +1,4 @@
+* Allow defining the tax date on taxable lines
* Add General Ledger per account and party
* Add start/end date to tax rule line
* Test for lines to reconcile before showing the next account
diff -r 864068d0f1ff -r 0dc546d3cbff tax.py
--- a/tax.py Sat Sep 05 22:21:38 2020 +0200
+++ b/tax.py Sat Sep 05 23:37:58 2020 +0200
@@ -1068,7 +1068,8 @@
return hash(self._key())
-_TaxableLine = namedtuple('_TaxableLine', ('taxes', 'unit_price', 'quantity'))
+_TaxableLine = namedtuple(
+ '_TaxableLine', ('taxes', 'unit_price', 'quantity', 'tax_date'))
class TaxableMixin(object):
@@ -1080,6 +1081,7 @@
- the first element is the taxes applicable
- the second element is the line unit price
- the third element is the line quantity
+ - the forth element is the optional tax date
"""
return []
@@ -1136,7 +1138,7 @@
for params in self.taxable_lines]
for line in taxable_lines:
l_taxes = Tax.compute(Tax.browse(line.taxes), line.unit_price,
- line.quantity, self.tax_date)
+ line.quantity, line.tax_date or self.tax_date)
for tax in l_taxes:
taxline = self._compute_tax_line(**tax)
# Base must always be rounded per line as there will be one
@@ -1757,7 +1759,7 @@
@property
def taxable_lines(self):
- return [(self.taxes, self.unit_price, self.quantity)]
+ return [(self.taxes, self.unit_price, self.quantity, self.tax_date)]
@fields.depends(
'tax_date', 'taxes', 'unit_price', 'quantity', 'currency', 'result')
diff -r 864068d0f1ff -r 0dc546d3cbff tests/test_account.py
--- a/tests/test_account.py Sat Sep 05 22:21:38 2020 +0200
+++ b/tests/test_account.py Sat Sep 05 23:37:58 2020 +0200
@@ -1026,7 +1026,7 @@
taxable = self.Taxable(
currency=currency,
taxable_lines=[
- ([tax], Decimal('1.001'), 1),
+ ([tax], Decimal('1.001'), 1, None),
] * 100)
taxes = taxable._get_taxes()
@@ -1062,7 +1062,7 @@
taxable = Taxable(
currency=currency,
taxable_lines=[
- ([tax], Decimal('1.001'), 1),
+ ([tax], Decimal('1.001'), 1, None),
] * 100)
taxes = taxable._get_taxes()