3305 lines
		
	
	
		
			93 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			3305 lines
		
	
	
		
			93 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
//
 | 
						|
// Ricezione dati: lista controllo movimenti
 | 
						|
//       
 | 
						|
 | 
						|
#include <config.h>
 | 
						|
#include <mask.h>
 | 
						|
#include <prefix.h>
 | 
						|
#include <printapp.h>
 | 
						|
#include <progind.h>
 | 
						|
#include <tabutil.h>
 | 
						|
#include <utility.h> 
 | 
						|
#include <mailbox.h>
 | 
						|
 | 
						|
#include <nditte.h>
 | 
						|
#include <mov.h>
 | 
						|
#include <rmov.h>
 | 
						|
#include <rmoviva.h> 
 | 
						|
#include <causali.h> 
 | 
						|
#include <clifo.h> 
 | 
						|
#include <nditte.h> 
 | 
						|
#include <pconti.h> 
 | 
						|
#include <partite.h>
 | 
						|
#include <scadenze.h>
 | 
						|
#include <pagsca.h>
 | 
						|
 | 
						|
#include "cglib.h"
 | 
						|
#include "cg2103.h"
 | 
						|
#include "cglib04.h" 
 | 
						|
#include "cg6700.h"
 | 
						|
 | 
						|
HIDDEN const char* err_msg[] = {"*** Data operazione non valida",
 | 
						|
                                "*** Data operazione non compresa in alcun esercizio",
 | 
						|
                                "*** Data competenza non valida",
 | 
						|
                                "*** Data competenza non compresa in alcun esercizio",
 | 
						|
                                "--- Data competenza incompatibile con data operazione",
 | 
						|
                                "*** Data operazione antecedente ad ultima stampa giornale",
 | 
						|
                                "--- Data documento non valida",
 | 
						|
                                "*** Codice causale non valido o non presente in archivio",
 | 
						|
                                "--- Codice pagamento non valido o non presente in tabella",
 | 
						|
                                "*** Codice registro IVA non valido o non presente in tabella",
 | 
						|
                                "*** Codice cliente/fornitore non valido o non presente in anagrafica",
 | 
						|
                                "--- Data 74 ter non valida",
 | 
						|
                                "*** Data operazione antecedente ad ultima stampa registro IVA",
 | 
						|
                                "*** Tipo anagrafico C/F errato",
 | 
						|
                                "*** Codice anagrafico C/F/Piano Conti errato",
 | 
						|
                                "*** Rif. partite saldaconto errato",
 | 
						|
                                "--- Codice valuta errato",
 | 
						|
                                "*** Data cambio non valida",
 | 
						|
                                "*** Data pagamento/incasso non valida",
 | 
						|
                                "*** Tipo pagamento errato",
 | 
						|
                                "*** Segno D/A errato",      
 | 
						|
                                "*** Cambio mancante",
 | 
						|
                                "*** Gruppo/Conto errato",                    
 | 
						|
                                "*** Rif. rata partite saldaconto errato",
 | 
						|
                                "*** Data scadenza non valida",
 | 
						|
                                "--- Ulteriore classificazione non valida o non presente in archivio",
 | 
						|
                                "*** Importo rata in lire mancante",
 | 
						|
                                "*** Importo rata in valuta mancante",
 | 
						|
                                "--- Codice Nostra banca non valido o non presente in archivio",
 | 
						|
                                "--- Codice Vostra banca non valido o non presente in archivio",
 | 
						|
                                "--- Codice agente non valido o non presente in archivio",
 | 
						|
                                "--- Data sollecito non valida",
 | 
						|
                                "*** Rif. fattura errato",
 | 
						|
                                "*** Rif. rata fattura errato",
 | 
						|
                                "*** In acconto/a saldo errato",
 | 
						|
                                "*** Importo inc./pag. in lire mancante",
 | 
						|
                                "*** Importo inc./pag. in valuta mancante",
 | 
						|
                                "*** Flag abbuono attivo/passivo errato",
 | 
						|
                                "*** Codice valuta errato",
 | 
						|
                                "*** Tipo movimento causale non congruo con tipo movimento saldaconto",
 | 
						|
                                "*** Tipo pagamento del codice di pagamento non congruo con tipo pagamento del saldaconto"};
 | 
						|
 | 
						|
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;
 | 
						|
  
 | 
						|
  TString80        _pathfile, _descr_causale, _descr_conto;
 | 
						|
  TString16        _causale, _registro, _numdoc, _tipodoc, _codval;
 | 
						|
  TString16        _codpag, _codiva, _tipo_conto;
 | 
						|
  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;
 | 
						|
  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;                
 | 
						|
    
 | 
						|
public:
 | 
						|
  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();
 | 
						|
  const char*      look_sdt();
 | 
						|
  const char*      get_codiva_des(const char*);
 | 
						|
  bool             DescrConto(int,int,long);
 | 
						|
  bool             check_archivi(TProgind*);
 | 
						|
  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(TString& codag); 
 | 
						|
  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& ritenute,TString& sez,TString& sezabb,TString& sezdc);  
 | 
						|
  void             azzera_impdocval();
 | 
						|
  int              cerca_anno_solare_esercizio(int codice_esercizio);  
 | 
						|
  bool             esiste_rata();
 | 
						|
  
 | 
						|
  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)
 | 
						|
{}
 | 
						|
 | 
						|
 | 
						|
