1939 lines
		
	
	
		
			49 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			1939 lines
		
	
	
		
			49 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
| // Ricezione dati da sistema
 | |
| 
 | |
| #include <mask.h>
 | |
| #include <printapp.h>
 | |
| #include <relation.h>
 | |
| #include <tabutil.h>
 | |
| #include <utility.h>
 | |
| #include <config.h>
 | |
| #include <urldefid.h> 
 | |
| #include <mailbox.h>
 | |
| #include <execp.h>                       
 | |
| #include <prefix.h>
 | |
| #include <scanner.h>
 | |
| #include <lffiles.h>  
 | |
| #include <progind.h>
 | |
| #include <nditte.h>  
 | |
| #include <mov.h>
 | |
| #include <rmov.h>
 | |
| #include <rmoviva.h>
 | |
| #include <pconti.h> 
 | |
| #include <comuni.h>
 | |
| #include <clifo.h>
 | |
| 
 | |
| #include "cglib04.h"
 | |
| #include "cglib.h"
 | |
| #include "cg2103.h"
 | |
| 
 | |
| #include "cg2600.h"
 | |
| 
 | |
| const int   CAMPI_RCAUS = 6;
 | |
| HIDDEN      TString80 TEMP;
 | |
| 
 | |
| HIDDEN int date2esc(const TDate& d, int* prevesc = NULL);
 | |
| 
 | |
| class TRic_tab : public TApplication
 | |
| {
 | |
|   
 | |
|   TTable*           _tab_tra;                    
 | |
|   TLocalisamfile*   _mov, *_rmov, *_rmoviva;
 | |
|   TTransfer_file    _tras_file;
 | |
|   TArray            _aggiorna;
 | |
|   char              _scelta;     
 | |
|   TSaldo_agg        _sld;  
 | |
|   TProgind*         _prog;
 | |
|   
 | |
|   int     _numinv,_nultras,_annoes,_g,_c;
 | |
|   TString _trasf,_ragsoc_dittar,_sigle_file,_std,_key,_nomeid,_dittainv;
 | |
|   long    _dittaric,_numrec,_nreg,_s,_ndoc,_npiva,_nupiva;      
 | |
|   TDate   _dataultras,_datareg,_dreg,_ddoc;                  
 | |
|   TString _uselab,_record,_nrec_file,_creg,_ccau,_tdoc,_cod_com;         
 | |
|   bool    _prima_volta;             
 | |
|   long    _protiva,_uprotiva,_nprotiva,_nuprotiva,_numreg,_numreg_p,_numreg_piva;
 | |
|   char    _sez;
 | |
|   real    _importo,_totdoc;
 | |
|   
 | |
| public:        
 | |
|   TString     _titolo;
 | |
|   
 | |
|   virtual bool create();
 | |
|   virtual bool destroy();
 | |
|   virtual bool menu(MENU_TAG m);         
 | |
|   bool    main_loop();
 | |
|   bool    video();
 | |
|   bool    leggi_trasfer();
 | |
|   bool    controlli();
 | |
|   void    ditta_ricevente();
 | |
|   bool    controllo_pre_ricezione();  
 | |
|   void    leggi_record_controllo();
 | |
| 
 | |
|   void    setta_parametri_record(const TString& sigla,const TString& flag);
 | |
|   
 | |
|   const char* numero_civico(TString& field);
 | |
|   const char* cerca_comune_cap(TString& field);
 | |
|   const char* cerca_comune_den(TString& field);                        
 | |
|   
 | |
|   void    trasferimento();
 | |
|   
 | |
|   void    scrivi_record_tab(TString& record,long rec);  
 | |
|   int     trasfer_data_tab(TLocalisamfile& file, TRectype& dep, const TString& sigla);
 | |
|   int     trasfer_data_conto(TLocalisamfile& file, TRectype& dep);
 | |
|   int     trasfer_data_sottoc(TLocalisamfile& file, TRectype& dep);
 | |
|   void    decimali(TString& campo, int dec);
 | |
|   
 | |
|   void    scrivi_record_mov(TString& record,long rec);
 | |
|   int     trasfer_data_mov(TLocalisamfile& file, TRectype& dep);
 | |
|   long    esiste_numreg(long nreg);                     
 | |
|   void    num_protocollo(TString& record);
 | |
|   void    controlli_prima_nota(TString& record,TString& codreg);
 | |
|   long    ulnumprot_reg(int anno,TString& codreg);             
 | |
|   long    ultima_registrazione();
 | |
|   void    aggiorna_reg(int anno,TString& codreg,long ulnum);
 | |
|   int     annoes_datacomp(const TString& record,TDate& datacomp);
 | |
|   void    datafine_esprec(const int annop,TDate& datacomp);
 | |
|   char    ricerca_causale(TString& field);
 | |
|   void    prepara_saldi(const TString& fname,const TString& field);
 | |
|   
 | |
|   void    scrivi_record_moviva(TString& record,long rec);            
 | |
|   void    aggiorna_temp_file(long numreg, long nreg);
 | |
|   long    numreg_PN(long numreg);
 | |
|   long    numrec_PN(long numreg);                
 | |
|   void    recupera_dati_testata(long numreg);
 | |
|   bool    occasionali(const TString& record);
 | |
|   void    scrivi_occasionali(const TString& record, long num);
 | |
|   void    ricerca_comune(const TString& com);  
 | |
|   int     cerca_annoes(long numreg);
 | |
|   int     trasfer_data_moviva(TLocalisamfile& file, TRectype& dep, int ln);
 | |
|   void    salva_dati_testata();
 | |
|   
 | |
|   const char* converti  (TString& data_AS400);
 | |
|   const char* riconverti(TString& data_PC);  
 | |
|   
 | |
|   TRic_tab(char ric_tab_mov);
 | |
| };                                      
 | |
| 
 | |
| HIDDEN TRic_tab& app() { return (TRic_tab &) main_app(); }
 | |
| 
 | |
| TRic_tab::TRic_tab(char ric_tab_mov) : _scelta(toupper(ric_tab_mov))
 | |
| {
 | |
|   if (_scelta == 'T')
 | |
|     _titolo = "Ricezione tabelle";
 | |
| 
 | |
|   if (_scelta == 'M')      
 | |
|     _titolo = "Ricezione movimenti";
 | |
| }
 | |
| 
 | |
| bool TRic_tab::create()
 | |
| {
 | |
|   TApplication::create();
 | |
|   
 | |
|   _tab_tra  = new TTable ("%TRA");
 | |
|   _mov      = new TLocalisamfile (LF_MOV);
 | |
|   _rmov     = new TLocalisamfile (LF_RMOV);
 | |
|   _rmoviva  = new TLocalisamfile (LF_RMOVIVA);
 | |
|   
 | |
|   _numrec      = 1;
 | |
|   _prima_volta = TRUE;   
 | |
|   _aggiorna.destroy();
 | |
|   _numreg_p    = 0;                
 | |
|   _numreg_piva = 0;                
 | |
|   _nreg        = 0;
 | |
|   _sld.reset();
 | |
|   
 | |
|   dispatch_e_menu (BAR_ITEM(1));
 | |
| 
 | |
|   return TRUE;
 | |
| }
 | |
| 
 | |
| bool TRic_tab::destroy()
 | |
| {
 | |
|   delete _tab_tra;                            
 | |
|   delete _mov;
 | |
|   delete _rmov;
 | |
|   delete _rmoviva;
 | |
|   
 | |
|   return TApplication::destroy();
 | |
| }                                
 | |
| 
 | |
| HIDDEN int date2esc(const TDate& d, int* prevesc)
 | |
| {                   
 | |
|   if (prevesc) *prevesc = 0;
 | |
|   TTable esc("ESC");
 | |
|   for (int err = esc.first(); err == NOERR; err = esc.next())
 | |
|   {
 | |
|     const TDate ia(esc.get("D0"));   // Data inizio esercizio
 | |
|     const TDate fa(esc.get("D1"));   // Data fine esercizio
 | |
|     const anno = esc.get_int("CODTAB");  
 | |
|     if (d >= ia && d <= fa)
 | |
|       return anno;
 | |
|     if (prevesc) *prevesc = anno; 
 | |
|   } 
 | |
|   return 0;
 | |
| }
 | |
| 
 | |
| void TRic_tab::leggi_record_controllo()
 | |
| {
 | |
|   _tras_file.read_control_rec();
 | |
|   _record = _tras_file.record();
 | |
| }
 | |
| 
 | |
| const char* TRic_tab::converti (TString& data_AS400)
 | |
| {
 | |
|   TEMP = data_AS400.mid(4,2);
 | |
|   TEMP << "-" <<data_AS400.mid(2,2);
 | |
|   TEMP << "-" <<data_AS400.mid(0,2);
 | |
|   return TEMP;
 | |
| }
 | |
| 
 | |
| const char* TRic_tab::riconverti (TString& data_PC)
 | |
| {
 | |
|   TEMP = data_PC.mid(8,2);
 | |
|   TEMP << data_PC.mid(3,2);
 | |
|   TEMP << data_PC.mid(0,2);
 | |
|   return TEMP;
 | |
| }
 | |
| 
 | |
| const char* TRic_tab::numero_civico(TString& indirizzo)
 | |
| {
 | |
|   int i;
 | |
|   
 | |
|   for (i = indirizzo.len(); (indirizzo[i] != ' ' && indirizzo[i] != ',' && i > 0); i--);
 | |
|   
 | |
|   if (i > 0)
 | |
|   {
 | |
|     TEMP = indirizzo.mid(i+1);
 | |
|     indirizzo = indirizzo.sub(0,i);
 | |
|   }                                
 | |
|   else
 | |
|     TEMP = "";
 | |
|   
 | |
|   return TEMP;
 | |
| }
 | |
| 
 | |
| const char* TRic_tab::cerca_comune_cap(TString& field)
 | |
