From 2ad07e88a1b9828ccd5c442eb5467e17abdde531 Mon Sep 17 00:00:00 2001 From: almumu Date: Tue, 13 Jun 2023 13:56:27 +0200 Subject: [PATCH] =?UTF-8?q?arreglados=20errores=20al=20enviar=20algunas=20?= =?UTF-8?q?sesiones=20al=20sii=20con=20casos=20que=20no=20se=20hab=C3=ADan?= =?UTF-8?q?=20contemplado:=20(#34)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - redondeo a 2 decimales de las bases imponibles - si sólo hay un pedido en la sesión, no se permite enviar resumen porque el número de inicio y fin no puede ser el mismo, en ese caso se enviará como factura simplificada - si no hay pedidos para el resumen porque se han facturado todos, que avise al usuario, en vez de petar, para que sepan que esa sesión no se envía al sii por ese motivo y la puedan excluir. --- l10n_es_aeat_sii_pos_summary/i18n/es.po | 8 +++++++- .../i18n/l10n_es_aeat_sii_pos_summary.pot | 6 ++++++ l10n_es_aeat_sii_pos_summary/models/account_move.py | 1 + l10n_es_aeat_sii_pos_summary/models/pos_session.py | 12 ++++++++++++ 4 files changed, 26 insertions(+), 1 deletion(-) diff --git a/l10n_es_aeat_sii_pos_summary/i18n/es.po b/l10n_es_aeat_sii_pos_summary/i18n/es.po index 91d5251de6d..62a1e8f3b26 100644 --- a/l10n_es_aeat_sii_pos_summary/i18n/es.po +++ b/l10n_es_aeat_sii_pos_summary/i18n/es.po @@ -19,7 +19,13 @@ msgstr "" #: code:addons/l10n_es_aeat_sii_pos_summary/models/pos_session.py:0 #, python-format msgid "A simplified invoice sequence must be cofigured" -msgstr "" +msgstr "Debe configurarse una secuencia de factura simplificada" + +#. module: l10n_es_aeat_sii_pos_summary +#: code:addons/l10n_es_aeat_sii_pos_summary/models/pos_session.py:0 +#, python-format +msgid "Cannot send any summary to SII. All orders have been invoiced" +msgstr "No se puede enviar resumen al SII. Todo los pedidos se han facturado" #. module: l10n_es_aeat_sii_pos_summary #: model:ir.model.fields.selection,name:l10n_es_aeat_sii_pos_summary.selection__pos_session__sii_state__sent_w_errors diff --git a/l10n_es_aeat_sii_pos_summary/i18n/l10n_es_aeat_sii_pos_summary.pot b/l10n_es_aeat_sii_pos_summary/i18n/l10n_es_aeat_sii_pos_summary.pot index 8858a17529b..48a2a0faf1c 100644 --- a/l10n_es_aeat_sii_pos_summary/i18n/l10n_es_aeat_sii_pos_summary.pot +++ b/l10n_es_aeat_sii_pos_summary/i18n/l10n_es_aeat_sii_pos_summary.pot @@ -21,6 +21,12 @@ msgstr "" msgid "A simplified invoice sequence must be cofigured" msgstr "" +#. module: l10n_es_aeat_sii_pos_summary +#: code:addons/l10n_es_aeat_sii_pos_summary/models/pos_session.py:0 +#, python-format +msgid "Cannot send any summary to SII. All orders have been invoiced" +msgstr "" + #. module: l10n_es_aeat_sii_pos_summary #: model:ir.model.fields.selection,name:l10n_es_aeat_sii_pos_summary.selection__pos_session__sii_state__sent_w_errors msgid "Accepted with errors" diff --git a/l10n_es_aeat_sii_pos_summary/models/account_move.py b/l10n_es_aeat_sii_pos_summary/models/account_move.py index 6e054029a00..d0f0f72f4d4 100644 --- a/l10n_es_aeat_sii_pos_summary/models/account_move.py +++ b/l10n_es_aeat_sii_pos_summary/models/account_move.py @@ -40,4 +40,5 @@ def _get_sii_tax_dict(self, tax_line, tax_lines): tax_dict = super(AccountMove, self)._get_sii_tax_dict(tax_line, tax_lines) if self._context.get("from_pos"): tax_dict["CuotaRepercutida"] = round(tax_dict.pop("CuotaSoportada"), 2) + tax_dict["BaseImponible"] = round(tax_dict.pop("BaseImponible"), 2) return tax_dict diff --git a/l10n_es_aeat_sii_pos_summary/models/pos_session.py b/l10n_es_aeat_sii_pos_summary/models/pos_session.py index 9bdec1ad3fd..9790a0ea50e 100644 --- a/l10n_es_aeat_sii_pos_summary/models/pos_session.py +++ b/l10n_es_aeat_sii_pos_summary/models/pos_session.py @@ -110,6 +110,11 @@ def _other_checks_before_send(self): self.ensure_one() if not self.config_id.l10n_es_simplified_invoice_sequence_id: raise UserError(_("A simplified invoice sequence must be cofigured")) + pos_orders_sorted = self._get_sorted_pos_orders() + if not pos_orders_sorted: + raise UserError( + _("Cannot send any summary to SII. All orders have been invoiced") + ) def _process_send_summary_to_sii(self, modification=False): for session in self: @@ -202,6 +207,11 @@ def _get_sii_summary_dict(self): sum(pos_orders_sorted.mapped("amount_total")), 2 ) tipo_factura = "F4" + # si sólo hay 1 pedido no se puede enviar resumen porque + # el número inicio y fin es el mismo y devuelve error, + # en ese caso lo enviamos como factura simplificada: F2 + if len(pos_orders_sorted) == 1: + tipo_factura = "F2" session_date = move._change_date_format(move.date) if pos_orders_amount_total < 0: raise UserError( @@ -227,6 +237,8 @@ def _get_sii_summary_dict(self): "ImporteTotal": importe_total, }, } + if tipo_factura == "F2": + del orders["IDFactura"]["NumSerieFacturaEmisorResumenFin"] if move.sii_macrodata: orders["FacturaExpedida"].update(Macrodato="S") return orders