const char* TRic_ListaMov::look_sdt()
 | 
						|
{
 | 
						|
  TConfig conf(CONFIG_DITTA);
 | 
						|
  return conf.get("FlStTra");
 | 
						|
}
 | 
						|
 | 
						|
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);  
 | 
						|
  
 | 
						|
  if (_ric_auto != 'A')
 | 
						|
  {
 | 
						|
    TProgind* pnd = NULL;
 | 
						|
    pnd = new TProgind (3,"Controllo archivi\nPrego attendere",FALSE, TRUE, 30);                        
 | 
						|
 | 
						|
    if (pnd) pnd->addstatus(1);
 | 
						|
  
 | 
						|
    if (!check_archivi(pnd))
 | 
						|
    {
 | 
						|
      delete pnd;
 | 
						|
      return FALSE;
 | 
						|
    }
 | 
						|
  
 | 
						|
    if (pnd) pnd->addstatus(1);
 | 
						|
    
 | 
						|
    delete pnd;
 | 
						|
  }
 | 
						|
  
 | 
						|
  TString80 tmpmov = "%";
 | 
						|
  tmpmov  << get_firm_dir();
 | 
						|
  tmpmov << "\\" << TEMP_MOV;
 | 
						|
  TString80 tmprmov = "%";
 | 
						|
  tmprmov << get_firm_dir();         
 | 
						|
  tmprmov << "\\" << TEMP_RMOV;  
 | 
						|
  TString80 tmprmoviva = "%";
 | 
						|
  tmprmoviva << get_firm_dir();     
 | 
						|
  tmprmoviva << "\\" << TEMP_RMOVIVA;
 | 
						|
 | 
						|
  _tmov  = new TIsamtempfile(LF_MOV, tmpmov, 0);
 | 
						|
  _trmov = new TIsamtempfile(LF_RMOV, tmprmov, 0);
 | 
						|
 | 
						|
  _is_iva = FALSE;
 | 
						|
  TString tmp = tmprmoviva.mid(1);
 | 
						|
  tmp << ".dbf";
 | 
						|
  if (fexist(tmp))  
 | 
						|
  {
 | 
						|
    _tiva  = new TIsamtempfile(LF_RMOVIVA, tmprmoviva, 0);
 | 
						|
    _is_iva = TRUE;
 | 
						|
  }
 | 
						|
 | 
						|
  _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 *** 
 | 
						|
// *************************************************
 | 
						|
  TString80 tmppart = "%";
 | 
						|
  tmppart  << get_firm_dir();
 | 
						|
  tmppart << "\\" << TEMP_PART;
 | 
						|
/*  TString80 tmpscad = "%";
 | 
						|
  tmpscad << get_firm_dir();         
 | 
						|
  tmpscad << "\\" << TEMP_SCAD;  
 | 
						|
  TString80 tmppagsca = "%";
 | 
						|
  tmppagsca << get_firm_dir();     
 | 
						|
  tmppagsca << "\\" << TEMP_PAGSCA;
 | 
						|
*/
 | 
						|
  _is_salda = FALSE;
 | 
						|
  tmp = tmppart.mid(1);
 | 
						|
  tmp << ".dbf";
 | 
						|
  if (fexist(tmp))
 | 
						|
  { 
 | 
						|
/*    _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); */
 | 
						|
    _is_salda = TRUE;
 | 
						|
/*    
 | 
						|
    _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 
 | 
						|
*/    
 | 
						|
  }
 | 
						|
  
 | 
						|
  _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;
 | 
						|
  TString tmp;
 | 
						|
// *************************************************
 | 
						|
// *** Parte riguardante il Saldaconto se esiste *** 
 | 
						|
// *************************************************
 | 
						|
  TString80 tmppart = "%";
 | 
						|
  tmppart  << get_firm_dir();
 | 
						|
  tmppart << "\\" << TEMP_PART;
 | 
						|
  TString80 tmpscad = "%";
 | 
						|
  tmpscad << get_firm_dir();         
 | 
						|
  tmpscad << "\\" << TEMP_SCAD;  
 | 
						|
  TString80 tmppagsca = "%";
 | 
						|
  tmppagsca << get_firm_dir();     
 | 
						|
  tmppagsca << "\\" << TEMP_PAGSCA;
 | 
						|
 | 
						|
  _is_salda = FALSE;
 | 
						|
  tmp = tmppart.mid(1);
 | 
						|
  tmp << ".dbf";
 | 
						|
  if (fexist(tmp))
 | 
						|
  { 
 | 
						|
    _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);
 | 
						|
    _is_salda = TRUE;
 | 
						|
    
 | 
						|
    _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 
 | 
						|
    
 | 
						|
    _ho_stampato = FALSE;
 | 
						|
  }
 | 
						|
}
 | 
						|
 | 
						|