| {             
 | |
|   TLocalisamfile comuni (LF_COMUNI);
 | |
|   TString cap = field;
 | |
|   
 | |
|   if (cap.sub(2,3) == "1")
 | |
|   {
 | |
|     cap = cap.sub(0,3);
 | |
|     cap << "00";
 | |
|   }
 | |
|   
 | |
|   comuni.setkey(3);
 | |
|   comuni.zero();
 | |
|   comuni.put(COM_CAPCOM, cap);
 | |
|   if (comuni.read() == NOERR)
 | |
|     TEMP = comuni.get(COM_COM);
 | |
|   else
 | |
|     TEMP = "";
 | |
|   
 | |
|   return TEMP;
 | |
| }
 | |
| 
 | |
| const char* TRic_tab::cerca_comune_den(TString& field)
 | |
| {   
 | |
|   TLocalisamfile comuni (LF_COMUNI);
 | |
|   
 | |
|   comuni.setkey(2);
 | |
|   comuni.zero();
 | |
|   comuni.put(COM_DENCOM, field);
 | |
|   if (comuni.read() == NOERR)
 | |
|     TEMP = comuni.get(COM_COM);
 | |
|   else
 | |
|     TEMP = "";
 | |
|   
 | |
|   return TEMP;
 | |
| }
 | |
| 
 | |
| bool TRic_tab::main_loop()
 | |
| {      
 | |
|   int posiz;
 | |
|   
 | |
|   _dittaric = get_firm();
 | |
|   
 | |
|   if (_scelta == 'T')
 | |
|   {  
 | |
|     if (video())
 | |
|     { 
 | |
|       if (_std == "")
 | |
|         if (!controllo_pre_ricezione())
 | |
|           return FALSE;
 | |
| 
 | |
|       trasferimento();
 | |
|       posiz  = _tras_file.num('Z'); //Ritorna la posizione della sigla all'interno dell'indice
 | |
|       
 | |
|       if (posiz >= 0)                 
 | |
|       {   
 | |
|         setta_parametri_record(" ","C");
 | |
|         message_box("Aggiornamento tabelle terminato: proseguire con controllo movimenti");
 | |
|         leggi_record_controllo();
 | |
|         TString str (_record.overwrite("               ",241));
 | |
|         _tras_file.write_control_rec(str,256);
 | |
|       }
 | |
|       else
 | |
|       {
 | |
|         setta_parametri_record(" ","*");
 | |
|         fremove(_trasf);
 | |
|         setta_parametri_record(" "," ");
 | |
|       }
 | |
|     }
 | |
|   }
 | |
|   else
 | |
|     if (_scelta == 'M')
 | |
|     {
 | |
|       if (video())
 | |
|       {
 | |
|         trasferimento();
 | |
|         setta_parametri_record(" ","*");
 | |
|         fremove(_trasf);
 | |
|         setta_parametri_record(" "," ");  
 | |
|       }
 | |
|     }
 | |
|   
 | |
|   return FALSE;
 | |
| }
 | |
| 
 | |
| void TRic_tab::trasferimento()
 | |
| {
 | |
|   char    uselab;
 | |
|   TString record(256),key;
 | |
|   int     posiz,i;
 | |
|   long    rec;
 | |
|   int     last_tab; 
 | |
|   char    sigla;               
 | |
|   TString message;
 | |
|   
 | |
|   uselab = (_tras_file.ult_file())[0];
 | |
|   posiz  = _tras_file.num(uselab); //Ritorna la posizione della sigla all'interno dell'indice
 | |
|   key    = _tras_file.key(); 
 | |
|   key.trim();
 | |
|   
 | |
|   if (_scelta == 'T')
 | |
|     last_tab = _tras_file.last_tab();  
 | |
|   else
 | |
|     if (_scelta == 'M')
 | |
|       last_tab = _tras_file.last_mov();        
 | |
|   
 | |
|   for (i = posiz; i < last_tab;i++)
 | |
|   {                 
 | |
|     if (key == "")                  
 | |
|       rec   = _tras_file.rec(i);
 | |
|     else
 | |
|       rec = atol(key.mid(2,6));
 | |
|     
 | |
|     long nrec = ((_tras_file.nrec(i))+1);    
 | |
|     sigla = _tras_file.name(i)[0];
 | |
|     long cicli = nrec - rec;
 | |
|     
 | |
|     switch (sigla)
 | |
|     {
 | |
|     case 'W': message = "Ricezione tabella causali in corso... Prego attendere.";
 | |
|               break;
 | |
|             case 'A': message = "Ricezione anagrafica Clienti / Fornitori in corso... Prego attendere.";
 | |
|               break;
 | |
|             case 'P': message = "Ricezione anagrafica Piano dei Conti in corso... Prego attendere.";
 | |
|               break;
 | |
|             case 'Z': message = "Ricezione Movimenti di primanota in corso... Prego attendere."; 
 | |
|               break;
 | |
|             case 'U': message = "Ricezione Movimenti iva in corso... Prego attendere."; 
 | |
|               break;                      
 | |
|             default: break;
 | |
|             }
 | |
|     _prog = new TProgind(cicli,message,FALSE);
 | |
|     
 | |
|     for (long j = rec; j < nrec; j++)
 | |
|     { 
 | |
|       _tras_file.read_rec_trasfer(j);
 | |
|       record = _tras_file.read_rec();
 | |
|       
 | |
|       if (_scelta == 'T')
 | |
|         scrivi_record_tab(record,j);
 | |
|       else
 | |
|         if (_scelta == 'M')
 | |
|         { 
 | |
|           if (sigla == 'Z')
 | |
|           {
 | |
|             scrivi_record_mov(record,j);
 | |
|             if (j == (nrec - 1))
 | |
|               _sld.registra();
 | |
|           }
 | |
|           else
 | |
|             if (sigla == 'U')
 | |
|             {
 | |
|               scrivi_record_moviva(record,j);
 | |
|             }
 | |
|         }
 | |
|       
 | |
|     } 
 | |
|     delete _prog;  
 | |
|     key = ""; //Altrimenti in caso di ripartenza mi ripristina sempre la situazione
 | |
|   }
 | |
| }
 | |
| 
 | |
| void TRic_tab::scrivi_record_tab(TString& record,long rec)
 | |
