changeset 1:08ea1ea4a567

Use tax code line for tax reporting issue6013 review40221002
author Cédric Krier <ced@b2ck.com>
date Sun, 25 Mar 2018 23:39:43 +0200
parents 28fbdf1a6625
children 26edf6030365
files __init__.py account.py tests/scenario_account_tax_cash.rst tests/scenario_account_tax_cash_supplier.rst
diffstat 4 files changed, 29 insertions(+), 33 deletions(-) [+]
line wrap: on
line diff
--- a/__init__.py	Sat Mar 24 15:59:19 2018 +0100
+++ b/__init__.py	Sun Mar 25 23:39:43 2018 +0200
@@ -14,7 +14,7 @@
         account.Period,
         party.Party,
         account.TaxGroupCash,
-        account.TaxCode,
+        account.Tax,
         account.TaxLine,
         account.Move,
         account.Invoice,
--- a/account.py	Sat Mar 24 15:59:19 2018 +0100
+++ b/account.py	Sun Mar 25 23:39:43 2018 +0200
@@ -94,15 +94,15 @@
         'account.tax.group', "Tax Group", ondelete='CASCADE', required=True)
 
 
-class TaxCode:
+class Tax:
     __metaclass__ = PoolMeta
-    __name__ = 'account.tax.code'
+    __name__ = 'account.tax'
 
     @classmethod
-    def _sum_where(cls, tax_line, move_line, move):
+    def _amount_where(cls, tax_line, move_line, move):
         context = Transaction().context
         periods = context.get('periods', [])
-        where = super(TaxCode, cls)._sum_where(tax_line, move_line, move)
+        where = super(Tax, cls)._amount_where(tax_line, move_line, move)
         return ((where
                 & (tax_line.on_cash_basis == False)
                 | (tax_line.on_cash_basis == Null))
@@ -110,10 +110,10 @@
                 & (tax_line.on_cash_basis == True)))
 
     @classmethod
-    def _sum_domain(cls):
+    def _amount_domain(cls):
         context = Transaction().context
         periods = context.get('periods', [])
