Files correlati : ve0.exe Ricompilazione Demo : [ ] Commento : Riportata la versione 3.2 patch 1350 git-svn-id: svn://10.65.10.50/trunk@18385 c028cbd2-c16b-5b4b-a496-9718f37d4682
		
			
				
	
	
		
			3389 lines
		
	
	
		
			95 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			3389 lines
		
	
	
		
			95 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
| //
 | |
| // Ricezione dati: lista controllo movimenti
 | |
| //       
 | |
| 
 | |
| #include "cglib01.h"
 | |
| #include "cglib03.h"
 | |
| #include "cglib04.h" 
 | |
| #include "cg6700.h"
 | |
| 
 | |
| #include <mask.h>
 | |
| #include <printapp.h>
 | |
| #include <progind.h>
 | |
| #include <tabutil.h>
 | |
| //#include <utility.h> 
 | |
| #include <mailbox.h>
 | |
| 
 | |
| #include <nditte.h>
 | |
| #include <mov.h>
 | |
| 
 | |
| class TRic_ListaMov : public TPrintapp
 | |
| {
 | |
|   TTable*              _tab_tra,* _tab_pag,* _tab_tpd,* _tab_iva, *_tab_ese;
 | |
|   TIsamtempfile*       _tmov,* _trmov,* _tiva,* _tpart,* _tscad,* _tpagsca;
 | |
|   TLocalisamfile*      _caus,* _ditte,* _clifo,* _pcon, *_mov, *_rmov, *_rmoviva;
 | |
|   TLocalisamfile*      _part,* _scad,* _pagsca;
 | |
|   TRelation*           _rel, *_relSC;
 | |
|   //TCursor*           _cur, *_curSC;
 | |
|   int                  _cur, _curSC;
 | |
|   TTransfer_file*      _trasfer;
 | |
|   TLibro_giornale*     _giornale;                
 | |
|   TEsercizi_contabili  _ec;
 | |
|   char                 _ric_auto,_tipo_lista;
 | |
|   
 | |
|   TFilename        _pathfile;
 | |
|   TString          _descr_causale, _descr_conto;
 | |
|   TString16        _numdoc;
 | |
|   TString4         _codpag, _codiva, _tipo_conto, _causale, _registro, _tipodoc, _codval;
 | |
|   TString          _record, _numpart, _descr_anag, _descr_pag, _tipom_cau, _codval_part, _codpag_scad,_reg;
 | |
|   bool             _mov_sez, _errore_grave, _esiste_conto, _seconda_volta, _errore_grave_SC;
 | |
|   bool             _is_iva, _is_salda, _risposta, _continua, _intestaSC, _errore_grave_totale;
 | |
|   bool             _prima_volta,_calcola,_prima_rata_pag,_ho_stampato;
 | |
|   char             _sdt, _sezione, _tipocf, _sez, _tipocf_p;
 | |
|   int              _ae, _anno, _gruppo, _conto, _tipocr, _tipod, _tiporeg, _tipomov, _tipopag, _nriga;
 | |
|   int              _gruppoc, _contoc, _gruppocr, _contocr, _annoiva, _gruppocl, _contocl, _numrig, _annoese;
 | |
|   int              _gruppo_p, _conto_p, _anno_prec;
 | |
|   TDate            _datacomp, _datadoc, _datareg, _data74tr, _datacam, _datacam_part,_datapag;
 | |
|   real             _importo, _impo, _impos, _tot_dare, _tot_avere, _tot_doc, _tot_val;
 | |
|   real             _cambio, _cambio_part, _impo_print, _impos_print;
 | |
|   long             _codcf, _numero, _protiva, _sottoconto, _numreg;
 | |
|   long             _sottocontoc, _sottocontocr, _codcf_p;
 | |
|   TBit_array       _err;   
 | |
|   byte             _controllo;   
 | |
|   real             _imp,_impval;   
 | |
|   TString          _numpart_prec;
 | |
|   int              _tipopag_pag;                
 | |
| 
 | |
| protected:
 | |
|   char sezione_ritsoc(const TRectype& part) const;
 | |
|   real segno_ritsoc(const TRectype& part) const;
 | |
|     
 | |
| public:
 | |
|   virtual bool check_autorization() const 
 | |
|   {return FALSE;}
 | |
|   virtual          bool set_print(int m);
 | |
|   virtual          bool user_create() ;
 | |
|   virtual          bool user_destroy();
 | |
|   virtual          bool preprocess_page(int,int);
 | |
|   virtual          bool preprocess_print(int,int);  
 | |
|   virtual          print_action postprocess_page(int,int);
 | |
|   virtual          print_action postprocess_print(int file, int counter);  
 | |
|   virtual          void postclose_print();
 | |
|   char             look_sdt();
 | |
|   const char*      get_codiva_des(const char*);
 | |
|   bool             DescrConto(int,int,long);
 | |
|   bool             check_archivi();
 | |
|   bool             look_pag();
 | |
|   bool             errori_partita(int,int,long);
 | |
|   bool             controlla_mov();
 | |
|   bool             controlla_rmov();
 | |
|   bool             controlla_riva();
 | |
|   void             stampa_errori_mov(int);
 | |
|   void             stampa_errori_rmov(int);
 | |
|   void             stampa_errori_riva(int);
 | |
|   void             aggiorna_mov();                        
 | |
|   void             aggiorna_rmov(char tipoc, char tipocc);
 | |
|   void             aggiorna_iva(char tipo);
 | |
|   void             setta_parametri(const TString&, const TString&);
 | |
|   void             setta_intestazione();          
 | |
|   char             TipoConto(int g, int c);   
 | |
| // Funzioni per lista controllo movimenti saldaconto  
 | |
|   bool             controlla_partite(); 
 | |
|   void             stampa_errori_partite(int riga);
 | |
|   bool             controlla_scadenze();            
 | |
|   void             stampa_errori_scadenze(int riga);  
 | |
|   bool             controlla_pagsca();                
 | |
|   void             stampa_errori_pagsca(int riga);    
 | |
|   bool             controlla_anaCF_Pcon(char tipocf,int gruppo,int conto,long codcf);
 | |
|   bool             controlla_anagrafica(char tipo, int gruppo, int conto);
 | |
|   bool             cerca_codpag(TString& codpag);                     
 | |
|   bool             cerca_tipopag_codpag(TString& codpag, int tipopag);
 | |
|   bool             ulteriore_classificazione(int tipopag, TString& ultclass); 
 | |
|   bool             banca(long abi,long cab);
 | |
|   bool             agente(const char* codag) const; 
 | |
|   bool             record_partite(int nriga);
 | |
|   bool             record_scadenze(int nriga,int nrata);  
 | |
|   void             descrizione_pagamento(TString& descr,int tipopag,TString& ultclass,TString& codpag);
 | |
|   void             esamina_partite();
 | |
|   
 | |
|   void             aggiorna_partite();
 | |
|   bool             solo_SC(long numreg);
 | |
| 
 | |
|   void             calcola_imposta(long numreg, real& imposta);  
 | |
|   bool             calcola_impdocval(long nreg,int nrig,char tipo,int g,int c, long s,int anno,TString& numpart,int nriga,real& doc,real& val);    
 | |
|   void             calcola_importo(char tipo,int g,int c,long s,int anno,TString& numpart,int nriga);  
 | |
|   void             aggiorna_partita(real& importo,real& importoval,real& abbuoni,real& diffcam,
 | |
|                                     real& ritfis,real& ritsoc,TString& sez,TString& sezabb,TString& sezdc);  
 | |
|   void             azzera_impdocval();
 | |
|   int              cerca_anno_solare_esercizio(int codice_esercizio);  
 | |
|   bool             esiste_rata();
 | |
|   const char * get_error(int err);
 | |
| 
 | |
| 	void             apri_file_SC();
 | |
|   void             chiudi_file_SC();
 | |
|   
 | |
|   TLibro_giornale& giornale() { return *_giornale; }
 | |
|   TTransfer_file&  trasfer() { return *_trasfer; }
 | |
|   
 | |
|   TRic_ListaMov(char ric_auto = '\0',char tipo_lista = '\0');
 | |
|   virtual ~TRic_ListaMov() {}
 | |
| };                  
 | |
| 
 | |
| HIDDEN inline TRic_ListaMov& app() { return (TRic_ListaMov&)main_app();}
 | |
| 
 | |
| TRic_ListaMov::TRic_ListaMov(char ric_auto,char tipo_lista):
 | |
| _ric_auto(toupper(ric_auto)), _tipo_lista(toupper(tipo_lista)), _err(80)
 | |
| {}
 | |
| 
 | |
| 
 | |
| char TRic_ListaMov::look_sdt()
 | |
| {
 | |
|   TConfig conf(CONFIG_DITTA);
 | |
|   return conf.get("FlStTra")[0];
 | |
| }
 | |
| 
 | |
| bool TRic_ListaMov::look_pag()
 | |
| {
 | |
|   TTable t ("%CPG");
 | |
|   t.zero();
 | |
|   t.put("CODTAB",_codpag);
 | |
|   if (t.read() != NOERR) return FALSE;
 | |
|   return TRUE;
 | |
| }
 | |
| 
 | |
| const char* TRic_ListaMov::get_codiva_des(const char* codiva)
 | |
| {
 | |
|   TTable iva ("%IVA");
 | |
|   
 | |
|   iva.zero();
 | |
|   iva.put("CODTAB", codiva);
 | |
|   if (iva.read() == NOERR)
 | |
|     return iva.get("S0");
 | |
|   else
 | |
|     return NULL;             
 | |
| }
 | |
| 
 | |
| bool TRic_ListaMov::DescrConto(int g, int c, long s)
 | |
| {
 | |
|   TString80 ragsoc;
 | |
|   const char* descr = NULL;
 | |
|   TLocalisamfile pconti (LF_PCON);
 | |
|   pconti.setkey(1);
 | |
|   pconti.zero();
 | |
|   pconti.put(PCN_GRUPPO, g);
 | |
|   pconti.put(PCN_CONTO,  c);
 | |
|   pconti.put(PCN_SOTTOCONTO, 0L);
 | |
|   if (pconti.read() == NOERR)
 | |
|   {
 | |
|     _tipo_conto = pconti.get(PCN_TMCF);
 | |
|     if (_tipo_conto == "C" || _tipo_conto == "F")
 | |
|     {
 | |
|      TLocalisamfile clifo (LF_CLIFO);
 | |
|      clifo.setkey(1);
 | |
|      clifo.zero();
 | |
|      clifo.put(CLI_TIPOCF, _tipo_conto);
 | |
|      clifo.put(CLI_CODCF, s);
 | |
|      if (clifo.read() != NOERR)
 | |
|      {
 | |
|        _descr_conto = ""; 
 | |
|        return FALSE;
 | |
|      }
 | |
|      else
 | |
|      {
 | |
|        char tipoa = clifo.get_char("TIPOAPER");
 | |
|        if (tipoa == 'F') //persona fisica
 | |
|        { 
 | |
|          TString80 cognome, nome;
 | |
|          ragsoc = clifo.get("RAGSOC");
 | |
|          cognome = ragsoc.mid(0,30);
 | |
|          nome = ragsoc.mid(30,20);
 | |
|          cognome.trim(); nome.trim();
 | |
|          ragsoc = cognome;
 | |
|          ragsoc << " " << nome;
 | |
|          _descr_conto = ragsoc;
 | |
|        } 
 | |
|        else _descr_conto = clifo.get("RAGSOC");
 | |
|      }   
 | |
|     } 
 | |
|     else
 | |
|     {
 | |
|      pconti.zero();
 | |
|      pconti.put(PCN_GRUPPO, g);
 | |
|      pconti.put(PCN_CONTO,  c);
 | |
|      pconti.put(PCN_SOTTOCONTO, s);
 | |
|      if (pconti.read() != NOERR)
 | |
|      {
 | |
|        _descr_conto = "";
 | |
|        return FALSE;
 | |
|      }
 | |
|      else _descr_conto = pconti.get(PCN_DESCR);  
 | |
|     }
 | |
|   }
 | |
|   else 
 | |
|   {
 | |
|     _descr_conto = "";
 | |
|     return FALSE;
 | |
|   }
 | |
|   return TRUE;
 | |
| }
 | |
| 
 | |
| bool TRic_ListaMov::user_create()
 | |
| {                              
 | |
|   TToken_string exp;                      
 | |
|   TToken_string exp1;
 | |
|   
 | |
|   _trasfer  = new TTransfer_file();
 | |
| 
 | |
|   _tab_tra = new TTable ("%TRA");
 | |
|   _tab_tpd = new TTable ("%TPD");
 | |
|   _tab_pag = new TTable ("%CPG"); 
 | |
|   _tab_iva = new TTable ("%IVA");
 | |
|   _tab_ese = new TTable ("ESC");
 | |
|   
 | |
|   _caus    = new TLocalisamfile (LF_CAUSALI);
 | |
|   _ditte   = new TLocalisamfile (LF_NDITTE);
 | |
|   _clifo   = new TLocalisamfile (LF_CLIFO);
 | |
|   _pcon    = new TLocalisamfile (LF_PCON);
 | |
|   _mov     = new TLocalisamfile (LF_MOV);
 | |
|   _rmov    = new TLocalisamfile (LF_RMOV);
 | |
|   _rmoviva = new TLocalisamfile (LF_RMOVIVA);  
 | |
|   
 | |
|   _part    = NULL;
 | |
|   _scad    = NULL;
 | |
|   _pagsca  = NULL;
 | |
|   _tpart   = NULL;
 | |
|   _tscad   = NULL;
 | |
|   _tpagsca = NULL;
 | |
|   
 | |
| //  _part    = new TLocalisamfile (LF_PARTITE);  
 | |
| //  _scad    = new TLocalisamfile (LF_SCADENZE);  
 | |
| //  _pagsca  = new TLocalisamfile (LF_PAGSCA);  
 | |
|   
 | |
|   if (_ric_auto != 'A')
 | |
|   {
 | |
|     TIndwin pnd(0,TR("Controllo archivi..."),FALSE, FALSE);
 | |
|     if (!check_archivi())
 | |
|       return FALSE;
 | |
|   }
 | |
|   
 | |
|   TFilename tmpmov = "%";
 | |
|   tmpmov  << get_firm_dir();
 | |
|   tmpmov << SLASH << TEMP_MOV;
 | |
|   TFilename tmprmov = "%";
 | |
|   tmprmov << get_firm_dir();         
 | |
|   tmprmov << SLASH << TEMP_RMOV;  
 | |
|   TFilename tmprmoviva = "%";
 | |
|   tmprmoviva << get_firm_dir();     
 | |
|   tmprmoviva << SLASH << TEMP_RMOVIVA;
 | |
| 
 | |
|   _tmov  = new TIsamtempfile(LF_MOV, tmpmov, 0);
 | |
|   _trmov = new TIsamtempfile(LF_RMOV, tmprmov, 0);
 | |
| 
 | |
|   _is_iva = FALSE;
 | |
|   TFilename tmp = tmprmoviva.mid(1); tmp.ext("dbf");
 | |
|   if (tmp.exist())  
 | |
|   {
 | |
|     _tiva  = new TIsamtempfile(LF_RMOVIVA, tmprmoviva, 0);
 | |
|     _is_iva = TRUE;
 | |
|   }
 | |
|   else
 | |
|     _tiva = NULL;
 | |
| 
 | |
|   _rel = new TRelation(_tmov);
 | |
|   _rel->add(_trmov,"NUMREG=NUMREG",1,0,0,FALSE);
 | |
|   if (_is_iva)
 | |
|     _rel->add(_tiva, "NUMREG=NUMREG",1,0,0,FALSE);
 | |
|   _cur = add_cursor(new TCursor (_rel, "", 1));    // Cursore definito sui file dei movimenti contabili e iva
 | |
| 
 | |
| // *************************************************
 | |
| // *** Parte riguardante il Saldaconto se esiste *** 
 | |
| // *************************************************
 | |
|   TFilename tmppart = "%";
 | |
|   tmppart  << get_firm_dir();
 | |
|   tmppart << SLASH << TEMP_PART;
 | |
| 
 | |
|   tmp = tmppart.mid(1);
 | |
|   tmp << ".dbf";
 | |
|   _is_salda = tmp.exist();
 | |
|   
 | |
|   _giornale = new TLibro_giornale();
 | |
| 
 | |
|   printer().footerlen(5);
 | |
|    
 | |
|   _tipom_cau       = "";  
 | |
|   _codpag_scad     = "";
 | |
|   _risposta        = FALSE;     
 | |
|   _continua        = TRUE;
 | |
|   _intestaSC       = FALSE;
 | |
|   _seconda_volta   = FALSE;
 | |
|   _errore_grave_SC = FALSE;
 | |
|   _prima_volta     = TRUE;      
 | |
|   _gruppo_p        = -1;
 | |
|   _conto_p         = -1;
 | |
|   _codcf_p         = -1;
 | |
|   _prima_rata_pag  = FALSE;      
 | |
|   _numpart_prec    = ""; 
 | |
|   _ho_stampato     = FALSE;
 | |
|   
 | |
|   return TRUE;
 | |
| }
 | |
| 
 | |
| void TRic_ListaMov::apri_file_SC()
 | |
| { 
 | |
|   TToken_string exp;                      
 | |
|   TToken_string exp1;
 | |
|   TFilename tmp;
 | |
| // *************************************************
 | |
| // *** Parte riguardante il Saldaconto se esiste *** 
 | |
| // *************************************************
 | |
|   TFilename tmppart = "%";
 | |
|   tmppart  << get_firm_dir();
 | |
|   tmppart << "\\" << TEMP_PART;
 | |
|   TFilename tmpscad = "%";
 | |
|   tmpscad << get_firm_dir();         
 | |
|   tmpscad << "\\" << TEMP_SCAD;  
 | |
|   TFilename tmppagsca = "%";
 | |
|   tmppagsca << get_firm_dir();     
 | |
|   tmppagsca << "\\" << TEMP_PAGSCA;
 | |
| 
 | |
|   tmp = tmppart.mid(1);
 | |
|   tmp << ".dbf";
 | |
|   _is_salda = tmp.exist();
 | |
|   if (_is_salda)
 | |
|   { 
 | |
|     _part    = new TLocalisamfile (LF_PARTITE);
 | |
|     _scad    = new TLocalisamfile (LF_SCADENZE);
 | |
|     _pagsca  = new TLocalisamfile (LF_PAGSCA);      
 | |
| 
 | |
|     _tpart   = new TIsamtempfile(LF_PARTITE,  tmppart, 0);
 | |
|     _tscad   = new TIsamtempfile(LF_SCADENZE,  tmpscad, 0);
 | |
|     _tpagsca = new TIsamtempfile(LF_PAGSCA,tmppagsca, 0);
 | |
|     
 | |
|     _relSC = new TRelation(_tpart);
 | |
|     exp.add("TIPOC=TIPOC");
 | |
|     exp.add("GRUPPO=GRUPPO");
 | |
|     exp.add("CONTO=CONTO");
 | |
|     exp.add("SOTTOCONTO=SOTTOCONTO");
 | |
|     exp.add("ANNO=ANNO");
 | |
|     exp.add("NUMPART==NUMPART");
 | |
|     exp.add("NRIGA=NRIGA");
 | |
|     _relSC->add(_tscad,exp,1,0,0,FALSE);
 | |
|     exp1.add("TIPOC=TIPOC");
 | |
|     exp1.add("GRUPPO=GRUPPO");
 | |
|     exp1.add("CONTO=CONTO");
 | |
|     exp1.add("SOTTOCONTO=SOTTOCONTO");
 | |
|     exp1.add("ANNO=ANNO");
 | |
|     exp1.add("NUMPART==NUMPART");
 | |
|     _relSC->add(_tpagsca,exp1,1,0,0,FALSE);
 | |
|     _curSC = add_cursor(new TCursor (_relSC, "", 1));   // Cursore definito sui movimenti del saldaconto 
 | |
|   }
 | |
| }
 | |