| {
 | |
|   TString sigla,key,str,numero,comune;
 | |
|   int     numfield = 2;  //Per le tabelle il primo campo della mappa non e' significativo
 | |
|   //ai fini del trasferimento (flag di record gia trasferito).
 | |
|   TMappa_trc&       trc = _tras_file.mappa();
 | |
|   TLocalisamfile*   file = NULL; 
 | |
|   TRectype*         dep         = NULL;
 | |
|   char              gia_trasf;
 | |
|   int               logicnum;
 | |
|   int               campi_righe = 0;
 | |
|   int               num_riga    = 1;
 | |
|   TToken_string     data;
 | |
|   TString cap = "";
 | |
|   
 | |
|   sigla     = record.mid(0,2);
 | |
|   gia_trasf = record.mid(255,1)[0];
 | |
|   
 | |
|   if (gia_trasf == ' ')
 | |
|   {   
 | |
|     key.format("%2s%d", (const char*)sigla,numfield);
 | |
|     
 | |
|     if (trc.is_key((const char *) key)) 
 | |
|     {    
 | |
|       int logicnum_p = 0;
 | |
|       
 | |
|       do
 | |
|       {  
 | |
|         logicnum = trc.logicnum(key);
 | |
|         
 | |
|         if (logicnum != logicnum_p)
 | |
|         {
 | |
|           if (logicnum_p)
 | |
|           {              
 | |
|             _prog->addstatus(1);
 | |
|             trasfer_data_tab(*file, *dep, sigla);            
 | |
|             delete file;
 | |
|             delete dep;
 | |
|           }           
 | |
|           
 | |
|           if ( (logicnum == LF_RCAUSALI) && (_tras_file.flg_agg() == 'D') )
 | |
|             break;
 | |
|           
 | |
|           file = new TLocalisamfile(logicnum);
 | |
|           dep  = new TRectype (logicnum);
 | |
|           dep->zero();
 | |
|         }                                                 
 | |
|         
 | |
|         logicnum_p = logicnum;
 | |
| 
 | |
|         if (logicnum == LF_RCAUSALI) 
 | |
|         {
 | |
|           campi_righe++;
 | |
| 
 | |
|           if (campi_righe == CAMPI_RCAUS)
 | |
|           {
 | |
|             TString16 gruppo(dep->get("GRUPPO"));     
 | |
|             //          
 | |
|             // scarta le righe non significative
 | |
|             // --------------------  NB  -----------------------
 | |
|             // supponiamo il GRUPPO INDISPENSABILE !!!!!!!!!!!!!
 | |
|             //
 | |
|             if (gruppo.not_empty()) 
 | |
|             {
 | |
|               dep->put("NRIGA", num_riga++);
 | |
|               
 | |
|               trasfer_data_tab(*file, *dep, sigla);
 | |
|             }
 | |
|             else
 | |
|               num_riga++;
 | |
|             
 | |
|             campi_righe   = 1;
 | |
|           } 
 | |
|         }
 | |
| 
 | |
|         int     from  = trc.from(key);
 | |
|         int     to    = trc.to(key);
 | |
|         TString fname = trc.field_name(key); 
 | |
|         int     flag  = trc.flag(key);
 | |
|         TString field = record.sub(from-1,to); 
 | |
|         
 | |
|         //Il nostro codice registro IVA e' lungo 3: se il loro registro (lungo 1) e' alfanumerico
 | |
|         //devo allinearlo a sinistra, mentre se e' numerico devo allinearlo a destra riempendolo con degli zero.      
 | |
|         if (logicnum == LF_CAUSALI)
 | |
|         {                          
 | |
|           if (fname == "REG")
 | |
|           {
 | |
|             char f = field[0];
 | |
|             if (isdigit(f))
 | |
|               field.format("%03c", f);
 | |
|             else
 | |
|               field.format("%-3c", f);
 | |
|           }
 | |
|           
 | |
|           if (fname == "M770")
 | |
|             if (field == "0")
 | |
|               field = " ";
 | |
| 
 | |
|           if (fname == "NUMDOC" || fname == "DATADOC")
 | |
|           {
 | |
|             if (field == "0")
 | |
|               field = " ";
 | |
|             else
 | |
|               if (field == "1")
 | |
|                 field = "X";
 | |
|           }
 | |
|           
 | |
|           if (fname == "CODCAUSIM")
 | |
|             if (field == "000")
 | |
|               field = "   ";                 
 | |
|         }                           
 | |
|         
 | |
|         //Il tipo cliente/fornitore presente su AS400 puo' assumere come valori 1 o 2
 | |
|         //mentre quello su PC C o F; devo fare la conversione.
 | |
|         if (sigla == "A1") 
 | |
|         {
 | |
|           if (fname == "TIPOCF")
 | |
|           {
 | |
|             if (field == "1")
 | |
|               field = "C"; 
 | |
|             
 | |
|             if (field == "2")
 | |
|               field = "F";
 | |
|           }
 | |
|           //Il tipo persona (fisica/giuridica) su AS400 puo' assumere come valori 1 e 0
 | |
|           //mentre quello su PC F o G; devo fare la conversione.
 | |
|           if (fname == "TIPOPERS")
 | |
|           {
 | |
|             if (field == "1")
 | |
|               field = "F";
 | |
|             
 | |
|             if (field == "0")
 | |
|               field = "G";
 | |
|           }        
 | |
|           
 | |
|           //Il codice pagamento su AS400 e' un alfanumerico di due, mentre su PC e' un
 | |
|           //alfanumerico di 4 trattato con il flag Z. Dunque in ricezione se si tratta
 | |
|           //di un numero va riempito con degli 0. Se si tratta di un alfa va allineato a destra.                       
 | |
|           if (fname == "CODPAG")
 | |
|           { 
 | |
|             TString f = field;
 | |
|             if (real::is_natural(f))
 | |
|               field.format("%04s", (const char*) f);
 | |
|             else
 | |
|               field.format("%-4s", (const char*) f);
 | |
|           }
 | |
|           
 | |
|           if (fname == "INDCF")
 | |
|           {            
 | |
|             field = field.rtrim();
 | |
|             if (field != "")
 | |
|             {
 | |
|               numero = numero_civico(field);
 | |
|               dep->put(CLI_CIVCF, (const char*)numero);
 | |
|             }
 | |
|           }
 | |
|           
 | |
|           if (fname == "CAPCF")
 | |
|           {
 | |
|             if (field == "00000")
 | |
|               field = "     ";
 | |
|             else
 | |
|               cap = field;
 | |
|           }
 | |
|           
 | |
|           if (fname == "LOCALITACF")
 | |
|           {
 | |
|             comune = "";
 | |
|             
 | |
|             if (cap.not_empty())
 | |
|               comune = cerca_comune_cap(cap);
 | |
|             if (comune.empty())
 | |
|               comune = cerca_comune_den(field);
 | |
|             if (comune.not_empty())
 | |
|             {
 | |
|               dep->put(CLI_COMCF, comune);
 | |
|               field = "";
 | |
|             }
 | |
|           } 
 | |
|           
 | |
|           if (fname == "ALLEG")
 | |
|             if (field == "0")
 | |
|               field = " "; 
 | |
|           
 | |
|           if (fname == "PAIV")
 | |
|             if (field == "00000000000")
 | |
|               field = " ";    
 | |
|         }
 | |
|         
 | |
|         if (flag && (_tras_file.flg_agg() == 'D') )       
 | |
|         {              
 | |
|           data = "";
 | |
|           data.add(fname);
 | |
|           data.add(field);
 | |
|           
 | |
|           _aggiorna.add(data);
 | |
| 
 | |
|           if (sigla == "A1" && fname == "INDCF")
 | |
|           {            
 | |
|             data = "";
 | |
|             data.add("CIVCF");
 | |
|             data.add(numero);
 | |
|             
 | |
|             _aggiorna.add(data);
 | |
|           }                                     
 | |
|           
 | |
|           if (sigla == "A1" && fname == "LOCALITACF")
 | |
|           {
 | |
|             data = "";
 | |
|             data.add("COMCF");
 | |
|             data.add(comune);
 | |
|             
 | |
|             _aggiorna.add(data);
 | |
|           }
 | |
|         }
 | |
| 
 | |
|         //Quando ricevo la IV direttiva del piano dei conti per evitare che nell'archivio,
 | |
|         //in caso di numero romano vuoto, venga memorizzato la stringa letta sul trasfer ("000"),
 | |
|         //vuoto la stringa prima di fare la put.
 | |
|         if (sigla == "P2" || sigla == "P3")
 | |
|         {             
 | |
|           if (fname == "STSOTTBIL")
 | |
|           {
 | |
|             if (field == "0")
 | |
|               field = "X";
 | |
|             else
 | |
|               if (field == "1")
 | |
|                 field = " ";
 | |
|           }
 | |
|           
 | |
|           if (fname == "NUMRIVD" || fname == "NUMRIVDOPP")
 | |
|           {
 | |
|             if (field == "000")
 | |
|               field = "";
 | |
|           }
 | |
|           if (fname == "SEZIVD" || fname == "SEZIVDOPP")
 | |
|           {
 | |
|             if (field == " ")
 | |
|               field = "0";
 | |
|           }
 | |
|         } 
 | |
|         
 | |
|         dep->put(fname, (const char*)field);                      
 | |
| 
 | |
|         numfield++;
 | |
|         key.format("%2s%d", (const char*) sigla,numfield);
 | |
|       }
 | |
|       while (trc.is_key((const char*) key));
 | |
|       
 | |
|       if (logicnum == LF_RCAUSALI) 
 | |
|       { 
 | |
|         if (_tras_file.flg_agg() != 'D')
 | |
|         {
 | |
|           campi_righe++;
 | |
| 
 | |
|           if (campi_righe == CAMPI_RCAUS)
 | |
|           {
 | |
|             TString16 gruppo(dep->get("GRUPPO"));     
 | |
|             //          
 | |
|             // scarta le righe non significative
 | |
|             // --------------------  NB  -----------------------
 | |
|             // supponiamo il GRUPPO INDISPENSABILE !!!!!!!!!!!!!
 | |
|             //
 | |
|             if (gruppo.not_empty()) 
 | |
|             {
 | |
|               dep->put("NRIGA", num_riga++);
 | |
|               trasfer_data_tab(*file, *dep, sigla);
 | |
|             }                                                
 | |
|             else
 | |
|               num_riga++;
 | |
|             
 | |
|             campi_righe   = 1;
 | |
|           }  
 | |
|         } 
 | |
|       }
 | |
|       else                      
 | |
|       {
 | |
|         _prog->addstatus(1);
 | |
|         trasfer_data_tab(*file, *dep, sigla);  
 | |
|       }
 | |
|       
 | |
|       delete file;
 | |
|       delete dep;
 | |
|       
 | |
|       _tras_file.writeat("*",1,1,sigla); 
 | |
|       leggi_record_controllo();
 | |
|       TString chiave;
 | |
|       chiave.format("%2s%d", (const char*) sigla,rec);
 | |
|       str = _record.overwrite(sigla,240);
 | |
|       str = _record.overwrite(chiave,241);
 | |
|       _tras_file.write_control_rec(str,256);
 | |
|       
 | |
|     } // if (trc.is_key((const char*) key))
 | |
|   } // if (gia_trasf == ' ')
 | |
| }
 | |
| 
 | |
| int TRic_tab::trasfer_data_tab(TLocalisamfile& file, TRectype& dep, const TString& sigla)
 | |
| { 
 | |
|   char  flag;
 | |
|   
 | |
|   if (sigla == "P2")     
 | |
|   { 
 | |
|     trasfer_data_conto(file,dep);
 | |
|   }
 | |
|   else
 | |
|     if (sigla == "P3")
 | |
|     {                
 | |
|       trasfer_data_sottoc(file,dep);
 | |
|     }
 | |
|     else
 | |
|     {  
 | |
|       file.zero();
 | |
|       file.curr() = dep;
 | |
|       
 | |
|       if (file.read() == NOERR)     
 | |
|       {   
 | |
|         flag    = _tras_file.flg_agg();
 | |
|         
 | |
|         if (flag == 'T')
 | |
|         { 
 | |
|           file.zero();
 | |
|           file.curr() = dep;
 | |
|           file.rewrite();
 | |
|         }
 | |
|         if (flag == 'D')
 | |
|         {                     
 | |
|           if (file.num() != LF_RCAUSALI)
 | |
|           {
 | |
|             for (int i = 0; i < _aggiorna.items(); i++)
 | |
|             {
 | |
|               TToken_string& data = (TToken_string&)_aggiorna[i];
 | |
|               TString fname = data.get(0);
 | |
|               TString field = data.get(1);  
 | |
|               file.put(fname,field);
 | |
|             }
 | |
|             file.rewrite();
 | |
|             _aggiorna.destroy();
 | |
|           }
 | |
|         }
 | |
|       }
 | |
|       else
 | |
|       {
 | |
|         file.zero();
 | |
|         file.curr() = dep;     
 | |
|         file.write();    
 | |
|       }
 | |
|     }
 | |
|   
 | |
|   return 0;
 | |
| }
 | |
| 
 | |
| int TRic_tab::trasfer_data_conto(TLocalisamfile& file, TRectype& dep)
 | |
