primanota eccola qua pero' quel sorgente la' io non so cosa ci fa (risulta che ho modificato TUTTI i cg6* che io non ho neppure mai visto) git-svn-id: svn://10.65.10.50/trunk@2245 c028cbd2-c16b-5b4b-a496-9718f37d4682
		
			
				
	
	
		
			1304 lines
		
	
	
		
			37 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			1304 lines
		
	
	
		
			37 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
#include "cg6900.h"
 | 
						|
#include "cg6900a.h"
 | 
						|
#include <math.h>  
 | 
						|
 | 
						|
FILE* TInv_cont::chiedi_disco(const char* name, int disk, char floppy, bool lettura) 
 | 
						|
{ 
 | 
						|
  message_box("Inserire il disco %d nel drive %c:", disk, floppy);
 | 
						|
 | 
						|
  //  name.ext(format("%03d", disk));
 | 
						|
  
 | 
						|
  FILE* f = NULL;                                                           
 | 
						|
  bool retry = TRUE;
 | 
						|
  while (retry)
 | 
						|
  {               
 | 
						|
    f = fopen(name, lettura ? "rb" : "wb");
 | 
						|
    if (f == NULL) 
 | 
						|
      retry = yesno_box("Il file %s non e' accessibile: riprovare?", (const char*)name);
 | 
						|
    else
 | 
						|
    {
 | 
						|
      retry = FALSE; 
 | 
						|
      fclose(f);
 | 
						|
    }
 | 
						|
  }  
 | 
						|
 | 
						|
  return f;
 | 
						|
} 
 | 
						|
 | 
						|
bool TInv_cont::scrivi_disco(char floppy, int disk, const char* work, 
 | 
						|
                             FILE* i, TProgind& w) 
 | 
						|
{               
 | 
						|
  chiedi_disco(work, disk, floppy, FALSE);                                   
 | 
						|
  
 | 
						|
  TString str;
 | 
						|
  str.format("%02d", disk);
 | 
						|
  aggiorna_marker(str,31);                 // Aggiorna il num. progr. disco su marker
 | 
						|
  
 | 
						|
  TString path_m;
 | 
						|
  path_m << floppy << ":\\marker";           
 | 
						|
 | 
						|
//  TString path_h;
 | 
						|
//  path_h << floppy << ":\\header";        
 | 
						|
       
 | 
						|
  TString path_t;
 | 
						|
  path_t << floppy << ":\\trasfer";
 | 
						|
  
 | 
						|
  fcopy(_marker,path_m);                    // Copia il marker su disco
 | 
						|
//  if (disk == 1)
 | 
						|
//    fcopy(_header,path_h);                  // Copia il record di controllo solo sul primo disco
 | 
						|
 | 
						|
  FILE* o = fopen(path_t, "wb");
 | 
						|
  
 | 
						|
  TString buffer(BUFSIZE);
 | 
						|
  
 | 
						|
  long tot_scritti = BUFSIZE;
 | 
						|
  
 | 
						|
  while (tot_scritti <= _dim_disk)
 | 
						|
  {
 | 
						|
    const word letti = fread((char*)(const char*)buffer, 1, BUFSIZE, i);
 | 
						|
    
 | 
						|
    long scritti = fwrite((char*)(const char*)buffer, letti, 1, o);
 | 
						|
    
 | 
						|
    tot_scritti += letti;
 | 
						|
    
 | 
						|
    if (letti < BUFSIZE) break;
 | 
						|
    
 | 
						|
    w.addstatus(letti);
 | 
						|
  }
 | 
						|
  
 | 
						|
  fclose(o);
 | 
						|
 | 
						|
  return TRUE;
 | 
						|
}
 | 
						|
 | 
						|
int TInv_cont::calcola_numero_dischi(TMask& msk)
 | 
						|
{        
 | 
						|
  int numdisc = 0;
 | 
						|
  
 | 
						|
  FILE* t = fopen(_trasf, "rb");
 | 
						|
  if (t == NULL) return error_box("Impossibile aprire il file '%s'", _trasf);
 | 
						|
  
 | 
						|
  long dim_t = _tras_file.determina_dimensione(t);  //Determina la dimensione del trasfer
 | 
						|
  fclose(t);
 | 
						|
 | 
						|
//  FILE* h = fopen(_header, "rb");
 | 
						|
//  if (h == NULL) return error_box("Impossibile aprire il file '%s'", _header);
 | 
						|
  
 | 
						|
//  long dim_h = determina_dimensione(h);  //Determina la dimensione del trasfer
 | 
						|
//  fclose(h);
 | 
						|
  
 | 
						|
  FILE* m = fopen(_marker, "rb");
 | 
						|
  if (m == NULL) return error_box("Impossibile aprire il file '%s'", _marker);
 | 
						|
  
 | 
						|
  long dim_m = _tras_file.determina_dimensione(m);  // Determina la dimensione del marker
 | 
						|
  fclose(m);
 | 
						|
  
 | 
						|
  _dim_tot = dim_t + dim_m; //+dim_h;       // Determina la dimensione totale           
 | 
						|
  
 | 
						|
  int  item = msk.get_int(F_DIM);       
 | 
						|
  
 | 
						|
  switch (item)
 | 
						|
  {
 | 
						|
  case 1 :
 | 
						|
    _dim_disk = 1400000L;
 | 
						|
    break;
 | 
						|
  case 2 :
 | 
						|
    _dim_disk = 1200000L;
 | 
						|
    break;
 | 
						|
  case 3 :
 | 
						|
    _dim_disk = 720000L;
 | 
						|
    break;
 | 
						|
  case 4 :
 | 
						|
    _dim_disk = 360000L;
 | 
						|
    break;            
 | 
						|
    default :
 | 
						|
    break;  
 | 
						|
  };
 | 
						|
  
 | 
						|
  if (_dim_tot < _dim_disk)
 | 
						|
    numdisc = 1;
 | 
						|
  else
 | 
						|
  {  
 | 
						|
    numdisc = int(_dim_tot / _dim_disk);
 | 
						|
    if ( (_dim_tot % _dim_disk) != 0)
 | 
						|
      numdisc += 1;
 | 
						|
  }
 | 
						|
  
 | 
						|
  return numdisc;
 | 
						|
}
 | 
						|
 | 
						|
bool TInv_cont::invio_contabilita()
 | 
						|
{
 | 
						|
  char    sigla;
 | 
						|
  TString nrec,files;               
 | 
						|
  bool    header = TRUE;
 | 
						|
  int     size = 256;
 | 
						|
  
 | 
						|
  _numrec_cau   = 0;
 | 
						|
  _numrec_clifo = 0;
 | 
						|
  _numrec_pcon  = 0;
 | 
						|
  _numrec_pn    = 0;
 | 
						|
  _numrec_iva   = 0;
 | 
						|
  
 | 
						|
  _tras_file.open(_header);
 | 
						|
  
 | 
						|
  leggi_record_controllo();
 | 
						|
 | 
						|
  files  = _tras_file.sigle_file();
 | 
						|
  nrec   = _tras_file.nrec_file();
 | 
						|
  files.trim();
 | 
						|
 | 
						|
  _tras_file.open(_trasf,TRUE);  
 | 
						|
  
 | 
						|
  for (int i = 0; i < files.len();i++)
 | 
						|
  {                 
 | 
						|
    sigla    = files[i];
 | 
						|
    //_numrec  = atol(nrec.mid(i * 6,6));
 | 
						|
 | 
						|
    if (header)
 | 
						|
    { 
 | 
						|
      TString app1 = _control_rec.mid(0,25);
 | 
						|
      TString app2 = _control_rec.mid(26,7);
 | 
						|
      TString app3 = _control_rec.mid(35);
 | 
						|
      _control_rec = app1 << app2 << app3;
 | 
						|
      _control_rec.insert("   ",232);
 | 
						|
      _tras_file.write_control_rec(_control_rec,size);      
 | 
						|
      header = FALSE;
 | 
						|
    }
 | 
						|
    
 | 
						|
    switch (sigla)        
 | 
						|
    {
 | 
						|
    case 'W': 
 | 
						|
      if (!invio_tab_cau())
 | 
						|
        return FALSE;       
 | 
						|
      break;
 | 
						|
      
 | 
						|
    case 'A':
 | 
						|
      if (!invio_clifo())
 | 
						|
        return FALSE;
 | 
						|
      break;
 | 
						|
      
 | 
						|
    case 'P':
 | 
						|
      if (!invio_pcon())
 | 
						|
        return FALSE;
 | 
						|
      break;
 | 
						|
      
 | 
						|
    case 'Z':
 | 
						|
      if (!invio_mov_PN())
 | 
						|
        return FALSE;                   
 | 
						|
      break;
 | 
						|
      
 | 
						|
    case 'U':
 | 
						|
      if (!invio_mov_IVA())
 | 
						|
        return FALSE;                 
 | 
						|
      break;
 | 
						|
      
 | 
						|
    default:
 | 
						|
      break;
 | 
						|
    };             
 | 
						|
  }
 | 
						|
   
 | 
						|
  aggiorna_header(files);
 | 
						|
  aggiorna_trasfer(files);
 | 
						|
  
 | 
						|
  TString str;
 | 
						|
  
 | 
						|
  calcola_totale_record();
 | 
						|
  str.format("%06ld", _tot_rec);
 | 
						|
  aggiorna_marker(str,23);  
 | 
						|
    
 | 
						|
  return TRUE;
 | 
						|
}
 | 
						|
 | 
						|