| 
 | |
| bool TRic_ListaMov::check_archivi()
 | |
| {
 | |
|   long ditta_ric = get_firm();
 | |
|   
 | |
|   if (!prefix().exist(ditta_ric))
 | |
|     return error_box(FR("Non esistono gli archivi della ditta %05ld: procedura interrotta"), ditta_ric);
 | |
|   
 | |
|   TTransfer_file& tr = trasfer();
 | |
|   
 | |
|   _pathfile = tr.path();         
 | |
|   
 | |
|   _pathfile = _pathfile << HEADER;
 | |
|   
 | |
|   if (!tr.open(_pathfile))
 | |
|      return error_box(TR("Al momento non ci sono trasferimenti attivi sulla ditta selezionata"));
 | |
|   
 | |
|   if (!tr.read_control_rec())
 | |
|     return error_box(TR("Rilevati errori gravi negli archivi: procedura interrotta"));
 | |
|   else 
 | |
|     _record = tr.record();
 | |
|   
 | |
|   const char sd = look_sdt();
 | |
|   if (sd <= ' ')
 | |
|     return error_box(TR("Ricezione tabelle non effettuata: richiamare il programma relativo"));
 | |
| 
 | |
|   _sdt = sd;
 | |
|   if (_sdt == 'T')
 | |
|      return error_box(TR("Ricezione tabelle non effettuata: richiamare il programma relativo"));
 | |
|      
 | |
|   if (_sdt == 'M')
 | |
|      return yesno_box(TR("Controllo gia' effettuato: si desidera ripeterlo ?"));
 | |
|      
 | |
|   if (_sdt != '*' && _sdt != 'C')
 | |
|      return error_box(TR("Rilevati errori gravi negli archivi: procedura interrotta"));
 | |
|   
 | |
|   TString16 ult = tr.ult_file();
 | |
|   TString16 key = tr.key();
 | |
|   
 | |
|   ult.strip_spaces(); 
 | |
|   key.strip_spaces();
 | |
| 
 | |
|   if (_sdt == 'C')
 | |
|      if ( ult.not_empty() || key.not_empty() )
 | |
|         return error_box(TR("Rilevati errori gravi negli archivi: procedura interrotta"));
 | |
| 
 | |
|   if (_sdt == '*')
 | |
|   {
 | |
|     tr.remove_all();
 | |
|     return warning_box(TR("Trasferimento interamente completato: proseguire per cancellare i file")); 
 | |
|   }
 | |
|   
 | |
|   return TRUE;        
 | |
| }
 | |
|  
 | |
| void TRic_ListaMov::stampa_errori_mov(int riga)
 | |
| {
 | |
|   long i = _err.first_one();
 | |
|   if (i != -1)
 | |
|   {
 | |
|     for (; i <= _err.last_one(); i++)
 | |
|       if (_err[i])
 | |
|         set_row(++riga, "@8g%s",  get_error(i));
 | |
|   }  
 | |
| } 
 | |
| 
 | |
| int  TRic_ListaMov::cerca_anno_solare_esercizio(int codice)
 | |
| {      
 | |
|   int anno = 0;                        
 | |
| 
 | |
|   TEsercizi_contabili esc;
 | |
|   if (esc.exist(codice))
 | |
|     anno = esc[codice].fine().year();
 | |
| 
 | |
|   return anno;
 | |
|   TDate datainizio, datafine;
 | |
|   _ec.code2range(codice, datainizio, datafine);
 | |
|   return datafine.year();
 | |
| }
 | |
| 
 | |
| bool TRic_ListaMov::controlla_mov()
 | |
| {
 | |
|   bool check_reg = TRUE;
 | |
|   TString4 causreg;
 | |
|   TDate udata;
 | |
|   char tipocf = ' ';
 | |
|   TTransfer_file& tr = trasfer();
 | |
|     
 | |
|   _tiporeg = 0;
 | |
|   
 | |
|   if ( !TDate::isdate(_datareg.string()) )
 | |
|   {
 | |
|     _errore_grave = TRUE;
 | |
|     _err.set(0L);
 | |
|   }
 | |
| 
 | |
|   if (!_datacomp.ok())
 | |
|     _datacomp = tr.data_fine_esercizio(_anno);
 | |
|   
 | |
|   if ( TDate::isdate(_datareg.string()) )
 | |
|   { 
 | |
|     int pr = 0;                             // Esercizio precedente
 | |
|     const int ar = date2esc(_datareg, &pr); // Esercizio in corso
 | |
|     if (ar == 0)    
 | |
|     {
 | |
|        _err.set(1);
 | |
|        _errore_grave = TRUE;
 | |
|     }
 | |
|     if ( TDate::isdate(_datacomp.string()) )
 | |
|     {  
 | |
|       const int ae = date2esc(_datacomp);
 | |
|       if (ae == 0)
 | |
|       {
 | |
|          _err.set(3);
 | |
|          _errore_grave = TRUE;
 | |
|       }
 | |
|       else if (ae != ar && ae != pr && ar)
 | |
|              _err.set(4);
 | |
|     }
 | |
|   }
 | |
|   
 | |
|   int pp;
 | |
|   _annoese = date2esc(_datacomp);    // Esercizio in corso  
 | |
|   pp = _ec.pred(_annoese);
 | |
|   
 | |
|   if ( !TDate::isdate(_datacomp.string()) )
 | |
|   {
 | |
|     _errore_grave = TRUE;
 | |
|     _err.set(2);
 | |
|   }
 | |
|     
 | |
|   TLibro_giornale& gio = giornale();
 | |
|   bool ok = gio.read(_ae);  //se _ae e' zero la read considera come anno quello corrente
 | |
|   if (_datareg < gio.last_print())
 | |
|   {
 | |
|     _errore_grave = TRUE;
 | |
|     _err.set(5);
 | |
|   } 
 | |
|   
 | |
|   TString16 dd = _datadoc.string();
 | |
|   if (dd.not_empty()) 
 | |
|     if ( !TDate::isdate(_datadoc.string()) )
 | |
|       _err.set(6);
 | |
|      
 | |
|   TLocalisamfile caus(LF_CAUSALI);
 | |
|   caus.setkey(1);
 | |
|   caus.zero();
 | |
|   caus.put(CAU_CODCAUS,_causale);
 | |
|   if (caus.read() == NOERR)
 | |
|   {   
 | |
|     _tipodoc   = caus.get(CAU_TIPODOC); 
 | |
|     if (_is_salda)
 | |
|       _tipom_cau = caus.get(CAU_TIPOMOV);
 | |
|   }
 | |
|   else
 | |
|   {
 | |
|     caus.zero();
 | |
|     if (_causale.full())  //se la causale e' significativa
 | |
|     {
 | |
|      _errore_grave = TRUE;
 | |
|      _err.set(7); 
 | |
|     } 
 | |
|   } 
 | |
|   //_tipodoc = caus.get(CAU_TIPODOC);  ho sempre quello letto sul movimento!
 | |
|   causreg = caus.get(CAU_REG); 
 | |
|   _descr_causale = caus.get(CAU_DESCR); 
 | |
|   _mov_sez = caus.get_bool(CAU_MOVSEZ);     
 | |
|   
 | |
|   if (!_codpag.blank())
 | |
|   {
 | |
|     bool ok = look_pag(); 
 | |
|     if (!ok)
 | |
|       _err.set(8);
 | |
|   }   
 | |
|    
 | |
|   if (!_registro.blank()) //movimento iva (fattura)
 | |
|   {
 | |
|     if (_causale.empty())  //se la causale non e' significativa
 | |
|     {
 | |
|       _errore_grave = TRUE;
 | |
|       check_reg = FALSE;
 | |
|       _err.set(9);
 | |
|     }
 | |
|     if (check_reg && _ae)
 | |
|     { 
 | |
|       int anno = cerca_anno_solare_esercizio(_ae);
 | |
|       TRegistro rg (_registro, anno);   
 | |
|       if (rg.name().empty())
 | |
|       {
 | |
|         _errore_grave = TRUE;
 | |
|         check_reg = FALSE;
 | |
|         _err.set(9);
 | |
|       }
 | |
|       else
 | |
|       {
 | |
|        _tiporeg = rg.tipo();
 | |
|        udata = rg.last_print();
 | |
|       }    
 | |
|     }
 | |
|   }
 | |
|   else if (causreg.full() && _ae)
 | |
|   {                                               
 | |
|     int anno = cerca_anno_solare_esercizio(_ae);  
 | |
|     TRegistro rg (causreg, anno);   
 | |
|     if (rg.name().empty())
 | |
|     {
 | |
|       _errore_grave = TRUE;
 | |
|       check_reg = FALSE;
 | |
|       _err.set(9);
 | |
|     }
 | |
|     else 
 | |
|     {
 | |
|       _tiporeg = rg.tipo();
 | |
|       udata = rg.last_print();
 | |
|     }   
 | |
|     _registro = causreg;   
 | |
|   }
 | |
| /*  
 | |
|   if (!_registro.blank())
 | |
|   {
 | |
|     if (_tiporeg == 1) _tipocf = tipocf = 'C';
 | |
|     else if (_tiporeg == 2) _tipocf = tipocf = 'F';
 | |
| //    if (_tiporeg != 0)    //se esiste, uso quello della causale!!!
 | |
| //    {   
 | |
|       TTable tabtpd("%TPD");
 | |
|       tabtpd.put("CODTAB", _tipodoc);
 | |
|       if (tabtpd.read() == NOERR) 
 | |
|       {
 | |
|         bool cor = tabtpd.get_bool("B0");
 | |
|         if (!cor)
 | |
|           if (_codcf != 0l)
 | |
|           { 
 | |
|             TLocalisamfile clifo(LF_CLIFO);
 | |
|             clifo.zero();
 | |
|             clifo.put(CLI_CODCF, _codcf);
 | |
|             clifo.put(CLI_TIPOCF,tipocf);
 | |
|             if (clifo.read() != NOERR)    
 | |
|             {
 | |
|               _errore_grave = TRUE;
 | |
|               _err.set(10);
 | |
|             }
 | |
|           }
 | |
|           else 
 | |
|           {
 | |
|             _errore_grave = TRUE;
 | |
|             _err.set(10);
 | |
|           }
 | |
|       }
 | |
|       else
 | |
|       {
 | |
|         if (_codcf != 0l)
 | |
|         { 
 | |
|           TLocalisamfile clifo(LF_CLIFO);
 | |
|           clifo.zero();
 | |
|           clifo.put(CLI_CODCF, _codcf);
 | |
|           clifo.put(CLI_TIPOCF,tipocf);
 | |
|           if (clifo.read() != NOERR)    
 | |
|           {
 | |
|             _errore_grave = TRUE;
 | |
|             _err.set(10);
 | |
|           }
 | |
|         }
 | |
|         else 
 | |
|         {
 | |
|           _errore_grave = TRUE;
 | |
|           _err.set(10);
 | |
|         }
 | |
|       }
 | |
| //    }
 | |
|   }
 | |
| */  
 | |
|   TString16 d74 = _data74tr.string();
 | |
|   if (d74.not_empty())
 | |
|     if ( !TDate::isdate(_data74tr.string()) ) 
 | |
|       _err.set(11);
 | |
|      
 | |
|   if (!_registro.blank() && check_reg)
 | |
|      if (_datareg < udata) 
 | |
|      {
 | |
|        _errore_grave = TRUE;
 | |
|        _err.set(12);
 | |
|      } 
 | |
|   
 | |
|   if (_err.ones())
 | |
|     return TRUE;
 | |
|   
 | |
|   return FALSE;   
 | |
| } 
 | |
| 
 | |
| bool TRic_ListaMov::errori_partita(int g, int c, long s)
 | |
| {
 | |
|   TLocalisamfile pconti (LF_PCON);
 | |
|   pconti.setkey(1);
 | |
|   pconti.zero();
 | |
|   pconti.put(PCN_GRUPPO, g);
 | |
|   pconti.put(PCN_CONTO,  c);
 | |
|   pconti.put(PCN_SOTTOCONTO, 0L);
 | |
|   if (pconti.read() == NOERR)
 | |
|   {
 | |
|     char tipo = pconti.get(PCN_TMCF)[0];
 | |
|     if (tipo == 'C' || tipo == 'F')
 | |
|     {
 | |
|      TLocalisamfile clifo (LF_CLIFO);
 | |
|      clifo.setkey(1);
 | |
|      clifo.zero();
 | |
|      clifo.put(CLI_TIPOCF, tipo);
 | |
|      clifo.put(CLI_CODCF, s);
 | |
|      if (clifo.read() != NOERR)
 | |
|         return FALSE; 
 | |
|     } 
 | |
|     else
 | |
|     {
 | |
|      pconti.zero();
 | |
|      pconti.put(PCN_GRUPPO, g);
 | |
|      pconti.put(PCN_CONTO,  c);
 | |
|      pconti.put(PCN_SOTTOCONTO, s);
 | |
|      if (pconti.read() != NOERR)
 | |
|         return FALSE;
 | |
|     }
 | |
|   }
 | |
|   else return FALSE;
 | |
|   
 | |
|   return TRUE;
 | |
| }
 | |
| 
 | |
| void TRic_ListaMov::stampa_errori_partite(int riga)
 | |
| {
 | |
|   long i = _err.first_one();
 | |
|   if (i != -1)
 | |
|   {
 | |
|     for (; i <= _err.last_one(); i++)
 | |
|       if (_err[i])
 | |
|         set_row(++riga, "@22g%s", get_error(i));
 | |
|   }  
 | |
| } 
 | |
| 
 | |
| char TRic_ListaMov::TipoConto(int g, int c)
 | |
| {
 | |
|   TLocalisamfile pcon (LF_PCON);
 | |
|   char tipo = ' ';
 | |
|   
 | |
|   pcon.setkey(1);
 | |
|   pcon.zero();
 | |
|   pcon.put(PCN_GRUPPO,     g);
 | |
|   pcon.put(PCN_CONTO,      c);
 | |
|   pcon.put(PCN_SOTTOCONTO, 0l);
 | |
|   if (pcon.read() == NOERR)
 | |
|     tipo = pcon.get_char(PCN_TMCF);
 | |
|     
 | |
|   return tipo;
 | |
| }
 | |
| 
 | |
| bool TRic_ListaMov::controlla_rmov()
 | |
| {
 | |
|   TLocalisamfile& rmov = current_cursor()->file(LF_RMOV);
 | |
|   int gruppo, conto, gruppoc, contoc;
 | |
|   long sottoconto, sottocontoc;
 | |
|   char sezione;
 | |
|   real importo, dare, avere;
 | |
|   
 | |
|   if (current_cursor()->is_first_match(LF_RMOV))
 | |
|   {
 | |
|     dare = avere = ZERO;
 | |
|     TRecnotype nrec = rmov.recno();
 | |
|     rmov.zero();
 | |
|     rmov.setkey(1);
 | |
|     rmov.put(RMV_NUMREG, _numero);
 | |
|     for (rmov.read(_isgteq); !rmov.eof() ;rmov.next())
 | |
|     {
 | |
|       const TRectype& rec = rmov.curr();
 | |
|       if (rec.get_long(RMV_NUMREG) != _numero) 
 | |
|         break;
 | |
|       gruppo = rec.get_int(RMV_GRUPPO);
 | |
|       conto  = rec.get_int(RMV_CONTO);
 | |
|       sottoconto = rec.get_long(RMV_SOTTOCONTO);
 | |
|       gruppoc = rec.get_int(RMV_GRUPPOC);
 | |
|       contoc  = rec.get_int(RMV_CONTOC);
 | |
|       sottocontoc = rec.get_long(RMV_SOTTOCONTOC);
 | |
|       sezione = rec.get_char(RMV_SEZIONE);
 | |
|       importo = rec.get_real(RMV_IMPORTO); 
 | |
|             
 | |
|        _tipo_conto = "";
 | |
| 
 | |
|       char tipo  = TipoConto(gruppo,conto);
 | |
|       char tipoc = TipoConto(gruppoc,contoc);
 | |
|       aggiorna_rmov(tipo,tipoc);                
 | |
|      
 | |
|       if (gruppo != 0 && conto != 0 && sottoconto != 0l)
 | |
|         _esiste_conto = DescrConto(gruppo,conto,sottoconto);
 | |
|       else
 | |
|       {
 | |
|        _esiste_conto = FALSE;
 | |
|        _descr_conto = "";
 | |
|       } 
 | |
|        
 | |
|       if (sezione == 'D') 
 | |
|         dare += importo;
 | |
|       if (sezione == 'A')
 | |
|         avere += importo;
 | |
|       
 | |
|       if (gruppo == 0 || conto == 0 || sottoconto == 0l)
 | |
|       { 
 | |
|         rmov.readat(nrec);
 | |
|         return TRUE; 
 | |
|       }
 | |
|       else
 | |
|       { 
 | |
|         bool ok = errori_partita(gruppo,conto,sottoconto);
 | |
|         if (!ok) 
 | |
|         {
 | |
|           rmov.readat(nrec);
 | |
|           return TRUE;
 | |
|         }
 | |
|       }
 | |
|   
 | |
|       if ( (importo != ZERO && sezione == '\0') || 
 | |
|            (sezione != 'D' && sezione != 'A' && sezione != '\0') )
 | |
|       {
 | |
|         rmov.readat(nrec);
 | |
|         return TRUE;
 | |
|       }
 | |
|   
 | |
|       if (gruppoc != 0 || contoc != 0 || sottocontoc != 0l)
 | |
|       { 
 | |
|         bool ok = errori_partita(gruppoc,contoc,sottocontoc);
 | |
|         if (!ok)
 | |
|         {
 | |
|           rmov.readat(nrec);
 | |
|           return TRUE;
 | |
|         }
 | |
|       } 
 | |
|       
 | |
|       if (!_mov_sez && importo == ZERO)
 | |
|       {
 | |
|         rmov.readat(nrec);
 | |
|         return TRUE;
 | |
|       }
 | |
|     }
 | |
|     if (dare.round(2) != avere.round(2))
 | |
|     {
 | |
|       rmov.readat(nrec);
 | |
|       return TRUE;
 | |
|     }                           
 | |
|     rmov.readat(nrec);
 | |
|   }
 | |
|   return FALSE;  
 | |
| }
 | |
| 
 | |
| void TRic_ListaMov::stampa_errori_rmov(int riga)
 | |
| {
 | |
|   if (_gruppo == 0 || _conto == 0 || _sottoconto == 0l) 
 | |
|   {
 | |
|     _errore_grave = TRUE;
 | |
|     set_row(++riga, FR("@8g*** Sottoconto partita %d.%d.%ld non valido"), _gruppo, _conto, _sottoconto);
 | |
|   }
 | |
|   else
 | |
|   { 
 | |
|     if (!_esiste_conto)
 | |
|     {    
 | |
|       _errore_grave = TRUE;
 | |
|       set_row(++riga, FR("@8g*** Sottoconto partita %d.%d.%ld non presente in archivio"), _gruppo, _conto, _sottoconto);
 | |
|     }
 | |
|   }
 | |
|                                         
 | |
|   if ( (_importo != ZERO && _sezione == '\0') || 
 | |
|        (_sezione != 'D' && _sezione != 'A' && _sezione != '\0') )
 | |
|   {     
 | |
|     _errore_grave = TRUE;
 | |
|     set_row(++riga, FR("@8g*** Segnale dare/avere non valido"));
 | |
|   }
 | |
|   
 | |
|   if (_sezione == 'D')
 | |
|      _tot_dare += _importo;
 | |
|   if (_sezione == 'A')
 | |
|      _tot_avere += _importo;       
 | |
|   
 | |
|   if (_gruppoc != 0 || _contoc != 0 || _sottocontoc != 0l)
 | |
|   { 
 | |
|     bool ok = errori_partita(_gruppoc,_contoc,_sottocontoc);
 | |
|     if (!ok)
 | |
|       set_row(++riga, FR("@8g--- Sottoconto contropartita non valido o non presente in archivio"));
 | |
|   } 
 | |
|   
 | |
|   if (!_mov_sez && _importo == ZERO)
 | |
|     set_row(++riga, FR("@8g--- Importo riga uguale a zero"));
 | |
| } 
 | |
