cg1500.cpp e cg1600.cpp Migliorate le prestazioni del calcolo saldi e
saldacon.h spostato il TDecoder da saldacon.h a Tele Piu' 2 git-svn-id: svn://10.65.10.50/trunk@3947 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
		
							parent
							
								
									64abb304de
								
							
						
					
					
						commit
						3b583ef40e
					
				@ -1712,6 +1712,8 @@ bool CG1500_application::calcola(int g, int c, long s)
 | 
				
			|||||||
  TLocalisamfile rmov(LF_RMOV);
 | 
					  TLocalisamfile rmov(LF_RMOV);
 | 
				
			||||||
  TLocalisamfile mov(LF_MOV);
 | 
					  TLocalisamfile mov(LF_MOV);
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
 | 
					  TDecoder causali(LF_CAUSALI, CAU_CODCAUS, CAU_MOVAP);
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
  _mov_periodo_dare  = ZERO;
 | 
					  _mov_periodo_dare  = ZERO;
 | 
				
			||||||
  _mov_periodo_avere = ZERO;
 | 
					  _mov_periodo_avere = ZERO;
 | 
				
			||||||
  _prg_prec_dare     = ZERO;
 | 
					  _prg_prec_dare     = ZERO;
 | 
				
			||||||
@ -1729,21 +1731,20 @@ bool CG1500_application::calcola(int g, int c, long s)
 | 
				
			|||||||
    rmov.put(RMV_SOTTOCONTO,s);
 | 
					    rmov.put(RMV_SOTTOCONTO,s);
 | 
				
			||||||
  TRectype rec(rmov.curr());
 | 
					  TRectype rec(rmov.curr());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  rmov.read(_isgteq);     
 | 
					  for (int err = rmov.read(_isgteq); err != NOERR; err = rmov.next())
 | 
				
			||||||
  for ( ; !rmov.eof(); rmov.next())
 | 
					 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
    if (rmov.curr() != rec) break;
 | 
					    if (rmov.curr() != rec) 
 | 
				
			||||||
 | 
					      break;
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    annoe    = rmov.get_int(RMV_ANNOES);
 | 
					    annoe    = rmov.get_int(RMV_ANNOES);
 | 
				
			||||||
    data     = rmov.get_date(RMV_DATAREG);
 | 
					    data     = rmov.get_date(RMV_DATAREG);
 | 
				
			||||||
    num_reg  = rmov.get_long(RMV_NUMREG);
 | 
					    num_reg  = rmov.get_long(RMV_NUMREG);
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    mov.setkey(1);
 | 
					    mov.setkey(1);
 | 
				
			||||||
    mov.zero();
 | 
					 | 
				
			||||||
    mov.put(MOV_NUMREG, num_reg);
 | 
					    mov.put(MOV_NUMREG, num_reg);
 | 
				
			||||||
    mov.read();
 | 
					    if (mov.read() != NOERR)
 | 
				
			||||||
    if (mov.bad())
 | 
					 | 
				
			||||||
      mov.zero();
 | 
					      mov.zero();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    provvis = mov.get_char(MOV_PROVVIS);
 | 
					    provvis = mov.get_char(MOV_PROVVIS);
 | 
				
			||||||
    datacomp = mov.get_date(MOV_DATACOMP);
 | 
					    datacomp = mov.get_date(MOV_DATACOMP);
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
@ -1753,38 +1754,31 @@ bool CG1500_application::calcola(int g, int c, long s)
 | 
				
			|||||||
    if (_stampa_mov_prov == 3 && provvis == '\0') //bilancio dei soli provvisori                
 | 
					    if (_stampa_mov_prov == 3 && provvis == '\0') //bilancio dei soli provvisori                
 | 
				
			||||||
      continue; 
 | 
					      continue; 
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    TString codcaus(mov.get(MOV_CODCAUS));
 | 
					    const TString& codcaus = mov.get(MOV_CODCAUS);
 | 
				
			||||||
 | 
					    const char causap = causali.decode(codcaus)[0];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    //  if (codcaus.not_empty())
 | 
					    if (!_quadratura && causap == 'C')                        
 | 
				
			||||||
    //    if (codcaus == causale_chiusura()) 
 | 
					    {
 | 
				
			||||||
    //      continue;
 | 
					      // Si tratta di causale di chiusura:
 | 
				
			||||||
 | 
					      // Non e' richiesta la quadratura con il Libro Giornale (Modifica
 | 
				
			||||||
    //  Modifica del 03-03-95
 | 
					      // del 18-06-96 richiesta da Patrizia in seguito alla modifica dei SALDI)
 | 
				
			||||||
    
 | 
					      continue;
 | 
				
			||||||
    TCaus cau (codcaus);
 | 
					    }
 | 
				
			||||||
    
 | 
					 | 
				
			||||||
    if (codcaus.not_empty())
 | 
					 | 
				
			||||||
      if (cau.chiusura())  // Si tratta di causale di chiusura
 | 
					 | 
				
			||||||
        if (!_quadratura)  // Non e' richiesta la quadratura con il Libro Giornale (Modifica
 | 
					 | 
				
			||||||
        continue;          // del 18-06-96 richiesta da Patrizia in seguito alla modifica dei SALDI)
 | 
					 | 
				
			||||||
                           
 | 
					 | 
				
			||||||
    //la causale e' uguale a quella di chiusura
 | 
					 | 
				
			||||||
    //break;
 | 
					 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    sezione   = rmov.get_char(RMV_SEZIONE);
 | 
					    sezione   = rmov.get_char(RMV_SEZIONE);
 | 
				
			||||||
    importo   = rmov.get_real(RMV_IMPORTO);
 | 
					    importo   = rmov.get_real(RMV_IMPORTO);
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    if (_annoes == 0)
 | 
					    if (_annoes == 0)
 | 
				
			||||||
      data_reg = data;
 | 
					      data_reg = data;
 | 
				
			||||||
    else data_reg = datacomp;
 | 
					    else 
 | 
				
			||||||
 | 
					      data_reg = datacomp;
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    if (importo == 0)
 | 
					    if (importo == 0)
 | 
				
			||||||
      continue;
 | 
					      continue;
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    //calcolo i movimenti del periodo
 | 
					    //calcolo i movimenti del periodo
 | 
				
			||||||
    if ( data_reg >= _datada && data_reg <= _dataa)
 | 
					    if ( data_reg >= _datada && data_reg <= _dataa)
 | 
				
			||||||
      if ((cau.apertura() && _dataini != _datada) ||
 | 
					      if ((causap == 'A' && _dataini != _datada) || (causap != 'A'))
 | 
				
			||||||
          (!cau.apertura()))
 | 
					 | 
				
			||||||
      {
 | 
					      {
 | 
				
			||||||
        conto_mov = TRUE;
 | 
					        conto_mov = TRUE;
 | 
				
			||||||
        if (sezione == 'D')
 | 
					        if (sezione == 'D')
 | 
				
			||||||
@ -1796,7 +1790,8 @@ bool CG1500_application::calcola(int g, int c, long s)
 | 
				
			|||||||
    //il saldo inizio es. e' dato dall'importo dare - importo avere di quei movimenti che hanno causale == apertura e data reg >= data inizio es. e <= data limite sup.
 | 
					    //il saldo inizio es. e' dato dall'importo dare - importo avere di quei movimenti che hanno causale == apertura e data reg >= data inizio es. e <= data limite sup.
 | 
				
			||||||
    if (_datada == _dataini) //calcolo il saldo iniziale
 | 
					    if (_datada == _dataini) //calcolo il saldo iniziale
 | 
				
			||||||
    {      
 | 
					    {      
 | 
				
			||||||
      if (cau.apertura())
 | 
					      if (causap == 'A')
 | 
				
			||||||
 | 
					      {
 | 
				
			||||||
        if ( (data_reg >= _dataini) && (data_reg <= _dataa) )
 | 
					        if ( (data_reg >= _dataini) && (data_reg <= _dataa) )
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
          if (sezione == 'D')
 | 
					          if (sezione == 'D')
 | 
				
			||||||
@ -1806,6 +1801,7 @@ bool CG1500_application::calcola(int g, int c, long s)
 | 
				
			|||||||
          conto_mov = _mov_ap = TRUE;              
 | 
					          conto_mov = _mov_ap = TRUE;              
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
      }  
 | 
					      }  
 | 
				
			||||||
 | 
					    }     
 | 
				
			||||||
    else if (_datada > _dataini) //calcolo i progressivi precedenti
 | 
					    else if (_datada > _dataini) //calcolo i progressivi precedenti
 | 
				
			||||||
      if ( (data_reg >= _dataini) && (data_reg < _datada) )
 | 
					      if ( (data_reg >= _dataini) && (data_reg < _datada) )
 | 
				
			||||||
      {
 | 
					      {
 | 
				
			||||||
@ -2847,8 +2843,6 @@ void CG1500_application::postclose_print()
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
void CG1500_application::set_page(int file, int counter)
 | 
					void CG1500_application::set_page(int file, int counter)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  TString dep = "";
 | 
					 | 
				
			||||||
  
 | 
					 | 
				
			||||||
  if (_bilancio == 1) //stampa bilancio a sezioni contrapposte 
 | 
					  if (_bilancio == 1) //stampa bilancio a sezioni contrapposte 
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
    _i = 1;
 | 
					    _i = 1;
 | 
				
			||||||
@ -2857,7 +2851,7 @@ void CG1500_application::set_page(int file, int counter)
 | 
				
			|||||||
    { 
 | 
					    { 
 | 
				
			||||||
      set_row(_i++,"@29gATTIVITA'@94gPASSIVITA'");
 | 
					      set_row(_i++,"@29gATTIVITA'@94gPASSIVITA'");
 | 
				
			||||||
      set_row(_i++,"@29g---------@94g----------");
 | 
					      set_row(_i++,"@29g---------@94g----------");
 | 
				
			||||||
      set_row(_i++, (const char*)dep);
 | 
					      set_row(_i++, "");
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    controlla_conto(_eof1,_eof2); //stampo una riga vuota tra un gruppo e un conto altrimenti no
 | 
					    controlla_conto(_eof1,_eof2); //stampo una riga vuota tra un gruppo e un conto altrimenti no
 | 
				
			||||||
@ -2868,7 +2862,7 @@ void CG1500_application::set_page(int file, int counter)
 | 
				
			|||||||
        printer().formfeed();
 | 
					        printer().formfeed();
 | 
				
			||||||
        set_row(_i++,"@29gCOSTI@94gRICAVI");
 | 
					        set_row(_i++,"@29gCOSTI@94gRICAVI");
 | 
				
			||||||
        set_row(_i++,"@29g-----@94g------");
 | 
					        set_row(_i++,"@29g-----@94g------");
 | 
				
			||||||
        set_row(_i++, (const char*)dep);
 | 
					        set_row(_i++, "");
 | 
				
			||||||
        _salto_pagina = TRUE;
 | 
					        _salto_pagina = TRUE;
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
@ -2885,7 +2879,7 @@ void CG1500_application::set_page(int file, int counter)
 | 
				
			|||||||
            printer().formfeed();
 | 
					            printer().formfeed();
 | 
				
			||||||
            set_row(_i++,"@59gCONTI D'ORDINE");
 | 
					            set_row(_i++,"@59gCONTI D'ORDINE");
 | 
				
			||||||
            set_row(_i++,"@59g--------------");
 | 
					            set_row(_i++,"@59g--------------");
 | 
				
			||||||
            set_row(_i++, (const char*)dep);
 | 
					            set_row(_i++, "");
 | 
				
			||||||
            if (_eof5 && _eof6)
 | 
					            if (_eof5 && _eof6)
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
              _stampato = TRUE;
 | 
					              _stampato = TRUE;
 | 
				
			||||||
@ -2911,7 +2905,7 @@ void CG1500_application::set_page(int file, int counter)
 | 
				
			|||||||
  }
 | 
					  }
 | 
				
			||||||
  else //stampa bilancio di verifica
 | 
					  else //stampa bilancio di verifica
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
    TString udata = _ultima_data.string(brief,'/');
 | 
					    TString16 udata = _ultima_data.string(brief,'/');
 | 
				
			||||||
    char app; 
 | 
					    char app; 
 | 
				
			||||||
    int r = 1;
 | 
					    int r = 1;
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
@ -3072,16 +3066,15 @@ int CG1500_application::stampa_record_conto(int g,int c,const TString& d,
 | 
				
			|||||||
                                            const real& r1,const real& r2,const real& r3,const real& r4,const real& r5, 
 | 
					                                            const real& r1,const real& r2,const real& r3,const real& r4,const real& r5, 
 | 
				
			||||||
                                            const char app)
 | 
					                                            const char app)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  TString dep = "";  
 | 
					 | 
				
			||||||
  int r = 1;
 | 
					  int r = 1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (_stampa_width == 148)
 | 
					  if (_stampa_width == 148)
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
    set_row(r,"@49g!@82g!@115g!",(const char*)dep); //stampo una riga vuota
 | 
					    set_row(r,"@49g!@82g!@115g!"); //stampo una riga vuota
 | 
				
			||||||
    set_row(r,"@148g!",(const char*)dep);
 | 
					    set_row(r,"@148g!");
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  else
 | 
					  else
 | 
				
			||||||
    set_row(r,"@49g!@82g!@114g!",(const char*)dep); //stampo una riga vuota     
 | 
					    set_row(r,"@49g!@82g!@114g!"); //stampo una riga vuota     
 | 
				
			||||||
  r++;
 | 
					  r++;
 | 
				
			||||||
  if (_verifica == 2)
 | 
					  if (_verifica == 2)
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
@ -3151,19 +3144,19 @@ int CG1500_application::stampa_record_conto(int g,int c,const TString& d,
 | 
				
			|||||||
  }
 | 
					  }
 | 
				
			||||||
  if (_stampa_width == 148) 
 | 
					  if (_stampa_width == 148) 
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
    set_row(r,"@49g!@82g!@115g!",(const char*)dep);
 | 
					    set_row(r,"@49g!@82g!@115g!");
 | 
				
			||||||
    set_row(r,"@148g!",(const char*)dep);
 | 
					    set_row(r,"@148g!");
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  else   
 | 
					  else   
 | 
				
			||||||
    set_row(r,"@49g!@82g!@114g!",(const char*)dep);   
 | 
					    set_row(r,"@49g!@82g!@114g!");   
 | 
				
			||||||
  r++;
 | 
					  r++;
 | 
				
			||||||
  if (_stampa_width == 148)
 | 
					  if (_stampa_width == 148)
 | 
				
			||||||
  { 
 | 
					  { 
 | 
				
			||||||
    set_row(r,"@49g!@82g!@115g!",(const char*)dep);
 | 
					    set_row(r,"@49g!@82g!@115g!");
 | 
				
			||||||
    set_row(r,"@148g!",(const char*)dep);      
 | 
					    set_row(r,"@148g!");      
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  else
 | 
					  else
 | 
				
			||||||
    set_row(r,"@49g!@82g!@114g!",(const char*)dep);  
 | 
					    set_row(r,"@49g!@82g!@114g!");  
 | 
				
			||||||
  r++;
 | 
					  r++;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (app == 'D')
 | 
					  if (app == 'D')
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										154
									
								
								cg/cg3600.cpp
									
									
									
									
									
								
							
							
						
						
									
										154
									
								
								cg/cg3600.cpp
									
									
									
									
									
								
							@ -305,75 +305,6 @@ bool TList::remove(long index)
 | 
				
			|||||||
  return o != NULL;
 | 
					  return o != NULL;
 | 
				
			||||||
}   
 | 
					}   
 | 
				
			||||||
 | 
					
 | 
				
			||||||
///////////////////////////////////////////////////////////
 | 
					 | 
				
			||||||
// TDecoder
 | 
					 | 
				
			||||||
///////////////////////////////////////////////////////////
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
class TDecoder : private TAssoc_array
 | 
					 | 
				
			||||||
{ 
 | 
					 | 
				
			||||||
  TLocalisamfile* _file;
 | 
					 | 
				
			||||||
  TString _if, _of;
 | 
					 | 
				
			||||||
  
 | 
					 | 
				
			||||||
public:            
 | 
					 | 
				
			||||||
  const TString& decode(const char* code); 
 | 
					 | 
				
			||||||
  const TString& decode(long code);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  TDecoder(int num, const char* inf, const char* outf);
 | 
					 | 
				
			||||||
  TDecoder(const char* table, const char* outf = "S0");
 | 
					 | 
				
			||||||
  virtual ~TDecoder();
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
///////////////////////////////////////////////////////////
 | 
					 | 
				
			||||||
// TDecoder
 | 
					 | 
				
			||||||
///////////////////////////////////////////////////////////
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
TDecoder::TDecoder(int num, const char* inf, const char* outf)
 | 
					 | 
				
			||||||
        : _file(new TLocalisamfile(num)), _if(inf), _of(outf)
 | 
					 | 
				
			||||||
{ }        
 | 
					 | 
				
			||||||
 
 | 
					 | 
				
			||||||
TDecoder::TDecoder(const char* tab, const char* outf)
 | 
					 | 
				
			||||||
        : _file(new TTable(tab)), _if("CODTAB"), _of(outf)
 | 
					 | 
				
			||||||
{ }        
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
TDecoder::~TDecoder()
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
  delete _file;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
const TString& TDecoder::decode(const char* code)
 | 
					 | 
				
			||||||
{       
 | 
					 | 
				
			||||||
  if (code == NULL)
 | 
					 | 
				
			||||||
    code = "";
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
  TObject* obj = objptr(code);
 | 
					 | 
				
			||||||
  if (obj == NULL)
 | 
					 | 
				
			||||||
  {     
 | 
					 | 
				
			||||||
    int err = ~NOERR;
 | 
					 | 
				
			||||||
    if (*code)
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
      _file->setkey(1);
 | 
					 | 
				
			||||||
      _file->put(_if, code);
 | 
					 | 
				
			||||||
      err = _file->read();
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    if (err == NOERR)
 | 
					 | 
				
			||||||
      obj = new TString(_file->get(_of));     // Found
 | 
					 | 
				
			||||||
    else   
 | 
					 | 
				
			||||||
      obj = new TString(1);                   // Not found
 | 
					 | 
				
			||||||
    add(code, obj);
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
  const TString& s = (const TString&)*obj;
 | 
					 | 
				
			||||||
  return s;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
const TString& TDecoder::decode(long code)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
  TString16 c; 
 | 
					 | 
				
			||||||
  if (code > 0)
 | 
					 | 
				
			||||||
    c << code;
 | 
					 | 
				
			||||||
  return decode(c);
 | 
					 | 
				
			||||||
}  
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
///////////////////////////////////////////////////////////
 | 
					///////////////////////////////////////////////////////////
 | 
				
			||||||
// TBalance
 | 
					// TBalance
 | 
				
			||||||
///////////////////////////////////////////////////////////
 | 
					///////////////////////////////////////////////////////////
 | 
				
			||||||
@ -676,6 +607,8 @@ TMastrino::~TMastrino()
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
long TMastrino::succ(long rec, tipo_riga_mastrino tipo) const
 | 
					long TMastrino::succ(long rec, tipo_riga_mastrino tipo) const
 | 
				
			||||||
{ 
 | 
					{ 
 | 
				
			||||||
 | 
					  if (rec < 0) rec = -1;
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
  const long ul = items();
 | 
					  const long ul = items();
 | 
				
			||||||
  for (long i = rec+1; i < ul; i++)
 | 
					  for (long i = rec+1; i < ul; i++)
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
@ -687,6 +620,7 @@ long TMastrino::succ(long rec, tipo_riga_mastrino tipo) const
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
long TMastrino::pred(long rec, tipo_riga_mastrino tipo) const
 | 
					long TMastrino::pred(long rec, tipo_riga_mastrino tipo) const
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					  if (rec > items()) rec = items();
 | 
				
			||||||
  for (long i = rec-1; i >= 0; i--)
 | 
					  for (long i = rec-1; i >= 0; i--)
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
    if (row(i).tipo() == tipo)
 | 
					    if (row(i).tipo() == tipo)
 | 
				
			||||||
@ -780,6 +714,11 @@ void TMastrino::read(const TBill& conto,
 | 
				
			|||||||
  conto.put(rmov_rec);
 | 
					  conto.put(rmov_rec);
 | 
				
			||||||
  rmov_rec.put(RMV_DATAREG, min_data_reg);
 | 
					  rmov_rec.put(RMV_DATAREG, min_data_reg);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifdef DBG
 | 
				
			||||||
 | 
					  long num_rec = 0;                                    
 | 
				
			||||||
 | 
					  const clock_t clock_start = clock();
 | 
				
			||||||
 | 
					#endif  
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
  for (int err = rel().read(_isgteq); err == NOERR; err = rel().next())
 | 
					  for (int err = rel().read(_isgteq); err == NOERR; err = rel().next())
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
    // Controlla di non aver superato la data limite  
 | 
					    // Controlla di non aver superato la data limite  
 | 
				
			||||||
@ -792,14 +731,22 @@ void TMastrino::read(const TBill& conto,
 | 
				
			|||||||
    if (conto_corrente != conto)
 | 
					    if (conto_corrente != conto)
 | 
				
			||||||
      break;
 | 
					      break;
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    const long giorno = data_reg - min_data_reg + 1;
 | 
					#ifdef DBG
 | 
				
			||||||
    pi.setstatus(giorno);
 | 
					    num_rec++;
 | 
				
			||||||
 | 
					    if ((num_rec & 0x7F) == 0)
 | 
				
			||||||
 | 
					    {             
 | 
				
			||||||
 | 
					      TString80 msg;
 | 
				
			||||||
 | 
					      const long sec = (clock() - clock_start) / CLOCKS_PER_SEC;
 | 
				
			||||||
 | 
					      msg.format("%ld records at %ld rec/sec", num_rec, num_rec / sec);
 | 
				
			||||||
 | 
					      pi.set_text(msg);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					#endif    
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    // Ignora i movimenti provvisori
 | 
					    // Ignora i movimenti provvisori
 | 
				
			||||||
    if (mov_rec.get_char(MOV_PROVVIS) > ' ')  
 | 
					    if (mov_rec.get_char(MOV_PROVVIS) > ' ')  
 | 
				
			||||||
      continue;
 | 
					      continue;
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    const TDate data_corrente(_esercizio <= 0 ? data_reg : mov_rec.get_date(MOV_DATADOC));
 | 
					    const TDate data_corrente(_esercizio <= 0 ? data_reg : mov_rec.get_date(MOV_DATACOMP));
 | 
				
			||||||
    if (data_corrente > _a_data)
 | 
					    if (data_corrente > _a_data)
 | 
				
			||||||
      continue;
 | 
					      continue;
 | 
				
			||||||
                     
 | 
					                     
 | 
				
			||||||
@ -835,6 +782,9 @@ void TMastrino::read(const TBill& conto,
 | 
				
			|||||||
        _riga.append(r);
 | 
					        _riga.append(r);
 | 
				
			||||||
      }  
 | 
					      }  
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    const long giorno = data_reg - min_data_reg + 1;
 | 
				
			||||||
 | 
					    pi.setstatus(giorno);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
  pi.setstatus(num_giorni);    // Raramente arriva in fondo!
 | 
					  pi.setstatus(num_giorni);    // Raramente arriva in fondo!
 | 
				
			||||||
@ -1082,6 +1032,9 @@ TGrid_control::TGrid_control(
 | 
				
			|||||||
  {
 | 
					  {
 | 
				
			||||||
    switch(*f)
 | 
					    switch(*f)
 | 
				
			||||||
    {       
 | 
					    {       
 | 
				
			||||||
 | 
					    case 'A':
 | 
				
			||||||
 | 
					      auto_num = TRUE;
 | 
				
			||||||
 | 
					      break;
 | 
				
			||||||
    case 'D': 
 | 
					    case 'D': 
 | 
				
			||||||
      _read_only = TRUE;
 | 
					      _read_only = TRUE;
 | 
				
			||||||
      break;
 | 
					      break;
 | 
				
			||||||
@ -1521,7 +1474,7 @@ bool TGrid_control::event_handler(XI_OBJ* itf, XI_EVENT *xiev)
 | 
				
			|||||||
        else
 | 
					        else
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
          if (cell.get_size() > 2)
 | 
					          if (cell.get_size() > 2)
 | 
				
			||||||
            cell.set(rec);
 | 
					            cell.set(rec+1);
 | 
				
			||||||
        }  
 | 
					        }  
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      else
 | 
					      else
 | 
				
			||||||
@ -1997,17 +1950,25 @@ void TMastrini_grid::cell_request(long rec, short id, TGrid_cell& cell)
 | 
				
			|||||||
    if (riga.tipo() == riga_mastrino)
 | 
					    if (riga.tipo() == riga_mastrino)
 | 
				
			||||||
    {                                  
 | 
					    {                                  
 | 
				
			||||||
      const TRectype& mov = _mastrino.testata(rec);
 | 
					      const TRectype& mov = _mastrino.testata(rec);
 | 
				
			||||||
      cell.set(mov.get(MOV_DESCR));
 | 
					      const TString& text = mov.get(MOV_DESCR);
 | 
				
			||||||
 | 
					      if (text.empty())
 | 
				
			||||||
 | 
					      {
 | 
				
			||||||
 | 
					        const TRectype& rmov = _mastrino.riga(rec);
 | 
				
			||||||
 | 
					        cell.set(rmov.get(RMV_DESCR));
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					      else
 | 
				
			||||||
 | 
					        cell.set(text);
 | 
				
			||||||
    }  
 | 
					    }  
 | 
				
			||||||
    else
 | 
					    else
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
      const TRectype& rmov = _mastrino.riga(rec);
 | 
					      const TRectype& rmov = _mastrino.riga(rec);
 | 
				
			||||||
      const char* text = rmov.get(RMV_DESCR);
 | 
					      const TString& text = rmov.get(RMV_DESCR);
 | 
				
			||||||
      if (*text == '\0')
 | 
					      if (text.empty())
 | 
				
			||||||
      {
 | 
					      {
 | 
				
			||||||
        const TBill conto(rmov);
 | 
					        const TBill conto(rmov);
 | 
				
			||||||
        text = conto.descrizione();
 | 
					        cell.set(conto.descrizione());
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
					      else
 | 
				
			||||||
        cell.set(text);
 | 
					        cell.set(text);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    break;  
 | 
					    break;  
 | 
				
			||||||
@ -2118,29 +2079,46 @@ void TMastrini_grid::on_dbl_cell(long rec, short id)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
void TMastrini_grid::on_grid_button()
 | 
					void TMastrini_grid::on_grid_button()
 | 
				
			||||||
{                           
 | 
					{                           
 | 
				
			||||||
 | 
					  const long total = _mastrino.items();                      
 | 
				
			||||||
 | 
					  if (total > 0)
 | 
				
			||||||
 | 
					  {
 | 
				
			||||||
 | 
					    TProgind* pi = NULL;
 | 
				
			||||||
 | 
					      
 | 
				
			||||||
 | 
					    if (total > 50)
 | 
				
			||||||
 | 
					      pi = new TProgind(total, "Calcolo contropartite", FALSE, TRUE, 48);
 | 
				
			||||||
 | 
					    else
 | 
				
			||||||
      begin_wait();  
 | 
					      begin_wait();  
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (items() > 0)
 | 
					    const long last_con = _mastrino.last(riga_contropartita);
 | 
				
			||||||
 | 
					    const bool expand = last_con < 0;
 | 
				
			||||||
 | 
					    if (expand)
 | 
				
			||||||
    { 
 | 
					    { 
 | 
				
			||||||
    long sample_rec = selected();
 | 
					      for (long n =  _mastrino.last(riga_mastrino); 
 | 
				
			||||||
    if (sample_rec < 0 || sample_rec >= items())
 | 
					           n >= 0; n = _mastrino.pred(n, riga_mastrino))
 | 
				
			||||||
      sample_rec = 0;
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
    if (_mastrino.expandable(sample_rec))
 | 
					 | 
				
			||||||
      {
 | 
					      {
 | 
				
			||||||
      for (long n = items()-1; n >= 0; n--)
 | 
					 | 
				
			||||||
        if (_mastrino.expandable(n))
 | 
					        if (_mastrino.expandable(n))
 | 
				
			||||||
          _mastrino.expand(n);
 | 
					          _mastrino.expand(n);
 | 
				
			||||||
 | 
					        if (pi)
 | 
				
			||||||
 | 
					          pi->setstatus(total - n);
 | 
				
			||||||
 | 
					      }       
 | 
				
			||||||
    }      
 | 
					    }      
 | 
				
			||||||
    else
 | 
					    else
 | 
				
			||||||
    {                                             
 | 
					    {                                             
 | 
				
			||||||
      for (long n = 0; n < _mastrino.items(); n++)
 | 
					      for (long n = last_con; n > 0; n = _mastrino.pred(n, riga_contropartita))
 | 
				
			||||||
        if (_mastrino[n].tipo() != riga_mastrino)
 | 
					      {
 | 
				
			||||||
          _mastrino.collapse(--n);
 | 
					        _mastrino.collapse(n);
 | 
				
			||||||
 | 
					        if (pi)
 | 
				
			||||||
 | 
					          pi->setstatus(total - n + 1);
 | 
				
			||||||
      }    
 | 
					      }    
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					      
 | 
				
			||||||
 | 
					    if (pi)
 | 
				
			||||||
 | 
					      delete pi;
 | 
				
			||||||
 | 
					    else
 | 
				
			||||||
 | 
					      end_wait();  
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    update();
 | 
					    update();
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  end_wait();
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void TMastrini_grid::on_record_button(long rec)
 | 
					void TMastrini_grid::on_record_button(long rec)
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										28
									
								
								cg/cglib.h
									
									
									
									
									
								
							
							
						
						
									
										28
									
								
								cg/cglib.h
									
									
									
									
									
								
							@ -31,6 +31,32 @@ public:
 | 
				
			|||||||
  ~TCaus() {}
 | 
					  ~TCaus() {}
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					///////////////////////////////////////////////////////////
 | 
				
			||||||
 | 
					// TDecoder
 | 
				
			||||||
 | 
					///////////////////////////////////////////////////////////
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class TDecoder : private TAssoc_array
 | 
				
			||||||
 | 
					{ 
 | 
				
			||||||
 | 
					  TLocalisamfile* _file;
 | 
				
			||||||
 | 
					  TString _if, _of;
 | 
				
			||||||
 | 
					  long _last_firm;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					protected:
 | 
				
			||||||
 | 
					  void init_firm();  
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
 | 
					public:            
 | 
				
			||||||
 | 
					  const TString& decode(const char* code); 
 | 
				
			||||||
 | 
					  const TString& decode(long code);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  TDecoder(int num, const char* inf, const char* outf);
 | 
				
			||||||
 | 
					  TDecoder(const char* table, const char* outf = "S0");
 | 
				
			||||||
 | 
					  virtual ~TDecoder();
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					///////////////////////////////////////////////////////////
 | 
				
			||||||
 | 
					// TSaldi_list
 | 
				
			||||||
 | 
					///////////////////////////////////////////////////////////
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class TSaldi_list : public TAssoc_array
 | 
					class TSaldi_list : public TAssoc_array
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
public:
 | 
					public:
 | 
				
			||||||
@ -63,6 +89,8 @@ class TSaldo
 | 
				
			|||||||
  bool      _rec_presente_ep;
 | 
					  bool      _rec_presente_ep;
 | 
				
			||||||
  bool      _prec;
 | 
					  bool      _prec;
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
 | 
					  TDecoder  _causali_apertura;
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
protected:
 | 
					protected:
 | 
				
			||||||
  void      InFinEs(int);
 | 
					  void      InFinEs(int);
 | 
				
			||||||
  bool      leggi_mov(long numreg);       // Leggi testata      
 | 
					  bool      leggi_mov(long numreg);       // Leggi testata      
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										136
									
								
								cg/cglib01.cpp
									
									
									
									
									
								
							
							
						
						
									
										136
									
								
								cg/cglib01.cpp
									
									
									
									
									
								
							@ -2,6 +2,8 @@
 | 
				
			|||||||
// calcolo dei saldi
 | 
					// calcolo dei saldi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <config.h>
 | 
					#include <config.h>
 | 
				
			||||||
 | 
					#include <xvtility.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <rmov.h>
 | 
					#include <rmov.h>
 | 
				
			||||||
#include <mov.h>
 | 
					#include <mov.h>
 | 
				
			||||||
#include <saldi.h> 
 | 
					#include <saldi.h> 
 | 
				
			||||||
@ -24,20 +26,23 @@ TCaus::TCaus(const char* cod) : _rec(LF_CAUSALI)
 | 
				
			|||||||
// Legge le righe della causale attualmente selezionata sulla maschera
 | 
					// Legge le righe della causale attualmente selezionata sulla maschera
 | 
				
			||||||
bool TCaus::read(const char* cod)
 | 
					bool TCaus::read(const char* cod)
 | 
				
			||||||
{ 
 | 
					{ 
 | 
				
			||||||
  TLocalisamfile caus(LF_CAUSALI);
 | 
					  bool ok = FALSE;
 | 
				
			||||||
  
 | 
					  if (cod && *cod)
 | 
				
			||||||
  _rec = caus.curr(); _rec.zero();                    // Delete header
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  if (*cod > ' ')
 | 
					 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
 | 
					    TLocalisamfile caus(LF_CAUSALI);
 | 
				
			||||||
    caus.setkey(1);
 | 
					    caus.setkey(1);
 | 
				
			||||||
    caus.put(CAU_CODCAUS, cod);
 | 
					    caus.put(CAU_CODCAUS, cod);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    int err = caus.read();
 | 
					    ok = caus.read() == NOERR;
 | 
				
			||||||
    if (err != NOERR) return FALSE;
 | 
					    if (ok) 
 | 
				
			||||||
      _rec = caus.curr();
 | 
					      _rec = caus.curr();
 | 
				
			||||||
 | 
					    else
 | 
				
			||||||
 | 
					      _rec.zero();
 | 
				
			||||||
  } 
 | 
					  } 
 | 
				
			||||||
  return TRUE;
 | 
					  else
 | 
				
			||||||
 | 
					    _rec.zero();
 | 
				
			||||||
 | 
					       
 | 
				
			||||||
 | 
					  return ok;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
bool TCaus::chiusura() const 
 | 
					bool TCaus::chiusura() const 
 | 
				
			||||||
@ -46,6 +51,11 @@ bool TCaus::chiusura() const
 | 
				
			|||||||
bool TCaus::apertura() const 
 | 
					bool TCaus::apertura() const 
 | 
				
			||||||
{ return _rec.get_char("MOVAP") == 'A'; }
 | 
					{ return _rec.get_char("MOVAP") == 'A'; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					///////////////////////////////////////////////////////////
 | 
				
			||||||
 | 
					// TSaldi_list
 | 
				
			||||||
 | 
					///////////////////////////////////////////////////////////
 | 
				
			||||||
 | 
					
 | 
				
			||||||
//  
 | 
					//  
 | 
				
			||||||
// Cerca l'esercizio precedente di EseCorr
 | 
					// Cerca l'esercizio precedente di EseCorr
 | 
				
			||||||
// Se EseCorr e' gia' il primo ritorna 0
 | 
					// Se EseCorr e' gia' il primo ritorna 0
 | 
				
			||||||
@ -103,10 +113,16 @@ TRectype* TSaldi_list::saldi() const
 | 
				
			|||||||
  return (TRectype*)o; 
 | 
					  return (TRectype*)o; 
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					///////////////////////////////////////////////////////////
 | 
				
			||||||
 | 
					// TSaldo
 | 
				
			||||||
 | 
					///////////////////////////////////////////////////////////
 | 
				
			||||||
 | 
					
 | 
				
			||||||
TSaldo::TSaldo() : _saldi(LF_SALDI), _saldoiniziale(ZERO), _saldo_iniziale(ZERO),
 | 
					TSaldo::TSaldo() : _saldi(LF_SALDI), _saldoiniziale(ZERO), _saldo_iniziale(ZERO),
 | 
				
			||||||
                   _prg_dare(ZERO), _prg_avere(ZERO), _saldo(ZERO), _annoes(0),
 | 
					                   _prg_dare(ZERO), _prg_avere(ZERO), _saldo(ZERO), _annoes(0),
 | 
				
			||||||
                   _indbil(0), _prec(FALSE), _movimentato(FALSE), _significativo(FALSE),
 | 
					                   _indbil(0), _prec(FALSE), _movimentato(FALSE), _significativo(FALSE),
 | 
				
			||||||
                   _rec_presente_ec(FALSE), _rec_presente_ep(FALSE)
 | 
					                   _rec_presente_ec(FALSE), _rec_presente_ep(FALSE),
 | 
				
			||||||
 | 
					                   _causali_apertura(LF_CAUSALI, CAU_CODCAUS, CAU_MOVAP)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
{}
 | 
					{}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
real TSaldo::saldofin_esprec(int annoes, int g, int c, long s, bool saldo_chiusura, bool mov_prec) 
 | 
					real TSaldo::saldofin_esprec(int annoes, int g, int c, long s, bool saldo_chiusura, bool mov_prec) 
 | 
				
			||||||
@ -196,19 +212,19 @@ const char* TSaldo::causale_apertura_es()
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
bool TSaldo::leggi_mov(long nr)
 | 
					bool TSaldo::leggi_mov(long nr)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  TLocalisamfile mov(LF_MOV, FALSE);
 | 
					  TLocalisamfile mov(LF_MOV);
 | 
				
			||||||
  bool ok = TRUE;
 | 
					//  mov.zero();
 | 
				
			||||||
  
 | 
					 | 
				
			||||||
  mov.zero();
 | 
					 | 
				
			||||||
  mov.put (MOV_NUMREG, nr);
 | 
					  mov.put (MOV_NUMREG, nr);
 | 
				
			||||||
 | 
					  const bool ok = mov.read() == NOERR;
 | 
				
			||||||
  if (ok = (mov.read() == NOERR))
 | 
					  if (ok)
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
    _codcaus  = mov.get(MOV_CODCAUS);
 | 
					    _codcaus  = mov.get(MOV_CODCAUS);
 | 
				
			||||||
    _datareg  = mov.get_date(MOV_DATAREG);
 | 
					    _datareg  = mov.get(MOV_DATAREG);
 | 
				
			||||||
    _provv    = mov.get     (MOV_PROVVIS);
 | 
					    _provv    = mov.get(MOV_PROVVIS); // _provv.trim();
 | 
				
			||||||
    _datacomp = mov.get_date(MOV_DATACOMP);
 | 
					    _datacomp = mov.get(MOV_DATACOMP);
 | 
				
			||||||
  } 
 | 
					  } 
 | 
				
			||||||
 | 
					  else
 | 
				
			||||||
 | 
					    NFCHECK("Testata assente: %ld", nr);
 | 
				
			||||||
  return ok; 
 | 
					  return ok; 
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -216,14 +232,7 @@ bool TSaldo::leggi_mov(long nr)
 | 
				
			|||||||
bool TSaldo::data_limite_bilancio(int bilancio, int g, int c, long s, const TDate& data_inf, 
 | 
					bool TSaldo::data_limite_bilancio(int bilancio, int g, int c, long s, const TDate& data_inf, 
 | 
				
			||||||
                                  const TDate& data_sup, int indbil, int stp_prov)
 | 
					                                  const TDate& data_sup, int indbil, int stp_prov)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  TString16 gcs_corr, gcs_prec;
 | 
					  TLocalisamfile rmov(LF_RMOV);
 | 
				
			||||||
  int       gruppo, conto, annoe;
 | 
					 | 
				
			||||||
  long      sottoconto, num_reg;
 | 
					 | 
				
			||||||
  real      importo;  
 | 
					 | 
				
			||||||
  TDate     data_mov;   
 | 
					 | 
				
			||||||
  char      sezione;
 | 
					 | 
				
			||||||
  
 | 
					 | 
				
			||||||
  TLocalisamfile rmov(LF_RMOV, FALSE);
 | 
					 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
  _saldo_iniziale  = ZERO;
 | 
					  _saldo_iniziale  = ZERO;
 | 
				
			||||||
  _saldo           = ZERO;
 | 
					  _saldo           = ZERO;
 | 
				
			||||||
@ -232,26 +241,43 @@ bool TSaldo::data_limite_bilancio(int bilancio, int g, int c, long s, const TDat
 | 
				
			|||||||
  _rec_presente_ec = FALSE; 
 | 
					  _rec_presente_ec = FALSE; 
 | 
				
			||||||
  _prec            = FALSE;
 | 
					  _prec            = FALSE;
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
  gcs_prec         = "";
 | 
					 | 
				
			||||||
  
 | 
					 | 
				
			||||||
  rmov.setkey(2);
 | 
					  rmov.setkey(2);
 | 
				
			||||||
  rmov.zero();
 | 
					  rmov.zero();
 | 
				
			||||||
  rmov.put(RMV_GRUPPO,g);
 | 
					  rmov.put(RMV_GRUPPO,g);
 | 
				
			||||||
  rmov.put(RMV_CONTO,c);
 | 
					  rmov.put(RMV_CONTO,c);
 | 
				
			||||||
  rmov.put(RMV_SOTTOCONTO,s);
 | 
					  rmov.put(RMV_SOTTOCONTO,s);
 | 
				
			||||||
  TRectype rec(rmov.curr());
 | 
					  
 | 
				
			||||||
 | 
					  // Anche se non movimentato vado a vedere il saldo 
 | 
				
			||||||
 | 
					  if (stp_prov != 3)
 | 
				
			||||||
 | 
					    _saldo = calcola_saldo_iniziale(g,c,s,indbil);  
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifdef DBG    
 | 
				
			||||||
 | 
					  long num_rec = 0;
 | 
				
			||||||
 | 
					  const clock_t clock_start = clock();  
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 
 | 
					 
 | 
				
			||||||
  for (rmov.read(_isgteq); !rmov.eof(); rmov.next())
 | 
					  for (rmov.read(_isgteq); !rmov.eof(); rmov.next())
 | 
				
			||||||
  {    
 | 
					  {    
 | 
				
			||||||
    if (rmov.curr() != rec) break;
 | 
					    const int  gruppo     = rmov.get_int(RMV_GRUPPO);
 | 
				
			||||||
 | 
					    const int  conto      = rmov.get_int(RMV_CONTO);
 | 
				
			||||||
 | 
					    const long sottoconto = rmov.get_long(RMV_SOTTOCONTO);
 | 
				
			||||||
 | 
					    if (gruppo != g || conto != c || sottoconto != s)
 | 
				
			||||||
 | 
					      break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    annoe      = rmov.get_int(RMV_ANNOES);
 | 
					#ifdef DBG    
 | 
				
			||||||
    gruppo     = rmov.get_int(RMV_GRUPPO);
 | 
					    num_rec++;
 | 
				
			||||||
    conto      = rmov.get_int(RMV_CONTO);
 | 
					    if ((num_rec & 0x7F) == 0)
 | 
				
			||||||
    sottoconto = rmov.get_long(RMV_SOTTOCONTO);
 | 
					    {               
 | 
				
			||||||
    num_reg    = rmov.get_long(RMV_NUMREG);
 | 
					      TString80 msg;
 | 
				
			||||||
    sezione    = rmov.get_char(RMV_SEZIONE);
 | 
					      const long sec = (clock() - clock_start) / CLOCKS_PER_SEC;
 | 
				
			||||||
    importo    = rmov.get_real(RMV_IMPORTO);
 | 
					      msg.format("%ld records at %ld rec/sec", num_rec, num_rec / sec);
 | 
				
			||||||
 | 
					      xvt_statbar_set(msg);
 | 
				
			||||||
 | 
					      do_events();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    const long num_reg    = rmov.get_long(RMV_NUMREG);
 | 
				
			||||||
 | 
					    TDate data_mov;
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    // Leggo la testata
 | 
					    // Leggo la testata
 | 
				
			||||||
    leggi_mov(num_reg);    
 | 
					    leggi_mov(num_reg);    
 | 
				
			||||||
@ -269,32 +295,29 @@ bool TSaldo::data_limite_bilancio(int bilancio, int g, int c, long s, const TDat
 | 
				
			|||||||
    if (data_mov < data_inf || data_mov > data_sup)
 | 
					    if (data_mov < data_inf || data_mov > data_sup)
 | 
				
			||||||
      continue;                         
 | 
					      continue;                         
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    // "Se la causale del movimento e' uguale a quella di chiusura, 
 | 
					    // "Se la causale del movimento e' di chiusura, 
 | 
				
			||||||
    //  o di apertura il movimento non va considerato"
 | 
					    //  o di apertura il movimento non va considerato"
 | 
				
			||||||
    TCaus cau(_codcaus); 
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
    if (_codcaus.not_empty())
 | 
					    if (_codcaus.not_empty())
 | 
				
			||||||
      if (cau.chiusura()) continue;                   
 | 
					    {
 | 
				
			||||||
 | 
					      const TString& movap = _causali_apertura.decode(_codcaus);
 | 
				
			||||||
 | 
					      if (movap == "C") 
 | 
				
			||||||
 | 
					        continue;                   
 | 
				
			||||||
 | 
					    }    
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    //bilancio normale (non comprende i provvisori) ?
 | 
					    //bilancio normale (non comprende i provvisori) ?
 | 
				
			||||||
    if (stp_prov == 1 && _provv.trim().not_empty()) 
 | 
					    if (stp_prov == 1 && _provv.not_empty()) 
 | 
				
			||||||
      continue;
 | 
					      continue;
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    //bilancio dei soli provvisori ?
 | 
					    //bilancio dei soli provvisori ?
 | 
				
			||||||
    if (stp_prov == 3 && _provv.trim().empty())     
 | 
					    if (stp_prov == 3 && _provv.empty())     
 | 
				
			||||||
      continue;                                             
 | 
					      continue;                                             
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
 | 
					    const char sezione    = rmov.get_char(RMV_SEZIONE);
 | 
				
			||||||
 | 
					    const real importo    = rmov.get(RMV_IMPORTO);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // I mov. di puro riferimento (= con importo = 0) vanno scartati
 | 
					    // I mov. di puro riferimento (= con importo = 0) vanno scartati
 | 
				
			||||||
    if (importo == ZERO) continue;
 | 
					    if (importo == ZERO) 
 | 
				
			||||||
    
 | 
					      continue;
 | 
				
			||||||
    gcs_corr.format ("%3d%3d%6ld", gruppo, conto, sottoconto);  
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
    if (gcs_corr != gcs_prec)  
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
      gcs_prec = gcs_corr;
 | 
					 | 
				
			||||||
      if (stp_prov != 3) //bilancio normale o globale 
 | 
					 | 
				
			||||||
        _saldo = calcola_saldo_iniziale(gruppo,conto,sottoconto,indbil);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    _movimentato = TRUE;
 | 
					    _movimentato = TRUE;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -304,10 +327,9 @@ bool TSaldo::data_limite_bilancio(int bilancio, int g, int c, long s, const TDat
 | 
				
			|||||||
      _saldo -= importo;
 | 
					      _saldo -= importo;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // Anche se non movimentato vado a vedere il saldo 
 | 
					#ifdef DBG                 
 | 
				
			||||||
  if (!_movimentato)
 | 
					  xvt_statbar_refresh();
 | 
				
			||||||
    if (stp_prov != 3)
 | 
					#endif
 | 
				
			||||||
      _saldo = calcola_saldo_iniziale(g,c,s,indbil);  
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  return _movimentato;  
 | 
					  return _movimentato;  
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -110,6 +110,83 @@ void TTab_conti::aggiorna_conto(const TBill& tcon,
 | 
				
			|||||||
      remove(*tc, anno_es, scaricato);  
 | 
					      remove(*tc, anno_es, scaricato);  
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					///////////////////////////////////////////////////////////
 | 
				
			||||||
 | 
					// TDecoder
 | 
				
			||||||
 | 
					///////////////////////////////////////////////////////////
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					TDecoder::TDecoder(int num, const char* inf, const char* outf)
 | 
				
			||||||
 | 
					        : _file(new TLocalisamfile(num)), _if(inf), _of(outf)
 | 
				
			||||||
 | 
					{ 
 | 
				
			||||||
 | 
					  init_firm();
 | 
				
			||||||
 | 
					}        
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					TDecoder::TDecoder(const char* tab, const char* outf)
 | 
				
			||||||
 | 
					        : _file(new TTable(tab)), _if("CODTAB"), _of(outf)
 | 
				
			||||||
 | 
					{ 
 | 
				
			||||||
 | 
					  init_firm();
 | 
				
			||||||
 | 
					}        
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					TDecoder::~TDecoder()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  delete _file;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void TDecoder::init_firm()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  TDir dir; 
 | 
				
			||||||
 | 
					  dir.get(_file->num());
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
 | 
					  // Se e' un file comune metti a -1, altrimenti alla ditta corrente
 | 
				
			||||||
 | 
					  _last_firm = dir.is_com() ? -1 : prefix().get_codditta();
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const TString& TDecoder::decode(const char* code)
 | 
				
			||||||
 | 
					{               
 | 
				
			||||||
 | 
					  if (_last_firm >= 0)  // Se e' un file di ditta ...
 | 
				
			||||||
 | 
					  {                     // ... controlla che non sia cambiata
 | 
				
			||||||
 | 
					    const long cur_firm = prefix().get_codditta();
 | 
				
			||||||
 | 
					    if (cur_firm != _last_firm)
 | 
				
			||||||
 | 
					    {                                             
 | 
				
			||||||
 | 
					      _last_firm = cur_firm;
 | 
				
			||||||
 | 
					      destroy();
 | 
				
			||||||
 | 
					    }  
 | 
				
			||||||
 | 
					  }  
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  if (code == NULL)
 | 
				
			||||||
 | 
					    code = "";
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					  TObject* obj = objptr(code);
 | 
				
			||||||
 | 
					  if (obj == NULL)
 | 
				
			||||||
 | 
					  {     
 | 
				
			||||||
 | 
					    int err = ~NOERR;
 | 
				
			||||||
 | 
					    if (*code)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					      _file->setkey(1);
 | 
				
			||||||
 | 
					      _file->put(_if, code);
 | 
				
			||||||
 | 
					      err = _file->read();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    if (err == NOERR)
 | 
				
			||||||
 | 
					      obj = new TString(_file->get(_of));     // Found
 | 
				
			||||||
 | 
					    else   
 | 
				
			||||||
 | 
					      obj = new TString(1);                   // Not found
 | 
				
			||||||
 | 
					    add(code, obj);
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					  const TString& s = (const TString&)*obj;
 | 
				
			||||||
 | 
					  return s;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const TString& TDecoder::decode(long code)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  TString16 c; 
 | 
				
			||||||
 | 
					  if (code > 0)
 | 
				
			||||||
 | 
					    c << code;
 | 
				
			||||||
 | 
					  return decode(c);
 | 
				
			||||||
 | 
					}  
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					///////////////////////////////////////////////////////////
 | 
				
			||||||
 | 
					// TSaldo_agg
 | 
				
			||||||
 | 
					///////////////////////////////////////////////////////////
 | 
				
			||||||
 | 
					
 | 
				
			||||||
TSaldo_agg::TSaldo_agg() : _anno_es(0), _data_ulmov(""), _num_ulmov(0l), 
 | 
					TSaldo_agg::TSaldo_agg() : _anno_es(0), _data_ulmov(""), _num_ulmov(0l), 
 | 
				
			||||||
                           _movap(normale), _provv(FALSE), _movimentato(FALSE) 
 | 
					                           _movap(normale), _provv(FALSE), _movimentato(FALSE) 
 | 
				
			||||||
{}
 | 
					{}
 | 
				
			||||||
@ -157,15 +234,6 @@ void TSaldo_agg::clear_saldi(int year)
 | 
				
			|||||||
  {            
 | 
					  {            
 | 
				
			||||||
    if (!saldi.get_bool(SLD_FLSCA))
 | 
					    if (!saldi.get_bool(SLD_FLSCA))
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
/*      saldi.put(SLD_FLAGSALINI, "D");
 | 
					 | 
				
			||||||
      saldi.zero(SLD_SALDO);
 | 
					 | 
				
			||||||
      saldi.zero(SLD_PDAREPRO);
 | 
					 | 
				
			||||||
      saldi.zero(SLD_PAVEREPRO);
 | 
					 | 
				
			||||||
      saldi.zero(SLD_PDARE);
 | 
					 | 
				
			||||||
      saldi.zero(SLD_PAVERE);
 | 
					 | 
				
			||||||
      saldi.zero(SLD_NUMULTMOV);
 | 
					 | 
				
			||||||
      saldi.zero(SLD_DATAULMOV);
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
      saldi.remove();
 | 
					      saldi.remove();
 | 
				
			||||||
    }  
 | 
					    }  
 | 
				
			||||||
    else                
 | 
					    else                
 | 
				
			||||||
 | 
				
			|||||||
@ -245,57 +245,6 @@ void TValuta::lit2val(TImporto& imp) const
 | 
				
			|||||||
  lit2val(imp.valore());
 | 
					  lit2val(imp.valore());
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
///////////////////////////////////////////////////////////
 | 
					 | 
				
			||||||
// TDecoder
 | 
					 | 
				
			||||||
///////////////////////////////////////////////////////////
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
TDecoder::TDecoder(int num, const char* inf, const char* outf)
 | 
					 | 
				
			||||||
        : _file(new TLocalisamfile(num)), _if(inf), _of(outf)
 | 
					 | 
				
			||||||
{ }        
 | 
					 | 
				
			||||||
 
 | 
					 | 
				
			||||||
TDecoder::TDecoder(const char* tab, const char* outf)
 | 
					 | 
				
			||||||
        : _file(new TTable(tab)), _if("CODTAB"), _of(outf)
 | 
					 | 
				
			||||||
{ }        
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
TDecoder::~TDecoder()
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
  delete _file;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
const TString& TDecoder::decode(const char* code)
 | 
					 | 
				
			||||||
{       
 | 
					 | 
				
			||||||
  if (code == NULL)
 | 
					 | 
				
			||||||
    code = "";
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
  TObject* obj = objptr(code);
 | 
					 | 
				
			||||||
  if (obj == NULL)
 | 
					 | 
				
			||||||
  {     
 | 
					 | 
				
			||||||
    int err = ~NOERR;
 | 
					 | 
				
			||||||
    if (*code)
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
      _file->setkey(1);
 | 
					 | 
				
			||||||
      _file->put(_if, code);
 | 
					 | 
				
			||||||
      err = _file->read();
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    if (err == NOERR)
 | 
					 | 
				
			||||||
      obj = new TString(_file->get(_of));     // Found
 | 
					 | 
				
			||||||
    else   
 | 
					 | 
				
			||||||
      obj = new TString(1);                   // Not found
 | 
					 | 
				
			||||||
    add(code, obj);
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
  const TString& s = (const TString&)*obj;
 | 
					 | 
				
			||||||
  return s;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
const TString& TDecoder::decode(long code)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
  TString16 c; 
 | 
					 | 
				
			||||||
  if (code > 0)
 | 
					 | 
				
			||||||
    c << code;
 | 
					 | 
				
			||||||
  return decode(c);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
///////////////////////////////////////////////////////////
 | 
					///////////////////////////////////////////////////////////
 | 
				
			||||||
// TRiga_scadenze
 | 
					// TRiga_scadenze
 | 
				
			||||||
///////////////////////////////////////////////////////////
 | 
					///////////////////////////////////////////////////////////
 | 
				
			||||||
 | 
				
			|||||||
@ -108,24 +108,6 @@ public:
 | 
				
			|||||||
  virtual ~TValuta() {}
 | 
					  virtual ~TValuta() {}
 | 
				
			||||||
};    
 | 
					};    
 | 
				
			||||||
 | 
					
 | 
				
			||||||
///////////////////////////////////////////////////////////
 | 
					 | 
				
			||||||
// TDecoder
 | 
					 | 
				
			||||||
///////////////////////////////////////////////////////////
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
class TDecoder : private TAssoc_array
 | 
					 | 
				
			||||||
{ 
 | 
					 | 
				
			||||||
  TLocalisamfile* _file;
 | 
					 | 
				
			||||||
  TString _if, _of;
 | 
					 | 
				
			||||||
  
 | 
					 | 
				
			||||||
public:            
 | 
					 | 
				
			||||||
  const TString& decode(const char* code); 
 | 
					 | 
				
			||||||
  const TString& decode(long code);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  TDecoder(int num, const char* inf, const char* outf);
 | 
					 | 
				
			||||||
  TDecoder(const char* table, const char* outf = "S0");
 | 
					 | 
				
			||||||
  virtual ~TDecoder();
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
///////////////////////////////////////////////////////////
 | 
					///////////////////////////////////////////////////////////
 | 
				
			||||||
// Riga scadenza
 | 
					// Riga scadenza
 | 
				
			||||||
///////////////////////////////////////////////////////////
 | 
					///////////////////////////////////////////////////////////
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user