278 lines
8.5 KiB
C++
Executable File
278 lines
8.5 KiB
C++
Executable File
#ifndef __VELIB01_H
|
|
#define __VELIB01_H
|
|
|
|
#ifndef __RELATION_H
|
|
#include <relation.h>
|
|
#endif
|
|
|
|
real lordo2netto(real& lordo, const TString& codiva, bool is_valuta = FALSE);
|
|
real netto2lordo(const real& netto, const TString& codiva, bool is_valuta = FALSE);
|
|
real lordo2netto(real& lordo, const real& iva, bool is_valuta = FALSE);
|
|
real netto2lordo(const real& netto, const real& iva, bool is_valuta = FALSE);
|
|
|
|
class TTipo_documento : public TRectype
|
|
{
|
|
protected:
|
|
int read(const char* tipodoc);
|
|
|
|
public:
|
|
TObject* dup() const { return new TTipo_documento(codice()); }
|
|
|
|
public:
|
|
const TString& profile_name() const { return get("S4");}
|
|
const TString& mask_name() const { return get("S4");}
|
|
const TString& causale() const { return get("S6"); }
|
|
const TString& codice() const { return get("CODTAB");}
|
|
|
|
const TString& descrizione() const { return get("S0"); }
|
|
const TString& riferimento() const { return get("S1"); }
|
|
|
|
TTipo_documento(const char* tipodoc = NULL);
|
|
TTipo_documento(const TRectype& rec);
|
|
virtual ~TTipo_documento();
|
|
};
|
|
|
|
class TTipo_riga_documento : public TRectype
|
|
{
|
|
protected:
|
|
int read(const char* tiporig);
|
|
|
|
public:
|
|
TObject* dup() const { return new TTipo_riga_documento(codice()); }
|
|
|
|
public:
|
|
const TString& codice() const { return get("CODTAB");}
|
|
|
|
const TString& descrizione() const { return get("S0"); }
|
|
char tipo() const { return get_char("S7"); }
|
|
|
|
TTipo_riga_documento(const char* tiporig = NULL);
|
|
TTipo_riga_documento(const TRectype& rec);
|
|
virtual ~TTipo_riga_documento();
|
|
};
|
|
|
|
|
|
class TRiga_documento : public TRectype
|
|
{
|
|
friend class TDocumento;
|
|
const TDocumento* _doc;
|
|
|
|
static TAssoc_array _tipi;
|
|
|
|
protected:
|
|
void set_doc(const TDocumento* doc) { _doc = doc; }
|
|
|
|
protected:
|
|
TObject* dup() const { return new TRiga_documento(*this); }
|
|
|
|
public:
|
|
const TDocumento& documento() const
|
|
{ CHECK(_doc, "Riga documento orfana"); return *_doc; }
|
|
|
|
const TTipo_riga_documento& tipo() const;
|
|
bool sola_descrizione() const;
|
|
void forza_sola_descrizione();
|
|
|
|
TRiga_documento& operator =(const TRiga_documento& r)
|
|
{ TRectype::operator=(r); _doc = r._doc; return *this; }
|
|
|
|
bool raggruppabile(const TRiga_documento& r, TToken_string& campi) const;
|
|
TRiga_documento& operator +=(const TRiga_documento& r);
|
|
|
|
TRiga_documento(const TDocumento* doc) : TRectype(LF_RIGHEDOC), _doc(doc) { }
|
|
TRiga_documento(const TRiga_documento& rec) : TRectype(rec), _doc(rec._doc) { }
|
|
virtual ~TRiga_documento() { }
|
|
};
|
|
|
|
class TDocumento : public TRectype
|
|
{
|
|
static TAssoc_array _tipi;
|
|
|
|
TRecord_array _rows; // Array di TRectype per le righe documenti di vendita.
|
|
bool _nuovo;
|
|
|
|
protected:
|
|
TRectype & row(int index) { return _rows.row(index, FALSE); }
|
|
long get_next_key(char provv, int anno, const char* codnum) const;
|
|
long renum(long numdoc = 0);
|
|
|
|
public:
|
|
const TRectype& head() const { return *this; } // Ritorna la testata del documento
|
|
TRectype& head() { return *this; } // Ritorna la testata del documento
|
|
|
|
int rows() const { return _rows.rows(); }
|
|
const TRiga_documento& operator[](int index) const { return (const TRiga_documento&)_rows.row(index); }
|
|
TRiga_documento& operator[](int index) { return (TRiga_documento&)_rows.row(index, FALSE); }
|
|
|
|
TRiga_documento& new_row() { return (TRiga_documento&)_rows.row(-1, TRUE); }
|
|
bool destroy_row(int n) { return _rows.destroy_row(n); }
|
|
void destroy_rows() { _rows.destroy_rows(); }
|
|
|
|
int read(char provv, int anno, const char* codnum, long numdoc);
|
|
int read(const TRectype& rec);
|
|
|
|
int write(bool re = FALSE) const;
|
|
int rewrite() const { return write(TRUE); }
|
|
int remove() const;
|
|
|
|
char tipo_numerazione() const { return get_char("PROVV"); }
|
|
int anno() const { return get_int("ANNO"); }
|
|
const TString& numerazione() { return get("CODNUM"); }
|
|
long numero() const { return get_long("NDOC"); }
|
|
TDate data() const { return get_date("DATADOC"); }
|
|
const bool in_valuta();
|
|
const TString& valuta() { return get("CODVAL"); }
|
|
const real cambio() { return get_real("CAMBIO"); }
|
|
const TTipo_documento& tipo() const;
|
|
|
|
char stato() const { return get_char("STATO"); }
|
|
void stato(char s) { put("STATO", s); }
|
|
|
|
bool raggruppabile() const { return get_bool("RAGGR"); }
|
|
bool raggruppabile(const TDocumento& doc, TToken_string& campi) const;
|
|
|
|
static void set_key(TRectype& rec, char provv, int anno, const char* codnum, long numdoc);
|
|
static void copy_data(TRectype& dst, const TRectype& src);
|
|
|
|
TDocumento ();
|
|
TDocumento(char provv, int anno, const char* codnum, long numdoc);
|
|
TDocumento(const TRectype& doc);
|
|
virtual ~TDocumento() { }
|
|
};
|
|
|
|
class TLista_documenti : public TObject
|
|
{
|
|
TArray _documenti;
|
|
|
|
protected:
|
|
const TDocumento& doc(int n) const { return (const TDocumento&)_documenti[n]; }
|
|
TDate num2date(char provv, int anno, const char* codnum, long num) const;
|
|
|
|
public:
|
|
int read(char provv, char tipo, long clifo, int anno,
|
|
TToken_string& tipidoc, TToken_string& statidoc,
|
|
const TDate& dd, const TDate& ad,
|
|
const char* codnum = "", long dn = 0L, long an = 0L);
|
|
int write(bool re = FALSE) const;
|
|
int rewrite() const { return write(TRUE); }
|
|
|
|
int add(TDocumento* doc) { return _documenti.add(doc); }
|
|
|
|
const TDocumento& operator[] (int n) const { return doc(n); }
|
|
TDocumento& operator[] (int n) { return (TDocumento&)_documenti[n]; }
|
|
int items() const { return _documenti.items(); }
|
|
|
|
TLista_documenti() { }
|
|
virtual ~TLista_documenti() { }
|
|
};
|
|
|
|
class TLista_clifo : public TObject
|
|
{
|
|
class TClifo : public TObject
|
|
{
|
|
long _codice;
|
|
long _agente;
|
|
long _zona;
|
|
|
|
protected:
|
|
void zero() { _codice = _agente = _zona = 0L; }
|
|
void init(const TRectype& rec, const TRectype& ven);
|
|
bool read(char tipo, long cod);
|
|
|
|
public: // TObject
|
|
virtual bool ok() const { return _codice > 0; }
|
|
|
|
public:
|
|
long codice() const { return _codice; }
|
|
long agente() const { return _agente; }
|
|
long zona() const { return _zona; }
|
|
|
|
TClifo() { zero(); }
|
|
TClifo(char tipo, long cod) { read(tipo, cod); }
|
|
TClifo(const TRectype& rec, const TRectype& ven) { init(rec, ven); }
|
|
TClifo(const TRectype& rec);
|
|
virtual ~TClifo() { }
|
|
};
|
|
|
|
TArray _clifo;
|
|
|
|
protected:
|
|
virtual char tipo() const pure;
|
|
const TClifo& clifo(int n) const { return (TClifo&)_clifo[n]; }
|
|
|
|
static int sort_by_code(const TObject** o1, const TObject** o2);
|
|
static int sort_by_agent(const TObject** o1, const TObject** o2);
|
|
static int sort_by_zone(const TObject** o1, const TObject** o2);
|
|
|
|
public:
|
|
int ordina_per_codice();
|
|
int ordina_per_agente();
|
|
int ordina_per_zona();
|
|
|
|
int leggi(long dc, long ac, long da = 0, long aa = 0, long dz = 0, long az = 0);
|
|
|
|
long operator[] (int n) const { return clifo(n).codice(); }
|
|
int items() const { return _clifo.items(); }
|
|
int find(long cod) const;
|
|
int add(long cod);
|
|
|
|
TLista_clifo() { }
|
|
virtual ~TLista_clifo() { }
|
|
};
|
|
|
|
class TLista_clienti : public TLista_clifo
|
|
{
|
|
protected:
|
|
virtual char tipo() const { return 'C'; }
|
|
};
|
|
|
|
class TLista_fornitori : public TLista_clifo
|
|
{
|
|
protected:
|
|
virtual char tipo() const { return 'F'; }
|
|
};
|
|
|
|
class TElaborazione : public TRectype
|
|
{
|
|
protected:
|
|
int read(const char* cod);
|
|
|
|
public:
|
|
const TString& codice() const { return get("CODTAB"); }
|
|
|
|
bool doc_uguale(int u) const { return get("S1")[u] == 'X'; }
|
|
bool riga_uguale(int u) const { return get("S1")[40+u] == 'X'; }
|
|
bool raggruppa_righe() const { return get_bool("B0"); }
|
|
bool gestione_riferimenti() const { return get_bool("B1"); }
|
|
bool riferimenti_in_testa() const { return get_bool("B2"); }
|
|
bool ignora_descrizioni() const { return get_bool("B3"); }
|
|
|
|
char tipo_numerazione() const { return get_bool("B4") ? 'P' : 'D'; }
|
|
const TString& codice_numerazione_finale() const { return get("S6"); }
|
|
|
|
virtual bool elabora(TLista_documenti& doc_in, TLista_documenti& doc_out,
|
|
const TDate& data_elab) pure;
|
|
|
|
TElaborazione(const char* cod);
|
|
TElaborazione(const TRectype& rec) : TRectype(rec) { }
|
|
virtual ~TElaborazione() { }
|
|
};
|
|
|
|
class TFatturazione_bolle : public TElaborazione
|
|
{
|
|
TToken_string _cod_desc;
|
|
|
|
public:
|
|
virtual bool raggruppa(TDocumento& din, TDocumento& dout);
|
|
virtual bool elabora(TLista_documenti& doc_in, TLista_documenti& doc_out,
|
|
const TDate& data_elab);
|
|
|
|
void tipi_validi(TToken_string& tipi) const;
|
|
void stati_validi(TToken_string& stati) const;
|
|
|
|
TFatturazione_bolle(const char* cod);
|
|
virtual ~TFatturazione_bolle() { }
|
|
};
|
|
|
|
#endif
|