Skip to content

Commit

Permalink
Fixed TotalImpuestosTrasladados
Browse files Browse the repository at this point in the history
  • Loading branch information
satcfdi committed Jan 9, 2025
1 parent 97a9415 commit 4cb0aad
Show file tree
Hide file tree
Showing 20 changed files with 498 additions and 51 deletions.
8 changes: 6 additions & 2 deletions satcfdi/create/compute.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,15 @@ def make_impuestos(conceptos):

if retenciones := impuestos.get('Retenciones'):
impuestos['Retenciones'] = retenciones
impuestos['TotalImpuestosRetenidos'] = sum(i["Importe"] for i in retenciones if i["Importe"])
imp = list(i["Importe"] for i in retenciones if i["Importe"] is not None)
if imp:
impuestos['TotalImpuestosRetenidos'] = sum(imp)

if traslados := impuestos.get('Traslados'):
impuestos['Traslados'] = traslados
impuestos['TotalImpuestosTrasladados'] = sum(i["Importe"] for i in traslados if i["Importe"])
imp = list(i["Importe"] for i in traslados if i["Importe"] is not None)
if imp:
impuestos['TotalImpuestosTrasladados'] = sum(imp)

return impuestos or None

Expand Down
47 changes: 47 additions & 0 deletions tests/test_create_cfdi40.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,3 +377,50 @@ def test_nomina():
invoice.sign(signer)

verify_invoice(invoice, f"{xml_file}")


def test_iva_exento():
rfc = 'xiqb891116qe4'
signer = get_signer(rfc)

invoice = cfdi40.Comprobante(
emisor=cfdi40.Emisor(
rfc=signer.rfc,
nombre=signer.legal_name,
regimen_fiscal="601"
),
lugar_expedicion="56820",
fecha=datetime.fromisoformat("2020-01-01T22:40:38"),
receptor=cfdi40.Receptor(
rfc='KIJ0906199R1',
nombre='KIJ, S.A DE C.V.',
uso_cfdi='G03',
domicilio_fiscal_receptor="59820",
regimen_fiscal_receptor="601"
),
metodo_pago='PPD',
serie="A",
folio="123456",
conceptos=[
cfdi40.Concepto(
cuenta_predial='1234567890',
clave_prod_serv='10101702',
cantidad=Decimal('1.00'),
clave_unidad='E48',
descripcion='SERVICIOS DE FACTURACION',
valor_unitario=Decimal('15390.30'),
impuestos=cfdi40.Impuestos(
traslados=cfdi40.Traslado(
impuesto=Impuesto.IVA,
tipo_factor=TipoFactor.EXENTO,
importe=None,
tasa_o_cuota=None
)
),
)
]
)
invoice.sign(signer)

