Iniziato calcolo inventario alla data
git-svn-id: svn://10.65.10.50/branches/R_10_00@22792 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
b2556eb707
commit
844e3440ee
@ -10,6 +10,7 @@ int main(int argc, char** argv)
|
||||
switch (r)
|
||||
{
|
||||
case 1: mg1200(argc,argv); break; // ricostruzione saldi
|
||||
case 2: mg1300(argc,argv); break; // giacenze alla data
|
||||
case 3: mg1400(argc,argv); break; // gestione aperture/chiusure
|
||||
default: mg1100(argc,argv); break; // gestione interattiva movimenti
|
||||
}
|
||||
|
1
mg/mg1.h
1
mg/mg1.h
@ -3,6 +3,7 @@
|
||||
|
||||
int mg1100(int argc, char* argv[]);
|
||||
int mg1200(int argc, char* argv[]);
|
||||
int mg1300(int argc, char* argv[]);
|
||||
int mg1400(int argc, char* argv[]);
|
||||
|
||||
#endif // __MG1_H
|
||||
|
235
mg/mg1300.cpp
Normal file
235
mg/mg1300.cpp
Normal file
@ -0,0 +1,235 @@
|
||||
#include <applicat.h>
|
||||
#include <automask.h>
|
||||
#include <progind.h>
|
||||
#include <recarray.h>
|
||||
#include <relation.h>
|
||||
#include <recset.h>
|
||||
#include <toolfld.h>
|
||||
|
||||
#include "mglib.h"
|
||||
|
||||
#include "mg1300a.h"
|
||||
|
||||
#include "../mg/mag.h"
|
||||
#include "../mg/movmag.h"
|
||||
#include "../mg/rmovmag.h"
|
||||
|
||||
class TSaldodata_mask : public TAutomask
|
||||
{
|
||||
protected:
|
||||
virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly);
|
||||
|
||||
public:
|
||||
TSaldodata_mask() : TAutomask("mg1300a") {}
|
||||
};
|
||||
|
||||
bool TSaldodata_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
|
||||
{
|
||||
if (e == fe_button && o.dlg() == DLG_PREVIEW)
|
||||
{
|
||||
TString query;
|
||||
query = "USE &MAG";
|
||||
|
||||
const TString& codmag = get(get_bool(F_USEDEP) ? F_DEP : F_MAG);
|
||||
if (codmag.full())
|
||||
{
|
||||
query << "\nFROM CODTAB=" << codmag
|
||||
<< "\nTO CODTAB=" << codmag;
|
||||
}
|
||||
TISAM_recordset recset(query);
|
||||
TCursor_sheet s(recset.cursor(), "CODTAB[1,5]|CODTAB[6,25]|CODTAB[26,35]|R0|R1|D0", TR("Situazione"),
|
||||
HR("Mag+Dep|Articolo@20|Livello@10|Giacenza@12V|Fisico@12V|Data@10"), 0, 1);
|
||||
s.run();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
class TSaldodata_app : public TSkeleton_application
|
||||
{
|
||||
protected:
|
||||
void reset_saldi(const TDate& data, const TString& codmag);
|
||||
void init_saldi_iniziali(const TDate& data, bool use_dep,const TString& codmag, TAssoc_array& saldi);
|
||||
void update_saldi(const TDate& data, bool use_dep, const TString& codmag, TAssoc_array& saldi);
|
||||
void rebuild_saldi(const TDate& data, bool use_dep, const TString& codmag);
|
||||
|
||||
public:
|
||||
virtual void main_loop();
|
||||
};
|
||||
|
||||
void TSaldodata_app::reset_saldi(const TDate& data, const TString& codmag)
|
||||
{
|
||||
TFast_isamfile mag(LF_TABMOD);
|
||||
|
||||
TString query;
|
||||
query = "USE &MAG";
|
||||
if (codmag.full())
|
||||
{
|
||||
query << "\nFROM CODTAB=" << codmag
|
||||
<< "\nTO CODTAB=" << codmag;
|
||||
}
|
||||
TISAM_recordset recset(query);
|
||||
TProgind pi(recset.items(), TR("Azzeramento"));
|
||||
TRectype& rec = recset.cursor()->curr();
|
||||
for (bool ok = recset.move_first(); ok; ok = recset.move_next())
|
||||
{
|
||||
if (!pi.addstatus(1))
|
||||
break;
|
||||
|
||||
rec.zero("R0");
|
||||
rec.zero("R1");
|
||||
rec.put("D0", data);
|
||||
rec.rewrite(mag);
|
||||
}
|
||||
}
|
||||
|
||||
void TSaldodata_app::init_saldi_iniziali(const TDate& data, bool use_dep, const TString& codmag, TAssoc_array& saldi)
|
||||
{
|
||||
TString limit;
|
||||
limit << " ANNOES=" << (data.year()-1);
|
||||
if (codmag.full())
|
||||
limit << " CODMAG=" << codmag;
|
||||
|
||||
TString query;
|
||||
query << "USE " << LF_MAG << " KEY 2"
|
||||
<< "\nFROM" << limit << "\nTO" << limit;
|
||||
|
||||
TISAM_recordset recset(query);
|
||||
TToken_string key;
|
||||
TProgind pi(recset.items(), TR("Saldi iniziali"));
|
||||
for (bool ok = recset.move_first(); ok; ok = recset.move_next())
|
||||
{
|
||||
if (!pi.addstatus(1))
|
||||
break;
|
||||
const real g = recset.get(MAG_GIAC).as_real();
|
||||
if (!g.is_zero())
|
||||
{
|
||||
key = recset.get(MAG_CODMAG).as_string();
|
||||
if (!use_dep) key.cut(3);
|
||||
key.add(recset.get(MAG_CODART).as_string());
|
||||
key.add(recset.get(MAG_LIVELLO).as_string());
|
||||
real* giac = (real*)saldi.objptr(key);
|
||||
if (giac == NULL)
|
||||
saldi.add(key, g);
|
||||
else
|
||||
*giac += g;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TSaldodata_app::update_saldi(const TDate& data, bool use_dep, const TString& mag, TAssoc_array& saldi)
|
||||
{
|
||||
TString query;
|
||||
query << "USE MOVMAG KEY 2 SELECT BETWEEN(DATAREG,0," << data.date2ansi() << ')'
|
||||
<< "\nFROM ANNOES=" << data.year()
|
||||
<< "\nTO ANNOES=" << data.year();
|
||||
TISAM_recordset recset(query);
|
||||
TProgind pi(recset.items(), TR("Scansione movimenti"));
|
||||
TToken_string key;
|
||||
for (bool ok = recset.move_first(); ok; ok = recset.move_next())
|
||||
{
|
||||
if (!pi.addstatus(1))
|
||||
break;
|
||||
const TString8 hcaus = recset.get(MOVMAG_CODCAUS).as_string();
|
||||
key = recset.get(MOVMAG_NUMREG).as_string();
|
||||
TRecord_array righe(key, LF_RMOVMAG);
|
||||
for (int i = righe.last_row(); i > 0; i = righe.pred_row(i))
|
||||
{
|
||||
real qta = recset.get(RMOVMAG_QUANT).as_real();
|
||||
if (qta.is_zero())
|
||||
continue;
|
||||
|
||||
const TString& rcaus = recset.get(RMOVMAG_CODCAUS).as_string();
|
||||
const TCausale_magazzino& caus = cached_causale_magazzino(rcaus.full() ? rcaus : hcaus);
|
||||
const int sgn = caus.sgn(s_giac);
|
||||
if (sgn != 0 && caus.update_qta())
|
||||
{
|
||||
TString8 codmag = recset.get(RMOVMAG_CODMAG).as_string();
|
||||
if (!use_dep) codmag.cut(3);
|
||||
if (mag.full() && codmag != mag)
|
||||
continue;
|
||||
|
||||
const TString80 codart = recset.get(RMOVMAG_CODART).as_string();
|
||||
const TString4 um = recset.get(RMOVMAG_UM).as_string();
|
||||
TArticolo& art = cached_article(codart);
|
||||
qta = art.convert_to_um(qta, EMPTY_STRING, um);
|
||||
|
||||
key = codmag;
|
||||
key.add(codart);
|
||||
key.add(recset.get(RMOVMAG_LIVGIAC).as_string());
|
||||
|
||||
real* giac = (real*)saldi.objptr(key);
|
||||
if (giac == NULL)
|
||||
{
|
||||
giac = new real;
|
||||
saldi.add(key, giac);
|
||||
}
|
||||
if (sgn > 0)
|
||||
*giac += qta;
|
||||
else
|
||||
*giac -= qta;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TSaldodata_app::rebuild_saldi(const TDate& data, bool use_dep, const TString& codmag)
|
||||
{
|
||||
TAssoc_array saldi;
|
||||
init_saldi_iniziali(data, use_dep, codmag, saldi);
|
||||
update_saldi(data, use_dep, codmag, saldi);
|
||||
|
||||
TFast_isamfile mag(LF_TABMOD);
|
||||
TToken_string k;
|
||||
TString80 codtab;
|
||||
|
||||
TProgind pi(saldi.items(), TR("Salvataggio inventario"));
|
||||
FOR_EACH_ASSOC_OBJECT(saldi, hash, key, obj)
|
||||
{
|
||||
if (!pi.addstatus(1))
|
||||
break;
|
||||
k = key;
|
||||
codtab.format("%-5s%-20s", k.get(0), k.get(1));
|
||||
const char* liv = k.get(2);
|
||||
if (liv && *liv > ' ')
|
||||
codtab << liv;
|
||||
mag.put("MOD", "MG");
|
||||
mag.put("COD", "MAG");
|
||||
mag.put("CODTAB", codtab);
|
||||
if (mag.read() != NOERR)
|
||||
{
|
||||
mag.zero();
|
||||
mag.put("MOD", "MG");
|
||||
mag.put("COD", "MAG");
|
||||
mag.put("CODTAB", codtab);
|
||||
mag.write();
|
||||
}
|
||||
mag.put("R0", *(real*)obj);
|
||||
mag.put("D0", data);
|
||||
if (mag.rewrite() != NOERR)
|
||||
{
|
||||
cantwrite_box("inventario alla data");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TSaldodata_app::main_loop()
|
||||
{
|
||||
TSaldodata_mask m;
|
||||
while (m.run()==K_ENTER)
|
||||
{
|
||||
const TDate al = m.get(F_DATA);
|
||||
const bool use_dep = m.get_bool(F_USEDEP);
|
||||
const TString& mag = m.get(use_dep ? F_DEP : F_MAG);
|
||||
reset_saldi(al, mag);
|
||||
rebuild_saldi(al, use_dep, mag);
|
||||
}
|
||||
}
|
||||
|
||||
int mg1300(int argc, char* argv[])
|
||||
{
|
||||
TSaldodata_app a;
|
||||
a.run(argc, argv, TR("Giacenza alla data"));
|
||||
return 0;
|
||||
}
|
||||
|
4
mg/mg1300a.h
Normal file
4
mg/mg1300a.h
Normal file
@ -0,0 +1,4 @@
|
||||
#define F_DATA 101
|
||||
#define F_USEDEP 102
|
||||
#define F_MAG 103
|
||||
#define F_DEP 104
|
58
mg/mg1300a.uml
Normal file
58
mg/mg1300a.uml
Normal file
@ -0,0 +1,58 @@
|
||||
#include "mg1300a.h"
|
||||
|
||||
PAGE "Giacenza alla data" -1 -1 40 3
|
||||
|
||||
DATE F_DATA
|
||||
BEGIN
|
||||
PROMPT 1 0 "Data "
|
||||
FLAGS "A"
|
||||
END
|
||||
|
||||
BOOLEAN F_USEDEP
|
||||
BEGIN
|
||||
PROMPT 1 1 "Suddivisione per deposito"
|
||||
MESSAGE FALSE HIDE,F_DEP|SHOW,F_MAG
|
||||
MESSAGE TRUE HIDE,F_MAG|SHOW,F_DEP
|
||||
END
|
||||
|
||||
STRING F_MAG 3
|
||||
BEGIN
|
||||
PROMPT 1 2 "Magazzino "
|
||||
USE MAG SELECT CODTAB[4,4]=''
|
||||
INPUT CODTAB F_MAG
|
||||
DISPLAY "Codice" CODTAB
|
||||
DISPLAY "Descrizione@50" S0
|
||||
OUTPUT F_MAG CODTAB
|
||||
CHECKTYPE NORMAL
|
||||
HELP "Elabora tutti i magazzini se vuoto"
|
||||
END
|
||||
|
||||
STRING F_DEP 5
|
||||
BEGIN
|
||||
PROMPT 1 2 "Deposito "
|
||||
USE MAG SELECT CODTAB[4,4]!=''
|
||||
INPUT CODTAB F_DEP
|
||||
COPY DISPLAY F_MAG
|
||||
OUTPUT F_DEP CODTAB
|
||||
CHECKTYPE NORMAL
|
||||
FLAGS "H"
|
||||
HELP "Elabora tutti i depositi se vuoto"
|
||||
END
|
||||
|
||||
ENDPAGE
|
||||
|
||||
TOOLBAR "topbar" 0 0 0 2
|
||||
|
||||
BUTTON DLG_PREVIEW 2 2
|
||||
BEGIN
|
||||
PROMPT 1 1 "Situazione"
|
||||
PICTURE TOOL_PREVIEW
|
||||
END
|
||||
|
||||
#include <elabar.h>
|
||||
|
||||
ENDPAGE
|
||||
|
||||
|
||||
ENDMASK
|
||||
|
@ -60,7 +60,7 @@ END
|
||||
|
||||
LISTBOX F_ORDINE 15
|
||||
BEGIN
|
||||
PROMPT 2 2 "Ordinamento "
|
||||
PROMPT 2 2 "Ordinamento "
|
||||
ITEM "A|Articoli"
|
||||
MESSAGE SHOW,F_SUBORDINE|HIDE,F_TOTALIDEPOSITI|"X",F_DETTAGLIODEP
|
||||
MESSAGE SHOW,F_TOTALIMAGAZZINI|SHOW,F_DETTAGLIOMAG
|
||||
@ -96,7 +96,7 @@ END
|
||||
NUMBER F_ANNOES 4
|
||||
BEGIN
|
||||
FLAGS "AZ"
|
||||
PROMPT 2 4 "Codice es. "
|
||||
PROMPT 2 4 "Esercizio "
|
||||
USE ESC
|
||||
INPUT CODTAB F_ANNOES
|
||||
DISPLAY "Esercizio" CODTAB
|
||||
@ -120,7 +120,7 @@ END
|
||||
|
||||
TEXT DLG_NULL
|
||||
BEGIN
|
||||
PROMPT 16 5 "@bDall'articolo"
|
||||
PROMPT 15 5 "@bDall'articolo"
|
||||
END
|
||||
|
||||
TEXT DLG_NULL
|
||||
@ -130,7 +130,7 @@ END
|
||||
|
||||
STRING F_DAART 20
|
||||
BEGIN
|
||||
PROMPT 2 6 "Codice "
|
||||
PROMPT 2 6 "Codice "
|
||||
FLAGS "U"
|
||||
USE LF_ANAMAG
|
||||
INPUT CODART F_DAART
|
||||
@ -144,7 +144,7 @@ END
|
||||
|
||||
STRING F_DADES 50 28
|
||||
BEGIN
|
||||
PROMPT 2 7 "Descrizione "
|
||||
PROMPT 2 7 "Descrizione "
|
||||
FLAGS "U"
|
||||
USE LF_ANAMAG KEY 2
|
||||
INPUT DESCR F_DADES
|
||||
|
@ -553,7 +553,7 @@ protected:
|
||||
// @member: effettua l'aggiornamento dei saldi relativi alle giacenze interessate al movimento
|
||||
bool update_balances(bool lock = true) ;
|
||||
// @member: effettua l'aggiornamento dei saldi di una giacenza
|
||||
void update_balances(TRectype& magrec, const TSaldo_mag & s) ;
|
||||
void update_balances(TRectype& magrec, const TSaldo_mag& s, const TCausale_magazzino& caus) const;
|
||||
// @member: effettua l'aggiornamento dei saldi di una giacenza sulle gacenze per ciente/fornitore
|
||||
void update_balances_clifo(TRectype& clifomagrec, const TSaldo_mag_clifo & s);
|
||||
// @member: effettua l'aggiornamento di un saldo di una giacenza
|
||||
@ -593,7 +593,7 @@ public:
|
||||
void update_balances_clifo(TRectype& cliforec, int numrig, bool plus = true);
|
||||
|
||||
//
|
||||
int codice_esercizio(const TDate &d);
|
||||
int codice_esercizio(const TDate& d) const;
|
||||
|
||||
// costruttori e distruttori
|
||||
TMov_mag();
|
||||
|
@ -1000,7 +1000,7 @@ void TMagazzini::init()
|
||||
|
||||
void TMagazzini::test_firm() const
|
||||
{
|
||||
long firm = prefix().get_codditta();
|
||||
const long firm = prefix().get_codditta();
|
||||
if (firm > 0 && firm != _last_firm)
|
||||
((TMagazzini *)this)->init();
|
||||
}
|
||||
@ -1051,18 +1051,17 @@ bool riporta_ordinato()
|
||||
if (__firm != cur_firm)
|
||||
{
|
||||
__firm = cur_firm;
|
||||
TConfig c(CONFIG_DITTA, "mg");
|
||||
__riporta_ordinato = c.get_bool("RIPORD");
|
||||
__riporta_ordinato = ini_get_bool(CONFIG_DITTA, "mg", "RIPORD");
|
||||
}
|
||||
return __riporta_ordinato;
|
||||
}
|
||||
|
||||
const char * get_magcode(TString & codmagdep)
|
||||
const char * get_magcode(const TString & codmagdep)
|
||||
{
|
||||
return codmagdep.left(3);
|
||||
}
|
||||
|
||||
const char * get_depcode(TString & codmagdep)
|
||||
const char * get_depcode(const TString & codmagdep)
|
||||
{
|
||||
return codmagdep.mid(3);
|
||||
}
|
||||
|
@ -6,7 +6,6 @@
|
||||
#include <diction.h>
|
||||
#include <fraction.h>
|
||||
#include <progind.h>
|
||||
#include <utility.h>
|
||||
|
||||
#include "mglib.h"
|
||||
#include "../cg/cglib01.h"
|
||||
@ -394,11 +393,10 @@ TArticolo::TArticolo(const TRectype& rec)
|
||||
class TCache_articoli : public TRecord_cache
|
||||
{
|
||||
protected:
|
||||
virtual TObject* rec2obj(const TRectype& rec) const{ return new TArticolo(rec); }
|
||||
|
||||
virtual TObject* rec2obj(const TRectype& rec) const { return new TArticolo(rec); }
|
||||
|
||||
public:
|
||||
TArticolo& art(const char* key){ return (TArticolo_giacenza&)query(key); }
|
||||
TArticolo& art(const char* key) { return (TArticolo&)query(key); }
|
||||
|
||||
TCache_articoli();
|
||||
virtual ~TCache_articoli() { }
|
||||
@ -406,7 +404,7 @@ public:
|
||||
|
||||
|
||||
TCache_articoli::TCache_articoli()
|
||||
: TRecord_cache(LF_ANAMAG, 1)
|
||||
: TRecord_cache(LF_ANAMAG, 1)
|
||||
{
|
||||
test_file_changes(); // Tieni d'occhio le modifiche sul file
|
||||
set_items_limit(257); // Numero primo!
|
||||
@ -756,7 +754,7 @@ bool TArticolo_giacenza::riporta_saldi(int oldes, int newes, const TTipo_valoriz
|
||||
|
||||
if (row >= 0)
|
||||
{
|
||||
const TRectype & oldrec = oldmag[row];
|
||||
const TRectype& oldrec = oldmag[row];
|
||||
|
||||
for (int i = 0; protected_fields[i]; i++)
|
||||
{
|
||||
@ -805,7 +803,7 @@ real TArticolo_giacenza::disponibilita(const char * annoes, const char * codmag,
|
||||
giac += rec.get_real(MAG_ACL) - rec.get_real(MAG_INCL);
|
||||
}
|
||||
}
|
||||
if (!solo_giac && !riporta_ordinato()) // Se l-ordinato viene riportato
|
||||
if (!solo_giac && !riporta_ordinato()) // Se l'ordinato viene riportato
|
||||
{
|
||||
const int prev = esercizi().pred(atoi(annoes)); // Controllo anche l'anno precedente
|
||||
if (prev > 0)
|
||||
@ -864,12 +862,10 @@ real TArticolo_giacenza::media_costi(int annoes) const
|
||||
if (nextes > 0)
|
||||
{
|
||||
const int index = find_storico(nextes);
|
||||
|
||||
if (index >= 0 )
|
||||
{
|
||||
const TRectype & rec = storico(nextes).row(index);
|
||||
real costo = rec.get_real(STOMAG_ULTCOS1);
|
||||
|
||||
costo = (costo + rec.get_real(STOMAG_ULTCOS2)) / 2.0;
|
||||
return costo.is_zero() ? costo_standard(annoes) : costo;
|
||||
}
|
||||
@ -1797,9 +1793,8 @@ class TCache_causali_magazzino : public TRecord_cache
|
||||
protected:
|
||||
virtual TObject* rec2obj(const TRectype& rec) const{ return new TCausale_magazzino(rec); }
|
||||
|
||||
|
||||
public:
|
||||
TCausale_magazzino & caus(const char* key);
|
||||
TCausale_magazzino& caus(const char* key);
|
||||
|
||||
TCache_causali_magazzino();
|
||||
virtual ~TCache_causali_magazzino() { }
|
||||
@ -1807,7 +1802,7 @@ public:
|
||||
|
||||
|
||||
TCache_causali_magazzino::TCache_causali_magazzino()
|
||||
: TRecord_cache("%CAU", 1)
|
||||
: TRecord_cache("%CAU", 1)
|
||||
{
|
||||
test_file_changes(); // Tieni d'occhio le modifiche sul file
|
||||
set_items_limit(83); // Numero primo
|
||||
@ -1824,7 +1819,6 @@ TCausale_magazzino & TCache_causali_magazzino::caus(const char* key)
|
||||
TCausale_magazzino & cached_causale_magazzino(const char * codcaus)
|
||||
{
|
||||
HIDDEN TCache_causali_magazzino __cache_causali_magazzino;
|
||||
|
||||
return __cache_causali_magazzino.caus(codcaus);
|
||||
}
|
||||
|
||||
@ -1979,7 +1973,7 @@ void TCondizione_vendita::put_condv(const char *tipocv,const char *codicecv,cons
|
||||
|
||||
void TCondizione_vendita::put_listino(const char * codlist,const char *catven)
|
||||
{
|
||||
if( !config_ditta().get_bool("GESLISCV", "ve"))
|
||||
if ( !config_ditta().get_bool("GESLISCV", "ve"))
|
||||
put_condv("L",codlist,"","","");
|
||||
else
|
||||
put_condv("L",codlist,catven,"","");
|
||||
@ -1993,7 +1987,6 @@ void TCondizione_vendita::put_offerta(const char * codoff)
|
||||
put_condv("C",codoff,"","","");
|
||||
}
|
||||
|
||||
|
||||
TCondizione_vendita::TCondizione_vendita(TConfig * ditta,
|
||||
TLocalisamfile * anamag, TLocalisamfile * umart)
|
||||
: _condv(LF_CONDV), _rcondv(LF_RCONDV),
|
||||
|
@ -36,9 +36,9 @@ public:
|
||||
virtual TObject* dup() const { return new TSaldo_mag(*this); }
|
||||
|
||||
bool is_deletable() const { return _quant == ZERO && _valore == ZERO; }
|
||||
static TToken_string & key(const TRectype & head, const TRectype & row);
|
||||
void add_quant(const real & q, bool plus = true) { _quant = _quant + (plus ? q : -q); }
|
||||
void add_valore(const real & v, bool plus = true) { _valore = _valore + (plus ? v : -v); }
|
||||
static TToken_string& key(const TRectype & head, const TRectype & row);
|
||||
void add_quant(const real & q, bool plus = true) { _quant += (plus ? q : -q); }
|
||||
void add_valore(const real & v, bool plus = true) { _valore += (plus ? v : -v); }
|
||||
void add(const real & q, const real & v, bool plus = true) { add_quant(q, plus); add_valore(v, plus); }
|
||||
void sub_quant(const real & q) { add_quant(q, false); }
|
||||
void sub_valore(const real & v) { add_valore(v, false); }
|
||||
@ -76,7 +76,7 @@ TToken_string & TSaldo_mag::key(const TRectype & head, const TRectype & row)
|
||||
key.add(row.get(RMOVMAG_CODMAG));
|
||||
key.add(row.get(RMOVMAG_CODART));
|
||||
key.add(row.get(RMOVMAG_LIVGIAC));
|
||||
const TString & c = row.get(RMOVMAG_CODCAUS);
|
||||
const TString& c = row.get(RMOVMAG_CODCAUS);
|
||||
key.add(c.full() ? c : head.get(MOVMAG_CODCAUS));
|
||||
return key;
|
||||
}
|
||||
@ -97,8 +97,10 @@ TSaldo_mag::TSaldo_mag(const TSaldo_mag & s)
|
||||
set(s._codes, s._codmag, s._codart, s._livello, s._codcaus);
|
||||
_quant = s._quant;
|
||||
_valore = s._valore;
|
||||
}
|
||||
}
|
||||
|
||||
// Quintessenza della coglioneria programmatoria espressa dal Calderoli dell'informatica
|
||||
// Invece di derivare da TSaldo_mag ed aggiunger il cliente, si crea un'orrida nuova classe
|
||||
class TSaldo_mag_clifo : public TObject
|
||||
{
|
||||
int _codes;
|
||||
@ -592,12 +594,10 @@ bool TMov_mag::update_balances(bool lock)
|
||||
bool updated_bal = true;
|
||||
|
||||
const TRecord_array& b = body();
|
||||
const TString8 hcodcaus = get(MOVMAG_CODCAUS);
|
||||
|
||||
for (int i = b.last_row(); i > 0; i = b.pred_row(i)) if (causale(i).update_ultcos())
|
||||
{
|
||||
const TRectype & rec = b[i];
|
||||
TArticolo & art = articolo(i);
|
||||
const TRectype& rec = b[i];
|
||||
TArticolo& art = articolo(i);
|
||||
|
||||
art.set_nuovo(false);
|
||||
if (art.lock_and_prompt(lock ? _testandlock : _nolock))
|
||||
@ -641,6 +641,7 @@ bool TMov_mag::update_balances(bool lock)
|
||||
const TCodice_articolo& codart = saldo.codart();
|
||||
|
||||
TArticolo_giacenza& art = cached_article_balances(codart);
|
||||
const TCausale_magazzino& caus = cached_causale_magazzino(saldo.codcaus());
|
||||
|
||||
if (art.lock_and_prompt(lock ? _testandlock : _nolock))
|
||||
{
|
||||
@ -656,7 +657,7 @@ bool TMov_mag::update_balances(bool lock)
|
||||
err = mag.write();
|
||||
CHECKD(err == NOERR, "Errore di write:" , err);
|
||||
}
|
||||
update_balances(magcurr, saldo);
|
||||
update_balances(magcurr, saldo, caus);
|
||||
err = mag.rewrite();
|
||||
if (err != NOERR)
|
||||
updated_bal = false;
|
||||
@ -725,10 +726,8 @@ bool TMov_mag::update_balances(bool lock)
|
||||
|
||||
// aggiorna i saldi del record corrente
|
||||
// in base alla causale e alla modifica fatta (con segno + o -)
|
||||
void TMov_mag::update_balances(TRectype& magrec, const TSaldo_mag & s)
|
||||
void TMov_mag::update_balances(TRectype& magrec, const TSaldo_mag& s, const TCausale_magazzino& caus) const
|
||||
{
|
||||
const TCausale_magazzino& caus = cached_causale_magazzino(s.codcaus());
|
||||
|
||||
if (caus.update_qta())
|
||||
{
|
||||
const real diff = s.quant();
|
||||
@ -838,17 +837,17 @@ void TMov_mag::update_balances(TRectype& magrec, int numrig, bool plus)
|
||||
{
|
||||
const TRectype & rec = body()[numrig];
|
||||
TSaldo_mag saldo(*this, rec);
|
||||
real quant = rec.get_real(RMOVMAG_QUANT);
|
||||
const TCausale_magazzino& caus = cached_causale_magazzino(saldo.codcaus());
|
||||
TArticolo& art = articolo(numrig);
|
||||
|
||||
real quant = rec.get_real(RMOVMAG_QUANT);
|
||||
quant = art.convert_to_um(quant, NULL, rec.get(RMOVMAG_UM));
|
||||
|
||||
const real valore = (quant.is_zero() && caus.update_val()) ? rec.get_real(RMOVMAG_PREZZO) : rec.get_real(RMOVMAG_PREZZO) * quant;
|
||||
|
||||
saldo.add(quant, valore, plus);
|
||||
|
||||
return update_balances(magrec, saldo);
|
||||
return update_balances(magrec, saldo, caus);
|
||||
}
|
||||
|
||||
void TMov_mag::update_balances_clifo(TRectype& cliforec, int numrig, bool plus)
|
||||
@ -868,12 +867,12 @@ void TMov_mag::update_balances_clifo(TRectype& cliforec, int numrig, bool plus)
|
||||
return update_balances_clifo(cliforec, saldo);
|
||||
}
|
||||
|
||||
int TMov_mag::codice_esercizio(const TDate &d)
|
||||
int TMov_mag::codice_esercizio(const TDate& d) const
|
||||
{
|
||||
return esercizi().date2esc(d);
|
||||
}
|
||||
|
||||
void TMov_mag::update_balance(TRectype & rec, const char * fieldname, const real& val, const int sgn) const
|
||||
void TMov_mag::update_balance(TRectype& rec, const char * fieldname, const real& val, const int sgn) const
|
||||
{
|
||||
if (sgn != 0)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user