| { 
 | |
|   char flag,flag_IV;
 | |
|   int  g,c;
 | |
|   
 | |
|   flag_IV = _tras_file.flg_agg_IV();
 | |
|   
 | |
|   file.zero();
 | |
|   file.curr() = dep;
 | |
|   
 | |
|   if (file.read() == NOERR)     
 | |
|   {   
 | |
|     flag    = _tras_file.flg_agg();
 | |
|     flag_IV = _tras_file.flg_agg_IV();
 | |
|     
 | |
|     if (flag == 'T')
 | |
|     { 
 | |
|       g = dep.get_int(PCN_GRUPPO);
 | |
|       c = dep.get_int(PCN_CONTO);
 | |
|       
 | |
|       if (flag_IV == 'T')
 | |
|       {
 | |
|         file.zero();
 | |
|         file.curr() = dep;
 | |
|         file.rewrite();
 | |
|       }
 | |
|       else
 | |
|       {    
 | |
|         dep.put(PCN_SEZIVD, "0");
 | |
|         dep.zero(PCN_LETTIVD);
 | |
|         dep.zero(PCN_NUMRIVD);
 | |
|         dep.zero(PCN_NUMIVD);
 | |
|         dep.put(PCN_SEZIVDOPP, "0");
 | |
|         dep.zero(PCN_LETTIVDOPP);
 | |
|         dep.zero(PCN_NUMRIVDOPP);
 | |
|         dep.zero(PCN_NUMIVDOPP);
 | |
|         file.curr() = dep;
 | |
|         file.rewrite();
 | |
|       }                
 | |
|       _tras_file.annulla_classi(g,c,TRUE);
 | |
|     }
 | |
|     if (flag == 'D')
 | |
|     { 
 | |
|       for (int i = 0; i < _aggiorna.items(); i++)
 | |
|       {
 | |
|         TToken_string& data = (TToken_string&)_aggiorna[i];
 | |
|         TString fname = data.get(0);
 | |
|         TString field = data.get(1);
 | |
|         file.put(fname,field);
 | |
|       }
 | |
|       file.rewrite();
 | |
|     }
 | |
|   }
 | |
|   else
 | |
|   { 
 | |
|     g = dep.get_int(PCN_GRUPPO);
 | |
|     c = dep.get_int(PCN_CONTO);
 | |
|     
 | |
|     if (flag_IV == 'T')
 | |
|     {
 | |
|       file.zero();
 | |
|       file.curr() = dep;
 | |
|       file.write();
 | |
|     }
 | |
|     else
 | |
|     {    
 | |
|       g = dep.get_int(PCN_GRUPPO);
 | |
|       c = dep.get_int(PCN_CONTO);
 | |
|       
 | |
|       dep.put(PCN_SEZIVD, "0");
 | |
|       dep.zero(PCN_LETTIVD);
 | |
|       dep.zero(PCN_NUMRIVD);
 | |
|       dep.zero(PCN_NUMIVD);
 | |
|       dep.put(PCN_SEZIVDOPP, "0");
 | |
|       dep.zero(PCN_LETTIVDOPP);
 | |
|       dep.zero(PCN_NUMRIVDOPP);
 | |
|       dep.zero(PCN_NUMIVDOPP);
 | |
|       file.curr() = dep;
 | |
|       file.write();
 | |
|     }                
 | |
|     _tras_file.annulla_classi(g,c,TRUE);
 | |
|   }
 | |
|   return 0;
 | |
| }
 | |
| 
 | |
| int TRic_tab::trasfer_data_sottoc(TLocalisamfile& file, TRectype& dep)
 | |
| { 
 | |
|   char flag,flag_IV;
 | |
|   int  g,c;
 | |
|   char sez;
 | |
|   
 | |
|   sez     = dep.get_char(PCN_SEZIVD);                                    
 | |
|   flag_IV = _tras_file.flg_agg_IV();
 | |
|   
 | |
|   file.zero();
 | |
|   file.curr() = dep;
 | |
|   
 | |
|   if (file.read() == NOERR)     
 | |
|   {   
 | |
|     flag    = _tras_file.flg_agg();
 | |
|     flag_IV = _tras_file.flg_agg_IV();
 | |
|     
 | |
|     if (flag == 'T')
 | |
|     { 
 | |
|       g = dep.get_int(PCN_GRUPPO);
 | |
|       c = dep.get_int(PCN_CONTO);
 | |
|       
 | |
|       if (flag_IV == 'T')
 | |
|       {   
 | |
|         if (sez != '0')
 | |
|           _tras_file.annulla_classi(g,c,FALSE);
 | |
|         
 | |
|         file.zero();
 | |
|         file.curr() = dep;
 | |
|         file.rewrite();
 | |
|       }
 | |
|       else
 | |
|       {    
 | |
|         dep.put(PCN_SEZIVD, "0");
 | |
|         dep.zero(PCN_LETTIVD);
 | |
|         dep.zero(PCN_NUMRIVD);
 | |
|         dep.zero(PCN_NUMIVD);
 | |
|         dep.put(PCN_SEZIVDOPP, "0");
 | |
|         dep.zero(PCN_LETTIVDOPP);
 | |
|         dep.zero(PCN_NUMRIVDOPP);
 | |
|         dep.zero(PCN_NUMIVDOPP);
 | |
|         file.curr() = dep;
 | |
|         file.rewrite();
 | |
|       }
 | |
|     }
 | |
|     if (flag == 'D')
 | |
|     { 
 | |
|       for (int i = 0; i < _aggiorna.items(); i++)
 | |
|       {
 | |
|         TToken_string& data = (TToken_string&)_aggiorna[i];
 | |
|         TString fname = data.get(0);
 | |
|         TString field = data.get(1);
 | |
|         file.put(fname,field);
 | |
|       }
 | |
|       file.rewrite();
 | |
|     }
 | |
|   }
 | |
|   else
 | |
|   { 
 | |
|     g = dep.get_int(PCN_GRUPPO);
 | |
|     c = dep.get_int(PCN_CONTO);
 | |
|     
 | |
|     if (flag_IV == 'T')
 | |
|     { 
 | |
|       if (sez != '0')
 | |
|         _tras_file.annulla_classi(g,c,FALSE);
 | |
|       
 | |
|       file.zero();
 | |
|       file.curr() = dep;
 | |
|       file.write();
 | |
|     }
 | |
|     else
 | |
|     {    
 | |
|       g = dep.get_int(PCN_GRUPPO);
 | |
|       c = dep.get_int(PCN_CONTO);
 | |
|       
 | |
|       dep.put(PCN_SEZIVD, "0");
 | |
|       dep.zero(PCN_LETTIVD);
 | |
|       dep.zero(PCN_NUMRIVD);
 | |
|       dep.zero(PCN_NUMIVD);
 | |
|       dep.put(PCN_SEZIVDOPP, "0");
 | |
|       dep.zero(PCN_LETTIVDOPP);
 | |
|       dep.zero(PCN_NUMRIVDOPP);
 | |
|       dep.zero(PCN_NUMIVDOPP);
 | |
|       file.curr() = dep;
 | |
|       file.write();
 | |
|     }                
 | |
|   }
 | |
|   return 0;
 | |
| }                                
 | |
| 
 | |
| long TRic_tab::esiste_numreg(long numulreg)
 | |
| { 
 | |
|   TLocalisamfile mov (LF_MOV);
 | |
|   
 | |
|   do
 | |
|   {
 | |
|     numulreg++;
 | |
|     
 | |
|     mov.setkey(1);
 | |
|     mov.zero();
 | |
|     mov.put(MOV_NUMREG, numulreg);
 | |
|   }
 | |
|   while (mov.read() == NOERR);
 | |
|   
 | |
|   return numulreg;
 | |
| }
 | |
| 
 | |
| void TRic_tab::num_protocollo(TString& record)
 | |
| {
 | |
|   _protiva  = atol(record.sub(36,41));
 | |
|   _uprotiva = atol(record.sub(108,113));
 | |
|   
 | |
|   if (_protiva == 0)
 | |
|     _uprotiva = 0;
 | |
|   
 | |
|   _nprotiva  = _protiva;
 | |
|   _nuprotiva = _uprotiva;
 | |
| }                        
 | |
| 
 | |
| long TRic_tab::ulnumprot_reg(int anno,TString& cr)
 | |
| {
 | |
|   //TString cr = format("%c", codreg);
 | |
|   TRegistro rg (cr, anno);   
 | |
|   
 | |
|   return rg.protocol();
 | |
| }
 | |
| 
 | |
| void TRic_tab::aggiorna_reg(int anno,TString& codreg,long ulnum)
 | |
| {
 | |
|   TTable reg ("REG");
 | |
|   TString16 dep;
 | |
|   
 | |
|   if (real::is_natural(codreg)) 
 | |
|     dep.format("%04d%03s", anno,(const char*) codreg);
 | |
|   else
 | |
|     dep.format("%04d%-3s", anno,(const char*) codreg);
 | |
|   
 | |
|   reg.zero();
 | |
|   reg.put("CODTAB", (const char*) dep);
 | |
|   if (reg.read() == NOERR)
 | |
|   {
 | |
|     if (_nprotiva > (ulnum + 1) )
 | |
|       reg.put("I5", _nprotiva);
 | |
|     
 | |
|     if (_nuprotiva > (ulnum + 1) )
 | |
|       reg.put("I5", _nuprotiva);
 | |
|     
 | |
|     reg.rewrite();
 | |
|   }  
 | |
| }
 | |
| 
 | |
| void TRic_tab::controlli_prima_nota(TString& record,TString& codreg)
 | |
