FDB: postarile direct pe sintetic raman brute; conturile 0/0 nu intra

Pe drumul FDB sinteticul e suma bruta a notelor, deci diferenta fata de
analitice se scrie cu D si C separat, nu pe net: rulajul 401 LACERTA iese ca
in SAGA (8.991,55 / 57.253,22). PDF/xls raman pe net (etalonul trece).
Conturile nepartener fara sold si fara rulaj (891) nu mai intra in xlsx.

LACERTA: 51/53 frunze identice cu REF; restul sunt asezari alese (5121,
4428), cu totaluri egale pe cont.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EYeAtVxeS8m4oXekjX8Am2
This commit is contained in:
2026-09-27 16:58:46 +03:00
parent d188c76c7f
commit 7ac40f9a34
7 changed files with 73 additions and 22 deletions

View File

@@ -218,11 +218,29 @@ def _iso(s):
return None
def diferente_dc(by, children, diffs, brut):
"""{parinte: (D, C)} al postarilor direct pe sintetic. Pe net (ca pana acum), sau,
cu brut=True (drumul FDB, unde sinteticul e suma bruta a tuturor notelor), cu D si C
separat, ca rulajul sa ramana cel din SAGA. Daca vreo latura iese negativa (netarea
soldului initial pe analitic), se revine la net."""
out = {}
for cont, d in diffs:
out[cont] = (d, 0.0) if d > 0 else (0.0, -d)
if brut:
for cont, kids in children.items():
dd = round(by[cont]["total_d"] - sum(by[k]["total_d"] for k in kids), 2)
dc = round(by[cont]["total_c"] - sum(by[k]["total_c"] for k in kids), 2)
if dd >= 0 and dc >= 0 and (dd > 0.005 or dc > 0.005):
out[cont] = (dd, dc)
return out
def genereaza(rows, header, an=AN, luna=LUNA, mapare=None, parteneri=None,
facturi=None):
facturi=None, brut=False):
by, children = arbore(rows)
diffs = diferente(by, children)
diff_by_parent = dict(diffs)
dif = diferente_dc(by, children, diffs, brut)
# parteneri/facturi reale (doar pe drumul FDB); lipsa = comportamentul de azi
part_map = {}
@@ -299,6 +317,9 @@ def genereaza(rows, header, an=AN, luna=LUNA, mapare=None, parteneri=None,
for r in rows:
if este_partener(r["cont"]) or r["cont"] in children:
continue
if round(r["total_d"], 2) == 0 and round(r["total_c"], 2) == 0:
leaf_rep.add(r["cont"]) # fara sold si fara rulaj: nimic de importat
continue
cont4, ac = split_cont(r["cont"])
cont4, ac = _mapare_cont(r["cont"], cont4, ac, mapare, partener=False)
add(rand(header, an, luna, TIP="BALANTA", cont=cont4, acont=ac, numar=1,
@@ -307,14 +328,13 @@ def genereaza(rows, header, an=AN, luna=LUNA, mapare=None, parteneri=None,
# A. analitic de diferenta pe parinte nepartener (postare directa pe sintetic).
# Randurile de diferenta raman calculate aici, nu trec prin mapare.
for cont, d in diffs:
for cont, (dd, dc) in dif.items():
if este_partener(cont):
continue
ac = acont_diferenta(cont, children[cont])
add(rand(header, an, luna, TIP="BALANTA", cont=cont.split(".")[0], acont=ac,
numar=1, nume="DIFERENTA SINTETIC SAGA",
totdeb=d if d > 0 else None,
totcred=-d if d < 0 else None))
totdeb=dd or None, totcred=dc or None))
parteneri_activi = sorted({c.split(".")[0] for c in by if este_partener(c)})
for p in parteneri_activi:
@@ -343,18 +363,17 @@ def genereaza(rows, header, an=AN, luna=LUNA, mapare=None, parteneri=None,
continue
sold = abs(net) if este_latura_formular(net, side) else -abs(net)
factura(k, cont_k, kac, kd["denumire"], side, net, sold, None)
if p in diff_by_parent:
d = diff_by_parent[p]
if p in dif:
dd, dc = dif[p]
ac = acont_diferenta(p, direct)
add(rand(header, an, luna, TIP="BALANTA", cont=p, acont=ac, numar=1,
nume="DIFERENTA SINTETIC SAGA",
totdeb=d if d > 0 else None,
totcred=-d if d < 0 else None))
totdeb=dd or None, totcred=dc or None))
continue
# 401/4092/4111/461/462/4551 si 5311
if direct:
d = diff_by_parent.get(p, 0.0)
dd, dc = dif.get(p, (0.0, 0.0))
cont_p, ac_p = _mapare_cont(p, p, None, mapare, True)
def baza(kids):
@@ -397,12 +416,11 @@ def genereaza(rows, header, an=AN, luna=LUNA, mapare=None, parteneri=None,
add(rand(header, an, luna, TIP="BALANTA", cont=cont_g, acont=ac_g,
numar=1, nume=nume, totdeb=round(bd, 2), totcred=round(bc, 2)))
facturi(kids, cont_g, ac_g)
if d:
if dd or dc:
add(rand(header, an, luna, TIP="BALANTA", cont=cont_p,
acont=acont_diferenta(p, direct), numar=1,
nume="DIFERENTA SINTETIC SAGA",
totdeb=d if d > 0 else None,
totcred=-d if d < 0 else None))
totdeb=dd or None, totcred=dc or None))
continue
base_d, base_c = baza(direct)
@@ -419,8 +437,8 @@ def genereaza(rows, header, an=AN, luna=LUNA, mapare=None, parteneri=None,
cont_p = variante.pop()
add(rand(header, an, luna, TIP="BALANTA", cont=cont_p, acont=ac_p,
numar=1, nume=by[p]["denumire"],
totdeb=round(base_d + (d if d > 0 else 0.0), 2),
totcred=round(base_c + (-d if d < 0 else 0.0), 2)))
totdeb=round(base_d + dd, 2),
totcred=round(base_c + dc, 2)))
facturi(direct, cont_p, ac_p)
else:
net = round(by[p]["total_d"] - by[p]["total_c"], 2)