Skip to content

Commit

Permalink
arreglados errores al enviar algunas sesiones al sii con casos que no…
Browse files Browse the repository at this point in the history
… se habían contemplado: (#34)

- 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.
  • Loading branch information
almumu authored and docker-odoo committed Feb 29, 2024
1 parent ff42530 commit a8f8ab4
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 1 deletion.
8 changes: 7 additions & 1 deletion l10n_es_aeat_sii_pos_summary/i18n/es.po
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions l10n_es_aeat_sii_pos_summary/models/account_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
12 changes: 12 additions & 0 deletions l10n_es_aeat_sii_pos_summary/models/pos_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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(
Expand All @@ -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
Expand Down

0 comments on commit a8f8ab4

Please sign in to comment.