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 8f5c6bb commit 232ffa2
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions satcfdi/accounting/contabilidad.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,24 +216,23 @@ def validate_cuentas(cuentas):
cuentas[v['SubCtaDe']]['_Lowest'] = False


def sign(cta):
if cta['Natur'] == 'D':
return 1
return -1


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

for k, v in totales.items():
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']}")
if v != cuentas[k]['SaldoFin'] * sign(cuentas[k]):
raise ValueError(f"Error in {k}: {v} != {cuentas[k]['SaldoFin']}")
else:
assert v == 0

Expand Down Expand Up @@ -276,7 +275,5 @@ def calcular_saldos(cuentas, polizas):

# Fill SaldoFin
for c in cuentas.values():
if c["Natur"] == "D":
c["SaldoFin"] += c["SaldoIni"] + c["Debe"] - c["Haber"]
else:
c["SaldoFin"] += c["SaldoIni"] + c["Haber"] - c["Debe"]
s = sign(c)
c["SaldoFin"] += c["SaldoIni"] + c["Debe"] * s - c["Haber"] * s

0 comments on commit 232ffa2

Please sign in to comment.