Patch level : 10.0

Files correlati     : mg1.exe
Ricompilazione Demo : [ ]
Commento            :
Corretto ricalcolo giacenze di magazzino (segnalazione Guimatrag)


git-svn-id: svn://10.65.10.50/branches/R_10_00@22551 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 2012-01-18 16:52:15 +00:00
parent 7244924ffa
commit aade406255

View File

@ -645,6 +645,7 @@ bool TMov_mag::update_balances(bool lock)
if (pi) pi->addstatus(1); 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);
if (art.lock_and_prompt(lock ? _testandlock : _nolock)) if (art.lock_and_prompt(lock ? _testandlock : _nolock))
@ -659,6 +660,7 @@ bool TMov_mag::update_balances(bool lock)
magcurr.put(MAG_NRIGA, nriga); magcurr.put(MAG_NRIGA, nriga);
sld.add_row(magcurr); sld.add_row(magcurr);
err = mag.write(); err = mag.write();
CHECKD(err == NOERR, "Errore di write:" , err);
} }
update_balances(magcurr, saldo); update_balances(magcurr, saldo);
err = mag.rewrite(); err = mag.rewrite();
@ -736,7 +738,8 @@ void TMov_mag::update_balances(TRectype & magrec, const TSaldo_mag & s)
if (caus.update_qta()) if (caus.update_qta())
{ {
const real diff = s.quant(); const real diff = s.quant();
if (!diff.is_zero())
{
update_balance(magrec, MAG_GIAC, diff, caus.sgn(s_giac)); // update .. update_balance(magrec, MAG_GIAC, diff, caus.sgn(s_giac)); // update ..
update_balance(magrec, MAG_ACQ, diff, caus.sgn(s_acq)); // update .. update_balance(magrec, MAG_ACQ, diff, caus.sgn(s_acq)); // update ..
update_balance(magrec, MAG_ENT, diff, caus.sgn(s_ent)); update_balance(magrec, MAG_ENT, diff, caus.sgn(s_ent));
@ -758,10 +761,12 @@ void TMov_mag::update_balances(TRectype & magrec, const TSaldo_mag & s)
update_balance(magrec, MAG_USER5, diff, caus.sgn(s_user5)); update_balance(magrec, MAG_USER5, diff, caus.sgn(s_user5));
update_balance(magrec, MAG_USER6, diff, caus.sgn(s_user6)); update_balance(magrec, MAG_USER6, diff, caus.sgn(s_user6));
} }
}
if (caus.update_val()) if (caus.update_val())
{ {
const real diff_val = s.valore(); const real diff_val = s.valore();
if (!diff_val.is_zero())
{
update_balance(magrec, MAG_VALACQ, diff_val, caus.sgn(s_acq)); // update .. update_balance(magrec, MAG_VALACQ, diff_val, caus.sgn(s_acq)); // update ..
update_balance(magrec, MAG_VALENT, diff_val, caus.sgn(s_ent)); update_balance(magrec, MAG_VALENT, diff_val, caus.sgn(s_ent));
update_balance(magrec, MAG_VALVEN, diff_val, caus.sgn(s_ven)); update_balance(magrec, MAG_VALVEN, diff_val, caus.sgn(s_ven));
@ -777,6 +782,7 @@ void TMov_mag::update_balances(TRectype & magrec, const TSaldo_mag & s)
update_balance(magrec, MAG_USERVAL5, diff_val, caus.sgn(s_user5)); update_balance(magrec, MAG_USERVAL5, diff_val, caus.sgn(s_user5));
update_balance(magrec, MAG_USERVAL6, diff_val, caus.sgn(s_user6)); update_balance(magrec, MAG_USERVAL6, diff_val, caus.sgn(s_user6));
} }
}
} }
// aggiorna i saldi del record corrente // aggiorna i saldi del record corrente
@ -877,6 +883,7 @@ void TMov_mag::update_balance(TRectype & rec, const char * fieldname, const real
{ {
if (sgn != 0) if (sgn != 0)
{ {
CHECK(!val.is_zero(), "Null balance");
if (sgn > 0) if (sgn > 0)
rec.add(fieldname, val); rec.add(fieldname, val);
else else
@ -1063,6 +1070,14 @@ bool rebuild_balances(int codes, const TTipo_valorizz tipo_valorizz,
c.scan(rel_reset_clifogiac, (void*)&p, msg); c.scan(rel_reset_clifogiac, (void*)&p, msg);
} }
// Compattamento giacenze dopo cancellazione
{
//prefix().close_closeable_isamfiles(); // Altrimenti segnala -69 durante la pack
TSystemisamfile mag(LF_MAG);
mag.pack(true, true);
}
// ricostruisce i saldi (ciclo sui movimenti) // ricostruisce i saldi (ciclo sui movimenti)
bool ok = true; bool ok = true;
{ {
@ -1078,12 +1093,5 @@ bool rebuild_balances(int codes, const TTipo_valorizz tipo_valorizz,
a.close(); a.close();
if (ok)
{
prefix().close_closeable_isamfiles(); // Altrimenti segnala -69 durante la pack
TSystemisamfile mag(LF_MAG);
mag.pack(true, true);
}
return ok; return ok;
} }