ve0100.h Aggiunto metodo mask2ini ve0100c.cpp Corretto #include errato di cgpagame.h velib.h Reso pubblico il metodo TTipo_riga_documento::read velib02.cpp Sostituito "TIPORIGA" con RDOC_TIPORIGA git-svn-id: svn://10.65.10.50/trunk@5866 c028cbd2-c16b-5b4b-a496-9718f37d4682
		
			
				
	
	
		
			1098 lines
		
	
	
		
			42 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			1098 lines
		
	
	
		
			42 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
#ifndef __VELIB_H 
 | 
						|
#define __VELIB_H
 | 
						|
 | 
						|
#ifndef __RELATION_H
 | 
						|
#include <relation.h>
 | 
						|
#endif
 | 
						|
 | 
						|
#ifndef __RECARRAY_H
 | 
						|
#include <recarray.h>
 | 
						|
#endif
 | 
						|
 | 
						|
#ifndef __VARREC_H
 | 
						|
#include <varrec.h>
 | 
						|
#endif
 | 
						|
 | 
						|
#ifndef __VARMASK_H
 | 
						|
#include <varmask.h>
 | 
						|
#endif
 | 
						|
 | 
						|
#ifndef __MULTIREC_H
 | 
						|
#include <multirec.h>
 | 
						|
#endif
 | 
						|
 | 
						|
#ifndef __CLIFOR_H
 | 
						|
#include "clifor.h"
 | 
						|
#endif
 | 
						|
                    
 | 
						|
#ifndef __CGPAGAME_H
 | 
						|
#include "../cg/cgpagame.h"
 | 
						|
#endif
 | 
						|
 | 
						|
#ifndef __PRLIB_H
 | 
						|
#include "../pr/prlib.h"
 | 
						|
#endif
 | 
						|
 | 
						|
#ifndef __DOC_H
 | 
						|
#include <doc.h>
 | 
						|
#endif
 | 
						|
 | 
						|
#ifndef __RDOC_H
 | 
						|
#include <rdoc.h>
 | 
						|
#endif
 | 
						|
                    
 | 
						|
#define RIGA_MERCE 'M'
 | 
						|
#define RIGA_SPESEDOC 'S'
 | 
						|
#define RIGA_PRESTAZIONI 'P'
 | 
						|
#define RIGA_SCONTI 'C'
 | 
						|
#define RIGA_OMAGGI 'O'
 | 
						|
#define RIGA_DESCRIZIONI 'D'
 | 
						|
 | 
						|
#define MAX_TIPI_DOC 10
 | 
						|
 | 
						|
#define NO_DECIMALS 0
 | 
						|
#define STD_DECIMALS 3
 | 
						|
#define ALL_DECIMALS 883
 | 
						|
#define AUTO_DECIMALS -883
 | 
						|
 | 
						|
class TDocumento;
 | 
						|
class TRiga_documento;
 | 
						|
class TCond_vendita;
 | 
						|
class TIVA;
 | 
						|
 | 
						|
 | 
						|
bool scontoexpr2perc(const char * exp, bool signal , TString & goodexp, real & val_perc );
 | 
						|
// velib01
 | 
						|
real lordo2netto(real& lordo, const TString& codiva, int ndec);
 | 
						|
inline real lordo2netto(real& lordo, const TString& codiva, bool is_valuta = FALSE) { return lordo2netto(lordo, codiva, is_valuta ? 3 : 0);}
 | 
						|
real netto2lordo(const real& netto, const TString& codiva, int ndec);
 | 
						|
inline real netto2lordo(const real& netto, const TString& codiva, bool is_valuta = FALSE) { return netto2lordo(netto, codiva, is_valuta ? 3 : 0);}
 | 
						|
real lordo2netto(real& lordo, const real& iva, int ndec);
 | 
						|
inline real lordo2netto(real& lordo, const real& iva, bool is_valuta = FALSE) {return lordo2netto(lordo, iva, is_valuta ? 3 : 0); }
 | 
						|
real netto2lordo(const real& netto, const real& iva, int ndec);
 | 
						|
inline real netto2lordo(const real& netto, const real& iva, bool is_valuta = FALSE) { return netto2lordo(netto, iva, is_valuta ? 3 : 0); }
 | 
						|
real prezzo_scontato(const real& prezzo, const char * sconto);
 | 
						|
real iva(real imponibile, const TIVA & codiva,int ndec);   
 | 
						|
 | 
						|
bool ora_hndl(TMask_field& field, KEY key);
 | 
						|
bool codcli_hndl(TMask_field& field, KEY key);
 | 
						|
bool dummy_hndl(TMask_field& field, KEY key);
 | 
						|
bool condpag_hndl(TMask_field& field, KEY key);
 | 
						|
bool note_hndl(TMask_field& field, KEY key);
 | 
						|
bool data_hndl(TMask_field& field, KEY key);
 | 
						|
void set_curr_um(const TMask & m);
 | 
						|
 | 
						|
 | 
						|
class TDocumento_variable_field : public TVariable_field
 | 
						|
{                                           
 | 
						|
  bool _dirty;
 | 
						|
 | 
						|
  public:
 | 
						|
  TObject* dup() const { return new TDocumento_variable_field(*this); }
 | 
						|
// @cmember segnala che il campo deve essere ricalcolato
 | 
						|
  virtual bool dirty() const { return _dirty;}
 | 
						|
// @cmember assegna lo stato di campo da ricalcolare
 | 
						|
  virtual void set_dirty(bool on = TRUE) { _dirty = on;}
 | 
						|
 | 
						|
// @ cmember Costruttore con una espressione di calcolo  
 | 
						|
  TDocumento_variable_field(const char * name, const char * expr = "", TTypeexp type = _strexpr)
 | 
						|
                          : TVariable_field(name, expr, type), _dirty(TRUE) {}
 | 
						|
// @ cmember Costruttore con una funzione
 | 
						|
  TDocumento_variable_field(const char * name, VIRTUAL_GET_FUNCTION getfunc)
 | 
						|
                          : TVariable_field(name, getfunc), _dirty(TRUE) {}
 | 
						|
// @ cmember Costruttore con una espressione di calcolo  
 | 
						|
  TDocumento_variable_field(const char * name, TExpression & expr, TTypeexp type = _strexpr)
 | 
						|
                          : TVariable_field(name, expr, type), _dirty(TRUE) {}
 | 
						|
// @ cmember Costruttore con un variable_field 
 | 
						|
  TDocumento_variable_field(const TVariable_field & f) : TVariable_field(f), _dirty(TRUE) {}
 | 
						|
// @ cmember Distruttore  
 | 
						|
  ~TDocumento_variable_field() {}
 | 
						|
};
 | 
						|
            
 | 
						|
class TSpesa_prest : public TRectype  // velib01
 | 
						|
{                    
 | 
						|
 | 
						|
protected:
 | 
						|
  int read(const char* codice);
 | 
						|
 | 
						|
public:
 | 
						|
  TObject* dup() const { return new TSpesa_prest(codice()); }
 | 
						|
 | 
						|
public:       
 | 
						|
  const TString& codice() const { return get("CODTAB");}  
 | 
						|
  const TString& descrizione() const { return get("S0"); } 
 | 
						|
  const TString& field_perc() const { return get("S5"); }  
 | 
						|
  const TString & um() const { return get("S7"); }
 | 
						|
  const TString& cod_iva() const { return get("S3"); }
 | 
						|
  real prezzo() const { return get_real("R0"); }
 | 
						|
  real qta() const { return get_real("R1"); }
 | 
						|
  char tipo() const { return get_char("S6"); }
 | 
						|
  const TString & tipo_riga() const { return get("S8"); }
 | 
						|
  char genere() const { return get("COD") == "SPP" ? 'S' : 'P'; }
 | 
						|
 | 
						|
  TSpesa_prest(const char* codice = NULL, char tipo = 'S');
 | 
						|
  TSpesa_prest(const TRectype& rec);
 | 
						|
  virtual ~TSpesa_prest() {}
 | 
						|
};
 | 
						|
 | 
						|