void TInv_cont::aggiorna_header(TString& files)
 | 
						|
{
 | 
						|
  char sigla;        
 | 
						|
  int     size = 256;  
 | 
						|
   
 | 
						|
  _tras_file.open(_header);
 | 
						|
  leggi_record_controllo();
 | 
						|
  
 | 
						|
  for (int i = 0; i < files.len();i++)
 | 
						|
  {                 
 | 
						|
    sigla    = files[i];
 | 
						|
 | 
						|
    switch (sigla)        
 | 
						|
    {
 | 
						|
    case 'W': 
 | 
						|
      {
 | 
						|
        TString app;
 | 
						|
        app.format("%06ld", _numrec_cau);
 | 
						|
        _control_rec.overwrite(app,((i * 6) + 50));
 | 
						|
      }
 | 
						|
      break;
 | 
						|
      
 | 
						|
    case 'A':
 | 
						|
      {
 | 
						|
        TString app;
 | 
						|
        app.format("%06ld", _numrec_clifo);
 | 
						|
        _control_rec.overwrite(app,((i * 6) + 50));
 | 
						|
      }
 | 
						|
      break;
 | 
						|
      
 | 
						|
    case 'P':
 | 
						|
      {
 | 
						|
        TString app;
 | 
						|
        app.format("%06ld", _numrec_pcon);
 | 
						|
        _control_rec.overwrite(app,((i * 6) + 50));
 | 
						|
      }        
 | 
						|
      break;
 | 
						|
      
 | 
						|
    case 'Z':
 | 
						|
      {
 | 
						|
        TString app;
 | 
						|
        app.format("%06ld", _numrec_pn);
 | 
						|
        _control_rec.overwrite(app,((i * 6) + 50));
 | 
						|
      }        
 | 
						|
      break;
 | 
						|
      
 | 
						|
    case 'U':
 | 
						|
      {
 | 
						|
        TString app;
 | 
						|
        app.format("%06ld", _numrec_iva);
 | 
						|
        _control_rec.overwrite(app,((i * 6) + 50));
 | 
						|
      }        
 | 
						|
      break;
 | 
						|
      
 | 
						|
    default:
 | 
						|
      break;
 | 
						|
    };             
 | 
						|
  }
 | 
						|
  _tras_file.write_control_rec(_control_rec,size);                      
 | 
						|
  _tras_file.close();
 | 
						|
}
 | 
						|
 | 
						|
void TInv_cont::aggiorna_trasfer(TString& files)
 | 
						|
{                    
 | 
						|
  char sigla;
 | 
						|
  int     size = 256;
 | 
						|
    
 | 
						|
  _tras_file.open(_trasf);
 | 
						|
  leggi_record_controllo();
 | 
						|
  
 | 
						|
  for (int i = 0; i < files.len();i++)
 | 
						|
  {                 
 | 
						|
    sigla    = files[i];
 | 
						|
 | 
						|
    switch (sigla)        
 | 
						|
    {
 | 
						|
    case 'W': 
 | 
						|
      {
 | 
						|
        TString app;
 | 
						|
        app.format("%06ld", _numrec_cau);
 | 
						|
        _control_rec.overwrite(app,((i * 6) + 47));
 | 
						|
      }
 | 
						|
      break;
 | 
						|
      
 | 
						|
    case 'A':
 | 
						|
      {
 | 
						|
        TString app;
 | 
						|
        app.format("%06ld", _numrec_clifo);
 | 
						|
        _control_rec.overwrite(app,((i * 6) + 47));
 | 
						|
      }
 | 
						|
      break;
 | 
						|
      
 | 
						|
    case 'P':
 | 
						|
      {
 | 
						|
        TString app;
 | 
						|
        app.format("%06ld", _numrec_pcon);
 | 
						|
        _control_rec.overwrite(app,((i * 6) + 47));
 | 
						|
      }        
 | 
						|
      break;
 | 
						|
      
 | 
						|
    case 'Z':
 | 
						|
      {
 | 
						|
        TString app;
 | 
						|
        app.format("%06ld", _numrec_pn);
 | 
						|
        _control_rec.overwrite(app,((i * 6) + 47));
 | 
						|
      }        
 | 
						|
      break;
 | 
						|
      
 | 
						|
    case 'U':
 | 
						|
      {
 | 
						|
        TString app;
 | 
						|
        app.format("%06ld", _numrec_iva);
 | 
						|
        _control_rec.overwrite(app,((i * 6) + 47));
 | 
						|
      }        
 | 
						|
      break;
 | 
						|
      
 | 
						|
    default:
 | 
						|
      break;
 | 
						|
    };             
 | 
						|
  }
 | 
						|
  _tras_file.write_control_rec(_control_rec,size);                      
 | 
						|
  _tras_file.close();
 | 
						|
}
 | 
						|
 | 
						|
