Patch level : 10.0 274
Files correlati : mg1.exe Ricompilazione Demo : [ ] Commento : Bug : 0000254 Sarebbe utile, nel momento in cui si gestiscono le chiusure definitive di magazzino, poter storicizzare i dati e valori di chiusura in modo tale da poter sempre rivalorizzare il magazzino chiuso coi medesimi valori di quando la chiusura è stata effettuata. Bug : 0000708 Ricostruendo i saldi dell'esercizio corrente mi riporta come scorta minima quella dell'esercizio precedente. Se l'anno precedente l'articolo non aveva scorta minima il risultato è che la scorta minima viene azzerata. Altri campi da preservare: UBICAZ, NLABEL, NDIST, LIVRIOR, LOTTORIOR, LOTTOIRIOR, GIORNIRIOR, SCORTAMIN NLABEL NON serve git-svn-id: svn://10.65.10.50/trunk@18641 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
37dd942a34
commit
03365b1098
@ -364,7 +364,6 @@ void TApp_openclose::chiudi_esercizio()
|
||||
TTable esc("ESC");
|
||||
TTable magazzini("MAG");
|
||||
|
||||
// rebuild_balances(_es_to_close); // Cosi' ci assicuriamo che i saldi dell'esercizio vecchio siano a posto
|
||||
descr1.format(_what == definitiva ? FR("Apertura esercizio %04d") : FR("Aggiornamento saldi esercizio %04d"), _es_to_open);
|
||||
descr2 << descr1 << TR(" in corso...");
|
||||
|
||||
@ -378,7 +377,11 @@ void TApp_openclose::chiudi_esercizio()
|
||||
int indici[9], last = 8;
|
||||
if (_what == definitiva)
|
||||
{
|
||||
for (int j = 0; j < 9; j++)
|
||||
TConfig cfg(CONFIG_DITTA);
|
||||
TString16 f;
|
||||
f.format("#%d->%s", LF_UMART, UMART_PREZZO);
|
||||
|
||||
for (int j = 0; j < 9; j++)
|
||||
{
|
||||
movimenti.add(new TMov_mag);
|
||||
TRectype& h = ((TMov_mag&) movimenti[j]).head();
|
||||
@ -442,12 +445,25 @@ void TApp_openclose::chiudi_esercizio()
|
||||
if (codmag.len() > 3)
|
||||
continue; // Salta i depositi
|
||||
|
||||
|
||||
real przlist;
|
||||
|
||||
if (_codlis.full())
|
||||
{
|
||||
TCondizione_vendita cv(&cfg);
|
||||
cv.put_listino(_codlis,_catven);
|
||||
if (cv.ricerca(art.codice()))
|
||||
przlist = cv.get_prezzo();
|
||||
else
|
||||
przlist = art.get_real(f);
|
||||
}
|
||||
// se non lo trova, cerca nel prezzo indicato nelle UM
|
||||
switch (_calctype)
|
||||
{
|
||||
case valorizz_LIFO:
|
||||
art.agg_storicoLIFO(_es_to_close, codmag, TRUE, _valorizza_comp); break;
|
||||
art.agg_storicoLIFO(_es_to_close, codmag, TRUE, _valorizza_comp, _catven, _codlis, przlist); break;
|
||||
case valorizz_FIFO:
|
||||
art.agg_storicoFIFO(_es_to_close, codmag, TRUE, _valorizza_comp); break;
|
||||
art.agg_storicoFIFO(_es_to_close, codmag, TRUE, _valorizza_comp, _catven, _codlis, przlist); break;
|
||||
default:
|
||||
{
|
||||
real val;
|
||||
@ -480,7 +496,7 @@ void TApp_openclose::chiudi_esercizio()
|
||||
default: break;
|
||||
}
|
||||
if (val != ZERO)
|
||||
art.agg_storico(_es_to_close, codmag, TRUE, _valorizza_comp, val);
|
||||
art.agg_storico(_es_to_close, codmag, TRUE, _valorizza_comp, val, _catven, _codlis, przlist);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -38,20 +38,20 @@ END
|
||||
LISTBOX F_VALORIZZAZIONE 27
|
||||
BEGIN
|
||||
PROMPT 2 5 "Valorizzazione "
|
||||
ITEM "5|Al costo medio ponderato" MESSAGE HIDE,2@
|
||||
ITEM "4|Al costo medio acquisti" MESSAGE HIDE,2@
|
||||
ITEM "0|All'ultimo costo" MESSAGE HIDE,2@
|
||||
ITEM "1|Alla media dei costi" MESSAGE HIDE,2@
|
||||
ITEM "2|Al prezzo di listino" MESSAGE SHOW,2@
|
||||
ITEM "3|Al costo standard" MESSAGE HIDE,2@
|
||||
ITEM "7|L.I.F.O. annuale" MESSAGE HIDE,2@
|
||||
ITEM "6|F.I.F.O. annuale" MESSAGE HIDE,2@
|
||||
ITEM "9|L.I.F.O. storico" MESSAGE HIDE,2@
|
||||
ITEM "8|F.I.F.O. storico" MESSAGE HIDE,2@
|
||||
ITEM "5|Al costo medio ponderato"
|
||||
ITEM "4|Al costo medio acquisti"
|
||||
ITEM "0|All'ultimo costo"
|
||||
ITEM "1|Alla media dei costi"
|
||||
ITEM "2|Al prezzo di listino"
|
||||
ITEM "3|Al costo standard"
|
||||
ITEM "7|L.I.F.O. annuale"
|
||||
ITEM "6|F.I.F.O. annuale"
|
||||
ITEM "9|L.I.F.O. storico"
|
||||
ITEM "8|F.I.F.O. storico"
|
||||
/*
|
||||
TBI LIFO/FIFO ragionieristico
|
||||
ITEM "9|L.I.F.O. ragionieristico" MESSAGE HIDE,2@|DISABLE,3@|COPY,F_STOMET
|
||||
ITEM "10|F.I.F.O. ragionieristico" MESSAGE HIDE,2@|DISABLE,3@|COPY,F_STOMET
|
||||
ITEM "9|L.I.F.O. ragionieristico" DISABLE,3@|COPY,F_STOMET
|
||||
ITEM "10|F.I.F.O. ragionieristico" DISABLE,3@|COPY,F_STOMET
|
||||
*/
|
||||
END
|
||||
|
||||
|
23
mg/mglib.h
23
mg/mglib.h
@ -161,11 +161,12 @@ protected:
|
||||
bool is_last_esercizio(const char* annoes) const { return is_last_esercizio(atoi(annoes));}
|
||||
bool is_deletable(const TRectype& mag) const;
|
||||
|
||||
void copia_storico(TRecord_array& nrstorico, int annoes, const char * codmag, int annoprec, real rim, real valrim);
|
||||
void add_storico(TRecord_array& nrstorico, int annoes,const char * codmag, const real & qta, const real & prz);
|
||||
void copia_valori(TRectype& rec, const char * catven, const char * codlist, real & przlist);
|
||||
void copia_storico(TRecord_array& nrstorico, int annoes, const char * codmag, int annoprec, real rim, real valrim, const char * catven, const char * codlist, real & przlist);
|
||||
void add_storico(TRecord_array& nrstorico, int annoes,const char * codmag, const real & qta, const real & prz, const char * catven, const char * codlist, real & przlist);
|
||||
|
||||
void copia_storico(TRecord_array& nrstorico, const char * annoes, const char * codmag, const char * annoprec, real rim, real valrim) { copia_storico(nrstorico, atoi(annoes), codmag, atoi(annoprec), rim, valrim); }
|
||||
void add_storico(TRecord_array& nrstorico, const char * annoes,const char * codmag, const real & qta, const real & prz) { add_storico(nrstorico, atoi(annoes), codmag, qta, prz); }
|
||||
void copia_storico(TRecord_array& nrstorico, const char * annoes, const char * codmag, const char * annoprec, real rim, real valrim, const char * catven, const char * codlist, real & przlist) { copia_storico(nrstorico, atoi(annoes), codmag, atoi(annoprec), rim, valrim, catven, codlist, przlist); }
|
||||
void add_storico(TRecord_array& nrstorico, const char * annoes,const char * codmag, const real & qta, const real & prz, const char * catven, const char * codlist, real & przlist) { add_storico(nrstorico, atoi(annoes), codmag, qta, prz, catven, codlist, przlist); }
|
||||
|
||||
public:
|
||||
|
||||
@ -197,7 +198,7 @@ public:
|
||||
// Identica alla precedente con gli esercizi passati come stringhe
|
||||
bool riporta_saldi(const char * oldes, const char* newes, const TTipo_valorizz tipo,
|
||||
const char * catven ,const char * codlist, bool save_to_disk = true) { return riporta_saldi(atoi(oldes), atoi(newes), tipo, catven, codlist, save_to_disk);}
|
||||
bool azzera_saldi(int codes, bool save_to_disk = true);
|
||||
bool azzera_saldi(int codes, int codespre, bool save_to_disk = true);
|
||||
bool azzera_saldi(const char* codes, bool save_to_disk = true) { return azzera_saldi(atoi(codes), save_to_disk); }
|
||||
|
||||
// valorizzazioni
|
||||
@ -239,13 +240,13 @@ public:
|
||||
real FIFO_ragionieristico(const char * annoes, const char * codmag, const char * livello,
|
||||
bool giacenza_effettiva = true, bool valorizza_componenti = true) const { return FIFO_ragionieristico(atoi(annoes), codmag, livello, giacenza_effettiva, valorizza_componenti );}
|
||||
|
||||
void agg_storicoLIFO (int annoes, const char * codmag, bool giac_eff, bool valorizza_componenti) ;
|
||||
void agg_storicoFIFO (int annoes, const char * codmag, bool giac_eff, bool valorizza_componenti) ;
|
||||
void agg_storico(int annoes, const char * codmag, bool giac_eff, bool valorizza_componenti, const real& val) ;
|
||||
void agg_storicoLIFO (int annoes, const char * codmag, bool giac_eff, bool valorizza_componenti, const char * catven, const char * codlist, real & przlist) ;
|
||||
void agg_storicoFIFO (int annoes, const char * codmag, bool giac_eff, bool valorizza_componenti, const char * catven, const char * codlist, real & przlist) ;
|
||||
void agg_storico(int annoes, const char * codmag, bool giac_eff, bool valorizza_componenti, const real& val, const char * catven, const char * codlist, real & przlist) ;
|
||||
|
||||
void agg_storicoLIFO (const char * annoes, const char * codmag, bool giac_eff, bool valorizza_componenti) { agg_storicoLIFO (atoi(annoes), codmag, giac_eff, valorizza_componenti); }
|
||||
void agg_storicoFIFO (const char * annoes, const char * codmag, bool giac_eff, bool valorizza_componenti) { agg_storicoFIFO (atoi(annoes), codmag, giac_eff, valorizza_componenti); }
|
||||
void agg_storico(const char * annoes, const char * codmag, bool giac_eff, bool valorizza_componenti, const real& val) { return agg_storico(atoi(annoes), codmag, giac_eff, valorizza_componenti, val);}
|
||||
void agg_storicoLIFO (const char * annoes, const char * codmag, bool giac_eff, bool valorizza_componenti, const char * catven, const char * codlist, real & przlist) { agg_storicoLIFO (atoi(annoes), codmag, giac_eff, valorizza_componenti, catven, codlist, przlist); }
|
||||
void agg_storicoFIFO (const char * annoes, const char * codmag, bool giac_eff, bool valorizza_componenti, const char * catven, const char * codlist, real & przlist) { agg_storicoFIFO (atoi(annoes), codmag, giac_eff, valorizza_componenti, catven, codlist, przlist); }
|
||||
void agg_storico(const char * annoes, const char * codmag, bool giac_eff, bool valorizza_componenti, const real& val, const char * catven, const char * codlist, real & przlist) { return agg_storico(atoi(annoes), codmag, giac_eff, valorizza_componenti, val, catven, codlist, przlist);}
|
||||
|
||||
real giacenza_corretta(const TRectype & rec , bool giacenza_effettiva, bool valorizza_componenti) const;
|
||||
|
||||
|
@ -645,8 +645,9 @@ bool TArticolo_giacenza::is_deletable(const TRectype& mag) const
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TArticolo_giacenza::azzera_saldi(int codes, bool save_to_disk)
|
||||
bool TArticolo_giacenza::azzera_saldi(int codes, int codespre, bool save_to_disk)
|
||||
{
|
||||
TRecord_array oldmag = mag(codespre);
|
||||
TRecord_array& rec_arr = mag(codes);
|
||||
|
||||
const int last = rec_arr.last_row();
|
||||
@ -655,6 +656,20 @@ bool TArticolo_giacenza::azzera_saldi(int codes, bool save_to_disk)
|
||||
TRectype& mag = rec_arr[r];
|
||||
for (int i = 0; zero_fields[i]; i++)
|
||||
mag.zero(zero_fields[i]);
|
||||
const TString80 liv(mag.get(MAG_LIVELLO));
|
||||
const int row = find_mag(oldmag, mag.get(MAG_CODMAG), liv);
|
||||
|
||||
if (row >= 0)
|
||||
{
|
||||
const TRectype & oldrec = oldmag[row];
|
||||
|
||||
for (int i = 0; protected_fields[i]; i++)
|
||||
{
|
||||
const TString& val = oldrec.get(protected_fields[i]);
|
||||
if (val.not_empty() && !real::is_null(val))
|
||||
mag.put(protected_fields[i], val);
|
||||
}
|
||||
}
|
||||
if (is_deletable(mag))
|
||||
rec_arr.destroy_row(r, TRUE);
|
||||
}
|
||||
@ -670,6 +685,7 @@ bool TArticolo_giacenza::riporta_saldi(int oldes, int newes, const TTipo_valoriz
|
||||
TString8 codmag;
|
||||
TString16 liv;
|
||||
TRecord_array& rec_arr = mag(oldes);
|
||||
TRecord_array oldmag = rec_arr;
|
||||
const int last = rec_arr.last_row();
|
||||
real rim, val, giac, inpf, proc, icl, acl;
|
||||
|
||||
@ -752,6 +768,19 @@ bool TArticolo_giacenza::riporta_saldi(int oldes, int newes, const TTipo_valoriz
|
||||
rec.zero(MAG_ORDC); rec.zero(MAG_VALORDC);
|
||||
}
|
||||
|
||||
const int row = find_mag(oldmag, rec.get(MAG_CODMAG), liv);
|
||||
|
||||
if (row >= 0)
|
||||
{
|
||||
const TRectype & oldrec = oldmag[row];
|
||||
|
||||
for (int i = 0; protected_fields[i]; i++)
|
||||
{
|
||||
const TString& val = oldrec.get(protected_fields[i]);
|
||||
if (val.not_empty() && !real::is_null(val))
|
||||
rec.put(protected_fields[i], val);
|
||||
}
|
||||
}
|
||||
if (is_deletable(rec))
|
||||
rec_arr.destroy_row(r, TRUE);
|
||||
}
|
||||
@ -1123,7 +1152,17 @@ real TArticolo_giacenza::LIFO_ragionieristico(int annoes, const char * codmag, c
|
||||
return ZERO; // da implementare
|
||||
}
|
||||
|
||||
void TArticolo_giacenza::copia_storico(TRecord_array& nrstorico, int annoes, const char * codmag, int annoprec, real rim, real valrim)
|
||||
void TArticolo_giacenza::copia_valori(TRectype& rec, const char * catven, const char * codlist, real & przlist)
|
||||
{
|
||||
rec.put(STOMAG_ULTCOS1, get(ANAMAG_ULTCOS1));
|
||||
rec.put(STOMAG_ULTCOS2, get(ANAMAG_ULTCOS2));
|
||||
rec.put(STOMAG_COSTSTD, get(ANAMAG_COSTSTD));
|
||||
rec.put(STOMAG_PRZLIST, przlist);
|
||||
rec.put(STOMAG_CODLISTINO, codlist);
|
||||
rec.put(STOMAG_CATVEN, catven);
|
||||
}
|
||||
|
||||
void TArticolo_giacenza::copia_storico(TRecord_array& nrstorico, int annoes, const char * codmag, int annoprec, real rim, real valrim, const char * catven, const char * codlist, real & przlist)
|
||||
{
|
||||
CHECK(annoes > 0,"Copia_storico: Indicare l'anno esercizio dello storico");
|
||||
|
||||
@ -1151,6 +1190,7 @@ void TArticolo_giacenza::copia_storico(TRecord_array& nrstorico, int annoes, con
|
||||
real q = rst.get_real(STOMAG_QUANT);
|
||||
rim -= q;
|
||||
valrim -= rst.get_real(STOMAG_VALORE) * q;
|
||||
copia_valori(newrec, catven, codlist, przlist);
|
||||
}
|
||||
}
|
||||
if (annoprec > 0 && (rim != ZERO || valrim != ZERO))
|
||||
@ -1166,6 +1206,7 @@ void TArticolo_giacenza::copia_storico(TRecord_array& nrstorico, int annoes, con
|
||||
newrec.put(STOMAG_NRIGA, ++last_old);
|
||||
|
||||
annoes_index = nrstorico.insert_row(newrec);
|
||||
copia_valori(newrec, catven, codlist, przlist);
|
||||
}
|
||||
|
||||
TRectype & rec = nrstorico[annoes_index];
|
||||
@ -1199,7 +1240,7 @@ HIDDEN int sort_storico_rev(const TObject ** a, const TObject ** b)
|
||||
return -sort_storico(a, b);
|
||||
}
|
||||
|
||||
void TArticolo_giacenza::add_storico(TRecord_array& nrstorico,int annoes,const char * codmag, const real & qta, const real & prz)
|
||||
void TArticolo_giacenza::add_storico(TRecord_array& nrstorico,int annoes,const char * codmag, const real & qta, const real & prz, const char * catven, const char * codlist, real & przlist)
|
||||
{
|
||||
TString8 annorif(nrstorico.key().get(STOMAG_ANNOESRIF));
|
||||
int i;
|
||||
@ -1221,12 +1262,14 @@ void TArticolo_giacenza::add_storico(TRecord_array& nrstorico,int annoes,const c
|
||||
const int dec_price = storec.ndec(STOMAG_VALORE);
|
||||
storec.put(STOMAG_VALORE, prz.string(0, dec_price));
|
||||
|
||||
copia_valori(storec, catven, codlist, przlist);
|
||||
nrstorico.insert_row(storec);
|
||||
}
|
||||
|
||||
// annoes indica l'anno dell'esercizio da chiudere
|
||||
void TArticolo_giacenza::agg_storicoLIFO(int annoes, const char * codmag,
|
||||
bool giac_eff, bool valorizza_componenti)
|
||||
bool giac_eff, bool valorizza_componenti,
|
||||
const char * catven, const char * codlist, real & przlist)
|
||||
{
|
||||
CHECK(strlen(codmag)<=3,"Non è più possibile avere valorizzazione a livello di deposito");
|
||||
CHECK(codmag && *codmag,"Necessario indicare il magazzino");
|
||||
@ -1252,7 +1295,7 @@ void TArticolo_giacenza::agg_storicoLIFO(int annoes, const char * codmag,
|
||||
const int annoprec = esercizi().pred(annoes);
|
||||
|
||||
TRecord_array nuovo_storico(storico(nuovoanno));
|
||||
copia_storico(nuovo_storico, annoes, codmag, annoprec, rim , valrim);
|
||||
copia_storico(nuovo_storico, annoes, codmag, annoprec, rim , valrim, catven, codlist, przlist);
|
||||
nuovo_storico.sort(sort_storico_rev);
|
||||
|
||||
if (giacenza <= ZERO)
|
||||
@ -1263,7 +1306,7 @@ void TArticolo_giacenza::agg_storicoLIFO(int annoes, const char * codmag,
|
||||
qta=giacenza-rim;
|
||||
if (!acq.is_zero())
|
||||
prz = valacq/acq;
|
||||
add_storico(nuovo_storico,annoes,codmag,qta,prz);
|
||||
add_storico(nuovo_storico,annoes,codmag,qta,prz, catven, codlist, przlist);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1294,7 +1337,8 @@ void TArticolo_giacenza::agg_storicoLIFO(int annoes, const char * codmag,
|
||||
|
||||
|
||||
void TArticolo_giacenza::agg_storicoFIFO(int annoes, const char * codmag,
|
||||
bool giac_eff, bool valorizza_componenti)
|
||||
bool giac_eff, bool valorizza_componenti,
|
||||
const char * catven, const char * codlist, real & przlist)
|
||||
{
|
||||
CHECK(strlen(codmag)<=3,"Non è più possibile avere valorizzazione a livello di deposito");
|
||||
CHECK(codmag && *codmag,"Necessario indicare il magazzino");
|
||||
@ -1320,7 +1364,7 @@ void TArticolo_giacenza::agg_storicoFIFO(int annoes, const char * codmag,
|
||||
const int annoprec = esercizi().pred(annoes);
|
||||
|
||||
TRecord_array nuovo_storico(storico(nuovoanno));
|
||||
copia_storico(nuovo_storico, annoes, codmag, annoprec, rim, valrim);
|
||||
copia_storico(nuovo_storico, annoes, codmag, annoprec, rim, valrim, catven, codlist, przlist);
|
||||
nuovo_storico.sort(sort_storico_rev);
|
||||
|
||||
real qta;
|
||||
@ -1352,7 +1396,7 @@ void TArticolo_giacenza::agg_storicoFIFO(int annoes, const char * codmag,
|
||||
real prz;
|
||||
if (!acq.is_zero())
|
||||
prz = valacq/acq;
|
||||
add_storico(nuovo_storico, annoes, codmag, qta, prz);
|
||||
add_storico(nuovo_storico, annoes, codmag, qta, prz, catven, codlist, przlist);
|
||||
}
|
||||
|
||||
nuovo_storico.pack();
|
||||
@ -1361,7 +1405,8 @@ void TArticolo_giacenza::agg_storicoFIFO(int annoes, const char * codmag,
|
||||
}
|
||||
|
||||
void TArticolo_giacenza::agg_storico(int annoes, const char * codmag,
|
||||
bool giac_eff, bool valorizza_componenti, const real& val)
|
||||
bool giac_eff, bool valorizza_componenti, const real& val,
|
||||
const char * catven, const char * codlist, real & przlist)
|
||||
{
|
||||
CHECK(strlen(codmag)<=3,"Non è più possibile avere valorizzazione a livello di deposito");
|
||||
CHECK(codmag && *codmag,"Necessario indicare il magazzino");
|
||||
@ -1379,7 +1424,7 @@ void TArticolo_giacenza::agg_storico(int annoes, const char * codmag,
|
||||
TRecord_array& nuovo_storico = storico(nuovoanno);
|
||||
|
||||
//nuovo_storico.destroy_rows();
|
||||
add_storico(nuovo_storico, annoes, codmag, qta, val);
|
||||
add_storico(nuovo_storico, annoes, codmag, qta, val, catven, codlist, przlist);
|
||||
nuovo_storico.sort(sort_storico);
|
||||
nuovo_storico.write();
|
||||
}
|
||||
|
@ -868,7 +868,7 @@ HIDDEN bool reset_giac(const TRelation& rel, void* pJolly)
|
||||
TBalance_params & p = *((TBalance_params *)pJolly);
|
||||
|
||||
if (p.zero_giac)
|
||||
articolo.azzera_saldi(p.codes);
|
||||
articolo.azzera_saldi(p.codes, p.codesprec);
|
||||
else
|
||||
articolo.riporta_saldi(p.codesprec, p.codes, p.tipov, p.catv, p.codl);
|
||||
return true;
|
||||
|
Loading…
x
Reference in New Issue
Block a user