class TIVA : public TRectype  // velib01
 | 
						|
{                    
 | 
						|
 | 
						|
protected:
 | 
						|
  int read(const char* codice);
 | 
						|
 | 
						|
public:
 | 
						|
  TObject* dup() const { return new TIVA(codice()); }
 | 
						|
 | 
						|
public:       
 | 
						|
  const TString& codice() const { return get("CODTAB");}  
 | 
						|
  const TString& descrizione() const { return get("S0"); } 
 | 
						|
  const real aliquota() const { return get_real("R0"); } 
 | 
						|
  const TString& tipo() const { return get("S1"); } 
 | 
						|
 | 
						|
  TIVA(const char* codice = NULL);
 | 
						|
  TIVA(const TRectype& rec);
 | 
						|
  virtual ~TIVA() {}
 | 
						|
};
 | 
						|
 | 
						|
class TExpr_documento : public TExpression  // velib01
 | 
						|
{     
 | 
						|
  TDocumento * _doc; 
 | 
						|
  TRiga_documento * _row;
 | 
						|
  
 | 
						|
protected:                       
 | 
						|
  virtual void evaluate_user_func(int index, int nparms, TEval_stack & stack, TTypeexp type) const;
 | 
						|
  virtual int parse_user_func(const char * name, int nparms) const;
 | 
						|
 | 
						|
public:            
 | 
						|
 // @cmember Duplica l'espressione
 | 
						|
  virtual TObject* dup() const;
 | 
						|
  // @cmember Assegna il documento corrente
 | 
						|
  void set_doc(TDocumento * doc) { _doc = doc; }
 | 
						|
  // @cmember Assegna il documento corrente
 | 
						|
  void set_row(TRiga_documento * row) { _row = row; }
 | 
						|
  // @cmember Costruttore (assegna l'estressione e il suo tipo)
 | 
						|
  TExpr_documento(const char* expression, TTypeexp type = _numexpr,
 | 
						|
                  TDocumento * doc = NULL, TRiga_documento * row = NULL);
 | 
						|
  // @cmember Costruttore (assegna il tipo dell'istruzione) 
 | 
						|
  TExpr_documento(TTypeexp type = _numexpr,
 | 
						|
                  TDocumento * doc = NULL, TRiga_documento * row = NULL)
 | 
						|
                 : TExpression(type), _doc(doc), _row(row) {}
 | 
						|
  // @cmember Costruttore di copia
 | 
						|
  TExpr_documento(const TExpr_documento & expr)
 | 
						|
                 : TExpression(expr), _doc(expr._doc), _row(expr._row) {}
 | 
						|
  // @cmember Distruttore
 | 
						|
  virtual ~TExpr_documento() {}
 | 
						|
};
 | 
						|
 | 
						|
enum TTipo_formula { _documento, _riga };
 | 
						|
 | 
						|
class TFormula_documento : public TRectype  // velib01
 | 
						|
{               
 | 
						|
  TString16       _tab;
 | 
						|
  TExpr_documento * _expr;
 | 
						|
  
 | 
						|
protected:
 | 
						|
  int read(const char* codice, const char* expr = NULL, bool numexpr = TRUE);
 | 
						|
 | 
						|
public:
 | 
						|
  TObject* dup() const { return new TFormula_documento(_tab == "%FRD" ? _documento : _riga, codice(), NULL, TRUE); }
 | 
						|
 | 
						|
public:       
 | 
						|
  const TString& codice() const { return get("CODTAB");}  
 | 
						|
  const TString& name() const { return codice();}
 | 
						|
  TExpr_documento * expr() const { return _expr ? new TExpr_documento(*_expr) : NULL;}
 | 
						|
  
 | 
						|
  const TString& descrizione() const { return get("S0"); } 
 | 
						|
  const TString& expr_string() const { return get("S1"); }
 | 
						|
  TTypeexp expr_type() const { return get_bool("B0") ? _numexpr : _strexpr;}
 | 
						|
  
 | 
						|
  TFormula_documento(TTipo_formula tipo = _documento, const char* codice = NULL, const char* expr = NULL, bool numexpr = TRUE);
 | 
						|
  TFormula_documento(const TRectype& rec);
 | 
						|
  virtual ~TFormula_documento();
 | 
						|
};
 | 
						|
 | 
						|
class TTipo_documento : public TRectype  // velib03
 | 
						|
{              
 | 
						|
  enum { _altro, _bolla, _fattura, _ordine};
 | 
						|
  
 | 
						|
  static TAssoc_array _formule_documento;
 | 
						|
  TToken_string _formule;
 | 
						|
  TString16 _imponibile;
 | 
						|
  TString16 _imposta;
 | 
						|
  TString16 _totale;
 | 
						|
  TString16 _totale_netto;
 | 
						|
  TString16 _basesconto; 
 | 
						|
  TString16 _spese;
 | 
						|
  TString16 _totprovv;
 | 
						|
        
 | 
						|
protected:     
 | 
						|
  void read_formule();
 | 
						|
  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"); } 
 | 
						|
  int tipo() const { return get_int("I1"); }
 | 
						|
  const TString& codice() const { return get("CODTAB");}  
 | 
						|
  
 | 
						|
  bool is_generic() const { return tipo() == _altro; }
 | 
						|
  bool is_fattura() const { return tipo() == _fattura; }
 | 
						|
  bool is_bolla() const { return tipo() == _bolla; }
 | 
						|
  bool is_ordine() const { return tipo() == _ordine; }
 | 
						|
  
 | 
						|
  const TString & descrizione() const { return get("S0"); } 
 | 
						|
  const TString & riferimento() const { return get("S1"); }
 | 
						|
  const TString & imponibile() const { return _imponibile;}  
 | 
						|
  const TString & imposta() const { return _imposta;}  
 | 
						|
  const TString & totale_doc() const { return _totale;}  
 | 
						|
  const TString & totale_netto() const { return _totale_netto; }
 | 
						|
  const TString & basesconto() const { return _basesconto;}  
 | 
						|
  const TString & spese() const { return _spese;}  
 | 
						|
  const TString & totprovv() const { return _totprovv;}  
 | 
						|
  bool mov_mag() const { return get_bool("B1"); }
 | 
						|
  bool statistiche() const { return get_bool("B2"); }
 | 
						|
  bool provvigioni() const { return get_bool("B3"); }
 | 
						|
  const char stato_mov_iniziale() const {return get_char("S7"); }
 | 
						|
  const char stato_mov_finale() const {return get_char("S8"); }
 | 
						|
  const char stato_provvigioni() const {return get_char("S3"); }
 | 
						|
  const TString & caus_mov() const {return get("S9"); } 
 | 
						|
  const char stato_finale_inserimento() const {return get("S2")[0]; } 
 | 
						|
  const char stato_finale_stampa() const {return get("S2")[1]; } 
 | 
						|
  const TString & stati_iniziali_modifica() const {return get("S2").mid(9,20); } 
 | 
						|
  const TString & stati_iniziali_cancellazione() const {return get("S2").mid(29,20); } 
 | 
						|
  const TString & stati_iniziali_stampa() const {return get("S2").mid(49,20); } 
 | 
						|
  bool stato_with_mov_mag(const char stato) const;
 | 
						|
  
 | 
						|
  TFormula_documento * first_formula() { return succ_formula(TRUE); }
 | 
						|
  TFormula_documento * succ_formula(bool restart = FALSE);
 | 
						|
 | 
						|
  const int ncopie() const { return get_int("I0"); }
 | 
						|
  bool spese_aut() const { return get_bool("B0"); }
 | 
						|
  
 | 
						|
  TTipo_documento(const char* tipodoc = NULL);
 | 
						|
  TTipo_documento(const TRectype& rec);
 | 
						|
  virtual ~TTipo_documento();
 | 
						|
};
 | 
						|
          
 | 
						|