| 
 | |
| bool TRic_ListaMov::controlla_riva()
 | |
| {
 | |
|   TLocalisamfile& rmoviva = current_cursor()->file(LF_RMOVIVA);
 | |
|   TTable  tab_iva("%IVA");
 | |
|   TString4 codiva;
 | |
|   int tipocr, gruppocr, contocr;
 | |
|   long sottocontocr;  
 | |
|   real impo, impos;
 | |
|   bool testata  = TRUE; 
 | |
|   bool no_grave = FALSE;
 | |
|   
 | |
|   if (current_cursor()->is_first_match(LF_RMOVIVA))
 | |
|   {
 | |
|     TRecnotype nrec = rmoviva.recno();
 | |
|     rmoviva.setkey(1);
 | |
|     rmoviva.zero();
 | |
|     rmoviva.put(RMI_NUMREG, _numero);
 | |
|     TRectype recc (rmoviva.curr());
 | |
|     for (rmoviva.read(_isgteq); !rmoviva.eof() ;rmoviva.next())
 | |
|     {
 | |
|       TRectype rec (rmoviva.curr());
 | |
|       if (rec > recc) break;
 | |
|       //_n_rec = rec.get_int(RMI_ANNOES);
 | |
|       codiva = rec.get(RMI_CODIVA);
 | |
|       real percind;
 | |
|       const int tipodet = get_tipodet_from_rmi(rec, current_cursor()->file(LF_MOV).curr(), percind);
 | |
|       tipocr  = rec.get_int(RMI_TIPOCR);
 | |
|       gruppocr = rec.get_int(RMI_GRUPPO);
 | |
|       contocr = rec.get_int(RMI_CONTO);
 | |
|       sottocontocr = rec.get_long(RMI_SOTTOCONTO);
 | |
|       impo  = rec.get_real(RMI_IMPONIBILE);
 | |
|       impos = rec.get_real(RMI_IMPOSTA);
 | |
|       
 | |
|       if (testata)
 | |
|       {                            
 | |
|         char tipocf = ' ';      
 | |
|         if (!_registro.blank())
 | |
|         {
 | |
|           if (_tiporeg == 1) _tipocf = tipocf = 'C';
 | |
|           else if (_tiporeg == 2) _tipocf = tipocf = 'F';
 | |
|           TTable tabtpd("%TPD");
 | |
|           tabtpd.put("CODTAB", _tipodoc);
 | |
|           if (tabtpd.read() == NOERR) 
 | |
|           {
 | |
|             bool cor = tabtpd.get_bool("B0");
 | |
|             if (!cor)
 | |
|               if (_codcf != 0l)
 | |
|               { 
 | |
|                 TLocalisamfile clifo(LF_CLIFO);
 | |
|                 clifo.zero();
 | |
|                 clifo.put(CLI_CODCF, _codcf);
 | |
|                 clifo.put(CLI_TIPOCF,tipocf);
 | |
|                 if (clifo.read() != NOERR)    
 | |
|                 {
 | |
|                   _errore_grave = TRUE;
 | |
|                   _err.set(10);
 | |
|                 }
 | |
|               }
 | |
|               else 
 | |
|               {
 | |
|                 _errore_grave = TRUE;
 | |
|                 _err.set(10);
 | |
|               }
 | |
|           }
 | |
|           else
 | |
|           {
 | |
|             if (_codcf != 0l)
 | |
|             { 
 | |
|               TLocalisamfile clifo(LF_CLIFO);
 | |
|               clifo.zero();
 | |
|               clifo.put(CLI_CODCF, _codcf);
 | |
|               clifo.put(CLI_TIPOCF,tipocf);
 | |
|               if (clifo.read() != NOERR)    
 | |
|               {
 | |
|                 _errore_grave = TRUE;
 | |
|                 _err.set(10);
 | |
|               }
 | |
|             }
 | |
|             else 
 | |
|             {
 | |
|               _errore_grave = TRUE;
 | |
|               _err.set(10);
 | |
|             }
 | |
|           }
 | |
|         }
 | |
|         testata = FALSE;
 | |
|       }
 | |
|       
 | |
|       //TString impostr = impo.string();
 | |
|       //TString impostastr = impos.string();
 | |
|       
 | |
|       _tot_doc += impo + impos;
 | |
|       
 | |
|       //TString totdocstr = _tot_doc.string();
 | |
|       
 | |
|       _impo = impo;
 | |
|       _impos = impos; 
 | |
| 
 | |
|       char tipo = TipoConto(gruppocr,contocr);
 | |
|       aggiorna_iva(tipo);
 | |
|      
 | |
|       if (!_tipodoc.blank())
 | |
|       {   
 | |
|         TTable tabtpd("%TPD");
 | |
|         tabtpd.put("CODTAB", _tipodoc);
 | |
|         if (tabtpd.read() == NOERR) 
 | |
|         {
 | |
|          bool cor = tabtpd.get_bool("B0");
 | |
|          if (cor)
 | |
|          {
 | |
|           _impo  = impo + impos;
 | |
|           _impos = ZERO;
 | |
|          }
 | |
|         }  
 | |
|       }
 | |
|       
 | |
|       TTable iva ("%IVA");
 | |
|       iva.zero();
 | |
|       iva.put("CODTAB", codiva);
 | |
|       if (iva.read() != NOERR)
 | |
|       {                 
 | |
|         no_grave = TRUE;
 | |
|       }
 | |
|     
 | |
|       if ( tipocr != 0 && tipocr != 1 && tipocr != 2 && tipocr != 3 && 
 | |
|            tipocr != 4 && tipocr != 5 && tipocr != 8 && tipocr != 9    )
 | |
|       { 
 | |
|         no_grave = TRUE;
 | |
|       }
 | |
|       if (gruppocr == 0 || contocr == 0 || sottocontocr == 0l)
 | |
|       {                 
 | |
|         no_grave = TRUE;
 | |
|       }
 | |
|       else if (gruppocr != 0 && contocr != 0 && sottocontocr != 0l)
 | |
|       {
 | |
|         bool ok = errori_partita(gruppocr,contocr,sottocontocr);
 | |
|         if (!ok) 
 | |
|         {               
 | |
|           no_grave = TRUE;
 | |
|         }
 | |
|       }  
 | |
|       if (tipodet != 0 && tipodet != 1 && tipodet != 3 && tipodet != 9)
 | |
|       {                   
 | |
|         no_grave = TRUE;
 | |
|       } 
 | |
|     }                   
 | |
|     if (no_grave)
 | |
|     {
 | |
|       rmoviva.readat(nrec);
 | |
|       return TRUE;
 | |
|     }
 | |
|     rmoviva.readat(nrec);    
 | |
|   }
 | |
|   return FALSE; 
 | |
| }       
 | |
| 
 | |
| void TRic_ListaMov::stampa_errori_riva(int riga)
 | |
| {
 | |
|   TTable iva ("%IVA");
 | |
|   
 | |
|   iva.zero();
 | |
|   iva.put("CODTAB", _codiva);
 | |
|   if (iva.read() != NOERR)
 | |
|     set_row(++riga, FR("@8g--- Codice IVA non valido o non presente in tabella"));
 | |
| 
 | |
|   if ( _tipocr != 0 && _tipocr != 1 && _tipocr != 2 && _tipocr != 3 && 
 | |
|        _tipocr != 4 && _tipocr != 5 && _tipocr != 8 && _tipocr != 9    )
 | |
|     set_row(++riga, FR("@8g--- Tipo costo/ricavo non valido"));
 | |
| 
 | |
|   if (_gruppocr == 0 || _contocr == 0 || _sottocontocr == 0l)
 | |
|     set_row(++riga, FR("@8g--- Sottoconto costo/ricavo %d.%d.%ld non valido"), _gruppocr, _contocr, _sottocontocr);
 | |
|   else if (_gruppocr != 0 && _contocr != 0 && _sottocontocr != 0l)
 | |
|   {
 | |
|     bool ok = errori_partita(_gruppocr,_contocr,_sottocontocr);
 | |
|     if (!ok) 
 | |
|      set_row(++riga, FR("@8g--- Sottoconto costo/ricavo %d.%d.%ld non presente in archivio"), _gruppocr, _contocr, _sottocontocr);
 | |
|   }  
 | |
| 
 | |
|   if (_tipod != 0 && _tipod != 1 && _tipod != 3 && _tipod != 9)
 | |
|     set_row(++riga, FR("@8g--- Tipo indetraibilita' non valido"));
 | |
| }
 | |
| 
 | |
| bool TRic_ListaMov::controlla_anaCF_Pcon(char tipocf,int gruppo,int conto,long codcf)
 | |
| {                      
 | |
|   if (codcf == 0)
 | |
|     return TRUE;
 | |
|     
 | |
|   if (tipocf == 'C' || tipocf == 'F')
 | |
|   {
 | |
|     TLocalisamfile clifo (LF_CLIFO);
 | |
|     
 | |
|     clifo.setkey(1);
 | |
|     clifo.zero();
 | |
|     clifo.put(CLI_TIPOCF, tipocf);
 | |
|     clifo.put(CLI_CODCF,  codcf);
 | |
|     if (clifo.read() == NOERR)
 | |
|     {         
 | |
|       TString descr = clifo.get(CLI_RAGSOC);
 | |
|       TString app1  = descr.mid(0,30); 
 | |
|       app1.trim();
 | |
|       TString app2  = descr.mid(30,20);  
 | |
|       app2.trim();
 | |
|       _descr_anag = app1 << " " << app2;
 | |
|       return TRUE;
 | |
|     }
 | |
|     else
 | |
|     { 
 | |
|       _descr_anag = "";
 | |
|       return FALSE;
 | |
|     }
 | |
|   } 
 | |
|   else
 | |
|   {
 | |
|     TLocalisamfile pcon (LF_PCON);
 | |
|     
 | |
|     pcon.setkey(1);
 | |
|     pcon.zero();
 | |
|     pcon.put(PCN_GRUPPO,     gruppo);
 | |
|     pcon.put(PCN_CONTO,      conto);
 | |
|     pcon.put(PCN_SOTTOCONTO, codcf);
 | |
|     if (pcon.read() == NOERR)
 | |
|     {              
 | |
|       _descr_anag = pcon.get(PCN_DESCR);
 | |
|       return TRUE;
 | |
|     }
 | |
|     else
 | |
|     { 
 | |
|       _descr_anag = "";
 | |
|       return FALSE;
 | |
|     }  
 | |
|   }
 | |
|   
 | |
|   return TRUE;
 | |
| }                  
 | |
| 
 | |
| bool TRic_ListaMov::controlla_anagrafica(char tipo, int gruppo, int conto)
 | |
| {
 | |
|   TLocalisamfile pcon (LF_PCON);
 | |
|   
 | |
|   pcon.setkey(1);
 | |
|   pcon.zero();
 | |
|   pcon.put(PCN_GRUPPO, gruppo);
 | |
|   pcon.put(PCN_CONTO,  conto);
 | |
|   pcon.read();
 | |
|   if (pcon.get_int(PCN_GRUPPO) == gruppo && pcon.get_int(PCN_CONTO) == conto)
 | |
|     if (pcon.get_char(PCN_TMCF) == tipo)
 | |
|       return TRUE;
 | |
| 
 | |
|   return FALSE;
 | |
| }
 | |
| 
 | |
| bool TRic_ListaMov::esiste_rata()
 | |
| {
 | |
|   TLocalisamfile& scad = current_cursor()->file(LF_SCADENZE);
 | |
|   TRecnotype record = scad.recno();
 | |
|   
 | |
|   scad.zero();
 | |
|   scad.put(SCAD_TIPOCF,     _tipocf);
 | |
|   if (_gruppo != 0)
 | |
|   scad.put(SCAD_GRUPPO,     _gruppo);
 | |
|   if (_conto != 0)
 | |
|     scad.put(SCAD_CONTO,      _conto);
 | |
|   if (_codcf != 0)
 | |
|     scad.put(SCAD_SOTTOCONTO, _codcf);
 | |
|   scad.put(SCAD_ANNO,       _anno);
 | |
|   scad.put(SCAD_NUMPART,    _numpart);
 | |
|   scad.put(SCAD_NRIGA,      _nriga);  
 | |
|     
 | |
|   TRectype recscad (scad.curr());
 | |
|     
 | |
|   for (scad.read(_isgteq); !scad.eof(); scad.next())
 | |
|   {                                              
 | |
|     TString rec  = recscad.get(SCAD_NUMPART);
 | |
|     TString file = scad.get(SCAD_NUMPART);
 | |
|           
 | |
|     if (scad.curr() != recscad || file != rec) break;
 | |
|     
 | |
|     return TRUE;  
 | |
|   }    
 | |
|   scad.readat(record);
 | |
|   
 | |
|   return FALSE;
 | |
| }
 | |
| 
 | |
| const char * TRic_ListaMov::get_error(int err)
 | |
| {
 | |
| 	switch (err)
 | |
| 	{
 | |
| 		case 0:
 | |
| 			return TR("*** Data operazione non valida");
 | |
| 		break;
 | |
| 		case 1:
 | |
|       return TR("*** Data operazione non compresa in alcun esercizio");
 | |
| 		break;
 | |
| 		case 2:
 | |
|       return TR("*** Data competenza non valida");
 | |
| 		break;
 | |
| 		case 3:
 | |
|       return TR("*** Data competenza non compresa in alcun esercizio");
 | |
| 		break;
 | |
| 		case 4:
 | |
|       return TR("--- Data competenza incompatibile con data operazione");
 | |
| 		break;
 | |
| 		case 5:
 | |
|       return TR("*** Data operazione antecedente ad ultima stampa giornale");
 | |
| 		break;
 | |
| 		case 6:
 | |
|       return TR("--- Data documento non valida");
 | |
| 		break;
 | |
| 		case 7:
 | |
|       return TR("*** Codice causale non valido o non presente in archivio");
 | |
| 		break;
 | |
| 		case 8:
 | |
|       return TR("--- Codice pagamento non valido o non presente in tabella");
 | |
| 		break;
 | |
| 		case 9:
 | |
|       return TR("*** Codice registro IVA non valido o non presente in tabella");
 | |
| 		break;
 | |
| 		case 10:
 | |
|       return TR("*** Codice cliente/fornitore non valido o non presente in anagrafica");
 | |
| 		break;
 | |
| 		case 11:
 | |
|       return TR("--- Data 74 ter non valida");
 | |
| 		break;
 | |
| 		case 12:
 | |
|       return TR("*** Data operazione antecedente ad ultima stampa registro IVA");
 | |
| 		break;
 | |
| 		case 13:
 | |
|       return TR("*** Tipo anagrafico C/F errato");
 | |
| 		break;
 | |
| 		case 14:
 | |
|       return TR("*** Codice anagrafico C/F/Piano Conti errato");
 | |
| 		break;
 | |
| 		case 15:
 | |
|       return TR("*** Rif. partite saldaconto errato");                                     
 | |
| 		break;
 | |
| 		case 16:
 | |
|       return TR("--- Codice valuta errato");
 | |
| 		break;
 | |
| 		case 17:
 | |
|       return TR("*** Data cambio non valida");
 | |
| 		break;
 | |
| 		case 18:
 | |
|       return TR("*** Data pagamento/incasso non valida");
 | |
| 		break;
 | |
| 		case 19:
 | |
|       return TR("*** Tipo pagamento errato");
 | |
| 		break;
 | |
| 		case 20:
 | |
|       return TR("*** Segno D/A errato");                                                   
 | |
| 		break;
 | |
| 		case 21:
 | |
|       return TR("*** Cambio mancante");
 | |
| 		break;
 | |
| 		case 22:
 | |
|       return TR("*** Gruppo/Conto errato");                    
 | |
| 		break;
 | |
| 		case 23:
 | |
|       return TR("*** Rif. rata partite saldaconto errato");
 | |
| 		break;
 | |
| 		case 24:
 | |
|       return TR("*** Data scadenza non valida");
 | |
| 		break;
 | |
| 		case 25:
 | |
|       return TR("--- Ulteriore classificazione non valida o non presente in archivio");
 | |
| 		break;
 | |
| 		case 26:
 | |
|       return TR("*** Importo rata in lire mancante");
 | |
| 		break;
 | |
| 		case 27:
 | |
|       return TR("*** Importo rata in valuta mancante");
 | |
| 		break;
 | |
| 		case 28:
 | |
|       return TR("--- Codice Nostra banca non valido o non presente in archivio");
 | |
| 		break;
 | |
| 		case 29:
 | |
|       return TR("--- Codice Vostra banca non valido o non presente in archivio");
 | |
| 		break;
 | |
| 		case 30:
 | |
|       return TR("--- Codice agente non valido o non presente in archivio");          
 | |
| 		break;
 | |
| 		case 31:
 | |
|       return TR("--- Data sollecito non valida");
 | |
| 		break;
 | |
| 		case 32:
 | |
|       return TR("*** Rif. fattura errato");
 | |
| 		break;
 | |
| 		case 33:
 | |
|       return TR("*** Rif. rata fattura errato");
 | |
| 		break;
 | |
| 		case 34:
 | |
|       return TR("*** In acconto/a saldo errato");
 | |
| 		break;
 | |
| 		case 35:
 | |
|       return TR("*** Importo inc./pag. in lire mancante");
 | |
| 		break;
 | |
| 		case 36:
 | |
|       return TR("*** Importo inc./pag. in valuta mancante");
 | |
| 		break;
 | |
| 		case 37:
 | |
|       return TR("*** Flag abbuono attivo/passivo errato");
 | |
| 		break;
 | |
| 		case 38:
 | |
|       return TR("*** Codice valuta errato");
 | |
| 		break;
 | |
| 		case 39:
 | |
|       return TR("*** Tipo movimento causale non congruo con tipo movimento saldaconto");
 | |
| 		break;
 | |
| 		case 40:
 | |
|       return TR("--- Tipo pagamento del codice di pagamento non congruo con tipo pagamento del saldaconto");
 | |
| 		break;
 | |
| 		default:
 | |
| 			return "";
 | |
| 		break;
 | |
| 	}
 | |
| }
 | |
| 
 | |
| bool TRic_ListaMov::controlla_partite()
 | |
