1275 lines
		
	
	
		
			36 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			1275 lines
		
	
	
		
			36 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
// ------------------------------------------------------------
 | 
						|
// Calcolo liquidazioni
 | 
						|
// Part 5: stampa 
 | 
						|
// fv 21-1-94
 | 
						|
// ------------------------------------------------------------
 | 
						|
 | 
						|
#include "cg4300.h"
 | 
						|
 | 
						|
// flags per annuale
 | 
						|
#define IS_PRORATA 0x0001
 | 
						|
 | 
						|
// minchietta per prospetto ventilazione
 | 
						|
class _vDesc : public TObject
 | 
						|
{
 | 
						|
public:
 | 
						|
  TString _codiva;
 | 
						|
  real    _acq;
 | 
						|
  real    _vnd;
 | 
						|
  real    _viv;
 | 
						|
  _vDesc() : _codiva(5) {}
 | 
						|
  virtual ~_vDesc() {}
 | 
						|
};
 | 
						|
 | 
						|
static char sep[] = 
 | 
						|
   "------------------------------------------------------------------"
 | 
						|
   "------------------------------------------------------------------";
 | 
						|
 | 
						|
void CG4300_App::set_page(int file, int cnt)
 | 
						|
{
 | 
						|
  _DescrItem& d = (_DescrItem&)_descr_arr[cnt];
 | 
						|
 | 
						|
  set_auto_ff(FALSE);
 | 
						|
  reset_print();
 | 
						|
 | 
						|
  switch(d._flags)
 | 
						|
    {
 | 
						|
    case CHG_PARMS: set_att(d);       break;
 | 
						|
    case SET_FIRM:  set_firm(d);      break;
 | 
						|
    case PIM_ROW:   set_pim(d);       break;
 | 
						|
    case TOT_ROW:   set_plm(d);       break;
 | 
						|
    case MISC_LIQ:  set_ptm(d);       break;
 | 
						|
    case PLAFOND:   set_plafond(d);   break;
 | 
						|
    case VENTILA:   set_ventila(d);   break;
 | 
						|
    case REGAGR:    set_regagr(d);    break;
 | 
						|
    case REGVIA:    set_viaggio(d);   break;
 | 
						|
    case THE_END:   set_grand(d);     break;
 | 
						|
    case ACCONTO:   set_acconto_p(d); break;
 | 
						|
    case ACCHEAD:   set_acchead_p(d); break;
 | 
						|
    }
 | 
						|
}
 | 
						|
 | 
						|
print_action CG4300_App::postprocess_page(int file, int cnt)
 | 
						|
{
 | 
						|
  if (_descr_arr.items() == 0 || cnt == _descr_arr.items()-1)
 | 
						|
    return NEXT_PAGE;
 | 
						|
  return REPEAT_PAGE;
 | 
						|
}
 | 
						|
 | 
						|
bool CG4300_App::preprocess_page(int file, int cnt)
 | 
						|
{
 | 
						|
  return  _descr_arr.items() != 0;
 | 
						|
}
 | 
						|
 | 
						|
// ----------------------------------------------------------------
 | 
						|
// Print description
 | 
						|
// ----------------------------------------------------------------
 | 
						|
 | 
						|
void CG4300_App::describe_att(int month, const char* codatt)
 | 
						|
{
 | 
						|
  TToken_string atts(codatt);
 | 
						|
  
 | 
						|
  if (_isprint)
 | 
						|
    {
 | 
						|
      describe_name(month, atts);
 | 
						|
      if (atts.items() == 1 && _isplafond) 
 | 
						|
	describe_plafond(month, codatt);
 | 
						|
      if (atts.items() == 1 && _isvent) 
 | 
						|
	describe_ventilation(month, codatt);
 | 
						|
      if (atts.items() == 1 && _isagricolo) 
 | 
						|
	describe_agricolo(month, codatt);
 | 
						|
      if (atts.items() == 1 && _isviaggio) 
 | 
						|
	describe_viaggio(month, codatt);
 | 
						|
      describe_pims(month,codatt);
 | 
						|
      if (atts.items() == 1)
 | 
						|
	describe_consistence(codatt);
 | 
						|
    }
 | 
						|
}
 | 
						|
 | 
						|
void CG4300_App::describe_name(int month, TToken_string& codatts)
 | 
						|
{
 | 
						|
  _DescrItem* d = new _DescrItem(CHG_PARMS);
 | 
						|
 | 
						|
  d->_s0 = _nditte->curr().get("CODDITTA");
 | 
						|
  d->_s1 = _nditte->curr().get("RAGSOC");
 | 
						|
  d->_s2 = _nditte->curr(LF_ATTIV).get("CODATT");
 | 
						|
	d->_s3 = codatts.items() == 1 ? (const char*)_nditte->curr(LF_ATTIV).get("DESCR")  : "";
 | 
						|
  d->_s4 = _nditte->curr().get("FREQVIVA");
 | 
						|
  
 | 
						|
  d->_f1 = month;
 | 
						|
  d->_f2 = _isbenzinaro;
 | 
						|
  if (_mixed && codatts.items() == 1) 
 | 
						|
    d->_f0 = atoi(codatts.mid(5));
 | 
						|
  _descr_arr.add(d);
 | 
						|
}
 | 
						|
 | 
						|
void CG4300_App::describe_firm(int month)
 | 
						|
{
 | 
						|
  if (!_isprint) return;
 | 
						|
 | 
						|
  _DescrItem* d = new _DescrItem(SET_FIRM);
 | 
						|
 | 
						|
  d->_s0 = _nditte->curr().get("CODDITTA");
 | 
						|
  d->_s1 = _nditte->curr().get("RAGSOC");
 | 
						|
  d->_s2 = _nditte->curr().get("FREQVIVA");
 | 
						|
  d->_f1 = month;
 | 
						|
  _descr_arr.add(d);
 | 
						|
}
 | 
						|
 | 
						|
void CG4300_App::describe_ventilation(int month, const char* codatt)
 | 
						|
{
 | 
						|
  if (_isriepilogo || _isannual) month = 12;
 | 
						|
 | 
						|
  _DescrItem* d = new _DescrItem(VENTILA);
 | 
						|
  TString att(codatt);
 | 
						|
 | 
						|
  look_ptm(month, att);
 | 
						|
  real r0 = _ptm->get("S4");
 | 
						|
  real r1 = _ptm->get("S5");
 | 
						|
  d->_r0 = r0; d->_r1 = r1;
 | 
						|
  
 | 
						|
  for (_pim->first(); !_pim->eof(); _pim->next())
 | 
						|
    {
 | 
						|
      if (strcmp(*_pim_codatt,att) != 0)
 | 
						|
	continue;
 | 
						|
 | 
						|
      look_reg(*_pim_codreg);
 | 
						|
      look_iva(*_pim_codiva);
 | 
						|
      
 | 
						|
      int     tipocr      = atoi(*_pim_tipocr);
 | 
						|
      int     mese        = atoi(*_pim_mese);
 | 
						|
      bool    corrisp     = _reg->get_bool("B0");  
 | 
						|
      real    imponibile  = _pim->get_real("R0");
 | 
						|
      real    imposta     = _pim->get_real("R1");
 | 
						|
      tiporeg tipomov     = (tiporeg)_reg->get_long("I0");
 | 
						|
 | 
						|
      if (mese <= month)
 | 
						|
	{
 | 
						|
	  if (tipocr == 1 && tipomov == acquisto)
 | 
						|
	    {
 | 
						|
	      // somma agli acquisti
 | 
						|
	      _vDesc* vd = NULL;
 | 
						|
	      for (int i = 0; i < d->_arr.items(); i++)
 | 
						|
		{
 | 
						|
		  _vDesc* vv = (_vDesc*)&(d->_arr[i]);
 | 
						|
		  if (strcmp(vv->_codiva,*_pim_codiva) == 0)
 | 
						|
		    { vd = vv; break; }
 | 
						|
		}
 | 
						|
	      if (vd == NULL) { vd = new _vDesc; }
 | 
						|
 | 
						|
	      vd->_acq += (imponibile+imposta);
 | 
						|
 | 
						|
	      if (vd->_codiva.empty()) 
 | 
						|
		{
 | 
						|
		  vd->_codiva = *_pim_codiva;
 | 
						|
		  d->_arr.add(vd);
 | 
						|
		}
 | 
						|
	    }
 | 
						|
	  else if (check_month(mese,month) && corrisp 
 | 
						|
		   && _pim->get_bool("B1") &&
 | 
						|
		   tipocr == 0 && tipomov == vendita)
 | 
						|
	  // non sono sicurissimo della above condition
 | 
						|
	    {
 | 
						|
	      // somma alle vendite
 | 
						|
	      _vDesc* vd = NULL;
 | 
						|
	      for (int i = 0; i < d->_arr.items(); i++)
 | 
						|
		{
 | 
						|
		  _vDesc* vv = (_vDesc*)&(d->_arr[i]);
 | 
						|
		  if (strcmp(vv->_codiva,*_pim_codiva) == 0)
 | 
						|
		    { vd = vv; break; }
 | 
						|
		}
 | 
						|
	      if (vd == NULL) { vd = new _vDesc; }
 | 
						|
 | 
						|
	      vd->_vnd  += imponibile;
 | 
						|
	      vd->_viv  += imposta;
 | 
						|
	      
 | 
						|
	      if (vd->_codiva.empty()) 
 | 
						|
		{
 | 
						|
		  vd->_codiva = *_pim_codiva;
 | 
						|
		  d->_arr.add(vd);
 | 
						|
		}
 | 
						|
	    }
 | 
						|
	}
 | 
						|
    }  
 | 
						|
  _descr_arr.add(d);
 | 
						|
}
 | 
						|
 | 
						|