class TCodice_numerazione : public TRectype
 | 
						|
{
 | 
						|
  int _status;
 | 
						|
 | 
						|
public:
 | 
						|
  TObject* dup() const { return new TCodice_numerazione(codice()); }
 | 
						|
 | 
						|
public:
 | 
						|
  int read(const char * cod);
 | 
						|
  const TString& codice() const { return get("CODTAB"); }
 | 
						|
  const TString& descrizione() const { return get("S0"); }
 | 
						|
  const TString& prefisso() const { return get("S6"); }
 | 
						|
  const TString& postfisso() const { return get("S7"); }
 | 
						|
  const bool num_provv() const { return get_bool("B0"); }
 | 
						|
  const bool auto_num() const { return get_bool("B1"); }
 | 
						|
  const TString & tipo_doc(int i) const { CHECK(i < MAX_TIPI_DOC, "Impossibbile tipo documento"); return ((TString& ) get("S2").mid(i << 2, 4)).trim();}
 | 
						|
  int ntipi_doc() const {const int l = get("S2").len(); return l ? (((l - 1) >> 2) + 1) : 0;}
 | 
						|
  
 | 
						|
  const char * complete_num (long num);
 | 
						|
  int status() { return _status; }
 | 
						|
  TCodice_numerazione(const char* codnum = NULL);
 | 
						|
  TCodice_numerazione(const TRectype& rec);
 | 
						|
  virtual ~TCodice_numerazione();
 | 
						|
};
 | 
						|
 | 
						|
class TTipo_riga_documento : public TRectype  // velib02
 | 
						|
{                    
 | 
						|
 | 
						|
  static TAssoc_array _formule_riga;
 | 
						|
  TToken_string _formule;
 | 
						|
  TString16 _name;
 | 
						|
  TString16 _imponibile;
 | 
						|
  TString16 _provv;
 | 
						|
  TVariable_mask * _mask;
 | 
						|
 | 
						|
protected:
 | 
						|
  void read_formule();
 | 
						|
 | 
						|
public:
 | 
						|
  TObject* dup() const { return new TTipo_riga_documento(codice()); }
 | 
						|
 | 
						|
public:       
 | 
						|
  const TString& profile_name() const { return _name;}
 | 
						|
  const TString& mask_name() const { return profile_name();}
 | 
						|
  const TString& codice() const { return get("CODTAB");}  
 | 
						|
  bool mask_loaded() const { return _mask != NULL; }
 | 
						|
  TVariable_mask* mask(); 
 | 
						|
    
 | 
						|
  const TString& descrizione() const { return get("S0"); } 
 | 
						|
  char tipo() const { return get_char("S7"); }
 | 
						|
  const TString& imponibile() const { return _imponibile;}  
 | 
						|
  const TString& provv() const { return _provv;}  
 | 
						|
 | 
						|
  TFormula_documento* first_formula() { return succ_formula(TRUE); }
 | 
						|
  TFormula_documento* succ_formula(bool restart = FALSE);
 | 
						|
  
 | 
						|
  int read(const char* tiporig);
 | 
						|
  TTipo_riga_documento(const char* tiporig = NULL);
 | 
						|
  TTipo_riga_documento(const TRectype& rec);
 | 
						|
  virtual ~TTipo_riga_documento();
 | 
						|
};
 | 
						|
 | 
						|
 | 
						|
class TRiga_documento : public TAuto_variable_rectype  // velib02
 | 
						|
{
 | 
						|
  TDocumento * _doc; 
 | 
						|
  static long _firm;
 | 
						|
  static TAssoc_array _tipi;
 | 
						|
  static TAssoc_array _spese;
 | 
						|
  static TAssoc_array _ive;  
 | 
						|
  bool _iva_calc;
 | 
						|
 | 
						|
protected:  
 | 
						|
   // @cmember Setta il contenuto del campo <p fieldname> (non tipizzata)
 | 
						|
  virtual void put_str(const char* fieldname, const char* val);
 | 
						|
 | 
						|
  virtual TRiga_documento & copy(const TRiga_documento & r);
 | 
						|
  TObject* dup() const { return new TRiga_documento(*this); }
 | 
						|
  
 | 
						|
  static void test_firm();
 | 
						|
  
 | 
						|
public:  
 | 
						|
  void dirty_fields(bool   dirty_document = TRUE); 
 | 
						|
  bool doc_dependent() const;
 | 
						|
  int numero() const { return get_int(RDOC_NRIGA); }
 | 
						|
  void set_numero(int numero) { put(RDOC_NRIGA, numero);}
 | 
						|
  bool is_generata() const { return get_bool(RDOC_GENERATA);}
 | 
						|
  void generata(bool on = TRUE) { put(RDOC_GENERATA, on);}
 | 
						|
  bool is_merce() const { return tipo().tipo() == 'M';}
 | 
						|
  bool is_spese() const { return tipo().tipo() == 'S';}
 | 
						|
  bool is_prestazione() const { return tipo().tipo() == 'P';}
 | 
						|
  bool is_sconto() const {return tipo().tipo() == 'C';}
 | 
						|
  bool is_sconto_perc() const { return get(RDOC_SCONTO).not_empty();}
 | 
						|
  bool is_omaggio() const { return tipo().tipo() == 'O';}
 | 
						|
  bool is_descrizione() const { return tipo().tipo() == 'D';}
 | 
						|
  bool is_articolo() const; 
 | 
						|
  bool is_checked() const { return get_bool(RDOC_CHECKED);}
 | 
						|
  void checked(bool on = TRUE) { put(RDOC_CHECKED, (bool)on); }
 | 
						|
  void unchecked() { checked(FALSE); }
 | 
						|
  // @cmember Assegna il documento corrente
 | 
						|
  void set_doc(TDocumento * doc) { _doc = doc; }
 | 
						|
  const TDocumento & doc() const { CHECK(_doc, "Documento nullo"); return *_doc;}
 | 
						|
 | 
						|
  virtual void zero(const char * fieldname);
 | 
						|
  virtual void zero(char c = '\0');
 | 
						|
  // row -> sheet
 | 
						|
  void autoload( TSheet_field& f);
 | 
						|
  // sheet -> row
 | 
						|
  void autosave( TSheet_field& f);
 | 
						|
 | 
						|
  const TTipo_riga_documento & tipo() const;
 | 
						|
  const TSpesa_prest & spesa() const;
 | 
						|
  static const TIVA & iva(const char * codice);
 | 
						|
  const TIVA & iva() const {const TString16 cod(get(RDOC_CODIVA)); return iva(cod);}
 | 
						|
  
 | 
						|
  const bool tipo_valido() const { return get(RDOC_TIPORIGA).not_empty(); }
 | 
						|
  void set_tipo(const char * tipo) { put(RDOC_TIPORIGA, tipo);}
 | 
						|
  bool sola_descrizione() const;
 | 
						|
  void forza_sola_descrizione();
 | 
						|
  
 | 
						|
  virtual TRiga_documento & operator =(const TRiga_documento & r) { return copy(r);}
 | 
						|
  virtual TRectype & operator =(const TRectype & r); 
 | 
						|
  virtual TRectype & operator =(const char * r); 
 | 
						|
  
 | 
						|
  bool raggruppabile(const TRiga_documento& r, TToken_string& campi) const;
 | 
						|
  TRiga_documento& operator +=(const TRiga_documento& r);
 | 
						|
  
 | 
						|
  void reset_fields(TAuto_variable_rectype& rec) { rec.remove_field(); }
 | 
						|
  void set_fields(TAuto_variable_rectype& rec);
 | 
						|
 | 
						|
  real prezzo(bool scontato, bool lordo, int ndec = AUTO_DECIMALS) const ;
 | 
						|
  real importo(bool scontato , bool lordo, int ndec = AUTO_DECIMALS) const ;   
 | 
						|
  real sconto() const { return importo(FALSE,FALSE) - importo(TRUE,FALSE); }
 | 
						|
  real iva(int ndec) const;
 | 
						|
  real imponibile() const; 
 | 
						|
  real imposta(bool round = TRUE) const;
 | 
						|
  real provvigione(int ndec = AUTO_DECIMALS) const;
 | 
						|
  
 | 
						|
  real quantita() const { return get_real(RDOC_QTA); }
 | 
						|
 | 
						|
  
 | 
						|
  TRiga_documento(TDocumento* doc, const char* tipo = NULL);
 | 
						|
  TRiga_documento(const TRiga_documento & row);
 | 
						|
  TRiga_documento(const TRiga_documento& rec, TDocumento* doc,
 | 
						|
                  const char* tipo = NULL);
 | 
						|
  virtual ~TRiga_documento() {}
 | 
						|
};
 | 
						|
 | 
						|
