CAche sulle causali di magazzino in TMov_mag e TMovmag_Mask
Correzione update saldi per causali di riga git-svn-id: svn://10.65.10.50/trunk@4772 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
3576bcc68b
commit
e050b11c3a
@ -1,11 +1,12 @@
|
|||||||
// oggetto TArticolo, multirecord dell'articolo di anagrafica magazzino
|
// oggetto TArticolo, multirecord dell'articolo di anagrafica magazzino
|
||||||
// oggetto TArticolo_giacenza, multirecord dell'articolo di magazzino
|
// oggetto TArticolo_giacenza, multirecord dell'articolo di magazzino
|
||||||
// oggetto TMov_Mag , multirecord del moviemnto di magazzino
|
// oggetto TMov_Mag , multirecord del movimento di magazzino
|
||||||
// funzione di ricostruzione saldi
|
// funzione di ricostruzione saldi
|
||||||
#include "mglib.h"
|
#include "mglib.h"
|
||||||
#include "anamag.h"
|
#include "anamag.h"
|
||||||
#include "mag.h"
|
#include "mag.h"
|
||||||
#include "movmag.h"
|
#include "movmag.h"
|
||||||
|
#include "rmovmag.h"
|
||||||
|
|
||||||
// libreria per i movimenti
|
// libreria per i movimenti
|
||||||
|
|
||||||
@ -855,6 +856,23 @@ TCausale_magazzino::TCausale_magazzino(const char * codice):
|
|||||||
}
|
}
|
||||||
|
|
||||||
// movimenti
|
// movimenti
|
||||||
|
// dati della linea di movimento di magazzino
|
||||||
|
class TLine_movmag : public TObject
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
TString16 codcaus;
|
||||||
|
TString16 um;
|
||||||
|
real quant;
|
||||||
|
real prezzo;
|
||||||
|
int operator==(TLine_movmag &);
|
||||||
|
|
||||||
|
virtual TObject* dup() const {return new TLine_movmag(*this);};
|
||||||
|
|
||||||
|
TLine_movmag() {};
|
||||||
|
TLine_movmag(const TLine_movmag &);
|
||||||
|
virtual ~TLine_movmag() {};
|
||||||
|
};
|
||||||
|
|
||||||
TLine_movmag ::TLine_movmag(const TLine_movmag &l)
|
TLine_movmag ::TLine_movmag(const TLine_movmag &l)
|
||||||
{
|
{
|
||||||
um=l.um;
|
um=l.um;
|
||||||
@ -864,10 +882,15 @@ TLine_movmag ::TLine_movmag(const TLine_movmag &l)
|
|||||||
|
|
||||||
int TLine_movmag::operator==(TLine_movmag &l)
|
int TLine_movmag::operator==(TLine_movmag &l)
|
||||||
{
|
{
|
||||||
return (um==l.um)&&(quant==l.quant)&&(prezzo==l.prezzo);
|
return (codcaus==l.codcaus)&&(um==l.um)&&(quant==l.quant)&&(prezzo==l.prezzo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ********************************
|
||||||
|
// TMov_mag
|
||||||
|
|
||||||
|
TRecord_cache TMov_mag::cache_causali("%CAU");
|
||||||
|
|
||||||
|
|
||||||
TMov_mag::TMov_mag() :
|
TMov_mag::TMov_mag() :
|
||||||
TMultiple_rectype(LF_MOVMAG),
|
TMultiple_rectype(LF_MOVMAG),
|
||||||
@ -898,7 +921,6 @@ int TMov_mag::read(TBaseisamfile& f, word op , word lockop)
|
|||||||
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
|
||||||
_codcaus=get("CODCAUS");
|
|
||||||
_annoes=get("ANNOES");
|
_annoes=get("ANNOES");
|
||||||
lines_to_add.destroy();
|
lines_to_add.destroy();
|
||||||
lines_to_subtract.destroy();
|
lines_to_subtract.destroy();
|
||||||
@ -929,7 +951,7 @@ void TMov_mag::add_automatiche()
|
|||||||
TString16 codcaus(row.get(RMOVMAG_CODCAUS));
|
TString16 codcaus(row.get(RMOVMAG_CODCAUS));
|
||||||
if (codcaus.empty())
|
if (codcaus.empty())
|
||||||
codcaus=get(MOVMAG_CODCAUS);
|
codcaus=get(MOVMAG_CODCAUS);
|
||||||
TCausale_magazzino cau(codcaus);
|
TCausale_magazzino & cau=(TCausale_magazzino & )cache_causali.get(codcaus);
|
||||||
codcaus=cau.caus_collegata();
|
codcaus=cau.caus_collegata();
|
||||||
if (codcaus.not_empty())
|
if (codcaus.not_empty())
|
||||||
{
|
{
|
||||||
@ -1000,11 +1022,8 @@ const char *TMov_mag::get_next_key()
|
|||||||
int TMov_mag::force_update_bal()
|
int TMov_mag::force_update_bal()
|
||||||
{
|
{
|
||||||
int res;
|
int res;
|
||||||
TToken_string l_key;
|
|
||||||
TLine_movmag l_data;
|
|
||||||
|
|
||||||
// reset delle strutture per il controlli delle variazioni dei saldi
|
// reset delle strutture per il controlli delle variazioni dei saldi
|
||||||
_codcaus=get(MOVMAG_CODCAUS);
|
|
||||||
_annoes=get(MOVMAG_ANNOES);
|
_annoes=get(MOVMAG_ANNOES);
|
||||||
lines_to_add.destroy();
|
lines_to_add.destroy();
|
||||||
lines_to_subtract.destroy();
|
lines_to_subtract.destroy();
|
||||||
@ -1018,14 +1037,18 @@ int TMov_mag::force_update_bal()
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
TLine_movmag & TMov_mag::line2data(int numriga) const
|
// restituisce
|
||||||
|
TLine_movmag & TMov_mag::line2data(int nrig) const
|
||||||
{
|
{
|
||||||
static TLine_movmag _rest;
|
static TLine_movmag _rest;
|
||||||
TRecord_array & b = body();
|
TRecord_array & b = body();
|
||||||
|
|
||||||
_rest.um = b.row(numriga).get("UM");
|
_rest.codcaus= b.row(nrig).get(RMOVMAG_CODCAUS) != " " ?
|
||||||
_rest.quant = b.row(numriga).get_real("QUANT");
|
b.row(nrig).get(RMOVMAG_CODCAUS)
|
||||||
_rest.prezzo= b.row(numriga).get_real("PREZZO");
|
: get(MOVMAG_CODCAUS);
|
||||||
|
_rest.um = b.row(nrig).get(RMOVMAG_UM);
|
||||||
|
_rest.quant = b.row(nrig).get_real(RMOVMAG_QUANT);
|
||||||
|
_rest.prezzo= b.row(nrig).get_real(RMOVMAG_PREZZO);
|
||||||
return _rest;
|
return _rest;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1059,7 +1082,7 @@ TString TMov_mag::key2field(TToken_string &key,const char *fieldname)
|
|||||||
|
|
||||||
int TMov_mag::line_inserted(TToken_string &k,TLine_movmag &r)
|
int TMov_mag::line_inserted(TToken_string &k,TLine_movmag &r)
|
||||||
{
|
{
|
||||||
if (_codcaus != get("CODCAUS") || _annoes != get("ANNOES")) {
|
if (_annoes != get("ANNOES")) {
|
||||||
lines_to_add.add(k,r);
|
lines_to_add.add(k,r);
|
||||||
} else {
|
} else {
|
||||||
if (lines_to_subtract.is_key(k)&& (TLine_movmag &)lines_to_subtract[k]==r)
|
if (lines_to_subtract.is_key(k)&& (TLine_movmag &)lines_to_subtract[k]==r)
|
||||||
@ -1074,7 +1097,7 @@ int TMov_mag::line_inserted(TToken_string &k,TLine_movmag &r)
|
|||||||
|
|
||||||
int TMov_mag::line_deleted(TToken_string &k,TLine_movmag &r)
|
int TMov_mag::line_deleted(TToken_string &k,TLine_movmag &r)
|
||||||
{
|
{
|
||||||
if (_codcaus != get("CODCAUS") || _annoes != get("ANNOES")) {
|
if (_annoes != get("ANNOES")) {
|
||||||
lines_to_subtract.add(k,r);
|
lines_to_subtract.add(k,r);
|
||||||
} else {
|
} else {
|
||||||
if (lines_to_add.is_key(k)&& r==(TLine_movmag &)lines_to_add[k] )
|
if (lines_to_add.is_key(k)&& r==(TLine_movmag &)lines_to_add[k] )
|
||||||
@ -1152,12 +1175,12 @@ int TMov_mag::update_balances()
|
|||||||
mag.write();
|
mag.write();
|
||||||
}
|
}
|
||||||
// modifica questo record (e lo sblocca)
|
// modifica questo record (e lo sblocca)
|
||||||
update_balances(mag.curr(),line_mov,get("CODCAUS"),+1);
|
update_balances(mag.curr(),line_mov, +1);
|
||||||
/*// ottimizzazione :(cerca di sfruttare la lettura fatta per un eventuale saldo vecchio)
|
/*// ottimizzazione :(cerca di sfruttare la lettura fatta per un eventuale saldo vecchio)
|
||||||
// ciò causa la modifica dell'oggetto TMov_mag (il metodo non è più const)
|
// ciò causa la modifica dell'oggetto TMov_mag (il metodo non è più const)
|
||||||
if (_annoes == get("ANNOES")
|
if (_annoes == get("ANNOES")
|
||||||
&& lines_to_subtract.is_key(*curr_key)) {
|
&& lines_to_subtract.is_key(*curr_key)) {
|
||||||
update_balances(mag.curr(),(TLine_movmag &)lines_to_subtract[*curr_key],_codcaus,-1);
|
update_balances(mag.curr(),(TLine_movmag &)lines_to_subtract[*curr_key],-1);
|
||||||
((TMov_mag *)this)->lines_to_add.remove(*curr_key);
|
((TMov_mag *)this)->lines_to_add.remove(*curr_key);
|
||||||
((TMov_mag *)this)->lines_to_subtract.remove(*curr_key);
|
((TMov_mag *)this)->lines_to_subtract.remove(*curr_key);
|
||||||
}*/
|
}*/
|
||||||
@ -1168,7 +1191,7 @@ int TMov_mag::update_balances()
|
|||||||
if (key2field(*rem_key,"CODART")==key2field(*curr_key,"CODART")) {
|
if (key2field(*rem_key,"CODART")==key2field(*curr_key,"CODART")) {
|
||||||
giac_putkey(mag,_annoes,*rem_key);
|
giac_putkey(mag,_annoes,*rem_key);
|
||||||
if (mag.read()==NOERR) {
|
if (mag.read()==NOERR) {
|
||||||
update_balances(mag.curr(),(TLine_movmag &)lines_to_subtract[*rem_key],_codcaus,-1);
|
update_balances(mag.curr(),(TLine_movmag &)lines_to_subtract[*rem_key],-1);
|
||||||
mag.rewrite();
|
mag.rewrite();
|
||||||
}
|
}
|
||||||
keys_to_remove.remove_item();
|
keys_to_remove.remove_item();
|
||||||
@ -1190,7 +1213,7 @@ int TMov_mag::update_balances()
|
|||||||
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],-1);
|
||||||
mag.rewrite();
|
mag.rewrite();
|
||||||
}
|
}
|
||||||
curr_art.unlock();
|
curr_art.unlock();
|
||||||
@ -1208,9 +1231,9 @@ int TMov_mag::update_balances()
|
|||||||
|
|
||||||
// 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)
|
int TMov_mag::update_balances(TRectype & magrec, const TLine_movmag &l,int rett_sign)
|
||||||
{
|
{
|
||||||
TCausale_magazzino caus(codcaus);
|
TCausale_magazzino & caus=(TCausale_magazzino &)cache_causali.get(l.codcaus);
|
||||||
TLocalisamfile umart(LF_UMART);
|
TLocalisamfile umart(LF_UMART);
|
||||||
real diff,diff_val;
|
real diff,diff_val;
|
||||||
umart.setkey(2);
|
umart.setkey(2);
|
||||||
@ -1324,10 +1347,3 @@ bool rebuild_balances(TString16 annoes, bool reset_giac)
|
|||||||
|
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user