Add link between IVA and recargo taxes

issue9182
review301261002
This commit is contained in:
Sergi Almacellas Abellana committed 2020-10-11 23:38:37 +02:00
1 parent c1a5771ad4
commit cffe9df210
7 files changed
+77 -30

No files matched your search

+1
View File
@@ -1,3 +1,4 @@
* Link recargo tax with its related VAT taxes
* Add purchase service tax group
Version 5.6.0 - 2020-05-04
+58 -1
View File
@@ -1,7 +1,7 @@
# This file is part of Tryton. The COPYRIGHT file at the top level of
# this repository contains the full copyright notices and license terms.
from trytond.model import fields
from trytond.pool import PoolMeta
from trytond.pool import PoolMeta, Pool
from trytond.pyson import Bool, Eval
@@ -42,6 +42,7 @@ class TaxTemplate(metaclass=PoolMeta):
es_vat_list_code = fields.Char("Spanish VAT List Code")
es_ec_purchases_list_code = fields.Char("Spanish EC Purchase List Code")
es_reported_with = fields.Many2One('account.tax.template', "Reported With")
def _get_tax_value(self, tax=None):
value = super()._get_tax_value(tax=tax)
@@ -50,6 +51,29 @@ class TaxTemplate(metaclass=PoolMeta):
value[name] = getattr(self, name)
return value
@classmethod
def create_tax(
cls, account_id, company_id, template2account, template2tax=None):
pool = Pool()
Tax = pool.get('account.tax')
super().create_tax(
account_id, company_id, template2account, template2tax)
to_write = []
for template_id, tax_id in template2tax.items():
template = cls(template_id)
if not template.es_reported_with:
continue
reported_with = template2tax[template.es_reported_with.id]
to_write.append([Tax(tax_id)])
to_write.append({
'es_reported_with': reported_with,
})
if to_write:
Tax.write(*to_write)
class Tax(metaclass=PoolMeta):
__name__ = 'account.tax'
@@ -66,3 +90,36 @@ class Tax(metaclass=PoolMeta):
& ~Eval('template_override', False)),
},
depends=['template', 'template_override'])
es_reported_with = fields.Many2One('account.tax', "Reported with",
states={
'readonly': (Bool(Eval('template', -1))
& ~Eval('template_override', False)),
},
depends=['template', 'template_override'])
@classmethod
def update_tax(cls, company_id, template2account, template2tax=None):
super().update_tax(company_id, template2account, template2tax)
to_write = []
for template_id, tax_id in template2tax.items():
tax = cls(tax_id)
if not tax.template_override:
values = {}
reported_with = (tax.es_reported_with.id
if tax.es_reported_with else None)
if (tax.template.es_reported_with
and reported_with != template2tax.get(
tax.template.es_reported_with.id)):
values['es_reported_with'] = template2tax.get(
tax.template.es_reported_with.id)
elif (not tax.template.es_reported_with
and tax.es_reported_with):
values['es_reported_with'] = None
if values:
to_write.append([tax])
to_write.append(values)
if to_write:
cls.write(*to_write)
+4 -9
View File
@@ -2,7 +2,7 @@
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
this repository contains the full copyright notices and license terms. -->
<tryton>
<data grouped="1">
<data>
<record model="account.tax.template" id="iva_rep_21">
<field name="name">IVA 21% (bienes)</field>
<field name="description">IVA 21%</field>
@@ -87,6 +87,7 @@ this repository contains the full copyright notices and license terms. -->
<field name="rate" eval="Decimal('0.052')"/>
<field name="invoice_account" ref="pgc_477"/>
<field name="credit_note_account" ref="pgc_477"/>
<field name="es_reported_with" ref="iva_rep_21"/>
</record>
<record model="account.tax.template" id="iva_rep_re_14">
<field name="name">Recargo Equivalencia 1.4%</field>
@@ -97,6 +98,7 @@ this repository contains the full copyright notices and license terms. -->
<field name="rate" eval="Decimal('0.014')"/>
<field name="invoice_account" ref="pgc_477"/>
<field name="credit_note_account" ref="pgc_477"/>
<field name="es_reported_with" ref="iva_rep_10"/>
</record>
<record model="account.tax.template" id="iva_rep_re_05">
<field name="name">Recargo Equivalencia 0.5%</field>
@@ -107,6 +109,7 @@ this repository contains the full copyright notices and license terms. -->
<field name="rate" eval="Decimal('0.005')"/>
<field name="invoice_account" ref="pgc_477"/>
<field name="credit_note_account" ref="pgc_477"/>
<field name="es_reported_with" ref="iva_rep_4"/>
</record>
<record model="account.tax.template" id="iva_rep_exportaciones">
<field name="name">IVA Exportaciones (bienes)</field>
@@ -433,8 +436,6 @@ this repository contains the full copyright notices and license terms. -->
<field name="update_unit_price" eval="True"/>
<field name="sequence" eval="10"/>
</record>
</data>
<data grouped="1">
<record model="account.tax.template" id="iva_sop_intracomunitario_1">
<field name="name">IVA Intracomunitario. Bienes (1)</field>
<field name="description">IVA Intracomunitario (1)</field>
@@ -504,8 +505,6 @@ this repository contains the full copyright notices and license terms. -->
<field name="invoice_account" ref="pgc_477"/>
<field name="credit_note_account" ref="pgc_477"/>
</record>
</data>
<data>
<record model="account.tax.code.template" id="vat_code_iva">
<field name="name">Impuesto sobre el Valor Añadido - Autoliquidación</field>
<field name="code">AEAT303</field>
@@ -1864,8 +1863,6 @@ this repository contains the full copyright notices and license terms. -->
<field name="amount">tax</field>
<field name="type">credit</field>
</record>
</data>
<data grouped="1">
<record model="account.tax.rule.template" id="fp_recargo">
<field name="name">Recargo de Equivalencia</field>
<field name="account" ref="pgc_0"/>
@@ -1931,8 +1928,6 @@ this repository contains the full copyright notices and license terms. -->
<field name="account" ref="pgc_0"/>
<field name="kind">purchase</field>
</record>
</data>
<data grouped="1">
<record model="account.tax.rule.line.template" id="fptt_recargo_4_2">
<field name="rule" ref="fp_recargo"/>
<field name="origin_tax" ref="iva_rep_4"/>
+4 -9
View File
@@ -2,7 +2,7 @@
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
this repository contains the full copyright notices and license terms. -->
<tryton>
<data grouped="1">
<data>
<record id="iva_rep_21_normal" model="account.tax.template">
<field name="name">IVA 21% (bienes)</field>
<field name="description">IVA 21%</field>
@@ -87,6 +87,7 @@ this repository contains the full copyright notices and license terms. -->
<field name="rate" eval="Decimal('0.052')"/>
<field name="invoice_account" ref="pgc_477_normal"/>
<field name="credit_note_account" ref="pgc_477_normal"/>
<field name="es_reported_with" ref="iva_rep_21_normal"/>
</record>
<record id="iva_rep_re_14_normal" model="account.tax.template">
<field name="name">Recargo Equivalencia 1.4%</field>
@@ -97,6 +98,7 @@ this repository contains the full copyright notices and license terms. -->
<field name="rate" eval="Decimal('0.014')"/>
<field name="invoice_account" ref="pgc_477_normal"/>
<field name="credit_note_account" ref="pgc_477_normal"/>
<field name="es_reported_with" ref="iva_rep_10_normal"/>
</record>
<record id="iva_rep_re_05_normal" model="account.tax.template">
<field name="name">Recargo Equivalencia 0.5%</field>
@@ -107,6 +109,7 @@ this repository contains the full copyright notices and license terms. -->
<field name="rate" eval="Decimal('0.005')"/>
<field name="invoice_account" ref="pgc_477_normal"/>
<field name="credit_note_account" ref="pgc_477_normal"/>
<field name="es_reported_with" ref="iva_rep_4_normal"/>
</record>
<record id="iva_rep_exportaciones_normal" model="account.tax.template">
<field name="name">IVA Exportaciones (bienes)</field>
@@ -433,8 +436,6 @@ this repository contains the full copyright notices and license terms. -->
<field name="update_unit_price" eval="True"/>
<field name="sequence" eval="10"/>
</record>
</data>
<data grouped="1">
<record id="iva_sop_intracomunitario_1_normal" model="account.tax.template">
<field name="name">IVA Intracomunitario. Bienes (1)</field>
<field name="description">IVA Intracomunitario (1)</field>
@@ -504,8 +505,6 @@ this repository contains the full copyright notices and license terms. -->
<field name="invoice_account" ref="pgc_477_normal"/>
<field name="credit_note_account" ref="pgc_477_normal"/>
</record>
</data>
<data>
<record id="vat_code_iva_normal" model="account.tax.code.template">
<field name="name">Impuesto sobre el Valor Añadido - Autoliquidación</field>
<field name="code">AEAT303</field>
@@ -1864,8 +1863,6 @@ this repository contains the full copyright notices and license terms. -->
<field name="amount">tax</field>
<field name="type">credit</field>
</record>
</data>
<data grouped="1">
<record id="fp_recargo_normal" model="account.tax.rule.template">
<field name="name">Recargo de Equivalencia</field>
<field name="account" ref="pgc_0_normal"/>
@@ -1931,8 +1928,6 @@ this repository contains the full copyright notices and license terms. -->
<field name="account" ref="pgc_0_normal"/>
<field name="kind">purchase</field>
</record>
</data>
<data grouped="1">
<record id="fptt_recargo_4_2_normal" model="account.tax.rule.line.template">
<field name="rule" ref="fp_recargo_normal"/>
<field name="origin_tax" ref="iva_rep_4_normal"/>
+4 -9
View File
@@ -2,7 +2,7 @@
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
this repository contains the full copyright notices and license terms. -->
<tryton>
<data grouped="1">
<data>
<record id="iva_rep_21_pyme" model="account.tax.template">
<field name="name">IVA 21% (bienes)</field>
<field name="description">IVA 21%</field>
@@ -87,6 +87,7 @@ this repository contains the full copyright notices and license terms. -->
<field name="rate" eval="Decimal('0.052')"/>
<field name="invoice_account" ref="pgc_477_pyme"/>
<field name="credit_note_account" ref="pgc_477_pyme"/>
<field name="es_reported_with" ref="iva_rep_21_pyme"/>
</record>
<record id="iva_rep_re_14_pyme" model="account.tax.template">
<field name="name">Recargo Equivalencia 1.4%</field>
@@ -97,6 +98,7 @@ this repository contains the full copyright notices and license terms. -->
<field name="rate" eval="Decimal('0.014')"/>
<field name="invoice_account" ref="pgc_477_pyme"/>
<field name="credit_note_account" ref="pgc_477_pyme"/>
<field name="es_reported_with" ref="iva_rep_10_pyme"/>
</record>
<record id="iva_rep_re_05_pyme" model="account.tax.template">
<field name="name">Recargo Equivalencia 0.5%</field>
@@ -107,6 +109,7 @@ this repository contains the full copyright notices and license terms. -->
<field name="rate" eval="Decimal('0.005')"/>
<field name="invoice_account" ref="pgc_477_pyme"/>
<field name="credit_note_account" ref="pgc_477_pyme"/>
<field name="es_reported_with" ref="iva_rep_4_pyme"/>
</record>
<record id="iva_rep_exportaciones_pyme" model="account.tax.template">
<field name="name">IVA Exportaciones (bienes)</field>
@@ -433,8 +436,6 @@ this repository contains the full copyright notices and license terms. -->
<field name="update_unit_price" eval="True"/>
<field name="sequence" eval="10"/>
</record>
</data>
<data grouped="1">
<record id="iva_sop_intracomunitario_1_pyme" model="account.tax.template">
<field name="name">IVA Intracomunitario. Bienes (1)</field>
<field name="description">IVA Intracomunitario (1)</field>
@@ -504,8 +505,6 @@ this repository contains the full copyright notices and license terms. -->
<field name="invoice_account" ref="pgc_477_pyme"/>
<field name="credit_note_account" ref="pgc_477_pyme"/>
</record>
</data>
<data>
<record id="vat_code_iva_pyme" model="account.tax.code.template">
<field name="name">Impuesto sobre el Valor Añadido - Autoliquidación</field>
<field name="code">AEAT303</field>
@@ -1864,8 +1863,6 @@ this repository contains the full copyright notices and license terms. -->
<field name="amount">tax</field>
<field name="type">credit</field>
</record>
</data>
<data grouped="1">
<record id="fp_recargo_pyme" model="account.tax.rule.template">
<field name="name">Recargo de Equivalencia</field>
<field name="account" ref="pgc_0_pyme"/>
@@ -1931,8 +1928,6 @@ this repository contains the full copyright notices and license terms. -->
<field name="account" ref="pgc_0_pyme"/>
<field name="kind">purchase</field>
</record>
</data>
<data grouped="1">
<record id="fptt_recargo_4_2_pyme" model="account.tax.rule.line.template">
<field name="rule" ref="fp_recargo_pyme"/>
<field name="origin_tax" ref="iva_rep_4_pyme"/>
+3 -1
View File
@@ -3,9 +3,11 @@
this repository contains the full copyright notices and license terms. -->
<data>
<xpath expr="/form/notebook" position="inside">
<page id="es_vat_list" string="Spanish VAT List">
<page id="es_vat" string="Spanish VAT">
<label name="es_vat_list_code"/>
<field name="es_vat_list_code"/>
<label name="es_reported_with"/>
<field name="es_reported_with"/>
</page>
</xpath>
<xpath expr="/form//field[@name='ec_sales_list_code']" position="after">
+3 -1
View File
@@ -3,9 +3,11 @@
this repository contains the full copyright notices and license terms. -->
<data>
<xpath expr="/form/notebook" position="inside">
<page id="es_vat_list" string="Spanish VAT List">
<page id="es_vat" string="Spanish VAT">
<label name="es_vat_list_code"/>
<field name="es_vat_list_code"/>
<label name="es_reported_with"/>
<field name="es_reported_with"/>
</page>
</xpath>
<xpath expr="/form//field[@name='ec_sales_list_code']" position="after">