void CG4300_App::describe_agricolo(int month, const char* codatt)
 | 
						|
{
 | 
						|
  if (month != 13)
 | 
						|
    if (!(look_plm(month, codatt) && look_ptm(month,codatt))) 
 | 
						|
      return;
 | 
						|
 | 
						|
  _DescrItem* d  = new _DescrItem(REGAGR);
 | 
						|
  
 | 
						|
  for (int mese = 1; mese <= month; mese++)
 | 
						|
    {
 | 
						|
      if (mese == 13) 
 | 
						|
	break;
 | 
						|
      if (month != 13 && mese != month) 
 | 
						|
	continue;
 | 
						|
      if (!(look_plm(mese, codatt) && look_ptm(mese,codatt))) 
 | 
						|
	continue;
 | 
						|
 | 
						|
      d->_r0 += _plm->get_real("R5"); // vend. reg. agr.
 | 
						|
      d->_r1 += _plm->get_real("R6"); // vend. per conferimento
 | 
						|
      d->_r2 += _plm->get_real("R7"); // vend. accessorie
 | 
						|
      d->_r3 += _plm->get_real("R8"); // acquisti reg. agr.
 | 
						|
      d->_r4 += _plm->get_real("R0"); // IVA acquisti rimasta
 | 
						|
      d->_r5 += _plm->get_real("R1"); // IVA vendite rimasta  
 | 
						|
      d->_r6 += _ptm->get_real("R4") + _ptm->get_real("R12") + 
 | 
						|
	        _ptm->get_real("R9"); // IVA acq. ammortizzabili
 | 
						|
    }
 | 
						|
  
 | 
						|
  _descr_arr.add(d);
 | 
						|
}
 | 
						|
 | 
						|
void CG4300_App::describe_viaggio(int month, const char* codatt)
 | 
						|
{
 | 
						|
  if (month != 13)
 | 
						|
    if (!(look_plm(month, codatt) && look_lim(month))) 
 | 
						|
      return;
 | 
						|
 | 
						|
  _DescrItem* d = new _DescrItem(REGVIA);
 | 
						|
 | 
						|
  for (int mese = 1; mese <= month; mese++)
 | 
						|
    {
 | 
						|
      if (mese == 13) 
 | 
						|
	break;
 | 
						|
      if (!check_month(mese,month)) 
 | 
						|
	continue;
 | 
						|
      if (!(look_plm(mese, codatt) && look_lim(mese))) 
 | 
						|
	continue;
 | 
						|
 | 
						|
      d->_r0 += _plm->get_real("R5");  // corrispettivi CEE
 | 
						|
      d->_r1 += _plm->get_real("R9");  // corrispettivi misti CEE 
 | 
						|
      d->_r2 += _plm->get_real("R6");  // corrispettivi fuori CE
 | 
						|
      d->_r3 += _plm->get_real("R7");  // acquisti CEE
 | 
						|
      d->_r4 += _plm->get_real("R10"); // acquisti misti parte CEE
 | 
						|
      d->_r5 += _plm->get_real("R8");  // acquisti fuori CEE
 | 
						|
      d->_r6 += _plm->get_real("R11"); // acquisti misti parte fuori CEE
 | 
						|
      // questa e' sempre quella dell'ultimo mese
 | 
						|
      d->_r7  = _lim->get_real("R4");  // percentuale di ripartizione
 | 
						|
     }
 | 
						|
  // credito di costo precedente (CHECK annuale)
 | 
						|
  d->_r8 = credito_costo_prec(_isriepilogo || _isannual ? 12 : mese, codatt);
 | 
						|
  // calcolera' imposte e crediti solo se e' annuale vera 
 | 
						|
  d->_f1 = _isriepilogo && !_isannual;
 | 
						|
 | 
						|
 _descr_arr.add(d);
 | 
						|
}
 | 
						|
 | 
						|
 | 
						|
void CG4300_App::describe_pims(int month, const char* codatt)
 | 
						|
// le si passa una tokenstring (o un codatt) e lei, da brava, calcola
 | 
						|
// cumulando per tutte le attivita' nominatele
 | 
						|
// ogni riga riguarda un codiva ma tutti i registri
 | 
						|