| {
 | |
|   if (_tipocf != 'C' && _tipocf != 'F' && _tipocf != '\0')
 | |
|   {
 | |
|     _errore_grave_SC = TRUE;
 | |
|     _err.set(13);
 | |
|   }
 | |
|   
 | |
|   if (!controlla_anaCF_Pcon(_tipocf,_gruppo,_conto,_codcf))
 | |
|   {
 | |
|     _errore_grave_SC = TRUE;
 | |
|     _err.set(14);
 | |
|   }
 | |
|   
 | |
|   if (_anno == 0 || _numpart.empty() || _nriga == 0)
 | |
|   {
 | |
|     _errore_grave_SC = TRUE;
 | |
|     _err.set(15);
 | |
|   }
 | |
|   
 | |
|   if ( !TDate::isdate(_datareg.string()) )
 | |
|   {
 | |
|     _errore_grave_SC = TRUE;
 | |
|     _err.set(0L);
 | |
|   }
 | |
|   
 | |
|   TString16 dd = _datadoc.string();
 | |
|   if (dd.not_empty()) 
 | |
|     if ( !TDate::isdate(_datadoc.string()) )
 | |
|       _err.set(6);
 | |
|   
 | |
|   if (_causale.empty())
 | |
|   {                   
 | |
|     _descr_causale = "";
 | |
|     if (_numreg != 0)
 | |
|     {
 | |
|       _errore_grave_SC = TRUE;
 | |
|       _err.set(7); 
 | |
|     } 
 | |
|   }
 | |
|   else
 | |
|   {   
 | |
|     TLocalisamfile caus(LF_CAUSALI);
 | |
|     caus.setkey(1);
 | |
|     caus.zero();
 | |
|     caus.put(CAU_CODCAUS,_causale);
 | |
|     if (caus.read() != NOERR)   
 | |
|     {
 | |
|       caus.zero();
 | |
|       _errore_grave_SC = TRUE;
 | |
|       _err.set(7); 
 | |
|     } 
 | |
|     _descr_causale = caus.get(CAU_DESCR);     
 | |
|     int tipomov_caus   = caus.get_int(CAU_TIPOMOV);
 | |
|     if (_tipomov != tipomov_caus)
 | |
|     {
 | |
|       _errore_grave_SC = TRUE;
 | |
|       _err.set(39);
 | |
|     }
 | |
|   }
 | |
|                  
 | |
|   if (_codval.not_empty())
 | |
|   {
 | |
|     TTable val ("%VAL");
 | |
|     val.put("CODTAB", _codval);
 | |
|     if (val.read() != NOERR)
 | |
|     {
 | |
|      _errore_grave_SC = TRUE;
 | |
|      _err.set(38);    
 | |
|     }   
 | |
| 
 | |
|     if (_cambio == ZERO)
 | |
|     {
 | |
|      _errore_grave_SC = TRUE;
 | |
|      _err.set(21);
 | |
|     }
 | |
|     
 | |
|     TString16 dcam = _datacam.string();
 | |
|       if (dcam.empty() || !TDate::isdate(_datacam.string()) ) 
 | |
|         _err.set(17);
 | |
|   }
 | |
|   
 | |
|   if (_tipomov != 1)
 | |
|   {       
 | |
|     if (esiste_rata())
 | |
|     {
 | |
|       if (_tipopag < 1 || _tipopag > 9)
 | |
|       {
 | |
|         _errore_grave_SC = TRUE;
 | |
|         _err.set(19);    
 | |
|       }    
 | |
|       TString datapag_str = _datapag.string();
 | |
|       if ( datapag_str.empty() || !TDate::isdate(_datapag.string()) )     
 | |
|       {
 | |
|        _errore_grave_SC = TRUE;
 | |
|        _err.set(18);
 | |
|       }  
 | |
|     }
 | |
|   }
 | |
| 
 | |
|   if (_gruppocl != 0 && _contocl != 0)
 | |
|   {
 | |
|     if (!controlla_anagrafica(_tipocf,_gruppocl,_contocl))    
 | |
|     {
 | |
|       _errore_grave_SC = TRUE;
 | |
|       _err.set(22);
 | |
|     }
 | |
|   }
 | |
| 
 | |
|   if (_sez != 'D' && _sez != 'A')
 | |
|   {
 | |
|     _errore_grave_SC = TRUE;
 | |
|     _err.set(20);    
 | |
|   }
 | |
|   
 | |
|   if (_err.ones())
 | |
|     return TRUE;
 | |
|   
 | |
|   return FALSE;   
 | |
| }
 | |
|                      
 | |
| bool TRic_ListaMov::cerca_codpag(TString& codpag)
 | |
| {             
 | |
|   TTable cpg ("%CPG"); 
 | |
|   
 | |
|   _descr_pag = "";
 | |
|   
 | |
|   cpg.zero();
 | |
|   cpg.put("CODTAB", codpag);
 | |
|   if (cpg.read() == NOERR)      
 | |
|   { 
 | |
|     _descr_pag   = cpg.get("S0");  
 | |
| //    _tipopag_pag = atoi(cpg.get("S4"));
 | |
|     return TRUE;
 | |
|   }                            
 | |
|     
 | |
|   return FALSE;
 | |
| }
 | |
| 
 | |
| bool TRic_ListaMov::cerca_tipopag_codpag(TString& codpag, int tipopag)
 | |
| {             
 | |
|   TTable rpg ("%RPG");
 | |
|   TString16 dep; 
 | |
|    
 | |
|   for (int i = 0; ; i++)
 | |
|   { 
 | |
|     dep.format("%-s%3d", (const char*) codpag, i);
 | |
|     rpg.put("CODTAB", dep);
 | |
|     if (rpg.read() == NOERR)      
 | |
|     {         
 | |
|       const int tipo = rpg.get_int("I1");
 | |
|       if (tipo == tipopag) 
 | |
|       {
 | |
|         _tipopag_pag = tipo;
 | |
|         return TRUE;  
 | |
|       }
 | |
|     } 
 | |
|     else
 | |
|       break;
 | |
|   }                            
 | |
|     
 | |
|   return FALSE;
 | |
| }
 | |
| 
 | |
| bool TRic_ListaMov::ulteriore_classificazione(int tipopag, TString& ultclass)
 | |
| {
 | |
|   TTable clr ("%CLR");
 | |
|   
 | |
|   TString4 dep; dep.format("%d%s", tipopag, (const char*) ultclass);
 | |
|   
 | |
|   clr.zero();
 | |
|   clr.put("CODTAB", dep);
 | |
|   if (clr.read() == NOERR)
 | |
|     return TRUE;
 | |
|     
 | |
|   return FALSE;
 | |
| }
 | |
| 
 | |
| bool TRic_ListaMov::banca(long abi,long cab)
 | |
| { 
 | |
|   if (abi == 0 && cab == 0)
 | |
|     return TRUE;
 | |
|               
 | |
|   TTable ban ("%BAN");
 | |
|   TString dep;
 | |
|   
 | |
|   if (abi != 0 && cab != 0)
 | |
|     dep.format("%05ld%05ld", abi,cab);
 | |
|   if (abi != 0 && cab == 0)           
 | |
|     dep.format("%05ld", abi);
 | |
|                        
 | |
|   ban.zero();
 | |
|   ban.put("CODTAB", dep);
 | |
|   if (ban.read() == NOERR)
 | |
|     return TRUE;
 | |
|     
 | |
|   return FALSE;
 | |
| }
 | |
| 
 | |
| bool TRic_ListaMov::agente(const char* codag) const
 | |
| {   
 | |
|   static int test_file = -1;
 | |
| 
 | |
|   bool ok = TRUE;
 | |
|   if (codag && *codag)
 | |
|   {                         
 | |
|     if (test_file < 0)
 | |
|     {
 | |
|       TDir d; d.get(LF_AGENTI);
 | |
|       const TFilename fn = d.filename();
 | |
|       test_file = fn.exist();        // Controlla l'esistenza del file
 | |
|     }
 | |
|     if (test_file)
 | |
|     {
 | |
|       const TRectype& age = cache().get(LF_AGENTI, codag);
 | |
|       ok = !age.empty();
 | |
|     }
 | |
|   }
 | |
|   return ok;
 | |
| }
 | |
| 
 | |
| bool TRic_ListaMov::controlla_scadenze()
 | |
| {       
 | |
|   int     tipopag,nrata;
 | |
|   TString codpag,ultclass,codag;                     
 | |
|   TDate   datascad,datasoll;
 | |
|   real    importo,importoval;
 | |
|   long    abins,cabns,abivs,cabvs;
 | |
|   
 | |
|   importo    = ZERO;
 | |
|   importoval = ZERO;
 | |
|   
 | |
|   TLocalisamfile& scad = current_cursor()->file(LF_SCADENZE);
 | |
|   
 | |
|   if (current_cursor()->is_first_match(LF_SCADENZE))
 | |
|   {
 | |
|     TRecnotype nrec = scad.recno();
 | |
|     scad.zero();
 | |
|     scad.setkey(1);
 | |
|     scad.put(SCAD_TIPOCF,     _tipocf);  
 | |
|     if (_gruppo != 0)
 | |
|       scad.put(SCAD_GRUPPO,     _gruppo);
 | |
|     if (_conto != 0)
 | |
|       scad.put(SCAD_CONTO,      _conto);
 | |
|     if (_codcf != 0)  
 | |
|       scad.put(SCAD_SOTTOCONTO, _codcf);
 | |
|     scad.put(SCAD_ANNO,       _anno);
 | |
|     scad.put(SCAD_NUMPART,    _numpart);
 | |
|     scad.put(SCAD_NRIGA,      _nriga);
 | |
|     TRectype recc (scad.curr());
 | |
|     for (scad.read(_isgteq); !scad.eof() ;scad.next())
 | |
|     {
 | |
|       TRectype rec (scad.curr()); 
 | |
|       
 | |
|       TString filea = recc.get(SCAD_NUMPART);
 | |
|       TString file  = rec.get(SCAD_NUMPART);
 | |
|       
 | |
|       if (rec != recc || file != filea) break;
 | |
|       
 | |
|       nrata      = rec.get_int (SCAD_NRATA);
 | |
|       tipopag    = rec.get_int (SCAD_TIPOPAG);
 | |
|       codpag     = rec.get     (SCAD_CODPAG);
 | |
|       ultclass   = rec.get     (SCAD_ULTCLASS);
 | |
|       datascad   = rec.get_date(SCAD_DATASCAD);
 | |
|       datasoll   = rec.get_date(SCAD_DATASOLL); 
 | |
|       importo    = rec.get_real(SCAD_IMPORTO);
 | |
|       importoval = rec.get_real(SCAD_IMPORTOVAL); 
 | |
|       abins      = rec.get_long(SCAD_CODABIPR);
 | |
|       cabns      = rec.get_long(SCAD_CODCABPR);
 | |
|       abivs      = rec.get_long(SCAD_CODABI);
 | |
|       cabvs      = rec.get_long(SCAD_CODCAB);
 | |
|       codag      = rec.get     (SCAD_CODAG);
 | |
|       
 | |
|       if (nrata == 0)
 | |
|       {
 | |
|         scad.readat(nrec);
 | |
|         return TRUE;
 | |
|       }  
 | |
|       if ( !TDate::isdate(datascad.string()) )
 | |
|       {
 | |
|         scad.readat(nrec);
 | |
|         return TRUE;
 | |
|       }   
 | |
|       if (codpag.not_empty())        // Modifica 01-10-96 chiesta da Patrizia: se il codice di 
 | |
|       {                              // pagamento non e' significativo non va controllato,
 | |
|         if (!cerca_codpag(codpag))   // altrimenti si presenta l'errore su quelle partite 
 | |
|         {                            // generate in automatico dove non e' possibile indicare
 | |
|           scad.readat(nrec);         // il codice di pagamento.
 | |
|           return TRUE;      
 | |
|         }
 | |
|         if (tipopag < 1 || tipopag > 9)
 | |
|         {
 | |
|           scad.readat(nrec);
 | |
|           return TRUE;
 | |
|         }
 | |
|         if (!cerca_tipopag_codpag(codpag,tipopag))
 | |
|         {
 | |
|           scad.readat(nrec);
 | |
|           return TRUE;
 | |
|         } 
 | |
|       }
 | |
|       if (ultclass.not_empty())
 | |
|       {
 | |
|         if (!ulteriore_classificazione(tipopag,ultclass))
 | |
|         {
 | |
|           scad.readat(nrec);
 | |
|           return TRUE;
 | |
|         }
 | |
|       }  
 | |
|       if (importo == ZERO)
 | |
|       {
 | |
|         scad.readat(nrec);
 | |
|         return TRUE;
 | |
|       }             
 | |
|       if (_codval.not_empty() && importoval == ZERO)
 | |
|       {
 | |
|         scad.readat(nrec);
 | |
|         return TRUE;
 | |
|       }          
 | |
|       if (!banca(abins,cabns))
 | |
|       {
 | |
|         scad.readat(nrec);
 | |
|         return TRUE;
 | |
|       }             
 | |
|       if (!banca(abivs,cabvs))
 | |
|       {
 | |
|         scad.readat(nrec);
 | |
|         return TRUE;
 | |
|       }             
 | |
|       if (!agente(codag))
 | |
|       {
 | |
|         scad.readat(nrec);
 | |
|         return TRUE;
 | |
|       }    
 | |
|       TString datasoll_str = datasoll.string();
 | |
|       if ( datasoll_str.not_empty() && !TDate::isdate(datasoll.string()) )
 | |
|       {
 | |
|         scad.readat(nrec);
 | |
|         return TRUE;
 | |
|       }
 | |
|     }
 | |
|     scad.readat(nrec);
 | |
|   }
 | |
|   return FALSE;  
 | |
| }
 | |
| 
 | |
| void TRic_ListaMov::descrizione_pagamento(TString& descr,int tipopag,TString& ultclass,TString& codpag)
 | |
| {  
 | |
|   TString dep;
 | |
|   
 | |
|   if (ultclass.not_empty())
 | |
|   {
 | |
|     TTable clr ("%CLR");
 | |
|     
 | |
|     dep.format("%d%s", tipopag,(const char*) ultclass);
 | |
|     
 | |
|     clr.zero();
 | |
|     clr.put("CODTAB", dep);
 | |
|     if (clr.read() == NOERR)
 | |
|       descr = clr.get("S0");
 | |
|     else 
 | |
|       descr = "";
 | |
|   }
 | |
|   else
 | |
|   {
 | |
|     TTable rpg ("%RPG");
 | |
|     int tipo;
 | |
|     
 | |
|     for (int i = 0; !rpg.eof(); rpg.next(), i++)
 | |
|     {
 | |
|       dep.format("%-s%3d", (const char*) codpag, i);
 | |
|     
 | |
|       rpg.zero();
 | |
|       rpg.put("CODTAB", dep);
 | |
|       if (rpg.read() == NOERR)   
 | |
|       {
 | |
|         tipo = rpg.get_int("I1");
 | |
|         if (tipo == tipopag)
 | |
|         {
 | |
|           switch(tipo)
 | |
|           {
 | |
|             case 1: descr = TR("Rimessa diretta");
 | |
|                     break;
 | |
|             case 2: descr = TR("Tratta");
 | |
|                     break;
 | |
|             case 3: descr = TR("Ricevuta bancaria");
 | |
|                     break;
 | |
|             case 4: descr = TR("Cessione");
 | |
|                     break;
 | |
|             case 5: descr = TR("Paghero'");
 | |
|                     break;
 | |
|             case 6: descr = TR("Lettera di credito");
 | |
|                     break;
 | |
|             case 7: descr = TR("Tratta accettata");
 | |
|                     break;
 | |
|             case 8: descr = TR("Rapporti interbancari diretti");
 | |
|                     break;
 | |
|             case 9: descr = TR("Bonifico");
 | |
|                     break;
 | |
|             case 10: descr = TR("Altro");
 | |
|                      break;
 | |
|             default: break;
 | |
|           };
 | |
|           break;
 | |
|         }
 | |
|       }  
 | |
|       else
 | |
|       {
 | |
|         descr = ""; 
 | |
|         break;
 | |
|       }
 | |
|     }    
 | |
|   }
 | |
| }
 | |
| 
 | |
| void TRic_ListaMov::stampa_errori_scadenze(int riga)
 | |
| {                                 
 | |
|   TCursor* cur = current_cursor();
 | |
|   
 | |
|   TString numpart    = cur->curr(LF_SCADENZE).get     (SCAD_NUMPART);
 | |
|   int     nriga      = cur->curr(LF_SCADENZE).get_int (SCAD_NRIGA);
 | |
|   int     nrata      = cur->curr(LF_SCADENZE).get_int (SCAD_NRATA);
 | |
|   int     tipopag    = cur->curr(LF_SCADENZE).get_int (SCAD_TIPOPAG);
 | |
|   TString codpag     = cur->curr(LF_SCADENZE).get     (SCAD_CODPAG);
 | |
|   TString ultclass   = cur->curr(LF_SCADENZE).get     (SCAD_ULTCLASS);
 | |
|   TDate   datascad   = cur->curr(LF_SCADENZE).get_date(SCAD_DATASCAD);
 | |
|   TDate   datasoll   = cur->curr(LF_SCADENZE).get_date(SCAD_DATASOLL);
 | |
|   real    importo    = cur->curr(LF_SCADENZE).get_real(SCAD_IMPORTO);
 | |
|   real    importoval = cur->curr(LF_SCADENZE).get_real(SCAD_IMPORTOVAL);
 | |
|   long    abins      = cur->curr(LF_SCADENZE).get_long(SCAD_CODABIPR);
 | |
|   long    cabns      = cur->curr(LF_SCADENZE).get_long(SCAD_CODCABPR);
 | |
|   long    abivs      = cur->curr(LF_SCADENZE).get_long(SCAD_CODABI);
 | |
|   long    cabvs      = cur->curr(LF_SCADENZE).get_long(SCAD_CODCAB);
 | |
|   TString codag      = cur->curr(LF_SCADENZE).get     (SCAD_CODAG);
 | |
|   
 | |
|   TString descr_pagamento;
 | |
|   descrizione_pagamento(descr_pagamento,tipopag,ultclass,codpag);
 | |
| 
 | |
|   if (_prima_rata_pag)
 | |
|   {
 | |
|     set_row(riga,FR("@26gN.rata      Data scad.  Sez          Importo  Importo valuta"));
 | |
|     set_row(riga++,FR("@88gCond.pagamento                                                        Nostra banca  Vostra banca    Agente"));
 | |
|     _prima_rata_pag = FALSE;
 | |
|   }
 | |
|   set_row(riga,"@27g%4d", nrata);
 | |
|   set_row(riga,"@38g%10s", (const char*) datascad.string());
 | |
|   set_row(riga,"@51g%c", _sez);
 | |
|   set_row(riga,"@55g%r", &importo);
 | |
|   if (importoval != ZERO)
 | |
|     set_row(riga,"@71g%15s", importoval.string("###.###.###,@@@"));  
 | |
|   set_row(riga,"@88g%-4s", (const char*) codpag);
 | |
|   set_row(riga,"@92g/@93g%d", tipopag);
 | |
|   set_row(riga,"@94g/@95g%s", (const char*) ultclass);
 | |
|   set_row(riga,"@100g%-50s", (const char*) descr_pagamento);
 | |
|   if (abins != 0)
 | |
|     set_row(riga,"@158g%ld", abins);
 | |
|   if (cabns != 0)
 | |
|     set_row(riga,"@165g%ld", cabns);
 | |
|   if (abivs != 0)
 | |
|     set_row(riga,"@172g%ld", abivs);
 | |
|   if (cabvs != 0)
 | |
|     set_row(riga,"@179g%ld", cabvs);
 | |
|   set_row(riga,"@189g%-5s", (const char*) codag);
 | |
|   
 | |
|   if (nrata == 0)
 | |
|   {
 | |
|     _errore_grave_SC = TRUE;
 | |
|     set_row(++riga, "@30g%s", get_error(23));
 | |
|   }  
 | |
|   if ( !TDate::isdate(datascad.string()) )
 | |
|   {
 | |
|     _errore_grave_SC = TRUE;
 | |
|     set_row(++riga, "@30g%s", get_error(24));
 | |
|   }
 | |
|   if (codpag.not_empty())          // Modifica 01-10-96 chiesta da Patrizia: per spiegazione vedi
 | |
|   {                                // funzione controlla_scadenze();
 | |
|     if (!cerca_codpag(codpag)) 
 | |
|     {
 | |
|       _errore_grave_SC = TRUE;
 | |
|       set_row(++riga, "@30g*** Codice pagamento non valido o non presente in tabella");
 | |
|     }
 | |
|     if (tipopag < 1 || tipopag > 9)
 | |
|     {
 | |
|       _errore_grave_SC = TRUE;
 | |
|       set_row(++riga, "@30g%s", get_error(19));
 | |
|     }
 | |
|     
 | |
|     if (!cerca_tipopag_codpag(codpag,tipopag))
 | |
|     {
 | |
|       // _errore_grave_SC = TRUE;   // CM700491
 | |
|       set_row(++riga, "@30g%s",  get_error(40));
 | |
|     } 
 | |
|   }
 | |
|   if (ultclass.not_empty())
 | |
|   {
 | |
|     if (!ulteriore_classificazione(tipopag,ultclass))
 | |
|       set_row(++riga, "@30g%s", get_error(25));
 | |
|   }  
 | |
|   if (importo == ZERO)
 | |
|   {
 | |
|     _errore_grave_SC = TRUE;
 | |
|     set_row(++riga, "@30g%s", get_error(26));
 | |
|   }             
 | |
|   if (_codval.not_empty() && importoval == ZERO)
 | |
|   {
 | |
|     _errore_grave_SC = TRUE;
 | |
|     set_row(++riga, "@30g%s", get_error(27));
 | |
|   }          
 | |
|   if (!banca(abins,cabns))
 | |
|     set_row(++riga, "@30g%s", get_error(28));
 | |
|              
 | |
|   if (!banca(abivs,cabvs))
 | |
|     set_row(++riga, "@30g%s", get_error(29));
 | |
|              
 | |
|   if (!agente(codag))
 | |
|     set_row(++riga, "@30g%s", get_error(30));
 | |
|   
 | |
|   TString datasoll_str = datasoll.string();
 | |
|   if ( datasoll_str.not_empty() && !TDate::isdate(datasoll.string()) )
 | |
|     set_row(++riga, "@30g%s", get_error(31));
 | |
| }
 | |