bool TRic_ListaMov::check_archivi(TProgind* pnd)
 | 
						|
{
 | 
						|
  TString80 nome;
 | 
						|
  long ditta_ric = get_firm();
 | 
						|
  
 | 
						|
  if (!prefix().exist(ditta_ric))
 | 
						|
     return error_box("Rilevati errori gravi negli archivi: procedura interrotta");
 | 
						|
  
 | 
						|
  TTransfer_file& tr = trasfer();
 | 
						|
  
 | 
						|
  _pathfile = tr.path();         
 | 
						|
  
 | 
						|
  _pathfile = _pathfile << HEADER;
 | 
						|
  
 | 
						|
  if (!tr.open(_pathfile))
 | 
						|
     return error_box("Al momento non presenti trasferimenti attivi sulla ditta selezionata");
 | 
						|
  
 | 
						|
  if (!tr.read_control_rec())
 | 
						|
    return error_box("Rilevati errori gravi negli archivi: procedura interrotta");
 | 
						|
  else _record = tr.record();
 | 
						|
  
 | 
						|
  TString16 sd = look_sdt();
 | 
						|
  
 | 
						|
  if (sd.not_empty())
 | 
						|
     _sdt = sd[0];
 | 
						|
  else return error_box("Ricezione tabelle non effettuata: richiamare il programma relativo");
 | 
						|
  
 | 
						|
  if (_sdt == 'T')
 | 
						|
     return error_box("Ricezione tabelle non effettuata: richiamare il programma relativo");
 | 
						|
     
 | 
						|
  if (_sdt == 'M')
 | 
						|
     return yesno_box("Controllo gia' effettuato: si desidera ripeterlo ?");
 | 
						|
     
 | 
						|
  if (_sdt != '*' && _sdt != 'C')
 | 
						|
     return error_box("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("Rilevati errori gravi negli archivi: procedura interrotta");
 | 
						|
 | 
						|
  if (_sdt == '*')
 | 
						|
  {
 | 
						|
    tr.remove_all();
 | 
						|
    return warning_box("Trasferimento interamente completato: proseguire per cancellare i file"); 
 | 
						|
  }
 | 
						|
  
 | 
						|
  if (pnd) pnd->addstatus(1);
 | 
						|
  
 | 
						|
  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", (const char*) err_msg[i]);
 | 
						|
  }  
 | 
						|
} 
 | 
						|
 | 
						|
int  TRic_ListaMov::cerca_anno_solare_esercizio(int codice)
 | 
						|
{      
 | 
						|
  TTable ese ("ESC");
 | 
						|
  TDate datafine;
 | 
						|
  int anno = 0;                        
 | 
						|
  TString dep (format("%04d", codice)); 
 | 
						|
  
 | 
						|
  ese.zero();
 | 
						|
  ese.put("CODTAB", dep);   
 | 
						|
  if (ese.read() == NOERR)
 | 
						|
    datafine = ese.get_date("D1");
 | 
						|
    
 | 
						|
  if (datafine != botime)
 | 
						|
    anno = datafine.year();
 | 
						|
    
 | 
						|
  return anno;
 | 
						|
}
 | 
						|
 | 
						|