// se il mese e' 13 si guarda tutto l'anno
 | 
						|
{
 | 
						|
  TToken_string atts(codatt);
 | 
						|
  TString ref(atts.items() == 1 ? codatt : "ALL");
 | 
						|
  const char*     tmpatt;
 | 
						|
  int last      = _descr_arr.last();
 | 
						|
  bool isfirst  = TRUE;
 | 
						|
  real t0, t1, t2, t3, t4, t5;
 | 
						|
 | 
						|
  while ((tmpatt = atts.get()) != NULL)
 | 
						|
    {
 | 
						|
      TString att(tmpatt);
 | 
						|
      for (_pim->first(); !_pim->eof(); _pim->next())
 | 
						|
	{
 | 
						|
	  _DescrItem* d = NULL;
 | 
						|
	  // compute
 | 
						|
	  bool ok = look_reg(*_pim_codreg);
 | 
						|
	  ok |= look_iva(*_pim_codiva);
 | 
						|
	  bool isnew    = FALSE;
 | 
						|
	  
 | 
						|
	  if (!ok) continue;
 | 
						|
 | 
						|
	  tiporeg tipomov  = (tiporeg)_reg->get_long("I0");
 | 
						|
	  bool corrisp     = _reg->get_bool("B0");  
 | 
						|
	  TString tipoiva  = _iva->get("S1");
 | 
						|
	  
 | 
						|
	  // se e' corrispettivo da ventilare non 
 | 
						|
	  // scrivo un cannolo ripieno visto che e' stato ventilato
 | 
						|
	  if (tipomov == vendita && tipoiva == "VE") continue;
 | 
						|
	  
 | 
						|
	  if (strcmp((const char*)*_pim_codatt, att) == 0 &&
 | 
						|
	      check_month(atoi(*_pim_mese),month) &&
 | 
						|
	      _year == (const char*)*_pim_anno)
 | 
						|
	    {
 | 
						|
	      // vedi se c'e' gia' un item corrispondente
 | 
						|
	      for(int i = last+1; i < _descr_arr.items(); i++)
 | 
						|
		{
 | 
						|
		  d = (_DescrItem*)&_descr_arr[i];
 | 
						|
		  if (d->_flags == PIM_ROW &&
 | 
						|
		      d->_s0    == ref     &&
 | 
						|
		      d->_s1    == (const char*)*_pim_codiva)
 | 
						|
		    break;
 | 
						|
		}
 | 
						|
	      if (i == _descr_arr.items())
 | 
						|
		{ 
 | 
						|
		  isnew = TRUE; 
 | 
						|
		  d = new _DescrItem(PIM_ROW); 
 | 
						|
		}
 | 
						|
 | 
						|
	      if (tipomov == acquisto)
 | 
						|
		{
 | 
						|
		  d->_r4 += _pim->get_real("R0");
 | 
						|
		  d->_r5 += _pim->get_real("R1");
 | 
						|
		  t4     += _pim->get_real("R0"); 
 | 
						|
		  t5     += _pim->get_real("R1"); 
 | 
						|
		}
 | 
						|
	      else  // vendita
 | 
						|
		{
 | 
						|
		  if (corrisp)
 | 
						|
		    {
 | 
						|
		      // usa R0 e R1 visto che la ventilazione e' gia' 
 | 
						|
		      // stata calcolata
 | 
						|
		      d->_r2 += _pim->get_real("R0");
 | 
						|
		      d->_r3 += _pim->get_real("R1");
 | 
						|
		      t2     += _pim->get_real("R0");
 | 
						|
		      t3     += _pim->get_real("R1"); 
 | 
						|
		    }
 | 
						|
		  else
 | 
						|
		    {
 | 
						|
		      d->_r0 += _pim->get_real("R0");
 | 
						|
		      d->_r1 += _pim->get_real("R1");
 | 
						|
		      t0     += _pim->get_real("R0"); 
 | 
						|
		      t1     += _pim->get_real("R1"); 
 | 
						|
		    }
 | 
						|
		}
 | 
						|
	      if (isnew) 
 | 
						|
		{ 
 | 
						|
		  d->_s0 = ref;
 | 
						|
		  d->_s1 = *_pim_codiva;
 | 
						|
		  _descr_arr.add(d);
 | 
						|
		  // flag per stampare l'intestazione colonne
 | 
						|
		  if (isfirst) 
 | 
						|
		    {
 | 
						|
		      d->_f0 = TRUE;
 | 
						|
		      isfirst = FALSE;
 | 
						|
		    }
 | 
						|
		}
 | 
						|
	    }
 | 
						|
	}
 | 
						|
    }
 | 
						|
  // prepara una bella riga di totali
 | 
						|
  if (!isfirst)
 | 
						|
    {
 | 
						|
      _DescrItem* d = new _DescrItem(TOT_ROW);
 | 
						|
      d->_r0 = t0; d->_r1 = t1;
 | 
						|
      d->_r2 = t2; d->_r3 = t3;
 | 
						|
      d->_r4 = t4; d->_r5 = t5;
 | 
						|
 | 
						|
      // aggiunge dati ptm
 | 
						|
      _DescrItem* t = new _DescrItem(MISC_LIQ);
 | 
						|
 | 
						|
      for (int m = 1; m <= month && m < 13; m++)
 | 
						|
	{
 | 
						|
	  if (!check_month(m,month)) continue;
 | 
						|
 | 
						|
	  atts.restart();
 | 
						|
	  while ((tmpatt = atts.get()) != NULL)
 | 
						|
	    {
 | 
						|
	      TString att(tmpatt);
 | 
						|
	      look_ptm(m, att);
 | 
						|
	      d->_r6  += _ptm->get_real("R0");  // acq. intracomunitari
 | 
						|
	      d->_r7  += _ptm->get_real("R1");  // inded. art 19
 | 
						|
	      d->_r8  += _ptm->get_real("R2");  // IVA su inded. art. 19
 | 
						|
	      t->_r0  += _ptm->get_real("R3");  // acq. ammortizz. 
 | 
						|
	      t->_r1  += _ptm->get_real("R4");  // IVA acq. ammort.
 | 
						|
	      t->_r2  += _ptm->get_real("R5");  // ammort. detr. 6% 
 | 
						|
	      t->_r3  += _ptm->get_real("R12"); // IVA ammort detr. 6%
 | 
						|
	      t->_r4  += _ptm->get_real("R6");  // acq. beni rivendita
 | 
						|
	      t->_r5  += _ptm->get_real("R7");  // IVA acq. beni rivendita
 | 
						|
	      t->_r6  += _ptm->get_real("R8");  // acq. leasing
 | 
						|
	      t->_r7  += _ptm->get_real("R9");  // IVA acq. leasing
 | 
						|
	      t->_r8  += _ptm->get_real("R10"); // cessioni beni ammort.
 | 
						|
	      t->_r9  += _ptm->get_real("R11"); // IVA su cessioni ammort.
 | 
						|
	      t->_r10 += _ptm->get_real("R13"); // tot. esenti IVA
 | 
						|
	      
 | 
						|
	      look_plm(m, att);
 | 
						|
 | 
						|
	      t->_r11 += _plm->get_real("R2");  // pro-rata indetraibile
 | 
						|
	      t->_s0  =  (_plm->get_real("R12")).string();  // % pro-rata 
 | 
						|
	    }
 | 
						|
	}
 | 
						|
      // annual follows in _arr
 | 
						|
      if ((_isannual || _isriepilogo) && ref != "ALL")
 | 
						|
	{
 | 
						|
	  // tutte quelle cose che vanno alla liquidazione annuale, come il
 | 
						|
	  // calcolo del prorata o del nuovo plafond o ....
 | 
						|
	  if (look_pla(codatt))
 | 
						|
	    {
 | 
						|
	      real v  = _pla->get_real("R0");
 | 
						|
	      real e1 = _pla->get_real("R1");
 | 
						|
	      real e2 = _pla->get_real("R2");
 | 
						|
	      real e3 = _pla->get_real("R3");
 | 
						|
	      real am = _pla->get_real("R4");
 | 
						|
	      real pr = _pla->get_real("R9");
 | 
						|
	      real co = _pla->get_real("R10");
 | 
						|
	      
 | 
						|
	      _DescrItem* dd = new _DescrItem(ANNUAL);
 | 
						|
	      
 | 
						|
	      // prorata
 | 
						|
	      if (!(_prorata.is_zero() && pr.is_zero()))
 | 
						|
		dd->_f0 |= IS_PRORATA;
 | 
						|
	      dd->_r0 = v - am - e3;
 | 
						|
	      dd->_r1 = e1;
 | 
						|
	      dd->_r2 = pr;
 | 
						|
	      dd->_r3 = co;
 | 
						|
	      dd->_r4 = e2;
 | 
						|
	      dd->_r5 = e3;
 | 
						|
	      t->_arr.add(dd);
 | 
						|
	    }
 | 
						|
	}
 | 
						|
      _descr_arr.add(d);
 | 
						|
      _descr_arr.add(t);
 | 
						|
    }
 | 
						|
}
 | 
						|
 | 
						|
 | 
						|
void CG4300_App::describe_liq(int month, const char* codatts, _DescrItem* di)
 | 
						|
{
 | 
						|
  if (!_isprint) return;
 | 
						|
  if (_isannual || _isriepilogo) month = 12;
 | 
						|
  
 | 
						|
  _DescrItem* d = new _DescrItem(THE_END);
 | 
						|
  TToken_string atts(codatts);
 | 
						|
  const char* tmpatt;
 | 
						|
  real conguaglio;
 | 
						|
 | 
						|
  // serve per pagare anche meno di 50000 a dicembre
 | 
						|
  d->_f1 = month == 12;
 | 
						|
  d->_f2 = month;
 | 
						|
 | 
						|
  while ((tmpatt = atts.get()) != NULL)
 | 
						|
    {
 | 
						|
      TString att(tmpatt);
 | 
						|
      look_plm(month, att);
 | 
						|
      d->_r0 += _plm->get_real("R0"); // IVA vendite
 | 
						|
      d->_r1 += _plm->get_real("R1"); // IVA acquisti
 | 
						|
      d->_r2 += _plm->get_real("R3"); // Detrazioni 1
 | 
						|
      d->_r2 += _plm->get_real("R4"); // Detrazioni 2
 | 
						|
      d->_r1 -= _plm->get_real("R2"); // pro-rata 
 | 
						|
      // ev. conguaglio prorata
 | 
						|
      if (_isannual || _isriepilogo)
 | 
						|
	{
 | 
						|
	  look_pla(att);
 | 
						|
	  conguaglio += _pla->get_real("R10");
 | 
						|
	}
 | 
						|
    }
 | 
						|
  look_lim(month);
 | 
						|
  d->_r3 += _lim->get_real("R0"); // risultato
 | 
						|
  d->_r4 += _lim->get_real("R1"); // rimborso
 | 
						|
  if (_lim->get("S7") == "D")
 | 
						|
    d->_r5 += _lim->get_real("R5"); // rettifiche a debito
 | 
						|
  else 
 | 
						|
    d->_r6 += _lim->get_real("R5"); // rettifiche a credito
 | 
						|
  
 | 
						|
  d->_f0 = _nditte->curr().get("FREQVIVA") == "T";
 | 
						|
  
 | 
						|
  // r7 = credito precedente    
 | 
						|
  d->_r7 = credito_prec(month);
 | 
						|
  
 | 
						|
  // vedi se c'era un debito precedente e schiaffa in r10
 | 
						|
  if (!is_first_month(month))
 | 
						|
    {
 | 
						|
      if (look_lim(previous_month(month)))
 | 
						|
	{
 | 
						|
	  real r = _lim->get_real("R0");
 | 
						|
	  if (_lim->get_real("R5").sign() > 0)
 | 
						|
	    r += _plm->get_real("R5");
 | 
						|
	  // non considera il rimborso in quanto se e' a debito
 | 
						|
	  // non c'e' rimborso, e se e' rettificato pure
 | 
						|
	  if (r.sign() > 0 && r < IVA_DA_RIPORTARE)
 | 
						|
	    d->_r10 += r;
 | 
						|
	}
 | 
						|
    }
 | 
						|
  
 | 
						|
  if (_isannual || _isriepilogo) 
 | 
						|
    {
 | 
						|
      look_lia();
 | 
						|
      
 | 
						|
      // r8  = acconto dicembre
 | 
						|
      d->_r8 = _lia->get_real("R4");
 | 
						|
      
 | 
						|
      // r9  = conguaglio prorata
 | 
						|
      d->_r9 = conguaglio;
 | 
						|
    }
 | 
						|
  
 | 
						|
  // aggiunge eventuale satellite per rimborso infraannuale
 | 
						|
  if (di != NULL) d->_arr.add(di);
 | 
						|
 | 
						|
  _descr_arr.add(d);
 | 
						|
}
 | 
						|
 | 
						|
