diff --git a/mg/mglib02a.cpp b/mg/mglib02a.cpp index fa0d4cb56..089dc2b8d 100755 --- a/mg/mglib02a.cpp +++ b/mg/mglib02a.cpp @@ -946,13 +946,16 @@ HIDDEN bool rel_reset_clifogiac(const TRelation& rel, void* pJolly) { TRectype & rec = rel.curr(); TBalance_params & p = *((TBalance_params *)pJolly); - TRectype oldrec(rec); + TRectype newrec(rec); - oldrec.put(CLIFOGIAC_ANNOES, p.codesprec); - if (oldrec.read(rel.lfile()) != NOERR) - oldrec.zero(); - reset_clifogiac(rec, oldrec); - return rec.rewrite(rel.lfile()) == NOERR; + newrec.put(CLIFOGIAC_ANNOES, p.codes); + if (newrec.read(rel.lfile()) != NOERR) + { + newrec = rec; + newrec.put(CLIFOGIAC_ANNOES, p.codes); + } + reset_clifogiac(newrec, rec); + return newrec.write_rewrite(rel.lfile()) == NOERR; } bool recalc_mov(const TRelation& rel, void* pJolly) @@ -990,7 +993,7 @@ bool rebuild_balances(int codes, const TTipo_valorizz tipo_valorizz, msg.format(FR("Ricostruzione saldi esercizio %04d : azzeramento..."), codes); anamag_cur.scan(reset_giac, (void *) &p, msg); - TString filter; filter << CLIFOGIAC_ANNOES << "==" << codes; + TString filter; filter << CLIFOGIAC_ANNOES << "==" << p.codesprec; TCursor c(new TRelation(LF_CLIFOGIAC), filter); msg.format(FR("Ricostruzione saldi esercizio %04d : azzeramento giacenze clienti..."), codes);