Correzione bug su TArticolo::read (ricorsione infinita)
Inserito un oggetto TArticolo_giacenza nel movimento Metodi update_balences non piu' const git-svn-id: svn://10.65.10.50/trunk@4709 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
d7dd466831
commit
88a83b9072
@ -84,19 +84,26 @@ void TArticolo::set_body_key(TRectype & rowrec)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int TArticolo::read(const char * cod, word op, word lockop)
|
int TArticolo::read(TRectype & rec, word op, word lockop)
|
||||||
{
|
{
|
||||||
if (op == _isequal && lockop == _nolock &&strcmp(cod, (const char *) _codice) == 0)
|
if (op == _isequal && lockop == _nolock &&strcmp(rec.get(ANAMAG_CODART), (const char *) _codice) == 0)
|
||||||
return NOERR;
|
return NOERR;
|
||||||
*_codice = cod;
|
|
||||||
|
*_codice = rec.get(ANAMAG_CODART);
|
||||||
|
|
||||||
const int err = TMultiple_rectype::read(op , lockop);
|
const int err = TMultiple_rectype::read(rec, op , lockop);
|
||||||
|
|
||||||
if (err != NOERR)
|
if (err != NOERR)
|
||||||
zero();
|
zero();
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int TArticolo::read(const char * cod, word op, word lockop)
|
||||||
|
{
|
||||||
|
put(ANAMAG_CODART,cod);
|
||||||
|
return read( *this, op, lockop);
|
||||||
|
}
|
||||||
|
|
||||||
const TString & TArticolo::descrizione(const char* lingua) const
|
const TString & TArticolo::descrizione(const char* lingua) const
|
||||||
{
|
{
|
||||||
if (lingua && *lingua)
|
if (lingua && *lingua)
|
||||||
@ -833,9 +840,9 @@ int TCausale_magazzino::sgn(TTipo_saldomag tiposaldo)
|
|||||||
|
|
||||||
|
|
||||||
TCausale_magazzino::TCausale_magazzino(const char * codice):
|
TCausale_magazzino::TCausale_magazzino(const char * codice):
|
||||||
TRectype(LF_TAB)
|
TRectype(LF_TABCOM)
|
||||||
{
|
{
|
||||||
TTable f("CAU");
|
TTable f("%CAU");
|
||||||
f.put("CODTAB",codice);
|
f.put("CODTAB",codice);
|
||||||
if (f.read() != NOERR)
|
if (f.read() != NOERR)
|
||||||
zero();
|
zero();
|
||||||
@ -911,7 +918,7 @@ int TMov_mag::remove(TBaseisamfile& f) const
|
|||||||
int res;
|
int res;
|
||||||
if ((res=TMultiple_rectype::remove(f))==NOERR )
|
if ((res=TMultiple_rectype::remove(f))==NOERR )
|
||||||
// effettua la variazione dei saldi
|
// effettua la variazione dei saldi
|
||||||
res=update_balances();
|
res=((TMov_mag *)this)->update_balances();
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -928,7 +935,7 @@ int TMov_mag::write(TBaseisamfile& f) const
|
|||||||
}
|
}
|
||||||
if ((res=TMultiple_rectype::write(f))==NOERR )
|
if ((res=TMultiple_rectype::write(f))==NOERR )
|
||||||
// effettua la variazione dei saldi
|
// effettua la variazione dei saldi
|
||||||
res=update_balances();
|
res=((TMov_mag *)this)->update_balances();
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -945,7 +952,7 @@ int TMov_mag::rewrite(TBaseisamfile& f) const
|
|||||||
}
|
}
|
||||||
if ((res=TMultiple_rectype::rewrite(f))==NOERR )
|
if ((res=TMultiple_rectype::rewrite(f))==NOERR )
|
||||||
// effettua la variazione dei saldi
|
// effettua la variazione dei saldi
|
||||||
res=update_balances();
|
res=((TMov_mag *)this)->update_balances();
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -976,7 +983,7 @@ int TMov_mag::force_update_bal()
|
|||||||
for (int i=0; i<rows(); i++) {
|
for (int i=0; i<rows(); i++) {
|
||||||
l_key=line2key(i+1);
|
l_key=line2key(i+1);
|
||||||
l_data=line2data(i+1);
|
l_data=line2data(i+1);
|
||||||
((TMov_mag *)this)->insert_line(l_key,l_data);
|
insert_line(l_key,l_data);
|
||||||
}
|
}
|
||||||
res=update_balances();
|
res=update_balances();
|
||||||
return res;
|
return res;
|
||||||
@ -1082,7 +1089,7 @@ void TMov_mag::giac_putkey(TLocalisamfile & mag,TString16 annoes,TToken_string c
|
|||||||
// aggiorna tutti i saldi in base alle modifiche fatte.
|
// aggiorna tutti i saldi in base alle modifiche fatte.
|
||||||
// il lock su anagrafica dovrebbe garantire il lock su tutte le
|
// il lock su anagrafica dovrebbe garantire il lock su tutte le
|
||||||
// giacenze dell'articolo
|
// giacenze dell'articolo
|
||||||
int TMov_mag::update_balances() const
|
int TMov_mag::update_balances()
|
||||||
{
|
{
|
||||||
bool updated_bal=TRUE;
|
bool updated_bal=TRUE;
|
||||||
TLocalisamfile mag(LF_MAG);
|
TLocalisamfile mag(LF_MAG);
|
||||||
@ -1098,16 +1105,16 @@ int TMov_mag::update_balances() const
|
|||||||
TToken_string * curr_key=(TToken_string *)keys_to_add.first_item();
|
TToken_string * curr_key=(TToken_string *)keys_to_add.first_item();
|
||||||
|
|
||||||
while (curr_key) {
|
while (curr_key) {
|
||||||
TArticolo_giacenza articolo(key2field(*curr_key,"CODART"));
|
curr_art.read((const char *)key2field(*curr_key,"CODART"));
|
||||||
if (articolo.lock_and_prompt()) {
|
if (curr_art.lock_and_prompt()) {
|
||||||
TLine_movmag & line_mov=(TLine_movmag &)lines_to_add[*curr_key];
|
TLine_movmag & line_mov=(TLine_movmag &)lines_to_add[*curr_key];
|
||||||
articolo.update_ultcosti(line_mov.prezzo,get_date("DATACOMP"));
|
curr_art.update_ultcosti(line_mov.prezzo,get_date("DATACOMP"));
|
||||||
// lock gained
|
// lock gained
|
||||||
giac_putkey(mag,get("ANNOES"),*curr_key);
|
giac_putkey(mag,get("ANNOES"),*curr_key);
|
||||||
if (mag.read()!=NOERR) {
|
if (mag.read()!=NOERR) {
|
||||||
// non trovato: aggiungo
|
// non trovato: aggiungo
|
||||||
giac_putkey(mag,get("ANNOES"),*curr_key);
|
giac_putkey(mag,get("ANNOES"),*curr_key);
|
||||||
mag.put("NRIGA",1+articolo.mag(get("ANNOES")).rows());
|
mag.put("NRIGA",1+curr_art.mag(get("ANNOES")).rows());
|
||||||
mag.write();
|
mag.write();
|
||||||
}
|
}
|
||||||
// modifica questo record (e lo sblocca)
|
// modifica questo record (e lo sblocca)
|
||||||
@ -1134,7 +1141,7 @@ int TMov_mag::update_balances() const
|
|||||||
}
|
}
|
||||||
rem_key=(TToken_string *)keys_to_remove.succ_item();
|
rem_key=(TToken_string *)keys_to_remove.succ_item();
|
||||||
}
|
}
|
||||||
articolo.unlock();
|
curr_art.unlock();
|
||||||
} else {
|
} else {
|
||||||
updated_bal=FALSE;
|
updated_bal=FALSE;
|
||||||
}
|
}
|
||||||
@ -1144,15 +1151,15 @@ int TMov_mag::update_balances() const
|
|||||||
curr_key=(TToken_string *)keys_to_remove.first_item();
|
curr_key=(TToken_string *)keys_to_remove.first_item();
|
||||||
|
|
||||||
while (curr_key) {
|
while (curr_key) {
|
||||||
TArticolo articolo(key2field(*curr_key,"CODART"));
|
curr_art.read((const char *)key2field(*curr_key,"CODART"));
|
||||||
if (articolo.lock_and_prompt()) {
|
if (curr_art.lock_and_prompt()) {
|
||||||
giac_putkey(mag,_annoes,*curr_key);
|
giac_putkey(mag,_annoes,*curr_key);
|
||||||
// modifica questo record (e lo sblocca)
|
// modifica questo record (e lo sblocca)
|
||||||
if (mag.read()==NOERR) {
|
if (mag.read()==NOERR) {
|
||||||
update_balances(mag.curr(),(TLine_movmag &)lines_to_subtract[*curr_key],_codcaus,-1);
|
update_balances(mag.curr(),(TLine_movmag &)lines_to_subtract[*curr_key],_codcaus,-1);
|
||||||
mag.rewrite();
|
mag.rewrite();
|
||||||
}
|
}
|
||||||
articolo.unlock();
|
curr_art.unlock();
|
||||||
} else {
|
} else {
|
||||||
updated_bal=FALSE;
|
updated_bal=FALSE;
|
||||||
}
|
}
|
||||||
@ -1167,7 +1174,7 @@ int TMov_mag::update_balances() const
|
|||||||
|
|
||||||
// aggiorna i saldi del record corrente
|
// aggiorna i saldi del record corrente
|
||||||
// in base alla causale e alla modifica fatta (con segno + o -)
|
// in base alla causale e alla modifica fatta (con segno + o -)
|
||||||
int TMov_mag::update_balances(TRectype & magrec, const TLine_movmag &l,TString16 codcaus,int rett_sign) const
|
int TMov_mag::update_balances(TRectype & magrec, const TLine_movmag &l,TString16 codcaus,int rett_sign)
|
||||||
{
|
{
|
||||||
TCausale_magazzino caus(codcaus);
|
TCausale_magazzino caus(codcaus);
|
||||||
TLocalisamfile umart(LF_UMART);
|
TLocalisamfile umart(LF_UMART);
|
||||||
@ -1225,7 +1232,7 @@ bool rebuild_balances(TString16 annoes, bool reset_giac)
|
|||||||
TArray used_files;
|
TArray used_files;
|
||||||
used_files.add(new TLocalisamfile(LF_RMOVMAG),LF_RMOVMAG);
|
used_files.add(new TLocalisamfile(LF_RMOVMAG),LF_RMOVMAG);
|
||||||
used_files.add(new TLocalisamfile(LF_MOVMAG),LF_MOVMAG);
|
used_files.add(new TLocalisamfile(LF_MOVMAG),LF_MOVMAG);
|
||||||
used_files.add(new TTable("CAU"),5);
|
used_files.add(new TTable("%CAU"),5);
|
||||||
TMov_mag * m_m= new TMov_mag; // record del movimento di magazzino
|
TMov_mag * m_m= new TMov_mag; // record del movimento di magazzino
|
||||||
|
|
||||||
// relazione con un solo file (LF_MOVMAG) ma col record Head_Body
|
// relazione con un solo file (LF_MOVMAG) ma col record Head_Body
|
||||||
|
Loading…
x
Reference in New Issue
Block a user