void CG4300_App::describe_consistence(const char* codatt)
 | 
						|
{
 | 
						|
  // controlla eventuali condizioni di conflitto con le normative
 | 
						|
  // per la ditta e crea i messaggi appropriati
 | 
						|
  // tutte le condizioni sono valutate sull'esercizio precedente
 | 
						|
  int pryear = atoi(_year) - 1;
 | 
						|
  TString att = codatt;
 | 
						|
 | 
						|
  _pla->zero();
 | 
						|
  *_pla_anno   = pryear;
 | 
						|
  *_pla_codatt = att;
 | 
						|
      
 | 
						|
  if (_pla->read() == NOERR)
 | 
						|
    {
 | 
						|
      real va  = _pla->get_real("R0");
 | 
						|
 | 
						|
      // 1) consistenza volume d'affari <-> frequenza versamenti
 | 
						|
      // deve essere: trimestrale ammesso solo se < 360.000.000
 | 
						|
      // per servizi, < 1.000.000.000 per altre imprese
 | 
						|
      // a meno che non sia benzinaro che ha diritto comunque
 | 
						|
 | 
						|
      if (_freqviva == "T" && !_isbenzinaro)
 | 
						|
	{
 | 
						|
	  bool err = FALSE;
 | 
						|
	  if (_isservizio)  err = va > SOGLIA_TRIM_SERVIZI;
 | 
						|
	  else              err = va > SOGLIA_TRIM_ALTRE;
 | 
						|
	  if (err)
 | 
						|
	    describe_error("Incoerenza volume affari/frequenza versamenti",
 | 
						|
			   att);
 | 
						|
	}
 | 
						|
    }
 | 
						|
}
 | 
						|
 | 
						|
  
 | 
						|
void CG4300_App::describe_error(const char* err, const char* codatt)
 | 
						|
{
 | 
						|
  _errors.add(new _ErrItem(err,codatt,_nditte->curr().get("CODDITTA")));
 | 
						|
}
 | 
						|
 | 
						|
// ----------------------------------------------------------------
 | 
						|
// Setrows
 | 
						|
// ----------------------------------------------------------------
 | 
						|
 | 
						|
void CG4300_App::set_firm(_DescrItem& d)
 | 
						|
{
 | 
						|
  TString tim_title(80);
 | 
						|
  tim_title << "Liquidazione IVA";
 | 
						|
 | 
						|
  if (d._f1 == 13)
 | 
						|
    tim_title << format(": Riepilogo Annuale %s",(const char*)_year);
 | 
						|
  else
 | 
						|
    {
 | 
						|
      if (d._s3 == "T")
 | 
						|
	tim_title << format(" del %dx Trimestre", d._f1/3);
 | 
						|
      else
 | 
						|
	tim_title << format(" del mese di %s %s", itom(d._f1), 
 | 
						|
			    (const char*)_year); 
 | 
						|
    }
 | 
						|
 | 
						|
  reset_header();
 | 
						|
  set_header(1,"Ditta %s %s@97gStudio@109gData @<@125gPag. @#", 
 | 
						|
	     (const char*)(d._s0), (const char*)(d._s1)); 
 | 
						|
  set_header(2,"");
 | 
						|
  set_header(3,sep);
 | 
						|
  set_header(4,"%s@102gFrequenza %s", 
 | 
						|
	     (const char*)tim_title, 
 | 
						|
	     d._s2 == "T" ? "Trimestrale" : "Mensile");
 | 
						|
  set_header(5,sep);
 | 
						|
  set_header(6,"");  
 | 
						|
  
 | 
						|
  // notify errors if any
 | 
						|
  int j = 0;
 | 
						|
  for (int i = 0; i < _errors.items(); i++)
 | 
						|
    {
 | 
						|
      _ErrItem& s = (_ErrItem&)_errors[i];
 | 
						|
      if (s._att == "ALL" && s._firm == d._s0)
 | 
						|
	{ j++; set_row(i+10, "@5g@b*** %s ***@r", (const char*)s._err); }
 | 
						|
    }
 | 
						|
  if (j) set_auto_ff(TRUE);
 | 
						|
}
 | 
						|
 | 
						|
 | 
						|
void CG4300_App::set_att(_DescrItem& d)
 | 
						|
{
 | 
						|
  // set header
 | 
						|
  TString tim_title(78);
 | 
						|
  TString att_title(48);
 | 
						|
  
 | 
						|
  tim_title << "Liquidazione IVA";
 | 
						|
 | 
						|
  if (d._f1 == 13)
 | 
						|
    {
 | 
						|
      if (d._s4 == "T" && !(d._f2)) // trimestrale e non benzinaro
 | 
						|
	tim_title << format(": Riepilogo Annuale %s",(const char*)_year);
 | 
						|
      else
 | 
						|
	tim_title << format(": Dichiarazione Annuale %s",(const char*)_year);
 | 
						|
    }
 | 
						|
  else
 | 
						|
    {
 | 
						|
      if (d._s4 == "T")
 | 
						|
	tim_title << format(" del %dx Trimestre", d._f1/3);
 | 
						|
      else
 | 
						|
	tim_title << format(" del mese di %s %s", itom(d._f1), 
 | 
						|
			    (const char*)_year); 
 | 
						|
    }
 | 
						|
 | 
						|
  TString tipatt = d._f0 ? "" : format("(att. %d)", d._f0); 
 | 
						|
 | 
						|
  if (d._s3.empty())
 | 
						|
    {
 | 
						|
      att_title = "Riepilogo attivita' ";
 | 
						|
      att_title << d._s2;
 | 
						|
    }
 | 
						|
  else
 | 
						|
    att_title = format("Attivita' %s %s %s", 
 | 
						|
		       (const char*)(d._s2),
 | 
						|
		       (const char*)(d._s3), 
 | 
						|
		       (const char*)tipatt);
 | 
						|
 | 
						|
  reset_header();
 | 
						|
  set_header(1,"Ditta %s %s@97gStudio@109gData @<@125gPag. @#", 
 | 
						|
	     (const char*)(d._s0), (const char*)(d._s1)); 
 | 
						|
  set_header(2,"");
 | 
						|
  set_header(3,sep);
 | 
						|
  set_header(4,"%s@55g%s", (const char*)tim_title, (const char*)att_title);
 | 
						|
  set_header(5,sep);
 | 
						|
  set_header(6,"");
 | 
						|
  
 | 
						|
  // notify errors if any
 | 
						|
  int j = 0;
 | 
						|
  for (int i = 0; i < _errors.items(); i++)
 | 
						|
    {
 | 
						|
      _ErrItem& s = (_ErrItem&)_errors[i];
 | 
						|
      if (d._s2 == s._att && s._firm == d._s0)
 | 
						|
	{ j++; set_row(i+10, "@5g@b*** %s ***@r", (const char*)s._err); }
 | 
						|
    }
 | 
						|
  if (j) set_auto_ff(TRUE);
 | 
						|
}
 | 
						|
 | 
						|
 | 
						|