enum TTipo_importo { _lordo, _netto, _imposta };
 | 
						|
 | 
						|
class TRiepilogo_iva : public TObject
 | 
						|
{ 
 | 
						|
  TIVA _codiva;
 | 
						|
  real _imp;
 | 
						|
  real _imp_spese;
 | 
						|
  real _iva;
 | 
						|
  real _iva_spese;
 | 
						|
  real _sconto_perc;
 | 
						|
  real _sconto_imp;
 | 
						|
  real _iva_sconto;
 | 
						|
  byte _tipo;
 | 
						|
  
 | 
						|
protected:
 | 
						|
  virtual TObject* dup() const { return new TRiepilogo_iva(*this); }
 | 
						|
  virtual TRiepilogo_iva & copy(const TRiepilogo_iva & a); 
 | 
						|
  
 | 
						|
public:
 | 
						|
  real imponibile(bool spese = TRUE) const { return _imp + (spese ? _imp_spese : ZERO);} // Imponibile
 | 
						|
  real imposta(bool spese = TRUE) const { return _iva + (spese ? _iva_spese : ZERO);} // Iva
 | 
						|
  real & imp() { return _imp;};
 | 
						|
  real & imp_spese() { return _imp_spese;};
 | 
						|
  real & iva() { return _iva;};
 | 
						|
  real & iva_spese() { return _iva_spese;};
 | 
						|
  real & iva_sconto() { return _iva_sconto;};
 | 
						|
  real & sconto_perc() { return _sconto_perc; }
 | 
						|
  real & sconto_imp () { return _sconto_imp; }
 | 
						|
  const TIVA & cod_iva() const { return _codiva;}
 | 
						|
  byte tipo(){ return _tipo;}// Tipo (Vedi opzioni per la selzione di filtro nella validate())
 | 
						|
  TRiepilogo_iva& operator = (const TRiepilogo_iva & a) {return copy(a);}
 | 
						|
  TRiepilogo_iva(const TIVA & codiva); 
 | 
						|
  TRiepilogo_iva(const TRiepilogo_iva & a) {copy(a);} 
 | 
						|
  TRiepilogo_iva() : _tipo(0) {} 
 | 
						|
  ~TRiepilogo_iva() {};
 | 
						|
};
 | 
						|
             
 | 
						|
class TAgente ;
 | 
						|
 | 
						|