| 
 | |
| bool TRic_ListaMov::record_partite(int nriga)
 | |
| {         
 | |
|   bool ok = FALSE;
 | |
|   for (int p = 0; p < 2 && !ok; p++)
 | |
|   {                         
 | |
|     TLocalisamfile* fpart = p == 0 ? _tpart : _part;
 | |
|     TLocalisamfile& part = *fpart;
 | |
|     const TRecnotype nrec = part.recno();
 | |
|     part.zero();
 | |
|     part.put(PART_TIPOCF,     _tipocf);
 | |
|     part.put(PART_GRUPPO,     _gruppo);
 | |
|     part.put(PART_CONTO,      _conto);
 | |
|     part.put(PART_SOTTOCONTO, _codcf);
 | |
|     part.put(PART_ANNO,       _anno);
 | |
|     part.put(PART_NUMPART,    _numpart);
 | |
|     part.put(PART_NRIGA,      nriga);
 | |
|     ok = part.read() == NOERR;
 | |
|     part.readat(nrec);
 | |
|   }  
 | |
|   return ok;
 | |
| }
 | |
| 
 | |
| bool TRic_ListaMov::record_scadenze(int nrigp,int nrata)
 | |
| {
 | |
|   bool ok = FALSE;
 | |
|   for (int p = 0; p < 2 && !ok; p++)
 | |
|   {                         
 | |
|     TLocalisamfile* fscad = p == 0 ? _tscad : _scad;
 | |
|     TLocalisamfile& scad = *fscad;
 | |
| 
 | |
|     const TRecnotype nrec = scad.recno();
 | |
|   
 | |
|     scad.zero();
 | |
|     scad.put(SCAD_TIPOCF,     _tipocf);
 | |
|     scad.put(SCAD_GRUPPO,     _gruppo);
 | |
|     scad.put(SCAD_CONTO,      _conto);
 | |
|     scad.put(SCAD_SOTTOCONTO, _codcf);
 | |
|     scad.put(SCAD_ANNO,       _anno);
 | |
|     scad.put(SCAD_NUMPART,    _numpart);
 | |
|     scad.put(SCAD_NRIGA,      nrigp); 
 | |
|     scad.put(SCAD_NRATA,      nrata);
 | |
|     ok = scad.read() == NOERR;
 | |
|     scad.readat(nrec);
 | |
|   }
 | |
|   return ok;
 | |
| }
 | |
| 
 | |
| bool TRic_ListaMov::controlla_pagsca()
 | |
| {                                   
 | |
|   char    tipoc,accsaldo,passat;
 | |
|   int     nriga,nrata,gruppoc,contoc;
 | |
|   TString codag;                     
 | |
|   real    importo,importoval,abbuoni;
 | |
|   long    abins,cabns,abivs,cabvs,sottocc;
 | |
|   bool    errore_non_grave = FALSE;
 | |
|   
 | |
|   importo    = ZERO;
 | |
|   importoval = ZERO;
 | |
|   
 | |
|   TLocalisamfile& pagsca = current_cursor()->file(LF_PAGSCA);
 | |
|   
 | |
|   if (current_cursor()->is_first_match(LF_PAGSCA))
 | |
|   {
 | |
|     TRecnotype nrec = pagsca.recno();
 | |
|     pagsca.zero();
 | |
|     pagsca.setkey(1);
 | |
|     pagsca.put(PAGSCA_TIPOC,     _tipocf);  
 | |
|     if (_gruppo != 0)
 | |
|       pagsca.put(PAGSCA_GRUPPO,     _gruppo);
 | |
|     if (_conto != 0)
 | |
|       pagsca.put(PAGSCA_CONTO,      _conto);
 | |
|     if (_codcf != 0)  
 | |
|       pagsca.put(PAGSCA_SOTTOCONTO, _codcf);
 | |
|     pagsca.put(PAGSCA_ANNO,       _anno);
 | |
|     pagsca.put(PAGSCA_NUMPART,    _numpart);
 | |
|     
 | |
|     TRectype recc (pagsca.curr());
 | |
|     for (pagsca.read(_isgteq); !pagsca.eof() ;pagsca.next())
 | |
|     {                               
 | |
|       int nrigp  = pagsca.get_int(PAGSCA_NRIGP);
 | |
|       TRectype rec (pagsca.curr());
 | |
|       
 | |
|       TString filea = recc.get(PAGSCA_NUMPART);
 | |
|       TString file  = rec.get(PAGSCA_NUMPART);
 | |
|       
 | |
|       if (rec != recc || file != filea) break;
 | |
|       if (nrigp != _nriga) continue;
 | |
|       
 | |
|       nriga      = rec.get_int (PAGSCA_NRIGA);
 | |
|       nrata      = rec.get_int (PAGSCA_NRATA);
 | |
|       accsaldo   = rec.get_char(PAGSCA_ACCSAL);
 | |
|       importo    = rec.get_real(PAGSCA_IMPORTO);
 | |
|       importoval = rec.get_real(PAGSCA_IMPORTOVAL);  
 | |
|       abbuoni    = rec.get_real(PAGSCA_ABBUONI);
 | |
|       passat     = rec.get_char(PAGSCA_PASSATT);
 | |
|       abins      = rec.get_long(PAGSCA_CODABIPR);
 | |
|       cabns      = rec.get_long(PAGSCA_CODCABPR);
 | |
|       abivs      = rec.get_long(PAGSCA_CODABI);
 | |
|       cabvs      = rec.get_long(PAGSCA_CODCAB);
 | |
|       codag      = rec.get     (PAGSCA_CODAG); 
 | |
|       tipoc      = rec.get_char(PAGSCA_TIPOCC);
 | |
|       gruppoc    = rec.get_int (PAGSCA_GRUPPOC);
 | |
|       contoc     = rec.get_int (PAGSCA_CONTOC);
 | |
|       sottocc    = rec.get_long(PAGSCA_SOTTOCONTC);
 | |
|       
 | |
|       if (nriga != 9999)
 | |
|       { 
 | |
|         if (!record_partite(nriga))
 | |
|         {
 | |
|           pagsca.readat(nrec);
 | |
|           return TRUE;
 | |
|         }
 | |
|       }  
 | |
|       if (nrata != 9999)
 | |
|       {
 | |
|         if (!record_scadenze(nriga,nrata))
 | |
|         {
 | |
|           pagsca.readat(nrec);
 | |
|           return TRUE;
 | |
|         }
 | |
|       }               
 | |
|       if (accsaldo != 'A' && accsaldo != 'S')
 | |
|       {
 | |
|         pagsca.readat(nrec);
 | |
|         return TRUE;
 | |
|       }
 | |
|       if (importo == ZERO) 
 | |
|       {
 | |
|         pagsca.readat(nrec);
 | |
|         return TRUE;      
 | |
|       }
 | |
|       if (_codval.not_empty() && importoval == ZERO)
 | |
|       {
 | |
|         pagsca.readat(nrec);
 | |
|         return TRUE;
 | |
|       }
 | |
|       if (abbuoni != ZERO && (passat != 'A' && passat != 'P') )
 | |
|       {
 | |
|         pagsca.readat(nrec);
 | |
|         return TRUE;
 | |
|       }  
 | |
|       if (!banca(abins,cabns))
 | |
|         errore_non_grave = TRUE;
 | |
|       if (!banca(abivs,cabvs))
 | |
|         errore_non_grave = TRUE;
 | |
|       if (!agente(codag))
 | |
|         errore_non_grave = TRUE;
 | |
|       if (!controlla_anaCF_Pcon(tipoc,gruppoc,contoc,sottocc))
 | |
|         errore_non_grave = TRUE;
 | |
|     }
 | |
|     pagsca.readat(nrec);        
 | |
|     if (errore_non_grave )
 | |
|       return TRUE;
 | |
|   }
 | |
|   return FALSE;  
 | |
| }
 | |
| 
 | |
| void TRic_ListaMov::stampa_errori_pagsca(int riga)
 | |
| {                                 
 | |
|   TCursor* cur = current_cursor();
 | |
|   const TRectype& pagsca = cur->curr(LF_PAGSCA);
 | |
|   
 | |
|   int nrigp = pagsca.get_int (PAGSCA_NRIGP);
 | |
|   if (nrigp == _nriga)
 | |
|   {
 | |
|     int     nriga      = pagsca.get_int (PAGSCA_NRIGA);
 | |
|     int     nrata      = pagsca.get_int (PAGSCA_NRATA);
 | |
|     char    accsaldo   = pagsca.get_char(PAGSCA_ACCSAL);
 | |
|     real    importo    = pagsca.get_real(PAGSCA_IMPORTO);
 | |
|     real    importoval = pagsca.get_real(PAGSCA_IMPORTOVAL);
 | |
|     real    abbuoni    = pagsca.get_real(PAGSCA_ABBUONI);
 | |
|     real    ritenute   = pagsca.get_real(PAGSCA_RITENUTE);
 | |
|     real    ritsoc     = pagsca.get_real(PAGSCA_RITSOC);
 | |
|     real    diffcam    = pagsca.get_real(PAGSCA_DIFFCAM);
 | |
|     char    passat     = pagsca.get_char(PAGSCA_PASSATT);
 | |
|     long    abins      = pagsca.get_long(PAGSCA_CODABIPR);
 | |
|     long    cabns      = pagsca.get_long(PAGSCA_CODCABPR);
 | |
|     long    abivs      = pagsca.get_long(PAGSCA_CODABI);
 | |
|     long    cabvs      = pagsca.get_long(PAGSCA_CODCAB);
 | |
|     TString codag      = pagsca.get     (PAGSCA_CODAG);  
 | |
|     char    tipoc      = pagsca.get_char(PAGSCA_TIPOCC);
 | |
|     int     gruppoc    = pagsca.get_int (PAGSCA_GRUPPOC);
 | |
|     int     contoc     = pagsca.get_int (PAGSCA_CONTOC);
 | |
|     long    sottocc    = pagsca.get_long(PAGSCA_SOTTOCONTC);
 | |
|   
 | |
|     controlla_anaCF_Pcon(tipoc,gruppoc,contoc,sottocc);
 | |
|   
 | |
|     if (_prima_rata_pag)
 | |
|     {                   
 | |
|       set_row(riga,FR("@22gRif. rata       acc./saldo  Sez          Importo  Importo valuta  Contropartita"));
 | |
|       set_row(riga++,FR("@158gNostra banca  Vostra banca    Agente"));
 | |
|       _prima_rata_pag = FALSE;
 | |
|     }     
 | |
|     else
 | |
|       set_row(riga++, "");
 | |
|     
 | |
|     set_row(riga,"@22g%4d", nriga);
 | |
|     set_row(riga,"@26g/@27g%4d", nrata);
 | |
|     set_row(riga,"@42g%c", accsaldo);
 | |
|     set_row(riga,"@51g%c", _sez);
 | |
|     set_row(riga,"@55g%r", &importo);
 | |
|     if (importoval != ZERO)
 | |
|       set_row(riga,"@71g%15s", (const char*) importoval.string("###.###.###,@@@"));  
 | |
|     set_row(riga,"@88g%c", tipoc); 
 | |
|     if (gruppoc != 0)
 | |
|       set_row(riga,"@90g%3d", gruppoc);
 | |
|     if (contoc != 0)
 | |
|       set_row(riga,"@94g%3d", contoc);
 | |
|     if (sottocc != 0)         
 | |
|     {
 | |
|       set_row(riga,"@98g%6ld", sottocc); 
 | |
|       set_row(riga,"@105g%-50s", (const char*) _descr_anag);
 | |
|     }
 | |
|     if (abins != 0)
 | |
|       set_row(riga,"@158g%ld", abins);
 | |
|     if (cabns != 0)
 | |
|       set_row(riga,"@165g%ld", cabns);
 | |
|     if (abivs != 0)
 | |
|       set_row(riga,"@172g%ld", abivs);
 | |
|     if (cabvs != 0)
 | |
|       set_row(riga,"@179g%ld", cabvs);
 | |
|     set_row(riga,"@189g%-5s", (const char*) codag);
 | |
|     if (ritenute != ZERO)
 | |
|     { 
 | |
|       riga++;
 | |
|       set_row(riga,"@51g%c", _sez);
 | |
|       set_row(riga,"@55g%r", &ritenute);
 | |
|       set_row(riga,FR("@88gRitenute professionali"));
 | |
|     }
 | |
|     if (abbuoni != ZERO)
 | |
|     {             
 | |
|       riga++;
 | |
|       char sezione;
 | |
|       if (passat == 'A')
 | |
|         sezione = 'D';
 | |
|       else
 | |
|         if (passat == 'P')
 | |
|           sezione = 'A';
 | |
|     
 | |
|       if (sezione != _sez)
 | |
|         abbuoni = abbuoni * -1;
 | |
|           
 | |
|       set_row(riga,"@51g%c", sezione);  
 | |
|       if (_codval.not_empty())
 | |
|         set_row(riga,"@71g%15s", (const char*) abbuoni.string("###.###.###,@@@"));
 | |
|       else
 | |
|         set_row(riga,"@55g%r", &abbuoni);
 | |
|       if (passat == 'A')
 | |
|         set_row(riga,"@88gAbbuoni attivi");
 | |
|       else
 | |
|         if (passat == 'P')
 | |
|           set_row(riga,FR("@88gAbbuoni passivi"));
 | |
|     }                                    
 | |
|     if (diffcam != ZERO)
 | |
|     {             
 | |
|       riga++;
 | |
|       char sezione = _sez;
 | |
|       if (diffcam < ZERO)
 | |
|       {
 | |
|         diffcam = diffcam * -1;
 | |
|         if (_sez == 'D')
 | |
|           sezione = 'A';
 | |
|         else
 | |
|           if (_sez == 'A')
 | |
|             sezione = 'D';
 | |
|       }
 | |
|       set_row(riga,"@51g%c", sezione);
 | |
|       set_row(riga,"@55g%r", &diffcam);
 | |
|       set_row(riga,FR("@88gDifferenza cambio"));
 | |
|     }
 | |
| 
 | |
|     if (nriga != 9999)
 | |
|     { 
 | |
|       if (!record_partite(nriga))
 | |
|       {
 | |
|         _errore_grave_SC = TRUE;
 | |
|         set_row(++riga, "@30g%s", get_error(32));
 | |
|       }
 | |
|     }  
 | |
|     if (nrata != 9999)
 | |
|     {
 | |
|       if (!record_scadenze(nriga,nrata))
 | |
|       {
 | |
|         _errore_grave_SC = TRUE;
 | |
|         set_row(++riga, "@30g%s", get_error(33));
 | |
|       }
 | |
|     }               
 | |
|     if (accsaldo != 'A' && accsaldo != 'S')
 | |
|     {
 | |
|       _errore_grave_SC = TRUE;
 | |
|       set_row(++riga, "@30g%s", get_error(34));
 | |
|     }
 | |
|     if (importo == ZERO)
 | |
|     {
 | |
|       _errore_grave_SC = TRUE;
 | |
|       set_row(++riga, "@30g%s", get_error(35));
 | |
|     }             
 | |
|     if (_codval.not_empty() && importoval == ZERO)
 | |
|     {
 | |
|       _errore_grave_SC = TRUE;
 | |
|       set_row(++riga, "@30g%s", get_error(36));
 | |
|     }          
 | |
|     if (abbuoni != ZERO && (passat != 'A' && passat != 'P') )
 | |
|     {
 | |
|       _errore_grave_SC = TRUE;
 | |
|       set_row(++riga, "@30g%s", get_error(37));
 | |
|     }  
 | |
|     if (!banca(abins,cabns))
 | |
|       set_row(++riga, "@30g%s", get_error(28));
 | |
|              
 | |
|     if (!banca(abivs,cabvs))
 | |
|       set_row(++riga, "@30g%s", get_error(29));
 | |
|              
 | |
|     if (!agente(codag))
 | |
|       set_row(++riga, "@30g%s", get_error(30));
 | |
| 
 | |
|     if (!controlla_anaCF_Pcon(tipoc,gruppoc,contoc,sottocc))
 | |
|       set_row(++riga, FR("@30g--- Codice contropartita errato"));
 | |
|   }  
 | |
| }
 | |
| 
 | |
| void TRic_ListaMov::azzera_impdocval()
 | |
| {
 | |
|   TRecnotype recn = _tpart->recno();
 | |
|   TIsamtempfile& part = *_tpart;
 | |
|    
 | |
|   part.setkey(1);
 | |
|   part.zero();
 | |
|    
 | |
|   for (part.first(); !part.eof(); part.next())
 | |
|   {
 | |
|     int tipomov = part.get_int(PART_TIPOMOV);
 | |
|     
 | |
|     if (tipomov != 1 && tipomov != 4)
 | |
|     {
 | |
|       part.zero(PART_IMPTOTDOC);
 | |
|       part.zero(PART_IMPTOTVAL);   
 | |
|       
 | |
|       part.rewrite();
 | |
|     }
 | |
|   }      
 | |
|   _tpart->readat(recn);
 | |
| }
 | |
| 
 | |
| bool TRic_ListaMov::preprocess_print(int file, int counter)
 | |
| {
 | |
|   if (file == LF_PARTITE)
 | |
|     azzera_impdocval();
 | |
|   
 | |
|   return TRUE;
 | |
| }
 | |
|  
 | |
| bool TRic_ListaMov::preprocess_page(int file,int counter)
 | |