| { 
 | |
|   TTable tpd ("%TPD");
 | |
|   bool      corrisp;
 | |
|   TDate     datareg;  
 | |
|   int       anno;
 | |
|   long      ulnum = 0;
 | |
|   TString16 tmp;
 | |
|   TString   tipodoc;
 | |
|   
 | |
|   int     tiporeg = atoi(record.sub(222,223));                  
 | |
| 
 | |
|   TString80 tmpmov = "%";
 | |
|   tmpmov  << _tras_file.path(_dittaric);
 | |
|   tmpmov << "\\" << TEMP_MOV;
 | |
|   
 | |
|   TIsamtempfile tmp_mov (LF_MOV, tmpmov, FALSE);
 | |
|   
 | |
|   tmp_mov.zero();
 | |
|   tmp_mov.put(MOV_NUMREG, _numreg);
 | |
|   if (tmp_mov.read() == NOERR)
 | |
|   {
 | |
|     codreg  = tmp_mov.get(MOV_REG);  
 | |
|     tipodoc = tmp_mov.get(MOV_TIPODOC);                   
 | |
|   }
 | |
| 
 | |
|   tmp             = record.sub(15,21);
 | |
|   TString data    = converti(tmp);
 | |
|   datareg         = data;
 | |
|   anno            = datareg.year();
 | |
|   
 | |
|   bool numprot_att = _tras_file.numprot_att(); 
 | |
|   bool numprot_pas = _tras_file.numprot_pas(); 
 | |
|   
 | |
|   tpd.zero();
 | |
|   tpd.put("CODTAB", (const char*) tipodoc);
 | |
|   if (tpd.read() == NOERR)
 | |
|     corrisp = tpd.get_bool("B0");
 | |
|   
 | |
|   if (codreg != "" && !corrisp)
 | |
|   {
 | |
|     if ( ( (tiporeg == 1 && (numprot_att || _protiva == 0) ) )
 | |
|         || ( (tiporeg == 2 && (numprot_pas || _protiva == 0) ) ) )
 | |
|     {              
 | |
|       ulnum = ulnumprot_reg(anno,codreg);
 | |
|       _nprotiva = ulnum + 1;
 | |
|       if (_uprotiva != 0)
 | |
|         _nuprotiva = (_nprotiva - ulnum) + _uprotiva;
 | |
|     }                                     
 | |
|   }
 | |
|   
 | |
|   aggiorna_reg(anno,codreg,ulnum);
 | |
| }
 | |
| 
 | |
| void TRic_tab::datafine_esprec(const int aep, TDate& datacomp)
 | |
| {
 | |
|   TTable esc("ESC");
 | |
|   for (int err = esc.first(); err == NOERR; err = esc.next())
 | |
|   {
 | |
|     const anno = esc.get_int("CODTAB");  
 | |
|     if (anno == aep)
 | |
|       datacomp = esc.get("D1");
 | |
|   } 
 | |
| }
 | |
| 
 | |
| int TRic_tab::annoes_datacomp(const TString& record, TDate& datacomp)
 | |
| { 
 | |
|   TString tmp;   
 | |
|   int     segn;
 | |
|   int     ae = 0;
 | |
|   
 | |
|   tmp          = record.sub(15,21);
 | |
|   TString data = converti(tmp);
 | |
|   _datareg      = data;
 | |
|   segn         = atoi(record.sub(21,22));  
 | |
|   
 | |
|   ae = date2esc(_datareg);
 | |
|   if (segn == 0)
 | |
|     datacomp = _datareg;
 | |
|   
 | |
|   if (segn == 1)
 | |
|   {
 | |
|     ae -= 1;
 | |
|     datafine_esprec(ae,datacomp);
 | |
|   }
 | |
|   return ae;
 | |
| }
 | |
| 
 | |
| long TRic_tab::ultima_registrazione()
 | |
| { 
 | |
|   if (_nreg == 0)
 | |
|   {
 | |
|     TLocalisamfile mov (LF_MOV);
 | |
|     
 | |
|     mov.last();
 | |
|     return (mov.get_long(MOV_NUMREG));
 | |
|   }                                
 | |
|   else
 | |
|     return _nreg;
 | |
| }
 | |
| 
 | |
| char TRic_tab::ricerca_causale(TString& causale)
 | |
| {  
 | |
|   TLocalisamfile cau (LF_CAUSALI);
 | |
|   char    movap = ' ';
 | |
|   
 | |
|   if (real::is_natural(causale))
 | |
|     causale.format("%03s", (const char*) causale);
 | |
|   else
 | |
|     causale.format("%-3s", (const char*) causale);
 | |
|   
 | |
|   cau.setkey(1);
 | |
|   cau.zero();
 | |
|   cau.put("CODCAUS", causale);
 | |
|   if (cau.read() == NOERR)
 | |
|     movap = cau.get_char("MOVAP");
 | |
|   
 | |
|   return movap;
 | |
| }
 | |
| 
 | |
| void TRic_tab::prepara_saldi(const TString& fname,const TString& field)
 | |
| {
 | |
|   if (fname == "GRUPPO")
 | |
|     _g = atoi(field);
 | |
|   
 | |
|   if (fname == "CONTO")
 | |
|     _c = atoi(field);
 | |
|   
 | |
|   if (fname == "SOTTOCONTO")
 | |
|     _s = atol(field);
 | |
|   
 | |
|   if (fname == "SEZIONE")
 | |
|     _sez = field[0];
 | |
|   
 | |
|   if (fname == "IMPORTO")
 | |
|   {
 | |
|     real imp = real::ita2eng(field);  
 | |
|     _importo = imp;
 | |
|     TString i = _importo.string();
 | |
|   }
 | |
| }
 | |
| 
 | |
| void TRic_tab::scrivi_record_mov(TString& record,long rec)
 | |
| {
 | |
|   TString sigla,key,str,codreg;
 | |
|   int     numfield = 3; //Per i movimenti i primi due campi della mappa non sono significativi
 | |
|   //ai fini del trasferimento (flag record gia trasferito e nuovo ultimo numero di registrazione). 
 | |
|   TMappa_trc&       trc  = _tras_file.mappa();
 | |
|   TLocalisamfile*   file = NULL; 
 | |
|   TRectype*         dep  = NULL;
 | |
|   char              gia_trasf,annullato;
 | |
|   int               logicnum;
 | |
|   long              numulreg;   
 | |
|   TDate             datacomp;
 | |
|   TString           nreg;
 | |
|   int               fnrmov = 14;
 | |
|   
 | |
|   sigla     = record.mid(0,2);
 | |
|   annullato = record.mid(248,1)[0];
 | |
|   
 | |
|   if (annullato == ' ')   
 | |
|   {   
 | |
|     key.format("%2s%d", (const char*)sigla,numfield);
 | |
|     
 | |
|     if (trc.is_key((const char *) key)) 
 | |
|     {    
 | |
|       int logicnum_p = 0;             
 | |
|       
 | |
|       _numreg = atol(record.sub(2,8));
 | |
|       
 | |
|       if (_numreg != _numreg_p)
 | |
|       { 
 | |
|         if (_numreg_p != 0)             
 | |
|         {
 | |
|           _sld.registra();
 | |
|           _sld.reset();
 | |
|         }
 | |
|         
 | |
|         long nuovareg = atol(record.sub(250,256));
 | |
|         
 | |
|         if (nuovareg == 0)
 | |
|         {
 | |
|           numulreg = ultima_registrazione(); //reperisco il numero ultima registrazione
 | |
|           _nreg = esiste_numreg(numulreg);
 | |
|           num_protocollo(record);
 | |
|           controlli_prima_nota(record,codreg);
 | |
|         }
 | |
|         else
 | |
|         {
 | |
|           _nreg = nuovareg;
 | |
|           numfield = fnrmov;
 | |
|           key.format("%2s%d", (const char*)sigla,numfield);
 | |
|         }
 | |
|       }
 | |
|       else
 | |
|       {
 | |
|         numfield = fnrmov;
 | |
|         key.format("%2s%d", (const char*)sigla,numfield);
 | |
|       }
 | |
|       
 | |
|       _annoes = annoes_datacomp(record,datacomp); 
 | |
|       _numreg_p = _numreg;   
 | |
|       gia_trasf = record.sub(249,250)[0];
 | |
|       
 | |
|       if (gia_trasf == ' ')
 | |
|       {
 | |
|         do
 | |
|         {  
 | |
|           logicnum = trc.logicnum(key);
 | |
|           
 | |
|           if (logicnum != logicnum_p)
 | |
|           {
 | |
|             if (logicnum_p)
 | |
|             {
 | |
|               trasfer_data_mov(*file, *dep);
 | |
|               nreg.format("%6d",_nreg);
 | |
|               _tras_file.writeat(nreg,6,2,sigla); 
 | |
|               aggiorna_temp_file(_numreg,_nreg);
 | |
|               delete file;
 | |
|               delete dep;
 | |
|             }
 | |
| 
 | |
|             file = new TLocalisamfile(logicnum);
 | |
|             dep  = new TRectype (logicnum);
 | |
|             dep->zero();
 | |
|           }                                                 
 | |
|           
 | |
|           logicnum_p = logicnum;                                                
 | |
|           
 | |
|           if (logicnum == 24 && numfield == 26)
 | |
|           {
 | |
|             numfield++;
 | |
|             key.format("%2s%d", (const char*) sigla,numfield);
 | |
|             continue;
 | |
|           }
 | |
|           
 | |
|           int     from  = trc.from(key);
 | |
|           int     to    = trc.to(key);
 | |
|           TString fname = trc.field_name(key); 
 | |
|           TString field = record.sub(from-1,to); 
 | |
|           int     flag  = trc.flag(key);
 | |
|           int     dec   = trc.flag_bis(key);
 | |
|           
 | |
|           if (flag == 3)
 | |
|           { 
 | |
|             if (dec > 0)
 | |
|               decimali(field,dec);
 | |
|             
 | |
|             real appoggio (field);
 | |
|             field = appoggio.string();
 | |
|           }
 | |
|           
 | |
|           if (logicnum == LF_MOV)
 | |
|           {
 | |
|             if (fname == "REG")
 | |
|             {                         
 | |
|               if (real::is_natural(codreg))
 | |
|                 field.format("%03s", (const char*) codreg);
 | |
|               else
 | |
|                 field.format("%-3s", (const char*) codreg);
 | |
|             }                           
 | |
| 
 | |
|             //Il codice pagamento su AS400 e' un alfanumerico di due, mentre su PC e' un
 | |
|             //alfanumerico di 4 trattato con il flag Z. Dunque in ricezione se si tratta
 | |
|             //di un numero va riempito con degli 0. Se si tratta di un alfa va allineato a destra.                       
 | |
|             if (fname == "CODPAG")
 | |
|             { 
 | |
|               TString f = field;
 | |
|               if (real::is_natural(f))
 | |
|                 field.format("%04s", (const char*) f);
 | |
|               else
 | |
|                 field.format("%-4s", (const char*) f);
 | |
|             }
 | |
|           }
 | |
| 
 | |
|           if (logicnum == LF_RMOV)
 | |
|             prepara_saldi(fname,field);
 | |
|           
 | |
|           if (fname == "PROTIVA") 
 | |
|           { 
 | |
|             char var[6];
 | |
|             sprintf(var,"%5d",_nprotiva);
 | |
|             field = var;
 | |
|           }  
 | |
|           if (fname == "UPROTIVA")  
 | |
|           {
 | |
|             char var[6];
 | |
|             sprintf(var,"%5d",_nuprotiva);
 | |
|             field = var;
 | |
|           }
 | |
|           
 | |
|           
 | |
|           if (logicnum == LF_MOV && fname == "CODCAUS")
 | |
|           {
 | |
|             _sld.set_anno_es(_annoes);
 | |
|             _sld.set_movprovv(FALSE);
 | |
|             _sld.set_num_ulmov(_nreg);
 | |
|             _sld.set_data_ulmov(_datareg);
 | |
|             char movap = ricerca_causale(field);
 | |
|             if (movap == 'A')
 | |
|               _sld.set_movap(TRUE);
 | |
|           }
 | |
|           
 | |
|           if (logicnum == LF_MOV && (fname == "NUMREG" || flag == 2) ) 
 | |
|           {                       
 | |
|             if (fname == "NUMREG") 
 | |
|             {
 | |
|               dep->put(MOV_ANNOES,   _annoes);                                     
 | |
|               dep->put(MOV_NUMREG,   _nreg);
 | |
|               dep->put(MOV_DATAREG,  _datareg);
 | |
|               dep->put(MOV_DATACOMP, datacomp);
 | |
|             }
 | |
|             if (flag == 2)
 | |
|             {
 | |
|               TString f = converti(field);
 | |
|               dep->put(fname,f);
 | |
|             }
 | |
|           }
 | |
|           else  
 | |
|             if (logicnum == LF_RMOV && (fname == "NUMREG" || fname == "NUMRIG") ) 
 | |
|             {                        
 | |
|               if (fname == "NUMREG")
 | |
|               {   
 | |
|                 dep->put(RMV_ANNOES,  _annoes);                                     
 | |
|                 dep->put(RMV_NUMREG,  _nreg);
 | |
|               }
 | |
| 
 | |
|               if (fname == "NUMRIG")
 | |
|               {
 | |
|                 dep->put(RMV_NUMRIG,  field);  
 | |
|                 dep->put(RMV_DATAREG, _datareg);
 | |
|               }
 | |
|             }
 | |
|             else
 | |
|               dep->put(fname, field);
 | |
|           
 | |
|           numfield++;
 | |
|           key.format("%2s%d", (const char*) sigla,numfield);
 | |
|         }
 | |
|         while (trc.is_key((const char*) key));
 | |
|         
 | |
|         _prog->addstatus(1);                                  
 | |
|         trasfer_data_mov(*file, *dep);      
 | |
|         TString impor = _importo.string();
 | |
|         _sld.aggiorna(_g,_c,_s,_importo,_sez);
 | |
|         
 | |
|         delete file;
 | |
|         delete dep;
 | |
|         
 | |
|         _tras_file.writeat("*",1,1,sigla);        
 | |
|         nreg.format("%6d",_nreg);
 | |
|         _tras_file.writeat(nreg,6,2,sigla);  
 | |
|         //aggiorna_temp_file(_numreg,_nreg);
 | |
|         leggi_record_controllo();
 | |
|         TString chiave;
 | |
|         chiave.format("%2s%d", (const char*) sigla,rec);
 | |
|         str = _record.overwrite(sigla,240);
 | |
|         str = _record.overwrite(chiave,241);
 | |
|         _tras_file.write_control_rec(str,256);
 | |
|       } // if (gia_trasf == ' ')
 | |
|     } // if (trc.is_key((const char*) key))
 | |
|   } // if (gia_trasf == ' ')
 | |
| }
 | |