void CG4300_App::set_plafond(_DescrItem& d)
 | 
						|
{
 | 
						|
  real r1 = d._r0 + d._r1 + d._r2;
 | 
						|
  real r2 = d._r3 + d._r4 + d._r5;
 | 
						|
  real r3 = d._r6 + d._r7 + d._r8;
 | 
						|
 | 
						|
  set_print_zero(TRUE);
 | 
						|
 | 
						|
  set_row(1,"QUADRO RELATIVO ALLA DISPONIBILITA' ED ALL'UTILIZZO "
 | 
						|
	    "MENSILE DEI PLAFOND");
 | 
						|
 | 
						|
  set_row(2,""); set_row(3,"");
 | 
						|
  set_row(4,"Art. 8 1@ix@rcomma lettere a-b@31gDisponibile@48g%r",
 | 
						|
	  &r1);
 | 
						|
  set_row(5,"Utilizzato all'interno@48g%r", &(d._r0));
 | 
						|
  set_row(6,"Utilizzato per l'importazione@48g%r@69gRiporto %r",
 | 
						|
	  &(d._r1), &(d._r2));
 | 
						|
 | 
						|
  set_row(7,"");
 | 
						|
  set_row(8,"Art. 8bis 1@ix@rcomma@31gDisponibile@48g%r",
 | 
						|
	  &r2);
 | 
						|
  set_row(9,"Utilizzato all'interno@48g%r", &(d._r3));
 | 
						|
  set_row(10,"Utilizzato per l'importazione@48g%r@69gRiporto %r",
 | 
						|
	  &(d._r4), &(d._r5));
 | 
						|
 | 
						|
  set_row(11,"");
 | 
						|
  set_row(12,"Art. 9 1@ix@rcomma@31gDisponibile@48g%r",
 | 
						|
	  &r3);
 | 
						|
  set_row(13,"Utilizzato all'interno@48g%r", &(d._r6));
 | 
						|
  set_row(14,"Utilizzato per l'importazione@48g%r@69gRiporto %r",
 | 
						|
	  &(d._r7), &(d._r8));
 | 
						|
 | 
						|
  set_print_zero(FALSE);
 | 
						|
  set_auto_ff();
 | 
						|
}
 | 
						|
 | 
						|
void CG4300_App::set_pim(_DescrItem& d)
 | 
						|
{
 | 
						|
  look_iva(d._s1);
 | 
						|
  d._s2 = _iva->get("S0");
 | 
						|
 | 
						|
  if (d._f0)  // e' il primo
 | 
						|
    {
 | 
						|
      // intestazioncina
 | 
						|
      set_row(1,"Cod.@41gVENDITE@71gCORRISPETTIVI@106gACQUISTI");
 | 
						|
      set_row(2,"IVA Descrizione@30gImponibile@49gImposta@63gImponibile"
 | 
						|
	        "@82gImposta@96gImponibile@115gImposta");
 | 
						|
      set_row(3,"");
 | 
						|
    }
 | 
						|
  set_row(d._f0 ? 4 : 1,"%3s %-20s@25g%r %r@58g%r %r@91g%r %r",
 | 
						|
	  (const char*)d._s1,
 | 
						|
	  (const char*)d._s2,
 | 
						|
	  &(d._r0),
 | 
						|
	  &(d._r1),
 | 
						|
	  &(d._r2),
 | 
						|
	  &(d._r3),
 | 
						|
	  &(d._r4),
 | 
						|
	  &(d._r5));
 | 
						|
}
 | 
						|
 | 
						|
void CG4300_App::set_plm(_DescrItem& d)
 | 
						|
{
 | 
						|
  set_row(1,""); set_row(2,"");
 | 
						|
  set_row(3,"Totale@25g%r %r@58g%r %r@91g%r %r",
 | 
						|
	  &(d._r0),
 | 
						|
	  &(d._r1),
 | 
						|
	  &(d._r2),
 | 
						|
	  &(d._r3),
 | 
						|
	  &(d._r4),
 | 
						|
	  &(d._r5));
 | 
						|
  // totalazzi parziali e generali
 | 
						|
  set_row(4,"di cui per acquisti intracomunitari@107g%r", &(d._r6)); 
 | 
						|
  set_row(5,"");
 | 
						|
  set_row(6,"Totali acquisti indeducibili per art.19@91g%r %r",
 | 
						|
	  &(d._r7), &(d._r8));
 | 
						|
  set_row(7,"");
 | 
						|
 | 
						|
  real tot1 = d._r7 + d._r4; 
 | 
						|
  real tot2 = d._r8 + d._r5; 
 | 
						|
 | 
						|
  set_row(8,"Totale Generale IVA@26g%r %r@58g%r %r@91g%r %r",
 | 
						|
	  &(d._r0),
 | 
						|
	  &(d._r1),
 | 
						|
	  &(d._r2),
 | 
						|
	  &(d._r3),
 | 
						|
	  &tot1,
 | 
						|
	  &tot2);
 | 
						|
}
 | 
						|
 | 
						|
void CG4300_App::set_ptm(_DescrItem& d)
 | 
						|
{
 | 
						|
  if (d._r0.is_zero()  &&  // acq. ammortizz. 
 | 
						|
      d._r1.is_zero()  &&  // IVA acq. ammort.
 | 
						|
      d._r2.is_zero()  &&  // ammort. detr. 6% 
 | 
						|
      d._r3.is_zero()  &&  // IVA ammort detr. 6%
 | 
						|
      d._r4.is_zero()  &&  // acq. beni rivendita
 | 
						|
      d._r5.is_zero()  &&  // IVA acq. beni rivendita
 | 
						|
      d._r6.is_zero()  &&  // acq. leasing
 | 
						|
      d._r7.is_zero()  &&  // IVA acq. leasing
 | 
						|
      d._r8.is_zero()  &&  // cessioni beni ammort.
 | 
						|
      d._r9.is_zero()  &&  // IVA su cessioni ammort.
 | 
						|
      d._r10.is_zero() &&  // tot. esenti IVA
 | 
						|
      d._r11.is_zero() &&  // pro_rata
 | 
						|
      d._arr.items()   == 0)
 | 
						|
    {
 | 
						|
      set_row(1,"");
 | 
						|
      set_auto_ff(TRUE);
 | 
						|
      return;
 | 
						|
    }
 | 
						|
 | 
						|
  set_row(1,"");
 | 
						|
  set_row(2,"");
 | 
						|
  set_row(3,"ALTRI DATI RELATIVI ALLA DICHIARAZIONE@55gimponibile"
 | 
						|
	    "@77gimposta@91gdetrazione");
 | 
						|
  set_row(4,"");
 | 
						|
  
 | 
						|
  int row = 5;
 | 
						|
 | 
						|
  if (! (d._r8.is_zero() && d._r9.is_zero()))
 | 
						|
    set_row(row++, "Cessione beni ammortizzabili@50g%r@69g%r",
 | 
						|
	    &(d._r8), 
 | 
						|
	    &(d._r9));
 | 
						|
  if (! (d._r4.is_zero() && d._r5.is_zero()))
 | 
						|
    set_row(row++, "Acquisto beni destinati alla rivendita@50g%r@69g%r", 
 | 
						|
	    &(d._r4), 
 | 
						|
	    &(d._r5));
 | 
						|
  if (! (d._r0.is_zero() && d._r1.is_zero()))
 | 
						|
    set_row(row++, "Acquisto beni ammortizzabili IVA detraibile@50g%r@69g%r", 
 | 
						|
	    &(d._r0), 
 | 
						|
	    &(d._r1));
 | 
						|
  if (! (d._r6.is_zero() && d._r7.is_zero()))
 | 
						|
    set_row(row++, "Altri beni strumentali acquisiti in leasing@50g%r@69g%r", 
 | 
						|
	    &(d._r6), 
 | 
						|
	    &(d._r7));
 | 
						|
  if (! (d._r2.is_zero() && d._r3.is_zero()))
 | 
						|
    {
 | 
						|
      real rn = d._r2 * real(DETRAZIONE_6PERCENTO);
 | 
						|
      set_row(row++, "Acquisto beni soggetti a detrazione (6%%)"
 | 
						|
	             "@50g%r@69g%r@88g%r", 
 | 
						|
	      &(d._r2), 
 | 
						|
	      &(d._r3),
 | 
						|
	      &rn);
 | 
						|
    }
 | 
						|
  if (!(d._r11.is_zero()))
 | 
						|
    {
 | 
						|
      set_row(row++, "%% PRO-RATA ed IVA non detraibile (%s%%)@69g%r", 
 | 
						|
	      (const char*)(d._s0), 
 | 
						|
	      &(d._r11));
 | 
						|
    }
 | 
						|
  
 | 
						|
  // items vari per dichiarazione annuale
 | 
						|
  for (int i = 0; i < d._arr.items(); i++)
 | 
						|
    {
 | 
						|
      _DescrItem& dd = (_DescrItem&)d._arr[i];
 | 
						|
      set_annual(dd);
 | 
						|
    }
 | 
						|
  
 | 
						|
  // form feed
 | 
						|
  set_auto_ff(TRUE);
 | 
						|
}
 | 
						|
 | 
						|