bool TRic_ListaMov::controlla_mov()
 | 
						|
{
 | 
						|
  bool check_reg = TRUE;
 | 
						|
  TString16 causreg;
 | 
						|
  TDate udata;
 | 
						|
  char tipocf = ' ';
 | 
						|
  TTransfer_file& tr = trasfer();
 | 
						|
    
 | 
						|
  _tiporeg = 0;
 | 
						|
  
 | 
						|
  if ( !TDate::isdate(_datareg.string()) )
 | 
						|
  {
 | 
						|
    _errore_grave = TRUE;
 | 
						|
    _err.set(0L);
 | 
						|
  }
 | 
						|
 | 
						|
  TString app (_datacomp.string());
 | 
						|
  if (app.empty())
 | 
						|
    tr.datafine_esprec(_anno,_datacomp);
 | 
						|
  
 | 
						|
  if ( TDate::isdate(_datareg.string()) )
 | 
						|
  { 
 | 
						|
    int pr;
 | 
						|
    const int ar = date2esc(_datareg);    // Esercizio in corso
 | 
						|
    pr = _ec.pred(ar);                    // Esercizio precedente
 | 
						|
    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);
 | 
						|
     
 | 
						|
  //if (_causale.not_empty()) 
 | 
						|
  //{
 | 
						|
    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.not_empty())  //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.blank() && _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", (const char*) err_msg[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);
 | 
						|
    TRectype recc (rmov.curr());
 | 
						|
    for (rmov.read(_isgteq); !rmov.eof() ;rmov.next())
 | 
						|
    {
 | 
						|
      TRectype rec (rmov.curr());
 | 
						|
      if (rec > recc) 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 = "";
 | 
						|
      } 
 | 
						|
      
 | 
						|
      //_num_rec = rec.get_long(RMV_ANNOES);
 | 
						|
      
 | 
						|
      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 != avere)
 | 
						|
    {
 | 
						|
     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, "@8g*** Sottoconto partita non valido o non presente in archivio");
 | 
						|
  }
 | 
						|
  else
 | 
						|
  { 
 | 
						|
    if (!_esiste_conto)
 | 
						|
    {    
 | 
						|
      _errore_grave = TRUE;
 | 
						|
      set_row(++riga, "@8g*** Sottoconto partita non valido o non presente in archivio");
 | 
						|
    }
 | 
						|
  }
 | 
						|
                                        
 | 
						|
  if ( (_importo != ZERO && _sezione == '\0') || 
 | 
						|
       (_sezione != 'D' && _sezione != 'A' && _sezione != '\0') )
 | 
						|
  {     
 | 
						|
    _errore_grave = TRUE;
 | 
						|
    set_row(++riga, "@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)
 | 
						|
  // set_row(++riga, "@8g*** Sottoconto contropartita non valido o non presente in archivio");
 | 
						|
  // else
 | 
						|
  { 
 | 
						|
    bool ok = errori_partita(_gruppoc,_contoc,_sottocontoc);
 | 
						|
    if (!ok)
 | 
						|
      set_row(++riga, "@8g--- Sottoconto contropartita non valido o non presente in archivio");
 | 
						|
  } 
 | 
						|
  
 | 
						|
  if (!_mov_sez && _importo == ZERO)
 | 
						|
    set_row(++riga, "@8g--- Importo riga uguale a zero");
 | 
						|
} 
 | 
						|
 | 
						|
bool TRic_ListaMov::controlla_riva()
 | 
						|
{
 | 
						|
  TLocalisamfile& rmoviva = current_cursor()->file(LF_RMOVIVA);
 | 
						|
  TTable  tab_iva("%IVA");
 | 
						|
  TString16 codiva;
 | 
						|
  int tipodet, tipocr, gruppocr, contocr;
 | 
						|
  long sottocontocr;  
 | 
						|
  real impo, impos;
 | 
						|
  bool testata = TRUE;
 | 
						|
  
 | 
						|
  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);
 | 
						|
      tipodet = rec.get_int(RMI_TIPODET);
 | 
						|
      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)
 | 
						|
      {
 | 
						|
        rmoviva.readat(nrec);
 | 
						|
        return TRUE;
 | 
						|
      }
 | 
						|
    
 | 
						|
      if ( tipocr != 0 && tipocr != 1 && tipocr != 2 && tipocr != 3 && 
 | 
						|
           tipocr != 4 && tipocr != 5 && tipocr != 8 && tipocr != 9    )
 | 
						|
      { 
 | 
						|
        rmoviva.readat(nrec);
 | 
						|
        return TRUE;
 | 
						|
      }
 | 
						|
      if (gruppocr == 0 || contocr == 0 || sottocontocr == 0l)
 | 
						|
      { 
 | 
						|
        rmoviva.readat(nrec);
 | 
						|
        return TRUE; 
 | 
						|
      }
 | 
						|
      else if (gruppocr != 0 && contocr != 0 && sottocontocr != 0l)
 | 
						|
      {
 | 
						|
        bool ok = errori_partita(gruppocr,contocr,sottocontocr);
 | 
						|
        if (!ok) 
 | 
						|
        { 
 | 
						|
         rmoviva.readat(nrec);
 | 
						|
         return TRUE;
 | 
						|
        }
 | 
						|
      }  
 | 
						|
      if (tipodet != 0 && tipodet != 1 && tipodet != 3 && tipodet != 9)
 | 
						|
      {  
 | 
						|
       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, "@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, "@8g--- Tipo costo/ricavo non valido");
 | 
						|
 | 
						|
  if (_gruppocr == 0 || _contocr == 0 || _sottocontocr == 0l)
 | 
						|
    set_row(++riga, "@8g--- Sottoconto costo/ricavo non valido o non presente in archivio");
 | 
						|
  else if (_gruppocr != 0 && _contocr != 0 && _sottocontocr != 0l)
 | 
						|
  {
 | 
						|
    bool ok = errori_partita(_gruppocr,_contocr,_sottocontocr);
 | 
						|
    if (!ok) 
 | 
						|
     set_row(++riga, "@8g--- Sottoconto costo/ricavo non valido o non presente in archivio");
 | 
						|
  }  
 | 
						|
 | 
						|
  if (_tipod != 0 && _tipod != 1 && _tipod != 3 && _tipod != 9)
 | 
						|
    set_row(++riga, "@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;
 | 
						|
}
 | 
						|
 | 
						|
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");
 | 
						|
    
 | 
						|
    TString dep (format("%-3s", (const char*) _codval));
 | 
						|
    
 | 
						|
    val.zero();
 | 
						|
    val.put("CODTAB", dep);
 | 
						|
    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");
 | 
						|
  TString dep; 
 | 
						|
   
 | 
						|
  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)      
 | 
						|
    {         
 | 
						|
      int tipo = rpg.get_int("I1");
 | 
						|
      if (tipo == tipopag) 
 | 
						|
      {
 | 
						|
        _tipopag_pag = tipo;
 | 
						|
        return TRUE;  
 | 
						|
      }
 | 
						|
    } 
 | 
						|
    else
 | 
						|
      return FALSE;
 | 
						|
  }                            
 | 
						|
    
 | 
						|
  return FALSE;
 | 
						|
}
 | 
						|
 | 
						|
