Skip to content

Commit

Permalink
updated test requirements
Browse files Browse the repository at this point in the history
  • Loading branch information
satcfdi committed Apr 10, 2024
1 parent ea294af commit 8f5c6bb
Showing 1 changed file with 14 additions and 18 deletions.
32 changes: 14 additions & 18 deletions satcfdi/accounting/contabilidad.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ def generar_contabilidad(
folder=None,
fiel=None,
generate_pdf=False):

validate_cuentas(cuentas)
validate_polizas(polizas)
calcular_saldos(cuentas, polizas)
Expand Down Expand Up @@ -202,6 +201,7 @@ def group_aux_folios(polizas):
def validate_cuentas(cuentas):
# validar cuentas
for k, v in cuentas.items():
assert k
v['_Lowest'] = True
assert v['Natur'] in ['A', 'D']
if v['SubCtaDe']:
Expand All @@ -217,29 +217,25 @@ def validate_cuentas(cuentas):


def validate_saldos(cuentas):
total = 0
totales = {}
for k, v in cuentas.items():
if v['Nivel'] == 1:
if v['Natur'] == 'D':
total += v['SaldoFin']
else:
total -= v['SaldoFin']
sub_cta = v.get('SubCtaDe') or ''
totales.setdefault(sub_cta, 0)
if v['Natur'] == 'D':
totales[sub_cta] += v['SaldoFin']
else:
totales.setdefault(v['SubCtaDe'], 0)
if v['Natur'] == 'D':
totales[v['SubCtaDe']] += v['SaldoFin']
else:
totales[v['SubCtaDe']] -= v['SaldoFin']
totales[sub_cta] -= v['SaldoFin']

assert total == 0
for k, v in totales.items():
if cuentas[k]['Natur'] == 'D':
if v != cuentas[k]['SaldoFin']:
raise ValueError(f"Error in {k}: {v} != {cuentas[k]['SaldoFin']}")
if k:
if cuentas[k]['Natur'] == 'D':
if v != cuentas[k]['SaldoFin']:
raise ValueError(f"Error in {k}: {v} != {cuentas[k]['SaldoFin']}")
else:
if v != -cuentas[k]['SaldoFin']:
raise ValueError(f"Error in {k}: {v} != {cuentas[k]['SaldoFin']}")
else:
if v != -cuentas[k]['SaldoFin']:
raise ValueError(f"Error in {k}: {v} != {cuentas[k]['SaldoFin']}")
assert v == 0


def validate_polizas(polizas):
Expand Down

0 comments on commit 8f5c6bb

Please sign in to comment.