bool TInv_cont::invio_tab_cau()
 | 
						|
{                      
 | 
						|
  int size = 256;
 | 
						|
  TString record(size);
 | 
						|
  TString cod;
 | 
						|
  
 | 
						|
  long cicli = _tcaus->items();
 | 
						|
  _prog = new TProgind(cicli,"Tabella Causali: generazione file TRASFER per Sistema\nPrego attendere.",FALSE);
 | 
						|
 | 
						|
  _tras_file.open(_trasf,TRUE);
 | 
						|
      
 | 
						|
  for (_tcaus->first(); !_tcaus->eof(); _tcaus->next())
 | 
						|
  { 
 | 
						|
    TString str;
 | 
						|
    
 | 
						|
    _prog->addstatus(1);
 | 
						|
    
 | 
						|
    record.spaces();                                                     
 | 
						|
    
 | 
						|
    const char* codcau = _tcaus->get(CAU_CODCAUS);
 | 
						|
    str.format("%03s", codcau);
 | 
						|
    record.overwrite("W1",0);                    //Tipo record
 | 
						|
    record.overwrite(str,2);                     //Codice causale
 | 
						|
    
 | 
						|
    TString descr = _tcaus->get(CAU_DESCR);
 | 
						|
    descr.format("%-.20s", (const char*) descr); 
 | 
						|
    record.overwrite(descr,15);                  //Descrizione
 | 
						|
    
 | 
						|
    TString tipodoc = _tcaus->get(CAU_TIPODOC);
 | 
						|
    record.overwrite(tipodoc,35);                //Tipo documento
 | 
						|
    
 | 
						|
    TString reg = _tcaus->get(CAU_REG); 
 | 
						|
    if (real::is_natural(reg))
 | 
						|
    {
 | 
						|
      int app = atoi(reg);
 | 
						|
      reg.format("%d", app);
 | 
						|
    }
 | 
						|
    record.overwrite(reg,37);                    //Registro IVA
 | 
						|
    
 | 
						|
    bool alleg = _tcaus->get_bool(CAU_ALLEG);
 | 
						|
    if (alleg)
 | 
						|
      record.overwrite("X",38);
 | 
						|
    else                                         //Flag esclusione tipo documento da allegato
 | 
						|
      record.overwrite(" ",38);
 | 
						|
    
 | 
						|
    int m770 = atoi(_tcaus->get(CAU_M770));
 | 
						|
    str = format("%1d", m770);  
 | 
						|
    record.overwrite(str,39);                    //Collegamento modello 770
 | 
						|
    
 | 
						|
    TString cespiti = _tcaus->get(CAU_COLLCESP);
 | 
						|
    record.overwrite(cespiti,40);                //Collegamento cespiti
 | 
						|
    
 | 
						|
    bool numdoc = _tcaus->get_bool(CAU_NUMDOC);
 | 
						|
    if (numdoc)
 | 
						|
      record.overwrite("1",206);
 | 
						|
    else                                         //Flag immissione numero documento
 | 
						|
      record.overwrite("0",206);
 | 
						|
    
 | 
						|
    bool datadoc = _tcaus->get_bool(CAU_DATADOC);
 | 
						|
    if (datadoc)
 | 
						|
      record.overwrite("1",207);
 | 
						|
    else                                         //Flag immissione data documento
 | 
						|
      record.overwrite("0",207);                                                 
 | 
						|
    
 | 
						|
    const char* codcausim = _tcaus->get(CAU_CODCAUSIM);
 | 
						|
    str.format("%03s", codcausim);
 | 
						|
    record.overwrite(str,209);                   //Codice causale per incasso immediato
 | 
						|
    
 | 
						|
    bool intracom = _tcaus->get_bool(CAU_INTRACOM);
 | 
						|
    if (intracom)
 | 
						|
      record.overwrite("X",246);
 | 
						|
    else                                         //Flag per operazioni intracomunitarie
 | 
						|
      record.overwrite(" ",246);                                                       
 | 
						|
    
 | 
						|
    bool valintra = _tcaus->get_bool(CAU_VALINTRA);
 | 
						|
    if (valintra)
 | 
						|
      record.overwrite("X",247);
 | 
						|
    else                                         //Gestione valuta per oper. intracomunitarie
 | 
						|
      record.overwrite(" ",247);                                                             
 | 
						|
    
 | 
						|
    bool ritfatt = _tcaus->get_bool(CAU_RITFATT);
 | 
						|
    if (ritfatt)
 | 
						|
      record.overwrite("X",248);
 | 
						|
    else                                         //Flag causale per fattura ricevuta in ritardo
 | 
						|
      record.overwrite(" ",248);                                                               
 | 
						|
    
 | 
						|
    bool autofatt = _tcaus->get_bool(CAU_AUTOFATT);
 | 
						|
    if (autofatt)
 | 
						|
      record.overwrite("X",249);
 | 
						|
    else                                         //Autofattura art.34
 | 
						|
      record.overwrite(" ",249);  
 | 
						|
 | 
						|
    
 | 
						|
    int num = 0;    
 | 
						|
    int pos_gcs = 41;
 | 
						|
    int pos_sez = 191;
 | 
						|
    _codcaus = _tcaus->get(CAU_CODCAUS);
 | 
						|
    
 | 
						|
    do
 | 
						|
    {
 | 
						|
      num++;
 | 
						|
      
 | 
						|
      _trcaus->setkey(1);
 | 
						|
      _trcaus->zero();
 | 
						|
      _trcaus->put(RCA_CODCAUS, _codcaus);
 | 
						|
      _trcaus->put(RCA_NRIGA,   num);
 | 
						|
 | 
						|
      if (_trcaus->read() == NOERR)
 | 
						|
      {
 | 
						|
        int     g   = _trcaus->get_int (RCA_GRUPPO);
 | 
						|
        int     c   = _trcaus->get_int (RCA_CONTO);  
 | 
						|
        long    s   = _trcaus->get_long(RCA_SOTTOCONTO);
 | 
						|
        TString sez = _trcaus->get     (RCA_SEZIONE);
 | 
						|
 | 
						|
        str = format("%02d", g);
 | 
						|
        record.overwrite(str,pos_gcs);      //Gruppo
 | 
						|
        pos_gcs += 2;
 | 
						|
        str = format("%02d", c);
 | 
						|
        record.overwrite(str,pos_gcs);      //Conto
 | 
						|
        pos_gcs += 2;
 | 
						|
        str = format("%06ld", s);
 | 
						|
        record.overwrite(str,pos_gcs);      //Sottoconto
 | 
						|
        pos_gcs += 6;
 | 
						|
        
 | 
						|
        record.overwrite(sez,pos_sez);      //Sezione
 | 
						|
        pos_sez++;
 | 
						|
      }
 | 
						|
      else
 | 
						|
      {
 | 
						|
        int     g   = 0;
 | 
						|
        int     c   = 0;
 | 
						|
        long    s   = 0;
 | 
						|
        TString sez = " ";
 | 
						|
 | 
						|
        str = format("%02d", g);
 | 
						|
        record.overwrite(str,pos_gcs);      //Gruppo
 | 
						|
        pos_gcs += 2;
 | 
						|
        str = format("%02d", c);
 | 
						|
        record.overwrite(str,pos_gcs);      //Conto
 | 
						|
        pos_gcs += 2;
 | 
						|
        str = format("%06ld", s);
 | 
						|
        record.overwrite(str,pos_gcs);      //Sottoconto
 | 
						|
        pos_gcs += 6;
 | 
						|
        
 | 
						|
        record.overwrite(sez,pos_sez);      //Sezione
 | 
						|
        pos_sez++;        
 | 
						|
      }           
 | 
						|
    }
 | 
						|
    while (num < 15);
 | 
						|
    
 | 
						|
    _numrec_cau++;            
 | 
						|
 | 
						|
    _tras_file.write_control_rec(record,size);
 | 
						|
  } 
 | 
						|
  delete _prog;                               
 | 
						|
  
 | 
						|
  _tras_file.close();  
 | 
						|
  
 | 
						|
  return TRUE;
 | 
						|
}
 | 
						|
 | 
						|
void TInv_cont::scrivi_telefono(TString& appoggio)
 | 
						|
{ 
 | 
						|
  TString ptel;
 | 
						|
  TString tel;
 | 
						|
  
 | 
						|
  if (_tclifo->get(CLI_TEL).not_empty())
 | 
						|
  {
 | 
						|
    ptel = _tclifo->get(CLI_PTEL);
 | 
						|
    tel  = _tclifo->get(CLI_TEL);
 | 
						|
  }
 | 
						|
  else
 | 
						|
    if (_tclifo->get(CLI_TEL2).not_empty())
 | 
						|
    {
 | 
						|
      ptel = _tclifo->get(CLI_PTEL2);
 | 
						|
      tel  = _tclifo->get(CLI_TEL2);
 | 
						|
    }
 | 
						|
    else
 | 
						|
      if (_tclifo->get(CLI_TEL3).not_empty())
 | 
						|
      {
 | 
						|
        ptel = _tclifo->get(CLI_PTEL3);
 | 
						|
        tel  = _tclifo->get(CLI_TEL3);
 | 
						|
      }
 | 
						|
    
 | 
						|
  if (real::is_natural(ptel))
 | 
						|
  {
 | 
						|
    appoggio << ptel;
 | 
						|
    if (ptel.not_empty())
 | 
						|
      appoggio << "/" << tel;
 | 
						|
    else
 | 
						|
      appoggio << tel;
 | 
						|
  }
 | 
						|
  else
 | 
						|
    appoggio << tel;
 | 
						|
}
 | 
						|
 | 
						|