| 
 | |
| int TRic_tab::trasfer_data_mov(TLocalisamfile& file, TRectype& dep)
 | |
| {  
 | |
|   file.zero();
 | |
|   file.curr() = dep;
 | |
|   
 | |
|   if (file.read() == NOERR)     
 | |
|   { 
 | |
|     file.zero();
 | |
|     file.curr() = dep;
 | |
|     file.rewrite();
 | |
|   }
 | |
|   else
 | |
|   {
 | |
|     file.zero();
 | |
|     file.curr() = dep;     
 | |
|     file.write();    
 | |
|   }
 | |
|   return 0;
 | |
| }
 | |
| 
 | |
| void TRic_tab::aggiorna_temp_file(long numreg, long nreg)
 | |
| {
 | |
|   TString80 tmpmov = "%";
 | |
|   tmpmov  << _tras_file.path(_dittaric);
 | |
|   tmpmov << "\\" << TEMP_MOV;
 | |
|   
 | |
|   TIsamtempfile tmp_mov (LF_MOV, tmpmov, FALSE);
 | |
|   
 | |
|   tmp_mov.zero();
 | |
|   tmp_mov.put(MOV_NUMREG, numreg);
 | |
|   if (tmp_mov.read() == NOERR)
 | |
|   {
 | |
|     tmp_mov.put(MOV_CODCF, nreg);
 | |
|     tmp_mov.rewrite();
 | |
|   }
 | |
| }
 | |
| 
 | |
| long TRic_tab::numrec_PN(long numreg)
 | |
| {   
 | |
|   long num = 0;
 | |
|   
 | |
|   TString80 tmpmov = "%";
 | |
|   tmpmov  << _tras_file.path(_dittaric);
 | |
|   tmpmov << "\\" << TEMP_MOV;
 | |
|   
 | |
|   TIsamtempfile tmp_mov (LF_MOV, tmpmov, FALSE);
 | |
|   
 | |
|   tmp_mov.zero();
 | |
|   tmp_mov.put(MOV_NUMREG, numreg);
 | |
|   if (tmp_mov.read() == NOERR)
 | |
|     num = tmp_mov.get_long(MOV_NUMGIO);
 | |
|   
 | |
|   return num;
 | |
| }                           
 | |
| 
 | |
| long TRic_tab::numreg_PN(long numreg)
 | |
| {   
 | |
|   long num = 0;
 | |
|   
 | |
|   TString80 tmpmov = "%";
 | |
|   tmpmov  << _tras_file.path(_dittaric);
 | |
|   tmpmov << "\\" << TEMP_MOV;
 | |
|   
 | |
|   TIsamtempfile tmp_mov (LF_MOV, tmpmov, FALSE);
 | |
|   
 | |
|   tmp_mov.zero();
 | |
|   tmp_mov.put(MOV_NUMREG, numreg);
 | |
|   if (tmp_mov.read() == NOERR)
 | |
|     num = tmp_mov.get_long(MOV_CODCF);
 | |
|   
 | |
|   return num;
 | |
| }                           
 | |
| 
 | |
| void TRic_tab::recupera_dati_testata(long numreg)
 | |
| {
 | |
|   TLocalisamfile mov (LF_MOV);
 | |
|   
 | |
|   mov.setkey(1);
 | |
|   mov.zero();
 | |
|   mov.put(MOV_NUMREG, numreg);
 | |
|   if (mov.read() == NOERR)
 | |
|   {
 | |
|     _dreg   = mov.get_date(MOV_DATAREG);
 | |
|     _ddoc   = mov.get_date(MOV_DATADOC);
 | |
|     _ndoc   = mov.get_long(MOV_NUMDOC);
 | |
|     _creg   = mov.get     (MOV_REG);
 | |
|     _ccau   = mov.get     (MOV_CODCAUS);
 | |
|     _tdoc   = mov.get     (MOV_TIPODOC);
 | |
|     _npiva  = mov.get_long(MOV_PROTIVA);
 | |
|     _nupiva = mov.get_long(MOV_UPROTIVA);
 | |
|     _totdoc = mov.get_real(MOV_TOTDOC);
 | |
|   }
 | |
| }
 | |
| 
 | |
| bool TRic_tab::occasionali(const TString& record)
 | |
| {
 | |
|   TLocalisamfile occas (LF_OCCAS);
 | |
|   TString ragsoc;        
 | |
|   long    num;
 | |
|   
 | |
|   ragsoc = record.sub(61,86);
 | |
|   ragsoc.trim();
 | |
|   
 | |
|   if (ragsoc == "") return FALSE;
 | |
|   
 | |
|   occas.setkey(1);
 | |
|   occas.zero();
 | |
|   occas.put("CFPI", "RIC999999");
 | |
|   if (occas.read() == NOERR)
 | |
|     num = 0;
 | |
|   else
 | |
|     if ( (occas.get("CFPI")).len() > 9)
 | |
|     {
 | |
|       occas.prev();
 | |
|       if ( (occas.get("CFPI")).len() > 9)
 | |
|         num = 0;
 | |
|       else
 | |
|       {
 | |
|         TString cfpi = occas.get("CFPI");
 | |
|         
 | |
|         if (cfpi.mid(0,3) == "RIC" && cfpi.len() == 9)
 | |
|         {
 | |
|           num = atol(cfpi.mid(3,6));
 | |
|           num += 1;
 | |
|         }
 | |
|         else
 | |
|           num = 0;
 | |
|       }
 | |
|     }         
 | |
|     else
 | |
|     {
 | |
|       TString cfpi = occas.get("CFPI");
 | |
|       
 | |
|       if (cfpi.mid(0,3) == "RIC" && cfpi.len() == 9)
 | |
|       {
 | |
|         num = atol(cfpi.mid(3,6));
 | |
|         num += 1;
 | |
|       }
 | |
|       else
 | |
|         num = 0;
 | |
|     }
 | |
|   
 | |
|   scrivi_occasionali(record,num);
 | |
|   
 | |
|   return TRUE;  
 | |
| }
 | |
