Files correlati : Ricompilazione Demo : [ ] Commento : Riportata la versione aga 07 patch 250 sul main trunk git-svn-id: svn://10.65.10.50/trunk@10209 c028cbd2-c16b-5b4b-a496-9718f37d4682
		
			
				
	
	
		
			202 lines
		
	
	
		
			4.8 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			202 lines
		
	
	
		
			4.8 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
#include <prefix.h>
 | 
						||
#include <recarray.h>
 | 
						||
 | 
						||
#include "cglib03.h"
 | 
						||
 | 
						||
///////////////////////////////////
 | 
						||
// classe TInteressi_IVA_table   //
 | 
						||
// per la lettura versamenti e   //
 | 
						||
// e interessi IVA dalla tabella //
 | 
						||
///////////////////////////////////
 | 
						||
 | 
						||
TInteressi_IVA_table::TInteressi_IVA_table() : TTable("%VER")
 | 
						||
{
 | 
						||
}
 | 
						||
 | 
						||
TInteressi_IVA_table::~TInteressi_IVA_table()
 | 
						||
{
 | 
						||
}
 | 
						||
 | 
						||
int TInteressi_IVA_table::read(int anno, int mese)
 | 
						||
{
 | 
						||
  TString16 k;
 | 
						||
  k.format("%04d%02d",anno,mese);
 | 
						||
  zero();put("CODTAB",k);
 | 
						||
  if (TTable::read(_isgteq) == NOERR)
 | 
						||
  {
 | 
						||
    TString16 cod = TTable::get("CODTAB");
 | 
						||
    
 | 
						||
    if (cod > k)
 | 
						||
      if (prev() != NOERR)
 | 
						||
        zero();
 | 
						||
  }
 | 
						||
  else
 | 
						||
    if (last() != NOERR)
 | 
						||
      zero();
 | 
						||
  return status();
 | 
						||
}
 | 
						||
 | 
						||
real TInteressi_IVA_table::get(int what)
 | 
						||
{
 | 
						||
  TString16 fieldname;
 | 
						||
  fieldname.format("R%d",what);
 | 
						||
  return get_real(fieldname);
 | 
						||
}
 | 
						||
 | 
						||
///////////////////////////////////////////////
 | 
						||
// TRigaiva_array 
 | 
						||
// Tabella per il calcolo degli imponibili Iva
 | 
						||
///////////////////////////////////////////////
 | 
						||
 | 
						||
bool TRigaiva_array::add_riga(const real& imponibile, const real& imposta, const real& imponibilep, const real& impostap, const char* codiva, const int tipodet, const int tipocr, bool intra, const int tipoatt) 
 | 
						||
{
 | 
						||
  bool found = FALSE;
 | 
						||
  for (int i = 0; i < items(); i++)
 | 
						||
  {
 | 
						||
    TRigaiva& r = riga(i);
 | 
						||
    if (r._codiva==codiva && tipodet==r._tipodet && tipocr==r._tipocr && tipoatt==r._tipoatt)
 | 
						||
    {
 | 
						||
      found = TRUE;
 | 
						||
      r._imponibile  += imponibile;
 | 
						||
      r._imposta     += imposta;
 | 
						||
      r._imponibilep += imponibilep;
 | 
						||
      r._impostap    += impostap;
 | 
						||
    }
 | 
						||
  }
 | 
						||
  if (!found)
 | 
						||
  {
 | 
						||
    TRigaiva* r = new TRigaiva(imponibile,imposta,imponibilep,impostap,codiva,tipodet,tipocr,intra,tipoatt);
 | 
						||
    add(r);
 | 
						||
  }
 | 
						||
  return found;
 | 
						||
}
 | 
						||
 | 
						||
bool TRiga_array::add_riga(const real& imponibile, const real& imposta, const real& implordo, const real& imponibilep, const real& impostap, const real& implordop, const char* codiva) 
 | 
						||
{
 | 
						||
  bool found = FALSE;
 | 
						||
  for (int i = 0; i < items(); i++)
 | 
						||
  {
 | 
						||
    TRiga& r = riga(i);
 | 
						||
    if (r._codiva==codiva) 
 | 
						||
    {
 | 
						||
      found = TRUE;
 | 
						||
      r._imponibile  += imponibile;
 | 
						||
      r._imposta     += imposta;
 | 
						||
      r._implordo    += implordo;  
 | 
						||
      r._imponibilep += imponibilep;
 | 
						||
      r._impostap    += impostap;
 | 
						||
      r._implordop   += implordop;
 | 
						||
    }
 | 
						||
  }
 | 
						||
  if (!found)
 | 
						||
  {                                                
 | 
						||
    TRiga* r = new TRiga(imponibile,imposta,implordo,imponibilep,impostap,implordop,codiva);
 | 
						||
    add(r);
 | 
						||
  }
 | 
						||
  return found;
 | 
						||
}                                 
 | 
						||
 | 
						||