bool TInv_cont::invio_clifo()
 | 
						|
{
 | 
						|
  int size = 256;
 | 
						|
  TString record(size);
 | 
						|
 | 
						|
  long cicli = _tclifo->items();
 | 
						|
  _prog = new TProgind(cicli,"Anagrafica Clienti/Fornitori: generazione file TRASFER per Sistema\nPrego attendere.",FALSE);
 | 
						|
 | 
						|
  _tras_file.open(_trasf,TRUE);      
 | 
						|
  
 | 
						|
  for (_tclifo->first(); !_tclifo->eof(); _tclifo->next())
 | 
						|
  { 
 | 
						|
    TString str;
 | 
						|
    
 | 
						|
    _prog->addstatus(1);
 | 
						|
    
 | 
						|
    record.spaces();                                                     
 | 
						|
    
 | 
						|
    // Il tipocf su PC e'      C = cliente  F = fornitore.
 | 
						|
    // Il tipocf su AS400 e'   1 = cliente  2 = fornitore.
 | 
						|
    TString  tipo_cod;
 | 
						|
    
 | 
						|
    char tipo = _tclifo->get_char(CLI_TIPOCF);
 | 
						|
    if (tipo == 'C')
 | 
						|
      tipo_cod = "1";
 | 
						|
    else             
 | 
						|
      if (tipo == 'F')
 | 
						|
        tipo_cod = "2";
 | 
						|
 | 
						|
    record.overwrite("A1",0);                    //Tipo record
 | 
						|
    record.overwrite(tipo_cod,2);                //Tipo cliente/fornitore
 | 
						|
    
 | 
						|
    long codice = _tclifo->get_long(CLI_CODCF);
 | 
						|
    str.format("%06ld", codice);
 | 
						|
    record.overwrite(str,3);                     //Codice cliente/fornitore
 | 
						|
    
 | 
						|
    //Il tipo persona su PC e'     F = fisica     G = giuridica
 | 
						|
    //Il tipo persona su AS400 e'  0 = giuridica  1 = fisica
 | 
						|
    char tipop = _tclifo->get_char(CLI_TIPOPERS);
 | 
						|
    TString tipopers;
 | 
						|
    
 | 
						|
    if (tipop == 'F')
 | 
						|
      tipopers = "1";
 | 
						|
    else
 | 
						|
      if (tipop == 'G')
 | 
						|
        tipopers = "0";
 | 
						|
    
 | 
						|
    record.overwrite(tipopers,15);               //Tipo persona
 | 
						|
    
 | 
						|
    TString ragsoc = _tclifo->get(CLI_RAGSOC);
 | 
						|
    TString cognome = ragsoc.mid(0,30);
 | 
						|
    TString nome    = ragsoc.mid(30,20);
 | 
						|
    str.format("%-30s", (const char*) cognome);  //Cognome o I ragione sociale
 | 
						|
    record.overwrite(str,16);
 | 
						|
    str.format("%-20s", (const char*) nome);
 | 
						|
    record.overwrite(str,46);                    //Nome o II ragione sociale
 | 
						|
    
 | 
						|
    TString paiv = _tclifo->get(CLI_PAIV);
 | 
						|
    str.format("%011s", (const char*) paiv);
 | 
						|
    record.overwrite(str,66);                    //Partita IVA
 | 
						|
    
 | 
						|
    TString cofi = _tclifo->get(CLI_COFI);
 | 
						|
    str.format("%-16s", (const char*) cofi);
 | 
						|
    record.overwrite(str,77);                    //Codice fiscale
 | 
						|
    
 | 
						|
    TString indcf = _tclifo->get(CLI_INDCF);
 | 
						|
    TString civcf = _tclifo->get(CLI_CIVCF);
 | 
						|
    int lind = indcf.len();
 | 
						|
    int lciv = civcf.len();
 | 
						|
    int totlen = lind + lciv + 1;
 | 
						|
    if (totlen < 36)
 | 
						|
      indcf << " " << civcf;
 | 
						|
 | 
						|
    str.format("%-35s", (const char*) indcf);
 | 
						|
    record.overwrite(str,93);                    //Indirizzo
 | 
						|
    
 | 
						|
    TString capcf = _tclifo->get(CLI_CAPCF);
 | 
						|
    str.format("%05s", (const char*) capcf);
 | 
						|
    record.overwrite(str,128);                 //Codice di avviamento postale
 | 
						|
    
 | 
						|
    TString localita = _tclifo->get(CLI_LOCCF);
 | 
						|
    str.format("%-.20s", (const char*) localita);
 | 
						|
    record.overwrite(str,133);                   //Localita'
 | 
						|
    
 | 
						|
    TString comcf = _tclifo->get(CLI_COMCF);  
 | 
						|
    TString provincia = "";
 | 
						|
    if (comcf.not_empty())
 | 
						|
      provincia = cerca_provincia(comcf);  
 | 
						|
    str.format("%-2s", (const char*) provincia);
 | 
						|
    record.overwrite(str,153);                   //Provincia
 | 
						|
    
 | 
						|
/*    TString ptel = _tclifo->get(CLI_PTEL);
 | 
						|
    TString tel  = _tclifo->get(CLI_TEL);
 | 
						|
    TString appoggio;
 | 
						|
    appoggio << ptel << " " << tel;   
 | 
						|
    record.overwrite(appoggio,155);
 | 
						|
*/  
 | 
						|
    TString appoggio = "";
 | 
						|
    scrivi_telefono(appoggio);
 | 
						|
    appoggio.format("%-12s", (const char*) appoggio);
 | 
						|
    appoggio.cut(12);
 | 
						|
    record.overwrite(appoggio,155);
 | 
						|
    
 | 
						|
    TString alleg = _tclifo->get(CLI_ALLEG);
 | 
						|
    record.overwrite(alleg,167);                 //Flag gestione allegato
 | 
						|
    
 | 
						|
    int gruppo = _tclifo->get_int(CLI_GRUPPORIC);
 | 
						|
    int conto  = _tclifo->get_int(CLI_CONTORIC);
 | 
						|
    long sottoc = _tclifo->get_long(CLI_SOTTOCRIC);
 | 
						|
    str.format("%02d", gruppo);
 | 
						|
    record.overwrite(str,168);                   //Gruppo di costo/ricavo
 | 
						|
    str.format("%02d", conto);
 | 
						|
    record.overwrite(str,170);                   //Conto di costo/ricavo
 | 
						|
    str.format("%06ld", sottoc);
 | 
						|
    record.overwrite(str,172);                   //sottoconto di costo/ricavo
 | 
						|
 | 
						|
    long codalleg = _tclifo->get_long(CLI_CODALLEG);
 | 
						|
    str.format("%06ld", codalleg);
 | 
						|
    record.overwrite(str,179);
 | 
						|
    
 | 
						|
    TString codpag = _tclifo->get(CLI_CODPAG);
 | 
						|
    str.format("%-2s", (const char*) codpag);
 | 
						|
 | 
						|
    _numrec_clifo++;            
 | 
						|
 | 
						|
    _tras_file.write_control_rec(record,size);
 | 
						|
  } 
 | 
						|
  delete _prog;  
 | 
						|
 | 
						|
  _tras_file.close();  
 | 
						|
  
 | 
						|
  return TRUE;
 | 
						|
}
 | 
						|
 | 
						|
