Skip to content

Commit

Permalink
[IMP] l10n_es_aeat_sii_invoice_summary: añadir rectificativas y tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ramiadavid committed Jul 6, 2022
1 parent b4a1a0d commit 94ce154
Show file tree
Hide file tree
Showing 25 changed files with 1,230 additions and 87 deletions.
34 changes: 5 additions & 29 deletions l10n_es_aeat_sii_invoice_summary/i18n/es.po
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ 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"
"MIME-Version: 1.0\n"
"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
Expand Down Expand Up @@ -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."
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 ""
55 changes: 24 additions & 31 deletions l10n_es_aeat_sii_invoice_summary/models/account_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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."))
1 change: 1 addition & 0 deletions l10n_es_aeat_sii_invoice_summary/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import test_l10n_es_aeat_sii_invoice_summary
Original file line number Diff line number Diff line change
@@ -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
}
}
Original file line number Diff line number Diff line change
@@ -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
}
}
Original file line number Diff line number Diff line change
@@ -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
}
}
Original file line number Diff line number Diff line change
@@ -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
}
}
Original file line number Diff line number Diff line change
@@ -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
}
}
Loading

0 comments on commit 94ce154

Please sign in to comment.