void CG4300_App::set_grand(_DescrItem& d)
 | 
						|
{
 | 
						|
  set_row(1,""); set_row(2,""); set_row(3,""); set_row(4,"");
 | 
						|
  set_row(5,"@11g@bCALCOLO LIQUIDAZIONE D'IMPOSTA@r");
 | 
						|
  set_row(6,""); int rw = 7;
 | 
						|
  set_row(rw++,"@67gCredito@84gDebito"); set_row(rw++,"");
 | 
						|
  set_row(rw++,"@11gIva sulle operazioni di vendita@75g%r", &(d._r0));
 | 
						|
  set_row(rw++,"@11gRettifiche IVA a debito@75g%r", &(d._r5));
 | 
						|
  set_row(rw++,"@11gIva chiesta a rimborso@75g%r", &(d._r4));
 | 
						|
  real rd = d._r0 + d._r5 + d._r4;
 | 
						|
 | 
						|
  // conguaglio prorata
 | 
						|
  if (d._r9.sign() > 0) 
 | 
						|
    {
 | 
						|
      rd += d._r9;
 | 
						|
      set_row(rw++,"@11gConguaglio pro-rata@75g%r", &(d._r9));
 | 
						|
    }
 | 
						|
 | 
						|
  // debito liq. precedente < 50000
 | 
						|
  if (d._r10 > real(0.0)) 
 | 
						|
    {
 | 
						|
      rd += d._r10;
 | 
						|
      set_row(rw++,"@11gDebito da liquidazione precedente@75g%r", &(d._r10));
 | 
						|
    }
 | 
						|
 
 | 
						|
  set_row(rw++,"@11gRISULTATO@75g%r", &rd);
 | 
						|
  set_row(rw++,"@11gIva sulle operazioni di acquisto@58g%r", &(d._r1));
 | 
						|
 | 
						|
  // credito precedente scorporato dell'acconto
 | 
						|
  d._r7 -= d._r8;
 | 
						|
  set_row(rw++,"@11gCredito precedente@58g%r", &(d._r7));
 | 
						|
 | 
						|
  if (!(d._r8.is_zero()))
 | 
						|
    set_row(rw++,"@11gVersamento acconto dicembre@58g%r", &(d._r8));
 | 
						|
 | 
						|
  set_row(rw++,"@11gRettifiche IVA a credito@58g%r", &(d._r6));
 | 
						|
  real rc = d._r1 + d._r7 + d._r8 + d._r6;
 | 
						|
  
 | 
						|
  // conguaglio prorata
 | 
						|
  if (d._r9.sign() < 0) rc -= d._r9;  
 | 
						|
 | 
						|
  set_row(rw++,"@11gRISULTATO@58g%r", &rc);
 | 
						|
 | 
						|
  // TBI versamenti integrativi e non, e chissa' cos'altro
 | 
						|
 | 
						|
  real iva = rd - rc;
 | 
						|
  char how = iva.sign() < 0 ? 'c' : 'd';
 | 
						|
  iva = abs(iva);
 | 
						|
  iva.round(ROUND_MILLELIRE);
 | 
						|
 | 
						|
  if (how == 'c')
 | 
						|
    {
 | 
						|
      set_row(rw++,"@23gCREDITO ATTUALE@58g%r",&iva);
 | 
						|
    }
 | 
						|
  else
 | 
						|
    {
 | 
						|
      if (d._f0)
 | 
						|
	{
 | 
						|
	  // trimestrale: interesse
 | 
						|
	  set_row(rw++,"@23gIVA DOVUTA@75g%r",&iva);
 | 
						|
	  real ivi = iva * interesse_trimestrale(d._f2);
 | 
						|
	  real ivt = iva + ivi;
 | 
						|
	  ivt.round(ROUND_MILLELIRE); 
 | 
						|
	  set_row(rw++,"@23gInteresse 1.50 %%@75g%r",&ivi);
 | 
						|
 | 
						|
	  if (ivt.is_zero() || ivt >= IVA_DA_RIPORTARE || d._f1)
 | 
						|
	    set_row(rw++,"@23gIVA DA VERSARE@75g%r",&ivt);
 | 
						|
	  else
 | 
						|
	    set_row(rw++,"@23gIVA DA VERSARE@85g0 (%s < 50.000)", 
 | 
						|
		    (const char*)ivt.string("."));
 | 
						|
	}
 | 
						|
      else
 | 
						|
	{
 | 
						|
	  if (iva.is_zero() || iva >= IVA_DA_RIPORTARE || d._f1)	
 | 
						|
	    set_row(rw++,"@23gIVA DA VERSARE@75g%r",&iva);
 | 
						|
	  else
 | 
						|
	    set_row(rw++,"@23gIVA DA VERSARE@85g0 (%s < 50.000)", 
 | 
						|
		    (const char*)iva.string("."));
 | 
						|
	}
 | 
						|
    }
 | 
						|
  
 | 
						|
  // rapportini per rimborso infraannuale
 | 
						|
  if (d._arr.items() > 0)
 | 
						|
    {
 | 
						|
      _DescrItem& di = (_DescrItem&)d._arr[0];
 | 
						|
      
 | 
						|
      set_row(rw++,""); 
 | 
						|
      set_row(rw++,"");
 | 
						|
      set_row(rw++, "    PROSPETTO DI RIMBORSO");
 | 
						|
      set_row(rw++,"");
 | 
						|
 | 
						|
      if (di._f0)
 | 
						|
	{
 | 
						|
	  // esenti
 | 
						|
	  set_row(rw++,"1) Soggetto con quota di operazioni esenti e non"
 | 
						|
		       " imponibili superiore al 50%%");
 | 
						|
 | 
						|
	  real perc = (di._r0/di._r1) * real(100.0);
 | 
						|
 | 
						|
	  TString sep(strlen(REAL_PICTURE)+2); sep.fill('-');
 | 
						|
	  set_row(rw++,"");
 | 
						|
	  set_row(rw++,"@26gTotale operazioni esenti e non imp.@66g%r", 
 | 
						|
		  &(di._r0));
 | 
						|
	  set_row(rw++,"@66g%t  x 100 = %5.2r", &sep, &perc);
 | 
						|
	  set_row(rw++,"@26gVolume di affari lordo@66g%r", &(di._r1));
 | 
						|
	  set_row(rw++,"");
 | 
						|
	}
 | 
						|
      
 | 
						|
      if (di._f1)
 | 
						|
	{
 | 
						|
	  set_row(rw++,"2) Soggetto con acquisti ad aliquota media "
 | 
						|
		       "superiore a quella delle vendite");
 | 
						|
	  TString sep(strlen(REAL_PICTURE)+2); sep.fill('-');
 | 
						|
	  set_row(rw++,"");
 | 
						|
	  set_row(rw++,"@26gTotale imposte sugli acquisti@66g%r", &(di._r5));
 | 
						|
	  set_row(rw++,"@66g%t  x 100 = %5.2r", &sep, &(di._r7));
 | 
						|
	  set_row(rw++,"@26gTotale imponibili sugli acquisti@66g%r", 
 | 
						|
		       &(di._r3));
 | 
						|
	  set_row(rw++,"");
 | 
						|
	  set_row(rw++,"@26gTotale imposte sulle vendite@66g%r", &(di._r4));
 | 
						|
	  set_row(rw++,"@66g%t  x 100 = %5.2r", &sep, &(di._r6));
 | 
						|
	  set_row(rw++,"@26gTotale imponibili sulle vendite@66g%r", &(di._r2));
 | 
						|
	}
 | 
						|
    }
 | 
						|
  set_auto_ff(TRUE);
 | 
						|
}
 | 
						|
 | 
						|
 | 
						|
void CG4300_App::set_annual(_DescrItem& d)
 | 
						|
{
 | 
						|
  // chiamata internamente a set_pims 
 | 
						|
  int row = get_maxrow()+1; 
 | 
						|
  if (d._f0 & IS_PRORATA)
 | 
						|
    {
 | 
						|
      set_print_zero(TRUE);
 | 
						|
      set_row(row++,"");
 | 
						|
      set_row(row++,"CALCOLO DELLA PERCENTUALE DI INDETRAIBILITA'");
 | 
						|
      set_row(row++,"");
 | 
						|
      set_row(row++,"Operazioni esenti riga B1@30g%r", &(d._r1));
 | 
						|
      set_row(row++,"Operazioni esenti riga B2@30g%r", &(d._r4));
 | 
						|
      set_row(row++,"Operazioni esenti riga B3@30g%r", &(d._r5));
 | 
						|
      set_row(row++,"Volume d'affari   riga B4@30g%r", &(d._r0));
 | 
						|
      set_row(row++,"Indetraibilita'     @40g%2.2r%%", &(d._r2));
 | 
						|
      if (!(d._r3.is_zero()))
 | 
						|
	{
 | 
						|
	  real ccc = abs(d._r3);
 | 
						|
	  set_row(row++,"Conguaglio a %s@30g%r", d._r3.sign() < 0 ? "credito" :
 | 
						|
		  "debito", &ccc);
 | 
						|
	}
 | 
						|
      set_print_zero(FALSE);
 | 
						|
    }
 | 
						|
}
 | 
						|
 | 
						|
 | 
						|
