diff --git a/l10n_mx_facturae/templates/account_invoice.txt b/l10n_mx_facturae/templates/account_invoice.txt index da97e52d93554a09ae000957a36a740fc6e50a92..0372bf0a6956665fa52955043908593cfc2a042c 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 %}