Modificati algoritmi di calcolo magazzino
git-svn-id: svn://10.65.10.50/trunk@4794 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
560063a128
commit
90faa88bdd
@ -300,10 +300,27 @@ int TArticolo_giacenza::find_mag(const char * annoes, const char * codmag, const
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int TArticolo_giacenza::find_storico(const char * annoesrif, const char * annoes, int from) const
|
int TArticolo_giacenza::find_storico(const char * annoesrif, const char * annoes, const char * codmag, int from) const
|
||||||
{
|
{
|
||||||
((TArticolo_giacenza *) this)->set_anno_sto(annoesrif);
|
TRecord_array & rsto = storico(annoesrif);
|
||||||
return find(LF_STOMAG, STOMAG_ANNOES, annoes, from);
|
const int last = rsto.last_row();
|
||||||
|
|
||||||
|
if (from <= last)
|
||||||
|
{
|
||||||
|
const int codmag_len = codmag ? strlen(codmag) : 0;
|
||||||
|
|
||||||
|
if (codmag_len == 0)
|
||||||
|
return from + 1;
|
||||||
|
|
||||||
|
for (int i = rsto.succ_row(from); i <= last; i = rsto.succ_row(i))
|
||||||
|
{
|
||||||
|
const TRectype & rec = rsto.row(i);
|
||||||
|
|
||||||
|
if (rec.get(STOMAG_CODMAG).compare(codmag, codmag_len) == 0)
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
TRecord_array & TArticolo_giacenza::mag(const char * annoes) const
|
TRecord_array & TArticolo_giacenza::mag(const char * annoes) const
|
||||||
@ -505,10 +522,10 @@ real TArticolo_giacenza::LIFO(const char * annoes, const char * codmag, const ch
|
|||||||
return ((giacenza - rim) * (acq == ZERO ? costo_standard(annoes) : valacq / acq) + valrim) / giacenza;
|
return ((giacenza - rim) * (acq == ZERO ? costo_standard(annoes) : valacq / acq) + valrim) / giacenza;
|
||||||
|
|
||||||
TRecord_array & rstorico = storico(annoes);
|
TRecord_array & rstorico = storico(annoes);
|
||||||
const int last = rstorico.last_row();
|
// const int last = rstorico.last_row();
|
||||||
|
|
||||||
rim = giacenza;
|
rim = giacenza;
|
||||||
for (i = rstorico.first_row(); i <= last; i = rstorico.succ_row(i))
|
for (i = find_storico(annoes, "", codmag); i > 0; i = find_storico(annoes, "", codmag, i))
|
||||||
{
|
{
|
||||||
const TRectype & rec = rstorico.row(i);
|
const TRectype & rec = rstorico.row(i);
|
||||||
const real qta = rec.get(STOMAG_QUANT);
|
const real qta = rec.get(STOMAG_QUANT);
|
||||||
@ -566,21 +583,26 @@ real TArticolo_giacenza::FIFO(const char * annoes, const char * codmag, const ch
|
|||||||
real res = giacenza - acq;
|
real res = giacenza - acq;
|
||||||
rim = ZERO;
|
rim = ZERO;
|
||||||
valrim = ZERO;
|
valrim = ZERO;
|
||||||
|
TFixed_string cmag(codmag);
|
||||||
|
int codmag_len = codmag ? strlen(cmag) : 0;
|
||||||
for (i = last; i > 0; i--)
|
for (i = last; i > 0; i--)
|
||||||
{
|
{
|
||||||
const TRectype & rec = rstorico.row(i);
|
const TRectype & rec = rstorico.row(i);
|
||||||
const real qta = rec.get(STOMAG_QUANT);
|
if (codmag_len == 0 || rec.get(STOMAG_CODMAG).compare(codmag, codmag_len) == 0)
|
||||||
|
{
|
||||||
|
const real qta = rec.get(STOMAG_QUANT);
|
||||||
|
|
||||||
if (qta > res)
|
if (qta > res)
|
||||||
{
|
{
|
||||||
rim += res;
|
rim += res;
|
||||||
valrim += (rec.get_real(STOMAG_VALORE) / qta) * res;
|
valrim += (rec.get_real(STOMAG_VALORE) / qta) * res;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
rim += qta;
|
rim += qta;
|
||||||
valrim += rec.get_real(STOMAG_VALORE);
|
valrim += rec.get_real(STOMAG_VALORE);
|
||||||
res -= qta;
|
res -= qta;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ((giacenza - acq) * (valrim / rim) + valacq) / giacenza;
|
return ((giacenza - acq) * (valrim / rim) + valacq) / giacenza;
|
||||||
@ -1175,7 +1197,7 @@ int TMov_mag::update_balances()
|
|||||||
mag.write();
|
mag.write();
|
||||||
}
|
}
|
||||||
// modifica questo record (e lo sblocca)
|
// modifica questo record (e lo sblocca)
|
||||||
update_balances(mag.curr(),line_mov, +1);
|
update_balances(mag.curr(), line_mov, +1);
|
||||||
/*// ottimizzazione :(cerca di sfruttare la lettura fatta per un eventuale saldo vecchio)
|
/*// ottimizzazione :(cerca di sfruttare la lettura fatta per un eventuale saldo vecchio)
|
||||||
// ciò causa la modifica dell'oggetto TMov_mag (il metodo non è più const)
|
// ciò causa la modifica dell'oggetto TMov_mag (il metodo non è più const)
|
||||||
if (_annoes == get("ANNOES")
|
if (_annoes == get("ANNOES")
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#define STOMAG_ANNOESRIF "ANNOESRIF"
|
#define STOMAG_ANNOESRIF "ANNOESRIF"
|
||||||
#define STOMAG_CODART "CODART"
|
#define STOMAG_CODART "CODART"
|
||||||
#define STOMAG_ANNOES "ANNOES"
|
#define STOMAG_ANNOES "ANNOES"
|
||||||
|
#define STOMAG_CODMAG "CODMAG"
|
||||||
// #define STOMAG_UM "UM"
|
// #define STOMAG_UM "UM"
|
||||||
#define STOMAG_QUANT "QUANT"
|
#define STOMAG_QUANT "QUANT"
|
||||||
#define STOMAG_VALORE "VALORE"
|
#define STOMAG_VALORE "VALORE"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user