1298 lines
45 KiB
C
1298 lines
45 KiB
C
|
#ifndef __CGLIB_H
|
|||
|
#define __CGLIB_H
|
|||
|
|
|||
|
#ifndef __ISAM_H
|
|||
|
#include <isam.h>
|
|||
|
#endif
|
|||
|
|
|||
|
#ifndef REAL_H
|
|||
|
#include <real.h>
|
|||
|
#endif
|
|||
|
|
|||
|
#ifndef __RECARRAY_H
|
|||
|
#include <recarray.h>
|
|||
|
#endif
|
|||
|
|
|||
|
#ifndef __MULTIREC
|
|||
|
#include <multirec.h>
|
|||
|
#endif
|
|||
|
|
|||
|
#ifndef __TABUTIL_H
|
|||
|
#include <tabutil.h>
|
|||
|
#endif
|
|||
|
|
|||
|
#ifndef __VARIANT_H
|
|||
|
#include <variant.h>
|
|||
|
#endif
|
|||
|
|
|||
|
#ifndef __VARREC_H
|
|||
|
#include <varrec.h>
|
|||
|
#endif
|
|||
|
|
|||
|
#include "../ba/ba8500.h"
|
|||
|
|
|||
|
#include <mov.h>
|
|||
|
#include <rmov.h>
|
|||
|
#include <rmoviva.h>
|
|||
|
#include <pconti.h>
|
|||
|
#include <comuni.h>
|
|||
|
#include <clifo.h>
|
|||
|
#include <rcausali.h>
|
|||
|
#include <causali.h>
|
|||
|
#include <occas.h>
|
|||
|
#include <partite.h>
|
|||
|
#include <scadenze.h>
|
|||
|
#include <pagsca.h>
|
|||
|
|
|||
|
#define COD "COD"
|
|||
|
#define DESC "DESC"
|
|||
|
#define IMPACQ "IMPACQ"
|
|||
|
#define IVAACQ "IVAACQ"
|
|||
|
#define IMPCORR "IMPCORR"
|
|||
|
#define IVACORR "IVACORR"
|
|||
|
#define IMPVEN "IMPVEN"
|
|||
|
#define IVAVEN "IVAVEN"
|
|||
|
#define IMPACQIND "IMPACQIND"
|
|||
|
#define IVAACQIND "IVAACQIND"
|
|||
|
|
|||
|
// Fatture
|
|||
|
#define RIGA_IVA_DETRAIBILE 3
|
|||
|
#define RIGA_IVA_NON_DETRAIBILE 4
|
|||
|
#define RIGA_RITENUTE_FISCALI 8
|
|||
|
#define RIGA_RITENUTE_SOCIALI 9
|
|||
|
#define RIGA_IVA_DIFFERITA 10
|
|||
|
#define RIGA_IVA_PER_CASSA 11
|
|||
|
#define RIGA_REVERSE_CHARGE 12
|
|||
|
|
|||
|
// Pagamenti
|
|||
|
#define RIGA_ABBUONI_PASSIVI 9
|
|||
|
#define RIGA_ABBUONI_ATTIVI 10
|
|||
|
#define RIGA_SPESE 11
|
|||
|
#define RIGA_PAG_RITFIS 12
|
|||
|
#define RIGA_DIFFCAM 13
|
|||
|
#define RIGA_PAG_RITSOC 14
|
|||
|
|
|||
|
|
|||
|
#ifndef __PROGIND_H
|
|||
|
class TProgind;
|
|||
|
#endif
|
|||
|
|
|||
|
#define PROVV "P"
|
|||
|
#define PROVV_NON_CANC "N"
|
|||
|
#define PROVV_BIL "B"
|
|||
|
#define PROVV_CESP "C"
|
|||
|
|
|||
|
// Defines per TInteressi_IVA_table. Servono per comporre i nomi dei campi
|
|||
|
|
|||
|
#define P_1_TRIMESTRE 0
|
|||
|
#define P_2_TRIMESTRE 1
|
|||
|
#define P_3_TRIMESTRE 2
|
|||
|
#define P_4_TRIMESTRE 3
|
|||
|
#define P_ANNUALE 4
|
|||
|
#define I_PERIODICO 5
|
|||
|
#define I_ANNUALE 6
|
|||
|
#define I_ACCONTOIVA 7
|
|||
|
#define I_INTEGRATIVO 8
|
|||
|
#define I_CESSAZIONE 9
|
|||
|
#define I_ART74 10
|
|||
|
#define B_LIQ_DIFF 11
|
|||
|
#define B_LIQ_NORM 12
|
|||
|
|
|||
|
|
|||
|
static const char * __date_field_name[] = { MOV_DATAREG, MOV_DATACOMP, MOV_DATACOMPCR };
|
|||
|
|
|||
|
enum TipoIVA
|
|||
|
{
|
|||
|
iva_errata = -1,
|
|||
|
nessuna_iva = 0,
|
|||
|
iva_vendite = 1,
|
|||
|
iva_acquisti = 2,
|
|||
|
libro_giornale = 5,
|
|||
|
iva_generica = 9
|
|||
|
};
|
|||
|
|
|||
|
enum tipo_movimento
|
|||
|
{
|
|||
|
tm_nessuno = 0,
|
|||
|
tm_fattura = 1,
|
|||
|
tm_nota_credito = 2,
|
|||
|
tm_pagamento = 3,
|
|||
|
tm_insoluto = 5,
|
|||
|
tm_pagamento_insoluto = 6
|
|||
|
};
|
|||
|
|
|||
|
|
|||
|
enum cgrowtypes
|
|||
|
{
|
|||
|
cgrowtype_contabile = ' ', // riga contabile
|
|||
|
cgrowtype_totale = 'T', // Totale documento
|
|||
|
cgrowtype_abbattivo = 'A', // Abbuoni attivi
|
|||
|
cgrowtype_diffcambio = 'C', // Differenza cambio
|
|||
|
cgrowtype_IVAdet = 'D', // IVA Detraibile
|
|||
|
cgrowtype_ritfis = 'F', // Ritenute Fiscali
|
|||
|
cgrowtype_contrspesa = 'L', // Contropartita delle spese
|
|||
|
cgrowtype_IVAnondet = 'N', // IVA Non detraibile
|
|||
|
cgrowtype_abbpassivo = 'P', // Abbuoni passivi
|
|||
|
cgrowtype_ritprof = 'R', // Ritenute professionali
|
|||
|
cgrowtype_ritsoc = 'S', // Ritenute Sociali
|
|||
|
cgrowtype_revcharge = 'V', // Reverse charge
|
|||
|
cgrowtype_IVAsplit = '2', // IVA per scissione pagamenti art.17-ter DPR 633/72
|
|||
|
cgrowtype_cliforsc = 'K', // Riga cliente/fornitore per saldaconto
|
|||
|
cgrowtype_imponibile = 'I', // Imponibile/contropartita saldaconto
|
|||
|
cgrowtype_clisplit = '1', // Cliente per scissione pagamenti art.17-ter DPR 633/72
|
|||
|
cgrowtype_spese = 'G' // Spese del saladaconto
|
|||
|
};
|
|||
|
|
|||
|
inline bool check_mov(const int tipomovprovv, const TString & provvis)
|
|||
|
{
|
|||
|
return ((tipomovprovv & 0x1) && provvis.blank()) ||
|
|||
|
((tipomovprovv & 0x2) && ((provvis == PROVV) || (provvis == PROVV_NON_CANC))) ||
|
|||
|
((tipomovprovv & 0x4) && (provvis == PROVV_BIL)) ||
|
|||
|
((tipomovprovv & 0x8) && (provvis == PROVV_CESP));
|
|||
|
}
|
|||
|
|
|||
|
// Gestione esercizi contabili, registri e libro giornale
|
|||
|
class TEsercizio : public TSortable
|
|||
|
{
|
|||
|
int _codice;
|
|||
|
TDate _inizio, _fine, _scarico, _chiusura, _chiusura_mag;
|
|||
|
|
|||
|
protected: // TSortable
|
|||
|
virtual int compare(const TSortable& s) const;
|
|||
|
|
|||
|
public:
|
|||
|
bool ok() const { return _codice != 0; }
|
|||
|
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;
|
|||
|
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); }
|
|||
|
const TEsercizio& esercizio(const TDate& date) const { return esercizio(date2esc(date)); }
|
|||
|
|
|||
|
int date2esc(const TDate& date) const;
|
|||
|
int date2prevesc(const TDate& date) const;
|
|||
|
int date2nextesc(const TDate& date) const;
|
|||
|
int pred(int codice) const;
|
|||
|
int next(int codice) const;
|
|||
|
int first() const;
|
|||
|
int last() const;
|
|||
|
int last_mag() const;
|
|||
|
bool exist(int codice) const;
|
|||
|
bool exist(const TDate & data) const { return exist(date2esc(data)); }
|
|||
|
bool code2range(int codice, TDate& dal, TDate& al) const;
|
|||
|
|
|||
|
TEsercizi_contabili();
|
|||
|
virtual ~TEsercizi_contabili() {}
|
|||
|
};
|
|||
|
|
|||
|
TEsercizi_contabili& esercizi();
|
|||
|
inline const TEsercizio & esercizio(const TDate & data) { return esercizi().esercizio(data); }
|
|||
|
inline const TEsercizio& esercizio(int codice) { return esercizi().esercizio(codice); };
|
|||
|
|
|||
|
const char* iva2name(TipoIVA i);
|
|||
|
const TString& cap2comune(const TString& cap, const TString& denom);
|
|||
|
|
|||
|
class TMask_field;
|
|||
|
|
|||
|
class TRegistro : public TObject
|
|||
|
{
|
|||
|
bool read_att();
|
|||
|
|
|||
|
protected:
|
|||
|
TRectype _rec, _att;
|
|||
|
TAssoc_array _prorata;
|
|||
|
|
|||
|
real* read_prorata(int anno) const;
|
|||
|
|
|||
|
public:
|
|||
|
bool read(const char* code, int year);
|
|||
|
bool force_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;
|
|||
|
const TString& tipo_attivita() const;
|
|||
|
bool attivita_mista() const { const char a = tipo_attivita()[0]; return a == 'E'; }
|
|||
|
|
|||
|
void set_prorata(int annodoc, const real& pro);
|
|||
|
real prorata(int annodoc);
|
|||
|
#ifdef PRORATA100
|
|||
|
bool prorata100(int annodoc) { return prorata(annodoc) >= CENTO; }
|
|||
|
#endif
|
|||
|
bool update(long uprotiva, const TDate& lastreg);
|
|||
|
|
|||
|
TRegistro(const char* code = "", int year = 0);
|
|||
|
TRegistro(const TRegistro & reg);
|
|||
|
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() {}
|
|||
|
};
|
|||
|
|
|||
|
class TBill;
|
|||
|
class TCodiceIVA;
|
|||
|
|
|||
|
class TCausale : public TArray
|
|||
|
{
|
|||
|
TRectype _rec;
|
|||
|
TRegistro _reg;
|
|||
|
|
|||
|
TipoIVA _iva;
|
|||
|
bool _corrisp;
|
|||
|
char _sezione_clifo, _sezione_ritsoc, _sezione_ritfis, _sezione_revcharge, _provvisorio;
|
|||
|
bool _regolarizzazione;
|
|||
|
|
|||
|
protected:
|
|||
|
const TRectype* row(int num) const { return (const TRectype*)objptr(num); }
|
|||
|
void calcIVA();
|
|||
|
|
|||
|
public: // TObject
|
|||
|
virtual bool ok() const;
|
|||
|
|
|||
|
public:
|
|||
|
TBill& bill(int num, TBill& c) const;
|
|||
|
|
|||
|
const char* codice() const;
|
|||
|
const char* descrizione() const;
|
|||
|
const char* cod_desc_agg(int num) const;
|
|||
|
const char* desc_agg(int num) const;
|
|||
|
|
|||
|
bool data_doc() const;
|
|||
|
bool num_doc() const;
|
|||
|
bool apertura() const;
|
|||
|
bool chiusura() const;
|
|||
|
bool sezionale() const;
|
|||
|
bool valuta() const;
|
|||
|
bool intra() const;
|
|||
|
bool valintra() const;
|
|||
|
bool soloiva() const;
|
|||
|
bool reverse_charge() const;
|
|||
|
bool reverse_charge_pubb() const;
|
|||
|
bool regolarizzazione() const;
|
|||
|
bool ril_fat_em_ric() const;
|
|||
|
bool datareg_prec() const;
|
|||
|
char provvisorio() const { return _provvisorio; }
|
|||
|
const TString& causale_collegata() const;
|
|||
|
const TString& causale_reg_iva() const;
|
|||
|
const TString& tipo_doc() const;
|
|||
|
|
|||
|
TRegistro& reg() const { return (TRegistro&)_reg; }
|
|||
|
TipoIVA iva() const { return _iva; }
|
|||
|
int regime_speciale() const;
|
|||
|
bool corrispettivi() const { return _corrisp; }
|
|||
|
bool esclusione_allegati() const;
|
|||
|
|
|||
|
// bill deve essere il conto di ricavo
|
|||
|
bool IVA2bill(const TCodiceIVA& iva, TBill& bill) const;
|
|||
|
|
|||
|
tipo_movimento tipomov() const;
|
|||
|
const TString& tipodoc() const;
|
|||
|
bool saldaconto(const TDate& datareg) const;
|
|||
|
int link_m770() const;
|
|||
|
char link_cespiti() const;
|
|||
|
bool link_analitica() const;
|
|||
|
bool link_industriale() const;
|
|||
|
|
|||
|
const TString& compatible(const TCausale& c) const;
|
|||
|
|
|||
|
char sezione(int riga, bool low_level = false) const;
|
|||
|
char sezione_clifo() const;
|
|||
|
char sezione_ritsoc() const;
|
|||
|
char sezione_ritfis() const;
|
|||
|
char sezione_revcharge() const;
|
|||
|
bool fattura_in_ritardo() const;
|
|||
|
|
|||
|
virtual bool reread();
|
|||
|
virtual bool read(const char* cod, int year);
|
|||
|
|
|||
|
TCausale(const char* code = "", int year = 0);
|
|||
|
virtual ~TCausale() {}
|
|||
|
};
|
|||
|
|
|||
|
const TCausale & cached_causale(const char * codcaus, const int year = 0);
|
|||
|
|
|||
|
class TCodiceIVA : public TRectype
|
|||
|
{
|
|||
|
protected:
|
|||
|
void copy(const TRectype & iva) { TRectype::operator =(iva); }
|
|||
|
void round(real& n, int ndec, const char* codval) const;
|
|||
|
|
|||
|
public: // TObject
|
|||
|
virtual bool ok() const { return !empty(); }
|
|||
|
TCodiceIVA& operator =(const TCodiceIVA & iva) { copy(iva) ; return *this;}
|
|||
|
TObject* dup() const { return new TCodiceIVA(*this); }
|
|||
|
bool read(const char* codice);
|
|||
|
const TString& codice() const { return get("CODTAB"); }
|
|||
|
const TString& descrizione() const { return get("S0"); }
|
|||
|
const real percentuale() const { return get_real("R0"); }
|
|||
|
const TString& tipo() const { return get("S1"); }
|
|||
|
const TString& indetraibilita() const { return get("S4"); } // Codice indetraibilit<69> alfanumerico (ex. 1, 3, 9)
|
|||
|
int tipo_indetraibilita() const; // Tipo indetraibilit<69>: 1,3,9
|
|||
|
bool senza_imposta() { return percentuale() == ZERO;}
|
|||
|
|
|||
|
int allegato(char tipocf) const { return get_int(tipocf == 'F' ? "S8" : "S7"); }
|
|||
|
bool has_plafond() const { return get_int("S3") > 0; }
|
|||
|
bool sospeso() const { return get_bool("B2"); }
|
|||
|
bool escluso_esenti() const { return get_bool("B5"); }
|
|||
|
bool numeratore_pro_rata() const { return get_bool("B6"); }
|
|||
|
bool denominatore_pro_rata() const { return get_bool("B7"); }
|
|||
|
bool reverse_charge_attivo() const { return get_bool("B8"); }
|
|||
|
|
|||
|
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
|
|||
|
|
|||
|
// bool reverse_charge() const;
|
|||
|
// bool reverse_charge_pubb() const;
|
|||
|
int regime_speciale() const { return get_int("I5");}
|
|||
|
|
|||
|
const TString& natura() const { return get("S12"); }
|
|||
|
|
|||
|
TCodiceIVA(const char* codice = nullptr);
|
|||
|
TCodiceIVA(const TRectype & rec) : TRectype(rec) {}
|
|||
|
TCodiceIVA(const TCodiceIVA & iva) : TRectype(iva) {}
|
|||
|
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
|
|||
|
char _sezione;
|
|||
|
bool _sospeso;
|
|||
|
|
|||
|
protected:
|
|||
|
void set_description(const char* d);
|
|||
|
const TBill& copy(const TBill& b);
|
|||
|
const char* field_name(int n, const TRectype& rec, bool contro) const;
|
|||
|
|
|||
|
public: // TObject
|
|||
|
virtual int compare(const TSortable& s) const;
|
|||
|
virtual const char* class_name() const { return "Conto"; }
|
|||
|
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 = nullptr, int r = -1)
|
|||
|
: _tipo(t), _gruppo(g), _conto(c), _sottoconto(s), _descrizione(nullptr),
|
|||
|
_sezione(' '), _sospeso(false)
|
|||
|
{ set(g,c,s,t,d,r);}
|
|||
|
|
|||
|
TBill(TToken_string& tgcsd, int from, int mode = 0)
|
|||
|
: _descrizione(nullptr), _sezione(' '), _sospeso(false)
|
|||
|
{ get(tgcsd, from, mode); }
|
|||
|
|
|||
|
TBill(const TRectype& rec, bool contro = false)
|
|||
|
: _descrizione(nullptr), _sezione(' '), _sospeso(false)
|
|||
|
{ get(rec, contro); }
|
|||
|
|
|||
|
TBill(const TBill& b)
|
|||
|
: _descrizione(nullptr)
|
|||
|
{ copy(b); }
|
|||
|
|
|||
|
virtual ~TBill();
|
|||
|
|
|||
|
const TBill& set(int g = 0, int c = 0, long s = 0L, char t = ' ',
|
|||
|
const char* d = nullptr, 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 indicatore_bilancio() const;
|
|||
|
|
|||
|
int tipo_att();
|
|||
|
bool read(TRectype& r);
|
|||
|
bool sospeso() const;
|
|||
|
char sezione() const;
|
|||
|
|
|||
|
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;
|
|||
|
|
|||
|
bool required_cdc() const;
|
|||
|
bool default_cdc(TString& cdc, TString& fas) const;
|
|||
|
bool is_analitico() const;
|
|||
|
};
|
|||
|
|
|||
|
enum TIndbil { ib_null, ib_attivita, ib_passivita, ib_costi, ib_ricavi, ib_conti_ordine };
|
|||
|
|
|||
|
const char* num2str(const TString & s);
|
|||
|
|
|||
|
// Gestione saldi e ... basta
|
|||
|
|
|||
|
class TConto : public TBill
|
|||
|
{
|
|||
|
real _dare, _avere, _darepro, _averepro, _dareprob, _avereprob, _dareproc, _avereproc, _saldofin, _saldo;
|
|||
|
TImporto _saldo_finale;
|
|||
|
|
|||
|
public:
|
|||
|
TConto(int g = 0, int c = 0, long s = 0L, char t = ' ', const char* d = nullptr)
|
|||
|
: TBill(g, c, s, t, d) {}
|
|||
|
TConto(TToken_string& tgcsd, int from, int mode = 0)
|
|||
|
: TBill(tgcsd, from, mode) {}
|
|||
|
|
|||
|
real& dare() { return _dare; }
|
|||
|
const real& dare() const { return _dare; }
|
|||
|
|
|||
|
real& avere() { return _avere; }
|
|||
|
const real& avere() const { return _avere; }
|
|||
|
|
|||
|
real& darepro() { return _darepro; }
|
|||
|
const real& darepro() const { return _darepro; }
|
|||
|
|
|||
|
real& averepro() { return _averepro; }
|
|||
|
const real& averepro() const { return _averepro; }
|
|||
|
|
|||
|
real& dareprob() { return _dareprob; }
|
|||
|
const real& dareprob() const { return _dareprob; }
|
|||
|
|
|||
|
real& avereprob() { return _avereprob; }
|
|||
|
const real& avereprob() const { return _avereprob; }
|
|||
|
|
|||
|
real& dareproc() { return _dareproc; }
|
|||
|
const real& dareproc() const { return _dareproc; }
|
|||
|
|
|||
|
real& avereproc() { return _avereproc; }
|
|||
|
const real& avereproc() const { return _avereproc; }
|
|||
|
|
|||
|
real& saldo() { return _saldo; }
|
|||
|
const real& saldo() const { return _saldo; }
|
|||
|
|
|||
|
real& saldofin() { return _saldofin; }
|
|||
|
const real& saldofin() const { return _saldofin; }
|
|||
|
|
|||
|
TImporto& saldo_finale() { return _saldo_finale; }
|
|||
|
const TImporto& saldo_finale() const { return _saldo_finale; }
|
|||
|
};
|
|||
|
|
|||
|
///////////////////////////////////////////////////////////
|
|||
|
// TSaldi_list
|
|||
|
///////////////////////////////////////////////////////////
|
|||
|
|
|||
|
class TSaldi_list : public TAssoc_array
|
|||
|
{
|
|||
|
public:
|
|||
|
TSaldi_list(int g, int c, int aec, int aep = 0);
|
|||
|
TRectype* saldi() const;
|
|||
|
};
|
|||
|
|
|||
|
enum tipobil { DataLimite = 1, UltimaImmissione };
|
|||
|
enum tiposal { normale, apertura, chiusura };
|
|||
|
enum TTipo_data { Registrazione, Competenza, CostiRicavi };
|
|||
|
|
|||
|
const TDate get_date_mov(const TRectype & mov, TTipo_data tipo_data);
|
|||
|
|
|||
|
class TSaldo : public TObject
|
|||
|
{
|
|||
|
TLocalisamfile _saldi;
|
|||
|
|
|||
|
char _sezsf;
|
|||
|
real _saldoiniziale; // oh my GOSH
|
|||
|
real _saldo_iniziale;
|
|||
|
real _prg_dare;
|
|||
|
real _prg_avere;
|
|||
|
real _prg_dare_mese[12];
|
|||
|
real _prg_avere_mese[12];
|
|||
|
real _saldofin;
|
|||
|
real _saldo;
|
|||
|
int _annoes;
|
|||
|
int _indbil;
|
|||
|
TDate _inizioEs, _fineEs;
|
|||
|
|
|||
|
bool _prec;
|
|||
|
bool _movimentato;
|
|||
|
bool _significativo;
|
|||
|
bool _rec_presente_ec;
|
|||
|
bool _rec_presente_ep;
|
|||
|
|
|||
|
TDecoder _causali_apertura;
|
|||
|
|
|||
|
protected:
|
|||
|
void InFinEs(int);
|
|||
|
bool leggi_mov(long numreg); // Leggi testata
|
|||
|
real calcola_saldo_iniziale(int g, int c, long s, int indbil, int provv = 0x1);
|
|||
|
bool prg_saldo(int, TConto&, real&, real&, bool);
|
|||
|
const real& iniziale() const { return _saldo_iniziale; }
|
|||
|
void set_iniziale(const real& val) { _saldo_iniziale = val; }
|
|||
|
real& saldo_ref() { return _saldo; }
|
|||
|
real& saldoini_ref() { return _saldo_iniziale; }
|
|||
|
real& prgdare_ref() { return _prg_dare; }
|
|||
|
real& prgavere_ref() { return _prg_avere; }
|
|||
|
void set_movimentato(bool on = true) { _movimentato = on; }
|
|||
|
|
|||
|
public:
|
|||
|
bool movimentato() const { return _movimentato; }
|
|||
|
bool significativo() const { return _significativo; }
|
|||
|
bool esiste_saldo() const { return _rec_presente_ec || _rec_presente_ep; }
|
|||
|
bool esiste_saldo_ep() const { return _rec_presente_ep; }
|
|||
|
|
|||
|
int annoes() const { return _annoes; }
|
|||
|
void set_annoes(int anno) { _annoes = anno; }
|
|||
|
|
|||
|
bool causale_mov(long, const TDate&, const TDate&, TString&);
|
|||
|
|
|||
|
bool ultima_immissione_bilancio(int annoes, int g, int c, long s, int indbil, int provv = 0x1, bool saldo_chiusura = true);
|
|||
|
bool ultima_immissione_verifica(int annoes, int g, int c, long s, int indbil, int provv = 0x1);
|
|||
|
bool data_limite_bilancio(TTipo_data tipo_data, int g, int c, long s, const TDate& data_inf, const TDate& data_suo, int indbil, int provv = 0x1, const char* filter = nullptr);
|
|||
|
const real& saldo_periodo(TTipo_data tipo_data, int g, int c, long s, const TDate& dal, const TDate& al, int indbil, int provv = 0x1);
|
|||
|
bool saldo_cont_sep(TTipo_data tipo_data, int g, int c, long s, const int codes, TDate al, int indbil, const char * cont_sep, int provv = 0x1, bool chiusura = false, bool first = true);
|
|||
|
bool ricerca_progr_prec(int, int, int, long);
|
|||
|
|
|||
|
real saldofin_esprec(int, int, int, long, bool saldo_chiusura = FALSE, int provv = 0x1);
|
|||
|
bool prg_attuali(int i, TConto& c, real& p1, real& p2)
|
|||
|
{
|
|||
|
return prg_saldo(i, c, p1, p2, FALSE);
|
|||
|
}
|
|||
|
bool prg_mov_eliminati(int i, TConto& c, real& p1, real& p2)
|
|||
|
{
|
|||
|
return prg_saldo(i, c, p1, p2, TRUE);
|
|||
|
}
|
|||
|
|
|||
|
const real& saldo() const { return _saldo; }
|
|||
|
const real& saldoini() const { return _saldo_iniziale; }
|
|||
|
const real& saldoinisusaldi() const { return _saldoiniziale; }
|
|||
|
const real& prgdare() const { return _prg_dare; }
|
|||
|
const real& prgavere() const { return _prg_avere; }
|
|||
|
const real& prgdare(int month) const { return _prg_dare_mese[month - 1]; }
|
|||
|
const real& prgavere(int month) const { return _prg_avere_mese[month - 1]; }
|
|||
|
const real& saldofin() const { return _saldofin; }
|
|||
|
const char sezsf() const { return _sezsf; }
|
|||
|
const bool flagprec() { return _prec; }
|
|||
|
|
|||
|
// bool prg_attuali(int i,TConto& c, int d, real& p1, real& p2);
|
|||
|
// bool prg_mov_eliminati(int i,TConto& c,int d, real& p1, real& p2);
|
|||
|
|
|||
|
TSaldo();
|
|||
|
virtual ~TSaldo() {}
|
|||
|
};
|
|||
|
|
|||
|
class TTab_conti : public TAssoc_array
|
|||
|
{
|
|||
|
protected:
|
|||
|
const TString& build_key(const TBill& c, int anno, bool scar) const;
|
|||
|
|
|||
|
public:
|
|||
|
void aggiorna_conto(const TBill& tc, int anno_es, const TImporto& importo,
|
|||
|
tiposal movap, char provv, bool somma, bool movimentato, bool scaricato);
|
|||
|
|
|||
|
TConto* add(const TBill& c, int anno, bool provv = FALSE);
|
|||
|
TConto* find(const TBill& c, int anno, bool provv = FALSE);
|
|||
|
void remove(const TBill& c, int anno, bool provv = FALSE);
|
|||
|
};
|
|||
|
|
|||
|
class TSaldo_agg : public TObject
|
|||
|
{
|
|||
|
TTab_conti _tab_conti;
|
|||
|
int _anno_es; // anno esercizio
|
|||
|
TDate _data_ulmov; // data ultimo movimento
|
|||
|
long _num_ulmov; // numero ultimo movimento
|
|||
|
tiposal _movap; // se e' mov. d'apertura (aggiorno SALDO e FLAGSALINI in saldi)
|
|||
|
char _provv;
|
|||
|
TRectype* _rec; // record corrente sui saldi
|
|||
|
bool _movimentato; // di default e' FALSE; viene usato a TRUE solo quando voglio
|
|||
|
// che un conto sia movimentato sui saldi anche se progressivi
|
|||
|
// e saldo iniziale non sono significativi. Usato dalla Chiusura/Apertura conti
|
|||
|
public:
|
|||
|
void clear_saldi(int year);
|
|||
|
void registra();
|
|||
|
void aggiorna(const TBill& tc, const TImporto& importo, bool somma = true, bool scaricato = false);
|
|||
|
void aggiorna(const TBill& tc, const real& importo, char sezione, bool somma = true, bool scaricato = false) { aggiorna(tc.gruppo(), tc.conto(), tc.sottoconto(), importo, sezione, somma, scaricato); }
|
|||
|
void aggiorna(int gruppo, int conto, long sottoconto,
|
|||
|
const real& importo, char sezione, bool somma = true, bool scaricato = false);
|
|||
|
void aggiorna(const TRectype& rmov, bool somma = true, bool scaricato = false);
|
|||
|
|
|||
|
TConto* find(const TBill& c, int anno) { return _tab_conti.find(c, anno); }
|
|||
|
|
|||
|
void set_anno_es(int anno) { _anno_es = anno; }
|
|||
|
int anno_es() const { return _anno_es; }
|
|||
|
|
|||
|
void set_tipo_saldo(tiposal movap) { _movap = movap; }
|
|||
|
tiposal tipo_saldo() const { return _movap; }
|
|||
|
|
|||
|
void set_movprovv(char p) { _provv = p; }
|
|||
|
char movprovv() const { return _provv; }
|
|||
|
|
|||
|
void set_movimentato(bool movimentato) { _movimentato = movimentato; }
|
|||
|
bool movimentato() const { return _movimentato; }
|
|||
|
|
|||
|
void set_data_ulmov(const TDate& data) { _data_ulmov = data; }
|
|||
|
const TDate& data_ulmov() const { return _data_ulmov; }
|
|||
|
|
|||
|
void set_num_ulmov(long num) { _num_ulmov = num; }
|
|||
|
long num_ulmov() const { return _num_ulmov; }
|
|||
|
|
|||
|
void reset(); // pulisce l'array dei conti
|
|||
|
int items() const { return _tab_conti.items(); }
|
|||
|
|
|||
|
TSaldo_agg();
|
|||
|
virtual ~TSaldo_agg() { }
|
|||
|
};
|
|||
|
|
|||
|
///////////////////////////////////////////////////////////
|
|||
|
// TBalance
|
|||
|
///////////////////////////////////////////////////////////
|
|||
|
|
|||
|
class TBalance : public TObject
|
|||
|
{
|
|||
|
TImporto _saldo_ini, _progr_dare, _progr_avere, _saldo_fin;
|
|||
|
|
|||
|
protected:
|
|||
|
bool find(const TBill& b, int esercizio,
|
|||
|
TImporto& si, TImporto& da, TImporto& av, TImporto& sf,
|
|||
|
TImporto& pd, TImporto& pa) const;
|
|||
|
int indicatore_bilancio(const TBill& b) const;
|
|||
|
|
|||
|
public:
|
|||
|
void read(int g, int c, long s, int esercizio, bool ignora_movap, bool provv);
|
|||
|
void read(const TBill& b, int esercizio, bool ignora_movap, bool provv);
|
|||
|
void reread();
|
|||
|
|
|||
|
const TImporto& saldo_iniziale() const;
|
|||
|
const real& progressivo_dare_iniziale() const;
|
|||
|
const real& progressivo_avere_iniziale() const;
|
|||
|
real progressivo_dare_finale() const;
|
|||
|
real progressivo_avere_finale() const;
|
|||
|
TImporto saldo_finale(bool chiusura = FALSE) const;
|
|||
|
TImporto saldo_finale_chiusura() const;
|
|||
|
|
|||
|
TBalance();
|
|||
|
TBalance(int g, int c, long s, int esercizio, bool ignora_movap, bool provv);
|
|||
|
TBalance(const TBill& b, int esercizio, bool ignora_movap, bool provv);
|
|||
|
virtual ~TBalance() { }
|
|||
|
};
|
|||
|
|
|||
|
class TInteressi_IVA_table : public TTable
|
|||
|
{
|
|||
|
public:
|
|||
|
int read(int anno, int mese);
|
|||
|
//int status() { return _ver->status();}
|
|||
|
real get(int what);
|
|||
|
int giorno_acc() const;
|
|||
|
TInteressi_IVA_table();
|
|||
|
virtual ~TInteressi_IVA_table();
|
|||
|
};
|
|||
|
|
|||
|
struct TDociva : public TObject
|
|||
|
{
|
|||
|
TString _descrdoc;
|
|||
|
real _totdociva;
|
|||
|
int _ndoc;
|
|||
|
|
|||
|
TDociva(const char* _descrdociva, const real& _importo, const int _natdoc)
|
|||
|
:_descrdoc(_descrdociva), _totdociva(_importo), _ndoc(_natdoc) { }
|
|||
|
virtual ~TDociva() { }
|
|||
|
};
|
|||
|
|
|||
|
class TDociva_array : public TArray
|
|||
|
{
|
|||
|
public:
|
|||
|
bool add_riga(const char* _descrdociva, const real& _importo, const int _natdoc);
|
|||
|
TDociva& riga(int i) { return (TDociva&)(*this)[i]; }
|
|||
|
};
|
|||
|
|
|||
|
struct TRigaiva : public TObject
|
|||
|
{
|
|||
|
real _imponibile, _imposta;
|
|||
|
real _imponibilep, _impostap;
|
|||
|
TString4 _codiva;
|
|||
|
int _tipodet;
|
|||
|
int _tipocr, _tipoatt;
|
|||
|
bool _intra;
|
|||
|
|
|||
|
const TString& descr_det() const;
|
|||
|
|
|||
|
TRigaiva(const real& imponibile, const real& imposta, const real& imponibilep, const real& impostap,
|
|||
|
const char* codiva, int tipodet, int tipocr, bool intra, int tipoatt) :
|
|||
|
_imponibile(imponibile), _imposta(imposta), _imponibilep(imponibilep), _impostap(impostap), _codiva(codiva), _tipodet(tipodet), _tipocr(tipocr), _tipoatt(tipoatt), _intra(intra)
|
|||
|
{}
|
|||
|
};
|
|||
|
|
|||
|
// TRigaiva_array
|
|||
|
// Tabella per il calcolo degli imponibili Iva
|
|||
|
class TRigaiva_array : public TArray
|
|||
|
{
|
|||
|
public:
|
|||
|
bool add_riga(const real& imponibile, const real& imposta,
|
|||
|
const real& imponibilep, const real& impostap,
|
|||
|
const char* codiva, int tipodet, int tipocr, bool intra, int tipoatt);
|
|||
|
|
|||
|
bool add_riga(const TRectype& rmi);
|
|||
|
|
|||
|
TRigaiva& riga(int i) { return (TRigaiva&)(*this)[i]; }
|
|||
|
const TRigaiva& riga(int i) const { return (const TRigaiva&)(*this)[i]; }
|
|||
|
};
|
|||
|
|
|||
|
struct TTipodoc : public TObject
|
|||
|
{
|
|||
|
TString4 _tipodoc;
|
|||
|
TString _descrdoc;
|
|||
|
real _totdoc;
|
|||
|
|
|||
|
TTipodoc(const char* tipodoc, const char* descrdoc, const real& totdoc) :
|
|||
|
_tipodoc(tipodoc), _descrdoc(descrdoc), _totdoc(totdoc) {}
|
|||
|
};
|
|||
|
|
|||
|
class TTipodoc_array : public TArray
|
|||
|
{
|
|||
|
public:
|
|||
|
bool add_riga(const char* tipodoc, const char* descrdoc, const real& totdoc);
|
|||
|
const TTipodoc& riga(int i) const { return (TTipodoc&)(*this)[i]; }
|
|||
|
};
|
|||
|
|
|||
|
struct TRiga : public TObject
|
|||
|
{
|
|||
|
real _imponibile, _imposta, _implordo; // totali del periodo
|
|||
|
real _imponibilep, _impostap, _implordop; // totali progressivi
|
|||
|
TString4 _codiva;
|
|||
|
|
|||
|
TRiga(const real& imponibile, const real& imposta, const real& implordo, const real& imponibilep, const real& impostap, const real& implordop, const char* codiva) :
|
|||
|
_imponibile(imponibile), _imposta(imposta), _implordo(implordo), _imponibilep(imponibilep), _impostap(impostap), _implordop(implordop), _codiva(codiva) {}
|
|||
|
};
|
|||
|
|
|||
|
class TRiga_array : public TArray
|
|||
|
{
|
|||
|
public:
|
|||
|
bool add_riga(const real& imponibile, const real& imposta, const real& implordo, const real& imponibilep, const real& impostap, const real& implordop, const char* codiva);
|
|||
|
bool add_riga(const real& imponibile, const real& imposta, const char* codiva) { return add_riga(imponibile, imposta, ZERO, ZERO, ZERO, ZERO, codiva); }
|
|||
|
|
|||
|
const TRiga& riga(int i) const { return (const TRiga&)(*this)[i]; }
|
|||
|
TRiga& riga(int i) { return (TRiga&)(*this)[i]; }
|
|||
|
};
|
|||
|
|
|||
|
///////////////////////////////////////////////////////////
|
|||
|
// Arrotondamenti IVA
|
|||
|
///////////////////////////////////////////////////////////
|
|||
|
|
|||
|
enum TRound_mode { rm_unknown, rm_round, rm_ceil, rm_millelire };
|
|||
|
|
|||
|
class TIva_round : public TObject
|
|||
|
{
|
|||
|
static TRound_mode _def_mode;
|
|||
|
static int _def_decimals;
|
|||
|
|
|||
|
TRound_mode _mode;
|
|||
|
int _decimals;
|
|||
|
|
|||
|
public: // Low level functions (rare usage)
|
|||
|
void set_default_mode(TRound_mode m, int d);
|
|||
|
void set_mode(TRound_mode m, int d);
|
|||
|
|
|||
|
public: // High level functions (common usage)
|
|||
|
virtual bool ok() const { return _mode != rm_unknown; }
|
|||
|
|
|||
|
// Call this before the first call to round!
|
|||
|
void set_default_iva_mode(int year, bool declaration = false, long firm = 0L);
|
|||
|
|
|||
|
void round(real& n) const;
|
|||
|
TIva_round();
|
|||
|
};
|
|||
|
|
|||
|
real indetraibile_al(const TString& codind, const TCausale& caus, int annodoc,
|
|||
|
int & tipodet, const bool is_liq = false);
|
|||
|
int analizza_IVA(const real& imptot, const real& ivatot, const real perc_ind,
|
|||
|
const bool corrispettivo, const bool iva_ind_al_costo, const TString& codiva,
|
|||
|
real& imp_det, real& iva_det, real& imp_ind, real& iva_ind);
|
|||
|
int get_tipodet_from_rmi(const TRectype& rmi, const TRectype& mv, real& percind, const bool is_liq = false);
|
|||
|
|
|||
|
bool gestione_IVAxCassa(const TDate& data, long firm = 0);
|
|||
|
bool is_reverse_charge(const TRectype& mov);
|
|||
|
bool is_split_payment(const TRectype& mov);
|
|||
|
bool is_IVA_diff(const TRectype& mov);
|
|||
|
bool is_IVAxCassa(const TRectype& mov);
|
|||
|
|
|||
|
///////////////////////////////////////////////////////////
|
|||
|
// TRiepilogoIVA_recordset
|
|||
|
///////////////////////////////////////////////////////////
|
|||
|
|
|||
|
|
|||
|
class TRiepilogoIVA_recordset : public TRecordset
|
|||
|
{
|
|||
|
TArray _rows;
|
|||
|
TArray _info;
|
|||
|
long _pos;
|
|||
|
TDate _from_date;
|
|||
|
TDate _to_date;
|
|||
|
int _anno;
|
|||
|
int _da_mese;
|
|||
|
int _a_mese;
|
|||
|
bool _freezed;
|
|||
|
bool _annuale;
|
|||
|
|
|||
|
protected:
|
|||
|
virtual const TVariant& get_field(int num, const char* field) const;
|
|||
|
void TRiepilogoIVA_recordset::add_field(TFieldtypes tipo, short id, int width, const char* name);
|
|||
|
|
|||
|
public:
|
|||
|
virtual TRecnotype items() const { return _rows.items(); }
|
|||
|
virtual bool move_to(TRecnotype pos);
|
|||
|
virtual TRecnotype current_row() const { return _pos; }
|
|||
|
virtual void requery();
|
|||
|
virtual const TString& query_text() const;
|
|||
|
virtual unsigned int columns() const { return _info.items(); }
|
|||
|
virtual const TRecordset_column_info& column_info(unsigned int column) const { return (const TRecordset_column_info&)_info[column]; }
|
|||
|
void freeze(bool on = true) { _freezed = on; }
|
|||
|
void unfreeze() { freeze(false); }
|
|||
|
// const TString& col2name(unsigned int column) const;
|
|||
|
virtual const TVariant& get(unsigned int column) const;
|
|||
|
|
|||
|
TDate set_from(const TDate& from) { set_var("#FROMDATE", from, true); return _from_date = from; }
|
|||
|
TDate set_to(const TDate& to) { set_var("#TODATE", to, true); return _to_date = to; }
|
|||
|
int set_anno(const int anno) { set_var("#ANNO", (long)anno, true); return _anno = anno; };
|
|||
|
void set_da_mese_var(const int mese) { set_var("#DAMESE", (long)mese, true); }
|
|||
|
void set_a_mese_var(const int mese) { set_var("#AMESE", (long)mese, true); }
|
|||
|
int set_da_mese(const int mese) { return _da_mese = mese; }
|
|||
|
int set_a_mese(const int mese) { return _a_mese = mese; }
|
|||
|
|
|||
|
bool set_annual(bool on) { return _annuale = on; }
|
|||
|
bool annuale() const { return _annuale; }
|
|||
|
virtual bool is_competenza() const { return false; }
|
|||
|
int anno() const { return _anno; }
|
|||
|
int da_mese() { return _da_mese; }
|
|||
|
int a_mese() { return _a_mese; }
|
|||
|
|
|||
|
TRiepilogoIVA_recordset();
|
|||
|
virtual ~TRiepilogoIVA_recordset() { }
|
|||
|
};
|
|||
|
|
|||
|
///////////////////////////////////////////////////////////
|
|||
|
// TRiepilogoIVA_report
|
|||
|
///////////////////////////////////////////////////////////
|
|||
|
|
|||
|
class TRiepilogoIVA_report : public TReport
|
|||
|
{
|
|||
|
|
|||
|
protected:
|
|||
|
virtual bool use_mask() { return false; }
|
|||
|
|
|||
|
public:
|
|||
|
virtual bool set_recordset(TRecordset * set) { return TReport::set_recordset(set); }
|
|||
|
|
|||
|
};
|
|||
|
|
|||
|
char frequenza_versamenti(int year, long firm = -1); // Ritorna 'M'ensile o 'T'rimestrale
|
|||
|
int date2liq(const TDate & data, long firm = -1); // Estrae dalla data il mese di liquidazione
|
|||
|
bool controlla_liquidazione(const TDate & data, const TRegistro & reg, bool reset = false);
|
|||
|
|
|||
|
class TMovimento_contabile : public TMultiple_rectype
|
|||
|
{
|
|||
|
TDate _olddataliq;
|
|||
|
TRecord_array _old_iva;
|
|||
|
|
|||
|
protected:
|
|||
|
int registra(bool re, bool force);
|
|||
|
int read_mov_rows();
|
|||
|
void update_rev_charge();
|
|||
|
void find_movcoll();
|
|||
|
virtual int write_rewrite(TBaseisamfile& f, bool re = false) const;
|
|||
|
|
|||
|
public:
|
|||
|
const TRecord_array& cg() const { return body(LF_RMOV); }
|
|||
|
TRecord_array& cg() { return body(LF_RMOV); }
|
|||
|
const TRecord_array& iva() const { return body(LF_RMOVIVA); }
|
|||
|
TRecord_array& iva() { return body(LF_RMOVIVA); }
|
|||
|
TRectype& cg(int i, bool create = true) { return cg().row(i, create); }
|
|||
|
TRectype& iva(int i, bool create = true) { return iva().row(i, create); }
|
|||
|
const TRectype& cg(int i, bool create = true) const { return (const TRectype &) ((TRecord_array &) cg()).row(i, create); }
|
|||
|
const TRectype& iva(int i, bool create = true) const { return (const TRectype &)((TRecord_array &) iva()).row(i, create); }
|
|||
|
int cg_rows() const { return cg().rows(); }
|
|||
|
int iva_rows() const { return iva().rows(); }
|
|||
|
|
|||
|
virtual int readat(TBaseisamfile& f, TRecnotype nrec, word lockop = _nolock);
|
|||
|
virtual int read(TBaseisamfile & f, word op = _isequal, word lockop = _nolock);
|
|||
|
virtual int TMovimento_contabile::remove();
|
|||
|
|
|||
|
void adjust_rowtypes();
|
|||
|
real imponibile(const char * codiva = nullptr) const ;
|
|||
|
real imposta(const char * codiva = nullptr) const ;
|
|||
|
|
|||
|
TMovimento_contabile();
|
|||
|
virtual ~TMovimento_contabile() {}
|
|||
|
};
|
|||
|
|
|||
|
#define TEMP_CAUS "tcaus"
|
|||
|
#define TEMP_RCAUS "trcaus"
|
|||
|
#define TEMP_CLIFO "tclifo"
|
|||
|
#define TEMP_PCON "tpcon"
|
|||
|
#define TEMP_MOV "tmov"
|
|||
|
#define TEMP_RMOV "trmov"
|
|||
|
#define TEMP_RMOVIVA "trmoviva"
|
|||
|
#define TEMP_OCC "toccas"
|
|||
|
#define TEMP_PART "tpart"
|
|||
|
#define TEMP_SCAD "tscad"
|
|||
|
#define TEMP_PAGSCA "tpagsca"
|
|||
|
#define TEMP_TAB "ttab"
|
|||
|
|
|||
|
#define SIZE 256
|
|||
|
|
|||
|
static unsigned char _tabella[10] = { 0x7d,0x4a,0x4b,0x4c,0x4d,0x4e,0x4f,0x50,0x51,0x52 };
|
|||
|
|
|||
|
#define HEADER "\\header"
|
|||
|
|
|||
|
const int CAMPI_RCAUS = 6;
|
|||
|
|
|||
|
// Tracciato del record di controllo
|
|||
|
HIDDEN int pos[15] = { 0,15,25,29,32,38,47,234,235,236,237,238,239,240,241 };
|
|||
|
|
|||
|
const int LEN_REC_HEAD = 1025;
|
|||
|
|
|||
|
const char* converti_data(const TString& data_AS400, bool anno_di_quattro);
|
|||
|
const char* riconverti_data(const TString& data_PC, bool anno_di_quattro);
|
|||
|
int date2esc(const TDate& d, int* prevesc = NULL);
|
|||
|
|
|||
|
int packindex(bool vis, int num, TString& name);
|
|||
|
int pack(bool vis, int num, TString& name);
|
|||
|
int packfile(bool vis, int num, TString& name);
|
|||
|
bool format_if_zero(TString&, int);
|
|||
|
|
|||
|
class TRic_recfield : public TObject
|
|||
|
{
|
|||
|
char _name[12]; // Nome campo
|
|||
|
TRectype* _rec; // Puntatore a inizio record
|
|||
|
char* _p; // Puntatore a inizio campo
|
|||
|
int _len; // Lunghezza campo
|
|||
|
int _dec; // Numero di decimali
|
|||
|
int _type; // Tipo del campo
|
|||
|
|
|||
|
void set(int from, int to);
|
|||
|
|
|||
|
public:
|
|||
|
|
|||
|
const char* operator =(const char* s);
|
|||
|
|
|||
|
|
|||
|
operator const char*() const;
|
|||
|
|
|||
|
const char* pos() const { return (const char*)_p; } // Ritorna un puntatore all'inizio del campo nel record. Dovrebbe essere protected!
|
|||
|
int len() const { return (int)_len; } // Ritorna la lunghezza
|
|||
|
int dec() const { return (int)_dec; } // Ritorna il numero di decimali
|
|||
|
TFieldtypes type() const { return (TFieldtypes)_type; } // Ritorna il tipo del campo
|
|||
|
TRectype& record() const { return *_rec; } // Ritorna puntatore a inizio record
|
|||
|
|
|||
|
TRic_recfield(TRectype& rec, const char* name, int from = 0, int len = 0);
|
|||
|
virtual ~TRic_recfield() {}
|
|||
|
};
|
|||
|
|
|||
|
class TMappa_trc : public TAssoc_array
|
|||
|
{
|
|||
|
public:
|
|||
|
bool leggi_modulo(const char* tracciato);
|
|||
|
|
|||
|
int from(const char* key) const;
|
|||
|
int to(const char* key) const;
|
|||
|
int logicnum(const char* key) const;
|
|||
|
const char* field_name(const char* key) const;
|
|||
|
int flag(const char* key) const;
|
|||
|
int flag_bis(const char* key) const;
|
|||
|
};
|
|||
|
|
|||
|
class TTransfer_file
|
|||
|
{
|
|||
|
FILE* _trasfer;
|
|||
|
TArray _index;
|
|||
|
TMappa_trc _trc;
|
|||
|
TString _curfile;
|
|||
|
TString256 _control_rec_t; // Buffer per il record di controllo del trasfer
|
|||
|
TString* _control_rec; // Buffer per il record di controllo
|
|||
|
TString256 _record; // Buffer per il record corrente
|
|||
|
TProgind* _prog;
|
|||
|
TIsamtempfile* _tcaus;
|
|||
|
TIsamtempfile* _trcaus;
|
|||
|
TIsamtempfile* _tclifo;
|
|||
|
TIsamtempfile* _tpcon;
|
|||
|
TIsamtempfile* _tmov;
|
|||
|
TIsamtempfile* _trmov;
|
|||
|
TIsamtempfile* _triva;
|
|||
|
TIsamtempfile* _toccas;
|
|||
|
TIsamtempfile* _tpart;
|
|||
|
TIsamtempfile* _tscad;
|
|||
|
TIsamtempfile* _tpagsca;
|
|||
|
TIsamtempfile* _ttab;
|
|||
|
TRectype* _depcaus;
|
|||
|
TRectype* _deprcaus;
|
|||
|
TRectype* _depclifo;
|
|||
|
TRectype* _deppcon;
|
|||
|
TRectype* _depmov;
|
|||
|
TRectype* _deprmov;
|
|||
|
TRectype* _depriva;
|
|||
|
TRectype* _depoccas;
|
|||
|
TExtrectype* _deppart;
|
|||
|
TExtrectype* _depscad;
|
|||
|
TExtrectype* _deppagsca;
|
|||
|
TRecord_cache _comuni2;
|
|||
|
|
|||
|
TRecnotype _rec; //Serve alle funzioni per istanziare un Isamtempfile localmente
|
|||
|
|
|||
|
|
|||
|
long _numreg, _numreg_p, _numreg_piva, _npoccas;
|
|||
|
long _nregSC, _nregSC_p;
|
|||
|
int _numrigSC, _numrigSC_p, _annoSC, _annoSC_p, _nrigaSC;
|
|||
|
TString8 _numpartSC, _numpartSC_p;
|
|||
|
int _annoes;
|
|||
|
TDate _datareg;
|
|||
|
TString4 _cod_com;
|
|||
|
|
|||
|
long _curpos;
|
|||
|
long _tot_rec; // Numero totale di record nel transfer
|
|||
|
int _nultras; // Numero ultimo trasferimento
|
|||
|
int _last_tab, _last_mov;
|
|||
|
long _ditta;
|
|||
|
|
|||
|
TString4 _tiporec;
|
|||
|
TString16 _nome_simb;
|
|||
|
TString16 _dataultras;
|
|||
|
TString16 _sigle_file;
|
|||
|
TString _nrec_file;
|
|||
|
TString _ult_file;
|
|||
|
TString _key;
|
|||
|
TFilename _tmpcaus, _tmprcaus, _tmpclifo, _tmppcon, _tmpmov;
|
|||
|
TFilename _tmprmov, _tmprmoviva, _tmppart, _tmpscad, _tmppagsca;
|
|||
|
TString _recprec;
|
|||
|
|
|||
|
long _SCAnreg, _SCAnreg_p;
|
|||
|
int _SCAnumrig, _SCAnumrig_p, _SCAanno, _SCAanno_p, _annoSCA, _nrigaSCA, _nrataSCA, _SCAnriga_p;
|
|||
|
TString _SCAnumpart, _SCAnumpart_p;
|
|||
|
real _imp, _impval;
|
|||
|
bool _esiste_pagsca;
|
|||
|
char _scelta;
|
|||
|
|
|||
|
private:
|
|||
|
// Inizializza l'indice leggendo il record di controllo
|
|||
|
void fill_index(const TString&, const TString&);
|
|||
|
|
|||
|
// Funzioni utilizzate da fcopytemp() nella ricezione da Sistema
|
|||
|
void scrivi_header(const char* dest, const char* wflag);
|
|||
|
void scrivi_causali(long nrec);
|
|||
|
void scrivi_clifo(long nrec);
|
|||
|
void scrivi_pcon(long nrec);
|
|||
|
void scrivi_PN(long nrec);
|
|||
|
void scrivi_IVA(long nrec);
|
|||
|
void scrivi_SC(long nrec);
|
|||
|
|
|||
|
void write_tmp_tabelle(TString& record, bool create);
|
|||
|
int trasfer_data_tab(TIsamtempfile& file, TRectype& dep);
|
|||
|
void write_tmp_movPN(TString& record);
|
|||
|
int trasfer_data_mov(TIsamtempfile& file, TRectype& dep);
|
|||
|
void write_tmp_movIVA(const TString& record);
|
|||
|
int trasfer_data_moviva(TIsamtempfile& file, const TRectype& dep);
|
|||
|
// Funzioni per la ricezione del Saldaconto da Sistema
|
|||
|
void write_tmp_movSC(TString& record);
|
|||
|
void new_key(TString& key, int tipo, TString& buffer);
|
|||
|
void tipo_anagrafica(TString& record, TString& tipo);
|
|||
|
int ultima_riga_partita(TString& record);
|
|||
|
void partita(TString& record);
|
|||
|
void scadenza(TString& record);
|
|||
|
void pagsca(TString& record);
|
|||
|
void calcola_imposta(const TString& numreg, real& imposta);
|
|||
|
void calcola_impdocval(long nreg, int nrig, TString& record);
|
|||
|
bool solo_SC(TString& numreg);
|
|||
|
void calcola_importo(TString& record);
|
|||
|
int recupera_scadenze(TString& record, TString& tipo);
|
|||
|
char what_is_this(TString& record, TString& tipo);
|
|||
|
// void aggiorna_partita(TString& record,TString& tipo,real& importo,real& importoval,real& abbuoni,real& diffcam,real& ritenute,real& ritsoc);
|
|||
|
char leggi_sez_partita(TString& record, TString& tipo);
|
|||
|
///////////////////////////////////////////////////////////////////////
|
|||
|
|
|||
|
// Funzioni utilizzate nella ricezione da sistema e da PC
|
|||
|
char TipoConto(int gruppo, int conto);
|
|||
|
const char* numero_civico(TString& field);
|
|||
|
void leggi_record_controllo();
|
|||
|
int annoes_datacomp(const TString& record, TDate& datacomp);
|
|||
|
void decimali(TString& campo, int dec);
|
|||
|
void negativo(TString& importo);
|
|||
|
int strip_zero(TString& importo);
|
|||
|
bool my_isdigit(unsigned char ch);
|
|||
|
int look(unsigned char carattere);
|
|||
|
int cerca_annoes(long numreg, TString& tipodoc) const;
|
|||
|
void scrivi_occasionali(const TString& record, TString& cfpi);
|
|||
|
///////////////////////////////////////////////////////////////////////
|
|||
|
|
|||
|
// Funzioni utilizzate da fcopytemp_PC() nella ricezione da PC
|
|||
|
void write_testata_causali(TString& record);
|
|||
|
void write_righe_causali(TString& record);
|
|||
|
void write_clienti_fornitori(TString& record);
|
|||
|
void write_piano_conti(TString& record);
|
|||
|
void write_testata_movimenti(TString& record);
|
|||
|
void write_righe_contabili(const TString& record);
|
|||
|
void write_righe_IVA(TString& record);
|
|||
|
// Funzioni utilizzate per la ricezione Saldaconto da PC
|
|||
|
void write_partite(const TString& record);
|
|||
|
void write_scadenze(const TString& record);
|
|||
|
void write_pagsca(const TString& record);
|
|||
|
|
|||
|
int annoes_PC(const TString& data) const;
|
|||
|
void causale(const TString& cau, TString& tipo, TString& descr) const;
|
|||
|
int registro(const TString& reg, int anno) const;
|
|||
|
|
|||
|
public:
|
|||
|
|
|||
|
void remove_all(bool file_ditta = TRUE);
|
|||
|
void canc_file_dir_temp(const char* dir);
|
|||
|
void temp_dir(TString& orig, TString& dest, TString& sigle);
|
|||
|
|
|||
|
const char* cerca_comune_cap(const TString& field, const TString& localita);
|
|||
|
const char* cerca_cap_comune(const TString& localita);
|
|||
|
const char* cerca_comune_den(const TString& field);
|
|||
|
TDate data_fine_esercizio(int codes) const;
|
|||
|
|
|||
|
bool fcopytemp(const char* orig, const char* dest);
|
|||
|
bool ordina_trasfer(const char* orig);
|
|||
|
void ordina_file_da_elaborare(TString& buffer);
|
|||
|
long determina_dimensione(FILE* f);
|
|||
|
|
|||
|
bool fcopytemp_PC(const char* orig, const char* dest);
|
|||
|
|
|||
|
int dataes(const TDate&, int*, TDate&);
|
|||
|
|
|||
|
const char* path(long codditta = 0);
|
|||
|
bool open(const char* path, bool create = FALSE);
|
|||
|
void close();
|
|||
|
bool exist() const { return _trasfer != NULL; }
|
|||
|
|
|||
|
void setta_sistema(char scelta);
|
|||
|
|
|||
|
long get_pos(const char* key);
|
|||
|
|
|||
|
// Funzioni che agiscono sul record di controllo del file trasfer.
|
|||
|
|
|||
|
bool read_control_rec(); // Legge il record del file header
|
|||
|
bool read_control_rec_t(); // Legge il record di controllo del file trasfer
|
|||
|
bool write_control_rec(const char* str, const int size); // Scrive una stringa di lunghezza size
|
|||
|
|
|||
|
const char* tiporec() const { return _tiporec; } // Ritorna il tipo record
|
|||
|
const char* nome_simb() const { return _nome_simb; } // Ritorna il nome simbolico del sistema inviante
|
|||
|
long ditta() const { return _ditta; } // Ritorna la ditta inviante
|
|||
|
int nultras() const { return _nultras; } // Ritorna il numero ultimo trasferimento
|
|||
|
const char* dataultras() const { return _dataultras; } // Ritorna la data ultimo trasferimento
|
|||
|
const char* sigle_file() const { return _sigle_file; } // Ritorna una stringa contenente le sigle dei file da ricevere
|
|||
|
const char* nrec_file() const { return _nrec_file; } // Ritorna una stringa con il numero totale di record corrispondenti ad ogni sigla dei file da ricevere
|
|||
|
char flg_agg(char sigla) const; // Ritorna i flag tipo aggiornamento relativi alle tabelle
|
|||
|
bool numprot_att() const; // Ritorna il flag riattribuzione numero protocollo su fatture attive
|
|||
|
bool numprot_pas() const; // Ritorna il flag riattribuzione numero protocollo su fatture passive
|
|||
|
char flg_agg_IV(char sigla) const; // Ritorna il flag tipo aggiornamento classi piano dei conti
|
|||
|
const char* ult_file() const { return (const char*)_ult_file; } // Ritorna l'ultima sigla file elaborato
|
|||
|
const char* key() const { return (const char*)_key; } // Ritorna la chiave ultimo record elaborato
|
|||
|
const char* record() const; // Ritorna il record di controllo del trasfer
|
|||
|
|
|||
|
// Funzioni per il posizionamento e la gestione dei record del trasfer (escluso il record di controllo)
|
|||
|
|
|||
|
// Legge il record del trasfer specificato da numrec
|
|||
|
int read_rec_trasfer(long numrec, int size = 256);
|
|||
|
const char* read_rec() const { return (const char*)_record; } // Ritorna un record del trasfer
|
|||
|
|
|||
|
// Scrive una stringa di lunghezza size nel campo specificato da fieldnum
|
|||
|
void writeat(const char* str, int size, int fieldnum, const char* file);
|
|||
|
void writeat(const char* str, int size, int fieldnum,
|
|||
|
const char* file, const long numrec);
|
|||
|
|
|||
|
int write(long numrec, int size = SIZE);
|
|||
|
|
|||
|
// Permette di posizionarsi all'interno del record sul campo specificato
|
|||
|
// da fieldnum sfruttando la Mappa precaricata
|
|||
|
int go2field(int fieldnum, const char* file = NULL,
|
|||
|
const long nrec = -1L, bool seek = TRUE);
|
|||
|
void go2rec(const long numrec);
|
|||
|
void readat(long recnum); // Si posiziona all'inizio del record specificato da numrec sfruttando l'array indice
|
|||
|
|
|||
|
void put(const char* val, const char* file, int fieldnum, long recnum = -1L);
|
|||
|
|
|||
|
// Funzioni per la gestione dell'array indice
|
|||
|
int last_tab() const { return _last_tab; } // Ritorna la posizione dell'ultima sigla relativa alle tabelle presente nella schiera delle sigle file
|
|||
|
int last_mov() const { return _last_mov; } // Ritorna la posizione dell'ultima sigla relativa ai movimenti presente nella schiera delle sigle file
|
|||
|
|
|||
|
int num(char sigla);
|
|||
|
const char* name(int i); // Ritorna la sigla di quel file
|
|||
|
long nrec(int i); // Ritorna il numero di record di quel file
|
|||
|
int lenrec(int i); // Ritorna la lunghezza del record del trasfer corrispondente a quel file
|
|||
|
int lenrec(char sigla); // Ritorna la stessa cosa ma con la sigla invece del numero
|
|||
|
// long start(int i); // Inizio del file numero i
|
|||
|
long start(char sigla); // Inizio del file sigla
|
|||
|
long end(int i); // Ritorna la posizione in byte corrispondente alla fine di quel file all'interno del trasfer
|
|||
|
//long rec(int i);
|
|||
|
|
|||
|
long tot_rec() const { return _tot_rec; }
|
|||
|
|
|||
|
void annulla_classi(int g, int c, bool conto);
|
|||
|
|
|||
|
// Copia il file trasfer creando tre isam_temp_file per i mov. di prima nota
|
|||
|
|
|||
|
bool fcopytemp(const char*, const char*, bool);
|
|||
|
|
|||
|
TMappa_trc& mappa() { return _trc; }
|
|||
|
|
|||
|
TTransfer_file(char scelta = '\0');
|
|||
|
~TTransfer_file();
|
|||
|
};
|
|||
|
|
|||
|
#endif
|