| {
 | |
|   TCursor* cur = current_cursor();
 | |
| 
 | |
|   if (counter) return TRUE;
 | |
|   
 | |
|   reset_print();
 | |
|   
 | |
|   if (file == LF_MOV)
 | |
|   {
 | |
|     _anno     = cur->curr(LF_MOV).get_int(MOV_ANNOES);
 | |
|     _datacomp = cur->curr(LF_MOV).get_date(MOV_DATACOMP);
 | |
|     _datadoc  = cur->curr(LF_MOV).get_date(MOV_DATADOC);
 | |
|     _data74tr = cur->curr(LF_MOV).get_date(MOV_DATA74TER);
 | |
|     _causale  = cur->curr(LF_MOV).get(MOV_CODCAUS);
 | |
|     _registro = cur->curr(LF_MOV).get(MOV_REG);  
 | |
|     format_if_zero(_registro, 3);
 | |
|     _tipodoc  = cur->curr(LF_MOV).get(MOV_TIPODOC);
 | |
|     _numdoc   = cur->curr(LF_MOV).get(MOV_NUMDOC);
 | |
|     _datareg  = cur->curr(LF_MOV).get_date(MOV_DATAREG);
 | |
|     _codcf    = cur->curr(LF_MOV).get_long(MOV_CODCF);
 | |
|     _numero   = cur->curr(LF_MOV).get_long(MOV_NUMREG);
 | |
|     _protiva  = cur->curr(LF_MOV).get_long(MOV_PROTIVA);
 | |
|     _codval   = cur->curr(LF_MOV).get(MOV_CODVALI);
 | |
|     _codpag   = cur->curr(LF_MOV).get(MOV_CODPAG);
 | |
|     _annoiva  = _datareg.year();
 | |
|     
 | |
|     _tot_dare = _tot_avere = ZERO;
 | |
|     _tot_doc  = ZERO;
 | |
|     _tipodoc  = "";
 | |
|     _tipocf   = ' ';
 | |
|     
 | |
|     _ae = date2esc(_datareg);
 | |
|     
 | |
|     //_num_rec = cur->curr(LF_MOV).get_long(MOV_NUMGIO);
 | |
|     
 | |
|     bool controlla = controlla_mov(); //se TRUE => ci sono errori nella testata
 | |
|     bool veriva = FALSE;
 | |
|     if (_is_iva)                      //Va fatto solo se ho ricevuto anche l'iva
 | |
|       veriva = controlla_riva();
 | |
|     bool verrmov   = controlla_rmov();
 | |
|     bool verifica  = (veriva || verrmov);
 | |
|     
 | |
|     aggiorna_mov();
 | |
|     
 | |
|     if ( (_controllo == 1 && controlla) || _controllo == 2 ||
 | |
|          (_controllo == 1 && verifica) ) 
 | |
|     {
 | |
|       TString16 datareg_str = _datareg.string();
 | |
|       // "Fai vedere lo stesso ..-..-.... anche se non c'e' la data..."    
 | |
|       if (datareg_str.empty())
 | |
|         datareg_str = "  -  -    ";
 | |
|       TString16 datadoc_str = _datadoc.string();
 | |
|       if (datadoc_str.empty())
 | |
|         datadoc_str = "  -  -    "; 
 | |
|       int r = 1;
 | |
|       set_row(r++, ""); 
 | |
|       set_row(r,FR("Operazione n. %-7ld"), _numero);
 | |
|       set_row(r,FR(" del %s"), (const char*)datareg_str);
 | |
|       set_row(r,FR(" doc. n. %-7s"), (const char*)_numdoc);
 | |
|       set_row(r,FR(" del %s"), (const char*)datadoc_str);
 | |
|       if (!_registro.blank())  //e' una fattura
 | |
|       {
 | |
|        set_row(r,FR(" registro IVA %-3s"), (const char*)_registro);
 | |
|        set_row(r,FR(" protocollo n. %-5ld"), _protiva);
 | |
|       } 
 | |
|       set_row(r, FR(" comp. %d"), _anno); 
 | |
| 
 | |
|       // Guy: Aggiunta stampa mese di liquidazione se presente
 | |
|       const int meseliq = cur->curr(LF_MOV).get_int(MOV_MESELIQ);
 | |
|       if (meseliq > 0)
 | |
|         set_row(r, FR(" mese liq. %d"), meseliq);
 | |
|      
 | |
|       stampa_errori_mov(r);  
 | |
|                           
 | |
|       _ho_stampato = TRUE;                    
 | |
|       return TRUE;
 | |
|     }
 | |
|     return FALSE;
 | |
|   }   
 | |
|   else if (file == LF_RMOV)
 | |
|   {
 | |
|     _gruppo = cur->curr(LF_RMOV).get_int(RMV_GRUPPO);
 | |
|     _conto  = cur->curr(LF_RMOV).get_int(RMV_CONTO);
 | |
|     _sottoconto = cur->curr(LF_RMOV).get_long(RMV_SOTTOCONTO); 
 | |
|     _gruppoc = cur->curr(LF_RMOV).get_int(RMV_GRUPPOC);
 | |
|     _contoc  = cur->curr(LF_RMOV).get_int(RMV_CONTOC);
 | |
|     _sottocontoc = cur->curr(LF_RMOV).get_long(RMV_SOTTOCONTOC);     
 | |
|     _importo = cur->curr(LF_RMOV).get_real(RMV_IMPORTO);
 | |
|     _sezione = cur->curr(LF_RMOV).get(RMV_SEZIONE)[0];
 | |
|     TString80 descr = cur->curr(LF_RMOV).get(RMV_DESCR);
 | |
|     int numrig = cur->curr(LF_RMOV).get_int(RMV_NUMRIG); 
 | |
|     
 | |
|     _tipo_conto = "";
 | |
|     
 | |
|     if (_gruppo != 0 && _conto != 0 && _sottoconto != 0l)
 | |
|       _esiste_conto = DescrConto(_gruppo,_conto,_sottoconto);
 | |
|     else
 | |
|     {
 | |
|      _esiste_conto = FALSE;
 | |
|      _descr_conto = "";
 | |
|     } 
 | |
| 
 | |
|     int r = 1;          
 | |
|     set_row(r, "P%d", numrig);
 | |
|     set_row(r, "@5g%3s %-.20s @30g%-.24s @56g%03d %03d %06ld @71g%-.28s", (const char*) _causale, 
 | |
|            (const char*) _descr_causale, (const char*) descr, _gruppo, _conto, _sottoconto, 
 | |
|            (const char*) _descr_conto);
 | |
|     if (_sezione == 'D')
 | |
|       set_row(r, "@99g%r", &_importo);
 | |
|     else if (_sezione == 'A')
 | |
|            set_row(r, "@116g%r", &_importo);
 | |
|          else set_row(r, "@107g%r", &_importo);
 | |
| 
 | |
|     stampa_errori_rmov(r);
 | |
|   }
 | |
|   else if (file == LF_RMOVIVA)
 | |
|   {
 | |
|     const TRectype& rmoviva = cur->curr(LF_RMOVIVA);
 | |
|     real impo = rmoviva.get_real(RMI_IMPONIBILE);
 | |
|     real impos = rmoviva.get_real(RMI_IMPOSTA);
 | |
|     int numrig = rmoviva.get_int(RMI_NUMRIG); 
 | |
|     _tipocr = rmoviva.get_int(RMI_TIPOCR);
 | |
|     real percind;
 | |
|     _tipod  = get_tipodet_from_rmi(rmoviva, current_cursor()->file(LF_MOV).curr(), percind);
 | |
|     _codiva = rmoviva.get(RMI_CODIVA);  
 | |
|     //_n_rec  = cur->curr(LF_RMOVIVA).get_int(RMI_ANNOES); 
 | |
|     _gruppocr = rmoviva.get_int(RMI_GRUPPO); 
 | |
|     _contocr  = rmoviva.get_int(RMI_CONTO);
 | |
|     _sottocontocr = rmoviva.get_long(RMI_SOTTOCONTO);
 | |
|     
 | |
|     TString80 codiva_des(get_codiva_des(_codiva));
 | |
|     
 | |
|     //_tot_doc += impo + impos;
 | |
|     
 | |
|     _impo = impo;
 | |
|     _impos = impos; 
 | |
|     if (!_tipodoc.blank())
 | |
|     {   
 | |
|       TTable tabtpd("%TPD");
 | |
|       tabtpd.put("CODTAB", _tipodoc);
 | |
|       if (tabtpd.read() == NOERR) 
 | |
|       {
 | |
|         bool cor = tabtpd.get_bool("B0");
 | |
|         if (cor)
 | |
|         {
 | |
|           _impo  = impo + impos;
 | |
|           _impos = ZERO;
 | |
|         }
 | |
|       }
 | |
|     }  
 | |
| 
 | |
|     int r = 1;
 | |
|     // Cambia segno se si tratta di note di credito o storni
 | |
|     if (_tipodoc == "NC" || _tipodoc == "ST")
 | |
|     {
 | |
|       _impo_print = _impo * (-1);
 | |
|       _impos_print = _impos * (-1);
 | |
|     }
 | |
|     else 
 | |
|     {
 | |
|       _impo_print = _impo;
 | |
|       _impos_print = _impos;
 | |
|     }
 | |
|      
 | |
|     set_row(r, "I%d", numrig);
 | |
|     set_row(r, FR("@5gImponibile@16g%r"),&_impo_print);
 | |
|     set_row(r, FR("@32gImposta@40g%r"), &_impos_print);      
 | |
|     set_row(r, FR("@56gCodice@63g%4s"), (const char*) _codiva);
 | |
|     set_row(r, "@68g%s", (const char*) codiva_des);
 | |
|              
 | |
|     if (_tipod != 0)
 | |
|       set_row(r," %d", _tipod);
 | |
|               
 | |
|     stampa_errori_riva(r);        
 | |
|   }          
 | |
|   if (file == LF_PARTITE)
 | |
|   {  
 | |
|     _err.reset();                             
 | |
|     _tipomov    = cur->curr(LF_PARTITE).get_int (PART_TIPOMOV);
 | |
|     _tipocf     = cur->curr(LF_PARTITE).get_char(PART_TIPOCF);
 | |
|     _gruppo     = cur->curr(LF_PARTITE).get_int (PART_GRUPPO);
 | |
|     _conto      = cur->curr(LF_PARTITE).get_int (PART_CONTO);
 | |
|     _codcf      = cur->curr(LF_PARTITE).get_long(PART_SOTTOCONTO);  
 | |
|     _anno       = cur->curr(LF_PARTITE).get_int (PART_ANNO);
 | |
|     _numpart    = cur->curr(LF_PARTITE).get     (PART_NUMPART);  
 | |
|     _nriga      = cur->curr(LF_PARTITE).get_int (PART_NRIGA);
 | |
|     _numreg     = cur->curr(LF_PARTITE).get_long(PART_NREG);
 | |
|     _numrig     = cur->curr(LF_PARTITE).get_int (PART_NUMRIG);
 | |
|     _datareg    = cur->curr(LF_PARTITE).get_date(PART_DATAREG);
 | |
|     _datadoc    = cur->curr(LF_PARTITE).get_date(PART_DATADOC);
 | |
|     _numdoc     = cur->curr(LF_PARTITE).get     (PART_NUMDOC);
 | |
|     _reg        = cur->curr(LF_PARTITE).get     (PART_REG);
 | |
|     _protiva    = cur->curr(LF_PARTITE).get_long(PART_PROTIVA);                                    
 | |
|     _causale    = cur->curr(LF_PARTITE).get     (PART_CODCAUS);
 | |
|     _tipopag    = cur->curr(LF_PARTITE).get_int (PART_TIPOPAG);  
 | |
|     _datapag    = cur->curr(LF_PARTITE).get_date(PART_DATAPAG);
 | |
|     _codval     = cur->curr(LF_PARTITE).get     (PART_CODVAL);                                                               
 | |
|     _cambio     = cur->curr(LF_PARTITE).get_real(PART_CAMBIO);    
 | |
|     _datacam    = cur->curr(LF_PARTITE).get     (PART_DATACAM);
 | |
|     _sez        = cur->curr(LF_PARTITE).get_char(PART_SEZ);
 | |
|     _gruppocl   = cur->curr(LF_PARTITE).get_int (PART_GRUPPOCL);
 | |
|     _contocl    = cur->curr(LF_PARTITE).get_int (PART_CONTOCL);                              
 | |
|     
 | |
|     aggiorna_partite();
 | |
|                                    
 | |
|     bool verpagsca = controlla_pagsca();
 | |
|     bool verscad   = controlla_scadenze();
 | |
|     bool controlla = controlla_partite(); //se TRUE => ci sono errori nella testata
 | |
|     bool verifica  = (verpagsca || verscad);
 | |
| 
 | |
|     if ( (_controllo == 1 && controlla) || _controllo == 2 || (_controllo == 1 && verifica) ) 
 | |
|     {
 | |
|       TString16 datareg_str = _datareg.string();
 | |
|       // "Fai vedere lo stesso ..-..-.... anche se non c'e' la data..."    
 | |
|       if (datareg_str.empty())
 | |
|         datareg_str = "  -  -    ";
 | |
|       TString16 datadoc_str = _datadoc.string();
 | |
|       if (datadoc_str.empty())
 | |
|         datadoc_str = "  -  -    "; 
 | |
|       TString16 datapag_str = _datapag.string();
 | |
|       if (datapag_str.empty())
 | |
|         datapag_str = "  -  -    "; 
 | |
|       TString16 datacam_str = _datacam.string();
 | |
|       if (datacam_str.empty())
 | |
|         datacam_str = "  -  -    "; 
 | |
|       
 | |
|       TString ccf;
 | |
|       if (_tipocf == 'C')
 | |
|         ccf = TR("Cliente:  ");
 | |
|       else
 | |
|         if (_tipocf == 'F')
 | |
|           ccf = TR("Fornitore:");
 | |
|         else
 | |
|           ccf = TR("Conto:    ");
 | |
|       
 | |
|       // I riga di testata      
 | |
|       int r = 1;
 | |
|       set_row(r++, "");
 | |
|       if (_tipocf != _tipocf_p || _gruppo != _gruppo_p || _conto != _conto_p || _codcf != _codcf_p)
 | |
|       {  
 | |
|         set_row(r++, "");         
 | |
|         set_row(r,"@b%s", (const char*) ccf);  
 | |
|         if (_gruppo != 0)
 | |
|           set_row(r,"@b%3d", _gruppo);
 | |
|         if (_conto != 0)
 | |
|           set_row(r,"@b%3d", _conto);
 | |
|         set_row(r,"@b%6ld", _codcf);
 | |
|         set_row(r++," @b%-50s", (const char*) _descr_anag);
 | |
|       }
 | |
|       // II riga di testata (L'intestazione viene stampata solo a rottura di partita)
 | |
|       if (_tipocf != _tipocf_p || _gruppo != _gruppo_p || _conto != _conto_p || 
 | |
|           _codcf != _codcf_p || _numpart != _numpart_prec || _anno != _anno_prec)
 | |
|         set_row(r,FR("@0g@rRif. partita"));
 | |
| 
 | |
|       set_row(r,FR("@14gN.riga@22gN.operaz./riga  Data oper.  Data doc.   N.doc.   Reg  Prot.  Causale"));
 | |
|       set_row(r++,FR("@142gTipo/Data pag.  Cod.val          Cambio  Data cambio Sez"));
 | |
| 
 | |
|       if (_tipocf != _tipocf_p || _gruppo != _gruppo_p || _conto != _conto_p || 
 | |
|           _codcf != _codcf_p || _numpart != _numpart_prec || _anno != _anno_prec)
 | |
|       {  
 | |
|         set_row(r,"%4d", _anno);
 | |
|         set_row(r,"@4g/%-7s", (const char*) _numpart);
 | |
|       }  
 | |
|       set_row(r,"@15g%4d", _nriga);   
 | |
|       if (_numreg != 0)
 | |
|         set_row(r,"@23g%7ld", _numreg);
 | |
|       else
 | |
|         set_row(r,"@23g-");
 | |
|       if (_numrig != 0)
 | |
|         set_row(r,"@32g%4d", _numrig);
 | |
|       else
 | |
|         set_row(r,"@32g-");
 | |
|       set_row(r,"@38g%10s", (const char*) datareg_str);
 | |
|       set_row(r,"@50g%10s", (const char*) datadoc_str);
 | |
|       set_row(r,"@62g%-7s", (const char*) _numdoc);
 | |
|       if (_tipomov == 1 || _tipomov == 2)
 | |
|       {
 | |
|         set_row(r,"@71g%-3s", (const char*) _reg);
 | |
|         if (_protiva != 0)
 | |
|           set_row(r,"@76g%05ld", _protiva);
 | |
|       }  
 | |
|       set_row(r,"@83g%-3s", (const char*) _causale);
 | |
|       set_row(r,"@88g%-50s", (const char*) _descr_causale);
 | |
|       if (_tipopag != 0)
 | |
|         set_row(r,"@144g%d", _tipopag);
 | |
|       set_row(r,"@147g%10s", (const char*) datapag_str);   
 | |
|       set_row(r,"@160g%-3s", (const char*) _codval);  
 | |
|       if (_cambio != ZERO)
 | |
|         set_row(r,"@166g%15s",(const char*) _cambio.string("#.###.###,@@@@@"));
 | |
|       set_row(r,"@183g%10s", (const char*) datacam_str);
 | |
|       set_row(r,"@196g%c", _sez);
 | |
|       
 | |
|       _tipocf_p = _tipocf;
 | |
|       _gruppo_p = _gruppo;
 | |
|       _conto_p  = _conto;
 | |
|       _codcf_p  = _codcf;
 | |
|       
 | |
|       stampa_errori_partite(r);  
 | |
|       
 | |
|       _prima_rata_pag = TRUE; 
 | |
|       _numpart_prec   = _numpart; 
 | |
|       _anno_prec      = _anno;
 | |
|       
 | |
|       _ho_stampato = TRUE;
 | |
|       return TRUE;
 | |
|     }
 | |
|     return FALSE;
 | |
|   }
 | |
|   if (file == LF_SCADENZE)
 | |
|   {                           
 | |
|     int r = 1; 
 | |
|     stampa_errori_scadenze(r);  
 | |
|   }  
 | |
|   if (file == LF_PAGSCA)
 | |
|   {                           
 | |
|     int r = 1; 
 | |
|     stampa_errori_pagsca(r);  
 | |
|   }
 | |
|   
 | |
|   return TRUE;
 | |
| }
 | |
| 
 | |
| print_action TRic_ListaMov::postprocess_page(int file,int count)
 | |
| {
 | |
|   if (count) return NEXT_PAGE;  
 | |
|   
 | |
|   if (file == LF_MOV)
 | |
|   {       
 | |
|     reset_print();
 | |
|     _err.reset();
 | |
|     int n = 1;     
 | |
|     
 | |
|     const TCurrency sbil(real(_tot_dare - _tot_avere));
 | |
|     if (!sbil.is_zero())
 | |
|     {
 | |
|        _errore_grave = TRUE;
 | |
|        set_row(n++, FR("@8g*** Il movimento risulta sbilanciato. Totali rilevati:@99g%r@116g%r"),
 | |
|                &_tot_dare, &_tot_avere);
 | |
|        return REPEAT_PAGE;           
 | |
|     }   
 | |
|   }
 | |
|   if (file == LF_PARTITE)
 | |
|   {       
 | |
|     reset_print();
 | |
|     _err.reset();
 | |
|   }
 | |
|   return NEXT_PAGE;
 | |
| }       
 | |
| 
 | |
| print_action TRic_ListaMov::postprocess_print(int file, int counter)
 | |
| {                  
 | |
|   if (file == LF_MOV || file == LF_PARTITE) 
 | |
|     if (_ho_stampato)
 | |
|       printer().formfeed();
 | |
|     
 | |
|   return NEXT_PAGE;
 | |
| }
 | |
| 
 | |
| void TRic_ListaMov::postclose_print()
 | |
