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):
|
TCausale_magazzino::TCausale_magazzino(const char * codice):
|
||||||
TRectype(LF_TABCOM)
|
TRectype(LF_TABCOM)
|
||||||
{
|
{
|
||||||
TTable f("%CAU");
|
TTable f("%CAU");
|
||||||
f.put("CODTAB",codice);
|
|
||||||
if (f.read() != NOERR)
|
settab("CAU");
|
||||||
|
put("CODTAB", codice);
|
||||||
|
if (TRectype::read(f) != NOERR)
|
||||||
zero();
|
zero();
|
||||||
else
|
}
|
||||||
*this=(TCausale_magazzino &)f.curr();
|
|
||||||
}
|
|
||||||
TCausale_magazzino::~TCausale_magazzino()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
// movimenti
|
// movimenti
|
||||||
TLine_movmag ::TLine_movmag(const TLine_movmag &l)
|
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
|
// copia la chiave dal file principale a quello delle righe
|
||||||
void TMov_mag::set_body_key(TRectype & rowrec)
|
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)
|
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);
|
int res=TMultiple_rectype::read(f,op,lockop);
|
||||||
|
|
||||||
// reset delle strutture per il controlli delle variazioni dei saldi
|
// 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");
|
_annoes=get("ANNOES");
|
||||||
lines_to_add.destroy();
|
lines_to_add.destroy();
|
||||||
lines_to_subtract.destroy();
|
lines_to_subtract.destroy();
|
||||||
for (int i=0; i<rows(); i++) {
|
|
||||||
l_key=line2key(i+1);
|
const int nrows = rows();
|
||||||
l_data=line2data(i+1);
|
|
||||||
line_deleted(l_key,l_data);
|
for (int i = 1; i< nrows; i++)
|
||||||
}
|
line_deleted(line2key(i), line2data(i));
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -928,24 +922,32 @@ int TMov_mag::remove(TBaseisamfile& f) const
|
|||||||
|
|
||||||
void TMov_mag::add_automatiche()
|
void TMov_mag::add_automatiche()
|
||||||
{
|
{
|
||||||
for (int r=rows(); r>0; r--)
|
for (int r = rows(); r > 0; r--)
|
||||||
{
|
{
|
||||||
TString16 codcaus(body()[r].get(RMOVMAG_CODCAUS));
|
TRecord_array & b = body();
|
||||||
if (codcaus.blank())
|
TRectype & row = b[r];
|
||||||
codcaus=get(RMOVMAG_CODCAUS);
|
TString16 codcaus(row.get(RMOVMAG_CODCAUS));
|
||||||
|
if (codcaus.empty())
|
||||||
|
codcaus=get(MOVMAG_CODCAUS);
|
||||||
TCausale_magazzino cau(codcaus);
|
TCausale_magazzino cau(codcaus);
|
||||||
if (*cau.get_collegata()!='\0')
|
codcaus=cau.caus_collegata();
|
||||||
|
if (codcaus.not_empty())
|
||||||
{
|
{
|
||||||
// deve esserci una riga collegata
|
// 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
|
// manca, la inserisco
|
||||||
TRectype linea_auto(body()[r]);
|
TRectype * linea_auto = new TRectype(row);
|
||||||
|
const char * codmag = codmag_rauto(r);
|
||||||
if (codmag_rauto(r)!=NULL) linea_auto.put(RMOVMAG_CODMAG,codmag_rauto(r));
|
if (codmag != NULL)
|
||||||
if (prezzo_rauto(r)!=NULL) linea_auto.put(RMOVMAG_PREZZO,prezzo_rauto(r));
|
linea_auto->put(RMOVMAG_CODMAG, codmag);
|
||||||
linea_auto.put(RMOVMAG_NRIG,r+1);
|
const char * prezzo = prezzo_rauto(r);
|
||||||
body().insert_row(&linea_auto);
|
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
|
} // ciclo righe
|
||||||
@ -955,14 +957,12 @@ int TMov_mag::write(TBaseisamfile& f) const
|
|||||||
{
|
{
|
||||||
int res;
|
int res;
|
||||||
((TMov_mag *)this)->add_automatiche();
|
((TMov_mag *)this)->add_automatiche();
|
||||||
TToken_string l_key;
|
// memorizza le variazioni
|
||||||
TLine_movmag l_data;
|
|
||||||
// memorizza le variazioni
|
const int nrows = rows();
|
||||||
for (int i=0; i<rows(); i++) {
|
|
||||||
l_key=line2key(i+1);
|
for (int i = 1; i <= nrows; i++)
|
||||||
l_data=line2data(i+1);
|
((TMov_mag *)this)->line_inserted(line2key(i), line2data(i));
|
||||||
((TMov_mag *)this)->line_inserted(l_key,l_data);
|
|
||||||
}
|
|
||||||
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=((TMov_mag *)this)->update_balances();
|
res=((TMov_mag *)this)->update_balances();
|
||||||
@ -973,14 +973,12 @@ int TMov_mag::rewrite(TBaseisamfile& f) const
|
|||||||
{
|
{
|
||||||
int res;
|
int res;
|
||||||
((TMov_mag *)this)->add_automatiche();
|
((TMov_mag *)this)->add_automatiche();
|
||||||
TToken_string l_key;
|
// memorizza le variazioni
|
||||||
TLine_movmag l_data;
|
|
||||||
// memorizza le variazioni
|
const int nrows = rows();
|
||||||
for (int i=0; i<rows(); i++) {
|
|
||||||
l_key=line2key(i+1);
|
for (int i = 1; i < nrows; i++)
|
||||||
l_data=line2data(i+1);
|
((TMov_mag *)this)->line_inserted(line2key(i), line2data(i));
|
||||||
((TMov_mag *)this)->line_inserted(l_key,l_data);
|
|
||||||
}
|
|
||||||
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=((TMov_mag *)this)->update_balances();
|
res=((TMov_mag *)this)->update_balances();
|
||||||
@ -1010,35 +1008,40 @@ int TMov_mag::force_update_bal()
|
|||||||
_annoes=get(MOVMAG_ANNOES);
|
_annoes=get(MOVMAG_ANNOES);
|
||||||
lines_to_add.destroy();
|
lines_to_add.destroy();
|
||||||
lines_to_subtract.destroy();
|
lines_to_subtract.destroy();
|
||||||
|
|
||||||
// memorizza le variazioni
|
// memorizza le variazioni
|
||||||
for (int i=0; i<rows(); i++) {
|
const int nrows = rows();
|
||||||
l_key=line2key(i+1);
|
|
||||||
l_data=line2data(i+1);
|
for (int i= 1; i <= nrows; i++)
|
||||||
line_inserted(l_key,l_data);
|
line_inserted(line2key(i), line2data(i));
|
||||||
}
|
|
||||||
res=update_balances();
|
res=update_balances();
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
TLine_movmag TMov_mag::line2data(int numriga) const
|
TLine_movmag & TMov_mag::line2data(int numriga) const
|
||||||
{
|
{
|
||||||
TLine_movmag rest;
|
static TLine_movmag _rest;
|
||||||
rest.um =(const char *)body().row(numriga).get("UM");
|
TRecord_array & b = body();
|
||||||
rest.quant =(const char *)body().row(numriga).get("QUANT");
|
|
||||||
rest.prezzo=(const char *)body().row(numriga).get("PREZZO");
|
_rest.um = b.row(numriga).get("UM");
|
||||||
return rest;
|
_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;
|
TString16 nr;
|
||||||
nr << numriga;
|
|
||||||
key.add(body().row(numriga).get("CODART"));
|
nr << numriga;
|
||||||
key.add(body().row(numriga).get("CODMAG"));
|
_key.cut(0);
|
||||||
key.add(body().row(numriga).get("LIVGIAC"));
|
_key.add(b.row(numriga).get(RMOVMAG_CODART));
|
||||||
key.add(nr);
|
_key.add(b.row(numriga).get(RMOVMAG_CODMAG));
|
||||||
return key;
|
_key.add(b.row(numriga).get(RMOVMAG_LIVGIAC));
|
||||||
|
_key.add(nr);
|
||||||
|
return _key;
|
||||||
}
|
}
|
||||||
|
|
||||||
TString TMov_mag::key2field(TToken_string &key,const char *fieldname)
|
TString TMov_mag::key2field(TToken_string &key,const char *fieldname)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user