bool TInv_cont::invio_pcon()
 | 
						|
{
 | 
						|
  int size = 256;
 | 
						|
  TString record(size);
 | 
						|
 | 
						|
  long cicli = _tpcon->items();
 | 
						|
  _prog = new TProgind(cicli,"Anagrafica Piano Conti: generazione file TRASFER per Sistema\nPrego attendere.",FALSE);
 | 
						|
 | 
						|
  _tras_file.open(_trasf,TRUE);
 | 
						|
      
 | 
						|
  for (_tpcon->first(); !_tpcon->eof(); _tpcon->next())
 | 
						|
  { 
 | 
						|
    TString str;
 | 
						|
    
 | 
						|
    _prog->addstatus(1);
 | 
						|
        
 | 
						|
    record.spaces();                                                     
 | 
						|
    
 | 
						|
    int  g = _tpcon->get_int (PCN_GRUPPO); 
 | 
						|
    int  c = _tpcon->get_int (PCN_CONTO);
 | 
						|
    long s = _tpcon->get_long(PCN_SOTTOCONTO);
 | 
						|
 | 
						|
    // Se si tratta di un GRUPPO 
 | 
						|
 | 
						|
    if (g != 0 && c == 0 && s == 0)
 | 
						|
    {                                                
 | 
						|
      record.overwrite("P1",0);                  //Tipo record
 | 
						|
      str.format("%02d", g);
 | 
						|
      record.overwrite(str,2);                   //Gruppo
 | 
						|
      
 | 
						|
      TString descr (_tpcon->get(PCN_DESCR));
 | 
						|
      str.format("%-.30s", (const char*) descr);
 | 
						|
      record.overwrite(str,15);                  //Descrizione gruppo
 | 
						|
    }
 | 
						|
    
 | 
						|
    // Se si tratta di un CONTO
 | 
						|
 | 
						|
    if (g != 0 && c != 0 && s == 0)
 | 
						|
    {
 | 
						|
      record.overwrite("P2",0);                  //Tipo record
 | 
						|
      str.format("%02d", g);
 | 
						|
      record.overwrite(str,2);                   //Gruppo
 | 
						|
      
 | 
						|
      str.format("%02d", c);
 | 
						|
      record.overwrite(str,4);                   //Conto
 | 
						|
      
 | 
						|
      TString descr (_tpcon->get(PCN_DESCR));
 | 
						|
      str.format("%-.30s", (const char*) descr);
 | 
						|
      record.overwrite(str,15);                  //Descrizione conto
 | 
						|
      
 | 
						|
      int indbil = _tpcon->get_int(PCN_INDBIL);
 | 
						|
      str.format("%d", indbil);
 | 
						|
      record.overwrite(str,45);                  //Indicatore di bilancio
 | 
						|
      
 | 
						|
      TString tmcf = _tpcon->get(PCN_TMCF);
 | 
						|
      record.overwrite(tmcf,46);                 //Flag conto cliente/fornitore
 | 
						|
      
 | 
						|
      bool stsottbil = _tpcon->get_bool(PCN_STSOTTBIL);
 | 
						|
      if (stsottbil)
 | 
						|
        str = "1";
 | 
						|
      else
 | 
						|
        str = "0";
 | 
						|
      record.overwrite(str,47);                  //Flag stampa dettaglio sottoconti su bilancio
 | 
						|
 | 
						|
      // Classe IV direttiva CEE
 | 
						|
      
 | 
						|
      TString sez = _tpcon->get(PCN_SEZIVD);
 | 
						|
      if (sez == "0")
 | 
						|
        sez = " ";
 | 
						|
      record.overwrite(sez,48);                  //Sezione IV dir
 | 
						|
      
 | 
						|
      TString let = _tpcon->get(PCN_LETTIVD);
 | 
						|
      record.overwrite(let,49);                  //Lettera IV dir
 | 
						|
      
 | 
						|
      int numrom = atoi(_tpcon->get(PCN_NUMRIVD));
 | 
						|
      str.format("%03d", numrom);
 | 
						|
      record.overwrite(str,60);                  //Numero arabo corrispondente al numero romano
 | 
						|
      TString numr = itor(numrom);
 | 
						|
      str.format("%-8s", (const char*) numr);
 | 
						|
      record.overwrite(str,50);                  //Numero romano IV dir
 | 
						|
      
 | 
						|
      int num = _tpcon->get_int(PCN_NUMIVD);
 | 
						|
      str.format("%02d", num);
 | 
						|
      record.overwrite(str,58);                  //Numero arabo IV dir
 | 
						|
 | 
						|
      // Classe IV direttiva CEE di segno opposto
 | 
						|
      
 | 
						|
      TString sezop = _tpcon->get(PCN_SEZIVDOPP);
 | 
						|
      if (sezop == "0")
 | 
						|
        sezop = " ";
 | 
						|
      record.overwrite(sezop,63);                //Sezione IV dir
 | 
						|
      
 | 
						|
      TString letop = _tpcon->get(PCN_LETTIVDOPP);
 | 
						|
      record.overwrite(letop,64);                //Lettera IV dir
 | 
						|
      
 | 
						|
      int numromop = atoi(_tpcon->get(PCN_NUMRIVDOPP));
 | 
						|
      str.format("%03d", numromop);
 | 
						|
      record.overwrite(str,75);                  //Numero arabo corrispondente al numero romano
 | 
						|
      TString numrop = itor(numromop);
 | 
						|
      str.format("%-8s", (const char*) numrop);
 | 
						|
      record.overwrite(str,65);                  //Numero romano IV dir
 | 
						|
      
 | 
						|
      int numop = _tpcon->get_int(PCN_NUMIVDOPP);
 | 
						|
      str.format("%02d", numop);
 | 
						|
      record.overwrite(str,73);                  //Numero arabo IV dir      
 | 
						|
    }
 | 
						|
    
 | 
						|
    // Se si tratta di un SOTTOCONTO
 | 
						|
 | 
						|
    if (g != 0 && c != 0 && s != 0)
 | 
						|
    {
 | 
						|
      record.overwrite("P3",0);                  //Tipo record
 | 
						|
      str.format("%02d", g);
 | 
						|
      record.overwrite(str,2);                   //Gruppo
 | 
						|
      
 | 
						|
      str.format("%02d", c);
 | 
						|
      record.overwrite(str,4);                   //Conto
 | 
						|
      
 | 
						|
      str.format("%06ld", s);
 | 
						|
      record.overwrite(str,6);                   //Sottoconto
 | 
						|
      
 | 
						|
      TString descr (_tpcon->get(PCN_DESCR));
 | 
						|
      str.format("%-.30s", (const char*) descr);
 | 
						|
      record.overwrite(str,15);                  //Descrizione sottoconto
 | 
						|
      
 | 
						|
      int tipospric = _tpcon->get_int(PCN_TIPOSPRIC);
 | 
						|
      str.format("%d", tipospric);
 | 
						|
      record.overwrite(str,45);                  //Tipo costo/ricavo
 | 
						|
      
 | 
						|
      int ricser = _tpcon->get_int(PCN_RICSER);
 | 
						|
      if (ricser == 0)
 | 
						|
        str = " ";
 | 
						|
      else
 | 
						|
        str.format("%d", ricser);                      
 | 
						|
      record.overwrite(str,46);                  //Tipo attivita'
 | 
						|
 | 
						|
      // Classe IV direttiva CEE
 | 
						|
      
 | 
						|
      TString sez = _tpcon->get(PCN_SEZIVD);
 | 
						|
      if (sez == "0")
 | 
						|
        sez = " ";
 | 
						|
      record.overwrite(sez,47);                  //Sezione IV dir
 | 
						|
      
 | 
						|
      TString let = _tpcon->get(PCN_LETTIVD);
 | 
						|
      record.overwrite(let,48);                  //Lettera IV dir
 | 
						|
      
 | 
						|
      int numrom = atoi(_tpcon->get(PCN_NUMRIVD));
 | 
						|
      str.format("%03d", numrom);
 | 
						|
      record.overwrite(str,59);                  //Numero arabo corrispondente al numero romano
 | 
						|
      TString numr = itor(numrom);
 | 
						|
      str.format("%-8s", (const char*) numr);
 | 
						|
      record.overwrite(str,49);                  //Numero romano IV dir
 | 
						|
      
 | 
						|
      int num = _tpcon->get_int(PCN_NUMIVD);
 | 
						|
      str.format("%02d", num);
 | 
						|
      record.overwrite(str,57);                  //Numero arabo IV dir
 | 
						|
 | 
						|
      // Classe IV direttiva CEE di segno opposto
 | 
						|
      
 | 
						|
      TString sezop = _tpcon->get(PCN_SEZIVDOPP);
 | 
						|
      if (sezop == "0")
 | 
						|
        sezop = " ";
 | 
						|
      record.overwrite(sezop,62);                //Sezione IV dir
 | 
						|
      
 | 
						|
      TString letop = _tpcon->get(PCN_LETTIVDOPP);
 | 
						|
      record.overwrite(letop,63);                //Lettera IV dir
 | 
						|
      
 | 
						|
      int numromop = atoi(_tpcon->get(PCN_NUMRIVDOPP));
 | 
						|
      str.format("%03d", numromop);
 | 
						|
      record.overwrite(str,74);                  //Numero arabo corrispondente al numero romano
 | 
						|
      TString numrop = itor(numromop);
 | 
						|
      str.format("%-8s", (const char*) numrop);
 | 
						|
      record.overwrite(str,64);                  //Numero romano IV dir
 | 
						|
      
 | 
						|
      int numop = _tpcon->get_int(PCN_NUMIVDOPP);
 | 
						|
      str.format("%02d", numop);
 | 
						|
      record.overwrite(str,72);                  //Numero arabo IV dir      
 | 
						|
    }
 | 
						|
 | 
						|
    _numrec_pcon++;            
 | 
						|
 | 
						|
    _tras_file.write_control_rec(record,size);
 | 
						|
  } 
 | 
						|
  delete _prog;      
 | 
						|
  
 | 
						|
  _tras_file.close();  
 | 
						|
  
 | 
						|
  return TRUE;
 | 
						|
}
 | 
						|
 | 
						|