void CG4300_App::set_ventila(_DescrItem& d)
 | 
						|
{
 | 
						|
  if (d._arr.items() == 0 || d._r0.is_zero())
 | 
						|
    return;
 | 
						|
 | 
						|
  set_row(1,"@54gPROSPETTO VENTILAZIONE");
 | 
						|
  set_row(2,"");
 | 
						|
  set_row(3,""); 
 | 
						|
  set_row(4,"@10gTotale acquisti destinati alla rivendita@55g%r",
 | 
						|
	  &(d._r0));
 | 
						|
  set_row(5,"@10gTotale dei corrispettivi da ventilare@55g%r",
 | 
						|
	  &(d._r1));
 | 
						|
  real m = d._r1 / d._r0;
 | 
						|
  set_row(6,"@10gMoltiplicatore@59g%3.9r",&m);
 | 
						|
  set_row(7,"");
 | 
						|
  set_row(8,"@10gCod.");
 | 
						|
  set_row(9,"@10gIVA@17gDescrizione@48gAcquisti"
 | 
						|
	  "@65gImponibile vendite@89gImposta vendite");
 | 
						|
  set_row(10,"");
 | 
						|
  int row = 11;
 | 
						|
  real t1, t2, t3;
 | 
						|
  for(int i = 0; i < d._arr.items(); i++)
 | 
						|
    {
 | 
						|
      _vDesc& vd = (_vDesc&)d._arr[i];
 | 
						|
      look_iva(vd._codiva);
 | 
						|
      TString s0 = _iva->get("S0");
 | 
						|
      set_row(row+i,"@8g%5s@17g%s@41g%r@68g%r@89g%r",
 | 
						|
	      (const char*)vd._codiva,
 | 
						|
	      (const char*)s0,
 | 
						|
	      &(vd._acq),
 | 
						|
	      &(vd._vnd),
 | 
						|
	      &(vd._viv));
 | 
						|
      t1 += vd._acq;
 | 
						|
      t2 += vd._vnd;
 | 
						|
      t3 += vd._viv;
 | 
						|
    }
 | 
						|
  set_row(row+i+1,"");
 | 
						|
  set_row(row+i+2,"@10gTotale@41g%r@68g%r@89g%r",
 | 
						|
	  &t1, &t2, &t3);
 | 
						|
  set_auto_ff(TRUE);
 | 
						|
}
 | 
						|
 | 
						|
void CG4300_App::set_regagr(_DescrItem& d)
 | 
						|
{
 | 
						|
  set_print_zero(TRUE);
 | 
						|
 | 
						|
  set_row(1,"@50gPROSPETTO REGIME AGRICOLO");
 | 
						|
  set_row(2,"");
 | 
						|
 | 
						|
  real ca = d._r0 + d._r1 + d._r2;
 | 
						|
  real an = d._r4 + d._r6;
 | 
						|
 | 
						|
  set_row(3,  "Cessioni in regime agricolo (Tabella A/I)@54g%r",&ca);
 | 
						|
  set_row(4,  "");
 | 
						|
  set_row(5,  "Cessioni non in regime agricolo@54g%r",&(d._r5));
 | 
						|
  set_row(6,  "");
 | 
						|
  set_row(7,  "Acquisti in regime agricolo@54g%r",&(d._r3));
 | 
						|
  set_row(8,  "");
 | 
						|
  set_row(9,  "Acquisti non in regime agricolo@54g%r",&an);
 | 
						|
  set_row(10, "... di cui beni ammortizzabili@54g%r",&(d._r6));
 | 
						|
 | 
						|
  set_auto_ff(TRUE);
 | 
						|
  set_print_zero(FALSE);
 | 
						|
}
 | 
						|
 | 
						|
void CG4300_App::set_viaggio(_DescrItem& d)
 | 
						|
{
 | 
						|
  // the longest & stronzest
 | 
						|
 | 
						|
  // Nel corso della scrittura di questa funzione
 | 
						|
  // Berlusconi + Fini + Bossi hanno vinto le elezioni
 | 
						|
  // Il moderno imprenditore illuminato dalla fiamma tricolore
 | 
						|
  // ha rincoglionito gli imbecilli con la TV
 | 
						|
  // Che la rovina, la galera e la giustizia rossa 
 | 
						|
  // possano aver campo su tutto
 | 
						|
  
 | 
						|
  set_print_zero(TRUE);
 | 
						|
 | 
						|
  set_row(1,"");
 | 
						|
  set_row(2,"@54gRIEPILOGO 74 TER");
 | 
						|
  set_row(3,"");
 | 
						|
  set_row(4,"Ammontare dei corrispettivi relativi a viaggi eseguiti"
 | 
						|
	    " interamente nella CEE .....................@100g%r", &(d._r0));
 | 
						|
  set_row(5,"Ammontare dei corrispettivi relativi a viaggi misti (dentro"
 | 
						|
	    " e fuori CEE) ......................... @100g%r", &(d._r1));
 | 
						|
  set_row(6,"Ammontare dei corrispettivi relativi a viaggi eseguiti"
 | 
						|
	    " interamente fuori CEE ..................... @100g%r", &(d._r2));
 | 
						|
 | 
						|
  real tc = d._r0 + d._r1 + d._r2;
 | 
						|
 | 
						|
  set_row(7,"");
 | 
						|
  set_row(8,"@56gTotale corrispettivi@100g%r", &tc);
 | 
						|
  set_row(9,"");
 | 
						|
 | 
						|
  set_row(10,"Ammontare dei costi relativi a viaggi interamente"
 | 
						|
	     " svolti nella CEE ............................... @100g%r", 
 | 
						|
	  &(d._r3));
 | 
						|
  set_row(11,"Ammontare dei costi relativi a viaggi misti (per la"
 | 
						|
	     " parte CEE) ................................... @100g%r", 
 | 
						|
	  &(d._r4));
 | 
						|
  set_row(12,"Ammontare dei costi relativi a viaggi interamente"
 | 
						|
	     " svolti fuori CEE ............................... @100g%r", 
 | 
						|
	  &(d._r5));
 | 
						|
  set_row(13,"Ammontare dei costi relativi a viaggi misti (per la"
 | 
						|
	     " parte fuori CEE) .............................@100g%r",
 | 
						|
	  &(d._r6));
 | 
						|
 | 
						|
  real tco = d._r3 + d._r4 + d._r5 + d._r6;
 | 
						|
 | 
						|
  set_row(14,"");
 | 
						|
  set_row(15,"@64gTotale costi@100g%r", &tco);
 | 
						|
 | 
						|
  set_row(16,"");
 | 
						|
  set_row(17,"DETERMINAZIONE CORRISPETTIVI IMPONIBILI "
 | 
						|
	     "RELATIVI A VIAGGI MISTI");
 | 
						|
  set_row(18,"");
 | 
						|
 | 
						|
 | 
						|
  // la bella frazioncina della percentuale di ripartizione
 | 
						|
  TString tmp(d._r4.string(REAL_PICTURE)); tmp.ltrim(); 
 | 
						|
  TString up = tmp;
 | 
						|
  up << " x 100";
 | 
						|
  TString dn = tmp;
 | 
						|
  tmp = d._r6.string(REAL_PICTURE); tmp.ltrim();
 | 
						|
  dn << " + " << tmp;
 | 
						|
  int ln = max(up.len(), dn.len()) + 2;
 | 
						|
  TString den(ln); den.fill('-');
 | 
						|
  up.center_just(ln); dn.center_just(ln);
 | 
						|
  real rip = d._r7 * 100.0; rip.round(2);
 | 
						|
 
 | 
						|
  // la bella frazioncina degli imponibili viaggi misti
 | 
						|
  TString tmp2 = d._r1.string(REAL_PICTURE); tmp2.ltrim(); 
 | 
						|
  TString up2 = tmp;
 | 
						|
  up2 << " x " << rip.string(2);
 | 
						|
  TString dn2 = "100";
 | 
						|
  int ln2 = max(up2.len(), 3) + 2;
 | 
						|
  TString den2(ln2); den2.fill('-');
 | 
						|
  up2.center_just(ln2); dn2.center_just(ln2);
 | 
						|
 | 
						|
  // la gran frazionazza centrata e stupenda
 | 
						|
  int tot  = 35 + ln + ln2; 
 | 
						|
  int rem1 = (100 - tot)/2; if (rem1 < 0) rem1 = 0;
 | 
						|
  int pos1 = rem1 + 13;
 | 
						|
  int rem2 = pos1+ den.len() + 11;
 | 
						|
  int pos2 = rem2 + 20;
 | 
						|
 | 
						|
  real cim = d._r1 * d._r7; cim.round(ROUND_LIRA);
 | 
						|
 | 
						|
  set_row(19,format("@%dg%%t@%dg%%t", pos1, pos2),
 | 
						|
	  &up, &up2);
 | 
						|
  set_row(20,format("@%dgPerc. rip. = %%t = %%5.2r; @%dg"
 | 
						|
		    "Imp. viaggi misti = %%t = @100g%%r", 
 | 
						|
		    rem1, rem2),
 | 
						|
	  &den, &rip, &den2, &cim);
 | 
						|
  set_row(21,format("@%dg%%t@%dg%%t", pos1, pos2),
 | 
						|
	  &dn, &dn2);
 | 
						|
 | 
						|
  real tmr = d._r0 + cim;
 | 
						|
 | 
						|
  // whew, come dicono su Topolino
 | 
						|
 | 
						|
  tmp = d._r0.string(REAL_PICTURE); tmp.ltrim();
 | 
						|
  up = "("; up << tmp << " + "; 
 | 
						|
  tmp = cim.string(REAL_PICTURE); tmp.ltrim();
 | 
						|
  up << tmp << ")";
 | 
						|
  den.fill('.',59-up.len());
 | 
						|
  set_row(23,"Ammontare dei corrispettivi imponibili@40g%t %t@100g%r", 
 | 
						|
	  &up, &den, &tmr);
 | 
						|
 | 
						|
  // se e' l'annuale non ha senso altro
 | 
						|
  if (d._f1) return;
 | 
						|
 | 
						|
  tmr = d._r3 + d._r4;
 | 
						|
  tmp = d._r3.string(REAL_PICTURE); tmp.ltrim();
 | 
						|
  up = "("; up << tmp << " + "; 
 | 
						|
  tmp = d._r4.string(REAL_PICTURE); tmp.ltrim();
 | 
						|
  up << tmp << ")";
 | 
						|
  den.fill('.',59-up.len());
 | 
						|
  set_row(24,"Ammontare dei costi deducibili@40g%t %t@100g%r", 
 | 
						|
	  &up, &den, &tmr);
 | 
						|
  den.fill('.',60);
 | 
						|
  set_row(25,"Credito di costo precedente @40g%t@100g%r", &den, &(d._r8));
 | 
						|
  
 | 
						|
  real bil = d._r0 - tmr - d._r8;
 | 
						|
  
 | 
						|
  bool iscred = bil.sign() < 0;
 | 
						|
  bil = abs(bil);
 | 
						|
 | 
						|
  tmp = d._r0.string(REAL_PICTURE); tmp.ltrim();
 | 
						|
  up = "["; up << tmp << " - (";
 | 
						|
  tmp = tmr.string(REAL_PICTURE); tmp.ltrim();
 | 
						|
  up << tmp << " + ";
 | 
						|
  tmp = d._r8.string(REAL_PICTURE); tmp.ltrim();
 | 
						|
  up << tmp << ")]";
 | 
						|
  den.fill('.',59-up.len());
 | 
						|
 | 
						|
  set_row(27,"");
 | 
						|
  if (iscred) 
 | 
						|
    {
 | 
						|
      set_row(26,"");
 | 
						|
      set_row(iscred ? 28 : 26,"%s@40g%t %t@100g%r", 
 | 
						|
	      iscred ? "CREDITO DI COSTO " : "Base imponibile lorda",
 | 
						|
	      &up, &den, &bil);
 | 
						|
    }
 | 
						|
  else
 | 
						|
    {
 | 
						|
      real aliva  = aliquota_agvia();
 | 
						|
      real dovuta = bil * aliva; dovuta.round(ROUND_LIRA);
 | 
						|
      aliva *= 100.0; 
 | 
						|
      
 | 
						|
      tmp = bil.string(REAL_PICTURE); tmp.ltrim(); 
 | 
						|
      up = tmp;
 | 
						|
      up << " x " << aliva.string(5,2);
 | 
						|
      dn = "100";
 | 
						|
      ln = max(up.len(), 3) + 2;
 | 
						|
      den.fill('-',ln);
 | 
						|
      up.center_just(ln); dn.center_just(ln);
 | 
						|
      
 | 
						|
      tmp.fill('.', 59 - den.len());
 | 
						|
 | 
						|
      set_row(28,"@40g%t",&up);
 | 
						|
      set_row(29,"IVA A DEBITO@40g%t %t@100g%r", &den, &tmp, &dovuta);
 | 
						|
      set_row(30,"@40g%t", &dn);
 | 
						|
    }
 | 
						|
 | 
						|
  set_print_zero(FALSE);
 | 
						|
  set_auto_ff(TRUE);
 | 
						|
}
 | 
						|
 | 
						|