bool TRic_ListaMov::ulteriore_classificazione(int tipopag, TString& ultclass)
 | 
						|
{
 | 
						|
  TTable clr ("%CLR");
 | 
						|
  
 | 
						|
  TString 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(TString& codag)
 | 
						|
{   
 | 
						|
  if (codag == "")
 | 
						|
    return TRUE;
 | 
						|
    
 | 
						|
  TTable ag ("%AGE");
 | 
						|
  TString dep;
 | 
						|
  
 | 
						|
  dep.format("%5s", (const char*) codag);
 | 
						|
  
 | 
						|
  ag.zero();
 | 
						|
  ag.put("CODTAB", dep);
 | 
						|
  if (ag.read() == NOERR)
 | 
						|
    return TRUE;
 | 
						|
    
 | 
						|
  return FALSE;
 | 
						|
}
 | 
						|
 | 
						|
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;
 | 
						|
        }
 | 
						|
        cerca_tipopag_codpag(codpag,tipopag);
 | 
						|
        if (tipopag != _tipopag_pag)
 | 
						|
        {
 | 
						|
          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 = "Rimessa diretta";
 | 
						|
                    break;
 | 
						|
            case 2: descr = "Tratta";
 | 
						|
                    break;
 | 
						|
            case 3: descr = "Ricevuta bancaria";
 | 
						|
                    break;
 | 
						|
            case 4: descr = "Cessione";
 | 
						|
                    break;
 | 
						|
            case 5: descr = "Paghero'";
 | 
						|
                    break;
 | 
						|
            case 6: descr = "Lettera di credito";
 | 
						|
                    break;
 | 
						|
            case 7: descr = "Tratta accettata";
 | 
						|
                    break;
 | 
						|
            case 8: descr = "Rapporti interbancari diretti";
 | 
						|
                    break;
 | 
						|
            case 9: descr = "Bonifico";
 | 
						|
                    break;
 | 
						|
            case 10: descr = "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,"@26gN.rata      Data scad.  Sez          Importo  Importo valuta");
 | 
						|
    set_row(riga++,"@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", (const char*) err_msg[23]);
 | 
						|
  }  
 | 
						|
  if ( !TDate::isdate(datascad.string()) )
 | 
						|
  {
 | 
						|
    _errore_grave_SC = TRUE;
 | 
						|
    set_row(++riga, "@30g%s", (const char*) err_msg[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", (const char*) err_msg[19]);
 | 
						|
    }
 | 
						|
    cerca_tipopag_codpag(codpag,tipopag);  
 | 
						|
    if (tipopag != _tipopag_pag)
 | 
						|
    {
 | 
						|
      _errore_grave_SC = TRUE;
 | 
						|
      set_row(++riga, "@30g%s", (const char*) err_msg[40]);
 | 
						|
    } 
 | 
						|
  }
 | 
						|
  if (ultclass.not_empty())
 | 
						|
  {
 | 
						|
    if (!ulteriore_classificazione(tipopag,ultclass))
 | 
						|
      set_row(++riga, "@30g%s", (const char*) err_msg[25]);
 | 
						|
  }  
 | 
						|
  if (importo == ZERO)
 | 
						|
  {
 | 
						|
    _errore_grave_SC = TRUE;
 | 
						|
    set_row(++riga, "@30g%s", (const char*) err_msg[26]);
 | 
						|
  }             
 | 
						|
  if (_codval.not_empty() && importoval == ZERO)
 | 
						|
  {
 | 
						|
    _errore_grave_SC = TRUE;
 | 
						|
    set_row(++riga, "@30g%s", (const char*) err_msg[27]);
 | 
						|
  }          
 | 
						|
  if (!banca(abins,cabns))
 | 
						|
    set_row(++riga, "@30g%s", (const char*) err_msg[28]);
 | 
						|
             
 | 
						|
  if (!banca(abivs,cabvs))
 | 
						|
    set_row(++riga, "@30g%s", (const char*) err_msg[29]);
 | 
						|
             
 | 
						|
  if (!agente(codag))
 | 
						|
    set_row(++riga, "@30g%s", (const char*) err_msg[30]);
 | 
						|
  
 | 
						|
  TString datasoll_str = datasoll.string();
 | 
						|
  if ( datasoll_str.not_empty() && !TDate::isdate(datasoll.string()) )
 | 
						|
    set_row(++riga, "@30g%s", (const char*) err_msg[31]);
 | 
						|
}
 | 
						|
 | 
						|
bool TRic_ListaMov::record_partite(int nriga)
 | 
						|
{
 | 
						|
  TRecnotype nrec = _tpart->recno();
 | 
						|
  TIsamtempfile& part = *_tpart;
 | 
						|
  
 | 
						|
  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);
 | 
						|
  if (part.read() == NOERR)  
 | 
						|
  {
 | 
						|
    _tpart->readat(nrec);
 | 
						|
    return TRUE;         
 | 
						|
  }
 | 
						|
  _tpart->readat(nrec);
 | 
						|
    
 | 
						|
  return FALSE;
 | 
						|
}
 | 
						|
 | 
						|
