Correzioni varie alle funzioni di movimenti di magazzino
git-svn-id: svn://10.65.10.50/trunk@4767 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
71ededdbc9
commit
8c639919bd
137
mg/mglib02.cpp
137
mg/mglib02.cpp
@ -844,18 +844,15 @@ int TCausale_magazzino::sgn(TTipo_saldomag tiposaldo)
|
||||
|
||||
|
||||
TCausale_magazzino::TCausale_magazzino(const char * codice):
|
||||
TRectype(LF_TABCOM)
|
||||
TRectype(LF_TABCOM)
|
||||
{
|
||||
TTable f("%CAU");
|
||||
f.put("CODTAB",codice);
|
||||
if (f.read() != NOERR)
|
||||
TTable f("%CAU");
|
||||
|
||||
settab("CAU");
|
||||
put("CODTAB", codice);
|
||||
if (TRectype::read(f) != NOERR)
|
||||
zero();
|
||||
else
|
||||
*this=(TCausale_magazzino &)f.curr();
|
||||
}
|
||||
TCausale_magazzino::~TCausale_magazzino()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
// movimenti
|
||||
TLine_movmag ::TLine_movmag(const TLine_movmag &l)
|
||||
@ -893,14 +890,11 @@ bool TMov_mag::renum()
|
||||
// copia la chiave dal file principale a quello delle righe
|
||||
void TMov_mag::set_body_key(TRectype & rowrec)
|
||||
{
|
||||
rowrec.put("NUMREG",get("NUMREG")) ;
|
||||
rowrec.put("NUMREG",get("NUMREG"));
|
||||
}
|
||||
|
||||
int TMov_mag::read(TBaseisamfile& f, word op , word lockop)
|
||||
{
|
||||
TToken_string l_key;
|
||||
TLine_movmag l_data;
|
||||
|
||||
int res=TMultiple_rectype::read(f,op,lockop);
|
||||
|
||||
// reset delle strutture per il controlli delle variazioni dei saldi
|
||||
@ -908,11 +902,11 @@ int TMov_mag::read(TBaseisamfile& f, word op , word lockop)
|
||||
_annoes=get("ANNOES");
|
||||
lines_to_add.destroy();
|
||||
lines_to_subtract.destroy();
|
||||
for (int i=0; i<rows(); i++) {
|
||||
l_key=line2key(i+1);
|
||||
l_data=line2data(i+1);
|
||||
line_deleted(l_key,l_data);
|
||||
}
|
||||
|
||||
const int nrows = rows();
|
||||
|
||||
for (int i = 1; i< nrows; i++)
|
||||
line_deleted(line2key(i), line2data(i));
|
||||
return res;
|
||||
}
|
||||
|
||||
@ -928,24 +922,32 @@ int TMov_mag::remove(TBaseisamfile& f) const
|
||||
|
||||
void TMov_mag::add_automatiche()
|
||||
{
|
||||
for (int r=rows(); r>0; r--)
|
||||
{
|
||||
TString16 codcaus(body()[r].get(RMOVMAG_CODCAUS));
|
||||
if (codcaus.blank())
|
||||
codcaus=get(RMOVMAG_CODCAUS);
|
||||
for (int r = rows(); r > 0; r--)
|
||||
{
|
||||
TRecord_array & b = body();
|
||||
TRectype & row = b[r];
|
||||
TString16 codcaus(row.get(RMOVMAG_CODCAUS));
|
||||
if (codcaus.empty())
|
||||
codcaus=get(MOVMAG_CODCAUS);
|
||||
TCausale_magazzino cau(codcaus);
|
||||
if (*cau.get_collegata()!='\0')
|
||||
codcaus=cau.caus_collegata();
|
||||
if (codcaus.not_empty())
|
||||
{
|
||||
// deve esserci una riga collegata
|
||||
if (r < rows()-1 && body()[r+1].get(RMOVMAG_TIPORIGA)[0] != riga_automatica)
|
||||
if (!b.exist(r + 1) || b[r + 1].get_char(RMOVMAG_TIPORIGA) != riga_automatica)
|
||||
{
|
||||
// manca, la inserisco
|
||||
TRectype linea_auto(body()[r]);
|
||||
|
||||
if (codmag_rauto(r)!=NULL) linea_auto.put(RMOVMAG_CODMAG,codmag_rauto(r));
|
||||
if (prezzo_rauto(r)!=NULL) linea_auto.put(RMOVMAG_PREZZO,prezzo_rauto(r));
|
||||
linea_auto.put(RMOVMAG_NRIG,r+1);
|
||||
body().insert_row(&linea_auto);
|
||||
TRectype * linea_auto = new TRectype(row);
|
||||
const char * codmag = codmag_rauto(r);
|
||||
if (codmag != NULL)
|
||||
linea_auto->put(RMOVMAG_CODMAG, codmag);
|
||||
const char * prezzo = prezzo_rauto(r);
|
||||
if (prezzo != NULL)
|
||||
linea_auto->put(RMOVMAG_PREZZO, prezzo);
|
||||
linea_auto->put(RMOVMAG_NRIG, r+1);
|
||||
linea_auto->put(RMOVMAG_TIPORIGA, (char) riga_automatica);
|
||||
linea_auto->put(RMOVMAG_CODCAUS, codcaus);
|
||||
b.insert_row(linea_auto);
|
||||
}
|
||||
}
|
||||
} // ciclo righe
|
||||
@ -955,14 +957,12 @@ int TMov_mag::write(TBaseisamfile& f) const
|
||||
{
|
||||
int res;
|
||||
((TMov_mag *)this)->add_automatiche();
|
||||
TToken_string l_key;
|
||||
TLine_movmag l_data;
|
||||
// memorizza le variazioni
|
||||
for (int i=0; i<rows(); i++) {
|
||||
l_key=line2key(i+1);
|
||||
l_data=line2data(i+1);
|
||||
((TMov_mag *)this)->line_inserted(l_key,l_data);
|
||||
}
|
||||
// memorizza le variazioni
|
||||
|
||||
const int nrows = rows();
|
||||
|
||||
for (int i = 1; i <= nrows; i++)
|
||||
((TMov_mag *)this)->line_inserted(line2key(i), line2data(i));
|
||||
if ((res=TMultiple_rectype::write(f))==NOERR )
|
||||
// effettua la variazione dei saldi
|
||||
res=((TMov_mag *)this)->update_balances();
|
||||
@ -973,14 +973,12 @@ int TMov_mag::rewrite(TBaseisamfile& f) const
|
||||
{
|
||||
int res;
|
||||
((TMov_mag *)this)->add_automatiche();
|
||||
TToken_string l_key;
|
||||
TLine_movmag l_data;
|
||||
// memorizza le variazioni
|
||||
for (int i=0; i<rows(); i++) {
|
||||
l_key=line2key(i+1);
|
||||
l_data=line2data(i+1);
|
||||
((TMov_mag *)this)->line_inserted(l_key,l_data);
|
||||
}
|
||||
// memorizza le variazioni
|
||||
|
||||
const int nrows = rows();
|
||||
|
||||
for (int i = 1; i < nrows; i++)
|
||||
((TMov_mag *)this)->line_inserted(line2key(i), line2data(i));
|
||||
if ((res=TMultiple_rectype::rewrite(f))==NOERR )
|
||||
// effettua la variazione dei saldi
|
||||
res=((TMov_mag *)this)->update_balances();
|
||||
@ -1010,35 +1008,40 @@ int TMov_mag::force_update_bal()
|
||||
_annoes=get(MOVMAG_ANNOES);
|
||||
lines_to_add.destroy();
|
||||
lines_to_subtract.destroy();
|
||||
|
||||
// memorizza le variazioni
|
||||
for (int i=0; i<rows(); i++) {
|
||||
l_key=line2key(i+1);
|
||||
l_data=line2data(i+1);
|
||||
line_inserted(l_key,l_data);
|
||||
}
|
||||
const int nrows = rows();
|
||||
|
||||
for (int i= 1; i <= nrows; i++)
|
||||
line_inserted(line2key(i), line2data(i));
|
||||
res=update_balances();
|
||||
return res;
|
||||
}
|
||||
|
||||
TLine_movmag TMov_mag::line2data(int numriga) const
|
||||
TLine_movmag & TMov_mag::line2data(int numriga) const
|
||||
{
|
||||
TLine_movmag rest;
|
||||
rest.um =(const char *)body().row(numriga).get("UM");
|
||||
rest.quant =(const char *)body().row(numriga).get("QUANT");
|
||||
rest.prezzo=(const char *)body().row(numriga).get("PREZZO");
|
||||
return rest;
|
||||
static TLine_movmag _rest;
|
||||
TRecord_array & b = body();
|
||||
|
||||
_rest.um = b.row(numriga).get("UM");
|
||||
_rest.quant = b.row(numriga).get_real("QUANT");
|
||||
_rest.prezzo= b.row(numriga).get_real("PREZZO");
|
||||
return _rest;
|
||||
}
|
||||
|
||||
TToken_string TMov_mag::line2key(int numriga) const
|
||||
TToken_string & TMov_mag::line2key(int numriga) const
|
||||
{
|
||||
TToken_string key;
|
||||
static TToken_string _key;
|
||||
TRecord_array & b = body();
|
||||
TString16 nr;
|
||||
nr << numriga;
|
||||
key.add(body().row(numriga).get("CODART"));
|
||||
key.add(body().row(numriga).get("CODMAG"));
|
||||
key.add(body().row(numriga).get("LIVGIAC"));
|
||||
key.add(nr);
|
||||
return key;
|
||||
|
||||
nr << numriga;
|
||||
_key.cut(0);
|
||||
_key.add(b.row(numriga).get(RMOVMAG_CODART));
|
||||
_key.add(b.row(numriga).get(RMOVMAG_CODMAG));
|
||||
_key.add(b.row(numriga).get(RMOVMAG_LIVGIAC));
|
||||
_key.add(nr);
|
||||
return _key;
|
||||
}
|
||||
|
||||
TString TMov_mag::key2field(TToken_string &key,const char *fieldname)
|
||||
|
Loading…
x
Reference in New Issue
Block a user