1997-06-19 14:33:52 +00:00
|
|
|
#ifndef __CGLIB01_H
|
|
|
|
#define __CGLIB01_H
|
|
|
|
|
1997-12-24 09:40:34 +00:00
|
|
|
#ifndef __ASSOC_H
|
|
|
|
#include <assoc.h>
|
|
|
|
#endif
|
|
|
|
|
1997-06-19 14:33:52 +00:00
|
|
|
#ifndef __ISAM_H
|
|
|
|
#include <isam.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// Gestione esercizi contabili, registri e libro giornale
|
|
|
|
|
|
|
|
class TEsercizio : public TSortable
|
|
|
|
{
|
|
|
|
int _codice;
|
|
|
|
TDate _inizio, _fine, _scarico, _chiusura, _chiusura_mag;
|
|
|
|
|
|
|
|
protected: // TSortable
|
2002-02-26 16:20:19 +00:00
|
|
|
virtual int compare(const TSortable& s) const;
|
1997-06-19 14:33:52 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
int codice() const { return _codice; }
|
|
|
|
const TDate& inizio() const { return _inizio; }
|
|
|
|
const TDate& fine() const { return _fine; }
|
|
|
|
const TDate& scarico() const { return _scarico; }
|
|
|
|
const TDate& chiusura() const { return _chiusura; }
|
|
|
|
const TDate& chiusura_mag() const { return _chiusura_mag; }
|
|
|
|
|
|
|
|
TEsercizio(const TRectype& rec);
|
|
|
|
virtual ~TEsercizio() {}
|
|
|
|
};
|
|
|
|
|
|
|
|
class TEsercizi_contabili : public TObject
|
|
|
|
{
|
|
|
|
static TArray _esercizi;
|
|
|
|
static long _firm;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
static void check();
|
|
|
|
|
|
|
|
const TEsercizio& esc(int i) const
|
|
|
|
{ return (const TEsercizio&)_esercizi[i]; }
|
|
|
|
|
|
|
|
int date2index(const TDate& d) const;
|
|
|
|
int esc2index(int codice) const;
|
|
|
|
int items() const { return _esercizi.items(); }
|
|
|
|
|
|
|
|
public:
|
|
|
|
static void update();
|
|
|
|
|
|
|
|
const TEsercizio& esercizio(int codice) const;
|
|
|
|
const TEsercizio& operator [](int codice) const { return esercizio(codice); }
|
|
|
|
|
|
|
|
int date2esc(const TDate& date) const;
|
2001-05-01 08:17:07 +00:00
|
|
|
int date2prevesc(const TDate& date) const;
|
|
|
|
int date2nextesc(const TDate& date) const;
|
1997-06-19 14:33:52 +00:00
|
|
|
int pred(int codice) const;
|
|
|
|
int next(int codice) const;
|
|
|
|
int first() const;
|
|
|
|
int last() const;
|
1999-04-06 15:34:39 +00:00
|
|
|
int last_mag() const;
|
1997-06-19 14:33:52 +00:00
|
|
|
bool exist(int codice) const;
|
|
|
|
|
|
|
|
TEsercizi_contabili();
|
|
|
|
virtual ~TEsercizi_contabili() {}
|
|
|
|
};
|
|
|
|
|
|
|
|
enum TipoIVA
|
|
|
|
{
|
|
|
|
iva_errata = -1,
|
|
|
|
nessuna_iva = 0,
|
|
|
|
iva_vendite = 1,
|
|
|
|
iva_acquisti = 2,
|
|
|
|
libro_giornale = 5,
|
|
|
|
iva_generica = 9
|
|
|
|
};
|
|
|
|
|
|
|
|
const char* iva2name(TipoIVA i);
|
|
|
|
|
1999-04-06 15:34:39 +00:00
|
|
|
class TMask_field;
|
|
|
|
bool handler_data_cambio(TMask_field& f, KEY k);
|
|
|
|
|
1997-06-19 14:33:52 +00:00
|
|
|
class TRegistro : public TObject
|
|
|
|
{
|
|
|
|
bool read_att();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
TRectype _rec, _att;
|
1997-12-24 09:40:34 +00:00
|
|
|
TAssoc_array _prorata;
|
|
|
|
|
|
|
|
real* read_prorata(int anno) const;
|
1997-06-19 14:33:52 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
bool read(const char* code, int year);
|
|
|
|
bool reread();
|
|
|
|
TRegistro& operator =(const TRegistro& r);
|
|
|
|
|
|
|
|
virtual bool ok() const { return !_rec.empty(); }
|
|
|
|
|
|
|
|
int tipo() const;
|
|
|
|
TipoIVA iva() const;
|
|
|
|
bool corrispettivi() const;
|
|
|
|
bool sospeso() const { return _rec.get_bool("B1");}
|
|
|
|
const TString& name() const;
|
|
|
|
int year() const;
|
|
|
|
TDate last_reg() const { return _rec.get_date("D2"); }
|
|
|
|
TDate last_print() const { return _rec.get_date("D3"); }
|
|
|
|
long mese_stampa_ultima_liq() const { return _rec.get_long("I4"); }
|
|
|
|
long protocol() const { return _rec.get_long("I5"); }
|
|
|
|
const TString& attivita() const { return _rec.get("S8"); }
|
|
|
|
|
|
|
|
bool agenzia_viaggi();
|
|
|
|
const TString& tipo_attivita();
|
|
|
|
bool attivita_mista() { const char a = tipo_attivita()[0]; return a == 'E'; }
|
1997-12-24 09:40:34 +00:00
|
|
|
|
|
|
|
void set_prorata(int annodoc, const real& pro);
|
|
|
|
real prorata(int annodoc);
|
|
|
|
bool prorata100(int annodoc) { return prorata(annodoc) >= 100.0; }
|
|
|
|
|
1997-06-19 14:33:52 +00:00
|
|
|
bool update(long uprotiva, const TDate& lastreg);
|
|
|
|
|
|
|
|
TRegistro(const char* code = "", int year = 0);
|
|
|
|
virtual ~TRegistro() {}
|
|
|
|
};
|
|
|
|
|
|
|
|
class TLibro_giornale : public TRegistro
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
bool read(int year);
|
|
|
|
TDate global_last_print() const;
|
|
|
|
|
|
|
|
TLibro_giornale(int year = 0);
|
|
|
|
virtual ~TLibro_giornale() {}
|
|
|
|
};
|
|
|
|
|
1999-07-16 14:59:11 +00:00
|
|
|
class TCodiceIVA : public TRectype
|
1997-06-19 14:33:52 +00:00
|
|
|
{
|
2000-10-03 13:45:12 +00:00
|
|
|
void copy(const TRectype & iva) { TRectype::operator =(iva); }
|
1997-06-19 14:33:52 +00:00
|
|
|
public: // TObject
|
|
|
|
virtual bool ok() const { return !empty(); }
|
1999-07-16 14:59:11 +00:00
|
|
|
TCodiceIVA & operator =(const TCodiceIVA & iva) { copy(iva) ; return *this;}
|
|
|
|
TObject* dup() const { return new TCodiceIVA(*this); }
|
1997-06-19 14:33:52 +00:00
|
|
|
bool read(const char* codice);
|
|
|
|
const TString& codice() const { return get("CODTAB"); }
|
1999-07-16 14:59:11 +00:00
|
|
|
const TString& descrizione() const { return get("S0"); }
|
2000-10-03 13:45:12 +00:00
|
|
|
const real percentuale() const { return get_real("R0"); }
|
1997-06-19 14:33:52 +00:00
|
|
|
const TString& tipo() const { return get("S1"); }
|
1999-07-16 14:59:11 +00:00
|
|
|
int detraibilita() const { return get_int("I1"); }
|
1997-06-19 14:33:52 +00:00
|
|
|
|
1999-07-16 14:59:11 +00:00
|
|
|
real imposta(const real& imponibile, int ndec = AUTO_DECIMALS, const char * codval = "") const; // Calcola l'imposta sull'imponibile l'imposta e la ritorna
|
|
|
|
real scorpora(real& imponibile, int ndec = AUTO_DECIMALS, const char * codval = "") const; // Scorpora dall'imponibile l'imposta e la ritorna
|
|
|
|
real lordo(const real& imponibile, int ndec = AUTO_DECIMALS, const char * codval = "") const; // Calcola il lordo dell'imponibile l'imposta e la ritorna
|
1997-06-19 14:33:52 +00:00
|
|
|
|
|
|
|
TCodiceIVA(const char* codice = NULL);
|
1999-07-16 14:59:11 +00:00
|
|
|
TCodiceIVA(const TRectype & rec) : TRectype(rec) {}
|
|
|
|
TCodiceIVA(const TCodiceIVA & iva) : TRectype(iva) {}
|
1997-06-19 14:33:52 +00:00
|
|
|
virtual ~TCodiceIVA() {}
|
|
|
|
};
|
|
|
|
|
|
|
|
#ifndef __MASK_H
|
|
|
|
class TMask;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
class TBill : public TSortable
|
|
|
|
{
|
|
|
|
char _tipo; // ' ' = Conto, 'C' = Cliente, 'F' = 'Fornitore'
|
|
|
|
int _gruppo, _conto;
|
|
|
|
long _sottoconto; // Sottoconto, codice cliente o fornitore
|
|
|
|
TString* _descrizione; // Vuota fino alla chiamata di describe
|
|
|
|
int _tipo_cr; // Tipo costo/ricavo
|
|
|
|
bool _sospeso;
|
|
|
|
char _sezione;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void set_description(const char* d);
|
|
|
|
const TBill& copy(const TBill& b);
|
|
|
|
const char* field_name(int n, bool contro) const;
|
|
|
|
|
|
|
|
public: // TObject
|
2004-01-22 15:23:23 +00:00
|
|
|
virtual int compare(const TSortable& s) const;
|
|
|
|
virtual const char* class_name() const { return "Conto"; }
|
1997-06-19 14:33:52 +00:00
|
|
|
virtual bool ok() const; // Gruppo, Conto e Sottoconto non nulli
|
|
|
|
|
|
|
|
public:
|
|
|
|
TBill(int g = 0, int c = 0, long s = 0L, char t = ' ', const char* d = NULL, int r = -1)
|
|
|
|
: _tipo(t), _gruppo(g), _conto(c), _sottoconto(s), _descrizione(NULL),
|
|
|
|
_sezione(' '), _sospeso(FALSE)
|
|
|
|
{ set(g,c,s,t,d,r);}
|
|
|
|
|
|
|
|
TBill(TToken_string& tgcsd, int from, int mode = 0)
|
2000-10-03 13:45:12 +00:00
|
|
|
: _descrizione(NULL), _sezione(' '), _sospeso(FALSE)
|
1997-06-19 14:33:52 +00:00
|
|
|
{ get(tgcsd, from, mode); }
|
|
|
|
|
|
|
|
TBill(const TRectype& rec, bool contro = FALSE)
|
2000-10-03 13:45:12 +00:00
|
|
|
: _descrizione(NULL), _sezione(' '), _sospeso(FALSE)
|
1997-06-19 14:33:52 +00:00
|
|
|
{ get(rec, contro); }
|
|
|
|
|
|
|
|
TBill(const TBill& b)
|
|
|
|
: _descrizione(NULL)
|
|
|
|
{ copy(b); }
|
|
|
|
|
|
|
|
virtual ~TBill();
|
|
|
|
|
|
|
|
const TBill& set(int g = 0, int c = 0, long s = 0L, char t = ' ',
|
|
|
|
const char* d = NULL, int r = -1);
|
|
|
|
|
|
|
|
const TBill& get(TToken_string& ts, int from, int mode = 0);
|
|
|
|
const TBill& add_to(TToken_string& ts, int from, int mode = 0);
|
|
|
|
const TBill& operator=(const TBill& b) { return copy(b); }
|
|
|
|
|
|
|
|
bool empty() const { return _gruppo==0 && _conto==0 && _sottoconto == 0; }
|
|
|
|
|
|
|
|
char tipo() const { return _tipo; }
|
|
|
|
int gruppo() const { return _gruppo; }
|
|
|
|
int conto() const { return _conto; }
|
|
|
|
long sottoconto() const { return _sottoconto; }
|
|
|
|
long codclifo() const { return _sottoconto; }
|
|
|
|
long& codclifo() { return _sottoconto; }
|
|
|
|
|
|
|
|
bool find();
|
|
|
|
const TString& descrizione() const;
|
|
|
|
int tipo_cr() const;
|
|
|
|
void tipo_cr(int tcr) { _tipo_cr = tcr; }
|
|
|
|
|
|
|
|
int tipo_att();
|
|
|
|
bool read(TRectype& r);
|
2000-10-03 13:45:12 +00:00
|
|
|
bool sospeso() const;
|
|
|
|
char sezione() const;
|
1997-06-19 14:33:52 +00:00
|
|
|
|
|
|
|
void put(TRectype& r, bool contro = FALSE) const;
|
|
|
|
bool get(const TRectype& r, bool contro = FALSE);
|
|
|
|
|
|
|
|
void set(TMask& m, short g, short c, short s, short t = 0, short d = 0) const;
|
|
|
|
void get(const TMask& m, short g, short c, short s, short t = 0, short d = 0);
|
|
|
|
|
|
|
|
const char* string(int mode = 0) const;
|
2002-09-13 14:06:05 +00:00
|
|
|
|
|
|
|
bool default_cdc(TString& cdc, TString& fas) const;
|
1997-06-19 14:33:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
enum TIndbil { ib_null, ib_attivita, ib_passivita, ib_costi, ib_ricavi, ib_conti_ordine };
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|