class TDocumento : public TMultiple_rectype  // velib03
 | 
						|
{               
 | 
						|
  TRecfield *_tipocf;
 | 
						|
  TRecfield *_codcf; 
 | 
						|
  TRecfield *_cod_occas; 
 | 
						|
  static TAssoc_array _tipi; 
 | 
						|
  static TAssoc_array _numerazioni;  
 | 
						|
  static long _firm;
 | 
						|
  static TString16 _codiva_spese;
 | 
						|
  static TString16 _codiva_bolli;
 | 
						|
  char _stato_originale;
 | 
						|
  static bool _has_mag;
 | 
						|
  static bool _has_stat_ven;
 | 
						|
  static bool _has_provv;
 | 
						|
  int _liv_len[4];
 | 
						|
 | 
						|
  TCond_vendita * _condv;
 | 
						|
  TCli_for _cli_for;
 | 
						|
  TProvvigioni_agente* _provv_agente;
 | 
						|
  TOccasionale _occas;
 | 
						|
  TPagamento _pag;  
 | 
						|
  TRiga_documento * _sconto; // Riga per lo sconto di testata
 | 
						|
  TRiga_documento * _esenzione; // Riga per l' esenzione iva
 | 
						|
  TAssoc_array _tabella_iva; // tabella di imponibili ed imposte
 | 
						|
 | 
						|
protected:  
 | 
						|
  virtual TRectype * new_body_record(int logicnum = 0) { return new TRiga_documento(this); }
 | 
						|
 | 
						|
  TRiga_documento & row(int index);
 | 
						|
  long get_next_key(char provv, int anno, const char* codnum) const;
 | 
						|
  virtual void put_str(const char* fieldname, const char* val);
 | 
						|
  long renum_ndoc(long numdoc = 0);  
 | 
						|
  virtual bool key_complete() { return numero() > 0; }
 | 
						|
  virtual bool renum() { return renum_ndoc() > 0;}
 | 
						|
  void set_riga_sconto();
 | 
						|
  void set_riga_esenzione();
 | 
						|
  int write_rewrite(TBaseisamfile & f, bool re) const;
 | 
						|
  virtual TDocumento & copy(const TDocumento & d); 
 | 
						|
  TObject* dup() const { return new TDocumento(*this); }
 | 
						|
  void update_tabella_iva();
 | 
						|
  void dirty_tabella_iva() { _tabella_iva.destroy();}
 | 
						|
  static void test_firm();
 | 
						|
  inline const TString16 & codiva_spese() const ;
 | 
						|
  inline const TString16 & codiva_bolli() const ;
 | 
						|
  void check_modules();
 | 
						|
 | 
						|
public:
 | 
						|
  void dirty_fields();
 | 
						|
 | 
						|
  TAssoc_array & tabella_iva() { update_tabella_iva(); return _tabella_iva; }
 | 
						|
  TCond_vendita & condv() const {CHECK(_condv, "Condizioni di vendita nulle"); return *_condv;}
 | 
						|
  TCli_for & clifor() const;
 | 
						|
  TOccasionale & occas() const;                       
 | 
						|
  const TAgente & agente() const;
 | 
						|
  void set_condv(TCond_vendita * condv) { _condv = condv; }
 | 
						|
    
 | 
						|
  virtual TDocumento & operator =(const TDocumento & d) {return copy(d);}
 | 
						|
  virtual TRectype & operator =(const TRectype & r); 
 | 
						|
  virtual TRectype & operator =(const char * r); 
 | 
						|
  virtual void zero(const char * fieldname);
 | 
						|
  virtual void zero(char c = '\0') { TMultiple_rectype::zero(c); }
 | 
						|
  
 | 
						|
  int physical_rows() const { return  body().rows(); } 
 | 
						|
  int rows() const { return physical_rows() + ((_sconto != NULL) ? 1 : 0) + ((_esenzione != NULL) ? 1 : 0); } 
 | 
						|
  const TRiga_documento& operator[](int index) const { return (const TRiga_documento&)((TDocumento *)this)->row(index); }
 | 
						|
  TRiga_documento& operator[](int index) { return (TRiga_documento&)row(index); } 
 | 
						|
  
 | 
						|
  TRiga_documento& insert_row(int row, const char *tipo = NULL);
 | 
						|
  TRiga_documento& new_row(const char *tipo = NULL);
 | 
						|
  virtual int read(TBaseisamfile& f, word op = _isequal, word lockop = _nolock);
 | 
						|
  virtual int write(TBaseisamfile& f) const { return write_rewrite(f, FALSE); }
 | 
						|
  virtual int rewrite(TBaseisamfile& f) const { return write_rewrite(f, TRUE); }
 | 
						|
  virtual int remove(TBaseisamfile& f) const;         
 | 
						|
 | 
						|
  int read(char provv, int anno, const char* codnum, long numdoc, word op = _isequal, word lockop = _nolock);
 | 
						|
  int read(const TRectype& rec, word op = _isequal, word lockop = _nolock) { *this = rec; return read(op, lockop); }
 | 
						|
  int read(word op = _isequal, word lockop = _nolock) { TLocalisamfile f(LF_DOC); return read(f, op, lockop);}
 | 
						|
  
 | 
						|
  int write(bool re = FALSE) const { TLocalisamfile f(LF_DOC); return write_rewrite(f, re);}
 | 
						|
  int rewrite() const { return write(TRUE); }
 | 
						|
  int remove() const { TLocalisamfile f(LF_DOC); return remove(f);}
 | 
						|
  
 | 
						|
  TProvvigioni_agente& calc_provvigioni(const bool generata = TRUE);
 | 
						|
  int write_provvigioni() { return calc_provvigioni().write();}
 | 
						|
 | 
						|
  char tipo_numerazione() const { return get_char("PROVV"); }
 | 
						|
  int anno() const { return get_int("ANNO"); }
 | 
						|
  const TString& numerazione() const { return get("CODNUM"); }
 | 
						|
  long numero() const { return get_long("NDOC"); }
 | 
						|
  TDate data() const { return get_date("DATADOC"); }
 | 
						|
  bool in_valuta() const;
 | 
						|
  const TString& valuta() const { return get("CODVAL"); }
 | 
						|
  real cambio() const { return get_real("CAMBIO"); }    
 | 
						|
  bool tipo_valido() const { return get("TIPODOC").not_empty(); }
 | 
						|
  static const TTipo_documento& tipo(const char * tipodoc);                  
 | 
						|
  const TTipo_documento& tipo() const;                  
 | 
						|
  const TCodice_numerazione& codice_numerazione() const;
 | 
						|
  void set_tipo(const char * tipo) { head().put("TIPODOC", tipo);}
 | 
						|
  void set_liv_giac_len(int liv, int len) { _liv_len[liv - 1] = len;}
 | 
						|
  int liv_giac_len(int liv) const { return _liv_len[liv - 1];}
 | 
						|
  bool provvisorio() const { return get_char("PROVV") == 'P'; }
 | 
						|
  char stato() const { return get_char("STATO"); }
 | 
						|
  void stato(char s) { put("STATO", s); }
 | 
						|
  bool modificabile() const;
 | 
						|
  bool cancellabile() const;
 | 
						|
  bool stampabile() const;
 | 
						|
  
 | 
						|
  bool raggruppabile() const { return get_bool("RAGGR"); }
 | 
						|
  bool raggruppabile(const TDocumento& doc, TToken_string& campi) const;
 | 
						|
  
 | 
						|
  char tipocf() const {return *(const char *) (*_tipocf);}
 | 
						|
  long codcf() const {return (long) *_codcf;}
 | 
						|
  const char * cod_occas() const { return (const char *) *_cod_occas; }
 | 
						|
  static void set_key(TRectype& rec, char provv, int anno, const char* codnum, long numdoc);
 | 
						|
  static void copy_data(TRectype& dst, const TRectype& src);
 | 
						|
  void copy_contents(const TDocumento & src);
 | 
						|
  
 | 
						|
  void set_fields(TAuto_variable_rectype & rec);
 | 
						|
 | 
						|
  real spese_incasso(real & imp, int ndec, TTipo_importo netto = _lordo) const ;
 | 
						|
  real bolli(real & imp, int ndec, TTipo_importo netto = _lordo) const ;
 | 
						|
 | 
						|
  real imponibile(bool spese = FALSE, int ndec = AUTO_DECIMALS) const;
 | 
						|
  real imposta(bool spese = FALSE, int ndec = AUTO_DECIMALS) const;
 | 
						|
  real totale_doc() const;
 | 
						|
  real totale_netto() const;
 | 
						|
  real basesconto() const;
 | 
						|
  real spese() const;
 | 
						|
  real provvigione(int ndec = AUTO_DECIMALS) const;
 | 
						|
  
 | 
						|
  TPagamento & pagamento();
 | 
						|
  
 | 
						|
  void update_spese_aut(TString_array & spese, bool preserve_old = FALSE, TSheet_field * sh = NULL);
 | 
						|
  
 | 
						|
  bool is_generic() const { return tipo_valido() && tipo().is_generic(); }
 | 
						|
  bool is_fattura() const { return tipo_valido() && tipo().is_fattura(); }
 | 
						|
  bool is_bolla() const { return tipo_valido() && tipo().is_bolla(); }
 | 
						|
  bool is_ordine() const { return tipo_valido() && tipo().is_ordine(); }
 | 
						|
  
 | 
						|
  TDocumento ();
 | 
						|
  TDocumento (const TDocumento & d);
 | 
						|
  TDocumento(char provv, int anno, const char* codnum, long numdoc, 
 | 
						|
             TCond_vendita * condv = NULL);
 | 
						|
  TDocumento(const TRectype& doc, TCond_vendita * condv = NULL);
 | 
						|
  virtual ~TDocumento();
 | 
						|
 };
 | 
						|
 | 
						|
class TDocumento_mask : public TVariable_mask  // velib06
 | 
						|
{
 | 
						|
  int _progs_page;  // pagina in cui cominciano i progressivi
 | 
						|
  int _last_prog;   // numero dell'ultimo progressivo
 | 
						|
  TDocumento * _doc; // documento                    
 | 
						|
  TRelation * _rel;
 | 
						|
 | 
						|
protected:
 | 
						|
  virtual void next_page(int p);
 | 
						|
  void sconto_testa2mask( TCli_for & c, TConfig & ditta );
 | 
						|
  void spese2mask(TCli_for & c);
 | 
						|
 | 
						|
public:
 | 
						|
  virtual bool on_key(KEY key);
 | 
						|
  TDocumento & doc() const {CHECK(_doc, "Documento nullo"); return *_doc;}
 | 
						|
  TCond_vendita & condv() const { return doc().condv();}
 | 
						|
  void cli2mask( TCli_for & c, TOccasionale & o, TConfig & ditta);
 | 
						|
  void occ2mask(TOccasionale & o);
 | 
						|
 | 
						|
  TDocumento_mask(const char* name, TDocumento * _doc, TRelation * rel, int num = 0, int max = MAX_PAGES);
 | 
						|
  virtual ~TDocumento_mask() {}
 | 
						|
};
 | 
						|
 | 
						|