| 
 | |
| void TRic_tab::scrivi_occasionali(const TString& record, long num)
 | |
| {
 | |
|   TLocalisamfile occas (LF_OCCAS);
 | |
|   TString cfpi,ragsoc,ind,com,cap,app; 
 | |
|   int     err;
 | |
|   
 | |
|   app = "RIC";
 | |
|   cfpi.format("%3s%6d", (const char*)app,num);
 | |
|   ragsoc = record.sub(61,86);
 | |
|   ind    = record.sub(86,108);
 | |
|   com    = record.sub(108,126);
 | |
|   cap    = record.sub(126,131);
 | |
|   
 | |
|   ricerca_comune(com);
 | |
|   
 | |
|   occas.setkey(1);
 | |
|   occas.zero();
 | |
|   occas.put("CFPI", cfpi);
 | |
|   occas.put("RAGSOC", ragsoc);
 | |
|   occas.put("INDIR", ind);
 | |
|   occas.put("CAP", cap);  
 | |
|   if (_cod_com != "")
 | |
|     occas.put("COM", _cod_com);
 | |
|   
 | |
|   err = occas.write();
 | |
|   
 | |
|   if (err == _isreinsert)
 | |
|     err = occas.rewrite();
 | |
| }
 | |
| 
 | |
| void TRic_tab::ricerca_comune(const TString& com)
 | |
| {
 | |
|   TLocalisamfile comuni (LF_COMUNI);
 | |
|   
 | |
|   comuni.setkey(2);
 | |
|   comuni.zero();
 | |
|   comuni.put(COM_DENCOM, com);
 | |
|   if (comuni.read() == NOERR)
 | |
|     _cod_com = comuni.get(COM_COM);
 | |
|   else
 | |
|     _cod_com = "";
 | |
| }
 | |
| 
 | |
| int TRic_tab::cerca_annoes(long numreg)
 | |
| {
 | |
|   TLocalisamfile mov (LF_MOV);
 | |
|   int anno = 0;
 | |
|   
 | |
|   mov.setkey(1);
 | |
|   mov.zero();
 | |
|   mov.put(MOV_NUMREG, numreg);
 | |
|   if (mov.read() == NOERR)
 | |
|     anno = mov.get_int(MOV_ANNOES);
 | |
|   
 | |
|   return anno;
 | |
| }
 | |
| 
 | |
| void TRic_tab::salva_dati_testata()
 | |
| {
 | |
|   TString str,app;
 | |
|   long    numrec;
 | |
|   
 | |
|   numrec =  numrec_PN(_numreg);
 | |
|   numrec += _tras_file.start('Z');
 | |
|   
 | |
|   _tras_file.read_rec_trasfer(numrec); //Leggo il record della prima nota
 | |
|   
 | |
|   app = _dreg.string();
 | |
|   str = riconverti(app);
 | |
|   _tras_file.put(str,"Z1",0,numrec);
 | |
|   app = _ddoc.string();
 | |
|   str = riconverti(app);
 | |
|   _tras_file.put(str,"Z1",4,numrec);
 | |
|   str = format("%ld", _ndoc);
 | |
|   _tras_file.put(str,"Z1",5,numrec);
 | |
|   _tras_file.put(_creg,"Z1",6,numrec);
 | |
|   _tras_file.put(_ccau,"Z1",8,numrec);
 | |
|   _tras_file.put(_tdoc,"Z1",12,numrec);
 | |
|   str = format("%ld", _npiva);
 | |
|   _tras_file.put(str,"Z1",7,numrec);
 | |
|   str = format("%ld", _nupiva);
 | |
|   _tras_file.put(str,"Z1",10,numrec);
 | |
|   str = _totdoc.string();
 | |
|   _tras_file.put(str,"Z1",13,numrec);
 | |
|   _tras_file.write(numrec);
 | |
| }
 | |
| 
 | |
| void TRic_tab::decimali(TString& campo, int dec)
 | |
| {
 | |
|   int l = campo.len();
 | |
|   int p = l - dec;
 | |
|   campo.insert(".",p);
 | |
| }
 | |
| 
 | |
| void TRic_tab::scrivi_record_moviva(TString& record,long rec)
 | |
| {
 | |
|   TString sigla,key,str;
 | |
|   int     numfield = 3; //Per i movimenti i primi due campi della mappa non sono significativi
 | |
|   //ai fini del trasferimento (flag record gia trasferito e nuovo ultimo numero di registrazione).  
 | |
|   TMappa_trc&       trc  = _tras_file.mappa();
 | |
|   TLocalisamfile*   file = NULL; 
 | |
|   TRectype*         dep  = NULL;
 | |
|   char              gia_trasf,annullato;
 | |
|   int               logicnum;
 | |
|   TString           nreg;
 | |
|   int               fnrmiva = 11;
 | |
|   
 | |
|   sigla     = record.mid(0,2);
 | |
|   annullato = record.mid(248,1)[0];
 | |
|   
 | |
|   if (annullato == ' ')   
 | |
|   {   
 | |
|     key.format("%2s%d", (const char*)sigla,numfield);
 | |
|     
 | |
|     if (trc.is_key((const char *) key)) 
 | |
|     {    
 | |
|       int logicnum_p = 0;             
 | |
|       
 | |
|       _numreg = atol(record.sub(2,8));
 | |
|       
 | |
|       if (_numreg != _numreg_piva)
 | |
|       { 
 | |
|         long nuovareg = atol(record.sub(250,256));
 | |
|         
 | |
|         if (nuovareg == 0)
 | |
|           _nreg = numreg_PN(_numreg);
 | |
|         else
 | |
|         {
 | |
|           _nreg = nuovareg;
 | |
|           //recupera_dati_testata(_nreg);
 | |
|           numfield = fnrmiva;
 | |
|           key.format("%2s%d", (const char*)sigla,numfield);
 | |
|         }   
 | |
|         recupera_dati_testata(_nreg);
 | |
|       }
 | |
|       else
 | |
|       {
 | |
|         numfield = fnrmiva;
 | |
|         key.format("%2s%d", (const char*)sigla,numfield);
 | |
|       }
 | |
|       
 | |
|       _numreg_piva = _numreg;   
 | |
|       gia_trasf = record.sub(249,250)[0];
 | |
|       
 | |
|       if (gia_trasf == ' ' || _ccau != "000")
 | |
|       {
 | |
|         
 | |
|         occasionali(record);
 | |
|         
 | |
|         do
 | |
|         {  
 | |
|           logicnum = trc.logicnum(key);
 | |
|           
 | |
|           if (logicnum != logicnum_p)
 | |
|           {
 | |
|             if (logicnum_p)
 | |
|             {
 | |
|               trasfer_data_moviva(*file, *dep, logicnum_p);
 | |
|               nreg.format("%6d",_nreg);
 | |
|               _tras_file.writeat(nreg,6,2,sigla);     
 | |
|               salva_dati_testata();
 | |
|               delete file;
 | |
|               delete dep;
 | |
|             }
 | |
| 
 | |
|             file = new TLocalisamfile(logicnum);
 | |
|             dep  = new TRectype (logicnum);
 | |
|             dep->zero();
 | |
|           }                                                 
 | |
|           
 | |
|           logicnum_p = logicnum;                                                
 | |
|           
 | |
|           int     from  = trc.from(key);
 | |
|           int     to    = trc.to(key);
 | |
|           TString fname = trc.field_name(key); 
 | |
|           TString field = record.sub(from-1,to); 
 | |
|           int     flag  = trc.flag(key);
 | |
|           int     dec   = trc.flag_bis(key);
 | |
|           
 | |
|           if (logicnum == LF_MOV && fname == "TOTDOC")
 | |
|           {
 | |
|             numfield++;
 | |
|             key.format("%2s%d", (const char*) sigla,numfield);
 | |
|             continue;
 | |
|           }
 | |
|           
 | |
|           if (flag == 3)
 | |
|           {
 | |
|             if (dec > 0)
 | |
|               decimali(field,dec);
 | |
|             
 | |
|             real appoggio (field);
 | |
|             field = appoggio.string();  
 | |
|           }                           
 | |
|           
 | |
|           if (logicnum == LF_MOV && ( fname == "NUMREG" || flag == 1 ) ) 
 | |
|           {  
 | |
|             if (fname == "NUMREG")
 | |
|               dep->put("NUMREG",   _nreg);
 | |
|             
 | |
|             if (flag == 1)
 | |
|             {
 | |
|               TString f = converti(field);
 | |
|               dep->put(fname,f);
 | |
|             }                                       
 | |
|           }
 | |
|           else
 | |
|             if (logicnum == LF_RMOVIVA && fname == "NUMREG")
 | |
|             {
 | |
|               int annoes = cerca_annoes(_nreg);                    
 | |
|               dep->put("ANNOES",   annoes);                                     
 | |
|               dep->put("NUMREG",   _nreg);
 | |
|             }
 | |
|             else
 | |
|               dep->put(fname, field);          
 | |
|           
 | |
|           numfield++;
 | |
|           key.format("%2s%d", (const char*) sigla,numfield);
 | |
|         }
 | |
|         while (trc.is_key((const char*) key));
 | |
|         
 | |
|         _prog->addstatus(1);                                  
 | |
|         trasfer_data_moviva(*file, *dep, logicnum_p);      
 | |
|         TString impor = _importo.string();
 | |
|         
 | |
|         delete file;
 | |
|         delete dep;
 | |
|         
 | |
|         _tras_file.read_rec_trasfer(rec); //Per essere sicuro di essere posizionato sul record giusto dell'iva sul trasfer
 | |
|         _tras_file.writeat("*",1,1,sigla);        
 | |
|         nreg.format("%6d",_nreg);
 | |
|         _tras_file.writeat(nreg,6,2,sigla);  
 | |
|         leggi_record_controllo();
 | |
|         TString chiave;
 | |
|         chiave.format("%2s%d", (const char*) sigla,rec);
 | |
|         str = _record.overwrite(sigla,240);
 | |
|         str = _record.overwrite(chiave,241);
 | |
|         _tras_file.write_control_rec(str,256);
 | |
|       } // if (gia_trasf == ' ')
 | |
|     } // if (trc.is_key((const char*) key))
 | |
|   } // if (gia_trasf == ' ')
 | |
| }
 | |