void TInv_cont::testata_mov_PN()
 | 
						|
{
 | 
						|
  _annoes   = _tmov->get_int (MOV_ANNOES);
 | 
						|
  _datareg  = _tmov->get_date(MOV_DATAREG);   
 | 
						|
  _datadoc  = _tmov->get_date(MOV_DATADOC);
 | 
						|
  _numdoc   = _tmov->get     (MOV_NUMDOC);
 | 
						|
  _reg      = _tmov->get     (MOV_REG);
 | 
						|
  _codcausm = _tmov->get     (MOV_CODCAUS);
 | 
						|
  _codpag   = _tmov->get     (MOV_CODPAG);
 | 
						|
//  _tipodoc  = _tmov->get     (MOV_TIPODOC);
 | 
						|
  _protiva  = _tmov->get_long(MOV_PROTIVA);
 | 
						|
  _uprotiva = _tmov->get_long(MOV_UPROTIVA);
 | 
						|
  _inviato  = _tmov->get_bool(MOV_INVIATO);
 | 
						|
}
 | 
						|
                                               
 | 
						|
void TInv_cont::testata_trasfer(long nreg, int nrig, TString& record)
 | 
						|
{                                         
 | 
						|
  TString str;
 | 
						|
  
 | 
						|
  record.overwrite("Z1",0);                    //Tipo record
 | 
						|
    
 | 
						|
  str.format("%06ld", nreg);
 | 
						|
  record.overwrite(str,2);                     //Numero di registrazione
 | 
						|
    
 | 
						|
  str.format("%02d", nrig);
 | 
						|
  record.overwrite(str,8);                     //Numero di riga
 | 
						|
    
 | 
						|
  TString datastr = _datareg.string();
 | 
						|
  str = riconverti(datastr,FALSE); 
 | 
						|
  str.format("%06s", (const char*) str);
 | 
						|
  record.overwrite(str,15);                    //Data di registrazione
 | 
						|
 | 
						|
  //Determino il segnalino della competenza
 | 
						|
  int segnalino;
 | 
						|
 | 
						|
  int anno   = date2esc(_datareg);
 | 
						|
  if (_annoes == anno)
 | 
						|
    segnalino = 0;
 | 
						|
  else
 | 
						|
    segnalino = 1;
 | 
						|
  str.format("%d", segnalino);
 | 
						|
  record.overwrite(str,21);                    //Segnalino della competenza
 | 
						|
    
 | 
						|
  TString datadocstr = _datadoc.string();                    
 | 
						|
  str = riconverti(datadocstr,FALSE);
 | 
						|
  str.format("%06s", (const char*) str);
 | 
						|
  record.overwrite(str,22);                    //Data documento
 | 
						|
    
 | 
						|
  str.format("%-7s", (const char*) _numdoc);
 | 
						|
  record.overwrite(str,28);
 | 
						|
    
 | 
						|
  TString reg;
 | 
						|
  if (real::is_natural(_reg))
 | 
						|
  {
 | 
						|
    int app = atoi(_reg);
 | 
						|
    reg.format("%d", app);
 | 
						|
  }  
 | 
						|
  else
 | 
						|
    reg = _reg.trim();
 | 
						|
 | 
						|
  record.overwrite(reg,35);                   //Codice registro IVA
 | 
						|
    
 | 
						|
  str.format("%05d", _protiva);
 | 
						|
  record.overwrite(str,36);                    //Numero protocollo IVA
 | 
						|
    
 | 
						|
  const char* cod_causm = (const char*)_codcausm;
 | 
						|
  str.format("%03s", (const char*)_codcausm);
 | 
						|
  record.overwrite(str,41);                     //Codice causale
 | 
						|
      
 | 
						|
  str.format("%-2s", (const char*) _codpag);
 | 
						|
  record.overwrite(str,95);                     //Codice di pagamento
 | 
						|
      
 | 
						|
  str.format("%05d", _uprotiva);
 | 
						|
  record.overwrite(str,108);                   //Ultimo numero di protocollo IVA
 | 
						|
  
 | 
						|
  record.overwrite("0",218);                   //Flag di solo sezionale
 | 
						|
}
 | 
						|
 | 
						|
void TInv_cont::sola_iva(TString& record)
 | 
						|
{                                         
 | 
						|
  TString str;                                                            
 | 
						|
  TLocalisamfile rcaus (LF_RCAUSALI);
 | 
						|
  int  gruppo = 0;
 | 
						|
  int  conto  = 0;
 | 
						|
  long sottoc = 0;
 | 
						|
  
 | 
						|
  rcaus.setkey(1);
 | 
						|
  rcaus.zero();
 | 
						|
  rcaus.put(RCA_CODCAUS, _codcausm);
 | 
						|
  rcaus.read();
 | 
						|
  TString codcau = rcaus.get(RCA_CODCAUS);
 | 
						|
  if (codcau == _codcausm)
 | 
						|
  {
 | 
						|
    gruppo  = rcaus.get_int (RCA_GRUPPO);
 | 
						|
    conto   = rcaus.get_int (RCA_CONTO);
 | 
						|
    sottoc  = _tmov->get_long(MOV_CODCF);
 | 
						|
  }            
 | 
						|
  
 | 
						|
  str.format("%02d", gruppo);
 | 
						|
  record.overwrite(str,74);                     //Gruppo di partita
 | 
						|
  str.format("%02d", conto);
 | 
						|
  record.overwrite(str,76);                     //Conto di partita
 | 
						|
  str.format("%06ld", sottoc);
 | 
						|
  record.overwrite(str,78);                     //Sottoconto di partita  
 | 
						|
  
 | 
						|
  record.overwrite("0000000000",85);            //Sottoconto di contropartita
 | 
						|
  
 | 
						|
  record.overwrite("00000000000",97);           //Importo
 | 
						|
}
 | 
						|
 | 
						|