class TLista_documenti : public TObject  // velib04
 | 
						|
{ 
 | 
						|
  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  // velib04
 | 
						|
{                
 | 
						|
  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'; }
 | 
						|
};
 | 
						|
     
 | 
						|
enum TTipo_elaborazione {_esterna, _consegna_ordini, _fatturazione_bolle, _contabilizzazione,  _copia_documento, _generazione_effetti };
 | 
						|
 | 
						|
class TElaborazione : public TRectype // velib04
 | 
						|
{ 
 | 
						|
protected:
 | 
						|
  int read(const char* cod);
 | 
						|
 | 
						|
public:
 | 
						|
  const TString& codice() const { return get("CODTAB"); }
 | 
						|
  const TString& descrizione() const { return get("S0"); }
 | 
						|
  const TTipo_elaborazione tipo() const { return (TTipo_elaborazione) get_int("I0"); } 
 | 
						|
 | 
						|
  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"); }
 | 
						|
  bool interattivo() const   { return get_bool("B5"); }
 | 
						|
  bool insert_mode() const   { return get_bool("B6"); }
 | 
						|
  
 | 
						|
  const TString& tipo_iniziale(int i) const { return get("S8").mid(i*4, 4); }
 | 
						|
  const char stato_iniziale(int i) const { return get("S9")[i]; }
 | 
						|
  const TString& tipo_finale() const { return get("S8"); }
 | 
						|
  const TString& stato_finale() const { return get("S9"); }
 | 
						|
  
 | 
						|
  char tipo_numerazione() const { return get_bool("B4") ? 'P' : 'D'; }
 | 
						|
  const TString& codice_numerazione_finale() const { return get("S6"); }
 | 
						|
  const TString & applicazione_esterna() const { return get("S5"); }
 | 
						|
  
 | 
						|
  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 TEsterna : public TElaborazione  // velib04
 | 
						|
{ 
 | 
						|
public:
 | 
						|
  virtual bool elabora(TLista_documenti& doc_in, TLista_documenti& doc_out,
 | 
						|
                       const TDate& data_elab);
 | 
						|
 | 
						|
  TEsterna(const char* cod);
 | 
						|
  TEsterna(const TRectype& rec) : TElaborazione(rec) { }
 | 
						|
  virtual ~TEsterna() { }
 | 
						|
};
 | 
						|
 | 
						|
class TConsegna_ordini : public TElaborazione  // velib05
 | 
						|
{ 
 | 
						|
public:
 | 
						|
  virtual bool elabora(TLista_documenti& doc_in, TLista_documenti& doc_out,
 | 
						|
                       const TDate& data_elab);
 | 
						|
 | 
						|
  TConsegna_ordini(const char* cod);
 | 
						|
  TConsegna_ordini(const TRectype& rec) : TElaborazione(rec) { }
 | 
						|
  virtual ~TConsegna_ordini() { }
 | 
						|
};
 | 
						|
 | 
						|
class TFatturazione_bolle : public TElaborazione  // velib04a
 | 
						|
{ 
 | 
						|
  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);
 | 
						|
  TFatturazione_bolle(const TRectype& rec) : TElaborazione(rec) { }
 | 
						|
  virtual ~TFatturazione_bolle() { }
 | 
						|
};
 | 
						|
 | 
						|
// Tipi di errore validi solo per TContabilizzazione e TGenerazione_effetti
 | 
						|
 | 
						|
enum error_type {
 | 
						|
  no_error,
 | 
						|
  nr_es_error,
 | 
						|
  nr_reg_error,
 | 
						|
  nr_doc_error,
 | 
						|
  chg_stat_error,
 | 
						|
  clifo_error,
 | 
						|
  ultprot_error,
 | 
						|
  datadoc_error,
 | 
						|
  caus_error,
 | 
						|
  register_error,
 | 
						|
  change_error,
 | 
						|
  val_error,
 | 
						|
  codpag_error,
 | 
						|
  row_type_error,
 | 
						|
  no_rows_error,
 | 
						|
  conto_error,
 | 
						|
  movement_error,
 | 
						|
  write_error,
 | 
						|
  scadenze_error,
 | 
						|
  bank_error,
 | 
						|
  generic_error
 | 
						|
};
 | 
						|
 | 
						|
class TBill;
 | 
						|
 | 
						|
class TContabilizzazione : public TElaborazione  // velib04b
 | 
						|
{ 
 | 
						|
  bool                _auto_data; // Flag per data di registrazione automatica
 | 
						|
  byte                _nump_iva;  // se 1 prende il numero protocollo da registro iva, se 2 prende il numero protocollo dal numero doc.
 | 
						|
  TDate               _data_reg;  // Data di registrazione documenti
 | 
						|
  long                _total_docs;// Numero di documenti contabilizzati
 | 
						|
  error_type          _error;     // Errore rilevato durante l'elaborazione
 | 
						|
  bool                _can_write; // se TRUE e' abilitata la scrittura. Non appena rileva un errore rimane a FALSE for this instance
 | 
						|
  TString16           _spin_cod,  // codice iva spese d'incasso
 | 
						|
                      _spbo_cod;  // codice iva spese bolli
 | 
						|
  TAssoc_array        _righe_iva; // array per la memorizzazione delle righe iva raggruppate in codesto modo:
 | 
						|
                                  // CODICE_IVA+TIPOCF+GRUPPO+CONTO+SOTTOCONTO
 | 
						|
                                  // una volta completo, tale array viene scorso per comporre le righe IVA
 | 
						|
                                  // del movimento
 | 
						|
  
 | 
						|
  // Files, tabelle, oggetti contabili ed altre amenita'...
 | 
						|
  TLocalisamfile      *_anamag,   // file delle anagrafiche di magazzino
 | 
						|
                      *_fcaus,
 | 
						|
                      *_frcaus,
 | 
						|
                      *_attiv,
 | 
						|
                      *_part,
 | 
						|
                      *_scad,
 | 
						|
                      *_pags,
 | 
						|
                      *_occas,
 | 
						|
                      *_docfile,
 | 
						|
                      *_rdocfile;
 | 
						|
 | 
						|
  TTable              *_cpg,      // tabella condizioni di pagamento
 | 
						|
                      *_gmc,      // tabella gruppi/sottogruppi merceologici
 | 
						|
                      *_rfa,      // tabella raggruppamenti fiscali
 | 
						|
                      *_cve,      // tabella categorie di vendita
 | 
						|
                      *_val,      // tabella valute estere
 | 
						|
                      *_tri,      // tabella tipi di riga
 | 
						|
                      *_prs,      // tabella prestazioni
 | 
						|
                      *_spp,      // tabella spese
 | 
						|
                      *_caa,      // tabella categorie acquisto articoli
 | 
						|
                      *_cra,      // tabella categorie ricavo articoli
 | 
						|
                      *_cco;      // tabella categorie contabili
 | 
						|
  TRelation           *_clifo;    // relazione dei clienti e fornitori + cfven
 | 
						|
  
 | 
						|
  // Parametri da leggere all'inizio dell'elaborazione tramite load_parameters()
 | 
						|
  bool              _nump_cfg;  // se TRUE prende il numero rif. partita dal numero protocollo
 | 
						|
  bool              _sc_enabled;// se TRUE il saldaconto di ditta e' abilitato
 | 
						|
  TToken_string     _search_seq;        // Sequenza di ricerca del conto costo/ricavo la correttezza dell'ordinamento
 | 
						|
                                        // va controllata nel programma di modifica parametri:
 | 
						|
                                        // "" = fine ordinamento
 | 
						|
                                        // CF = cliente fornitore
 | 
						|
                                        // CA = causale
 | 
						|
                                        // AR = articolo (costo/ricavo)
 | 
						|
                                        // GM = gruppo merceologico
 | 
						|
                                        // SM = sottogruppo merceologico
 | 
						|
                                        // RF = raggruppamento fiscale
 | 
						|
                                        // CV = categoria di vendita
 | 
						|
                                        // CC = categoria contabile
 | 
						|
                                        // Gli utlimi 6 fanno parte della ricerca per costi ricavi, in particolare AR,GM,SM e RF
 | 
						|
                                        // non possono essere interrotti da CV o CC. Ad es. CA|CF|AR|CV|GM|CC|RF non e' valida come stringa
 | 
						|
                                        // di ricerca.
 | 
						|
protected:
 | 
						|
  // Carica i parametri dalla configurazione
 | 
						|
  bool load_parameters();        
 | 
						|
  // Compila la testata del movimento
 | 
						|
  error_type   compile_head_mov(TDocumento&);
 | 
						|
  // Funzione per ricercare il conto di costo/ricavo
 | 
						|
  error_type   search_costo_ricavo(TBill&, const TRiga_documento&);
 | 
						|
  // Funzione per aggiungere la riga iva al TAssoc_array _righe_iva
 | 
						|
  error_type   add_iva_row(const TBill&, const TRiga_documento&, const int);
 | 
						|
  // Funzione atomica per aggiungere le righe di spese d'incasso e bolli al TAssoc_array _righe_iva
 | 
						|
  void calculate_spese(real&, real&, int, bool, bool);
 | 
						|
  // Funzione per aggiungere le righe di spese d'incasso e bolli al TAssoc_array _righe_iva (chiama calculate_spese())
 | 
						|
  error_type   add_spese_inbo(TDocumento&, const int);
 | 
						|
  // Aggiorna le righe di sconto importo o percentuale
 | 
						|
  error_type   adjust_sconto_rows(TDocumento&);
 | 
						|
  // Controlla la corrispondenza tra limposta del documento e quelle generate
 | 
						|
  error_type   adjust_iva_rows(TDocumento&);
 | 
						|
  // Crea le righe iva sul movimento
 | 
						|
  error_type   create_iva_rows(TDocumento&);
 | 
						|
  // Crea la riga di totale documento
 | 
						|
  error_type   create_total_doc_row();
 | 
						|
  // Compila le righe del movimento
 | 
						|
  error_type   compile_rows_mov(TDocumento&);
 | 
						|
  // scrive le scadenze
 | 
						|
  error_type write_scadenze(TDocumento&);
 | 
						|
  // scrive il movimento e le scadenze
 | 
						|
  error_type write_all(TDocumento&);
 | 
						|
  // Cambia lo stato del documento
 | 
						|
  error_type   change_doc_status(TDocumento&);
 | 
						|
  // Visualizza l'ultimo errore rilevato
 | 
						|
  void display_error(TDocumento&);
 | 
						|
  // Verifica se non ci sono stati errori
 | 
						|
  bool good() const { return _error == no_error;}
 | 
						|
  // Ritorna TRUE se il saldaconto e' abilitato (verifica anche la causale del documento corrente)
 | 
						|
  bool   sc_enabled() const ; 
 | 
						|
public:
 | 
						|
  virtual bool elabora(TLista_documenti& doc_in, TLista_documenti& doc_out,
 | 
						|
                       const TDate& data_elab);
 | 
						|
  void set_auto(const bool a) { _auto_data = a; }
 | 
						|
  void set_nump(const byte n) { _nump_iva  = n; }
 | 
						|
  const long docs()           { return _total_docs; }
 | 
						|
  TContabilizzazione(const char* cod);
 | 
						|
  TContabilizzazione(const TRectype& rec);
 | 
						|
  virtual ~TContabilizzazione();
 | 
						|
};
 | 
						|
 | 
						|
class TCopia_documento : public TElaborazione  // velib04
 | 
						|
{ 
 | 
						|
public:
 | 
						|
  virtual bool elabora(TLista_documenti& doc_in, TLista_documenti& doc_out,
 | 
						|
                       const TDate& data_elab);
 | 
						|
 | 
						|
  TCopia_documento(const char* cod);
 | 
						|
  TCopia_documento(const TRectype& rec) : TElaborazione(rec) { }
 | 
						|
  virtual ~TCopia_documento() { }
 | 
						|
};
 | 
						|
 | 
						|
 | 
						|
class TGenerazione_effetti : public TElaborazione  // velib04c
 | 
						|
{ 
 | 
						|
  error_type     _error;       // Errore rilevato durante l'elaborazione
 | 
						|
  long           _total_bills; // Totale effetti generati
 | 
						|
  bool           _can_write;   // se TRUE e' abilitata la scrittura. Non appena rileva un errore rimane a FALSE for this instance
 | 
						|
  TBit_array     _valid_array; // array dei tipi di pagamento validi per la generazione di effetti
 | 
						|
 | 
						|
  TLocalisamfile *_efffile,    // file effetti
 | 
						|
                 *_refffile,   // file righe di effetti
 | 
						|
                 *_cessfile,
 | 
						|
                 *_docfile,
 | 
						|
                 *_rdocfile,
 | 
						|
                 *_clifo,
 | 
						|
                 *_cfven,
 | 
						|
                 *_tab,
 | 
						|
                 *_occas;
 | 
						|
  TTable         *_cpg;        // tabella condizioni di pagamento
 | 
						|
  TArray         _effetti_array;//Array di effetti (TEffetto) da scrivere
 | 
						|
  TAssoc_array   _group_array; // Assoc_array dei documenti da raggruppare. La chiave di ogni elemento
 | 
						|
                               // e composta dagli stessi criteri di raggruppamento (vedi sotto)
 | 
						|
                               // Ogni elemento e una TToken_string. Ogni elemento della TToken_string contiene
 | 
						|
                               // la chiave per identificare il documento che fa parte di quel raggruppamento
 | 
						|
protected:
 | 
						|
  // Visualizza l'ultimo errore rilevato
 | 
						|
  void display_error(TDocumento& doc);
 | 
						|
  // Restituisce TRUE se il tipo di pagamento passato e' valido per generare l'effetto
 | 
						|
  bool   valid_type(int) const ;
 | 
						|
  // Genera l'effetto
 | 
						|
  void   generate_bill(TDocumento&);
 | 
						|
  // Effettua il raggruppamento vero e proprio degli effetti (solo se ci sono elementi nell'assoc_array
 | 
						|
  void   group_bills(TDocumento&);
 | 
						|
  // Istanzia il pagamento corrente
 | 
						|
  void   calc_pagamento(TDocumento&, TString16&, TString16&);
 | 
						|
  // Scrive i record array degli effetti raggruppati
 | 
						|
  error_type write_groups();
 | 
						|
  // Cambia lo stato dei gruppi di documenti raggruppati in effetti
 | 
						|
  error_type change_group_status(TDocumento&);
 | 
						|
  // Cambia lo stato del documento
 | 
						|
  error_type change_doc_status(TDocumento&);
 | 
						|
  // Verifica se non ci sono stati errori
 | 
						|
  bool good() const { return _error == no_error;}
 | 
						|
public:
 | 
						|
  virtual bool elabora(TLista_documenti& doc_in, TLista_documenti& doc_out,
 | 
						|
                       const TDate& data_elab);
 | 
						|
                           
 | 
						|
  const long bills()                    { return _total_bills; }
 | 
						|
  void       set_group(TAssoc_array& a) { _group_array = a; }
 | 
						|
  TGenerazione_effetti(const char* cod);
 | 
						|
  TGenerazione_effetti(const TRectype& rec);
 | 
						|
  virtual ~TGenerazione_effetti();
 | 
						|
};
 | 
						|
 | 
						|
class TLista_elaborazioni : public TObject  // velib04
 | 
						|
{    
 | 
						|
  TAssoc_array * _elab;            
 | 
						|
  
 | 
						|
protected:
 | 
						|
  void read();
 | 
						|
    
 | 
						|
public:                                     
 | 
						|
  TElaborazione & operator [](const char * key) const;
 | 
						|
  int select(TString_array & result, bool interattivo, bool insert_mode, const char * tipo_iniziale = NULL, const char * stato_iniziale = NULL, const char * tipo_finale = NULL, const char * stato_finale = NULL);
 | 
						|
  void update(); 
 | 
						|
  TLista_elaborazioni() : _elab(NULL) {}
 | 
						|
  virtual ~TLista_elaborazioni();
 | 
						|
};
 | 
						|
 | 
						|
struct dec_parm {
 | 
						|
  int pri_lit,
 | 
						|
      pri_val, 
 | 
						|
      qta_lit, 
 | 
						|
      qta_val,  // si lo so non ha senso, ma lo faccio lo stesso
 | 
						|
      imp_lit, 
 | 
						|
      imp_val;
 | 
						|
      // add other groups here
 | 
						|
};
 | 
						|
 | 
						|
//////////////////////////////////////////////////////////////////////////////////////////////
 | 
						|
// classe TDocumentoEsteso: oggetto che ha come finalita' il calcolo dei riepiloghi IVA
 | 
						|
//////////////////////////////////////////////////////////////////////////////////////////////
 | 
						|
 | 
						|
class TDocumentoEsteso : public TDocumento
 | 
						|
{ 
 | 
						|
  // Parametri del documento
 | 
						|
  dec_parm        _parm;          // Parametri per gli arrotondamenti
 | 
						|
  TTable        * _iva;           // Tabella codici IVA
 | 
						|
  
 | 
						|
  // Totali del documento ricalcolati non appena la tabellina di riepilogo IVA e' completa
 | 
						|
//  real _importi_netti, _imposte;
 | 
						|
 | 
						|
  // membri per il calcolo del riepilogo IVA
 | 
						|
  bool            _sum_selected;  // TRUE se ha selezionato una riga del riepilogo, funge da semaforo per leggere la prossima
 | 
						|
  int             _sum_filter;    // Filtro corrente della riga TRiepilogo_iva in corso di stampa (-1 se non ha ancora calcolato la tabella)
 | 
						|
  TString_array   _order_array;   // Array di TToken_string contenenti i codici IVA soddisfacenti ad ogni tipo di filtro
 | 
						|
  TAssoc_array    _summary_table; // Array associativo contenete imonibili ed imposte pronte per la stampa;
 | 
						|
  TArray          _summary_array; // Array dove vengono memorizzate le imposte/imponibili per riga
 | 
						|
  TRiepilogo_iva  _sum_current;   // Riga corrente del riepilogo
 | 
						|
 | 
						|
  // membri per il calcolo del riepilogo scadenze
 | 
						|
  TString_array   _scadenze_array;// Array che contiene le scadenze ("<data>|<importo>")
 | 
						|
  int             _scadenze_current;  // indice per identificare l'elementi corrente sull'array (-1 se non ha ancora calcolato)
 | 
						|
 | 
						|
public:
 | 
						|
 | 
						|
  
 | 
						|
  // Funzioni per il riepilogo IVA
 | 
						|
  const bool summary_compiled() { return _sum_filter > -1; }
 | 
						|
  void compile_summary(); // Aggiorna la tabella riepilogativa    
 | 
						|
  void summary_filter(byte selector);  // filtra la tabellina secondo il filtro corrente se non e' gia' stato fatto
 | 
						|
  void summary_reset(bool force=FALSE); // riposiziona l'array dei codici IVA (_order_array). Se il parametro e' TRUE forza il ricalcolo della tabella 
 | 
						|
  void summary_set_next(); // seleziona il prossimo elemento del filtro
 | 
						|
  const TRiepilogo_iva& sum_current() { return _sum_current; } // ritorna la riga corrente del filtro corrente
 | 
						|
  const char * summary_get(const TString& w); // ritorna l'informazione richiesta estratta dall'elemento corrente
 | 
						|
  int  summary_items() { return tabella_iva().items();} // ritorna il numero di righe in totale della tabellina
 | 
						|
  const TAssoc_array& summary() { return _summary_table; }
 | 
						|
  const TArray& summary_array() { return _summary_array;}
 | 
						|
  
 | 
						|
 | 
						|
  // Funzioni per il ricalcolo delle scadenze
 | 
						|
  void scadenze_reset(); // riposiziona sulla prima scadenza
 | 
						|
  void scadenze_recalc(); // resetta e ricalcola le scadenze
 | 
						|
  void scadenze_set_next(); // seleziona il prossimo elemento dell'array delle scadenze
 | 
						|
  const char * scadenze_get(const TString& w); // reperisce l'informazione richiesta dall'elemento corrente
 | 
						|
  int  scadenze_items() { return _scadenze_array.items(); }  // restituisce il numero di scadenze
 | 
						|
  TString_array& scadenze() { return _scadenze_array; }
 | 
						|
 | 
						|
  // restituisce tot_imponibili, tot_esenti, tot_nonsoggetti a seconda del selettore:  
 | 
						|
  // 1 = regime normale
 | 
						|
  // 2 = da ventilare (non usato)
 | 
						|
  // 4 = esenti
 | 
						|
  // 8 = non imponibili
 | 
						|
  // 16 = non soggetti
 | 
						|
  // pertanto i non imponibili avranno selettore 1 e gli esenti selettore 4.
 | 
						|
  // per avere esenti + non soggetti il selettore sara' 20 e cosi' via.
 | 
						|
  real tot_imponibili(byte selector);
 | 
						|
  
 | 
						|
  // Funzioni per settare i parametri
 | 
						|
  void set_decimals(dec_parm & parm) { _parm = parm ; }
 | 
						|
  void set_condv(TCli_for * cli); // Cambia le condizioni di vendita
 | 
						|
  TDocumentoEsteso (const TRectype & rec, dec_parm & parm, TCond_vendita * condv = NULL) ;
 | 
						|
  TDocumentoEsteso (const TRectype & rec, TCond_vendita * condv = NULL) ;
 | 
						|
  TDocumentoEsteso () ;
 | 
						|
  ~TDocumentoEsteso();
 | 
						|
};
 | 
						|
 | 
						|
 | 
						|
#endif
 |