Commit 4bac106a authored by Carlos Antonio Pérez Felipe's avatar Carlos Antonio Pérez Felipe Committed by agb80

feat(account.invoice): se agrega complemento de impuesto local

Se esta trabajando en el complemento de impuesto local, aun no se ha concluido con la integración
del complemento ya que surgieron algunas dudas en el calculo del atributo TotalRetenciones del
elemento Impuestos locales
parent d3d9be93
Pipeline #15385 passed with stage
in 1 minute and 44 seconds
......@@ -50,6 +50,7 @@ class AccountInvoice(models.Model):
- self.descuento
+ self.impuestos["total_traslados"]
+ self.impuestos["total_retenciones"]
+ self.impuestos["total_locales"]
)
@property
......@@ -60,8 +61,10 @@ class AccountInvoice(models.Model):
taxes = {
"traslados": [],
"retenciones": [],
"locales": [],
"total_traslados": 0.0,
"total_retenciones": 0.0,
"total_locales": 0.0,
}
for line in self.invoice_line:
......@@ -89,12 +92,16 @@ class AccountInvoice(models.Model):
# Classify taxes for CFDI
for dummy, tax in tax_grouped.iteritems():
if tax.amount >= 0:
taxes["traslados"].append(tax)
taxes["total_traslados"] += tax.amount
if tax.group in ["IVA", "IEPS"]:
if tax.amount >= 0:
taxes["traslados"].append(tax)
taxes["total_traslados"] += tax.amount
else:
taxes["retenciones"].append(tax)
taxes["total_retenciones"] += tax.amount
else:
taxes["retenciones"].append(tax)
taxes["total_retenciones"] += tax.amount
taxes["locales"].append(tax)
taxes["total_locales"] += tax.amount
return taxes
# pylint: disable=W0212
......@@ -463,12 +470,15 @@ class AccountInvoiceLine(models.Model):
def impuestos(self):
"""Return computed taxes for display on CFDI"""
self.ensure_one()
taxes = {"traslados": [], "retenciones": []}
taxes = {"traslados": [], "retenciones": [], "locales": []}
for tax in self.export_invoice_line_for_xml().taxes:
if tax.amount >= 0:
taxes["traslados"].append(tax)
if tax.group in ["IVA", "IEPS"]:
if tax.amount >= 0:
taxes["traslados"].append(tax)
else:
taxes["retenciones"].append(tax)
else:
taxes["retenciones"].append(tax)
taxes["locales"].append(tax)
return taxes
@property
......
<?xml version="1.0" encoding="UTF-8"?>
{% python setLang(lang or 'en_US') %}
{% with
taxes=o.impuestos ;
is_local_taxes=bool(taxes["total_locales"]) ;
%}
<cfdi:Comprobante
xsi:schemaLocation="http://www.sat.gob.mx/cfd/3 http://www.sat.gob.mx/sitio_internet/cfd/3/cfdv33.xsd"
xmlns:cfdi="http://www.sat.gob.mx/cfd/3"
xsi:schemaLocation="
http://www.sat.gob.mx/cfd/3
http://www.sat.gob.mx/sitio_internet/cfd/3/cfdv33.xsd
{% if is_local_taxes %}
http://www.sat.gob.mx/implocal
http://www.sat.gob.mx/sitio_internet/cfd/implocal/implocal.xsd
{% end %}
"
{% if is_local_taxes %}
xmlns:implocal="http://www.sat.gob.mx/implocal"
{% end %}
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
Version="3.3"
{% if o.journal_id.sequence_id.prefix %}
......@@ -165,7 +179,6 @@
</cfdi:Concepto>
{% end %}
</cfdi:Conceptos>
{% with taxes=o.impuestos %}
{% if sum_field(taxes['traslados'], 'base') or sum_field(taxes['retenciones'], 'base') %}
<cfdi:Impuestos
TotalImpuestosTrasladados="${ '{0:.2f}'.format(taxes.total_traslados) }"
......@@ -205,5 +218,23 @@
{% end %}
</cfdi:Impuestos>
{% end %}
{% if is_local_taxes %}
<cfdi:Complemento>
<implocal:ImpuestosLocales
version="1.0"
TotaldeTraslados="${ '{0:.2f}'.format(sumif(taxes.locales, 'amount', [('amount', '>', 0)])) }"
TotaldeRetenciones="${ '{0:.2f}'.format(abs(sumif(taxes.locales, 'amount', [('amount', '<', 0)]))) }"
>
{% for tax_line in taxes.locales %}
{% if tax_line.amount > 0 %}
<implocal:TrasladosLocales ImpLocTrasladado="${ html_escape(tax_line.name) }" TasadeTraslado="${ '{0:.2f}'.format(tax_line.TasaOCuota * 100) }" Importe="${ '{0:.2f}'.format(tax_line.amount) }"/>
{% end %}
{% if tax_line.amount < 0 %}
<implocal:RetencionesLocales ImpLocRetenido="${ html_escape(tax_line.name) }" TasadeRetencion="${ '{0:.2f}'.format(abs(tax_line.TasaOCuota * 100)) }" Importe="${ '{0:.2f}'.format(abs(tax_line.amount)) }"/>
{% end %}
{% end %}
</implocal:ImpuestosLocales>
</cfdi:Complemento>
{% end %}
</cfdi:Comprobante>
{% end %}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment