[IMP] l10n_es, l10n_es_edi_sii: add DUA taxes + some cleanout of taxes
We have 2 different invoices for importation: The trasitoria from let's say the customs (through the transport company) and the importation invoice coming from the vendor. For SII and the register, nothing needs to be sent for the importation, but for the trasitoria we also need to register the base amount from the viewpoint of the customs. That is why we added a tax that is actually a group of taxes composed of undoing the base amount and adding the tax, so the line will just have the tax amount, but we are still informed about its base. We also added the products with those taxes by default, so the user can easily encode the trasitoria that way. By default the extra-community fiscal position will not map to import taxes anymore, but to nothing and the We also updated some other taxes: - The term included was put in the csv, while the tax is not, so we just removed it - We split the exempt taxes, so the user has the different cases by default. - The Exempt not subject case, handled a total corner case, so we added a new tax to handle the case of Exempt Non Deductible - Modify tax grid for account_tax_template_s_iva_e to mod303[120] We also changed the name of the fiscal position Reglas de Localizacion (TAI) as it has nothing to do with Canary Islands in itself, but with services/goods. opw-3395186 closes odoo/odoo#139514 Signed-off-by: William André (wan) <wan@odoo.com>
This commit is contained in:
@@ -29,6 +29,7 @@ Spanish charts of accounts (PGCE 2008).
|
||||
'data/res_partner_data.xml',
|
||||
'views/account_move_views.xml',
|
||||
'views/account_tax_views.xml',
|
||||
'data/product_data.xml',
|
||||
'views/report_invoice.xml',
|
||||
'data/mod111.xml',
|
||||
'data/mod115.xml',
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<record id="product_dua_valuation_21" model="product.product">
|
||||
<field name="name">DUA VAT Valuation 21%</field>
|
||||
<field name="default_code">DUA21</field>
|
||||
<field name="categ_id" ref="product.product_category_all"/>
|
||||
<field name="type">service</field>
|
||||
<field name="sale_ok" eval="False"/>
|
||||
<field name="purchase_ok" eval="True"/>
|
||||
</record>
|
||||
<record id="product_dua_valuation_10" model="product.product">
|
||||
<field name="name">DUA VAT Valuation 10%</field>
|
||||
<field name="default_code">DUA10</field>
|
||||
<field name="categ_id" ref="product.product_category_all"/>
|
||||
<field name="type">service</field>
|
||||
<field name="sale_ok" eval="False"/>
|
||||
<field name="purchase_ok" eval="True"/>
|
||||
</record>
|
||||
<record id="product_dua_valuation_4" model="product.product">
|
||||
<field name="name">DUA VAT Valuation 4%</field>
|
||||
<field name="default_code">DUA4</field>
|
||||
<field name="categ_id" ref="product.product_category_all"/>
|
||||
<field name="type">service</field>
|
||||
<field name="sale_ok" eval="False"/>
|
||||
<field name="purchase_ok" eval="True"/>
|
||||
</record>
|
||||
</odoo>
|
||||
@@ -33,15 +33,15 @@
|
||||
"","","","","","","","","","","account_common_7050","account_common_7051"
|
||||
"fp_extra","4","Extra-community","Régimen Extracomunitario","1","","","","account_tax_template_p_iva0_s_bc","account_tax_template_p_iva0_ibc","",""
|
||||
"","","","","","","","","account_tax_template_p_iva0_s_sc","account_tax_template_p_iva0_isc","",""
|
||||
"","","","","","","","","account_tax_template_p_iva4_bc","account_tax_template_p_iva4_ibc","",""
|
||||
"","","","","","","","","account_tax_template_p_iva4_bc","","",""
|
||||
"","","","","","","","","account_tax_template_p_iva4_sc","account_tax_template_p_iva4_sp_ex","",""
|
||||
"","","","","","","","","account_tax_template_p_iva4_bi","account_tax_template_p_iva4_ibi","",""
|
||||
"","","","","","","","","account_tax_template_p_iva5_bc","account_tax_template_p_iva5_ibc","",""
|
||||
"","","","","","","","","account_tax_template_p_iva5_bc","","",""
|
||||
"","","","","","","","","account_tax_template_p_iva5_sc","account_tax_template_p_iva5_isc","",""
|
||||
"","","","","","","","","account_tax_template_p_iva10_bc","account_tax_template_p_iva10_ibc","",""
|
||||
"","","","","","","","","account_tax_template_p_iva10_bc","","",""
|
||||
"","","","","","","","","account_tax_template_p_iva10_sc","account_tax_template_p_iva10_sp_ex","",""
|
||||
"","","","","","","","","account_tax_template_p_iva10_bi","account_tax_template_p_iva10_ibi","",""
|
||||
"","","","","","","","","account_tax_template_p_iva21_bc","account_tax_template_p_iva21_ibc","",""
|
||||
"","","","","","","","","account_tax_template_p_iva21_bc","","",""
|
||||
"","","","","","","","","account_tax_template_p_iva21_sc","account_tax_template_p_iva21_sp_ex","",""
|
||||
"","","","","","","","","account_tax_template_p_iva21_bi","account_tax_template_p_iva21_ibi","",""
|
||||
"","","","","","","","","account_tax_template_s_iva0b","account_tax_template_s_iva0_e","",""
|
||||
@@ -61,7 +61,7 @@
|
||||
"","","","","","","","","","","account_common_7030","account_common_7032"
|
||||
"","","","","","","","","","","account_common_7040","account_common_7042"
|
||||
"","","","","","","","","","","account_common_7050","account_common_7052"
|
||||
"fp_not_subject_tai","","Regime not subject to localition rules (TAI, Canarias, ...)","Régimen No sujeto por reglas de localización (TAI - Canarias, Ceuta, Melilla...)","","","","","account_tax_template_p_iva4_bc","account_tax_template_p_iva0_ns_b","",""
|
||||
"fp_not_subject_tai","","Regime not subject to localization rules","Régimen No sujeto por reglas de localización","","","","","account_tax_template_p_iva4_bc","account_tax_template_p_iva0_ns_b","",""
|
||||
"","","","","","","","","account_tax_template_p_iva4_sc","account_tax_template_p_iva0_ns","",""
|
||||
"","","","","","","","","account_tax_template_p_iva4_bi","account_tax_template_p_iva0_ns_b","",""
|
||||
"","","","","","","","","account_tax_template_p_iva10_bc","account_tax_template_p_iva0_ns_b","",""
|
||||
@@ -659,3 +659,6 @@
|
||||
"","","","","","","","","account_tax_template_p_iva0_s_bc","account_tax_template_p_irpf2","",""
|
||||
"fp_reagyp_gp","","REAGYP - animal breeding and fishing","REAGYP - Ganadería y pesca","","","","","account_tax_template_p_iva4_bc","account_tax_template_p_iva105_gan","",""
|
||||
"","","","","","","","","account_tax_template_p_iva4_bc","account_tax_template_p_irpf2","",""
|
||||
"fp_dua","","DUA","DUA","","","","","account_tax_template_p_iva4_bc","account_tax_template_p_iva4_ibc_group","",""
|
||||
"","","","","","","","","account_tax_template_p_iva10_bc","account_tax_template_p_iva10_ibc_group","",""
|
||||
"","","","","","","","","account_tax_template_p_iva21_bc","account_tax_template_p_iva21_ibc_group","",""
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -23,3 +23,4 @@
|
||||
"tax_group_retenciones_24","Withholding 24%","Retenciones 24%","base.es"
|
||||
"tax_group_iva_10-5","VAT 10,5% REAGYP","IVA 10,5% REAGYP","base.es"
|
||||
"tax_group_iva_nd","VAT exempt","IVA no deducible","base.es"
|
||||
"tax_group_no_base","Subtract Base Amount","Resta Base","base.es"
|
||||
|
||||
|
@@ -28,6 +28,7 @@ class AccountTax(models.Model):
|
||||
('no_deducible', 'No Deducible'),
|
||||
('retencion', 'Retencion'),
|
||||
('recargo', 'Recargo de Equivalencia'),
|
||||
('dua', 'DUA'),
|
||||
('ignore', 'Ignore even the base amount'),
|
||||
],
|
||||
string="Tax Type (Spain)", default='sujeto'
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
from odoo import models, _
|
||||
from odoo import models, _, Command
|
||||
from odoo.addons.account.models.chart_template import template
|
||||
|
||||
|
||||
@@ -41,3 +41,11 @@ class AccountChartTemplate(models.AbstractModel):
|
||||
'account_purchase_tax_id': 'account_tax_template_p_iva21_bc',
|
||||
},
|
||||
}
|
||||
|
||||
@template('es_common', model='product.product')
|
||||
def _get_product(self):
|
||||
return {
|
||||
'l10n_es.product_dua_valuation_4': {'supplier_taxes_id': [Command.set(['account_tax_template_p_iva4_ibc_group'])]},
|
||||
'l10n_es.product_dua_valuation_10': {'supplier_taxes_id': [Command.set(['account_tax_template_p_iva10_ibc_group'])]},
|
||||
'l10n_es.product_dua_valuation_21': {'supplier_taxes_id': [Command.set(['account_tax_template_p_iva21_ibc_group'])]},
|
||||
}
|
||||
|
||||
@@ -1,14 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
from . import models
|
||||
|
||||
|
||||
def _l10n_es_edi_post_init(env):
|
||||
for company in env['res.company'].search([('partner_id.country_id.code', '=', 'ES')]):
|
||||
if not (company.chart_template and company.chart_template.startswith('es_')):
|
||||
# only attempt to update tax definitions for companies where a spanish CoA
|
||||
# is already installed
|
||||
continue
|
||||
ChartTemplate = env['account.chart.template'].with_company(company)
|
||||
taxes_data = ChartTemplate._get_es_edi_sii_account_tax()
|
||||
ChartTemplate._load_data({'account.tax': taxes_data})
|
||||
|
||||
@@ -43,6 +43,5 @@ You need to configure your certificate and the tax agency.
|
||||
'external_dependencies': {
|
||||
'python': ['pyOpenSSL'],
|
||||
},
|
||||
'post_init_hook': '_l10n_es_edi_post_init',
|
||||
'license': 'LGPL-3',
|
||||
}
|
||||
|
||||
@@ -1,94 +0,0 @@
|
||||
"id","name","description","invoice_label","l10n_es_type","l10n_es_bien_inversion","l10n_es_exempt_reason","tax_scope"
|
||||
"account_tax_template_s_iva21b","","","","sujeto","","","consu"
|
||||
"account_tax_template_s_iva21s","","","","sujeto","","","service"
|
||||
"account_tax_template_s_iva21isp","","","","sujeto","","",""
|
||||
"account_tax_template_p_iva21_bc","21% IVA soportado (bienes corrientes)","","","sujeto","","","consu"
|
||||
"account_tax_template_p_iva21_sc","21% IVA soportado (servicios corrientes)","","","sujeto","","","service"
|
||||
"account_tax_template_p_iva21_sp_in","IVA 21% Adquisición de servicios intracomunitarios","","","sujeto","","","service"
|
||||
"account_tax_template_p_iva21_ic_bc","IVA 21% Adquisición Intracomunitaria. Bienes corrientes","","","sujeto","","","consu"
|
||||
"account_tax_template_p_iva21_ic_bi","IVA 21% Adquisición Intracomunitaria. Bienes de inversión","","","sujeto","","","consu"
|
||||
"account_tax_template_p_iva21_ibc","IVA 21% Importaciones bienes corrientes","","","sujeto","","","consu"
|
||||
"account_tax_template_p_iva21_ibi","IVA 21% Importaciones bienes de inversión","","","sujeto","","","consu"
|
||||
"account_tax_template_p_irpf21td","Retenciones IRPF (Trabajadores) dinerarios","","","retencion","","",""
|
||||
"account_tax_template_p_iva4_sp_ex","IVA 4% Adquisición de servicios extracomunitarios","","","sujeto_isp","","","consu"
|
||||
"account_tax_template_p_iva10_sp_ex","IVA 10% Adquisición de servicios extracomunitarios","","","sujeto_isp","","","consu"
|
||||
"account_tax_template_p_iva21_sp_ex","IVA 21% Adquisición de servicios extracomunitarios","","","sujeto_isp","","","service"
|
||||
"account_tax_template_p_iva4_ic_bc","IVA 4% Adquisición Intracomunitario. Bienes corrientes","","","sujeto","","","consu"
|
||||
"account_tax_template_p_iva4_ic_bi","IVA 4% Adquisición Intracomunitario. Bienes de inversión","","","sujeto","","","consu"
|
||||
"account_tax_template_p_iva10_ic_bc","IVA 10% Adquisición Intracomunitario. Bienes corrientes","","","sujeto","","","consu"
|
||||
"account_tax_template_p_iva10_ic_bi","IVA 10% Adquisición Intracomunitario. Bienes de inversión","","","sujeto","","","consu"
|
||||
"account_tax_template_s_iva0_sp_i","IVA 0% Prestación de servicios intracomunitario","","","no_sujeto","","","service"
|
||||
"account_tax_template_s_iva_ns","No sujeto Repercutido (Servicios)","","","no_sujeto","","","service"
|
||||
"account_tax_template_s_iva_ns_b","No sujeto Repercutido (Bienes)","","","no_sujeto","","","consu"
|
||||
"account_tax_template_s_iva_e","IVA 0% Prestación de servicios extracomunitaria","","","no_sujeto_loc","","","service"
|
||||
"account_tax_template_p_iva4_ibc","IVA 4% Importaciones bienes corrientes","","","sujeto","","","consu"
|
||||
"account_tax_template_p_iva4_ibi","IVA 4% Importaciones bienes de inversión","","","sujeto","","","consu"
|
||||
"account_tax_template_p_iva10_ibc","IVA 10% Importaciones bienes corrientes","","","sujeto","","","consu"
|
||||
"account_tax_template_p_iva10_ibi","IVA 10% Importaciones bienes de inversión","","","sujeto","","","consu"
|
||||
"account_tax_template_p_iva4_bi","4% IVA Soportado (bienes de inversión)","","","sujeto","True","","consu"
|
||||
"account_tax_template_p_iva4_sc","4% IVA soportado (servicios corrientes)","","","sujeto","","","consu"
|
||||
"account_tax_template_p_iva10_bi","10% IVA Soportado (bienes de inversión)","","","sujeto","True","","consu"
|
||||
"account_tax_template_p_iva21_bi","21% IVA Soportado (bienes de inversión)","","","sujeto","True","","consu"
|
||||
"account_tax_template_p_iva10_bc","10% IVA soportado (bienes corrientes)","","","sujeto","","","consu"
|
||||
"account_tax_template_p_iva4_bc","4% IVA soportado (bienes corrientes)","","","sujeto","","","consu"
|
||||
"account_tax_template_p_iva10_sc","10% IVA soportado (servicios corrientes)","","","sujeto","","","consu"
|
||||
"account_tax_template_s_iva0","IVA Exento Repercutido Sujeto","","","exento","","E1",""
|
||||
"account_tax_template_s_iva0_ns","IVA Exento Repercutido No Sujeto","","","ignore","","",""
|
||||
"account_tax_template_s_req05","0.50% Recargo Equivalencia Ventas","","","recargo","","",""
|
||||
"account_tax_template_s_iva4b","IVA 4% (Bienes)","","","sujeto","","","consu"
|
||||
"account_tax_template_s_iva10b","IVA 10% (Bienes)","","","sujeto","","","consu"
|
||||
"account_tax_template_p_iva0_nd","21% IVA Soportado no deducible","","","no_deducible","","",""
|
||||
"account_tax_template_p_iva10_nd","10% IVA Soportado no deducible","","","no_deducible","","",""
|
||||
"account_tax_template_p_iva4_nd","4% IVA Soportado no deducible","","","no_deducible","","",""
|
||||
"account_tax_template_s_iva4s","IVA 4% (Servicios)","","","sujeto","","","service"
|
||||
"account_tax_template_s_iva10s","IVA 10% (Servicios)","","","sujeto","","","service"
|
||||
"account_tax_template_s_req014","1.4% Recargo Equivalencia Ventas","","","recargo","","",""
|
||||
"account_tax_template_s_req52","5.2% Recargo Equivalencia Ventas","","","recargo","","",""
|
||||
"account_tax_template_p_iva0_bc","IVA Soportado exento (operaciones corrientes)","","","sujeto","","","consu"
|
||||
"account_tax_template_p_iva0_ns","IVA Soportado no sujeto (Servicios)","","","no_sujeto","","","service"
|
||||
"account_tax_template_p_iva0_ns_b","IVA Soportado no sujeto (Bienes)","","","no_sujeto","","","consu"
|
||||
"account_tax_template_s_irpf9","Retenciones a cuenta IRPF 9%","","","retencion","","",""
|
||||
"account_tax_template_s_irpf18","Retenciones a cuenta IRPF 18%","","","retencion","","",""
|
||||
"account_tax_template_s_irpf19","Retenciones a cuenta IRPF 19%","","","retencion","","",""
|
||||
"account_tax_template_s_irpf19a","Retenciones a cuenta 19% (Arrendamientos)","","","retencion","","",""
|
||||
"account_tax_template_s_irpf195a","Retenciones a cuenta 19,5% (Arrendamientos)","","","retencion","","",""
|
||||
"account_tax_template_p_irpf19","Retenciones IRPF 19%","","","retencion","","",""
|
||||
"account_tax_template_p_irpf20a","Retenciones 20% (Arrendamientos)","","","retencion","","",""
|
||||
"account_tax_template_p_irpf18","Retenciones IRPF 18%","","","retencion","","",""
|
||||
"account_tax_template_p_irpf19a","Retenciones 19% (Arrendamientos)","","","retencion","","",""
|
||||
"account_tax_template_p_irpf195a","Retenciones 19,5% (Arrendamientos)","","","retencion","","",""
|
||||
"account_tax_template_p_irpf7","Retenciones IRPF 7%","","","retencion","","",""
|
||||
"account_tax_template_p_irpf9","Retenciones IRPF 9%","","","retencion","","",""
|
||||
"account_tax_template_p_irpf24","Retenciones IRPF 14%","","","retencion","","",""
|
||||
"account_tax_template_s_irpf20","Retenciones a cuenta IRPF 20%","","","retencion","","",""
|
||||
"account_tax_template_s_irpf20a","Retenciones a cuenta 20% (Arrendamientos)","","","retencion","","",""
|
||||
"account_tax_template_s_irpf24","Retenciones a cuenta IRPF 24%","","","retencion","","",""
|
||||
"account_tax_template_p_iva12_agr","12% IVA Soportado régimen agricultura","","","sujeto_agricultura","","",""
|
||||
"account_tax_template_p_iva105_gan","10,5% IVA Soportado régimen ganadero o pesca","","","","","",""
|
||||
"account_tax_template_s_iva0_e","IVA 0% Exportaciones","","","exento","","E2","consu"
|
||||
"account_tax_template_s_iva0_ic","IVA 0% Entregas Intracomunitarias exentas","","","exento","","E5","consu"
|
||||
"account_tax_template_p_req014","1.4% Recargo Equivalencia Compras","","","recargo","","",""
|
||||
"account_tax_template_p_req05","0.50% Recargo Equivalencia Compras","","","recargo","","",""
|
||||
"account_tax_template_p_req52","5.2% Recargo Equivalencia Compras","","","recargo","","",""
|
||||
"account_tax_template_s_irpf1","Retenciones a cuenta IRPF 1%","","","retencion","","",""
|
||||
"account_tax_template_s_irpf2","Retenciones a cuenta IRPF 2%","","","retencion","","",""
|
||||
"account_tax_template_s_irpf21","Retenciones a cuenta IRPF 21%","","","retencion","","",""
|
||||
"account_tax_template_s_irpf21a","Retenciones a cuenta 21% (Arrendamientos)","","","retencion","","",""
|
||||
"account_tax_template_s_irpf7","Retenciones a cuenta IRPF 7%","","","retencion","","",""
|
||||
"account_tax_template_s_irpf15","Retenciones a cuenta IRPF 15%","","","retencion","","",""
|
||||
"account_tax_template_p_irpf1","Retenciones IRPF 1%","","","retencion","","",""
|
||||
"account_tax_template_p_irpf15","Retenciones IRPF 15%","","","retencion","","",""
|
||||
"account_tax_template_p_irpf21t","Retenciones IRPF (Trabajadores)","","","retencion","","",""
|
||||
"account_tax_template_p_iva10_sp_in","IVA 10% Adquisición de servicios intracomunitarios","","","retencion","","",""
|
||||
"account_tax_template_p_iva4_sp_in","IVA 4% Adquisición de servicios intracomunitarios","","","retencion","","",""
|
||||
"account_tax_template_p_irpf21te","Retenciones IRPF (Trabajadores) en especie","","","retencion","","",""
|
||||
"account_tax_template_p_irpf20","Retenciones IRPF 20%","","","retencion","","",""
|
||||
"account_tax_template_p_irpf21a","Retenciones 21% (Arrendamientos)","","","retencion","","",""
|
||||
"account_tax_template_p_irpf21p","Retenciones IRPF 21%","","","retencion","","",""
|
||||
"account_tax_template_p_irpf2","Retenciones IRPF 2%","","","retencion","","",""
|
||||
"account_tax_template_s_iva0_isp","IVA 0% Venta con Inversión del Sujeto Pasivo","","","sujeto_isp","","",""
|
||||
"account_tax_template_p_iva4_isp","IVA 4% Compra con Inversión del Sujeto Pasivo Nacional","","","sujeto_isp","","",""
|
||||
"account_tax_template_p_iva10_isp","IVA 10% Compra con Inversión del Sujeto Pasivo Nacional","","","sujeto_isp","","",""
|
||||
"account_tax_template_p_iva21_isp","IVA 21% Compra con Inversión del Sujeto Pasivo Nacional","","","sujeto_isp","","",""
|
||||
"account_tax_template_p_rp19","Retenciones 19% (préstamos)","","","retencion","","",""
|
||||
"account_tax_template_p_rrD19","Retenciones 19% (reparto de dividendos)","","","retencion","","",""
|
||||
|
@@ -2,7 +2,6 @@
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
from . import account_edi_format
|
||||
from . import account_move
|
||||
from . import account_chart_template
|
||||
from . import l10n_es_edi_certificate
|
||||
from . import res_company
|
||||
from . import res_config_settings
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
from odoo import models
|
||||
from odoo.addons.account.models.chart_template import template
|
||||
|
||||
class AccountChartTemplate(models.AbstractModel):
|
||||
_inherit = 'account.chart.template'
|
||||
|
||||
@template('es_common', 'account.tax')
|
||||
def _get_es_edi_sii_account_tax(self):
|
||||
return self._parse_csv('es_common', 'account.tax', module='l10n_es_edi_sii')
|
||||
@@ -78,10 +78,12 @@ class AccountEdiFormat(models.Model):
|
||||
|
||||
def filter_to_apply(base_line, tax_values):
|
||||
# For intra-community, we do not take into account the negative repartition line
|
||||
return tax_values['tax_repartition_line'].factor_percent > 0.0
|
||||
return (tax_values['tax_repartition_line'].factor_percent > 0.0
|
||||
and tax_values['tax_repartition_line'].tax_id.amount != -100.0
|
||||
and tax_values['tax_repartition_line'].tax_id.l10n_es_type != 'ignore')
|
||||
|
||||
def full_filter_invl_to_apply(invoice_line):
|
||||
if 'ignore' in invoice_line.tax_ids.flatten_taxes_hierarchy().mapped('l10n_es_type'):
|
||||
if all(t == 'ignore' for t in invoice_line.tax_ids.flatten_taxes_hierarchy().mapped('l10n_es_type')):
|
||||
return False
|
||||
return filter_invl_to_apply(invoice_line) if filter_invl_to_apply else True
|
||||
|
||||
@@ -119,7 +121,6 @@ class AccountEdiFormat(models.Model):
|
||||
tax_subject_info_list = []
|
||||
tax_subject_isp_info_list = []
|
||||
for tax_values in tax_details['tax_details'].values():
|
||||
|
||||
if invoice.is_sale_document():
|
||||
# Customer invoices
|
||||
|
||||
@@ -160,7 +161,7 @@ class AccountEdiFormat(models.Model):
|
||||
|
||||
else:
|
||||
# Vendor bills
|
||||
if tax_values['l10n_es_type'] in ('sujeto', 'sujeto_isp', 'no_sujeto', 'no_sujeto_loc'):
|
||||
if tax_values['l10n_es_type'] in ('sujeto', 'sujeto_isp', 'no_sujeto', 'no_sujeto_loc', 'dua'):
|
||||
tax_amount_deductible += tax_values['tax_amount']
|
||||
elif tax_values['l10n_es_type'] == 'retencion':
|
||||
tax_amount_retention += tax_values['tax_amount']
|
||||
@@ -287,6 +288,8 @@ class AccountEdiFormat(models.Model):
|
||||
export_exempts = invoice.invoice_line_ids.tax_ids.filtered(lambda t: t.l10n_es_exempt_reason == 'E2')
|
||||
invoice_node['ClaveRegimenEspecialOTrascendencia'] = '02' if export_exempts else '01'
|
||||
else:
|
||||
if invoice._l10n_es_is_dua():
|
||||
partner_info = self._l10n_es_edi_get_partner_info(invoice.company_id.partner_id)
|
||||
info['IDFactura']['IDEmisorFactura'] = partner_info
|
||||
info['IDFactura']['NumSerieFacturaEmisor'] = invoice.ref[:60]
|
||||
if not is_simplified:
|
||||
@@ -313,6 +316,8 @@ class AccountEdiFormat(models.Model):
|
||||
invoice_node['TipoRectificativa'] = 'I'
|
||||
elif invoice.move_type == 'in_invoice':
|
||||
invoice_node['TipoFactura'] = 'F1'
|
||||
if invoice._l10n_es_is_dua():
|
||||
invoice_node['TipoFactura'] = 'F5'
|
||||
elif invoice.move_type == 'in_refund':
|
||||
invoice_node['TipoFactura'] = 'R4'
|
||||
invoice_node['TipoRectificativa'] = 'I'
|
||||
@@ -392,7 +397,6 @@ class AccountEdiFormat(models.Model):
|
||||
+ tax_details_info_other_vals['tax_details']['tax_amount']
|
||||
- tax_details_info_other_vals['tax_amount_retention']
|
||||
), 2)
|
||||
|
||||
invoice_node['CuotaDeducible'] = round(sign * (
|
||||
tax_details_info_isp_vals['tax_amount_deductible']
|
||||
+ tax_details_info_other_vals['tax_amount_deductible']
|
||||
@@ -530,11 +534,14 @@ class AccountEdiFormat(models.Model):
|
||||
else:
|
||||
# 'ref' can be the same for different partners.
|
||||
candidates = invoices.filtered(lambda x: x.ref[:60] == invoice_number)
|
||||
if len(candidates) >= 1:
|
||||
if len(candidates) > 1:
|
||||
respl_partner_info = respl.IDFactura.IDEmisorFactura
|
||||
inv = None
|
||||
for candidate in candidates:
|
||||
partner_info = self._l10n_es_edi_get_partner_info(candidate.commercial_partner_id)
|
||||
partner = candidate.commercial_partner_id
|
||||
if candidate._l10n_es_is_dua():
|
||||
partner = candidate.company_id.partner_id
|
||||
partner_info = self._l10n_es_edi_get_partner_info(partner)
|
||||
if partner_info.get('NIF') and partner_info['NIF'] == respl_partner_info.NIF:
|
||||
inv = candidate
|
||||
break
|
||||
|
||||
@@ -22,15 +22,25 @@ class AccountMove(models.Model):
|
||||
# COMPUTE METHODS
|
||||
# -------------------------------------------------------------------------
|
||||
|
||||
@api.depends('move_type', 'company_id')
|
||||
@api.depends('move_type', 'company_id', 'invoice_line_ids.tax_ids')
|
||||
def _compute_l10n_es_edi_is_required(self):
|
||||
for move in self:
|
||||
has_tax = True
|
||||
# Check it is not an importation invoice (which will be report through the DUA invoice)
|
||||
if move.is_purchase_document():
|
||||
taxes = move.invoice_line_ids.tax_ids
|
||||
has_tax = any(t.l10n_es_type and t.l10n_es_type != 'ignore' for t in taxes)
|
||||
move.l10n_es_edi_is_required = move.is_invoice() \
|
||||
and move.country_code == 'ES' \
|
||||
and move.company_id.l10n_es_edi_tax_agency
|
||||
and move.company_id.l10n_es_edi_tax_agency \
|
||||
and has_tax
|
||||
|
||||
@api.depends('l10n_es_edi_is_required')
|
||||
def _compute_edi_show_cancel_button(self):
|
||||
super()._compute_edi_show_cancel_button()
|
||||
for move in self.filtered('l10n_es_edi_is_required'):
|
||||
move.edi_show_cancel_button = False
|
||||
|
||||
def _l10n_es_is_dua(self):
|
||||
self.ensure_one()
|
||||
return any(t.l10n_es_type == 'dua' for t in self.invoice_line_ids.tax_ids.flatten_taxes_hierarchy())
|
||||
|
||||
@@ -1056,3 +1056,48 @@ class TestEdiXmls(TestEsEdiCommon):
|
||||
},
|
||||
'PeriodoLiquidacion': {'Periodo': '01', 'Ejercicio': '2019'},
|
||||
})
|
||||
|
||||
def test_170_in_invoice_dua(self):
|
||||
with freeze_time(self.frozen_today), patch(
|
||||
'odoo.addons.l10n_es_edi_sii.models.account_edi_format.AccountEdiFormat._l10n_es_edi_call_web_service_sign',
|
||||
new=mocked_l10n_es_edi_call_web_service_sign
|
||||
):
|
||||
invoice = self.create_invoice(
|
||||
move_type='in_invoice',
|
||||
ref='fakedua',
|
||||
partner_id=self.partner_b.id,
|
||||
currency_id=self.currency_data['currency'].id,
|
||||
l10n_es_registration_date='2019-01-02',
|
||||
invoice_line_ids=[
|
||||
{
|
||||
'tax_ids': [(6, 0, (self._get_tax_by_xml_id('p_iva21_ibc_group').ids))],
|
||||
},
|
||||
],
|
||||
)
|
||||
invoice.action_post()
|
||||
|
||||
generated_files = self._process_documents_web_services(invoice, {'es_sii'})
|
||||
self.assertTrue(generated_files)
|
||||
|
||||
json_file = json.loads(generated_files[0].decode())[0]
|
||||
self.assertEqual(json_file, {
|
||||
'PeriodoLiquidacion': {'Ejercicio': '2019', 'Periodo': '01'},
|
||||
'IDFactura': {
|
||||
'FechaExpedicionFacturaEmisor': '01-01-2019',
|
||||
'IDEmisorFactura': {'NIF': '59962470K'},
|
||||
'NumSerieFacturaEmisor': 'fakedua'
|
||||
},
|
||||
'FacturaRecibida': {
|
||||
'DescripcionOperacion': 'manual',
|
||||
'Contraparte': {'NIF': '59962470K', 'NombreRazon': 'partner_b'},
|
||||
'FechaRegContable': '02-01-2019',
|
||||
'ClaveRegimenEspecialOTrascendencia': '01',
|
||||
'TipoFactura': 'F5',
|
||||
'DesgloseFactura': {
|
||||
'DesgloseIVA': {
|
||||
'DetalleIVA': [{'BaseImponible': 500.0, 'TipoImpositivo': 21.0, 'CuotaSoportada': 105.0}]
|
||||
}
|
||||
},
|
||||
'ImporteTotal': 605.0,
|
||||
'CuotaDeducible': 105.0
|
||||
}})
|
||||
|
||||
Reference in New Issue
Block a user