-
-
Notifications
You must be signed in to change notification settings - Fork 520
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FIX] l10n_es_aeat_mod190: Multiple fixes #3828
base: 16.0
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -545,129 +545,149 @@ | |
# Calculo campos SIN incapacidad | ||
@api.depends("report_id", "report_id.tax_line_ids", "discapacidad") | ||
def _compute_percepciones_dinerarias(self): | ||
for item in self.filtered( | ||
lambda x: not x.discapacidad or x.discapacidad == "0" | ||
): | ||
for item in self: | ||
if item.discapacidad and item.discapacidad != "0": | ||
item.percepciones_dinerarias = 0.0 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. En lugar de esto, se puede hacer al principio de todo un |
||
continue | ||
tax_lines = item.report_id.tax_line_ids.filtered( | ||
lambda x: x.field_number in (11, 15) and x.res_id == item.report_id.id | ||
) | ||
value = 0.0 | ||
for move_line in tax_lines.move_line_ids: | ||
for move_line in tax_lines.move_line_ids.filtered(item._check_lines): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Esto debería llevar There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. En todos lados se usa el mismo filtro que encima es grande. Lo he pasado al final There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sí, pero yo te digo de la forma en la que se debería implementar. Mira también lo del tema de rendimiento. |
||
value += move_line.debit - move_line.credit | ||
item.percepciones_dinerarias = value | ||
|
||
@api.depends("report_id", "report_id.tax_line_ids", "discapacidad") | ||
def _compute_retenciones_dinerarias(self): | ||
for item in self.filtered( | ||
lambda x: not x.discapacidad or x.discapacidad == "0" | ||
): | ||
for item in self: | ||
if item.discapacidad and item.discapacidad != "0": | ||
item.retenciones_dinerarias = 0.0 | ||
continue | ||
tax_lines = item.report_id.tax_line_ids.filtered( | ||
lambda x: x.field_number in (12, 16) and x.res_id == item.report_id.id | ||
) | ||
value = 0.0 | ||
for move_line in tax_lines.move_line_ids: | ||
for move_line in tax_lines.move_line_ids.filtered(item._check_lines): | ||
value += move_line.credit - move_line.debit | ||
item.retenciones_dinerarias = value | ||
|
||
@api.depends("report_id", "report_id.tax_line_ids", "discapacidad") | ||
def _compute_percepciones_en_especie(self): | ||
for item in self.filtered( | ||
lambda x: not x.discapacidad or x.discapacidad == "0" | ||
): | ||
for item in self: | ||
if item.discapacidad and item.discapacidad != "0": | ||
item.percepciones_en_especie = 0.0 | ||
continue | ||
tax_lines = item.report_id.tax_line_ids.filtered( | ||
lambda x: x.field_number == 13 and x.res_id == item.report_id.id | ||
) | ||
pde = rde = 0.0 | ||
for move_line in tax_lines.move_line_ids: | ||
for move_line in tax_lines.move_line_ids.filtered(item._check_lines): | ||
pde += move_line.debit - move_line.credit | ||
rde += move_line.credit - move_line.debit | ||
item.percepciones_en_especie = pde - rde | ||
|
||
@api.depends("report_id", "report_id.tax_line_ids", "discapacidad") | ||
def _compute_ingresos_a_cuenta_efectuados(self): | ||
for item in self.filtered( | ||
lambda x: not x.discapacidad or x.discapacidad == "0" | ||
): | ||
for item in self: | ||
if item.discapacidad and item.discapacidad != "0": | ||
item.ingresos_a_cuenta_efectuados = 0.0 | ||
continue | ||
tax_lines = item.report_id.tax_line_ids.filtered( | ||
lambda x: x.field_number == 13 and x.res_id == item.report_id.id | ||
) | ||
value = 0.0 | ||
for move_line in tax_lines.move_line_ids: | ||
for move_line in tax_lines.move_line_ids.filtered(item._check_lines): | ||
value += move_line.debit - move_line.credit | ||
item.ingresos_a_cuenta_efectuados = value | ||
|
||
@api.depends("report_id", "report_id.tax_line_ids", "discapacidad") | ||
def _compute_ingresos_a_cuenta_repercutidos(self): | ||
for item in self.filtered( | ||
lambda x: not x.discapacidad or x.discapacidad == "0" | ||
): | ||
for item in self: | ||
if item.discapacidad and item.discapacidad != "0": | ||
item.ingresos_a_cuenta_repercutidos = 0.0 | ||
continue | ||
tax_lines = item.report_id.tax_line_ids.filtered( | ||
lambda x: x.field_number == 13 and x.res_id == item.report_id.id | ||
) | ||
value = 0.0 | ||
for move_line in tax_lines.move_line_ids: | ||
for move_line in tax_lines.move_line_ids.filtered(item._check_lines): | ||
value += move_line.credit - move_line.debit | ||
item.ingresos_a_cuenta_repercutidos = value | ||
|
||
# Calculo campos CON incapacidad | ||
@api.depends("report_id", "report_id.tax_line_ids", "discapacidad") | ||
def _compute_percepciones_dinerarias_incap(self): | ||
"""La misma lógica que para percepciones_dinerarias.""" | ||
for item in self.filtered(lambda x: x.discapacidad or x.discapacidad != "0"): | ||
for item in self: | ||
if not item.discapacidad or item.discapacidad == "0": | ||
item.percepciones_dinerarias_incap = 0.0 | ||
continue | ||
tax_lines = item.report_id.tax_line_ids.filtered( | ||
lambda x: x.field_number in (11, 15) and x.res_id == item.report_id.id | ||
) | ||
value = 0.0 | ||
for move_line in tax_lines.move_line_ids: | ||
for move_line in tax_lines.move_line_ids.filtered(item._check_lines): | ||
value += move_line.debit - move_line.credit | ||
item.percepciones_dinerarias_incap = value | ||
|
||
@api.depends("report_id", "report_id.tax_line_ids", "discapacidad") | ||
def _compute_retenciones_dinerarias_incap(self): | ||
"""La misma lógica que para retenciones_dinerarias.""" | ||
for item in self.filtered(lambda x: x.discapacidad or x.discapacidad != "0"): | ||
for item in self: | ||
if not item.discapacidad or item.discapacidad == "0": | ||
item.retenciones_dinerarias_incap = 0.0 | ||
continue | ||
tax_lines = item.report_id.tax_line_ids.filtered( | ||
lambda x: x.field_number in (12, 16) and x.res_id == item.report_id.id | ||
) | ||
value = 0.0 | ||
for move_line in tax_lines.move_line_ids: | ||
for move_line in tax_lines.move_line_ids.filtered(item._check_lines): | ||
value += move_line.credit - move_line.debit | ||
item.retenciones_dinerarias_incap = value | ||
|
||
@api.depends("report_id", "report_id.tax_line_ids", "discapacidad") | ||
def _compute_percepciones_en_especie_incap(self): | ||
"""La misma lógica que para percepciones_en_especie.""" | ||
for item in self.filtered(lambda x: x.discapacidad or x.discapacidad != "0"): | ||
for item in self: | ||
if not item.discapacidad or item.discapacidad == "0": | ||
item.percepciones_en_especie_incap = 0.0 | ||
continue | ||
tax_lines = item.report_id.tax_line_ids.filtered( | ||
lambda x: x.field_number == 13 and x.res_id == item.report_id.id | ||
) | ||
pde = rde = 0.0 | ||
for move_line in tax_lines.move_line_ids: | ||
for move_line in tax_lines.move_line_ids.filtered(item._check_lines): | ||
pde += move_line.debit - move_line.credit | ||
rde += move_line.credit - move_line.debit | ||
item.percepciones_en_especie_incap = pde - rde | ||
|
||
@api.depends("report_id", "report_id.tax_line_ids", "discapacidad") | ||
def _compute_ingresos_a_cuenta_efectuados_incap(self): | ||
"""La misma lógica que para ingresos_a_cuenta_efectuados.""" | ||
for item in self.filtered(lambda x: x.discapacidad or x.discapacidad != "0"): | ||
for item in self: | ||
if not item.discapacidad or item.discapacidad == "0": | ||
item.ingresos_a_cuenta_efectuados_incap = 0.0 | ||
continue | ||
tax_lines = item.report_id.tax_line_ids.filtered( | ||
lambda x: x.field_number == 13 and x.res_id == item.report_id.id | ||
) | ||
value = 0.0 | ||
for move_line in tax_lines.move_line_ids: | ||
for move_line in tax_lines.move_line_ids.filtered(item._check_lines): | ||
value += move_line.debit - move_line.credit | ||
item.ingresos_a_cuenta_efectuados_incap = value | ||
|
||
@api.depends("report_id", "report_id.tax_line_ids", "discapacidad") | ||
def _compute_ingresos_a_cuenta_repercutidos_incap(self): | ||
"""La misma lógica que para ingresos_a_cuenta_repercutidos.""" | ||
for item in self.filtered(lambda x: x.discapacidad or x.discapacidad != "0"): | ||
for item in self: | ||
if not item.discapacidad or item.discapacidad == "0": | ||
item.ingresos_a_cuenta_repercutidos_incap = 0.0 | ||
continue | ||
tax_lines = item.report_id.tax_line_ids.filtered( | ||
lambda x: x.field_number == 13 and x.res_id == item.report_id.id | ||
) | ||
value = 0.0 | ||
for move_line in tax_lines.move_line_ids: | ||
for move_line in tax_lines.move_line_ids.filtered(item._check_lines): | ||
value += move_line.credit - move_line.debit | ||
item.ingresos_a_cuenta_repercutidos_incap = value | ||
|
||
|
@@ -686,3 +706,21 @@ | |
def onchange_aeat_perception_key_id(self): | ||
if self.aeat_perception_key_id: | ||
self.aeat_perception_subkey_id = False | ||
|
||
def _check_lines(self, line): | ||
return ( | ||
line.partner_id == self.partner_id | ||
and ( | ||
(line.aeat_perception_key_id or line.partner_id.aeat_perception_key_id) | ||
== self.aeat_perception_key_id | ||
) | ||
and ( | ||
(line.aeat_perception_subkey_id) | ||
or ( | ||
not line.aeat_perception_key_id | ||
and line.partner_id.aeat_perception_subkey_id | ||
) | ||
or self.env["l10n.es.aeat.report.perception.subkey"] | ||
) | ||
== self.aeat_perception_subkey_id | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Esta línea no hay que quitarla.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Si que hay que quitarla. No se muestran las lineas de impuestos
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Vale, pero entonces lo que hay es que cambiar la condición. Lo que no se debe computar es para las secciones, notas, etc. Hay que mirar también qué pasa con el resto de líneas, como COGS, anticipos, payment terms, etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
De hecho, en general el approach yo lo quitaría. Si por ejemplo introduzco nóminas, debería ponerse en la clave B,pero esta parte del código lo bloquea todo 😭
Mi siguerencia seria dejarlo como
(not line.move_id.is_invoice() or line.display_type in ["product","tax"])
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sí, pues a eso me refería.