void CG4300_App::set_acconto_p(_DescrItem& d)
 | 
						|
{
 | 
						|
  set_print_zero(TRUE);
 | 
						|
 | 
						|
  set_row(1,"%t@8g%t",&(d._s0), &(d._s1));
 | 
						|
  if (d._f2) set_row(1,"@50g@b*** ERRORE: liquidazione anno precedente "
 | 
						|
		     "non presente ***@r");
 | 
						|
  else
 | 
						|
    {
 | 
						|
      if (d._f0) // base anno in corso
 | 
						|
	{
 | 
						|
	  if (d._f1) // stampa base di calcolo
 | 
						|
	    {
 | 
						|
	      real bc = d._r0; 
 | 
						|
	      if (bc.sign() < 0) 
 | 
						|
		{
 | 
						|
		  bc = abs(bc);
 | 
						|
		  set_row(1,"@73g%r@86g%r@119g%s", &bc, &d._r1, 
 | 
						|
			  d._f3 ? "Si" : "No"); 
 | 
						|
		}
 | 
						|
	      else
 | 
						|
		{
 | 
						|
		  set_row(1,"@55g%r@86g%r@119g%s", &bc, &(d._r1), 
 | 
						|
			  d._f3 ? "Si" : "No"); 
 | 
						|
		}
 | 
						|
	    }
 | 
						|
	  else
 | 
						|
	    {
 | 
						|
	      set_row(1,"@51g%r@75g%s", &(d._r1), d._f3 ? "Si" : "No"); 
 | 
						|
	    }
 | 
						|
	}
 | 
						|
      else
 | 
						|
	{
 | 
						|
	  if (d._f1) // stampa base di calcolo
 | 
						|
	    {
 | 
						|
	      set_row(1,"@57g%r@85g%r", &(d._r0), &(d._r1));
 | 
						|
	    }
 | 
						|
	  else
 | 
						|
	    {
 | 
						|
	      set_row(1,"@85g%r",&(d._r1));
 | 
						|
	    }
 | 
						|
	}
 | 
						|
    }
 | 
						|
  set_print_zero(FALSE);
 | 
						|
}
 | 
						|
 | 
						|
void CG4300_App::set_acchead_p(_DescrItem& d)
 | 
						|
{
 | 
						|
  reset_header();
 | 
						|
  set_header(1,"Gestione IVA@97gStudio@109gData @<@125gPag. @#");
 | 
						|
  set_header(3,sep);
 | 
						|
  
 | 
						|
  if (d._f0) // base anno in corso
 | 
						|
    {
 | 
						|
      set_header(2,"@40gCALCOLO ACCONTI IVA DICEMBRE "
 | 
						|
	         "1994 (base anno in corso)");
 | 
						|
      if (d._f1) // stampa base calcolo
 | 
						|
	{
 | 
						|
	  set_header(4,"@51g------- Base di calcolo -------");
 | 
						|
	  set_header(5,"@1gDitta@8gDenominazione@55gDebito@73gCredito"
 | 
						|
		       "@86gACCONTO calcolato@109gLiq. differita"); 
 | 
						|
	  set_header(6,sep);
 | 
						|
	  set_header(7,"");   
 | 
						|
	}
 | 
						|
      else 
 | 
						|
	{
 | 
						|
	  set_header(4,"@1gDitta@8gDenominazione@51gACCONTO calcolato"
 | 
						|
		     "@75gLiq. differita");
 | 
						|
	  set_header(5,sep);
 | 
						|
	  set_header(6,"");   
 | 
						|
	}   
 | 
						|
    }
 | 
						|
  else
 | 
						|
    {
 | 
						|
      set_header(5,sep);
 | 
						|
      set_header(6,"");   
 | 
						|
      if (d._f1)
 | 
						|
	set_header(4,"@1gDitta@8gDenominazione@57gBase di calcolo"
 | 
						|
		   "@85gACCONTO calcolato");
 | 
						|
      else
 | 
						|
	set_header(4,"@1gDitta@8gDenominazione@85gACCONTO calcolato");
 | 
						|
    }
 | 
						|
}
 |