Suppporto statistiche di vendita

git-svn-id: svn://10.65.10.50/trunk@5290 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
alex 1997-09-26 15:22:39 +00:00
parent eb223fa499
commit 3a358709f1
2 changed files with 75 additions and 6 deletions

View File

@ -450,7 +450,7 @@ public:
TRiepilogo_iva() : _tipo(0) {}
~TRiepilogo_iva() {};
};
class TDocumento : public TMultiple_rectype // velib03
{
TRecfield *_tipocf;
@ -462,7 +462,9 @@ class TDocumento : public TMultiple_rectype // velib03
static TString16 _codiva_spese;
static TString16 _codiva_bolli;
char _stato_originale;
static bool _has_mag;
static bool _has_stat_ven;
static bool _has_provv;
int _liv_len[4];
// TRecord_array _rows; // Array di TRectype per le righe documenti di vendita.
@ -495,6 +497,7 @@ protected:
static void test_firm();
const TString16 & codiva_spese() const { ((TDocumento *)this)->test_firm(); return _codiva_spese;}
const TString16 & codiva_bolli() const { ((TDocumento *)this)->test_firm(); return _codiva_bolli;}
void check_modules();
public:
void dirty_fields();

View File

@ -38,6 +38,10 @@
#include <modaut.h>
#endif
#ifndef __SVLIB01_H
#include "../sv/svlib01.h"
#endif
#include "../mg/movmag.h"
///////////////////////////////////////////////////////////
// Movimento di magazzino
@ -230,6 +234,11 @@ TAssoc_array TDocumento::_tipi;
TAssoc_array TDocumento::_numerazioni;
TString16 TDocumento::_codiva_spese;
TString16 TDocumento::_codiva_bolli;
HIDDEN TStats_agg _st_agg;
HIDDEN TAssoc_array _docs_to_agg;
bool TDocumento::_has_mag = 3;
bool TDocumento::_has_stat_ven = 3;
bool TDocumento::_has_provv = 3;
TDocumento::TDocumento()
: TMultiple_rectype(LF_DOC), _condv(NULL),
@ -241,8 +250,9 @@ TDocumento::TDocumento()
_cod_occas = new TRecfield(*this, "OCFPI");
set_memo_fld("G1");
for (int i = 3 ; i >= 0; i--)
_liv_len[i] = 0;
}
_liv_len[i] = 0;
check_modules();
}
TDocumento::TDocumento(const TDocumento & d)
: TMultiple_rectype(LF_DOC), _condv(NULL),
@ -250,6 +260,7 @@ TDocumento::TDocumento(const TDocumento & d)
{
add_file(LF_RIGHEDOC, "NRIGA");
copy(d);
check_modules();
}
TDocumento::TDocumento(char provv, int anno, const char* codnum, long numdoc,
@ -262,6 +273,7 @@ TDocumento::TDocumento(char provv, int anno, const char* codnum, long numdoc,
_codcf = new TRecfield(*this, "CODCF");
_cod_occas = new TRecfield(*this, "OCFPI");
set_memo_fld("G1");
check_modules();
if (numdoc <= 0)
{
numdoc = 0;
@ -285,6 +297,7 @@ TDocumento::TDocumento(const TRectype& rec, TCond_vendita * condv)
read(rec);
for (int i = 3 ; i >= 0; i--)
_liv_len[i] = 0;
check_modules();
}
TDocumento::~TDocumento()
@ -297,6 +310,16 @@ TDocumento::~TDocumento()
if (_esenzione != NULL) delete _esenzione;
}
void TDocumento::check_modules()
{
if (_has_mag == 3)
{
_has_mag = main_app().has_module(MGAUT, CHK_DONGLE);
_has_stat_ven = main_app().has_module(SVAUT, CHK_DONGLE);
_has_provv = main_app().has_module(PRAUT, CHK_DONGLE);
}
}
void TDocumento::test_firm()
{
const long new_firm = prefix().get_codditta();
@ -583,6 +606,27 @@ int TDocumento::read(TBaseisamfile& f, word op, word lockop)
if (is_fattura())
set_riga_esenzione();
_stato_originale = stato();
if (tipo().statistiche() && _has_stat_ven)
{
TString80 key(get(DOC_PROVV)); key << get(DOC_ANNO); key << get(DOC_CODNUM); key << get(DOC_NDOC);
TObject * o = _docs_to_agg.objptr(key);
if ( lockop >= _lock && o == NULL)
{
_docs_to_agg.add(key, key);
for (int i = physical_rows(); i > 0; i--)
_st_agg.sub(row(i));
}
else
if (lockop == _unlock && o != NULL)
{
_docs_to_agg.remove(key);
for (int i = physical_rows(); i > 0; i--)
_st_agg.add(row(i));
}
if (_docs_to_agg.items() == 0)
_st_agg.update();
}
return err;
}
@ -890,7 +934,19 @@ int TDocumento::write_rewrite(TBaseisamfile & f, bool re) const
if (err == _isreinsert)
err = occ.rewrite(o);
}
}
}
if (tipo().statistiche() && _has_stat_ven)
{
TString80 key(get(DOC_PROVV)); key << get(DOC_ANNO); key << get(DOC_CODNUM); key << get(DOC_NDOC);
TObject * o = _docs_to_agg.objptr(key);
if (o != NULL)
_docs_to_agg.remove(key);
for (int i = physical_rows(); i > 0; i--)
_st_agg.add(myself.row(i));
if (_docs_to_agg.items() == 0)
_st_agg.update();
}
return err;
}
// eliminare anche il mov di mag. ??????
@ -914,7 +970,17 @@ int TDocumento::remove(TBaseisamfile& f) const
mov.remove(m);
}
}
return TMultiple_rectype::remove(f);
if (tipo().statistiche() && _has_stat_ven)
{
TString80 key(get(DOC_PROVV)); key << get(DOC_ANNO); key << get(DOC_CODNUM); key << get(DOC_NDOC);
TObject * o = _docs_to_agg.objptr(key);
if (o != NULL)
_docs_to_agg.remove(key);
if (_docs_to_agg.items() == 0)
_st_agg.update();
}
return TMultiple_rectype::remove(f);
}
bool TDocumento::in_valuta() const