verify_invoice(invoice, "iva_exento")

Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@
'Fecha': datetime.datetime(2020, 1, 1, 22, 40, 38),
'Folio': '123456',
'FormaPago': None,
'Impuestos': {'TotalImpuestosTrasladados': 0,
'Traslados': [{'Base': Decimal('15390.30'),
'Impuestos': {'Traslados': [{'Base': Decimal('15390.30'),
'Importe': None,
'Impuesto': <Impuesto.IVA: '002'>,
'TasaOCuota': None,
Expand All @@ -52,7 +51,7 @@
'ResidenciaFiscal': None,
'Rfc': 'KIJ0906199R1',
'UsoCFDI': 'G03'},
'Sello': 'ITnWt9XD28y3p9TifH554OrrvBoPcnsr+v33Tkhq+P+XD1tqg3dsKnC6GqYJezTdCbdpS9+VOaAK6b7/0Efw5KmwRKJ/zXHcdaG5vjHNoAljH+HHu/t4gbK+ToSkLnT2mSEr8dbGeUWMUXsu/yTonZQfw0aXcd8NXxwCJeB/EH1sAlAesZ1uMMVdcNhbOfiDPwFuMuGaKvTXj6pRpbU4SdZ5BKboqyOBfiBtXC+B/n8R/NoniMs+SAhPj9QF4hFPh5v62eFFrP1/KeK16uwHhUaF4VQmqvIgKmoh84kaFhXLXRLD80q0ShgfnYWof8uDZH7o7fIon02FMDUxSZdmgQ==',
'Sello': 'aR5o+/+GiFVZG1csiz01f1IuDtW/R/FpgKHViqpF/61rb//fzaoea2aqj8Z4PSiduekpZW+GFC8g/yQrVbKTBeymIyJinBogcqChMVlu9wIw2CbVYk7zJ3ts+ieD6e1eoyc7w0BJk3WfHrdOwEQY8saSVItouOZ71vMWuvGGpRyhx+xzFJM3W2C85KdXrH/baS3Cxo89ekpKhpU9Qh4cP8YnVm6kNjUyx2QIfdjHN6Tx5d2NKofvHgvJx2cTTALNWR0sbLpJeBZk7pt8mg/nzyEqcUQ1q/jYl3wmzlq67OIJuefrp0GGi6b1zncwV4vWWZ15KOrt4TpGRCdHVwuXQg==',
'Serie': 'A',
'SubTotal': Decimal('15390.30'),
'TipoCambio': None,
Expand Down
4 changes: 2 additions & 2 deletions tests/test_create_cfdi40/h&e951128469_ingreso_exento.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version='1.0' encoding='UTF-8'?>
<cfdi:Comprobante xmlns:cfdi="http://www.sat.gob.mx/cfd/4" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" Version="4.0" Serie="A" Folio="123456" Fecha="2020-01-01T22:40:38" Sello="ITnWt9XD28y3p9TifH554OrrvBoPcnsr+v33Tkhq+P+XD1tqg3dsKnC6GqYJezTdCbdpS9+VOaAK6b7/0Efw5KmwRKJ/zXHcdaG5vjHNoAljH+HHu/t4gbK+ToSkLnT2mSEr8dbGeUWMUXsu/yTonZQfw0aXcd8NXxwCJeB/EH1sAlAesZ1uMMVdcNhbOfiDPwFuMuGaKvTXj6pRpbU4SdZ5BKboqyOBfiBtXC+B/n8R/NoniMs+SAhPj9QF4hFPh5v62eFFrP1/KeK16uwHhUaF4VQmqvIgKmoh84kaFhXLXRLD80q0ShgfnYWof8uDZH7o7fIon02FMDUxSZdmgQ==" NoCertificado="30001000000400002460" Certificado="MIIGAjCCA+qgAwIBAgIUMzAwMDEwMDAwMDA0MDAwMDI0NjAwDQYJKoZIhvcNAQELBQAwggErMQ8wDQYDVQQDDAZBQyBVQVQxLjAsBgNVBAoMJVNFUlZJQ0lPIERFIEFETUlOSVNUUkFDSU9OIFRSSUJVVEFSSUExGjAYBgNVBAsMEVNBVC1JRVMgQXV0aG9yaXR5MSgwJgYJKoZIhvcNAQkBFhlvc2Nhci5tYXJ0aW5lekBzYXQuZ29iLm14MR0wGwYDVQQJDBQzcmEgY2VycmFkYSBkZSBjYWRpejEOMAwGA1UEEQwFMDYzNzAxCzAJBgNVBAYTAk1YMRkwFwYDVQQIDBBDS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IOOcmHFHHc8mmVD3dPsUTrDxlo1qWR2qwrvrUn38bxkEF5IJK/XKcG0LOupl67V2gvnrm5bVkT9kJuYjYHdPFuSao4yEJhzHnMHOvT6rC3hhjywo6QGegQTuR+oTrwHQeU8SplNqkwd6k/GWL7Ba/2bVhH79lB4QpjuO2BXip0sHhLbctwu98Sp1FSiaooDlMzQeQoVWW8QgUQp15LaClsOTZRnXxztOR/h6cd25XQezdxqEoV0rS9BW+sgABPQNXDRWK87aeJ3R5lByjUhbt0eONod42l/emAiDE9S85tztQ4KkvMFA3e0vIth70sinS5eV/j1l4Ws+Ft/pdNA/AP3a2R6b+Lw4P7hCBVLtunx8pbh15KzX5g947JN5KVhMKvnqciCoMC9GowLzua/VNJX5pPiKXD6fm5bljW5JQ5F4Ue30Hve6lmftLGDXtOCDfj74+Zs3f3Y9gXkPAsK4y2WyZ1Xpw9dAIJJv5HajJwxbQVP2B48aN0ai46Dc6tQEp+Oa4oNHTRRyNNlqXwEb+IGtQ4FwiL13c55gOaSie1buy26a0yAO3ogcDfNyTcbfC73W9R0Zi4gsb+6xLuHZOLTJWUWLY9bE43P++KbWCGKz0uwIA3u" SubTotal="15390.30" Moneda="MXN" Total="15390.30" TipoDeComprobante="I" Exportacion="01" MetodoPago="PPD" LugarExpedicion="56820" xsi:schemaLocation="http://www.sat.gob.mx/cfd/4 http://www.sat.gob.mx/sitio_internet/cfd/4/cfdv40.xsd">
<cfdi:Comprobante xmlns:cfdi="http://www.sat.gob.mx/cfd/4" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" Version="4.0" Serie="A" Folio="123456" Fecha="2020-01-01T22:40:38" Sello="aR5o+/+GiFVZG1csiz01f1IuDtW/R/FpgKHViqpF/61rb//fzaoea2aqj8Z4PSiduekpZW+GFC8g/yQrVbKTBeymIyJinBogcqChMVlu9wIw2CbVYk7zJ3ts+ieD6e1eoyc7w0BJk3WfHrdOwEQY8saSVItouOZ71vMWuvGGpRyhx+xzFJM3W2C85KdXrH/baS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L13c55gOaSie1buy26a0yAO3ogcDfNyTcbfC73W9R0Zi4gsb+6xLuHZOLTJWUWLY9bE43P++KbWCGKz0uwIA3u" SubTotal="15390.30" Moneda="MXN" Total="15390.30" TipoDeComprobante="I" Exportacion="01" MetodoPago="PPD" LugarExpedicion="56820" xsi:schemaLocation="http://www.sat.gob.mx/cfd/4 http://www.sat.gob.mx/sitio_internet/cfd/4/cfdv40.xsd">
<cfdi:Emisor Rfc="H&amp;E951128469" Nombre="HERRERIA &amp; ELECTRICOS" RegimenFiscal="601"/>
<cfdi:Receptor Rfc="KIJ0906199R1" Nombre="KIJ, S.A DE C.V." DomicilioFiscalReceptor="59820" RegimenFiscalReceptor="601" UsoCFDI="G03"/>
<cfdi:Conceptos>
Expand All @@ -12,7 +12,7 @@
<cfdi:CuentaPredial Numero="1234567890"/>
</cfdi:Concepto>
</cfdi:Conceptos>
<cfdi:Impuestos TotalImpuestosTrasladados="0">
<cfdi:Impuestos>
<cfdi:Traslados>
<cfdi:Traslado Base="15390.30" Impuesto="002" TipoFactor="Exento"/>
</cfdi:Traslados>
Expand Down
Loading

0 comments on commit 4cb0aad

Please sign in to comment.