Files correlati : cg2100o.msk cg6.exe Ricompilazione Demo : [ ] Commento : Corretta importazione codice fiscale da trasfer (cliente CRPE) git-svn-id: svn://10.65.10.50/trunk@20264 c028cbd2-c16b-5b4b-a496-9718f37d4682
		
			
				
	
	
		
			354 lines
		
	
	
		
			15 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			354 lines
		
	
	
		
			15 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
// cglib04.h
 | 
						|
 | 
						|
#ifndef __CGLIB04_H
 | 
						|
#define __CGLIB04_H
 | 
						|
 | 
						|
#ifndef __RECARRAY_H
 | 
						|
#include <recarray.h> 
 | 
						|
#endif
 | 
						|
 | 
						|
#ifndef __PROGIND_H
 | 
						|
class TProgind;
 | 
						|
#endif
 | 
						|
 | 
						|
#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> 
 | 
						|
#include <varrec.h>
 | 
						|
 | 
						|
#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:
 | 
						|
/*    int operator =(int i) ;
 | 
						|
    long operator =(long l) ;
 | 
						|
    const TDate& operator =(const TDate& d) ;
 | 
						|
    const real& operator =(const real& r) ; */
 | 
						|
    
 | 
						|
    const char* operator =(const char* s);
 | 
						|
 | 
						|
/*    operator int() const ;
 | 
						|
    operator long() const ;
 | 
						|
    operator TDate() const ;
 | 
						|
    operator const real() const ; */
 | 
						|
    
 | 
						|
    operator const char*() const;
 | 
						|
 | 
						|
//    void setptr(TRecnotype r); // Scrive un campo packed. Sarebbe meglio non usare mai campi packed.
 | 
						|
//    TRecnotype ptr() const;    // Legge un campo packed. Sarebbe meglio non usare mai campi packed.
 | 
						|
 | 
						|
    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(TString& cau,TString& tipo,TString& descr);
 | 
						|
  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
 | 
						|
 |