-        domain = super(TaxCode, cls)._sum_domain()
+        domain = super(Tax, cls)._sum_domain()
         return ['OR',
             [domain,
                 ('on_cash_basis', '=', False),
@@ -151,8 +151,8 @@
     @classmethod
     def group_cash_basis_key(cls, line):
         return (
-            ('code', line.code),
             ('tax', line.tax),
+            ('type', line.type),
             ('move_line', line.move_line),
             ('on_cash_basis', line.on_cash_basis),
             )
--- a/tests/scenario_account_tax_cash.rst	Sat Mar 24 15:59:19 2018 +0100
+++ b/tests/scenario_account_tax_cash.rst	Sun Mar 25 23:39:43 2018 +0200
@@ -10,7 +10,7 @@
     >>> from trytond.modules.company.tests.tools import create_company, \
     ...     get_company
     >>> from trytond.modules.account.tests.tools import create_fiscalyear, \
-    ...     create_chart, get_accounts, create_tax, set_tax_code
+    ...     create_chart, get_accounts, create_tax, create_tax_code
     >>> from trytond.modules.account_invoice.tests.tools import \
     ...     set_fiscalyear_invoice_sequences
 
@@ -56,18 +56,26 @@
 
     >>> group_cash_basis = TaxGroup(name="Cash Basis", code="CASH")
     >>> group_cash_basis.save()
-    >>> tax_cash_basis = set_tax_code(create_tax(Decimal('.10')))
+    >>> tax_cash_basis = create_tax(Decimal('.10'))
     >>> tax_cash_basis.group = group_cash_basis
     >>> tax_cash_basis.save()
+    >>> code_base_cash_basis = create_tax_code(tax_cash_basis, 'base', 'invoice')
+    >>> code_base_cash_basis.save()
+    >>> code_tax_cash_basis = create_tax_code(tax_cash_basis, 'tax', 'invoice')
+    >>> code_tax_cash_basis.save()
 
     >>> fiscalyear.tax_group_on_cash_basis.append(TaxGroup(group_cash_basis.id))
     >>> fiscalyear.save()
 
     >>> group_no_cash_basis = TaxGroup(name="No Cash Basis", code="NOCASH")
     >>> group_no_cash_basis.save()
-    >>> tax_no_cash_basis = set_tax_code(create_tax(Decimal('.05')))
+    >>> tax_no_cash_basis = create_tax(Decimal('.05'))
     >>> tax_no_cash_basis.group = group_no_cash_basis
     >>> tax_no_cash_basis.save()
+    >>> code_base_no_cash_basis = create_tax_code(tax_no_cash_basis, 'base', 'invoice')
+    >>> code_base_no_cash_basis.save()
+    >>> code_tax_no_cash_basis = create_tax_code(tax_no_cash_basis, 'tax', 'invoice')
+    >>> code_tax_no_cash_basis.save()
 
 Create party::
 
@@ -107,18 +115,14 @@
 Check tax codes::
 
     >>> with config.set_context(periods=[period.id]):
-    ...     invoice_base_code = TaxCode(tax_cash_basis.invoice_base_code.id)
-    ...     invoice_base_code.sum
-    ...     invoice_tax_code = TaxCode(tax_cash_basis.invoice_tax_code.id)
-    ...     invoice_tax_code.sum
+    ...     TaxCode(code_base_cash_basis.id).amount
+    ...     TaxCode(code_tax_cash_basis.id).amount
     Decimal('0.00')
     Decimal('0.00')
 
     >>> with config.set_context(periods=[period.id]):
-    ...     invoice_base_code = TaxCode(tax_no_cash_basis.invoice_base_code.id)
-    ...     invoice_base_code.sum
-    ...     invoice_tax_code = TaxCode(tax_no_cash_basis.invoice_tax_code.id)
-    ...     invoice_tax_code.sum
+    ...     TaxCode(code_base_no_cash_basis.id).amount
+    ...     TaxCode(code_tax_no_cash_basis.id).amount
     Decimal('100.00')
     Decimal('5.00')
 
@@ -136,17 +140,13 @@
 Check tax codes::
 
     >>> with config.set_context(periods=[period.id]):
-    ...     invoice_base_code = TaxCode(tax_cash_basis.invoice_base_code.id)
-    ...     invoice_base_code.sum
-    ...     invoice_tax_code = TaxCode(tax_cash_basis.invoice_tax_code.id)
-    ...     invoice_tax_code.sum
+    ...     TaxCode(code_base_cash_basis.id).amount
+    ...     TaxCode(code_tax_cash_basis.id).amount
     Decimal('52.17')
     Decimal('5.22')
 
     >>> with config.set_context(periods=[period.id]):
-    ...     invoice_base_code = TaxCode(tax_no_cash_basis.invoice_base_code.id)
-    ...     invoice_base_code.sum
-    ...     invoice_tax_code = TaxCode(tax_no_cash_basis.invoice_tax_code.id)
-    ...     invoice_tax_code.sum
+    ...     TaxCode(code_base_no_cash_basis.id).amount
+    ...     TaxCode(code_tax_no_cash_basis.id).amount
     Decimal('100.00')
     Decimal('5.00')
--- a/tests/scenario_account_tax_cash_supplier.rst	Sat Mar 24 15:59:19 2018 +0100
+++ b/tests/scenario_account_tax_cash_supplier.rst	Sun Mar 25 23:39:43 2018 +0200
@@ -10,7 +10,7 @@
     >>> from trytond.modules.company.tests.tools import create_company, \
     ...     get_company
     >>> from trytond.modules.account.tests.tools import create_fiscalyear, \
-    ...     create_chart, get_accounts, create_tax, set_tax_code
+    ...     create_chart, get_accounts, create_tax
     >>> from trytond.modules.account_invoice.tests.tools import \
     ...     set_fiscalyear_invoice_sequences
 
@@ -47,13 +47,9 @@
     >>> TaxCode = Model.get('account.tax.code')
     >>> tax_group = TaxGroup(name="Supplier", code="SUP")
     >>> tax_group.save()
-    >>> tax = set_tax_code(create_tax(Decimal('.10')))
+    >>> tax = create_tax(Decimal('.10'))
     >>> tax.group = tax_group
     >>> tax.save()
-    >>> invoice_base_code = tax.invoice_base_code
-    >>> invoice_tax_code = tax.invoice_tax_code
-    >>> credit_note_base_code = tax.credit_note_base_code
-    >>> credit_note_tax_code = tax.credit_note_tax_code
 
 Create party::
 

Repository Layout

/ Tryton top level repositories
modules Modules
public Public repositories
tpf Tryton Foundation repositories
sandbox Sandbox