Skip to content

Commit

Permalink
[FIX] l10n_es_aeat_sii_oca: Campo BaseImponibleACoste obligatorio con…
Browse files Browse the repository at this point in the history
… ^ClaveRegimenEspecialOTrascendencia.*$ = '06'
  • Loading branch information
eantones committed Aug 2, 2022
1 parent 1f8f5f3 commit 637b55a
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions l10n_es_aeat_sii_oca/models/account_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
# Copyright 2021 Tecnativa - João Marques
# Copyright 2022 ForgeFlow - Lois Rilo
# Copyright 2022 Tecnativa - Víctor Martínez
# Copyright 2022 NuoBiT Solutions - Eric Antones <eantones@nuobit.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

import json
Expand Down Expand Up @@ -74,6 +75,17 @@ def round_by_keys(elem, search_keys, prec=2):
round_by_keys(value, search_keys)


def sum_key(elem, key):
value = 0
if isinstance(elem, (list, tuple)):
for v in elem:
value += sum_key(v, key)
elif isinstance(elem, dict):
for k, v in elem.items():
value += v if k == key else sum_key(v, key)
return value


class AccountMove(models.Model):
_inherit = "account.move"

Expand Down Expand Up @@ -841,6 +853,14 @@ def _get_sii_invoice_dict_out(self, cancel=False):
)
}
)
if "06" in [
self.sii_registration_key.code,
self.sii_registration_key_additional1.code,
self.sii_registration_key_additional2.code,
]:
inv_dict["FacturaExpedida"].update(
{"BaseImponibleACoste": sum_key(tipo_desglose, "BaseImponible")}
)
if self.sii_registration_key.code in ["12", "13"]:
inv_dict["FacturaExpedida"]["DatosInmueble"] = {
"DetalleInmueble": {
Expand Down Expand Up @@ -931,6 +951,14 @@ def _get_sii_invoice_dict_in(self, cancel=False):
)
}
)
if "06" in [
self.sii_registration_key.code,
self.sii_registration_key_additional1.code,
self.sii_registration_key_additional2.code,
]:
inv_dict["FacturaRecibida"].update(
{"BaseImponibleACoste": sum_key(desglose_factura, "BaseImponible")}
)
# Uso condicional de IDOtro/NIF
inv_dict["FacturaRecibida"]["Contraparte"].update(ident)
if self.move_type == "in_refund":
Expand Down Expand Up @@ -969,6 +997,7 @@ def _get_sii_invoice_dict(self):
"CuotaRectificada",
"CuotaDeducible",
"ImporteCompensacionREAGYP",
"BaseImponibleACoste",
],
)
return inv_dict
Expand Down

0 comments on commit 637b55a

Please sign in to comment.