bool TRic_ListaMov::record_scadenze(int nrigp,int nrata)
 | 
						|
{
 | 
						|
  TRecnotype nrec = _tscad->recno();
 | 
						|
  TIsamtempfile& scad = *_tscad;
 | 
						|
  
 | 
						|
  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);
 | 
						|
  if (scad.read() == NOERR)  
 | 
						|
  {
 | 
						|
    _tscad->readat(nrec);
 | 
						|
    return TRUE;         
 | 
						|
  }
 | 
						|
  _tscad->readat(nrec);
 | 
						|
    
 | 
						|
  return FALSE;
 | 
						|
}
 | 
						|
 | 
						|
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);
 | 
						|
    //pagsca.put(PAGSCA_NRIGA,      _nriga);
 | 
						|
    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();
 | 
						|
  
 | 
						|
  int     nrigp      = cur->curr(LF_PAGSCA).get_int (PAGSCA_NRIGP);
 | 
						|
  if (nrigp == _nriga)
 | 
						|
  {
 | 
						|
  int     nriga      = cur->curr(LF_PAGSCA).get_int (PAGSCA_NRIGA);
 | 
						|
  int     nrata      = cur->curr(LF_PAGSCA).get_int (PAGSCA_NRATA);
 | 
						|
  char    accsaldo   = cur->curr(LF_PAGSCA).get_char(PAGSCA_ACCSAL);
 | 
						|
  real    importo    = cur->curr(LF_PAGSCA).get_real(PAGSCA_IMPORTO);
 | 
						|
  real    importoval = cur->curr(LF_PAGSCA).get_real(PAGSCA_IMPORTOVAL);
 | 
						|
  real    abbuoni    = cur->curr(LF_PAGSCA).get_real(PAGSCA_ABBUONI);
 | 
						|
  real    ritenute   = cur->curr(LF_PAGSCA).get_real(PAGSCA_RITENUTE);
 | 
						|
  real    diffcam    = cur->curr(LF_PAGSCA).get_real(PAGSCA_DIFFCAM);
 | 
						|
  char    passat     = cur->curr(LF_PAGSCA).get_char(PAGSCA_PASSATT);
 | 
						|
  long    abins      = cur->curr(LF_PAGSCA).get_long(PAGSCA_CODABIPR);
 | 
						|
  long    cabns      = cur->curr(LF_PAGSCA).get_long(PAGSCA_CODCABPR);
 | 
						|
  long    abivs      = cur->curr(LF_PAGSCA).get_long(PAGSCA_CODABI);
 | 
						|
  long    cabvs      = cur->curr(LF_PAGSCA).get_long(PAGSCA_CODCAB);
 | 
						|
  TString codag      = cur->curr(LF_PAGSCA).get     (PAGSCA_CODAG);  
 | 
						|
  char    tipoc      = cur->curr(LF_PAGSCA).get_char(PAGSCA_TIPOCC);
 | 
						|
  int     gruppoc    = cur->curr(LF_PAGSCA).get_int (PAGSCA_GRUPPOC);
 | 
						|
  int     contoc     = cur->curr(LF_PAGSCA).get_int (PAGSCA_CONTOC);
 | 
						|
  long    sottocc    = cur->curr(LF_PAGSCA).get_long(PAGSCA_SOTTOCONTC);
 | 
						|
  
 | 
						|
  controlla_anaCF_Pcon(tipoc,gruppoc,contoc,sottocc);
 | 
						|
  
 | 
						|
  if (_prima_rata_pag)
 | 
						|
  {                   
 | 
						|
    set_row(riga,"@22gRif. rata       acc./saldo  Sez          Importo  Importo valuta  Contropartita");
 | 
						|
    set_row(riga++,"@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,"@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,"@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,"@88gDifferenza cambio");
 | 
						|
  }
 | 
						|
 | 
						|
  if (nriga != 9999)
 | 
						|
  { 
 | 
						|
    if (!record_partite(nriga))
 | 
						|
    {
 | 
						|
      _errore_grave_SC = TRUE;
 | 
						|
      set_row(++riga, "@30g%s", (const char*) err_msg[32]);
 | 
						|
    }
 | 
						|
  }  
 | 
						|
  if (nrata != 9999)
 | 
						|
  {
 | 
						|
    if (!record_scadenze(nriga,nrata))
 | 
						|
    {
 | 
						|
      _errore_grave_SC = TRUE;
 | 
						|
      set_row(++riga, "@30g%s", (const char*) err_msg[33]);
 | 
						|
    }
 | 
						|
  }               
 | 
						|
  if (accsaldo != 'A' && accsaldo != 'S')
 | 
						|
  {
 | 
						|
    _errore_grave_SC = TRUE;
 | 
						|
    set_row(++riga, "@30g%s", (const char*) err_msg[34]);
 | 
						|
  }
 | 
						|
  if (importo == ZERO)
 | 
						|
  {
 | 
						|
    _errore_grave_SC = TRUE;
 | 
						|
    set_row(++riga, "@30g%s", (const char*) err_msg[35]);
 | 
						|
  }             
 | 
						|
  if (_codval.not_empty() && importoval == ZERO)
 | 
						|
  {
 | 
						|
    _errore_grave_SC = TRUE;
 | 
						|
    set_row(++riga, "@30g%s", (const char*) err_msg[36]);
 | 
						|
  }          
 | 
						|
  if (abbuoni != ZERO && (passat != 'A' && passat != 'P') )
 | 
						|
  {
 | 
						|
    _errore_grave_SC = TRUE;
 | 
						|
    set_row(++riga, "@30g%s", (const char*) err_msg[37]);
 | 
						|
  }  
 | 
						|
  if (!banca(abins,cabns))
 | 
						|
    set_row(++riga, "@30g%s", (const char*) err_msg[28]);
 | 
						|
             
 | 
						|
  if (!banca(abivs,cabvs))
 | 
						|
    set_row(++riga, "@30g%s", (const char*) err_msg[29]);
 | 
						|
             
 | 
						|
  if (!agente(codag))
 | 
						|
    set_row(++riga, "@30g%s", (const char*) err_msg[30]);
 | 
						|
 | 
						|
  if (!controlla_anaCF_Pcon(tipoc,gruppoc,contoc,sottocc))
 | 
						|
    set_row(++riga, "@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,"Operazione n. %-7ld", _numero);
 | 
						|
      set_row(r," del %s", (const char*)datareg_str);
 | 
						|
      set_row(r," doc. n. %-7s", (const char*)_numdoc);
 | 
						|
      set_row(r," del %s", (const char*)datadoc_str);
 | 
						|
      if (!_registro.blank())  //e' una fattura
 | 
						|
      {
 | 
						|
       set_row(r," registro IVA %-3s", (const char*)_registro);
 | 
						|
       set_row(r," protocollo n. %-5ld", _protiva);
 | 
						|
      } 
 | 
						|
      set_row(r, " comp. %d", _anno); 
 | 
						|
     
 | 
						|
      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);
 | 
						|
//    TLocalisamfile& rmov = current_cursor()->file(LF_RMOV); 
 | 
						|
    
 | 
						|
//    rmov.put(RMV_ANNOES, _annoese);
 | 
						|
    
 | 
						|
//    rmov.rewrite();
 | 
						|
  }
 | 
						|
  else if (file == LF_RMOVIVA)
 | 
						|
  {
 | 
						|
    real impo = cur->curr(LF_RMOVIVA).get_real(RMI_IMPONIBILE);
 | 
						|
    real impos = cur->curr(LF_RMOVIVA).get_real(RMI_IMPOSTA);
 | 
						|
    int numrig = cur->curr(LF_RMOVIVA).get_int(RMI_NUMRIG); 
 | 
						|
    _tipocr = cur->curr(LF_RMOVIVA).get_int(RMI_TIPOCR);
 | 
						|
    _tipod  = cur->curr(LF_RMOVIVA).get_int(RMI_TIPODET);
 | 
						|
    _codiva = cur->curr(LF_RMOVIVA).get(RMI_CODIVA);  
 | 
						|
    //_n_rec  = cur->curr(LF_RMOVIVA).get_int(RMI_ANNOES); 
 | 
						|
    _gruppocr = cur->curr(LF_RMOVIVA).get_int(RMI_GRUPPO); 
 | 
						|
    _contocr  = cur->curr(LF_RMOVIVA).get_int(RMI_CONTO);
 | 
						|
    _sottocontocr = cur->curr(LF_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;          
 | 
						|
    set_row(r, "I%d", numrig);
 | 
						|
    set_row(r, "@5gImponibile@16g%r",&_impo);
 | 
						|
    set_row(r, "@32gImposta@40g%r", &_impos);      
 | 
						|
    set_row(r, "@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 controlla = controlla_partite(); //se TRUE => ci sono errori nella testata
 | 
						|
    bool verpagsca = controlla_pagsca();
 | 
						|
    bool verscad   = controlla_scadenze();
 | 
						|
    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 = "Cliente:  ";
 | 
						|
      else
 | 
						|
        if (_tipocf == 'F')
 | 
						|
          ccf = "Fornitore:";
 | 
						|
        else
 | 
						|
          ccf = "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,"@0g@rRif. partita");
 | 
						|
      set_row(r,"@14gN.riga@22gN.operaz./riga  Data oper.  Data doc.   N.doc.   Reg  Prot.  Causale");
 | 
						|
      set_row(r++,"@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;
 | 
						|
    if (_tot_dare != _tot_avere)
 | 
						|
    {
 | 
						|
       _errore_grave = TRUE;
 | 
						|
       set_row(n++, "@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("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("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("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)
 | 
						|
}
 | 
						|
 | 
						|
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);
 | 
						|
  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);
 | 
						|
          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);
 | 
						|
  if (_tipodoc == "NC" || _tipodoc == "ST")
 | 
						|
    _tot_doc = _tot_doc * -1;
 | 
						|
  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);
 | 
						|
 | 
						|
  if (_tipodoc == "NC" || _tipodoc == "ST")
 | 
						|
  {
 | 
						|
    _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);
 | 
						|
  
 | 
						|
  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);
 | 
						|
    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& ritenute,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);
 | 
						|
    ritenute   += pagsca.get_real(PAGSCA_RITENUTE);
 | 
						|
    
 | 
						|
    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)   
 | 
						|
  {  
 | 
						|
/*    if (_prima_volta)
 | 
						|
    {
 | 
						|
      _prima_volta = FALSE;
 | 
						|
      if (part.get_real(PART_IMPTOTDOC) == ZERO)
 | 
						|
        _calcola = TRUE;
 | 
						|
      else
 | 
						|
        _calcola = FALSE;
 | 
						|
    }  */
 | 
						|
//    if (_calcola)
 | 
						|
//    {
 | 
						|
      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    ritenute   = 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,ritenute,sez,sezabb,sezdc);  
 | 
						|
 | 
						|
    part.put(PART_IMPORTO,    importo);
 | 
						|
    part.put(PART_IMPORTOVAL, importoval);
 | 
						|
    part.put(PART_RITENUTE,   ritenute);
 | 
						|
    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; 
 | 
						|
