Skip to content

Commit

Permalink
Updated Comprobante
Browse files Browse the repository at this point in the history
  • Loading branch information
satcfdi committed May 7, 2024
1 parent 859eb4b commit 97ed8aa
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 14 deletions.
19 changes: 5 additions & 14 deletions satcfdi/create/cfd/cfdi40.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,8 +438,8 @@ def __init__(
fecha: datetime = None,
):
super().__init__({
'Version': None,
'Fecha': fecha,
'Version': self.version,
'Fecha': fecha or datetime.now(tz=get_timezone(lugar_expedicion)).replace(tzinfo=None),
'Sello': '',
'SubTotal': None,
'Moneda': moneda,
Expand Down Expand Up @@ -469,25 +469,16 @@ def __init__(
self.compute()

def compute(self):
self['Version'] = self.version
self['Fecha'] = self.get('Fecha') or datetime.now(tz=get_timezone(self['LugarExpedicion'])).replace(tzinfo=None)
self['Moneda'] = self.get('Moneda') or 'MXN'
self['Sello'] = ''
self['TipoDeComprobante'] = self.get('TipoDeComprobante') or 'I'
self['Exportacion'] = self.get('Exportacion') or '01'

self["Conceptos"] = conceptos = _make_conceptos(self["Conceptos"], rnd_fn=rounder(self["Moneda"]))
self["SubTotal"] = sub_total = sum(c['Importe'] for c in conceptos)
descuento = sum(c.get('Descuento') or 0 for c in conceptos)
self['Descuento'] = descuento or None
self['Impuestos'] = impuestos = make_impuestos(conceptos)

total = sub_total - descuento
if impuestos:
total += impuestos.get('TotalImpuestosTrasladados', 0)
total -= impuestos.get('TotalImpuestosRetenidos', 0)

total += impuestos.get('TotalImpuestosTrasladados') or 0
total -= impuestos.get('TotalImpuestosRetenidos') or 0
self['Total'] = total
self['Descuento'] = descuento or None

@classmethod
def pago(
Expand Down
6 changes: 6 additions & 0 deletions tests/test_create_cfdi40_raw.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ def test_create_raw():
"Serie": "A",
"Folio": "123456",
"Moneda": "MXN",
"Sello": "",
'TipoDeComprobante': 'I',
'Exportacion': "01"
}

a = cfdi40.Comprobante.__new__(cfdi40.Comprobante)
Expand Down Expand Up @@ -139,6 +142,9 @@ def test_create_raw_no_signature():
"Moneda": "MXN",
'NoCertificado': '',
'Certificado': '',
"Sello": "",
'TipoDeComprobante': 'I',
'Exportacion': "01"
}

a = cfdi40.Comprobante.__new__(cfdi40.Comprobante)
Expand Down

0 comments on commit 97ed8aa

Please sign in to comment.