| 
 | |
| int TRic_tab::trasfer_data_moviva(TLocalisamfile& file, TRectype& dep, int ln)
 | |
| {   
 | |
|   file.zero();
 | |
|   file.curr() = dep;
 | |
|   
 | |
|   if (file.read() == NOERR)     
 | |
|   { 
 | |
|     if (ln == LF_MOV)
 | |
|     { 
 | |
|       TDate   data74ter (dep.get_date(MOV_DATA74TER));
 | |
|       TString codval    (dep.get     (MOV_CODVAL));
 | |
|       long    codcf     = dep.get_long(MOV_CODCF);
 | |
|       real    cambioi   (dep.get_real(MOV_CAMBIOI));
 | |
|       real    corrlire  (dep.get_real(MOV_CORRLIRE));
 | |
|       real    corrvaluta(dep.get_real(MOV_CORRVALUTA));
 | |
|       
 | |
|       file.put(MOV_DATA74TER, data74ter);
 | |
|       file.put(MOV_CODVAL,    codval);
 | |
|       file.put(MOV_CODCF,     codcf);
 | |
|       file.put(MOV_CAMBIOI,   cambioi);
 | |
|       file.put(MOV_CORRLIRE,  corrlire);
 | |
|       file.put(MOV_CORRVALUTA,corrvaluta);
 | |
|       
 | |
|       file.rewrite();
 | |
|     }
 | |
|     else
 | |
|     {
 | |
|       file.zero();
 | |
|       file.curr() = dep;
 | |
|       file.rewrite();
 | |
|     }
 | |
|   }
 | |
|   else
 | |
|   {
 | |
|     file.zero();
 | |
|     file.curr() = dep;     
 | |
|     file.write();    
 | |
|   }
 | |
|   
 | |
|   return 0;
 | |
| }
 | |
| 
 | |
| bool TRic_tab::leggi_trasfer()
 | |
| { 
 | |
|   _nultras = 0;
 | |
|   
 | |
|   _trasf = _tras_file.path(_dittaric);
 | |
|   _trasf << "\\trasfer";
 | |
|   
 | |
|   _tras_file.open(_trasf);
 | |
|   
 | |
|   if (_tras_file.exist())
 | |
|   {  
 | |
|     if (_tras_file.read_control_rec())
 | |
|     {
 | |
|       _nultras    = _tras_file.nultras();
 | |
|       _dataultras = _tras_file.dataultras();
 | |
|       _sigle_file = _tras_file.sigle_file();
 | |
|       _nrec_file  = _tras_file.nrec_file();             
 | |
|       // La fill_index e' richiamata dentro a read_control_rec      
 | |
|       //      _tras_file.fill_index(_sigle_file,_nrec_file);  
 | |
|       _uselab     = _tras_file.ult_file();
 | |
|       _key        = _tras_file.key();
 | |
|       _record     = _tras_file.record();
 | |
|     }         
 | |
| else
 | |
|   return error_box("Rilevati gravi errori negli archivi:procedura interrotta");
 | |
|   } 
 | |
| else
 | |
|   return error_box("Al momento non presenti trasferimenti attivi sulla ditta selezionata");
 | |
|   
 | |
|   return TRUE; 
 | |
| }
 | |
| 
 | |
| bool TRic_tab::video()
 | |
| {                    
 | |
|   TConfig conf(CONFIG_DITTA);           
 | |
|   
 | |
|   _std = conf.get("FlStTra");
 | |
|   
 | |
|   if (!leggi_trasfer())
 | |
|     return FALSE;
 | |
|   
 | |
|   TMask msk ("cg2600a");
 | |
|   KEY  tasto;
 | |
|   
 | |
|   ditta_ricevente();       
 | |
|   
 | |
|   msk.set(F_CODDITTA,   _dittaric);
 | |
|   msk.set(F_RAGSOC,     _ragsoc_dittar);
 | |
|   msk.set(F_NULTRAS,    _nultras);
 | |
|   TString data1 = _dataultras.string();
 | |
|   msk.set(F_DATAULTRAS, data1);         
 | |
|   msk.set(F_STD,        _std);
 | |
|   msk.set(F_USELAB,     _uselab);
 | |
|   msk.set(F_STATO,      _key);
 | |
| 
 | |
|   tasto = msk.run();
 | |
|   
 | |
|   if (tasto != K_ENTER)
 | |
|     return FALSE;
 | |
|   
 | |
|   if (!prefix().exist(_dittaric))
 | |
|     return error_box("Rilevati gravi errori negli archivi: procedura interrotta");
 | |
| 
 | |
|   if (!controlli())
 | |
|     return FALSE;     
 | |
|   
 | |
|   return TRUE;
 | |
| }
 | |
| 
 | |
| void TRic_tab::setta_parametri_record(const TString& sigla,const TString& flag)
 | |
| { 
 | |
|   TConfig conf (CONFIG_DITTA);
 | |
|   
 | |
|   conf.set("FlStTra", flag);
 | |
|   
 | |
|   leggi_record_controllo();
 | |
|   _record.overwrite(sigla,240);
 | |
|   
 | |
|   const int size = 256;
 | |
|   
 | |
|   _tras_file.write_control_rec(_record, size);
 | |
| }
 | |
| 
 | |
| bool TRic_tab::controllo_pre_ricezione()
 | |
| { 
 | |
|   TString flag;
 | |
|   
 | |
|   TString sigla = _sigle_file.mid(0,1);
 | |
|   
 | |
|   if (sigla == " ")
 | |
|   {
 | |
|     flag   = "*";
 | |
|     setta_parametri_record(sigla,flag);
 | |
|     fremove(_trasf);
 | |
|     return FALSE;
 | |
|   }              
 | |
|   
 | |
|   if (sigla == "Z")
 | |
|   {
 | |
|     flag   = "C";
 | |
|     setta_parametri_record(sigla,flag);
 | |
|     return error_box("Aggiornamento tabelle terminato: proseguire con controllo movimenti");
 | |
|   }             
 | |
|   
 | |
|   if (sigla != "Z")
 | |
|   {
 | |
|     flag   = "T";
 | |
|     setta_parametri_record(sigla,flag);
 | |
|     return TRUE;
 | |
|   }
 | |
|   
 | |
|   return TRUE;
 | |
| }
 | |
| 
 | |
| void TRic_tab::ditta_ricevente()
 | |
| {
 | |
|   TLocalisamfile nditte (LF_NDITTE);
 | |
|   
 | |
|   nditte.setkey(1);
 | |
|   nditte.zero();
 | |
|   nditte.put(NDT_CODDITTA, _dittaric);
 | |
|   if (nditte.read() == NOERR)
 | |
|     _ragsoc_dittar = nditte.get(NDT_RAGSOC);
 | |
| }
 | |
| 
 | |
| bool TRic_tab::controlli()
 | |
| { 
 | |
|   if (_scelta == 'T')
 | |
|   {
 | |
|     if (_std == "C")
 | |
|       return error_box("Aggiornamento tabelle gia' effettuato: richiamare Controllo movimenti");
 | |
|     
 | |
|     if (_std == "M")
 | |
|       return error_box("Aggiornamento tabelle gia' effettuato: richiamare Trasferimento movimenti");           
 | |
|     
 | |
|     if (_std != "" && _std != "T")
 | |
|       return error_box("Rilevati gravi errori negli archivi: procedura interrotta");
 | |
|     
 | |
|     if ( (_std == "" || _std == "T") && (_uselab == "Z" || _uselab == "U") )  
 | |
|       return error_box("Rilevati gravi errori negli archivi: procedura interrotta");
 | |
|   }
 | |
|   else
 | |
|     if (_scelta == 'M')
 | |
|     {
 | |
|       if (_std == "" || _std == "T")
 | |
|         return error_box("Aggiornamento tabelle NON EFFETTUATO: richiamare il programma relativo");
 | |
|       
 | |
|       if (_std == "C")
 | |
|         return error_box("Controllo movimenti non effettuato o rilevati errori gravi");
 | |
|       
 | |
|       if (_std == "M" && (_uselab != "Z" && _uselab != "U" && _uselab != "B") ) 
 | |
|         return error_box("Rilevati GRAVI ERRORI negli archivi: procedura interrotta");
 | |
|       
 | |
|       if (_std != "" && _std != "M")
 | |
|         error_box("Rilevati GRAVI ERRORI negli archivi: procedura interrotta");  
 | |
|     }
 | |
|   
 | |
|   if (_std == "*") 
 | |
|   {
 | |
|     warning_box("Trasferimento interamente completato: proseguire per cancellare il file");    
 | |
|     fremove(_trasf);
 | |
|     return FALSE;
 | |
|   }
 | |
|   
 | |
|   return TRUE;
 | |
| }
 | |
| 
 | |
| bool TRic_tab::menu(MENU_TAG m)
 | |
| {
 | |
|   if (m == BAR_ITEM(1))
 | |
|     return main_loop(); 
 | |
|   return FALSE;
 | |
| }
 | |
| 
 | |
| int cg2600 (int argc, char* argv[])
 | |
| {                                
 | |
|   TRic_tab main_app(*argv[2]);
 | |
|   main_app.run(argc, argv,main_app._titolo);
 | |
|   return TRUE;
 | |
| }
 |