Skip to content

Commit ab1b85c

Browse files
committed
[IMP] l10n_es_aeat_sii_invoice_summary: Añadir _is_aeat_unidentified_document para aclarar uso de _is_aeat_simplified_invoice
1 parent 15be1c7 commit ab1b85c

8 files changed

Lines changed: 29 additions & 18 deletions

File tree

l10n_es_aeat/models/aeat_mixin.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,16 @@ def _change_date_format(self, date):
102102
def _get_document_period(self):
103103
return "%02d" % fields.Date.to_date(self._get_document_fiscal_date()).month
104104

105+
# TODO: Remove in 20.0 migration and use _is_aeat_unidentified_document
105106
def _is_aeat_simplified_invoice(self):
106107
"""Inheritable method to allow control when an
107108
invoice are simplified or normal"""
108109
return self._aeat_get_partner().aeat_simplified_invoice
109110

111+
def _is_aeat_unidentified_document(self):
112+
"""Inheritable method to allow control when an document is identified"""
113+
return self._is_aeat_simplified_invoice()
114+
110115
def _get_document_amount_total(self):
111116
raise NotImplementedError()
112117

@@ -154,8 +159,8 @@ def _aeat_check_exceptions(self):
154159
self.ensure_one()
155160
partner = self._aeat_get_partner()
156161
country_code = self._get_aeat_country_code()
157-
is_simplified_invoice = self._is_aeat_simplified_invoice()
158-
if country_code == "ES" and not partner.vat and not is_simplified_invoice:
162+
is_unidentified_document = self._is_aeat_unidentified_document()
163+
if country_code == "ES" and not partner.vat and not is_unidentified_document:
159164
raise UserError(_("The partner has not a VAT configured."))
160165
if not self.company_id.chart_template:
161166
raise UserError(

l10n_es_aeat_sii_invoice_summary/models/account_move.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ def _is_aeat_summary_invoice(self):
2222
return True
2323
return False
2424

25-
def _is_aeat_simplified_invoice(self):
25+
def _is_aeat_unidentified_document(self):
2626
# En el SII, una factura resumen (F4) debe considerarse, a efectos de estructura
2727
# y validaciones, equivalente a una factura simplificada (F2), compartiendo
2828
# todas sus restricciones y campos obligatorios, con la única diferencia de
2929
# requerir la clave TipoFactura = F4 y el campo adicional
3030
# NumSerieFacturaEmisorResumenFin
31-
return self.is_invoice_summary or super()._is_aeat_simplified_invoice()
31+
return self.is_invoice_summary or super()._is_aeat_unidentified_document()
3232

3333
def _get_sii_invoice_type(self):
3434
invoice_type = super()._get_sii_invoice_type()

l10n_es_aeat_sii_oca/models/account_move.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -430,13 +430,13 @@ def _get_sii_invoice_type(self):
430430
if self.move_type in ["in_invoice", "in_refund"]:
431431
invoice_type = "R4" if self.move_type == "in_refund" else "F1"
432432
elif self.move_type in ["out_invoice", "out_refund"]:
433-
is_simplified = self._is_aeat_simplified_invoice()
434-
invoice_type = "F2" if is_simplified else "F1"
433+
is_unidentified_document = self._is_aeat_unidentified_document()
434+
invoice_type = "F2" if is_unidentified_document else "F1"
435435
if self.move_type == "out_refund":
436436
if self.sii_refund_specific_invoice_type:
437437
invoice_type = self.sii_refund_specific_invoice_type
438438
else:
439-
invoice_type = "R5" if is_simplified else "R1"
439+
invoice_type = "R5" if is_unidentified_document else "R1"
440440
return invoice_type
441441

442442
def _get_aeat_invoice_dict_out(self, cancel=False):

l10n_es_aeat_sii_oca/models/sii_mixin.py

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -347,27 +347,21 @@ def _get_sii_gen_type(self):
347347
res = 1
348348
return res
349349

350-
def _is_aeat_simplified_invoice(self):
351-
"""Inheritable method to allow control when an
352-
invoice are simplified or normal"""
353-
partner = self._aeat_get_partner()
354-
return partner.aeat_simplified_invoice
355-
356350
def _aeat_check_exceptions(self):
357351
"""Inheritable method for exceptions control when sending SII invoices."""
358352
res = super()._aeat_check_exceptions()
359353
if self.company_id.sii_enabled:
360354
gen_type = self._get_sii_gen_type()
361355
partner = self._aeat_get_partner()
362356
country_code = self._get_aeat_country_code()
363-
is_simplified_invoice = self._is_aeat_simplified_invoice()
357+
is_unidentified_document = self._is_aeat_unidentified_document()
364358
if (
365359
(gen_type != 3 or country_code == "ES")
366360
and not partner.vat
367361
and not (
368362
partner.aeat_identification_type and partner.aeat_identification
369363
)
370-
and not is_simplified_invoice
364+
and not is_unidentified_document
371365
):
372366
raise UserError(_("The partner has not a VAT configured."))
373367
if not self.sii_enabled:
@@ -697,7 +691,7 @@ def _get_aeat_invoice_dict_out(self, cancel=False):
697691
company = self.company_id
698692
fiscal_year = self._get_document_fiscal_year()
699693
period = self._get_document_period()
700-
is_simplified_invoice = self._is_aeat_simplified_invoice()
694+
is_unidentified_document = self._is_aeat_unidentified_document()
701695
serial_number = self._get_document_serial_number()
702696
inv_dict = {
703697
"IDFactura": {
@@ -726,7 +720,7 @@ def _get_aeat_invoice_dict_out(self, cancel=False):
726720
if self.sii_macrodata:
727721
inv_dict["FacturaExpedida"].update(Macrodato="S")
728722
exp_dict = inv_dict["FacturaExpedida"]
729-
if not is_simplified_invoice:
723+
if not is_unidentified_document:
730724
# Simplified invoices don't have counterpart
731725
exp_dict["Contraparte"] = {
732726
"NombreRazon": partner.name[0:120],

l10n_es_aeat_sii_oca/tests/test_l10n_es_aeat_sii.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,11 @@ def test_is_aeat_simplified_invoice(self):
443443
self.partner.aeat_simplified_invoice = True
444444
self.assertTrue(self.invoice._is_aeat_simplified_invoice())
445445

446+
def test_is_aeat_unidentified_document(self):
447+
self.assertFalse(self.invoice._is_aeat_unidentified_document())
448+
self.partner.aeat_simplified_invoice = True
449+
self.assertTrue(self.invoice._is_aeat_unidentified_document())
450+
446451
def test_aeat_check_exceptions_case_supplier_simplified(self):
447452
self.partner.aeat_simplified_invoice = True
448453
invoice = self.env["account.move"].create(

l10n_es_pos_sii/models/pos_order.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@ def _aeat_get_partner(self):
8080
def _is_aeat_simplified_invoice(self):
8181
return True
8282

83+
def _is_aeat_unidentified_document(self):
84+
return True
85+
8386
def _get_mapping_key(self):
8487
return "out_invoice"
8588

l10n_es_pos_sii/tests/test_l10n_es_pos_sii.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,3 +388,7 @@ def test_07_export_for_ui_session_is_closed(self):
388388
),
389389
"The session is closed",
390390
)
391+
392+
def test_08_is_aeat_unidentified_document(self):
393+
for order in self.session.order_ids:
394+
self.assertTrue(order._is_aeat_unidentified_document())

l10n_es_verifactu_oca/models/account_move.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ def _compute_verifactu_registration_key(self):
100100
def _get_verifactu_document_type(self):
101101
invoice_type = ""
102102
if self.move_type in ["out_invoice", "out_refund"]:
103-
is_simplified = self._is_aeat_simplified_invoice()
103+
is_simplified = self._is_aeat_unidentified_document()
104104
invoice_type = "F2" if is_simplified else "F1"
105105
if self.move_type == "out_refund":
106106
if self.verifactu_refund_specific_type:

0 commit comments

Comments
 (0)