Files correlati : ve*.exe mg *.exe Ricompilazione Demo : [ ] Commento : gestione giacenze per cliente/ fornitore git-svn-id: svn://10.65.10.50/trunk@17356 c028cbd2-c16b-5b4b-a496-9718f37d4682
		
			
				
	
	
		
			249 lines
		
	
	
		
			7.6 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			249 lines
		
	
	
		
			7.6 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
| #ifndef __CGLIB01_H
 | |
| #define __CGLIB01_H
 | |
| 
 | |
| #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
 | |
|   virtual int compare(const TSortable& s) const;
 | |
| 
 | |
| 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); }
 | |
| 	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 code2range(int codice, TDate& dal, TDate& al) const;
 | |
|   
 | |
|   TEsercizi_contabili();
 | |
|   virtual ~TEsercizi_contabili() {}
 | |
| };
 | |
| 
 | |
| TEsercizi_contabili & esercizi();
 | |
| 
 | |
| 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);
 | |
| 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 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'; }
 | |
|   
 | |
|   void set_prorata(int annodoc, const real& pro);
 | |
|   real prorata(int annodoc);
 | |
|   bool prorata100(int annodoc) { return prorata(annodoc) >= 100.0; }
 | |
|   
 | |
|   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() {}
 | |
| };
 | |
| 
 | |
| class TCodiceIVA : public TRectype
 | |
| {
 | |
|   void copy(const TRectype & iva) { TRectype::operator =(iva); }
 | |
| 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"); }
 | |
|   int detraibilita() const { return get_int("I1"); }
 | |
|   int allegato(char tipocf) const { return get_int(tipocf == 'F' ? "S8" : "S7"); }
 | |
|   
 | |
|   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
 | |
| 
 | |
|   TCodiceIVA(const char* codice = NULL);                        
 | |
|   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, 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 = 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)  
 | |
|     : _descrizione(NULL), _sezione(' '), _sospeso(FALSE)
 | |
|   { get(tgcsd, from, mode); }
 | |
|   
 | |
|   TBill(const TRectype& rec, bool contro = FALSE) 
 | |
|     : _descrizione(NULL), _sezione(' '), _sospeso(FALSE)
 | |
|   { 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 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 };
 | |
| 
 | |
| #endif
 |