| { 
 | |
|   bool esegui;  // La variabile esegui mi permette di visualizzare il messaggio se non c'e il
 | |
|                 // saldaconto, oppure se c'e' il saldaconto ma e' gia' stato eseguito il controllo
 | |
|                 // su quest'ultimo
 | |
|   if ( (_is_salda && _seconda_volta) || !_is_salda)
 | |
|     esegui = TRUE;
 | |
|   else
 | |
|     esegui = FALSE; 
 | |
|   
 | |
|   if (_is_salda)     
 | |
|     if (_seconda_volta)
 | |
|       _seconda_volta = FALSE;
 | |
|     else
 | |
|       _seconda_volta = TRUE;
 | |
|     
 | |
|   _errore_grave_totale = _errore_grave || _errore_grave_SC;
 | |
|   
 | |
|   if (esegui)
 | |
|   {  
 | |
|     if (_errore_grave_totale)
 | |
|     {  
 | |
|        if (_ric_auto == 'A')
 | |
|        { 
 | |
|          _risposta = TRUE;
 | |
|          _continua = yesno_box(TR("Rilevati ERRORI GRAVI durante il controllo movimenti: \n Controllare gli errori sulla lista dei movimenti stampata per eseguire le correzioni. \n Continuare ugualmente?"));
 | |
|          TTransfer_file& tr = trasfer();
 | |
|          if (!_continua)
 | |
|            _record.overwrite(" ",240);  //_record e' letto nella read_control_rec()
 | |
|          else 
 | |
|          {
 | |
|            TConfig conf (CONFIG_DITTA);
 | |
|            conf.set("FlStTra", "M"); 
 | |
|            _record.overwrite("Z",240);  
 | |
|          }
 | |
|          const int size = 1024;
 | |
|          tr.write_control_rec(_record, size); 
 | |
|          tr.read_control_rec();
 | |
|        }
 | |
|        else 
 | |
|        {
 | |
|          message_box(TR("Rilevati errori gravi durante il controllo movimenti:\n trasferimento interrotto"));
 | |
|          TTransfer_file& tr = trasfer();
 | |
|          _record.overwrite(" ",240);  //_record e' letto nella read_control_rec()
 | |
|          const int size = 1024;
 | |
|          tr.write_control_rec(_record, size); 
 | |
|          tr.read_control_rec();
 | |
|          chiudi_file_SC();
 | |
|        }
 | |
|     }                        
 | |
|     else 
 | |
|     { 
 | |
|       if (_ric_auto == 'A')                  
 | |
|         _risposta = TRUE;
 | |
|       else
 | |
|         message_box(TR("CONTROLLO MOVIMENTI terminato: \n proseguire con RICEZIONE movimenti"));
 | |
|       TConfig conf (CONFIG_DITTA);
 | |
|       conf.set("FlStTra", "M"); 
 | |
|    
 | |
|       TTransfer_file& tr = trasfer();
 | |
|       _record.overwrite("Z",240);  //_record e' letto nella read_control_rec()
 | |
|       const int size = 1024;
 | |
|       tr.write_control_rec(_record, size);    
 | |
|       tr.read_control_rec();
 | |
|       chiudi_file_SC();
 | |
|     }
 | |
|   }  // if (esegui)
 | |
| }
 | |
| 
 | |
| char TRic_ListaMov::sezione_ritsoc(const TRectype& part) const 
 | |
| {
 | |
|   TString16 key; key << part.get(PART_CODCAUS) << "|14";  // Riga ritenute sociali
 | |
|   const char sezrs = cache().get(LF_RCAUSALI, key, RCA_SEZIONE)[0];
 | |
|   return sezrs > ' ' ? (sezrs == 'D' ? 'A' : 'D') : part.get_char(PART_SEZ);
 | |
| }
 | |
| 
 | |
| real TRic_ListaMov::segno_ritsoc(const TRectype& part) const
 | |
| {
 | |
|   return part.get_char(PART_SEZ) == sezione_ritsoc(part) ? UNO : -UNO;
 | |
| }
 | |
| 
 | |
| void TRic_ListaMov::esamina_partite()
 | |
| {   
 | |
|   bool prima_volta = TRUE;
 | |
|   int  numrigp = -1;
 | |
|   TRecnotype recp = _tpart->recno();
 | |
|   TIsamtempfile& part = *_tpart;
 | |
|   
 | |
|   part.setkey(2);
 | |
|   part.zero();
 | |
|   part.put(PART_NREG, _numero);
 | |
|   const TRectype partita (part.curr());
 | |
|   
 | |
|   for (part.read(_isgteq); !part.eof(); part.next())
 | |
|   {
 | |
|     if (part.curr() != partita) break;
 | |
|     
 | |
|     int tipomov = part.get_int(PART_TIPOMOV);
 | |
|     int numrig  = part.get_int(PART_NUMRIG);
 | |
|     
 | |
| //    if (numrig != numrigp)
 | |
| //    {
 | |
|       real doc = ZERO;
 | |
|       real val = ZERO;
 | |
| 
 | |
|       if (tipomov != 1 && tipomov != 2)
 | |
|       {  
 | |
|         TIsamtempfile& pagsca = *_tpagsca;
 | |
|         
 | |
|         pagsca.zero();
 | |
|         pagsca.put(PAGSCA_TIPOC,      part.get_char(PART_TIPOCF));
 | |
|         pagsca.put(PAGSCA_GRUPPO,     part.get_int (PART_GRUPPO));
 | |
|         pagsca.put(PAGSCA_CONTO,      part.get_int (PART_CONTO));
 | |
|         pagsca.put(PAGSCA_SOTTOCONTO, part.get_long(PART_SOTTOCONTO));
 | |
|         pagsca.put(PAGSCA_ANNO,       part.get_int (PART_ANNO));
 | |
|         pagsca.put(PAGSCA_NUMPART,    part.get     (PART_NUMPART));
 | |
|         int nriga = part.get_int(PART_NRIGA);
 | |
|         TRectype pagamenti (pagsca.curr());
 | |
|   
 | |
|         for (pagsca.read(_isgteq); !pagsca.eof(); pagsca.next())
 | |
|         {                                           
 | |
|           TString rec  = pagamenti.get(PAGSCA_NUMPART);
 | |
|           TString file = pagsca.get(PAGSCA_NUMPART);
 | |
|           
 | |
|           if (pagsca.curr() != pagamenti || file != rec) break;
 | |
|     
 | |
|           int nrigp = pagsca.get_int(PAGSCA_NRIGP);
 | |
|     
 | |
|           if (nrigp != nriga) continue;
 | |
|     
 | |
|           doc += pagsca.get_real(PAGSCA_IMPORTO) + pagsca.get_real(PAGSCA_RITENUTE);
 | |
|           doc += pagsca.get_real(PAGSCA_RITSOC) * segno_ritsoc(part.curr());
 | |
| 
 | |
|           val += pagsca.get_real(PAGSCA_IMPORTOVAL);
 | |
|         }
 | |
|       
 | |
|         if (prima_volta) 
 | |
|           _tot_doc = ZERO;
 | |
|         _tot_doc += doc;  
 | |
|       }
 | |
|       if (tipomov == 1)
 | |
|       {                                   
 | |
|         TRecnotype recs = _tscad->recno();      
 | |
|         TIsamtempfile& scad = *_tscad;
 | |
|         
 | |
|         scad.zero();
 | |
|         scad.put(SCAD_TIPOCF,     part.get_char(PART_TIPOCF));
 | |
|         scad.put(SCAD_GRUPPO,     part.get_int (PART_GRUPPO));
 | |
|         scad.put(SCAD_CONTO,      part.get_int (PART_CONTO));
 | |
|         scad.put(SCAD_SOTTOCONTO, part.get_long(PART_SOTTOCONTO));
 | |
|         scad.put(SCAD_ANNO,       part.get_int (PART_ANNO));
 | |
|         scad.put(SCAD_NUMPART,    part.get     (PART_NUMPART));
 | |
|         scad.put(SCAD_NRIGA,      part.get_int (PART_NRIGA));
 | |
|         TRectype scadenze (scad.curr());
 | |
|   
 | |
|         for (scad.read(_isgteq); !scad.eof(); scad.next())
 | |
|         {  
 | |
|           TString rec  = scadenze.get(SCAD_NUMPART);
 | |
|           TString file = scad.get(SCAD_NUMPART);
 | |
|           
 | |
|           if (scad.curr() != scadenze || file != rec) break;
 | |
|     
 | |
|           val += scad.get_real(SCAD_IMPORTOVAL);
 | |
|         }
 | |
|         _tscad->readat(recs);
 | |
|       }                                           
 | |
|       if (prima_volta)
 | |
|         _tot_val = ZERO;
 | |
|       _tot_val += val;  
 | |
| //    }
 | |
| //    numrigp = numrig;
 | |
|     
 | |
|     if (prima_volta)
 | |
|     {
 | |
|       _codval_part  = part.get     (PART_CODVAL);
 | |
|       _datacam_part = part.get_date(PART_DATACAM);
 | |
|       _cambio_part  = part.get_real(PART_CAMBIO);   
 | |
|       if (tipomov == 1)
 | |
|       { 
 | |
|         TRecnotype recs = _tscad->recno();
 | |
|         TIsamtempfile& scad = *_tscad;
 | |
|       
 | |
|         char    tipo    = part.get_char(PART_TIPOCF);
 | |
|         int     gruppo  = part.get_int (PART_GRUPPO);
 | |
|         int     conto   = part.get_int (PART_CONTO);
 | |
|         long    sottoc  = part.get_long(PART_SOTTOCONTO);
 | |
|         int     anno    = part.get_int (PART_ANNO);
 | |
|         TString numpart = part.get     (PART_NUMPART);
 | |
|         int     nriga   = part.get_int (PART_NRIGA);
 | |
|         
 | |
|         scad.setkey(1);
 | |
|         scad.zero();
 | |
|         scad.put(SCAD_TIPOCF,     tipo);
 | |
|         scad.put(SCAD_GRUPPO,     gruppo);
 | |
|         scad.put(SCAD_CONTO,      conto);
 | |
|         scad.put(SCAD_SOTTOCONTO, sottoc);
 | |
|         scad.put(SCAD_ANNO,       anno);
 | |
|         scad.put(SCAD_NUMPART,    numpart);
 | |
|         scad.put(SCAD_NRIGA,      nriga);
 | |
|         TRectype scadenza (scad.curr());
 | |
|         
 | |
|         _codpag_scad = "";
 | |
|         
 | |
|         for (scad.read(_isgteq); !scad.eof(); scad.next())
 | |
|         {       
 | |
|           TString rec  = scadenza.get(SCAD_NUMPART);
 | |
|           TString file = scad.get(SCAD_NUMPART);
 | |
|           
 | |
|           if (scad.curr() != scadenza || file != rec) break;
 | |
|           
 | |
|           _codpag_scad = scad.get(SCAD_CODPAG);
 | |
|           break;
 | |
|         }  
 | |
|         _tscad->readat(recs);
 | |
|       }
 | |
|       prima_volta = FALSE;
 | |
|     }                                            
 | |
|   }
 | |
|   _tpart->readat(recp);
 | |
| }
 | |
| 
 | |
| void TRic_ListaMov::aggiorna_mov()
 | |
| {
 | |
|   TLocalisamfile& mov = current_cursor()->file(LF_MOV);
 | |
| 
 | |
|   if (_is_salda)
 | |
|     esamina_partite();
 | |
| 
 | |
|   if (_anno == 0)
 | |
|     mov.put(MOV_ANNOES, _annoese);
 | |
|   mov.put(MOV_DATACOMP, _datacomp);
 | |
|   mov.put(MOV_ANNOIVA,  _annoiva);
 | |
|   mov.put(MOV_REG,      _registro);
 | |
|   mov.put(MOV_TIPODOC,  _tipodoc); 
 | |
|   mov.put(MOV_TIPO,     _tipocf);  
 | |
|   if (mov.get(MOV_TIPOMOV).empty())
 | |
|     mov.put(MOV_TIPOMOV,  _tipom_cau); 
 | |
|   mov.put(MOV_CODPAG,   _codpag_scad);
 | |
|   const bool first_time = mov.get("TOCFP")!="X";
 | |
|   if ((_tipodoc == "NC" || _tipodoc == "ST") && first_time)  // swap sign only if it's first time
 | |
|   {
 | |
|     _tot_doc = -_tot_doc;
 | |
|     mov.put("TOCFP","X");
 | |
|   }
 | |
|   
 | |
|   // NB In caso di ricezione da sistema ritsoc e ritfis valgono sempre 0  
 | |
|   // quindi in caso di ricezione da PC ripristina il totale documento corretto.
 | |
|   real ritsoc = mov.get(MOV_RITSOC);
 | |
|   real ritfis = mov.get(MOV_RITFIS);
 | |
|   _tot_doc = _tot_doc - ritsoc - ritfis;
 | |
|   
 | |
|   mov.put(MOV_TOTDOC,   _tot_doc);    
 | |
|   if (_is_salda)
 | |
|   { 
 | |
|     if (mov.get_real(MOV_TOTDOCVAL) == ZERO)
 | |
|       mov.put(MOV_TOTDOCVAL, _tot_val);
 | |
|     if (mov.get(MOV_CODVAL).empty())  
 | |
|       mov.put(MOV_CODVAL,    _codval_part);
 | |
|     if (mov.get(MOV_DATACAM).empty())  
 | |
|       mov.put(MOV_DATACAM,   _datacam_part);
 | |
|     if (mov.get_real(MOV_CAMBIO) == ZERO)  
 | |
|       mov.put(MOV_CAMBIO,    _cambio_part);
 | |
|   }
 | |
|   mov.rewrite();
 | |
| }
 | |
| 
 | |
| void TRic_ListaMov::aggiorna_rmov(char tipoc, char tipocc)
 | |
| {
 | |
|   TLocalisamfile& rmov = current_cursor()->file(LF_RMOV); 
 | |
| 
 | |
|   if (_anno == 0)
 | |
|     rmov.put(RMV_ANNOES, _annoese);
 | |
| 
 | |
|   rmov.put(RMV_TIPOC,  tipoc);
 | |
|   rmov.put(RMV_TIPOCC, tipocc);
 | |
|   
 | |
|   rmov.rewrite();
 | |
| }
 | |
| 
 | |
| void TRic_ListaMov::aggiorna_iva(char tipo)
 | |
| {                                                       
 | |
|   TLocalisamfile& riva = current_cursor()->file(LF_RMOVIVA); 
 | |
|   
 | |
|   if (_anno == 0)
 | |
|     riva.put(RMI_ANNOES, _annoese);
 | |
| 
 | |
|   const TRectype& mov = current_cursor()->curr(LF_MOV);   
 | |
|   const bool first_time = mov.get("TOCFP") != "X";
 | |
|   if ((_tipodoc == "NC" || _tipodoc == "ST") && first_time) // swap sign only if it is the first time
 | |
|   {
 | |
|     _impo  = _impo * -1;
 | |
|     _impos = _impos * -1;
 | |
|   }  
 | |
|   riva.put(RMI_IMPONIBILE, _impo);
 | |
|   riva.put(RMI_IMPOSTA,    _impos);  
 | |
|   riva.put(RMI_TIPOC,      tipo);
 | |
|   
 | |
|   riva.rewrite();
 | |
| }
 | |
| 
 | |
| bool TRic_ListaMov::solo_SC(long numreg)
 | |
| {               
 | |
|   TIsamtempfile& tmov = *_tmov;
 | |
|   
 | |
|   tmov.setkey(1);              
 | |
|   tmov.zero();   
 | |
|   tmov.put(MOV_NUMREG, numreg);
 | |
|   if (tmov.read() == NOERR)
 | |
|     return FALSE;      
 | |
|   
 | |
|   return TRUE;  
 | |
| }
 | |
| 
 | |
| void TRic_ListaMov::calcola_imposta(long nreg, real& imposta)
 | |
| {                             
 | |
|   TRecnotype recn = _tiva->recno();
 | |
|   TIsamtempfile& riva = *_tiva; 
 | |
|     
 | |
|   riva.zero();
 | |
|   riva.put(RMI_NUMREG, nreg);
 | |
| 
 | |
|   TRectype recriva (riva.curr());
 | |
|     
 | |
|   for (riva.read(_isgteq); !riva.eof(); riva.next())
 | |
|   {
 | |
|     if (riva.curr() > recriva) break;
 | |
|     
 | |
|     real imp (riva.get_real(RMI_IMPOSTA));
 | |
|     imposta += imp;                              
 | |
|   }                                
 | |
|   _tiva->readat(recn);
 | |
| }
 | |
| 
 | |
| bool TRic_ListaMov::calcola_impdocval(long nreg,int nrig,char tipoc,int gruppo,int conto,long sottoc,
 | |
|                                       int anno,TString& numpart,int nriga,real& doc,real& val)
 | |
| { 
 | |
|   TRecnotype recn = _tpagsca->recno();
 | |
|   TIsamtempfile& pagsca = *_tpagsca;
 | |
|   bool prima_volta = TRUE;
 | |
|   
 | |
|   doc = ZERO;
 | |
|   val = ZERO;
 | |
| 
 | |
|   pagsca.zero();
 | |
|   pagsca.put(PAGSCA_TIPOC,      tipoc);
 | |
|   pagsca.put(PAGSCA_GRUPPO,     gruppo);
 | |
|   pagsca.put(PAGSCA_CONTO,      conto);
 | |
|   pagsca.put(PAGSCA_SOTTOCONTO, sottoc);
 | |
|   pagsca.put(PAGSCA_ANNO,       anno);
 | |
|   pagsca.put(PAGSCA_NUMPART,    numpart);
 | |
| //  pagsca.put(PAGSCA_NRIGA,      nriga);
 | |
|   
 | |
|   const TRectype pagamenti (pagsca.curr());
 | |
|   
 | |
|   for (pagsca.read(_isgteq); !pagsca.eof(); pagsca.next())
 | |
|   {                                           
 | |
|     TString rec  = pagamenti.get(PAGSCA_NUMPART);
 | |
|     TString file = pagsca.get(PAGSCA_NUMPART);
 | |
|     
 | |
|     if (pagsca.curr() != pagamenti || file != rec) break;
 | |
|     
 | |
|     int nrigp = pagsca.get_int(PAGSCA_NRIGP);
 | |
|     
 | |
|     if (nrigp != nriga) continue;
 | |
|     
 | |
|     doc += pagsca.get_real(PAGSCA_IMPORTO) + pagsca.get_real(PAGSCA_RITENUTE);
 | |
|     const real ritsoc = pagsca.get(PAGSCA_RITSOC);
 | |
|     if (!ritsoc.is_zero())
 | |
|     {
 | |
|       TToken_string key;
 | |
|       key.add(tipoc); key.add(gruppo); key.add(conto); key.add(sottoc);
 | |
|       key.add(anno); key.add(numpart);
 | |
|       const TRectype& part = cache().get(LF_PARTITE, key);
 | |
|       doc += ritsoc * segno_ritsoc(part);
 | |
|     }
 | |
| 
 | |
|     val += pagsca.get_real(PAGSCA_IMPORTOVAL);
 | |
|   }
 | |
|   _tpagsca->readat(recn);
 | |
|   
 | |
|   if (nreg != 0 && nrig != 0)
 | |
|   {
 | |
|     int key = _tpart->getkey();      
 | |
|     TRecnotype rec = _tpart->recno();
 | |
|     TIsamtempfile& part = *_tpart;
 | |
| 
 | |
|     part.setkey(2);
 | |
|     part.zero();
 | |
|     part.put(PART_NREG,   nreg);
 | |
|     part.put(PART_NUMRIG, nrig);
 | |
|       
 | |
|     TRectype partita (part.curr());
 | |
|       
 | |
|     for (part.read(); !part.eof(); part.next())
 | |
|     {
 | |
|       if (part.curr() > partita) break;
 | |
|       
 | |
|       real imp    = part.get_real(PART_IMPTOTDOC) + doc;
 | |
|       real impval = part.get_real(PART_IMPTOTVAL) + val;
 | |
|       part.put(PART_IMPTOTDOC, imp);
 | |
|       part.put(PART_IMPTOTVAL, impval);  
 | |
|       part.setkey(1);
 | |
|       part.rewrite();
 | |
|       part.setkey(2);
 | |
|     }                
 | |
|     _tpart->readat(rec);
 | |
|     _tpart->setkey(key);  
 | |
|   }           
 | |
|   else
 | |
|     return TRUE;
 | |
|   
 | |
|   return FALSE;
 | |
| }
 | |
| 
 | |
| void TRic_ListaMov::calcola_importo(char tipoc,int gruppo,int conto,long sottoc,
 | |
|                                      int anno,TString& numpart,int nriga)
 | |
