From 94ce154dbacef7e53c0f88784b09fd4cde1528b0 Mon Sep 17 00:00:00 2001 From: David Ramia Date: Tue, 5 Jul 2022 19:52:34 +0200 Subject: [PATCH] =?UTF-8?q?[IMP]=20l10n=5Fes=5Faeat=5Fsii=5Finvoice=5Fsumm?= =?UTF-8?q?ary:=20a=C3=B1adir=20rectificativas=20y=20tests?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- l10n_es_aeat_sii_invoice_summary/i18n/es.po | 34 +-- .../i18n/l10n_es_aeat_sii_invoice_summary.pot | 30 +- .../models/account_move.py | 55 ++-- .../tests/__init__.py | 1 + ...ut_invoice_s_iva0_sp_i_s_iva0_ic_dict.json | 41 +++ ...voice_s_iva0_sp_i_s_iva0_ic_same_dict.json | 40 +++ .../json/sii_out_invoice_s_iva10b_dict.json | 38 +++ ...sii_out_invoice_s_iva10b_s_irpf1_dict.json | 38 +++ ...ut_invoice_s_iva10b_s_irpf1_same_dict.json | 37 +++ ...i_out_invoice_s_iva10b_s_iva0_ns_dict.json | 52 ++++ ..._invoice_s_iva10b_s_iva0_ns_same_dict.json | 51 ++++ ...ii_out_invoice_s_iva10b_s_iva21s_dict.json | 56 ++++ ...t_invoice_s_iva10b_s_iva21s_same_dict.json | 55 ++++ ...iva10b_s_req014_s_iva21s_s_req52_dict.json | 60 ++++ ...b_s_req014_s_iva21s_s_req52_same_dict.json | 59 ++++ .../sii_out_invoice_s_iva10b_same_dict.json | 37 +++ ...sii_out_invoice_s_iva_e_s_iva0_e_dict.json | 41 +++ ...ut_invoice_s_iva_e_s_iva0_e_same_dict.json | 40 +++ ...out_refund_s_iva0_sp_i_s_iva0_ic_dict.json | 41 +++ ...efund_s_iva0_sp_i_s_iva0_ic_same_dict.json | 45 +++ ...efund_s_iva10b_s_iva10b_s_iva21s_dict.json | 56 ++++ ..._s_iva10b_s_iva10b_s_iva21s_same_dict.json | 60 ++++ .../sii_out_refund_s_iva_e_s_iva0_e_dict.json | 41 +++ ...out_refund_s_iva_e_s_iva0_e_same_dict.json | 45 +++ .../test_l10n_es_aeat_sii_invoice_summary.py | 264 ++++++++++++++++++ 25 files changed, 1230 insertions(+), 87 deletions(-) create mode 100644 l10n_es_aeat_sii_invoice_summary/tests/__init__.py create mode 100644 l10n_es_aeat_sii_invoice_summary/tests/json/sii_out_invoice_s_iva0_sp_i_s_iva0_ic_dict.json create mode 100644 l10n_es_aeat_sii_invoice_summary/tests/json/sii_out_invoice_s_iva0_sp_i_s_iva0_ic_same_dict.json create mode 100644 l10n_es_aeat_sii_invoice_summary/tests/json/sii_out_invoice_s_iva10b_dict.json create mode 100644 l10n_es_aeat_sii_invoice_summary/tests/json/sii_out_invoice_s_iva10b_s_irpf1_dict.json create mode 100644 l10n_es_aeat_sii_invoice_summary/tests/json/sii_out_invoice_s_iva10b_s_irpf1_same_dict.json create mode 100644 l10n_es_aeat_sii_invoice_summary/tests/json/sii_out_invoice_s_iva10b_s_iva0_ns_dict.json create mode 100644 l10n_es_aeat_sii_invoice_summary/tests/json/sii_out_invoice_s_iva10b_s_iva0_ns_same_dict.json create mode 100644 l10n_es_aeat_sii_invoice_summary/tests/json/sii_out_invoice_s_iva10b_s_iva21s_dict.json create mode 100644 l10n_es_aeat_sii_invoice_summary/tests/json/sii_out_invoice_s_iva10b_s_iva21s_same_dict.json create mode 100644 l10n_es_aeat_sii_invoice_summary/tests/json/sii_out_invoice_s_iva10b_s_req014_s_iva21s_s_req52_dict.json create mode 100644 l10n_es_aeat_sii_invoice_summary/tests/json/sii_out_invoice_s_iva10b_s_req014_s_iva21s_s_req52_same_dict.json create mode 100644 l10n_es_aeat_sii_invoice_summary/tests/json/sii_out_invoice_s_iva10b_same_dict.json create mode 100644 l10n_es_aeat_sii_invoice_summary/tests/json/sii_out_invoice_s_iva_e_s_iva0_e_dict.json create mode 100644 l10n_es_aeat_sii_invoice_summary/tests/json/sii_out_invoice_s_iva_e_s_iva0_e_same_dict.json create mode 100644 l10n_es_aeat_sii_invoice_summary/tests/json/sii_out_refund_s_iva0_sp_i_s_iva0_ic_dict.json create mode 100644 l10n_es_aeat_sii_invoice_summary/tests/json/sii_out_refund_s_iva0_sp_i_s_iva0_ic_same_dict.json create mode 100644 l10n_es_aeat_sii_invoice_summary/tests/json/sii_out_refund_s_iva10b_s_iva10b_s_iva21s_dict.json create mode 100644 l10n_es_aeat_sii_invoice_summary/tests/json/sii_out_refund_s_iva10b_s_iva10b_s_iva21s_same_dict.json create mode 100644 l10n_es_aeat_sii_invoice_summary/tests/json/sii_out_refund_s_iva_e_s_iva0_e_dict.json create mode 100644 l10n_es_aeat_sii_invoice_summary/tests/json/sii_out_refund_s_iva_e_s_iva0_e_same_dict.json create mode 100644 l10n_es_aeat_sii_invoice_summary/tests/test_l10n_es_aeat_sii_invoice_summary.py diff --git a/l10n_es_aeat_sii_invoice_summary/i18n/es.po b/l10n_es_aeat_sii_invoice_summary/i18n/es.po index 2313b9542ef..4bf6720b939 100644 --- a/l10n_es_aeat_sii_invoice_summary/i18n/es.po +++ b/l10n_es_aeat_sii_invoice_summary/i18n/es.po @@ -6,8 +6,8 @@ msgid "" msgstr "" "Project-Id-Version: Odoo Server 14.0+e\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-05-26 19:46+0000\n" -"PO-Revision-Date: 2022-05-26 21:48+0200\n" +"POT-Creation-Date: 2022-06-30 05:57+0000\n" +"PO-Revision-Date: 2022-06-30 07:59+0200\n" "Last-Translator: <>\n" "Language-Team: \n" "Language: es\n" @@ -15,7 +15,7 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: \n" -"X-Generator: Poedit 3.0.1\n" +"X-Generator: Poedit 3.1\n" #. module: l10n_es_aeat_sii_invoice_summary #: model:ir.model.fields,field_description:l10n_es_aeat_sii_invoice_summary.field_account_move__display_name @@ -67,29 +67,5 @@ msgstr "El cliente no tiene un CIF/NIF configurado." #. module: l10n_es_aeat_sii_invoice_summary #: code:addons/l10n_es_aeat_sii_invoice_summary/models/account_move.py:0 #, python-format -msgid "The supplier number invoice is required" -msgstr "El nº de factura del proveedor es obligatorio" - -#. module: l10n_es_aeat_sii_invoice_summary -#: code:addons/l10n_es_aeat_sii_invoice_summary/models/account_move.py:0 -#, python-format -msgid "This company doesn't have SII enabled." -msgstr "Esta compañía no tiene el SII habilitado." - -#. module: l10n_es_aeat_sii_invoice_summary -#: code:addons/l10n_es_aeat_sii_invoice_summary/models/account_move.py:0 -#, python-format -msgid "This invoice is not SII enabled." -msgstr "Esta compañía no tiene el SII habilitado." - -#. module: l10n_es_aeat_sii_invoice_summary -#: code:addons/l10n_es_aeat_sii_invoice_summary/models/account_move.py:0 -#, python-format -msgid "You can't make a supplier simplified invoice." -msgstr "No puede realizar una factura simplificada a un proveedor." - -#. module: l10n_es_aeat_sii_invoice_summary -#: code:addons/l10n_es_aeat_sii_invoice_summary/models/account_move.py:0 -#, python-format -msgid "You have to select what account chart template use this company." -msgstr "Debe seleccionar el plan de cuentas que está utilizando esta compañía." +msgid "You can't make a supplier summary invoice." +msgstr "No puede realizar una factura resumen a un proveedor." diff --git a/l10n_es_aeat_sii_invoice_summary/i18n/l10n_es_aeat_sii_invoice_summary.pot b/l10n_es_aeat_sii_invoice_summary/i18n/l10n_es_aeat_sii_invoice_summary.pot index 80abc8b5e20..1a32a120c34 100644 --- a/l10n_es_aeat_sii_invoice_summary/i18n/l10n_es_aeat_sii_invoice_summary.pot +++ b/l10n_es_aeat_sii_invoice_summary/i18n/l10n_es_aeat_sii_invoice_summary.pot @@ -6,8 +6,8 @@ msgid "" msgstr "" "Project-Id-Version: Odoo Server 14.0+e\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-05-26 19:46+0000\n" -"PO-Revision-Date: 2022-05-26 19:46+0000\n" +"POT-Creation-Date: 2022-06-30 05:57+0000\n" +"PO-Revision-Date: 2022-06-30 05:57+0000\n" "Last-Translator: \n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -65,29 +65,5 @@ msgstr "" #. module: l10n_es_aeat_sii_invoice_summary #: code:addons/l10n_es_aeat_sii_invoice_summary/models/account_move.py:0 #, python-format -msgid "The supplier number invoice is required" -msgstr "" - -#. module: l10n_es_aeat_sii_invoice_summary -#: code:addons/l10n_es_aeat_sii_invoice_summary/models/account_move.py:0 -#, python-format -msgid "This company doesn't have SII enabled." -msgstr "" - -#. module: l10n_es_aeat_sii_invoice_summary -#: code:addons/l10n_es_aeat_sii_invoice_summary/models/account_move.py:0 -#, python-format -msgid "This invoice is not SII enabled." -msgstr "" - -#. module: l10n_es_aeat_sii_invoice_summary -#: code:addons/l10n_es_aeat_sii_invoice_summary/models/account_move.py:0 -#, python-format -msgid "You can't make a supplier simplified invoice." -msgstr "" - -#. module: l10n_es_aeat_sii_invoice_summary -#: code:addons/l10n_es_aeat_sii_invoice_summary/models/account_move.py:0 -#, python-format -msgid "You have to select what account chart template use this company." +msgid "You can't make a supplier summary invoice." msgstr "" diff --git a/l10n_es_aeat_sii_invoice_summary/models/account_move.py b/l10n_es_aeat_sii_invoice_summary/models/account_move.py index 684871bb57f..1c46b9a496d 100644 --- a/l10n_es_aeat_sii_invoice_summary/models/account_move.py +++ b/l10n_es_aeat_sii_invoice_summary/models/account_move.py @@ -14,11 +14,11 @@ class AccountMove(models.Model): def _get_sii_invoice_dict_out(self, cancel=False): inv_dict = super(AccountMove, self)._get_sii_invoice_dict_out(cancel=cancel) - if self.is_invoice_summary and self.move_type == "out_invoice": + if self.is_invoice_summary and self.move_type in ("out_invoice", "out_refund"): tipo_factura = "F4" if self.sii_invoice_summary_start: if self.sii_invoice_summary_start == self.sii_invoice_summary_end: - tipo_factura = "F2" + tipo_factura = "F2" if self.move_type == "out_invoice" else "R1" else: inv_dict["IDFactura"][ "NumSerieFacturaEmisor" @@ -29,38 +29,31 @@ def _get_sii_invoice_dict_out(self, cancel=False): if "FacturaExpedida" in inv_dict: if "TipoFactura" in inv_dict["FacturaExpedida"]: inv_dict["FacturaExpedida"]["TipoFactura"] = tipo_factura - if "Contraparte" in inv_dict["FacturaExpedida"]: + if "Contraparte" in inv_dict["FacturaExpedida"] and tipo_factura in ( + "F2", + "F4" + ): del inv_dict["FacturaExpedida"]["Contraparte"] + if ( + "TipoRectificativa" in inv_dict["FacturaExpedida"] + and tipo_factura == "F4" + ): + inv_dict["FacturaExpedida"].pop("TipoRectificativa") return inv_dict def _sii_check_exceptions(self): """Inheritable method for exceptions control when sending SII invoices.""" - self.ensure_one() - gen_type = self._get_sii_gen_type() - partner = self._sii_get_partner() - country_code = self._get_sii_country_code() - is_simplified_invoice = self._is_sii_simplified_invoice() - - if is_simplified_invoice and self.move_type[:2] == "in": - raise exceptions.UserError( - _("You can't make a supplier simplified invoice.") - ) - if ( - (gen_type != 3 or country_code == "ES") - and not partner.vat - and not is_simplified_invoice - and not self.is_invoice_summary - ): - raise exceptions.UserError(_("The partner has not a VAT configured.")) - - if not self.company_id.chart_template_id: - raise exceptions.UserError( - _("You have to select what account chart template use this" " company.") - ) - if not self.company_id.sii_enabled: - raise exceptions.UserError(_("This company doesn't have SII enabled.")) - if not self.sii_enabled: - raise exceptions.UserError(_("This invoice is not SII enabled.")) - if not self.ref and self.move_type in ["in_invoice", "in_refund"]: - raise exceptions.UserError(_("The supplier number invoice is required")) + try: + super(AccountMove, self)._sii_check_exceptions() + except exceptions.UserError as e: + if ( + e.args[0] == _("The partner has not a VAT configured.") + and self.is_invoice_summary + ): + pass + else: + raise + + if self.is_invoice_summary and self.move_type[:2] == "in": + raise exceptions.UserError(_("You can't make a supplier summary invoice.")) diff --git a/l10n_es_aeat_sii_invoice_summary/tests/__init__.py b/l10n_es_aeat_sii_invoice_summary/tests/__init__.py new file mode 100644 index 00000000000..866000135b8 --- /dev/null +++ b/l10n_es_aeat_sii_invoice_summary/tests/__init__.py @@ -0,0 +1 @@ +from . import test_l10n_es_aeat_sii_invoice_summary diff --git a/l10n_es_aeat_sii_invoice_summary/tests/json/sii_out_invoice_s_iva0_sp_i_s_iva0_ic_dict.json b/l10n_es_aeat_sii_invoice_summary/tests/json/sii_out_invoice_s_iva0_sp_i_s_iva0_ic_dict.json new file mode 100644 index 00000000000..0d1df9bee15 --- /dev/null +++ b/l10n_es_aeat_sii_invoice_summary/tests/json/sii_out_invoice_s_iva0_sp_i_s_iva0_ic_dict.json @@ -0,0 +1,41 @@ +{ + "IDFactura": { + "IDEmisorFactura": { + "NIF": "U2687761C" + }, + "NumSerieFacturaEmisor": "1", + "FechaExpedicionFacturaEmisor": "01-01-2020", + "NumSerieFacturaEmisorResumenFin": "10" + }, + "PeriodoLiquidacion": { + "Ejercicio": 2020, + "Periodo": "01" + }, + "FacturaExpedida": { + "TipoFactura": "F4", + "ClaveRegimenEspecialOTrascendencia": "01", + "DescripcionOperacion": "/", + "TipoDesglose": { + "DesgloseTipoOperacion": { + "PrestacionServicios": { + "NoSujeta": { + "ImporteTAIReglasLocalizacion": 100.0 + } + }, + "Entrega": { + "Sujeta": { + "Exenta": { + "DetalleExenta": [ + { + "BaseImponible": 200.0, + "CausaExencion": "E5" + } + ] + } + } + } + } + }, + "ImporteTotal": 300.0 + } +} diff --git a/l10n_es_aeat_sii_invoice_summary/tests/json/sii_out_invoice_s_iva0_sp_i_s_iva0_ic_same_dict.json b/l10n_es_aeat_sii_invoice_summary/tests/json/sii_out_invoice_s_iva0_sp_i_s_iva0_ic_same_dict.json new file mode 100644 index 00000000000..96561996f7c --- /dev/null +++ b/l10n_es_aeat_sii_invoice_summary/tests/json/sii_out_invoice_s_iva0_sp_i_s_iva0_ic_same_dict.json @@ -0,0 +1,40 @@ +{ + "IDFactura": { + "IDEmisorFactura": { + "NIF": "U2687761C" + }, + "NumSerieFacturaEmisor": "TEST001", + "FechaExpedicionFacturaEmisor": "01-01-2020" + }, + "PeriodoLiquidacion": { + "Ejercicio": 2020, + "Periodo": "01" + }, + "FacturaExpedida": { + "TipoFactura": "F2", + "ClaveRegimenEspecialOTrascendencia": "01", + "DescripcionOperacion": "/", + "TipoDesglose": { + "DesgloseTipoOperacion": { + "PrestacionServicios": { + "NoSujeta": { + "ImporteTAIReglasLocalizacion": 100.0 + } + }, + "Entrega": { + "Sujeta": { + "Exenta": { + "DetalleExenta": [ + { + "BaseImponible": 200.0, + "CausaExencion": "E5" + } + ] + } + } + } + } + }, + "ImporteTotal": 300.0 + } +} diff --git a/l10n_es_aeat_sii_invoice_summary/tests/json/sii_out_invoice_s_iva10b_dict.json b/l10n_es_aeat_sii_invoice_summary/tests/json/sii_out_invoice_s_iva10b_dict.json new file mode 100644 index 00000000000..846c3fd4ecb --- /dev/null +++ b/l10n_es_aeat_sii_invoice_summary/tests/json/sii_out_invoice_s_iva10b_dict.json @@ -0,0 +1,38 @@ +{ + "IDFactura": { + "IDEmisorFactura": { + "NIF": "U2687761C" + }, + "NumSerieFacturaEmisor": "1", + "FechaExpedicionFacturaEmisor": "01-01-2020", + "NumSerieFacturaEmisorResumenFin": "10" + }, + "PeriodoLiquidacion": { + "Ejercicio": 2020, + "Periodo": "01" + }, + "FacturaExpedida": { + "TipoFactura": "F4", + "ClaveRegimenEspecialOTrascendencia": "01", + "DescripcionOperacion": "/", + "TipoDesglose": { + "DesgloseFactura": { + "Sujeta": { + "NoExenta": { + "TipoNoExenta": "S1", + "DesgloseIVA": { + "DetalleIVA": [ + { + "TipoImpositivo": "10.0", + "BaseImponible": 83.33, + "CuotaRepercutida": 8.33 + } + ] + } + } + } + } + }, + "ImporteTotal": 91.66 + } +} diff --git a/l10n_es_aeat_sii_invoice_summary/tests/json/sii_out_invoice_s_iva10b_s_irpf1_dict.json b/l10n_es_aeat_sii_invoice_summary/tests/json/sii_out_invoice_s_iva10b_s_irpf1_dict.json new file mode 100644 index 00000000000..846c3fd4ecb --- /dev/null +++ b/l10n_es_aeat_sii_invoice_summary/tests/json/sii_out_invoice_s_iva10b_s_irpf1_dict.json @@ -0,0 +1,38 @@ +{ + "IDFactura": { + "IDEmisorFactura": { + "NIF": "U2687761C" + }, + "NumSerieFacturaEmisor": "1", + "FechaExpedicionFacturaEmisor": "01-01-2020", + "NumSerieFacturaEmisorResumenFin": "10" + }, + "PeriodoLiquidacion": { + "Ejercicio": 2020, + "Periodo": "01" + }, + "FacturaExpedida": { + "TipoFactura": "F4", + "ClaveRegimenEspecialOTrascendencia": "01", + "DescripcionOperacion": "/", + "TipoDesglose": { + "DesgloseFactura": { + "Sujeta": { + "NoExenta": { + "TipoNoExenta": "S1", + "DesgloseIVA": { + "DetalleIVA": [ + { + "TipoImpositivo": "10.0", + "BaseImponible": 83.33, + "CuotaRepercutida": 8.33 + } + ] + } + } + } + } + }, + "ImporteTotal": 91.66 + } +} diff --git a/l10n_es_aeat_sii_invoice_summary/tests/json/sii_out_invoice_s_iva10b_s_irpf1_same_dict.json b/l10n_es_aeat_sii_invoice_summary/tests/json/sii_out_invoice_s_iva10b_s_irpf1_same_dict.json new file mode 100644 index 00000000000..f9e55c8a07c --- /dev/null +++ b/l10n_es_aeat_sii_invoice_summary/tests/json/sii_out_invoice_s_iva10b_s_irpf1_same_dict.json @@ -0,0 +1,37 @@ +{ + "IDFactura": { + "IDEmisorFactura": { + "NIF": "U2687761C" + }, + "NumSerieFacturaEmisor": "TEST001", + "FechaExpedicionFacturaEmisor": "01-01-2020" + }, + "PeriodoLiquidacion": { + "Ejercicio": 2020, + "Periodo": "01" + }, + "FacturaExpedida": { + "TipoFactura": "F2", + "ClaveRegimenEspecialOTrascendencia": "01", + "DescripcionOperacion": "/", + "TipoDesglose": { + "DesgloseFactura": { + "Sujeta": { + "NoExenta": { + "TipoNoExenta": "S1", + "DesgloseIVA": { + "DetalleIVA": [ + { + "TipoImpositivo": "10.0", + "BaseImponible": 83.33, + "CuotaRepercutida": 8.33 + } + ] + } + } + } + } + }, + "ImporteTotal": 91.66 + } +} diff --git a/l10n_es_aeat_sii_invoice_summary/tests/json/sii_out_invoice_s_iva10b_s_iva0_ns_dict.json b/l10n_es_aeat_sii_invoice_summary/tests/json/sii_out_invoice_s_iva10b_s_iva0_ns_dict.json new file mode 100644 index 00000000000..e6760a743b0 --- /dev/null +++ b/l10n_es_aeat_sii_invoice_summary/tests/json/sii_out_invoice_s_iva10b_s_iva0_ns_dict.json @@ -0,0 +1,52 @@ +{ + "IDFactura": { + "IDEmisorFactura": { + "NIF": "U2687761C" + }, + "NumSerieFacturaEmisor": "1", + "FechaExpedicionFacturaEmisor": "01-01-2020", + "NumSerieFacturaEmisorResumenFin": "10" + }, + "PeriodoLiquidacion": { + "Ejercicio": 2020, + "Periodo": "01" + }, + "FacturaExpedida": { + "TipoFactura": "F4", + "ClaveRegimenEspecialOTrascendencia": "01", + "DescripcionOperacion": "/", + "TipoDesglose": { + "DesgloseTipoOperacion": { + "PrestacionServicios": { + "Sujeta": { + "Exenta": { + "DetalleExenta": [ + { + "BaseImponible": 200.0, + "CausaExencion": "E5" + } + ] + } + } + }, + "Entrega": { + "Sujeta": { + "NoExenta": { + "TipoNoExenta": "S1", + "DesgloseIVA": { + "DetalleIVA": [ + { + "TipoImpositivo": "10.0", + "BaseImponible": 100.0, + "CuotaRepercutida": 10.0 + } + ] + } + } + } + } + } + }, + "ImporteTotal": 110.0 + } +} diff --git a/l10n_es_aeat_sii_invoice_summary/tests/json/sii_out_invoice_s_iva10b_s_iva0_ns_same_dict.json b/l10n_es_aeat_sii_invoice_summary/tests/json/sii_out_invoice_s_iva10b_s_iva0_ns_same_dict.json new file mode 100644 index 00000000000..e419e045376 --- /dev/null +++ b/l10n_es_aeat_sii_invoice_summary/tests/json/sii_out_invoice_s_iva10b_s_iva0_ns_same_dict.json @@ -0,0 +1,51 @@ +{ + "IDFactura": { + "IDEmisorFactura": { + "NIF": "U2687761C" + }, + "NumSerieFacturaEmisor": "TEST001", + "FechaExpedicionFacturaEmisor": "01-01-2020" + }, + "PeriodoLiquidacion": { + "Ejercicio": 2020, + "Periodo": "01" + }, + "FacturaExpedida": { + "TipoFactura": "F2", + "ClaveRegimenEspecialOTrascendencia": "01", + "DescripcionOperacion": "/", + "TipoDesglose": { + "DesgloseTipoOperacion": { + "PrestacionServicios": { + "Sujeta": { + "Exenta": { + "DetalleExenta": [ + { + "BaseImponible": 200.0, + "CausaExencion": "E5" + } + ] + } + } + }, + "Entrega": { + "Sujeta": { + "NoExenta": { + "TipoNoExenta": "S1", + "DesgloseIVA": { + "DetalleIVA": [ + { + "TipoImpositivo": "10.0", + "BaseImponible": 100.0, + "CuotaRepercutida": 10.0 + } + ] + } + } + } + } + } + }, + "ImporteTotal": 110.0 + } +} diff --git a/l10n_es_aeat_sii_invoice_summary/tests/json/sii_out_invoice_s_iva10b_s_iva21s_dict.json b/l10n_es_aeat_sii_invoice_summary/tests/json/sii_out_invoice_s_iva10b_s_iva21s_dict.json new file mode 100644 index 00000000000..927e356ee73 --- /dev/null +++ b/l10n_es_aeat_sii_invoice_summary/tests/json/sii_out_invoice_s_iva10b_s_iva21s_dict.json @@ -0,0 +1,56 @@ +{ + "IDFactura": { + "IDEmisorFactura": { + "NIF": "U2687761C" + }, + "NumSerieFacturaEmisor": "1", + "FechaExpedicionFacturaEmisor": "01-01-2020", + "NumSerieFacturaEmisorResumenFin": "10" + }, + "PeriodoLiquidacion": { + "Ejercicio": 2020, + "Periodo": "01" + }, + "FacturaExpedida": { + "TipoFactura": "F4", + "ClaveRegimenEspecialOTrascendencia": "01", + "DescripcionOperacion": "/", + "TipoDesglose": { + "DesgloseTipoOperacion": { + "PrestacionServicios": { + "Sujeta": { + "NoExenta": { + "TipoNoExenta": "S1", + "DesgloseIVA": { + "DetalleIVA": [ + { + "TipoImpositivo": "21.0", + "BaseImponible": 200.0, + "CuotaRepercutida": 42.0 + } + ] + } + } + } + }, + "Entrega": { + "Sujeta": { + "NoExenta": { + "TipoNoExenta": "S1", + "DesgloseIVA": { + "DetalleIVA": [ + { + "TipoImpositivo": "10.0", + "BaseImponible": 100.0, + "CuotaRepercutida": 10.0 + } + ] + } + } + } + } + } + }, + "ImporteTotal": 352.0 + } +} diff --git a/l10n_es_aeat_sii_invoice_summary/tests/json/sii_out_invoice_s_iva10b_s_iva21s_same_dict.json b/l10n_es_aeat_sii_invoice_summary/tests/json/sii_out_invoice_s_iva10b_s_iva21s_same_dict.json new file mode 100644 index 00000000000..457bfb04062 --- /dev/null +++ b/l10n_es_aeat_sii_invoice_summary/tests/json/sii_out_invoice_s_iva10b_s_iva21s_same_dict.json @@ -0,0 +1,55 @@ +{ + "IDFactura": { + "IDEmisorFactura": { + "NIF": "U2687761C" + }, + "NumSerieFacturaEmisor": "TEST001", + "FechaExpedicionFacturaEmisor": "01-01-2020" + }, + "PeriodoLiquidacion": { + "Ejercicio": 2020, + "Periodo": "01" + }, + "FacturaExpedida": { + "TipoFactura": "F2", + "ClaveRegimenEspecialOTrascendencia": "01", + "DescripcionOperacion": "/", + "TipoDesglose": { + "DesgloseTipoOperacion": { + "PrestacionServicios": { + "Sujeta": { + "NoExenta": { + "TipoNoExenta": "S1", + "DesgloseIVA": { + "DetalleIVA": [ + { + "TipoImpositivo": "21.0", + "BaseImponible": 200.0, + "CuotaRepercutida": 42.0 + } + ] + } + } + } + }, + "Entrega": { + "Sujeta": { + "NoExenta": { + "TipoNoExenta": "S1", + "DesgloseIVA": { + "DetalleIVA": [ + { + "TipoImpositivo": "10.0", + "BaseImponible": 100.0, + "CuotaRepercutida": 10.0 + } + ] + } + } + } + } + } + }, + "ImporteTotal": 352.0 + } +} diff --git a/l10n_es_aeat_sii_invoice_summary/tests/json/sii_out_invoice_s_iva10b_s_req014_s_iva21s_s_req52_dict.json b/l10n_es_aeat_sii_invoice_summary/tests/json/sii_out_invoice_s_iva10b_s_req014_s_iva21s_s_req52_dict.json new file mode 100644 index 00000000000..3ac0e2b0663 --- /dev/null +++ b/l10n_es_aeat_sii_invoice_summary/tests/json/sii_out_invoice_s_iva10b_s_req014_s_iva21s_s_req52_dict.json @@ -0,0 +1,60 @@ +{ + "IDFactura": { + "IDEmisorFactura": { + "NIF": "U2687761C" + }, + "NumSerieFacturaEmisor": "1", + "FechaExpedicionFacturaEmisor": "01-01-2020", + "NumSerieFacturaEmisorResumenFin": "10" + }, + "PeriodoLiquidacion": { + "Ejercicio": 2020, + "Periodo": "01" + }, + "FacturaExpedida": { + "TipoFactura": "F4", + "ClaveRegimenEspecialOTrascendencia": "01", + "DescripcionOperacion": "/", + "TipoDesglose": { + "DesgloseTipoOperacion": { + "PrestacionServicios": { + "Sujeta": { + "NoExenta": { + "TipoNoExenta": "S1", + "DesgloseIVA": { + "DetalleIVA": [ + { + "TipoImpositivo": "21.0", + "BaseImponible": 200.0, + "CuotaRepercutida": 42.0, + "TipoRecargoEquivalencia": 5.2, + "CuotaRecargoEquivalencia": 10.4 + } + ] + } + } + } + }, + "Entrega": { + "Sujeta": { + "NoExenta": { + "TipoNoExenta": "S1", + "DesgloseIVA": { + "DetalleIVA": [ + { + "TipoImpositivo": "10.0", + "BaseImponible": 100.0, + "CuotaRepercutida": 10.0, + "TipoRecargoEquivalencia": 1.4, + "CuotaRecargoEquivalencia": 1.4 + } + ] + } + } + } + } + } + }, + "ImporteTotal": 363.8 + } +} diff --git a/l10n_es_aeat_sii_invoice_summary/tests/json/sii_out_invoice_s_iva10b_s_req014_s_iva21s_s_req52_same_dict.json b/l10n_es_aeat_sii_invoice_summary/tests/json/sii_out_invoice_s_iva10b_s_req014_s_iva21s_s_req52_same_dict.json new file mode 100644 index 00000000000..dc7a8d1485b --- /dev/null +++ b/l10n_es_aeat_sii_invoice_summary/tests/json/sii_out_invoice_s_iva10b_s_req014_s_iva21s_s_req52_same_dict.json @@ -0,0 +1,59 @@ +{ + "IDFactura": { + "IDEmisorFactura": { + "NIF": "U2687761C" + }, + "NumSerieFacturaEmisor": "TEST001", + "FechaExpedicionFacturaEmisor": "01-01-2020" + }, + "PeriodoLiquidacion": { + "Ejercicio": 2020, + "Periodo": "01" + }, + "FacturaExpedida": { + "TipoFactura": "F2", + "ClaveRegimenEspecialOTrascendencia": "01", + "DescripcionOperacion": "/", + "TipoDesglose": { + "DesgloseTipoOperacion": { + "PrestacionServicios": { + "Sujeta": { + "NoExenta": { + "TipoNoExenta": "S1", + "DesgloseIVA": { + "DetalleIVA": [ + { + "TipoImpositivo": "21.0", + "BaseImponible": 200.0, + "CuotaRepercutida": 42.0, + "TipoRecargoEquivalencia": 5.2, + "CuotaRecargoEquivalencia": 10.4 + } + ] + } + } + } + }, + "Entrega": { + "Sujeta": { + "NoExenta": { + "TipoNoExenta": "S1", + "DesgloseIVA": { + "DetalleIVA": [ + { + "TipoImpositivo": "10.0", + "BaseImponible": 100.0, + "CuotaRepercutida": 10.0, + "TipoRecargoEquivalencia": 1.4, + "CuotaRecargoEquivalencia": 1.4 + } + ] + } + } + } + } + } + }, + "ImporteTotal": 363.8 + } +} diff --git a/l10n_es_aeat_sii_invoice_summary/tests/json/sii_out_invoice_s_iva10b_same_dict.json b/l10n_es_aeat_sii_invoice_summary/tests/json/sii_out_invoice_s_iva10b_same_dict.json new file mode 100644 index 00000000000..f9e55c8a07c --- /dev/null +++ b/l10n_es_aeat_sii_invoice_summary/tests/json/sii_out_invoice_s_iva10b_same_dict.json @@ -0,0 +1,37 @@ +{ + "IDFactura": { + "IDEmisorFactura": { + "NIF": "U2687761C" + }, + "NumSerieFacturaEmisor": "TEST001", + "FechaExpedicionFacturaEmisor": "01-01-2020" + }, + "PeriodoLiquidacion": { + "Ejercicio": 2020, + "Periodo": "01" + }, + "FacturaExpedida": { + "TipoFactura": "F2", + "ClaveRegimenEspecialOTrascendencia": "01", + "DescripcionOperacion": "/", + "TipoDesglose": { + "DesgloseFactura": { + "Sujeta": { + "NoExenta": { + "TipoNoExenta": "S1", + "DesgloseIVA": { + "DetalleIVA": [ + { + "TipoImpositivo": "10.0", + "BaseImponible": 83.33, + "CuotaRepercutida": 8.33 + } + ] + } + } + } + } + }, + "ImporteTotal": 91.66 + } +} diff --git a/l10n_es_aeat_sii_invoice_summary/tests/json/sii_out_invoice_s_iva_e_s_iva0_e_dict.json b/l10n_es_aeat_sii_invoice_summary/tests/json/sii_out_invoice_s_iva_e_s_iva0_e_dict.json new file mode 100644 index 00000000000..0d1df9bee15 --- /dev/null +++ b/l10n_es_aeat_sii_invoice_summary/tests/json/sii_out_invoice_s_iva_e_s_iva0_e_dict.json @@ -0,0 +1,41 @@ +{ + "IDFactura": { + "IDEmisorFactura": { + "NIF": "U2687761C" + }, + "NumSerieFacturaEmisor": "1", + "FechaExpedicionFacturaEmisor": "01-01-2020", + "NumSerieFacturaEmisorResumenFin": "10" + }, + "PeriodoLiquidacion": { + "Ejercicio": 2020, + "Periodo": "01" + }, + "FacturaExpedida": { + "TipoFactura": "F4", + "ClaveRegimenEspecialOTrascendencia": "01", + "DescripcionOperacion": "/", + "TipoDesglose": { + "DesgloseTipoOperacion": { + "PrestacionServicios": { + "NoSujeta": { + "ImporteTAIReglasLocalizacion": 100.0 + } + }, + "Entrega": { + "Sujeta": { + "Exenta": { + "DetalleExenta": [ + { + "BaseImponible": 200.0, + "CausaExencion": "E5" + } + ] + } + } + } + } + }, + "ImporteTotal": 300.0 + } +} diff --git a/l10n_es_aeat_sii_invoice_summary/tests/json/sii_out_invoice_s_iva_e_s_iva0_e_same_dict.json b/l10n_es_aeat_sii_invoice_summary/tests/json/sii_out_invoice_s_iva_e_s_iva0_e_same_dict.json new file mode 100644 index 00000000000..96561996f7c --- /dev/null +++ b/l10n_es_aeat_sii_invoice_summary/tests/json/sii_out_invoice_s_iva_e_s_iva0_e_same_dict.json @@ -0,0 +1,40 @@ +{ + "IDFactura": { + "IDEmisorFactura": { + "NIF": "U2687761C" + }, + "NumSerieFacturaEmisor": "TEST001", + "FechaExpedicionFacturaEmisor": "01-01-2020" + }, + "PeriodoLiquidacion": { + "Ejercicio": 2020, + "Periodo": "01" + }, + "FacturaExpedida": { + "TipoFactura": "F2", + "ClaveRegimenEspecialOTrascendencia": "01", + "DescripcionOperacion": "/", + "TipoDesglose": { + "DesgloseTipoOperacion": { + "PrestacionServicios": { + "NoSujeta": { + "ImporteTAIReglasLocalizacion": 100.0 + } + }, + "Entrega": { + "Sujeta": { + "Exenta": { + "DetalleExenta": [ + { + "BaseImponible": 200.0, + "CausaExencion": "E5" + } + ] + } + } + } + } + }, + "ImporteTotal": 300.0 + } +} diff --git a/l10n_es_aeat_sii_invoice_summary/tests/json/sii_out_refund_s_iva0_sp_i_s_iva0_ic_dict.json b/l10n_es_aeat_sii_invoice_summary/tests/json/sii_out_refund_s_iva0_sp_i_s_iva0_ic_dict.json new file mode 100644 index 00000000000..e2b8c984ea7 --- /dev/null +++ b/l10n_es_aeat_sii_invoice_summary/tests/json/sii_out_refund_s_iva0_sp_i_s_iva0_ic_dict.json @@ -0,0 +1,41 @@ +{ + "IDFactura": { + "IDEmisorFactura": { + "NIF": "U2687761C" + }, + "NumSerieFacturaEmisor": "1", + "FechaExpedicionFacturaEmisor": "01-01-2020", + "NumSerieFacturaEmisorResumenFin": "10" + }, + "PeriodoLiquidacion": { + "Ejercicio": 2020, + "Periodo": "01" + }, + "FacturaExpedida": { + "TipoFactura": "F4", + "ClaveRegimenEspecialOTrascendencia": "01", + "DescripcionOperacion": "/", + "TipoDesglose": { + "DesgloseTipoOperacion": { + "PrestacionServicios": { + "NoSujeta": { + "ImporteTAIReglasLocalizacion": -100.0 + } + }, + "Entrega": { + "Sujeta": { + "Exenta": { + "DetalleExenta": [ + { + "BaseImponible": -200.0, + "CausaExencion": "E5" + } + ] + } + } + } + } + }, + "ImporteTotal": -300.0 + } +} diff --git a/l10n_es_aeat_sii_invoice_summary/tests/json/sii_out_refund_s_iva0_sp_i_s_iva0_ic_same_dict.json b/l10n_es_aeat_sii_invoice_summary/tests/json/sii_out_refund_s_iva0_sp_i_s_iva0_ic_same_dict.json new file mode 100644 index 00000000000..6bba04971bd --- /dev/null +++ b/l10n_es_aeat_sii_invoice_summary/tests/json/sii_out_refund_s_iva0_sp_i_s_iva0_ic_same_dict.json @@ -0,0 +1,45 @@ +{ + "IDFactura": { + "IDEmisorFactura": { + "NIF": "U2687761C" + }, + "NumSerieFacturaEmisor": "TEST001", + "FechaExpedicionFacturaEmisor": "01-01-2020" + }, + "PeriodoLiquidacion": { + "Ejercicio": 2020, + "Periodo": "01" + }, + "FacturaExpedida": { + "TipoFactura": "R1", + "ClaveRegimenEspecialOTrascendencia": "01", + "DescripcionOperacion": "/", + "TipoDesglose": { + "DesgloseTipoOperacion": { + "PrestacionServicios": { + "NoSujeta": { + "ImporteTAIReglasLocalizacion": -100.0 + } + }, + "Entrega": { + "Sujeta": { + "Exenta": { + "DetalleExenta": [ + { + "BaseImponible": -200.0, + "CausaExencion": "E5" + } + ] + } + } + } + } + }, + "ImporteTotal": -300.0, + "Contraparte": { + "NombreRazon": "Test partner", + "NIF": "F35999705" + }, + "TipoRectificativa": "I" + } +} diff --git a/l10n_es_aeat_sii_invoice_summary/tests/json/sii_out_refund_s_iva10b_s_iva10b_s_iva21s_dict.json b/l10n_es_aeat_sii_invoice_summary/tests/json/sii_out_refund_s_iva10b_s_iva10b_s_iva21s_dict.json new file mode 100644 index 00000000000..9861a6c25e9 --- /dev/null +++ b/l10n_es_aeat_sii_invoice_summary/tests/json/sii_out_refund_s_iva10b_s_iva10b_s_iva21s_dict.json @@ -0,0 +1,56 @@ +{ + "IDFactura": { + "IDEmisorFactura": { + "NIF": "U2687761C" + }, + "NumSerieFacturaEmisor": "1", + "FechaExpedicionFacturaEmisor": "01-01-2020", + "NumSerieFacturaEmisorResumenFin": "10" + }, + "PeriodoLiquidacion": { + "Ejercicio": 2020, + "Periodo": "01" + }, + "FacturaExpedida": { + "TipoFactura": "F4", + "ClaveRegimenEspecialOTrascendencia": "01", + "DescripcionOperacion": "/", + "TipoDesglose": { + "DesgloseTipoOperacion": { + "PrestacionServicios": { + "Sujeta": { + "NoExenta": { + "TipoNoExenta": "S1", + "DesgloseIVA": { + "DetalleIVA": [ + { + "TipoImpositivo": "21.0", + "BaseImponible": -200.0, + "CuotaRepercutida": -42.0 + } + ] + } + } + } + }, + "Entrega": { + "Sujeta": { + "NoExenta": { + "TipoNoExenta": "S1", + "DesgloseIVA": { + "DetalleIVA": [ + { + "TipoImpositivo": "10.0", + "BaseImponible": -200.0, + "CuotaRepercutida": -20.0 + } + ] + } + } + } + } + } + }, + "ImporteTotal": -462.0 + } +} diff --git a/l10n_es_aeat_sii_invoice_summary/tests/json/sii_out_refund_s_iva10b_s_iva10b_s_iva21s_same_dict.json b/l10n_es_aeat_sii_invoice_summary/tests/json/sii_out_refund_s_iva10b_s_iva10b_s_iva21s_same_dict.json new file mode 100644 index 00000000000..114c2b5b3eb --- /dev/null +++ b/l10n_es_aeat_sii_invoice_summary/tests/json/sii_out_refund_s_iva10b_s_iva10b_s_iva21s_same_dict.json @@ -0,0 +1,60 @@ +{ + "IDFactura": { + "IDEmisorFactura": { + "NIF": "U2687761C" + }, + "NumSerieFacturaEmisor": "TEST001", + "FechaExpedicionFacturaEmisor": "01-01-2020" + }, + "PeriodoLiquidacion": { + "Ejercicio": 2020, + "Periodo": "01" + }, + "FacturaExpedida": { + "TipoFactura": "R1", + "ClaveRegimenEspecialOTrascendencia": "01", + "DescripcionOperacion": "/", + "TipoDesglose": { + "DesgloseTipoOperacion": { + "PrestacionServicios": { + "Sujeta": { + "NoExenta": { + "TipoNoExenta": "S1", + "DesgloseIVA": { + "DetalleIVA": [ + { + "TipoImpositivo": "21.0", + "BaseImponible": -200.0, + "CuotaRepercutida": -42.0 + } + ] + } + } + } + }, + "Entrega": { + "Sujeta": { + "NoExenta": { + "TipoNoExenta": "S1", + "DesgloseIVA": { + "DetalleIVA": [ + { + "TipoImpositivo": "10.0", + "BaseImponible": -200.0, + "CuotaRepercutida": -20.0 + } + ] + } + } + } + } + } + }, + "ImporteTotal": -462.0, + "Contraparte": { + "NombreRazon": "Test partner", + "NIF": "F35999705" + }, + "TipoRectificativa": "I" + } +} diff --git a/l10n_es_aeat_sii_invoice_summary/tests/json/sii_out_refund_s_iva_e_s_iva0_e_dict.json b/l10n_es_aeat_sii_invoice_summary/tests/json/sii_out_refund_s_iva_e_s_iva0_e_dict.json new file mode 100644 index 00000000000..e2b8c984ea7 --- /dev/null +++ b/l10n_es_aeat_sii_invoice_summary/tests/json/sii_out_refund_s_iva_e_s_iva0_e_dict.json @@ -0,0 +1,41 @@ +{ + "IDFactura": { + "IDEmisorFactura": { + "NIF": "U2687761C" + }, + "NumSerieFacturaEmisor": "1", + "FechaExpedicionFacturaEmisor": "01-01-2020", + "NumSerieFacturaEmisorResumenFin": "10" + }, + "PeriodoLiquidacion": { + "Ejercicio": 2020, + "Periodo": "01" + }, + "FacturaExpedida": { + "TipoFactura": "F4", + "ClaveRegimenEspecialOTrascendencia": "01", + "DescripcionOperacion": "/", + "TipoDesglose": { + "DesgloseTipoOperacion": { + "PrestacionServicios": { + "NoSujeta": { + "ImporteTAIReglasLocalizacion": -100.0 + } + }, + "Entrega": { + "Sujeta": { + "Exenta": { + "DetalleExenta": [ + { + "BaseImponible": -200.0, + "CausaExencion": "E5" + } + ] + } + } + } + } + }, + "ImporteTotal": -300.0 + } +} diff --git a/l10n_es_aeat_sii_invoice_summary/tests/json/sii_out_refund_s_iva_e_s_iva0_e_same_dict.json b/l10n_es_aeat_sii_invoice_summary/tests/json/sii_out_refund_s_iva_e_s_iva0_e_same_dict.json new file mode 100644 index 00000000000..6bba04971bd --- /dev/null +++ b/l10n_es_aeat_sii_invoice_summary/tests/json/sii_out_refund_s_iva_e_s_iva0_e_same_dict.json @@ -0,0 +1,45 @@ +{ + "IDFactura": { + "IDEmisorFactura": { + "NIF": "U2687761C" + }, + "NumSerieFacturaEmisor": "TEST001", + "FechaExpedicionFacturaEmisor": "01-01-2020" + }, + "PeriodoLiquidacion": { + "Ejercicio": 2020, + "Periodo": "01" + }, + "FacturaExpedida": { + "TipoFactura": "R1", + "ClaveRegimenEspecialOTrascendencia": "01", + "DescripcionOperacion": "/", + "TipoDesglose": { + "DesgloseTipoOperacion": { + "PrestacionServicios": { + "NoSujeta": { + "ImporteTAIReglasLocalizacion": -100.0 + } + }, + "Entrega": { + "Sujeta": { + "Exenta": { + "DetalleExenta": [ + { + "BaseImponible": -200.0, + "CausaExencion": "E5" + } + ] + } + } + } + } + }, + "ImporteTotal": -300.0, + "Contraparte": { + "NombreRazon": "Test partner", + "NIF": "F35999705" + }, + "TipoRectificativa": "I" + } +} diff --git a/l10n_es_aeat_sii_invoice_summary/tests/test_l10n_es_aeat_sii_invoice_summary.py b/l10n_es_aeat_sii_invoice_summary/tests/test_l10n_es_aeat_sii_invoice_summary.py new file mode 100644 index 00000000000..86bedea0d73 --- /dev/null +++ b/l10n_es_aeat_sii_invoice_summary/tests/test_l10n_es_aeat_sii_invoice_summary.py @@ -0,0 +1,264 @@ +# Copyright 2022 ProcessControl david.ramia@processcontrol.es +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html) + +from odoo import exceptions + +from odoo.addons.l10n_es_aeat_sii_oca.tests.test_l10n_es_aeat_sii import ( + TestL10nEsAeatSii, +) + + +class TestL10nEsAeatSiiSummary(TestL10nEsAeatSii): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.invoice.is_invoice_summary = True + cls.invoice.sii_invoice_summary_start = True + cls.invoice.sii_invoice_summary_end = True + + def test_sii_check_exceptions_case_supplier_summary(self): + invoice = self.env["account.move"].create( + { + "partner_id": self.partner.id, + "invoice_date": "2018-02-01", + "move_type": "in_invoice", + "is_invoice_summary": True, + "sii_invoice_summary_start": 1, + "sii_invoice_summary_end": 10, + } + ) + with self.assertRaises(exceptions.UserError): + invoice._sii_check_exceptions() + + def test_sii_check_exceptions_case_summary_vat(self): + partner = self.env["res.partner"].create({"name": "Test partner"}) + invoice = self.env["account.move"].create( + { + "partner_id": partner.id, + "invoice_date": "2018-02-01", + "move_type": "out_invoice", + "is_invoice_summary": True, + "sii_invoice_summary_start": 1, + "sii_invoice_summary_end": 10, + } + ) + invoice._sii_check_exceptions() + + def test_get_invoice_data_summary_case_same_number(self): + mapping = [ + ( + "out_invoice", + [(100, ["s_iva10b"]), (200, ["s_iva21s"])], + { + "is_invoice_summary": True, + "sii_invoice_summary_start": 1, + "sii_invoice_summary_end": 1, + }, + ), + ( + "out_invoice", + [(100, ["s_iva10b"]), (200, ["s_iva0_ns"])], + { + "is_invoice_summary": True, + "sii_invoice_summary_start": 1, + "sii_invoice_summary_end": 1, + }, + ), + ( + "out_invoice", + [(100, ["s_iva10b", "s_req014"]), (200, ["s_iva21s", "s_req52"])], + { + "is_invoice_summary": True, + "sii_invoice_summary_start": 1, + "sii_invoice_summary_end": 1, + }, + ), + ( + "out_refund", + [(100, ["s_iva10b"]), (100, ["s_iva10b"]), (200, ["s_iva21s"])], + { + "is_invoice_summary": True, + "sii_invoice_summary_start": 1, + "sii_invoice_summary_end": 1, + }, + ), + ( + "out_invoice", + [(100, ["s_iva0_sp_i"]), (200, ["s_iva0_ic"])], + { + "is_invoice_summary": True, + "sii_invoice_summary_start": 1, + "sii_invoice_summary_end": 1, + }, + ), + ( + "out_refund", + [(100, ["s_iva0_sp_i"]), (200, ["s_iva0_ic"])], + { + "is_invoice_summary": True, + "sii_invoice_summary_start": 1, + "sii_invoice_summary_end": 1, + }, + ), + ( + "out_invoice", + [(100, ["s_iva_e"]), (200, ["s_iva0_e"])], + { + "is_invoice_summary": True, + "sii_invoice_summary_start": 1, + "sii_invoice_summary_end": 1, + }, + ), + ( + "out_refund", + [(100, ["s_iva_e"]), (200, ["s_iva0_e"])], + { + "is_invoice_summary": True, + "sii_invoice_summary_start": 1, + "sii_invoice_summary_end": 1, + }, + ), + # Out invoice with currency + ( + "out_invoice", + [(100, ["s_iva10b"])], + { + "currency_id": self.usd.id, + "is_invoice_summary": True, + "sii_invoice_summary_start": 1, + "sii_invoice_summary_end": 1, + }, + ), + # Out invoice with currency and with not included in total amount + ( + "out_invoice", + [(100, ["s_iva10b", "s_irpf1"])], + { + "currency_id": self.usd.id, + "is_invoice_summary": True, + "sii_invoice_summary_start": 1, + "sii_invoice_summary_end": 1, + }, + ), + ] + for inv_type, lines, extra_vals in mapping: + self._create_and_test_invoice_sii_dict( + inv_type, lines, extra_vals, "l10n_es_aeat_sii_invoice_summary" + ) + return + + def test_get_invoice_data_summary(self): + mapping = [ + ( + "out_invoice", + [(100, ["s_iva10b"]), (200, ["s_iva21s"])], + { + "is_invoice_summary": True, + "sii_invoice_summary_start": 1, + "sii_invoice_summary_end": 10, + }, + ), + ( + "out_invoice", + [(100, ["s_iva10b"]), (200, ["s_iva0_ns"])], + { + "is_invoice_summary": True, + "sii_invoice_summary_start": 1, + "sii_invoice_summary_end": 10, + }, + ), + ( + "out_invoice", + [(100, ["s_iva10b", "s_req014"]), (200, ["s_iva21s", "s_req52"])], + { + "is_invoice_summary": True, + "sii_invoice_summary_start": 1, + "sii_invoice_summary_end": 10, + }, + ), + ( + "out_refund", + [(100, ["s_iva10b"]), (100, ["s_iva10b"]), (200, ["s_iva21s"])], + { + "is_invoice_summary": True, + "sii_invoice_summary_start": 1, + "sii_invoice_summary_end": 10, + }, + ), + ( + "out_invoice", + [(100, ["s_iva0_sp_i"]), (200, ["s_iva0_ic"])], + { + "is_invoice_summary": True, + "sii_invoice_summary_start": 1, + "sii_invoice_summary_end": 10, + }, + ), + ( + "out_refund", + [(100, ["s_iva0_sp_i"]), (200, ["s_iva0_ic"])], + { + "is_invoice_summary": True, + "sii_invoice_summary_start": 1, + "sii_invoice_summary_end": 10, + }, + ), + ( + "out_invoice", + [(100, ["s_iva_e"]), (200, ["s_iva0_e"])], + { + "is_invoice_summary": True, + "sii_invoice_summary_start": 1, + "sii_invoice_summary_end": 10, + }, + ), + ( + "out_refund", + [(100, ["s_iva_e"]), (200, ["s_iva0_e"])], + { + "is_invoice_summary": True, + "sii_invoice_summary_start": 1, + "sii_invoice_summary_end": 10, + }, + ), + # Out invoice with currency + ( + "out_invoice", + [(100, ["s_iva10b"])], + { + "currency_id": self.usd.id, + "is_invoice_summary": True, + "sii_invoice_summary_start": 1, + "sii_invoice_summary_end": 10, + }, + ), + # Out invoice with currency and with not included in total amount + ( + "out_invoice", + [(100, ["s_iva10b", "s_irpf1"])], + { + "currency_id": self.usd.id, + "is_invoice_summary": True, + "sii_invoice_summary_start": 1, + "sii_invoice_summary_end": 10, + }, + ), + ] + for inv_type, lines, extra_vals in mapping: + self._create_and_test_invoice_sii_dict( + inv_type, lines, extra_vals, "l10n_es_aeat_sii_invoice_summary" + ) + return + + def _compare_sii_dict( + self, json_file, inv_type, lines, extra_vals=None, module=None + ): + if extra_vals.get("sii_invoice_summary_start"): + if extra_vals.get("sii_invoice_summary_start") == extra_vals.get( + "sii_invoice_summary_end" + ): + json_file = json_file.replace("dict.json", "same_dict.json") + + return super(TestL10nEsAeatSiiSummary, self)._compare_sii_dict( + json_file, inv_type, lines, extra_vals, module + )