//  delete _relSC;
 | 
						|
//  delete _cur;
 | 
						|
  delete _tmov;
 | 
						|
  delete _trmov;
 | 
						|
  if (_is_iva)
 | 
						|
    delete _tiva;
 | 
						|
/*  if (_is_salda)
 | 
						|
  {
 | 
						|
    delete _tpart;
 | 
						|
    delete _tscad;
 | 
						|
    delete _tpagsca;
 | 
						|
  } */ 
 | 
						|
  delete _caus;
 | 
						|
  delete _ditte; 
 | 
						|
  delete _clifo; 
 | 
						|
  delete _pcon;    
 | 
						|
  delete _mov;
 | 
						|
  delete _rmov;
 | 
						|
  delete _rmoviva;
 | 
						|
/*  delete _part;
 | 
						|
  delete _scad;
 | 
						|
  delete _pagsca; */ 
 | 
						|
  delete _tab_tra;
 | 
						|
  delete _tab_pag;
 | 
						|
  delete _tab_tpd;
 | 
						|
  delete _tab_iva;
 | 
						|
  delete _tab_ese;      
 | 
						|
  
 | 
						|
  return TRUE;
 | 
						|
}                                
 | 
						|
 | 
						|
void TRic_ListaMov::chiudi_file_SC()
 | 
						|
{
 | 
						|
  if (_is_salda)
 | 
						|
  { 
 | 
						|
    delete _relSC;
 | 
						|
    delete _tpart;
 | 
						|
    delete _tscad;
 | 
						|
    delete _tpagsca;
 | 
						|
    delete _part;
 | 
						|
    delete _scad;
 | 
						|
    delete _pagsca;
 | 
						|
  }
 | 
						|
}
 | 
						|
 | 
						|
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;
 | 
						|
    }
 | 
						|
    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("Al momento non presenti trasferimenti attivi sulla ditta selezionata");
 | 
						|
 | 
						|
      if (!tr.read_control_rec())
 | 
						|
        return error_box("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("###.###.###.###");
 | 
						|
  
 | 
						|
    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;
 | 
						|
    }
 | 
						|
    else
 | 
						|
    {
 | 
						|
      TMask msk ("cg6700a");
 | 
						|
  
 | 
						|
      TTransfer_file& tr = trasfer();
 | 
						|
  
 | 
						|
      apri_file_SC(); 
 | 
						|
      
 | 
						|
      msk.set(F_NUMERO, tr.nultras());
 | 
						|
      msk.set(F_DATALIMITE, tr.dataultras());
 | 
						|
      msk.set(F_SDT, look_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 == '*')
 | 
						|
      fremove(_pathfile);
 | 
						|
  
 | 
						|
    setta_parametri(" ", "C");   
 | 
						|
  
 | 
						|
    set_real_picture("###.###.###.###");
 | 
						|
  
 | 
						|
    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 << "Ditta  " << get_firm();
 | 
						|
    sep1 << " " << ragsoc;
 | 
						|
    sep1.left_just(198);
 | 
						|
  
 | 
						|
    set_header (soh++, (const char*) sep1);
 | 
						|
  
 | 
						|
    sep1 = "";
 | 
						|
    sep1 << "Data @< Pag. @#";
 | 
						|
  
 | 
						|
    sep1.right_just(193);
 | 
						|
    sep1.overwrite ("LISTA DI CONTROLLO MOVIMENTI DI SALDACONTO");
 | 
						|
    set_header (soh++, (const char*)sep1);
 | 
						|
    sep1.fill('-');
 | 
						|
    set_header (soh++, (const char *) sep1);
 | 
						|
  }
 | 
						|
  else
 | 
						|
  {
 | 
						|
    sep << "Ditta  " << get_firm();
 | 
						|
    sep << " " << ragsoc;
 | 
						|
    sep.left_just(132);
 | 
						|
  
 | 
						|
    set_header (soh++, (const char*) sep);
 | 
						|
  
 | 
						|
    sep = "";
 | 
						|
    sep << "Data @< Pag. @#";
 | 
						|
  
 | 
						|
    sep.right_just(127);
 | 
						|
    sep.overwrite ("LISTA DI CONTROLLO MOVIMENTI IN TRASFERIMENTO");
 | 
						|
    set_header (soh++, (const char*)sep);
 | 
						|
    sep.fill('-');
 | 
						|
    set_header (soh++, (const char *) sep);
 | 
						|
    set_header (soh++, "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,"Lista controllo movimenti");
 | 
						|
  delete a;
 | 
						|
  return TRUE;
 | 
						|
}
 |