1997-08-05 09:24:21 +00:00
|
|
|
|
#ifndef __SVLIB01_H
|
|
|
|
|
#define __SVLIB01_H
|
|
|
|
|
|
1998-05-04 10:12:16 +00:00
|
|
|
|
#ifndef __VARREC_H
|
|
|
|
|
#include <varrec.h>
|
1997-08-05 09:24:21 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
1998-05-04 10:12:16 +00:00
|
|
|
|
#ifndef __VELIB_H
|
2004-03-16 07:43:45 +00:00
|
|
|
|
#include "../ve/velib.h"
|
1997-09-19 10:17:17 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
2004-03-16 07:43:45 +00:00
|
|
|
|
#include "../sv/svlib09.h"
|
2000-05-05 15:25:49 +00:00
|
|
|
|
|
1997-08-26 13:40:34 +00:00
|
|
|
|
enum TFrequenza_statistiche { fs_nulla, fs_giornaliera,
|
|
|
|
|
fs_settimanale, fs_quindicinale,
|
|
|
|
|
fs_mensile, fs_bimestrale,
|
|
|
|
|
fs_trimestrale, fs_quadrimestrale,
|
|
|
|
|
fs_semestrale, fs_annuale };
|
1997-08-05 09:24:21 +00:00
|
|
|
|
|
1997-10-06 10:22:47 +00:00
|
|
|
|
//@cmember Converte una carattere in una frequenza delle statisitiche
|
1997-08-26 13:40:34 +00:00
|
|
|
|
TFrequenza_statistiche char2frequency(char c);
|
1999-04-06 15:34:39 +00:00
|
|
|
|
//@cmember Converte una frequenza delle statistiche in un carattere
|
1997-08-26 13:40:34 +00:00
|
|
|
|
char frequency2char(TFrequenza_statistiche f);
|
1997-10-06 10:22:47 +00:00
|
|
|
|
//@cmember Converte una carattere nel nome completo della frequenza
|
|
|
|
|
TString & char2freqname(char c);
|
1997-08-26 13:40:34 +00:00
|
|
|
|
|
1997-09-19 10:17:17 +00:00
|
|
|
|
//Arrotondamento di una data alla frequenza specificata
|
1997-08-26 13:40:34 +00:00
|
|
|
|
const TDate& floor(TDate& data, TFrequenza_statistiche freq);
|
|
|
|
|
const TDate& ceil(TDate& data, TFrequenza_statistiche freq);
|
|
|
|
|
|
1997-09-19 10:17:17 +00:00
|
|
|
|
//Ritorna il rapporto tra le frequenze: 0 se impossibile stabilirlo
|
1997-08-26 13:40:34 +00:00
|
|
|
|
int divide(TFrequenza_statistiche f1, TFrequenza_statistiche f2);
|
|
|
|
|
|
1997-09-19 10:17:17 +00:00
|
|
|
|
//Ritorna l'ultimo periodo di un anno (primo = 1)
|
1997-08-26 13:40:34 +00:00
|
|
|
|
int last_period(int anno, TFrequenza_statistiche freq);
|
1997-10-06 10:22:47 +00:00
|
|
|
|
int last_period(const TDate & d, TFrequenza_statistiche f);
|
1997-08-26 13:40:34 +00:00
|
|
|
|
|
1997-09-19 10:17:17 +00:00
|
|
|
|
//Ritorna la parte "periodo" di una data (l'anno si ottiene da year())
|
1997-08-26 13:40:34 +00:00
|
|
|
|
int date2period(const TDate& data, TFrequenza_statistiche freq);
|
1997-09-19 10:17:17 +00:00
|
|
|
|
|
1999-04-06 15:34:39 +00:00
|
|
|
|
//Converte una coppia anno+periodo in un TDate in base alla frequenza passata
|
|
|
|
|
const TDate & period2date(const int anno, int periodo, TFrequenza_statistiche f);
|
|
|
|
|
|
1997-09-19 10:17:17 +00:00
|
|
|
|
//Converte una data in un long in base alla frequenza passata
|
|
|
|
|
long date2long(const TDate d, TFrequenza_statistiche f);
|
|
|
|
|
|
|
|
|
|
//Converte una coppia anno+periodo in un long in base alla frequenza passata
|
|
|
|
|
long period2long(const int anno, const int periodo, TFrequenza_statistiche f);
|
|
|
|
|
|
1997-08-05 09:24:21 +00:00
|
|
|
|
class TStats_agg : public TObject
|
|
|
|
|
{
|
|
|
|
|
class TStats_data : public TObject
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
real _quantita, _valore;
|
|
|
|
|
};
|
1997-08-18 14:20:21 +00:00
|
|
|
|
|
|
|
|
|
long _ditta;
|
1997-08-05 09:24:21 +00:00
|
|
|
|
TAssoc_array _data;
|
|
|
|
|
|
|
|
|
|
TFrequenza_statistiche _frequenza;
|
2003-06-30 15:56:12 +00:00
|
|
|
|
bool _merce, _prestazioni, _spesedoc, _omaggi, _omaggio_is_merce, _omaggi_valore;
|
1997-08-18 14:20:21 +00:00
|
|
|
|
bool _art_nocode, _art_noanag, _art_noanag_grp;
|
1997-09-19 10:17:17 +00:00
|
|
|
|
bool _agente, _cliente, _zona, _articolo, _giacenza, _magazzino,_catvend;
|
2000-05-05 15:25:49 +00:00
|
|
|
|
TString16 _valfield;
|
1997-08-05 09:24:21 +00:00
|
|
|
|
|
|
|
|
|
protected:
|
1997-08-18 14:20:21 +00:00
|
|
|
|
void test_firm() const;
|
|
|
|
|
void put_key(TRectype& stat, TToken_string& key) const;
|
1997-08-05 09:24:21 +00:00
|
|
|
|
TStats_agg::TStats_data& find(const TRiga_documento& rdoc);
|
|
|
|
|
bool can_add(const TRiga_documento& rdoc) const;
|
2003-06-30 15:56:12 +00:00
|
|
|
|
bool algebric_sum(const TRiga_documento& rdoc, int sign); // Implements Add and Sub
|
1997-08-18 14:20:21 +00:00
|
|
|
|
|
1997-08-05 09:24:21 +00:00
|
|
|
|
public:
|
1997-08-18 14:20:21 +00:00
|
|
|
|
void init();
|
|
|
|
|
void reset();
|
1997-08-05 09:24:21 +00:00
|
|
|
|
bool sub(const TRiga_documento& rdoc);
|
|
|
|
|
bool add(const TRiga_documento& rdoc);
|
|
|
|
|
bool update();
|
1997-10-31 16:51:04 +00:00
|
|
|
|
// restituisce TRUE se l'archivio di riepilogo <20> vuoto
|
|
|
|
|
bool empty();
|
1997-08-26 13:40:34 +00:00
|
|
|
|
TFrequenza_statistiche frequency() const
|
|
|
|
|
{ return _frequenza; }
|
|
|
|
|
|
|
|
|
|
int date2period(const TDate& datadoc) const
|
|
|
|
|
{ return ::date2period(datadoc, _frequenza); }
|
|
|
|
|
|
|
|
|
|
bool grp_agente() const { test_firm(); return _agente; }
|
|
|
|
|
bool grp_cliente() const { test_firm(); return _cliente; }
|
|
|
|
|
bool grp_zona() const { test_firm(); return _zona; }
|
|
|
|
|
bool grp_articolo() const { test_firm(); return _articolo; }
|
|
|
|
|
bool grp_giacenza() const { test_firm(); return _giacenza; }
|
|
|
|
|
bool grp_magazzino() const { test_firm(); return _magazzino; }
|
1997-09-19 10:17:17 +00:00
|
|
|
|
bool grp_catven() const { test_firm(); return _catvend; }
|
1997-08-26 13:40:34 +00:00
|
|
|
|
|
|
|
|
|
bool omaggio_is_merce() const { test_firm(); return _omaggio_is_merce; }
|
2000-05-05 15:25:49 +00:00
|
|
|
|
|
1997-08-05 09:24:21 +00:00
|
|
|
|
TStats_agg();
|
|
|
|
|
virtual ~TStats_agg() { }
|
|
|
|
|
};
|
|
|
|
|
|
1997-09-19 10:17:17 +00:00
|
|
|
|
class TSVriep_record : public TVariable_rectype
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
virtual const TString & get_str(const char* fieldname) const;
|
|
|
|
|
virtual void put_str(const char* fieldname, const char* val);
|
|
|
|
|
TSVriep_record();
|
|
|
|
|
virtual ~TSVriep_record();
|
|
|
|
|
};
|
|
|
|
|
|
1997-09-25 16:51:52 +00:00
|
|
|
|
const TString& get_partname(const char *lev_code) ;
|
1997-09-19 10:17:17 +00:00
|
|
|
|
|
|
|
|
|
class TStat_cache : public TRWrecord_cache
|
|
|
|
|
{
|
|
|
|
|
protected:
|
|
|
|
|
virtual const TString & getkey2discard();
|
|
|
|
|
public:
|
1997-10-14 07:48:10 +00:00
|
|
|
|
TStat_cache (TLocalisamfile &f, bool lock=FALSE);
|
|
|
|
|
TStat_cache (TLocalisamfile *f, bool lock=FALSE);
|
1997-09-19 10:17:17 +00:00
|
|
|
|
virtual ~TStat_cache()
|
|
|
|
|
{}
|
1997-10-14 07:48:10 +00:00
|
|
|
|
void zap();
|
1997-09-19 10:17:17 +00:00
|
|
|
|
};
|
1997-08-05 09:24:21 +00:00
|
|
|
|
#endif
|
1997-09-19 10:17:17 +00:00
|
|
|
|
|