Patch level :

Files correlati     : mg1
Ricompilazione Demo : [ ]
Commento            :
Ottimizzato ricalcolo saldi ed aaggiunta compattazione file giacenze


git-svn-id: svn://10.65.10.50/branches/R_10_00@22458 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 2011-10-18 13:24:25 +00:00
parent e3d6bc759a
commit 77f9314dec

View File

@ -599,45 +599,50 @@ bool TMov_mag::update_balances(bool lock)
{ {
bool updated_bal = true; bool updated_bal = true;
TLocalisamfile mag(LF_MAG);
mag.setkey(2);
TRectype& magcurr = mag.curr();
const TRecord_array& b = body(); const TRecord_array& b = body();
const TString8 hcodcaus = get(MOVMAG_CODCAUS); const TString8 hcodcaus = get(MOVMAG_CODCAUS);
for (int i = b.last_row(); i > 0; i = b.pred_row(i)) for (int i = b.last_row(); i > 0; i = b.pred_row(i)) if (causale(i).update_ultcos())
if (causale(i).update_ultcos()) {
{ const TRectype & rec = b[i];
TArticolo & art = articolo(i);
const TRectype & rec = b[i]; art.set_nuovo(false);
TArticolo & art = articolo(i); if (art.lock_and_prompt(lock ? _testandlock : _nolock))
{
art.set_nuovo(false); const real prezzo = art.convert_to_um(rec.get_real(RMOVMAG_PREZZO), NULL, rec.get(RMOVMAG_UM), false);
if (art.lock_and_prompt(lock ? _testandlock : _nolock)) const long numreg = get_long(MOVMAG_NUMREG);
{ art.update_ultcosti(prezzo,get_date(MOVMAG_DATACOMP), numreg, i);
const real prezzo = art.convert_to_um(rec.get_real(RMOVMAG_PREZZO), NULL, rec.get(RMOVMAG_UM), false); art.rewrite();
const long numreg = get_long(MOVMAG_NUMREG);
art.update_ultcosti(prezzo,get_date(MOVMAG_DATACOMP), numreg, i);
art.rewrite();
}
else
{
if (lock)
art.unlock();
}
} }
else
{
if (lock)
art.unlock();
}
}
if (_saldi_mag.items() > 0) if (_saldi_mag.items() > 0)
{ {
TFast_isamfile mag(LF_MAG);
mag.setkey(2);
TRectype& magcurr = mag.curr();
TString_array keys_mag; TString_array keys_mag;
_saldi_mag.get_keys(keys_mag); _saldi_mag.get_keys(keys_mag);
keys_mag.sort(); keys_mag.sort();
for (TToken_string* curr_key = (TToken_string*)keys_mag.first_item(); TProgind* pi = NULL;
curr_key != NULL; curr_key = (TToken_string*)keys_mag.succ_item()) if (keys_mag.items() >= 32)
{
TString msg; msg << TR("Aggiornamento saldi del movimento ") << get(MOVMAG_NUMREG);
pi = new TProgind(keys_mag.items(), msg, false, true);
}
FOR_EACH_ARRAY_ROW(keys_mag, r, curr_key)
{ {
if (pi) pi->addstatus(1);
const TSaldo_mag& saldo = (const TSaldo_mag&)_saldi_mag[*curr_key]; const TSaldo_mag& saldo = (const TSaldo_mag&)_saldi_mag[*curr_key];
const TCodice_articolo& codart = saldo.codart(); const TCodice_articolo& codart = saldo.codart();
TArticolo_giacenza& art = cached_article_balances(codart); TArticolo_giacenza& art = cached_article_balances(codart);
@ -664,11 +669,13 @@ bool TMov_mag::update_balances(bool lock)
art.unlock(); art.unlock();
} }
} }
if (pi) delete pi;
} }
if (_saldi_mag_clifo.items() > 0) if (_saldi_mag_clifo.items() > 0)
{ {
TLocalisamfile clifomag(LF_CLIFOGIAC); TFast_isamfile clifomag(LF_CLIFOGIAC);
clifomag.setkey(2); clifomag.setkey(2);
TRectype& clifomag_curr = clifomag.curr(); TRectype& clifomag_curr = clifomag.curr();
@ -1035,33 +1042,47 @@ bool rebuild_balances(int codes, const TTipo_valorizz tipo_valorizz,
p.codl = codlis; p.codl = codlis;
p.tipov = tipo_valorizz; p.tipov = tipo_valorizz;
// azzera tutte giacenze (ciclo sulle giacenze) TString msg;
TCursor anamag_cur(new TRelation(LF_ANAMAG));
TString msg;
anamag_cur.relation()->lfile().set_curr(new TArticolo_giacenza()); {
anamag_cur.freeze(); // azzera tutte giacenze (ciclo sulle giacenze)
msg.format(FR("Ricostruzione saldi esercizio %04d : azzeramento..."), codes); TRelation anamag_rel(LF_ANAMAG);
anamag_cur.scan(reset_giac, (void *) &p, msg); TCursor anamag_cur(&anamag_rel);
TString filter; filter << CLIFOGIAC_ANNOES << "==" << p.codesprec; anamag_cur.relation()->lfile().set_curr(new TArticolo_giacenza());
TCursor c(new TRelation(LF_CLIFOGIAC), filter); msg.format(FR("Ricostruzione saldi esercizio %04d : azzeramento..."), codes);
anamag_cur.scan(reset_giac, (void*)&p, msg);
}
msg.format(FR("Ricostruzione saldi esercizio %04d : azzeramento giacenze clienti..."), codes); {
c.scan(rel_reset_clifogiac, (void *) &p, msg); TString filter; filter << CLIFOGIAC_ANNOES << "==" << p.codesprec;
TRelation clifogiac_rel(LF_CLIFOGIAC);
TCursor c(&clifogiac_rel, filter);
msg.format(FR("Ricostruzione saldi esercizio %04d : azzeramento giacenze clienti..."), codes);
c.scan(rel_reset_clifogiac, (void*)&p, msg);
}
// ricostruisce i saldi (ciclo sui movimenti) // ricostruisce i saldi (ciclo sui movimenti)
bool ok = true; bool ok = true;
{
TRelation relmovmag(LF_MOVMAG);
TRectype& rec = relmovmag.curr();
rec.put(MOVMAG_ANNOES, codes);
TRelation relmovmag(LF_MOVMAG); TCursor mov_cur(&relmovmag, "", 2, &rec, &rec);
TRectype& rec = relmovmag.curr(); relmovmag.lfile().set_curr(new TMov_mag());
rec.put(MOVMAG_ANNOES, codes); msg.format(FR("Ricostruzione saldi esercizio %04d : ricalcolo..."), codes);
mov_cur.scan(recalc_mov, (void*)&ok, msg);
TCursor mov_cur(&relmovmag ,"", 2, &rec, &rec); }
relmovmag.lfile().set_curr(new TMov_mag());
msg.format(FR("Ricostruzione saldi esercizio %04d : ricalcolo..."), codes);
mov_cur.scan(recalc_mov, (void *) &ok, msg);
a.close(); a.close();
if (ok)
{
TSystemisamfile mag(LF_MAG);
mag.pack(true, true);
}
return ok; return ok;
} }