bool TInv_cont::invio_mov_PN()
 | 
						|
{
 | 
						|
  int     size = 256;
 | 
						|
  TString record(size);
 | 
						|
  bool    almeno_una_riga = FALSE;
 | 
						|
  
 | 
						|
  long cicli = _tmov->items();
 | 
						|
  _prog = new TProgind(cicli,"Movimenti di Prima nota: generazione file TRASFER per Sistema\nPrego attendere.",FALSE);
 | 
						|
 | 
						|
  _tras_file.open(_trasf,TRUE);
 | 
						|
   
 | 
						|
  for (_tmov->first(); !_tmov->eof(); _tmov->next())
 | 
						|
  { 
 | 
						|
    TString str;
 | 
						|
    
 | 
						|
    _prog->addstatus(1);      
 | 
						|
        
 | 
						|
    record.spaces();                                                     
 | 
						|
    
 | 
						|
    long nreg = _tmov->get_long(RMV_NUMREG);
 | 
						|
 | 
						|
    testata_mov_PN();
 | 
						|
                   
 | 
						|
    _trmov->setkey(1);               
 | 
						|
    _trmov->zero();   
 | 
						|
    _trmov->put(RMV_NUMREG, nreg);
 | 
						|
    TRectype trmov(LF_RMOV);
 | 
						|
    trmov = _trmov->curr();
 | 
						|
    
 | 
						|
    for (_trmov->read(); !_trmov->eof(); _trmov->next())
 | 
						|
    {                                     
 | 
						|
      if (_trmov->curr() > trmov) break;
 | 
						|
      
 | 
						|
      record = "";
 | 
						|
      record.spaces();
 | 
						|
      
 | 
						|
      almeno_una_riga = TRUE;
 | 
						|
      
 | 
						|
      int  nrig = _trmov->get_int (RMV_NUMRIG);        
 | 
						|
 | 
						|
      testata_trasfer(nreg,nrig,record);
 | 
						|
      
 | 
						|
      TString descr = _trmov->get(RMV_DESCR);
 | 
						|
      str.format("%-.30s", (const char*) descr);
 | 
						|
      record.overwrite(str,44);                     //Descrizione riga di movimento
 | 
						|
    
 | 
						|
      int gruppo = _trmov->get_int(RMV_GRUPPO);
 | 
						|
      str.format("%02d", gruppo);
 | 
						|
      record.overwrite(str,74);                     //Gruppo di partita
 | 
						|
    
 | 
						|
      int conto = _trmov->get_int(RMV_CONTO);
 | 
						|
      str.format("%02d", conto);
 | 
						|
      record.overwrite(str,76);                     //Conto di partita
 | 
						|
    
 | 
						|
      long sottoc = _trmov->get_long(RMV_SOTTOCONTO);
 | 
						|
      str.format("%06ld", sottoc);
 | 
						|
      record.overwrite(str,78);                     //Sottoconto di partita
 | 
						|
    
 | 
						|
      TString sez = _trmov->get(RMV_SEZIONE);
 | 
						|
      str.format("%s", (const char*) sez);
 | 
						|
      record.overwrite(str,84);                     //Sezione importo
 | 
						|
    
 | 
						|
      int gruppoc = _trmov->get_int(RMV_GRUPPOC);
 | 
						|
      str.format("%02d", gruppoc);
 | 
						|
      record.overwrite(str,85);                     //Gruppo di contropartita
 | 
						|
    
 | 
						|
      int contoc = _trmov->get_int(RMV_CONTOC);
 | 
						|
      str.format("%02d", contoc);
 | 
						|
      record.overwrite(str,87);                     //Conto di contropartita
 | 
						|
    
 | 
						|
      long sottocc = _trmov->get_long(RMV_SOTTOCONTOC);
 | 
						|
      str.format("%06ld", sottocc);
 | 
						|
      record.overwrite(str,89);                     //Sottoconto di contropartita
 | 
						|
    
 | 
						|
      real importo (_trmov->get_real(RMV_IMPORTO));
 | 
						|
      TString numero = importo.string();
 | 
						|
      if (importo.sign() < 0)
 | 
						|
        negPC2negAS(numero);
 | 
						|
      str.format("%011s", (const char*) numero);
 | 
						|
      record.overwrite(str,97);                     //Importo riga di movimento
 | 
						|
    
 | 
						|
//      TString tipoc = _trmov->get(RMV_TIPOC);
 | 
						|
//      record.overwrite(tipoc,219);                  //Flag cliente/fornitore
 | 
						|
 | 
						|
      _tras_file.write_control_rec(record,size);         
 | 
						|
      _numrec_pn++;            
 | 
						|
    }
 | 
						|
 | 
						|
    if (!almeno_una_riga)
 | 
						|
    {
 | 
						|
      int nrig = 1;
 | 
						|
      testata_trasfer(nreg,nrig,record);
 | 
						|
      sola_iva(record);
 | 
						|
      _numrec_pn++;
 | 
						|
      _tras_file.write_control_rec(record,size);          
 | 
						|
    }
 | 
						|
    else
 | 
						|
      almeno_una_riga = FALSE;
 | 
						|
  } 
 | 
						|
  delete _prog;  
 | 
						|
 | 
						|
  _tras_file.close();                      
 | 
						|
  
 | 
						|
  return TRUE;
 | 
						|
}
 | 
						|
 | 
						|
bool TInv_cont::testata_mov_IVA(long numreg)
 | 
						|
{
 | 
						|
  _tmov->setkey(1);
 | 
						|
  _tmov->zero();
 | 
						|
  _tmov->put(MOV_NUMREG, numreg);
 | 
						|
  if (_tmov->read() == NOERR)
 | 
						|
  {
 | 
						|
    _codcf      = _tmov->get_long(MOV_CODCF);
 | 
						|
    _data74ter  = _tmov->get_date(MOV_DATA74TER);
 | 
						|
    _corrlire   = _tmov->get_real(MOV_CORRLIRE);
 | 
						|
    _codvali    = _tmov->get     (MOV_CODVALI);
 | 
						|
    _cambioi    = _tmov->get_real(MOV_CAMBIOI);
 | 
						|
    _corrval    = _tmov->get_real(MOV_CORRVALUTA);
 | 
						|
    _ocfpi      = _tmov->get     (MOV_OCFPI);
 | 
						|
    _dataregiva = _tmov->get_date(MOV_DATAREG);                            
 | 
						|
    _inviato    = _tmov->get_bool(MOV_INVIVA);
 | 
						|
    if (_ocfpi.not_empty())
 | 
						|
      cerca_occasionale();
 | 
						|
  }           
 | 
						|
  else
 | 
						|
    return FALSE;
 | 
						|
  
 | 
						|
  return TRUE;
 | 
						|
}
 | 
						|
 | 
						|
void TInv_cont::cerca_occasionale()
 | 
						|
{
 | 
						|
  _toccas->setkey(1);
 | 
						|
  _toccas->zero();
 | 
						|
  _toccas->put(OCC_CFPI, _ocfpi);
 | 
						|
  if (_toccas->read() == NOERR)
 | 
						|
  {
 | 
						|
    _ragsococc  = _toccas->get(OCC_RAGSOC);
 | 
						|
    _indocc     = _toccas->get(OCC_INDIR);
 | 
						|
    _capocc     = _toccas->get(OCC_CAP);
 | 
						|
    TString com = _toccas->get(OCC_COM);
 | 
						|
    cerca_comune_occas(com);
 | 
						|
  }                         
 | 
						|
  else
 | 
						|
  {
 | 
						|
    _ragsococc = "";
 | 
						|
    _indocc    = "";
 | 
						|
    _capocc    = "";
 | 
						|
    _localocc  = "";
 | 
						|
    _provocc   = "";
 | 
						|
  }
 | 
						|
}
 | 
						|
 | 
						|
void TInv_cont::cerca_comune_occas(const TString& com)
 | 
						|
{
 | 
						|
  TLocalisamfile comuni (LF_COMUNI);
 | 
						|
  
 | 
						|
  comuni.setkey(1);
 | 
						|
  comuni.zero();
 | 
						|
  comuni.put(COM_COM, com);
 | 
						|
  if (comuni.read() == NOERR)
 | 
						|
  {
 | 
						|
    _localocc = comuni.get(COM_DENCOM);
 | 
						|
    _provocc  = comuni.get(COM_PROVCOM);
 | 
						|
  }
 | 
						|
}                                       
 | 
						|
 | 
						|