| { 
 | |
|   TRecnotype recn = _tscad->recno();                            
 | |
|   TIsamtempfile& scad = *_tscad;
 | |
|   
 | |
|   scad.setkey(1);
 | |
|   scad.zero();
 | |
|   scad.put(SCAD_TIPOCF,     tipoc);
 | |
|   scad.put(SCAD_GRUPPO,     gruppo);
 | |
|   scad.put(SCAD_CONTO,      conto);
 | |
|   scad.put(SCAD_SOTTOCONTO, sottoc); 
 | |
|   scad.put(SCAD_ANNO,       anno);
 | |
|   scad.put(SCAD_NUMPART,    numpart);
 | |
|   scad.put(SCAD_NRIGA,      nriga);
 | |
|   
 | |
|   TRectype scadenza (scad.curr());
 | |
|   
 | |
|   for (scad.read(_isgteq); !scad.eof(); scad.next())
 | |
|   {       
 | |
|     TString rec  = scadenza.get(SCAD_NUMPART);
 | |
|     TString file = scad.get(SCAD_NUMPART);
 | |
|                                            
 | |
|     if (scad.curr() != scadenza || file != rec) break;
 | |
|     
 | |
|     _imp    += scad.get_real(SCAD_IMPORTO);
 | |
|     _impval += scad.get_real(SCAD_IMPORTOVAL);
 | |
|   }
 | |
|   _tscad->readat(recn);    
 | |
| }
 | |
| 
 | |
| void TRic_ListaMov::aggiorna_partita(real& importo,real& importoval,real& abbuoni,real& diffcam,
 | |
|                                      real& ritfis,real& ritsoc, TString& sez,TString& sezabb,TString& sezdc)
 | |
| {                  
 | |
|   TRecnotype recn = _tpagsca->recno();
 | |
|   TIsamtempfile& pagsca = *_tpagsca;
 | |
|   real    abb,diff;
 | |
| 
 | |
|   abb  = ZERO;
 | |
|   diff = ZERO;
 | |
|   
 | |
|   pagsca.setkey(1);
 | |
|   pagsca.zero();
 | |
|   pagsca.put(PAGSCA_TIPOC,      _tipocf);
 | |
|   pagsca.put(PAGSCA_GRUPPO,     _gruppo);
 | |
|   pagsca.put(PAGSCA_CONTO,      _conto);
 | |
|   pagsca.put(PAGSCA_SOTTOCONTO, _codcf); 
 | |
|   pagsca.put(PAGSCA_ANNO,       _anno);
 | |
|   pagsca.put(PAGSCA_NUMPART,    _numpart);
 | |
|   
 | |
|   TRectype pagamento (pagsca.curr());
 | |
|   
 | |
|   for (pagsca.read(_isgteq); !pagsca.eof(); pagsca.next())
 | |
|   {            
 | |
|     TString rec  = pagamento.get(PAGSCA_NUMPART);
 | |
|     TString file = pagsca.get(PAGSCA_NUMPART);
 | |
|                   
 | |
|     if (pagsca.curr() != pagamento || file != rec) break;
 | |
|     
 | |
|     int nrigp = pagsca.get_int(PAGSCA_NRIGP);
 | |
|     
 | |
|     if (_nriga != nrigp) continue;
 | |
|     
 | |
|     importo    += pagsca.get_real(PAGSCA_IMPORTO);
 | |
|     importoval += pagsca.get_real(PAGSCA_IMPORTOVAL);
 | |
|     ritfis     += pagsca.get_real(PAGSCA_RITENUTE);
 | |
|     ritsoc     += pagsca.get_real(PAGSCA_RITSOC);
 | |
|     
 | |
|     abb = pagsca.get_real(PAGSCA_ABBUONI);
 | |
|     if (abb != ZERO)
 | |
|     {  
 | |
|       if (sezabb.empty())  
 | |
|       {
 | |
|         abbuoni += abb;
 | |
|         sezabb = sez;
 | |
|       }
 | |
|       else
 | |
|         if (sez == sezabb)
 | |
|           abbuoni += abb;        
 | |
|         else
 | |
|           abbuoni -= abb;                
 | |
|     }
 | |
|     diff = pagsca.get_real(PAGSCA_DIFFCAM);
 | |
|     if (diff != ZERO)
 | |
|     {
 | |
|       if (sezdc.empty())  
 | |
|       {
 | |
|         diffcam += diff;
 | |
|         sezdc = sez;
 | |
|       }
 | |
|       else
 | |
|         if (sez == sezdc)
 | |
|           diffcam += diff;        
 | |
|         else
 | |
|           diffcam -= diff;                
 | |
|     }
 | |
|   }
 | |
|   if (abbuoni < ZERO)
 | |
|   {
 | |
|     abbuoni = abbuoni * -1;
 | |
|     if (sezabb == "D")
 | |
|       sezabb = "A";
 | |
|     else          
 | |
|       if (sezabb == "A")
 | |
|         sezabb = "D";
 | |
|   }            
 | |
|   if (diffcam < ZERO)
 | |
|   {
 | |
|     diffcam = diffcam * -1;
 | |
|     if (sezdc == "D")
 | |
|       sezdc = "A";
 | |
|     else          
 | |
|       if (sezdc == "A")
 | |
|         sezdc = "D";      
 | |
|   } 
 | |
|   _tpagsca->readat(recn);               
 | |
| }
 | |
| 
 | |
| void TRic_ListaMov::aggiorna_partite()
 | |
| {
 | |
|   TLocalisamfile& part = current_cursor()->file(LF_PARTITE); 
 | |
|   
 | |
|   real imposta = ZERO;
 | |
|   
 | |
|   if (!solo_SC(_numreg) && _tipomov == 1) // && (part.get_real(PART_IMPOSTA) == ZERO) )         
 | |
|   { 
 | |
|     if (_is_iva)
 | |
|     {
 | |
|       calcola_imposta(_numreg,imposta);
 | |
|       part.put(PART_IMPOSTA, imposta);
 | |
|     }
 | |
|   }                       
 | |
|   if (_tipomov != 1 && _tipomov != 4)   
 | |
|   {  
 | |
|     real doc;
 | |
|     real val;
 | |
|     if (calcola_impdocval(_numreg,_numrig,_tipocf,_gruppo,_conto,_codcf,_anno,_numpart,_nriga,doc,val))
 | |
|     {
 | |
|       part.put(PART_IMPTOTDOC, doc);
 | |
|       part.put(PART_IMPTOTVAL, val);  
 | |
|     } 
 | |
|   }        
 | |
|   if (_tipomov == 1 ) //&& (part.get_real(PART_IMPORTO) == ZERO) )
 | |
|   {
 | |
|     calcola_importo(_tipocf,_gruppo,_conto,_codcf,_anno,_numpart,_nriga);
 | |
|   
 | |
|     part.put(PART_IMPORTO,    _imp);
 | |
|     part.put(PART_IMPORTOVAL, _impval);
 | |
|     
 | |
|     _imp    = ZERO;
 | |
|     _impval = ZERO;
 | |
|   }
 | |
|   if (_tipomov != 1) // && (part.get_real(PART_IMPORTO) == ZERO) )
 | |
|   {
 | |
|     real    importo    = ZERO;
 | |
|     real    importoval = ZERO;
 | |
|     real    ritfis     = ZERO;
 | |
|     real    ritsoc     = ZERO;
 | |
|     real    abbuoni    = ZERO;
 | |
|     real    diffcam    = ZERO;
 | |
|     TString sez        = part.get(PART_SEZ);
 | |
|     TString sezabb     = part.get(PART_SEZABB);
 | |
|     TString sezdc      = part.get(PART_SEZDIFCAM);
 | |
| 
 | |
|     aggiorna_partita(importo,importoval,abbuoni,diffcam,ritfis,ritsoc,sez,sezabb,sezdc);  
 | |
| 
 | |
|     part.put(PART_IMPORTO,    importo);
 | |
|     part.put(PART_IMPORTOVAL, importoval);
 | |
|     part.put(PART_RITENUTE,   ritfis);
 | |
|     part.put(PART_RITSOC,     ritsoc);
 | |
|     part.put(PART_SEZABB,     sezabb);   
 | |
|     part.put(PART_ABBUONI,    abbuoni);  
 | |
|     part.put(PART_SEZDIFCAM,  sezdc);   
 | |
|     part.put(PART_DIFFCAM,    diffcam);
 | |
|   }
 | |
|   part.rewrite();
 | |
| }
 | |
| 
 | |
| bool TRic_ListaMov::user_destroy()
 | |
| {
 | |
|   delete _giornale;
 | |
|   delete _trasfer;
 | |
|   delete _rel; 
 | |
|   
 | |
|   // Sono gia' distrutti in quanto parte di _rel
 | |
|   // delete _tmov;  
 | |
|   // delete _trmov;
 | |
|   // if (_is_iva) delete _tiva;
 | |
|   
 | |
|   delete _caus;
 | |
|   delete _ditte; 
 | |
|   delete _clifo; 
 | |
|   delete _pcon;    
 | |
|   delete _mov;
 | |
|   delete _rmov;
 | |
|   delete _rmoviva;
 | |
|   delete _part;
 | |
|   delete _scad;
 | |
|   delete _pagsca;
 | |
|   
 | |
|   delete _tab_pag;
 | |
|   delete _tab_tpd;
 | |
|   delete _tab_iva;
 | |
|   delete _tab_ese;      
 | |
|   delete _tab_tra;
 | |
|   
 | |
|   return TRUE;
 | |
| }                                
 | |
| 
 | |
| void TRic_ListaMov::chiudi_file_SC()
 | |
| {
 | |
|   if (_is_salda)
 | |
|   { 
 | |
|     delete _relSC;   _relSC   = NULL;
 | |
|     // Non cancellare: Gia' contenuti in _relSC
 | |
|     // delete _tpart;   _tpart   = NULL;  
 | |
|     // delete _tscad;   _tscad   = NULL;
 | |
|     // delete _tpagsca; _tpagsca = NULL;
 | |
| 
 | |
|     delete _part;    _part = NULL;
 | |
|     delete _scad;    _scad = NULL;
 | |
|     delete _pagsca;  _pagsca = NULL;
 | |
|   }
 | |
| }
 | |
|                                     
 | |
| bool TRic_ListaMov::set_print(int m)
 | |
| { 
 | |
|   if (_ric_auto == 'A')
 | |
|   {   
 | |
|     if (_risposta)    // Metto questa variabile booleana per uscire, altrimenti
 | |
|     {                 // il programma andrebbe in loop andando ancora in stampa
 | |
|       TString appname = "cg6 -0";
 | |
|       TString body    = "";
 | |
|   
 | |
|       if (_continua)
 | |
|         body = "1";
 | |
|       else
 | |
|         body = "0";
 | |
|         
 | |
|       TMessage msg (appname,"",(const char*)body);
 | |
|       TMailbox mb;
 | |
|       mb.send(msg);
 | |
|     
 | |
|       return FALSE;   
 | |
|     }
 | |
| 
 | |
|     if (_seconda_volta && _is_salda)
 | |
|     { 
 | |
|       reset_files();           // Resetta l'albero di stampa precedente relativo ai movimenti contabili e iva
 | |
|       select_cursor(_curSC);   // Seleziona il cursore relativo ai movimenti del saldaconto
 | |
|     
 | |
|       add_file (LF_PARTITE);
 | |
|       add_file (LF_SCADENZE, LF_PARTITE);
 | |
|       add_file (LF_PAGSCA, LF_PARTITE);  
 | |
|       _errore_grave_SC = FALSE;   
 | |
|       _intestaSC       = TRUE;  
 | |
|       _prima_volta     = TRUE;
 | |
|       _ho_stampato     = FALSE;      
 | |
|     }
 | |
|     else
 | |
|     {
 | |
|       TString80 nome;
 | |
|       long ditta_ric = get_firm();
 | |
|   
 | |
|       TTransfer_file& tr = trasfer(); // Nella lista controllo movimenti lanciata da menu il record di  
 | |
|                                       // controllo dell'header viene letto nella funzione check_archivi
 | |
|                                       // Nella ricezione in automatico devo leggerlo in questo punto
 | |
|       _pathfile = tr.path();         
 | |
|   
 | |
|       _pathfile = _pathfile << HEADER;
 | |
|   
 | |
|       if (!tr.open(_pathfile))
 | |
|         return error_box(TR("Al momento non presenti trasferimenti attivi sulla ditta selezionata"));
 | |
| 
 | |
|       if (!tr.read_control_rec())
 | |
|         return error_box(TR("Rilevati errori gravi negli archivi: procedura interrotta"));
 | |
|       else _record = tr.record();     
 | |
|                                     
 | |
|       if (_tipo_lista == 'A')
 | |
|         _controllo = 2;
 | |
|       else
 | |
|         _controllo = 1;
 | |
| 
 | |
|       apri_file_SC(); 
 | |
|       
 | |
|       reset_files();           // Resetta l'albero di stampa precedente relativo ai movimenti del saldaconto
 | |
|       select_cursor(_cur);     // Seleziona il cursore relativo ai movimenti contabili e iva
 | |
|   
 | |
|       add_file (LF_MOV);
 | |
|       add_file (LF_RMOV, LF_MOV);
 | |
|       if (_is_iva)
 | |
|         add_file (LF_RMOVIVA, LF_MOV);
 | |
|            
 | |
|       _errore_grave = FALSE;   
 | |
|       _errore_grave_totale = FALSE;  
 | |
|       _intestaSC           = FALSE;
 | |
|     
 | |
|       _err.reset();  
 | |
|     }
 | |
|     setta_parametri(" ", "C");   
 | |
|   
 | |
|     set_real_picture("###.###.###.###");
 | |
|     set_magic_currency(TRUE);
 | |
| 
 | |
|     printer().footerlen(5);
 | |
|   
 | |
|     setta_intestazione();
 | |
| 
 | |
|     _err.reset();
 | |
|   }
 | |
|   else
 | |
|   { 
 | |
|     if (_seconda_volta && _is_salda)
 | |
|     { 
 | |
|       reset_files();           // Resetta l'albero di stampa precedente relativo ai movimenti contabili e iva
 | |
|       select_cursor(_curSC);   // Seleziona il cursore relativo ai movimenti del saldaconto
 | |
|     
 | |
|       add_file (LF_PARTITE);
 | |
|       add_file (LF_SCADENZE, LF_PARTITE);
 | |
|       add_file (LF_PAGSCA, LF_PARTITE);  
 | |
|       _errore_grave_SC = FALSE;   
 | |
|       _intestaSC       = TRUE;  
 | |
|       _prima_volta     = TRUE;
 | |
|       _ho_stampato     = FALSE;
 | |
|     }
 | |
|     else
 | |
|     {
 | |
|       TMask msk ("cg6700a");
 | |
|   
 | |
|       TTransfer_file& tr = trasfer();
 | |
|   
 | |
|       apri_file_SC(); 
 | |
|       
 | |
|       msk.set(F_NUMERO, tr.nultras());
 | |
|       msk.set(F_DATALIMITE, tr.dataultras());
 | |
|       const char sdt[2] = { look_sdt(), '\0' };
 | |
|       msk.set(F_SDT, sdt);
 | |
|       msk.set(F_SIGLA, tr.ult_file());
 | |
|       msk.set(F_CHIAVE, tr.key());
 | |
|   
 | |
|       if (msk.run() != K_ENTER) return FALSE;
 | |
|   
 | |
|       _controllo = msk.get_int(F_LISTA);
 | |
|       
 | |
|       reset_files();           // Resetta l'albero di stampa precedente relativo ai movimenti del saldaconto
 | |
|       select_cursor(_cur);     // Seleziona il cursore relativo ai movimenti contabili e iva
 | |
|   
 | |
|       add_file (LF_MOV);
 | |
|       add_file (LF_RMOV, LF_MOV);
 | |
|       if (_is_iva)
 | |
|         add_file (LF_RMOVIVA, LF_MOV);
 | |
|            
 | |
|       _errore_grave        = FALSE; 
 | |
|       _errore_grave_totale = FALSE;  
 | |
|       _intestaSC           = FALSE;
 | |
|     }
 | |
|     
 | |
|     if (_sdt == '*')
 | |
|       ::remove(_pathfile);
 | |
|   
 | |
|     setta_parametri(" ", "C");   
 | |
|   
 | |
|     set_real_picture("###.###.###.###");
 | |
|     set_magic_currency(TRUE);
 | |
|   
 | |
|     printer().footerlen(5);
 | |
|   
 | |
|     setta_intestazione();
 | |
|               
 | |
|     _err.reset();
 | |
|   }
 | |
|   
 | |
|   return TRUE;
 | |
| }
 | |
| 
 | |
| void TRic_ListaMov::setta_intestazione()
 | |
| {
 | |
|   int soh = 1;       
 | |
|   TString sep(132);
 | |
|   TString sep1(198);
 | |
|   TString ragsoc(50);
 | |
|  
 | |
|   TLocalisamfile nditte(LF_NDITTE); 
 | |
|   nditte.zero();
 | |
|   nditte.put(NDT_CODDITTA, get_firm());   
 | |
|   if (nditte.read() == NOERR) 
 | |
|     ragsoc = nditte.get(NDT_RAGSOC);
 | |
|   
 | |
|   reset_header();
 | |
| 
 | |
|   if (_intestaSC)
 | |
|   {
 | |
|     sep1 << TR("Ditta  ") << get_firm();
 | |
|     sep1 << " " << ragsoc;
 | |
|     sep1.left_just(198);
 | |
|   
 | |
|     set_header (soh++, (const char*) sep1);
 | |
|   
 | |
|     sep1 = "";
 | |
|     sep1 << FR("Data @< Pag. @#");
 | |
|   
 | |
|     sep1.right_just(193);
 | |
|     sep1.overwrite (TR("LISTA DI CONTROLLO MOVIMENTI DI SALDACONTO"));
 | |
|     set_header (soh++, (const char*)sep1);
 | |
|     sep1.fill('-');
 | |
|     set_header (soh++, (const char *) sep1);
 | |
|   }
 | |
|   else
 | |
|   {
 | |
|     sep << TR("Ditta  ") << get_firm();
 | |
|     sep << " " << ragsoc;
 | |
|     sep.left_just(132);
 | |
|   
 | |
|     set_header (soh++, (const char*) sep);
 | |
|   
 | |
|     sep = "";
 | |
|     sep << FR("Data @< Pag. @#");
 | |
|   
 | |
|     sep.right_just(127);
 | |
|     sep.overwrite (TR("LISTA DI CONTROLLO MOVIMENTI IN TRASFERIMENTO"));
 | |
|     set_header (soh++, (const char*)sep);
 | |
|     sep.fill('-');
 | |
|     set_header (soh++, (const char *) sep);
 | |
|     set_header (soh++, FR("Rig  Cod.causale  @30gDescriz.aggiuntiva  @56gCod.conto  @71gDescriz.conto  @99gDare  @116gAvere"));
 | |
|     set_header (soh, (const char *) sep);
 | |
|   }
 | |
| }
 | |
| 
 | |
| void TRic_ListaMov::setta_parametri(const TString& sigla, const TString& flag)
 | |
| { 
 | |
|   TTransfer_file& tr = trasfer();
 | |
|   
 | |
|   TConfig conf (CONFIG_DITTA);
 | |
|   conf.set("FlStTra", flag);
 | |
|   
 | |
|   TString rec = tr.record();
 | |
|   rec.overwrite(sigla,240);
 | |
|     
 | |
|   const int size = 1024;
 | |
|   tr.write_control_rec(rec, size);
 | |
| }
 | |
| 
 | |
| int cg6700 (int argc, char* argv[])
 | |
| { 
 | |
|   char p1 = '\0';
 | |
|   char p2 = '\0';
 | |
|   
 | |
|   if (argc >= 4)
 | |
|     p1 = *argv[2];
 | |
|   if (argc >= 5)  
 | |
|     p2 = *argv[3];
 | |
|   
 | |
|   TRic_ListaMov* a = new TRic_ListaMov(p1,p2);
 | |
|   a->run(argc, argv,TR("Lista controllo movimenti"));
 | |
|   delete a;
 | |
|   return TRUE;
 | |
| }
 |