Skip to content

Commit 06578a8

Browse files
committed
Fixed Accounting Logic, Added Base 16, status Retenciones
1 parent 4cb0aad commit 06578a8

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

satcfdi/accounting/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ class PaymentsDetails(Payment):
104104
def __post_init__(self):
105105
if self.pago:
106106
self.impuestos = self.docto_relacionado.get('ImpuestosDR')
107-
if self.impuestos is None:
107+
if self.impuestos is None and self.comprobante['Version'] == '3.3':
108108
self.impuestos = make_impuestos_dr_parcial(
109109
conceptos=self.comprobante_pagado['Conceptos'],
110110
imp_saldo_ant=self.docto_relacionado['ImpSaldoAnt'],

satcfdi/accounting/process.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ def invoice_def():
130130

131131
'SubTotal': (12, True, lambda i: i["SubTotal"]),
132132
'Descuento': (12, True, lambda i: i.get("Descuento")),
133+
'IVA16 Base': (12, True, lambda i: i.get("Impuestos", {}).get("Traslados", {}).get(IVA16, {}).get("Base")),
133134
'IVA16 Tras': (12, True, lambda i: i.get("Impuestos", {}).get("Traslados", {}).get(IVA16, {}).get("Importe")),
134135
'IVA Ret': (12, True, lambda i: i.get("Impuestos", {}).get("Retenciones", {}).get(Impuesto.IVA, {}).get("Importe")),
135136
'ISR Ret': (12, True, lambda i: i.get("Impuestos", {}).get("Retenciones", {}).get(Impuesto.ISR, {}).get("Importe")),
@@ -153,6 +154,7 @@ def invoice_confirm_def():
153154

154155
'SubTotal': (12, True, lambda i: i["SubTotal"]),
155156
'Descuento': (12, True, lambda i: i.get("Descuento")),
157+
'IVA16 Base': (12, True, lambda i: i.get("Impuestos", {}).get("Traslados", {}).get(IVA16, {}).get("Base")),
156158
'IVA16 Tras': (12, True, lambda i: i.get("Impuestos", {}).get("Traslados", {}).get(IVA16, {}).get("Importe")),
157159
'IVA Ret': (12, True, lambda i: i.get("Impuestos", {}).get("Retenciones", {}).get(Impuesto.IVA, {}).get("Importe")),
158160
'ISR Ret': (12, True, lambda i: i.get("Impuestos", {}).get("Retenciones", {}).get(Impuesto.ISR, {}).get("Importe")),
@@ -180,6 +182,7 @@ def payment_def():
180182
'Parcialidad': (12, False, lambda i: i.docto_relacionado["NumParcialidad"] if i.pago else None),
181183
'Subtotal': (12, True, lambda i: i.sub_total),
182184
'Descuento': (12, True, lambda i: i.descuento),
185+
'IVA16 Base': (12, True, lambda i: i.impuestos.get("Traslados", {}).get(IVA16, {}).get("Base")),
183186
'IVA16 Tras': (12, True, lambda i: i.impuestos.get("Traslados", {}).get(IVA16, {}).get("Importe")),
184187
'IVA Ret': (12, True, lambda i: i.impuestos.get("Retenciones", {}).get(Impuesto.IVA, {}).get("Importe")),
185188
'ISR Ret': (12, True, lambda i: i.impuestos.get("Retenciones", {}).get(Impuesto.ISR, {}).get("Importe")),

satcfdi/pacs/sat.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
from itertools import islice
1313
from typing import Iterator
1414
from uuid import UUID
15+
16+
from bs4 import BeautifulSoup
1517
from packaging import version
1618

1719
import requests
@@ -432,6 +434,28 @@ def status(self, cfdi: CFDI) -> dict:
432434
for i in res
433435
}
434436

437+
def status_retencion(self, cfdi: CFDI) -> dict:
438+
rfc_emisor = cfdi["Emisor"]["RfcE"]
439+
rfc_receptor = cfdi["Receptor"]["Nacional"]["RfcR"]
440+
uuid = cfdi["Complemento"]["TimbreFiscalDigital"]["UUID"]
441+
442+
params = {
443+
'folio': uuid,
444+
'rfcEmisor': rfc_emisor,
445+
'rfcReceptor': rfc_receptor
446+
}
447+
448+
res = requests.get('https://prodretencionverificacion.clouda.sat.gob.mx/Home/ConsultaRetencion', params)
449+
450+
if res.status_code == 200:
451+
soup = BeautifulSoup(res.text, 'html.parser')
452+
status = soup.find('span', string='Cancelado').string
453+
date = soup.find('td', id='tdFechaCancelacion').get_text(strip=True)
454+
455+
return {
456+
"estado": status, "fecha": date
457+
}
458+
435459
def validate(self, cfdi: CFDI):
436460
"""
437461
verify if the CFDI is valid based on its signatures and certificates

0 commit comments

Comments
 (0)