From 71978ee5ace3b90552dbc7e4125540e984af1272 Mon Sep 17 00:00:00 2001
From: "antonio.manzano" <antonio.manzano@openpyme.mx>
Date: Tue, 11 Apr 2023 12:38:28 -0600
Subject: [PATCH] fix(l10n.mx.facturae): se modifico el objeto impuesto
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Se modifico el objetoImp ya que una factura generada con el 100 por ciento de descuento tiene que
ser sin objeto de impuesto, se agrego la condición para estos casos.
---
 .../templates/account_invoice.txt             | 104 +++++++++---------
 1 file changed, 54 insertions(+), 50 deletions(-)

diff --git a/l10n_mx_facturae/templates/account_invoice.txt b/l10n_mx_facturae/templates/account_invoice.txt
index da97e52d93..0372bf0a69 100644
--- a/l10n_mx_facturae/templates/account_invoice.txt
+++ b/l10n_mx_facturae/templates/account_invoice.txt
@@ -130,55 +130,59 @@
             ValorUnitario="${ line.valorunitario }"
             Importe="${ '{0:.2f}'.format(line.importe) }"
             Descuento="${ '{0:.2f}'.format(line.descuento) }"
-            ObjetoImp="02" >
-            {% with taxes=line.impuestos %}
-            {% if sum_field(taxes['traslados'], 'base') or sum_field(taxes['retenciones'], 'base') %}
-            <cfdi:Impuestos>
-                {% if taxes.traslados %}
-                <cfdi:Traslados>
-                {% for tax in taxes.traslados %}
-                    <cfdi:Traslado
-                        Base="${ '{0:.2f}'.format(tax.base) }"
-                        {% choose tax.group %}
-                            {% when 'ISR' %}Impuesto="001"{% end %}
-                            {% when 'IVA' %}Impuesto="002"{% end %}
-                            {% when 'IEPS' %}Impuesto="003"{% end %}
-                            {% otherwise %}${ validationerror(_('Missing SAT code for tax: {t}').format(t=tax.name)) }{% end %}
-                        {% end %}
-                        {% choose tax.type %}
-                            {% when 'percent' %}TipoFactor="Tasa"{% end %}
-                            {% when 'fixed' %}TipoFactor="Cuota"{% end %}
-                            {% when 'none' %}TipoFactor="Exento"{% end %}
-                        {% end %}
-                        {% if tax.type != 'none' %}
-                        TasaOCuota="${ '{0:.6f}'.format(tax.TasaOCuota) }"
-                        Importe="${ '{0:.2f}'.format(tax.amount) }"
-                        {% end %}/>
-                {% end %}
-                </cfdi:Traslados>
-                {% end %}
-                {% if taxes.retenciones %}
-                <cfdi:Retenciones>
-                {% for tax in taxes.retenciones %}
-                    <cfdi:Retencion
-                        Base="${ '{0:.2f}'.format(tax.base) }"
-                        {% choose tax.group %}
-                            {% when 'ISR' %}Impuesto="001"{% end %}
-                            {% when 'IVA' %}Impuesto="002"{% end %}
-                            {% when 'IEPS' %}Impuesto="003"{% end %}
-                            {% otherwise %}${ validationerror(_('Missing SAT code for tax: {t}').format(t=tax.name)) }{% end %}
-                        {% end %}
-                        {% choose tax.type %}
-                            {% when 'percent' %}TipoFactor="Tasa"{% end %}
-                            {% when 'fixed' %}TipoFactor="Cuota"{% end %}
-                        {% end %}
-                        TasaOCuota="${ '{0:.6f}'.format(tax.TasaOCuota) }"
-                        Importe="${ '{0:.2f}'.format(abs(tax.amount)) }" />
-                {% end %}
-                </cfdi:Retenciones>
-                {% end %}
-            </cfdi:Impuestos>
-            {% end %}
+            {% with 
+            	taxes = line.impuestos
+            	objetoimp = sum_field(taxes['traslados'], 'base') or sum_field(taxes['retenciones'], 'base')
+           	%}
+            ObjetoImp="${ '02' if objetoimp else '01' }"
+            >
+		        {% if objetoimp %}
+				    <cfdi:Impuestos>
+				        {% if taxes.traslados %}
+				        <cfdi:Traslados>
+				        {% for tax in taxes.traslados %}
+				            <cfdi:Traslado
+				                Base="${ '{0:.2f}'.format(tax.base) }"
+				                {% choose tax.group %}
+				                    {% when 'ISR' %}Impuesto="001"{% end %}
+				                    {% when 'IVA' %}Impuesto="002"{% end %}
+				                    {% when 'IEPS' %}Impuesto="003"{% end %}
+				                    {% otherwise %}${ validationerror(_('Missing SAT code for tax: {t}').format(t=tax.name)) }{% end %}
+				                {% end %}
+				                {% choose tax.type %}
+				                    {% when 'percent' %}TipoFactor="Tasa"{% end %}
+				                    {% when 'fixed' %}TipoFactor="Cuota"{% end %}
+				                    {% when 'none' %}TipoFactor="Exento"{% end %}
+				                {% end %}
+				                {% if tax.type != 'none' %}
+				                TasaOCuota="${ '{0:.6f}'.format(tax.TasaOCuota) }"
+				                Importe="${ '{0:.2f}'.format(tax.amount) }"
+				                {% end %}/>
+				        {% end %}
+				        </cfdi:Traslados>
+				        {% end %}
+				        {% if taxes.retenciones %}
+				        <cfdi:Retenciones>
+				        {% for tax in taxes.retenciones %}
+				            <cfdi:Retencion
+				                Base="${ '{0:.2f}'.format(tax.base) }"
+				                {% choose tax.group %}
+				                    {% when 'ISR' %}Impuesto="001"{% end %}
+				                    {% when 'IVA' %}Impuesto="002"{% end %}
+				                    {% when 'IEPS' %}Impuesto="003"{% end %}
+				                    {% otherwise %}${ validationerror(_('Missing SAT code for tax: {t}').format(t=tax.name)) }{% end %}
+				                {% end %}
+				                {% choose tax.type %}
+				                    {% when 'percent' %}TipoFactor="Tasa"{% end %}
+				                    {% when 'fixed' %}TipoFactor="Cuota"{% end %}
+				                {% end %}
+				                TasaOCuota="${ '{0:.6f}'.format(tax.TasaOCuota) }"
+				                Importe="${ '{0:.2f}'.format(abs(tax.amount)) }" />
+				        {% end %}
+				        </cfdi:Retenciones>
+				        {% end %}
+				    </cfdi:Impuestos>
+		        {% end %}
             {% end %}
             {% if line.cfdi_cuentapredial %}
             <cfdi:CuentaPredial Numero="${ line.cfdi_cuentapredial }"/>
@@ -262,4 +266,4 @@
         </cfdi:Complemento>
     {% end %}
 </cfdi:Comprobante>
-{% end %}
\ No newline at end of file
+{% end %}
-- 
GitLab