Funzione aggiornamento storico e giac al cambio di um principale
Corretto bug autosettaggio dell'anno di storico git-svn-id: svn://10.65.10.50/trunk@5067 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
3fbe6a84b6
commit
a3737ab83a
119
ve/ve2400.cpp
119
ve/ve2400.cpp
@ -40,12 +40,12 @@ class TMask_anamag: public TMask {
|
|||||||
|
|
||||||
void clear_info_sto();
|
void clear_info_sto();
|
||||||
bool info_sto_dirty();
|
bool info_sto_dirty();
|
||||||
void ricalcola_giacenze(TString newum,real fc);
|
|
||||||
int add_totali_storico(TString &codmag);
|
int add_totali_storico(TString &codmag);
|
||||||
bool remove_totali_storico(TString & codmag);
|
bool remove_totali_storico(TString & codmag);
|
||||||
void update_totali_storico(TString & codmag);
|
void update_totali_storico(TString & codmag);
|
||||||
bool check_totali_storico();
|
bool check_totali_storico();
|
||||||
public:
|
public:
|
||||||
|
void ricalcola_giacenze();
|
||||||
TString16 um_principale;
|
TString16 um_principale;
|
||||||
TEsercizi_contabili esercizi_contabili;
|
TEsercizi_contabili esercizi_contabili;
|
||||||
|
|
||||||
@ -312,9 +312,14 @@ bool TMask_anamag::handle_stoanno(TMask_field &fld, KEY k)
|
|||||||
{
|
{
|
||||||
TSheet_field &fld_stomag= (TSheet_field &)fld.mask().field(F_SHEETSTOMAG);
|
TSheet_field &fld_stomag= (TSheet_field &)fld.mask().field(F_SHEETSTOMAG);
|
||||||
|
|
||||||
|
if (mask.get_int(F_STOANNO) >=mask.esercizi_contabili.last())
|
||||||
|
{
|
||||||
|
fld.error_box("Impossibile dare la composizione delle rimanenze per l'ultimo anno");
|
||||||
|
mask.reset(F_STOANNO);
|
||||||
|
}
|
||||||
if (mask.get(F_STOANNO).empty() )
|
if (mask.get(F_STOANNO).empty() )
|
||||||
{
|
{
|
||||||
mask.set(F_STOANNORIF, mask.esercizi_contabili.pred(mask.get_int(F_ANNORIF)) );
|
mask.set(F_STOANNORIF, max(mask.esercizi_contabili.first(),mask.esercizi_contabili.pred(mask.get_int(F_ANNORIF))) );
|
||||||
mask.set(F_STOANNO, mask.get(F_STOANNORIF));
|
mask.set(F_STOANNO, mask.get(F_STOANNORIF));
|
||||||
}
|
}
|
||||||
if ( fld.focusdirty() && mask.last_annosto>0 && mask.last_annosto!=fld.mask().get_int(F_STOANNO))
|
if ( fld.focusdirty() && mask.last_annosto>0 && mask.last_annosto!=fld.mask().get_int(F_STOANNO))
|
||||||
@ -349,6 +354,8 @@ bool TMask_anamag::handle_sheet_um(TMask_field &fld, KEY k)
|
|||||||
TMask_anamag & m= (TMask_anamag &)(fld.mask());
|
TMask_anamag & m= (TMask_anamag &)(fld.mask());
|
||||||
if (k == K_ENTER)
|
if (k == K_ENTER)
|
||||||
{
|
{
|
||||||
|
if (*f.cell(0,f.cid2index(FS_CODUM))==' ')
|
||||||
|
return error_box("La prima unità di misura deve essere specificata");
|
||||||
const int items = f.items();
|
const int items = f.items();
|
||||||
if (items > 0)
|
if (items > 0)
|
||||||
{
|
{
|
||||||
@ -363,20 +370,17 @@ bool TMask_anamag::handle_sheet_um(TMask_field &fld, KEY k)
|
|||||||
if (v.add(um))
|
if (v.add(um))
|
||||||
return error_box("Le unità di misura devono essere diverse tra loro");
|
return error_box("Le unità di misura devono essere diverse tra loro");
|
||||||
}
|
}
|
||||||
if (!m.um_principale.blank() && m.um_principale!=f.cell(0,f.cid2index(FS_CODUM))) {
|
|
||||||
for (int i= 0; i<f.items(); i++)
|
|
||||||
{
|
|
||||||
if (m.um_principale==f.cell(i,f.cid2index(FS_CODUM)))
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (i>=f.items()) {
|
|
||||||
return error_box("L'unità di misura %s deve essere presente in tabella",(const char *)m.um_principale);
|
|
||||||
} else {
|
|
||||||
m.um_principale=f.cell(0,f.cid2index(FS_CODUM));
|
|
||||||
}
|
|
||||||
m.ricalcola_giacenze(f.cell(0,f.cid2index(FS_CODUM)),f.cell(i,f.cid2index(FS_FCUM)));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
if (!m.um_principale.blank() && m.um_principale!=f.cell(0,f.cid2index(FS_CODUM))) {
|
||||||
|
for (int i= 0; i<f.items(); i++)
|
||||||
|
{
|
||||||
|
if (m.um_principale==f.cell(i,f.cid2index(FS_CODUM)))
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (i>=f.items()) {
|
||||||
|
return error_box("L'unità di misura '%s' deve essere presente in tabella",(const char *)m.um_principale);
|
||||||
|
}
|
||||||
|
}
|
||||||
} else if (k==K_TAB) {
|
} else if (k==K_TAB) {
|
||||||
} else if (k==K_SPACE) {
|
} else if (k==K_SPACE) {
|
||||||
m.um_principale=f.cell(0,f.cid2index(FS_CODUM));
|
m.um_principale=f.cell(0,f.cid2index(FS_CODUM));
|
||||||
@ -828,10 +832,13 @@ bool TMask_anamag::handle_sheet_um_um(TMask_field &fld, KEY k)
|
|||||||
x = 1.00;
|
x = 1.00;
|
||||||
m.set(FS_FCUM, x); // il risultato viene scritto nel campo del fattore di conversione
|
m.set(FS_FCUM, x); // il risultato viene scritto nel campo del fattore di conversione
|
||||||
} else {
|
} else {
|
||||||
// prima unità di misura
|
TString & um_p=((TMask_anamag &)f->mask()).um_principale;
|
||||||
f->mask().set(F_UMPRINCIPALE,curr_um);
|
if (um_p.blank()) {
|
||||||
f->mask().set(F_UMPRINCIPALE2,curr_um);
|
f->mask().set(F_UMPRINCIPALE,curr_um);
|
||||||
}
|
f->mask().set(F_UMPRINCIPALE2,curr_um);
|
||||||
|
um_p=curr_um;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@ -903,10 +910,74 @@ void TMask_anamag::sheetgiac_put(TSheet_field &fld_righe, int item)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// aggiorna il valore delle giacenze del fattore indicato
|
// Aggiorna il valore delle giacenze in base al cambiamento dell'unità di misura principale
|
||||||
void TMask_anamag:: ricalcola_giacenze(TString newum, real fc)
|
void TMask_anamag::ricalcola_giacenze()
|
||||||
{
|
{
|
||||||
|
real fc(1.0);
|
||||||
|
TSheet_field & f=(TSheet_field &)field(F_SHEETUM);
|
||||||
|
if (!um_principale.blank() && um_principale!=f.cell(0,f.cid2index(FS_CODUM))) {
|
||||||
|
for (int i= 0; i<f.items(); i++)
|
||||||
|
{
|
||||||
|
if (um_principale==f.cell(i,f.cid2index(FS_CODUM)))
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
fc=f.cell(i,f.cid2index(FS_FCUM));
|
||||||
|
}
|
||||||
|
if (fc != 1.0)
|
||||||
|
{
|
||||||
|
TLocalisamfile mag(LF_MAG),stomag(LF_STOMAG);
|
||||||
|
int annoes=esercizi_contabili.first();
|
||||||
|
do {
|
||||||
|
mag.zero();
|
||||||
|
mag.put(MAG_ANNOES,annoes);
|
||||||
|
mag.put(MAG_CODART,get(F_CODART));
|
||||||
|
mag.read();
|
||||||
|
while (!mag.eof() && get(F_CODART)==mag.get(MAG_CODART) && annoes==mag.get_int(MAG_ANNOES))
|
||||||
|
{
|
||||||
|
mag.put(MAG_LIVRIOR,mag.get_real(MAG_LIVRIOR)*fc); // update ..
|
||||||
|
mag.put(MAG_LOTTORIOR,mag.get_real(MAG_LOTTORIOR)*fc);
|
||||||
|
// saldi
|
||||||
|
mag.put(MAG_GIAC,mag.get_real(MAG_GIAC)*fc); // update ..
|
||||||
|
mag.put(MAG_ACQ,mag.get_real(MAG_ACQ)*fc);
|
||||||
|
mag.put(MAG_ENT,mag.get_real(MAG_ENT)*fc);
|
||||||
|
mag.put(MAG_VEN,mag.get_real(MAG_VEN)*fc);
|
||||||
|
mag.put(MAG_USC,mag.get_real(MAG_USC)*fc);
|
||||||
|
mag.put(MAG_ORDC,mag.get_real(MAG_ORDC)*fc);
|
||||||
|
mag.put(MAG_ORDF,mag.get_real(MAG_ORDF)*fc);
|
||||||
|
mag.put(MAG_RIM,mag.get_real(MAG_RIM)*fc);
|
||||||
|
mag.put(MAG_SCARTI,mag.get_real(MAG_SCARTI)*fc);
|
||||||
|
mag.put(MAG_INCL,mag.get_real(MAG_INCL)*fc);
|
||||||
|
mag.put(MAG_ACL,mag.get_real(MAG_ACL)*fc);
|
||||||
|
mag.put(MAG_PRODCOMP,mag.get_real(MAG_PRODCOMP)*fc);
|
||||||
|
mag.put(MAG_PRODFIN,mag.get_real(MAG_PRODFIN)*fc);
|
||||||
|
mag.put(MAG_SCORTAMIN,mag.get_real(MAG_SCORTAMIN)*fc);
|
||||||
|
// valori
|
||||||
|
mag.put(MAG_VALACQ,mag.get_real(MAG_VALACQ)*fc);
|
||||||
|
mag.put(MAG_VALENT,mag.get_real(MAG_VALENT)*fc);
|
||||||
|
mag.put(MAG_VALVEN,mag.get_real(MAG_VALVEN)*fc);
|
||||||
|
mag.put(MAG_VALUSC,mag.get_real(MAG_VALUSC)*fc);
|
||||||
|
mag.put(MAG_VALORDC,mag.get_real(MAG_VALORDC)*fc);
|
||||||
|
mag.put(MAG_VALORDF,mag.get_real(MAG_VALORDF)*fc);
|
||||||
|
mag.put(MAG_VALRIM,mag.get_real(MAG_VALRIM)*fc);
|
||||||
|
mag.put(MAG_VALSCARTI,mag.get_real(MAG_VALSCARTI)*fc);
|
||||||
|
|
||||||
|
mag.rewrite();
|
||||||
|
mag.next();
|
||||||
|
}
|
||||||
|
stomag.zero();
|
||||||
|
stomag.put(MAG_ANNOES,annoes);
|
||||||
|
stomag.put(MAG_CODART,get(F_CODART));
|
||||||
|
stomag.read();
|
||||||
|
while (!stomag.eof() && get(F_CODART)==stomag.get(MAG_CODART) && annoes==mag.get_int(MAG_ANNOES))
|
||||||
|
{
|
||||||
|
stomag.put(STOMAG_QUANT,mag.get_real(STOMAG_QUANT)*fc); // update ..
|
||||||
|
stomag.put(STOMAG_VALORE,mag.get_real(STOMAG_VALORE)*fc);
|
||||||
|
|
||||||
|
stomag.rewrite();
|
||||||
|
stomag.next();
|
||||||
|
}
|
||||||
|
} while (annoes=esercizi_contabili.next(annoes));
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -999,7 +1070,9 @@ int TAnagrafica_magazzino::write(const TMask& m)
|
|||||||
|
|
||||||
int TAnagrafica_magazzino::rewrite(const TMask& m)
|
int TAnagrafica_magazzino::rewrite(const TMask& m)
|
||||||
{
|
{
|
||||||
return TRelation_application::rewrite(m);
|
const int err =TRelation_application::rewrite(m);
|
||||||
|
((TMask_anamag &)m).ricalcola_giacenze();
|
||||||
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TAnagrafica_magazzino::init_insert_mode(TMask &m)
|
void TAnagrafica_magazzino::init_insert_mode(TMask &m)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user