bool TDociva_array::add_riga(const char* _descrdociva, const real& _importo,const int _natdoc) 
 | 
						||
{
 | 
						||
  bool found = FALSE;
 | 
						||
  for (int i = 0; i < items(); i++)
 | 
						||
  {
 | 
						||
    TDociva& r = riga(i);
 | 
						||
    if (r._descrdoc==_descrdociva) 
 | 
						||
    {
 | 
						||
      found = TRUE;
 | 
						||
      if ((r._ndoc == 1)||(r._ndoc == 2)||(r._ndoc == 9))//||(r._ndoc == 4))
 | 
						||
        r._totdociva += _importo;
 | 
						||
    }
 | 
						||
  }
 | 
						||
  if (!found)
 | 
						||
  {
 | 
						||
    if ((_natdoc == 1)||(_natdoc == 2)||(_natdoc == 9))//||(_natdoc == 4))
 | 
						||
    {
 | 
						||
      TDociva* r = new TDociva(_descrdociva,_importo,_natdoc);
 | 
						||
      add(r);
 | 
						||
    }
 | 
						||
  }
 | 
						||
  return found; 
 | 
						||
}  
 | 
						||
 | 
						||
bool TTipodoc_array::add_riga(const char* tipodoc, const char* descrdoc, const real& totdoc) 
 | 
						||
{
 | 
						||
  bool found = FALSE;
 | 
						||
  for (int i = 0; i < items(); i++)
 | 
						||
  {
 | 
						||
    TTipodoc& r = (TTipodoc&)(*this)[i];
 | 
						||
    if (r._tipodoc==tipodoc) 
 | 
						||
    {
 | 
						||
      found = TRUE;
 | 
						||
      r._totdoc += totdoc;
 | 
						||
    }
 | 
						||
  }
 | 
						||
  if (!found)
 | 
						||
  {
 | 
						||
    TTipodoc* r = new TTipodoc(tipodoc,descrdoc,totdoc);
 | 
						||
    add(r);
 | 
						||
  }
 | 
						||
  return found;
 | 
						||
}
 | 
						||
 | 
						||
///////////////////////////////////////////////////////////
 | 
						||
// Arrotondamenti iva 
 | 
						||
///////////////////////////////////////////////////////////
 | 
						||
 | 
						||
TRound_mode TIva_round::_def_mode = rm_unknown;
 | 
						||
int TIva_round::_def_decimals = 0;
 | 
						||
 | 
						||
void TIva_round::set_default_mode(TRound_mode m, int d)
 | 
						||
{
 | 
						||
  _def_mode = _mode = m;
 | 
						||
  _def_decimals = _decimals = d;
 | 
						||
}
 | 
						||
 | 
						||
void TIva_round::set_mode(TRound_mode m, int d)
 | 
						||
{
 | 
						||
  _mode = m;
 | 
						||
  _decimals = d;
 | 
						||
}
 | 
						||
 | 
						||
void TIva_round::set_default_iva_mode(int year, bool declaration, long ditta)
 | 
						||
{                               
 | 
						||
  if (year < 1990)
 | 
						||
    year = TDate(TODAY).year();
 | 
						||
 | 
						||
  if (year >= 2002 && is_euro_value(NULL))
 | 
						||
  {
 | 
						||
    if (ditta <= 0)
 | 
						||
      ditta = prefix().get_codditta();
 | 
						||
    TString16 key; key.format("%05ld%04d", ditta, year);
 | 
						||
    const TRectype& lia = cache().get("%LIA", key);
 | 
						||
    const int dec = lia.get_int(declaration ? "I2" : "I1");
 | 
						||
    set_default_mode(rm_round, dec);
 | 
						||
  }
 | 
						||
  else
 | 
						||
    set_default_mode(rm_millelire, -3);
 | 
						||
}
 | 
						||
  
 | 
						||
void TIva_round::round(real& n) const
 | 
						||
{
 | 
						||
  CHECK(_mode != rm_unknown, "Non <20> stato impostato il metodo di arrotondamento");
 | 
						||
  switch (_mode)
 | 
						||
  {
 | 
						||
  case rm_ceil: 
 | 
						||
    n.ceil(_decimals); 
 | 
						||
    break;
 | 
						||
  case rm_millelire: 
 | 
						||
    n -= 0.0001; // Le 500 lire vanno arrontondate per difetto
 | 
						||
  default: 
 | 
						||
    n.round(_decimals); 
 | 
						||
    break;
 | 
						||
  }
 | 
						||
}
 | 
						||
 | 
						||
TIva_round::TIva_round()
 | 
						||
{
 | 
						||
  _mode = _def_mode;
 | 
						||
  _decimals = _def_decimals;
 | 
						||
}  
 | 
						||
 |