bool TInv_cont::invio_mov_IVA()
 | 
						|
{
 | 
						|
  int size = 256;
 | 
						|
  TString record(size);
 | 
						|
  long nreg_p;
 | 
						|
  int  numero_righe = 0;
 | 
						|
  
 | 
						|
  nreg_p = -1;
 | 
						|
  
 | 
						|
  long cicli = _triva->items();
 | 
						|
  _prog = new TProgind(cicli,"Movimenti Iva: generazione file TRASFER per Sistema\nPrego attendere.",FALSE);
 | 
						|
                        
 | 
						|
  _tras_file.open(_trasf,TRUE);
 | 
						|
                        
 | 
						|
  for (_triva->first(); !_triva->eof(); _triva->next())
 | 
						|
  { 
 | 
						|
    TString str;
 | 
						|
    
 | 
						|
    _prog->addstatus(1);    
 | 
						|
        
 | 
						|
    record.spaces();                                                     
 | 
						|
    
 | 
						|
    long nreg = _triva->get_long(RMI_NUMREG);
 | 
						|
    int  nrig = _triva->get_int (RMI_NUMRIG);
 | 
						|
 | 
						|
    if (nreg != nreg_p) 
 | 
						|
    { 
 | 
						|
      numero_righe = 0;
 | 
						|
      if (!testata_mov_IVA(nreg))
 | 
						|
        return error_box("Rilevata riga mancante di testata: impossibile proseguire. /n Registrazione %07d Riga %03d",nreg,nrig);
 | 
						|
    }
 | 
						|
    
 | 
						|
    record.overwrite("U1",0);                    //Tipo record
 | 
						|
    
 | 
						|
    str.format("%06ld", nreg);
 | 
						|
    record.overwrite(str,2);                     //Numero di registrazione
 | 
						|
    
 | 
						|
    str.format("%02d", nrig);
 | 
						|
    record.overwrite(str,8);                     //Numero di riga
 | 
						|
    
 | 
						|
    nreg_p = nreg;
 | 
						|
    
 | 
						|
    str.format("%06ld", _codcf);
 | 
						|
    record.overwrite(str,15);                    //Codice cliente/fornitore
 | 
						|
    
 | 
						|
    real imponibile (_triva->get_real(RMI_IMPONIBILE));
 | 
						|
    TString numero = imponibile.string();
 | 
						|
    if (imponibile.sign() < 0)
 | 
						|
      negPC2negAS(numero);
 | 
						|
    str.format("%011s", (const char*) numero);
 | 
						|
    record.overwrite(str,21);                    //Imponibile
 | 
						|
 | 
						|
    TString codiva (_triva->get(RMI_CODIVA));
 | 
						|
    str.format("%02s", (const char*) codiva);
 | 
						|
    record.overwrite(str,32);                    //Codice iva
 | 
						|
    
 | 
						|
    real imposta (_triva->get_real(RMI_IMPOSTA));
 | 
						|
    numero = imposta.string();
 | 
						|
    if (imposta.sign() < 0)
 | 
						|
      negPC2negAS(numero);
 | 
						|
    str.format("%09s", (const char*) numero);
 | 
						|
    record.overwrite(str,34);                    //Imposta
 | 
						|
    
 | 
						|
    int tipocr = _triva->get_int(RMI_TIPOCR);
 | 
						|
    str.format("%01d", tipocr);
 | 
						|
    record.overwrite(str,43);                    //Tipo costo/ricavo
 | 
						|
    
 | 
						|
    int tipodet = _triva->get_int(RMI_TIPODET);
 | 
						|
    str.format("%01d", tipodet);
 | 
						|
    record.overwrite(str,44);                    //Tipo detraibilita'
 | 
						|
    
 | 
						|
    int gruppo = _triva->get_int(RMI_GRUPPO);
 | 
						|
    str.format("%02d", gruppo);
 | 
						|
    record.overwrite(str,45);                    //Gruppo
 | 
						|
    
 | 
						|
    int conto = _triva->get_int(RMI_CONTO);
 | 
						|
    str.format("%02d", conto);
 | 
						|
    record.overwrite(str,47);                    //Conto
 | 
						|
    
 | 
						|
    long sottoc = _triva->get_long(RMI_SOTTOCONTO);
 | 
						|
    str.format("%06ld", sottoc);
 | 
						|
    record.overwrite(str,49);                    //Sottoconto
 | 
						|
    
 | 
						|
    TString data74terstr = _data74ter.string();
 | 
						|
    str = riconverti(data74terstr,FALSE); 
 | 
						|
    str.format("%06s", (const char*) str);
 | 
						|
    record.overwrite(str,55);                    //Data per registri 74 TER
 | 
						|
    
 | 
						|
    if (_ocfpi.not_empty())
 | 
						|
    {
 | 
						|
      str.format("%-.25s", (const char*) _ragsococc);
 | 
						|
      record.overwrite(str,61);                  //Ragione sociale cliente occasionale
 | 
						|
      
 | 
						|
      str.format("%-.22s", (const char*) _indocc);
 | 
						|
      record.overwrite(str,86);                  //indirizzo cliente occasionale
 | 
						|
      
 | 
						|
      str.format("%-.18s", (const char*) _localocc);
 | 
						|
      record.overwrite(str,108);                 //Localita cliente occasionale
 | 
						|
      
 | 
						|
      str.format("%05s", (const char*) _capocc);
 | 
						|
      record.overwrite(str,126);                 //Codice avviamento postale cliente occasionale
 | 
						|
      
 | 
						|
      str.format("%-.2s", (const char*) _provocc);
 | 
						|
      record.overwrite(str,131);                 //Provincia cliente occasionale
 | 
						|
    }
 | 
						|
 | 
						|
    int tipoatt = _triva->get_int(RMI_TIPOATT);
 | 
						|
    str.format("%01d", tipoatt);
 | 
						|
    record.overwrite(str,133);                   //Tipo attivita'
 | 
						|
    
 | 
						|
    bool intra = _triva->get_bool(RMI_INTRA);
 | 
						|
    if (intra)
 | 
						|
      record.overwrite("X",134);
 | 
						|
    else                                         
 | 
						|
      record.overwrite(" ",134);                  //Flag causale x acquisti intracomunitari
 | 
						|
 | 
						|
    TString corrlire = _corrlire.string();
 | 
						|
    if (_corrlire.sign() < 0)
 | 
						|
      negPC2negAS(corrlire);
 | 
						|
    str.format("%011s", (const char*) corrlire);
 | 
						|
    record.overwrite(str,135);                   //Corrispettivo in lire
 | 
						|
    
 | 
						|
    record.overwrite(_codvali,146);              //Codice valuta
 | 
						|
     
 | 
						|
    dec2integer(_cambioi,100000);                                          
 | 
						|
    TString cambioi = _cambioi.string();
 | 
						|
    if (_cambioi.sign() < 0)
 | 
						|
      negPC2negAS(cambioi);                                          
 | 
						|
    str.format("%011s", (const char*) cambioi);
 | 
						|
    record.overwrite(str,149);                   //Cambio
 | 
						|
    
 | 
						|
    dec2integer(_corrval,1000);                                         
 | 
						|
    TString corrval = _corrval.string();
 | 
						|
    if (_corrval.sign() < 0)
 | 
						|
      negPC2negAS(corrval);                                         
 | 
						|
    str.format("%014s", (const char*) corrval);
 | 
						|
    record.overwrite(str,160);                   //Corrispettivo in valuta
 | 
						|
 | 
						|
    _numrec_iva++;            
 | 
						|
 | 
						|
    _tras_file.write_control_rec(record,size);    
 | 
						|
    
 | 
						|
    iva_inviata(nreg);
 | 
						|
  } 
 | 
						|
  delete _prog;  
 | 
						|
 | 
						|
  _tras_file.close();
 | 
						|
  
 | 
						|
  return TRUE;
 | 
						|
}
 | 
						|
 | 
						|
void TInv_cont::negPC2negAS(TString& numero)
 | 
						|
{
 | 
						|
  numero.trim();
 | 
						|
  numero = numero.mid(1);            // Considero il numero senza il segno -
 | 
						|
  
 | 
						|
  int len   = numero.len();
 | 
						|
  int cifra = atoi(numero.mid(len -1 ,1)); // Considero l'ultima cifra
 | 
						|
  
 | 
						|
  char carattere = _tabella[cifra];
 | 
						|
  
 | 
						|
  numero = numero.mid(0,len -1);     // Considero il numero senza l'ultima cifra
 | 
						|
  numero << carattere;
 | 
						|
}                              
 | 
						|
 | 
						|
void TInv_cont::dec2integer(real& val, long dec)
 | 
						|
{        
 | 
						|
  val = val * dec;
 | 
						|
}
 |