Files correlati : Ricompilazione Demo : [ ] Commento :controllo riga_uno migliorato git-svn-id: svn://10.65.10.50/trunk@14340 c028cbd2-c16b-5b4b-a496-9718f37d4682
		
			
				
	
	
		
			643 lines
		
	
	
		
			21 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			643 lines
		
	
	
		
			21 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
#include <applicat.h>
 | 
						||
#include <form.h>
 | 
						||
#include <printer.h>
 | 
						||
#include <recarray.h>
 | 
						||
#include <utility.h>
 | 
						||
 | 
						||
#include "../cg/cglib01.h"
 | 
						||
#include "ce3.h"
 | 
						||
#include "ce3200a.h"
 | 
						||
#include "ce3200.h"
 | 
						||
#include "celib.h"
 | 
						||
#include "ammce.h"
 | 
						||
#include "cespi.h"
 | 
						||
#include "movce.h"
 | 
						||
#include "salce.h"
 | 
						||
 | 
						||
//-----FORM--------------------------------------------------------------------------------------//
 | 
						||
 | 
						||
class TForm_schedacesp : public TForm_cespiti
 | 
						||
{
 | 
						||
 | 
						||
public:
 | 
						||
  virtual bool validate(TForm_item &cf, TToken_string &s);
 | 
						||
  void set_testata() {set_header(1,true);}
 | 
						||
  void set_pedata() {set_footer(1,false); set_footer(1,true);}
 | 
						||
  TForm_schedacesp();
 | 
						||
  TPrint_section& get_rigauno() {return section('B', first_page);}
 | 
						||
  TPrint_section& get_rigadue() {return section('B', odd_page);}
 | 
						||
  TPrint_section& get_rigadueven() {return section('B', even_page);}
 | 
						||
  TPrint_section& get_rigatre() {return section('B', last_page);}
 | 
						||
  TPrint_section& get_rigatot() {return section('F', odd_page);}
 | 
						||
  TPrint_section& get_footer() {return section('F', first_page);}
 | 
						||
  virtual ~TForm_schedacesp();
 | 
						||
};
 | 
						||
  
 | 
						||
TForm_schedacesp::TForm_schedacesp() :TForm_cespiti ("ce3200a")            //costruttore con relazione..
 | 
						||
{
 | 
						||
} 
 | 
						||
 | 
						||
TForm_schedacesp::~TForm_schedacesp()
 | 
						||
{ 
 | 
						||
}
 | 
						||
 | 
						||
bool TForm_schedacesp::validate(TForm_item &cf, TToken_string &s)
 | 
						||
{
 | 
						||
  return TForm_cespiti::validate(cf,s);   //richiama la validate standard della classe genitore (TForm_cespiti)
 | 
						||
}
 | 
						||
 | 
						||
//-----AUTOMASK---------------------------------------------------------------------------------//
 | 
						||
  
 | 
						||
class TStampastorico_mask : public TAutomask
 | 
						||
{
 | 
						||
  TRelation * _rel;
 | 
						||
  TCursor * _cur;
 | 
						||
 | 
						||
protected:
 | 
						||
  bool on_field_event(TOperable_field& o, TField_event e, long jolly);
 | 
						||
public:
 | 
						||
 | 
						||
  TStampastorico_mask();
 | 
						||
  
 | 
						||
  virtual ~TStampastorico_mask(){};
 | 
						||
};
 | 
						||
  
 | 
						||
TStampastorico_mask::TStampastorico_mask() :TAutomask ("ce3200a")
 | 
						||
{
 | 
						||
  ditta_cespiti().init_mask(* this);
 | 
						||
}  
 | 
						||
  
 | 
						||
bool TStampastorico_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
 | 
						||
{ 
 | 
						||
  switch (o.dlg())
 | 
						||
  {
 | 
						||
  case F_CATCESP:
 | 
						||
  case F_DESCRCAT:
 | 
						||
    return ditta_cespiti().on_category_event(o, e, jolly);      //ultimo ritrovato per selezionare la categoria (da celib)
 | 
						||
  case F_SITFISC :
 | 
						||
    if (e == fe_close)
 | 
						||
    {
 | 
						||
      if (!get_bool(F_SITFISC) && !get_bool(F_SITCIV) && !get_bool(F_SITGEST))
 | 
						||
        return error_box(TR("Selezionare almeno una delle Situazioni da stampare"));
 | 
						||
    }
 | 
						||
    break;
 | 
						||
  default: break;
 | 
						||
  }  
 | 
						||
  return true;
 | 
						||
}
 | 
						||
 | 
						||
//-----SKELETON APPLICATION------------------------------------------------------------------------------------------//
 | 
						||
 | 
						||
class TStampa_storico : public TSkeleton_application
 | 
						||
{
 | 
						||
  TStampastorico_mask * _mask;
 | 
						||
  TForm_schedacesp * _form;
 | 
						||
	TEsercizi_contabili _esc; 
 | 
						||
  bool _ammvenduti;
 | 
						||
 | 
						||
protected:
 | 
						||
  virtual bool create();
 | 
						||
  virtual bool destroy();
 | 
						||
  virtual void main_loop();
 | 
						||
 | 
						||
  void print_header(const int tipo);
 | 
						||
  void print_footer();
 | 
						||
  void print_percespite(const int tipo);
 | 
						||
 | 
						||
	const TRectype& cespite() const { return _form->cursor()->curr(LF_CESPI);} 
 | 
						||
  bool stampa_primo_saldo(const int tipo);
 | 
						||
	bool stampa_ammortamenti(const int tipo, const int esc_ini, const int esc_fin);
 | 
						||
	bool stampa_rigatre(const TRectype& recammce);
 | 
						||
 | 
						||
public:
 | 
						||
  TStampa_storico() {}
 | 
						||
};
 | 
						||
 | 
						||
 | 
						||
bool TStampa_storico::create()
 | 
						||
{
 | 
						||
  open_files(LF_CESPI, LF_SALCE, LF_AMMCE, LF_MOVCE, LF_AMMMV, 0);
 | 
						||
  _mask = new TStampastorico_mask;
 | 
						||
  _form = new TForm_schedacesp();
 | 
						||
  
 | 
						||
  return TSkeleton_application::create();
 | 
						||
}
 | 
						||
 | 
						||
bool TStampa_storico::destroy()
 | 
						||
{
 | 
						||
  delete _mask;
 | 
						||
  delete _form;
 | 
						||
  return TSkeleton_application::destroy();
 | 
						||
}
 | 
						||
 | 
						||
 | 
						||
void TStampa_storico::print_header( const int tipo )
 | 
						||
{  
 | 
						||
  _form->find_field('H', odd_page, FF_CODDITTA).set(_mask->get(F_CODDITTA));
 | 
						||
  _form->find_field('H', odd_page, FF_DESCRDITTA).set(_mask->get(F_DESCRDITTA));
 | 
						||
  _form->find_field('H', odd_page, FF_GRUPPO).set(_mask->get(F_GRUPPO));
 | 
						||
  _form->find_field('H', odd_page, FF_D_GRUPPO).set(_mask->get(F_D_GRUPPO));                 
 | 
						||
  _form->find_field('H', odd_page, FF_SPECIE).set(_mask->get(F_SPECIE));
 | 
						||
  _form->find_field('H', odd_page, FF_D_SPECIE).set(_mask->get(F_D_SPECIE));
 | 
						||
  TDate inies(_mask->get(F_INIZIO_ES));
 | 
						||
  --inies;
 | 
						||
  _form->find_field('H', odd_page, FF_DATASIT).set(inies.string());
 | 
						||
  
 | 
						||
  switch(tipo)      //in base al(ai) tipo(i) di situazione cambia una riga dell'header
 | 
						||
  {
 | 
						||
  case 1:
 | 
						||
    _form->find_field('H', odd_page, FF_SITUAZIONE).set(TR("fiscale"));
 | 
						||
    break;
 | 
						||
  case 2:
 | 
						||
    _form->find_field('H', odd_page, FF_SITUAZIONE).set(TR("civilistica"));
 | 
						||
    break;
 | 
						||
  case 3:
 | 
						||
    _form->find_field('H', odd_page, FF_SITUAZIONE).set(TR("gestionale"));
 | 
						||
    break;
 | 
						||
  }  
 | 
						||
  _form->set_testata();
 | 
						||
}
 | 
						||
 | 
						||
void TStampa_storico::print_footer()
 | 
						||
{
 | 
						||
  _form->set_pedata();
 | 
						||
}
 | 
						||
 | 
						||
 | 
						||
bool TStampa_storico::stampa_primo_saldo(const int tipo)
 | 
						||
{        
 | 
						||
  TLocalisamfile salce(LF_SALCE);
 | 
						||
	const TString16 id = cespite().get(CESPI_IDCESPITE);
 | 
						||
	salce.put(SALCE_IDCESPITE, id);
 | 
						||
	int err = salce.read(_isgteq);
 | 
						||
	//se non lo trova
 | 
						||
	if (err != NOERR || salce.get(SALCE_IDCESPITE) != id)
 | 
						||
		return false;
 | 
						||
 | 
						||
	//gli serve il saldo primordiale di tipo 1 del cespite;e' il primo che trova,quindi non ci va..
 | 
						||
	//..nient'altro
 | 
						||
  const TRectype& recsalce = salce.curr();
 | 
						||
	const int esercizio = recsalce.get_int(SALCE_CODES);
 | 
						||
  const TDate& datainies = _esc[esercizio].inizio();
 | 
						||
	const TDate& datafines = _esc[esercizio].fine();
 | 
						||
  const int numele = recsalce.get_int("NUMELE");
 | 
						||
  
 | 
						||
  TPrint_section& section1 = _form->get_rigauno();          //preparazione stampa riga dettaglio 1
 | 
						||
	section1.reset_fields();
 | 
						||
  const TDate dtcomp = cespite().get_date("DTCOMP");
 | 
						||
  section1.reset();
 | 
						||
	bool devo_stampare = false;
 | 
						||
	
 | 
						||
  if ((datainies >= dtcomp && numele > 0) || (esercizio == _esc.date2esc(dtcomp) && numele == 0))    //datasaldo >= data acquisto
 | 
						||
  {
 | 
						||
    section1.find_field(FF_DATAUNO).set(datainies);
 | 
						||
    section1.find_field(FF_DESCRUNO).set(TR("Ripresa saldi"));
 | 
						||
    section1.find_field(FF_NUMELEUNO).set(recsalce.get(SALCE_NUMELE));
 | 
						||
    real sum = recsalce.get_real("CSTO");
 | 
						||
    sum -= recsalce.get_real("VNONAMM");
 | 
						||
    sum += recsalce.get_real("RIV75");
 | 
						||
    sum += recsalce.get_real("RIV83");
 | 
						||
    sum += recsalce.get_real("RIV90");
 | 
						||
    sum += recsalce.get_real("RIV91");
 | 
						||
    sum += recsalce.get_real("RIVGF");
 | 
						||
    section1.find_field(FF_VALOREUNO).set(sum.string());
 | 
						||
		devo_stampare = sum != ZERO;
 | 
						||
 | 
						||
		TLocalisamfile ammce(LF_AMMCE);
 | 
						||
		ammce.put(AMMCE_IDCESPITE, id);
 | 
						||
		ammce.put(AMMCE_CODES, esercizio);
 | 
						||
		ammce.put(AMMCE_TPSALDO, 1);
 | 
						||
		ammce.put(AMMCE_TPAMM, tipo);
 | 
						||
		if (ammce.read() != NOERR)
 | 
						||
			ammce.zero();
 | 
						||
    const TRectype& recammce = ammce.curr();
 | 
						||
    sum = recammce.get_real("QNOR");
 | 
						||
    sum += recammce.get_real("QANT");
 | 
						||
    sum += recammce.get_real("QACC");
 | 
						||
    section1.find_field(FF_FONDIUNO).set(sum.string());
 | 
						||
		devo_stampare |= sum != ZERO;
 | 
						||
  }
 | 
						||
  else   //cespite dopo l'esercizio selezionato ma che presenta un saldo precedente (improponibile)
 | 
						||
  {
 | 
						||
		section1.find_field(FF_DESCRUNO).set(TR("Data acq. errata"));
 | 
						||
		devo_stampare = true;
 | 
						||
  }
 | 
						||
  
 | 
						||
	if (devo_stampare)
 | 
						||
	{
 | 
						||
		section1.update(); 
 | 
						||
		for (word i = 0; i < section1.height(); i++)        // stampa le righe tipo 1 (solo nel caso che dtmov != dtcomp)
 | 
						||
			printer().print(section1.row(i));                 // in caso contrario passa semplicemente alle righe tipo 2
 | 
						||
	}
 | 
						||
 | 
						||
	return devo_stampare;
 | 
						||
}
 | 
						||
 | 
						||
 | 
						||
bool TStampa_storico::stampa_rigatre(const TRectype& recammce)
 | 
						||
{
 | 
						||
  const TDate dataelim = cespite().get_date(CESPI_DTALIEN);
 | 
						||
 | 
						||
  const int esercizio = recammce.get_int(AMMCE_CODES);
 | 
						||
  const TDate& datafinees = _esc[esercizio].fine();
 | 
						||
 | 
						||
	bool scrivo_unarigatre = false;
 | 
						||
 | 
						||
  if (dataelim.empty() || dataelim > datafinees)            // qui ci va l'if con la condizione di scrittura riga3
 | 
						||
  {                                                                     
 | 
						||
    real aliqnort = recammce.get_real("PNOR");
 | 
						||
    real aliqantt = recammce.get_real("PANT");
 | 
						||
    real aliqacct = recammce.get_real("PACC");
 | 
						||
    
 | 
						||
    real qnort = recammce.get_real("QNOR");
 | 
						||
    real qantt = recammce.get_real("QANT");
 | 
						||
    real qacct = recammce.get_real("QACC");
 | 
						||
		   
 | 
						||
    TPrint_section& section3 = _form->get_rigatre();
 | 
						||
		section3.find_field(FF_TPNOR).set(aliqnort.string());
 | 
						||
		section3.find_field(FF_TPANT).set(aliqantt.string());
 | 
						||
		section3.find_field(FF_TPACC).set(aliqacct.string());
 | 
						||
		section3.find_field(FF_TQNOR).set(qnort.string());
 | 
						||
		section3.find_field(FF_TQANT).set(qantt.string());
 | 
						||
		section3.find_field(FF_TQACC).set(qacct.string());
 | 
						||
                                                      //controllo sulla scrittura di pi<70> righe causa diverse aliquote
 | 
						||
    int r = 1;
 | 
						||
      if (aliqnort != ZERO || qnort != ZERO)
 | 
						||
      {                           
 | 
						||
        section3.find_field(FF_TPNOR).show();
 | 
						||
        section3.find_field(FF_TPNOR).y() = r;            
 | 
						||
        section3.find_field(FF_TALINOR).show();
 | 
						||
        section3.find_field(FF_TALINOR).y() = r;
 | 
						||
        section3.find_field(FF_TQNOR).show();
 | 
						||
        section3.find_field(FF_TQNOR).y() = r;
 | 
						||
        r++;
 | 
						||
        scrivo_unarigatre = true;
 | 
						||
      }
 | 
						||
      else
 | 
						||
      {
 | 
						||
        section3.find_field(FF_TPNOR).hide();
 | 
						||
        section3.find_field(FF_TALINOR).hide();
 | 
						||
        section3.find_field(FF_TQNOR).hide();
 | 
						||
      }
 | 
						||
      if (aliqantt != ZERO || qantt != ZERO)
 | 
						||
      {                           
 | 
						||
        section3.find_field(FF_TPANT).show();
 | 
						||
        section3.find_field(FF_TPANT).y() = r;
 | 
						||
        section3.find_field(FF_TALIANT).show();
 | 
						||
        section3.find_field(FF_TALIANT).y() = r;
 | 
						||
        section3.find_field(FF_TQANT).show();
 | 
						||
        section3.find_field(FF_TQANT).y() = r;
 | 
						||
        r++;
 | 
						||
        scrivo_unarigatre = true;
 | 
						||
      }
 | 
						||
      else
 | 
						||
      {
 | 
						||
        section3.find_field(FF_TPANT).hide();
 | 
						||
        section3.find_field(FF_TALIANT).hide();
 | 
						||
        section3.find_field(FF_TQANT).hide();
 | 
						||
      }
 | 
						||
      if (aliqacct != ZERO || qacct != ZERO)
 | 
						||
      {                             
 | 
						||
        section3.find_field(FF_TPACC).show();
 | 
						||
        section3.find_field(FF_TPACC).y() = r;
 | 
						||
        section3.find_field(FF_TALIACC).show();
 | 
						||
        section3.find_field(FF_TALIACC).y() = r;
 | 
						||
        section3.find_field(FF_TQACC).show();
 | 
						||
        section3.find_field(FF_TQACC).y() = r;
 | 
						||
        r++;
 | 
						||
        scrivo_unarigatre = true;
 | 
						||
      }
 | 
						||
      else
 | 
						||
      {
 | 
						||
        section3.find_field(FF_TPACC).hide();
 | 
						||
        section3.find_field(FF_TALIACC).hide();
 | 
						||
        section3.find_field(FF_TQACC).hide();
 | 
						||
      }
 | 
						||
    
 | 
						||
    if (scrivo_unarigatre)                        //stampa la riga3 solo se ha trovato almeno una cosa da stampare
 | 
						||
    {
 | 
						||
      _form->find_field('B', last_page, FF_DATASIT).set(datafinees.string());
 | 
						||
    
 | 
						||
      section3.update();
 | 
						||
      for (int i = 0; i < r ; i++)               // stampa riga tipo 3
 | 
						||
        printer().print(section3.row(i));
 | 
						||
    }  
 | 
						||
  }
 | 
						||
  
 | 
						||
	return scrivo_unarigatre;
 | 
						||
} 
 | 
						||
 | 
						||
 | 
						||
bool TStampa_storico::stampa_ammortamenti(const int tipo, int esc_ini, int esc_fin)
 | 
						||
{
 | 
						||
	bool ho_stampato_qualcosa = false;
 | 
						||
  if (esc_ini <= 0)
 | 
						||
		esc_ini = _esc.first();
 | 
						||
	if (esc_fin <=0)
 | 
						||
		esc_fin = _esc.last();
 | 
						||
 | 
						||
	TLocalisamfile ammce(LF_AMMCE);
 | 
						||
	TRectype& recammce = ammce.curr();
 | 
						||
	//attenzione!NON va preso l'ultimo esercizio x' servono ammortamenti finali
 | 
						||
	for (int e = esc_ini; e != esc_fin; e = _esc.next(e))
 | 
						||
	{
 | 
						||
		recammce.put(AMMCE_IDCESPITE, cespite().get(CESPI_IDCESPITE));
 | 
						||
		recammce.put(AMMCE_CODES, e);
 | 
						||
		recammce.put(AMMCE_TPSALDO, 2);
 | 
						||
		recammce.put(AMMCE_TPAMM, tipo);
 | 
						||
		if (ammce.read() == NOERR)
 | 
						||
			ho_stampato_qualcosa |= stampa_rigatre(recammce);
 | 
						||
	}
 | 
						||
	return ho_stampato_qualcosa;
 | 
						||
}
 | 
						||
 | 
						||
 | 
						||
//parte principale del programma
 | 
						||
void TStampa_storico::print_percespite(const int tipo)
 | 
						||
{ 
 | 
						||
  bool ho_stampato_qualcosa = false;
 | 
						||
  print_header(tipo);    // stampa l'intestazione;tipo si riferisce al tipo di situazione da stampare
 | 
						||
  print_footer();        //stampa data e pagenumber
 | 
						||
  
 | 
						||
  const int esercizio_finale = _mask->get_int(F_ESERCIZIO);
 | 
						||
  const long pos = _form->cursor()->pos();                       //memorizza posizione cursore
 | 
						||
  
 | 
						||
  //scelta dei tipi ammort. su AMMMV
 | 
						||
  TRectype& recammmv = _form->cursor()->curr(LF_AMMMV);
 | 
						||
  bool continua = _form->cursor()->is_first_match(LF_AMMMV);
 | 
						||
  while (recammmv.get_int("TPAMM") != tipo && continua)
 | 
						||
		continua = _form->cursor()->next_match(LF_AMMMV);  
 | 
						||
 | 
						||
	//resetta il totale elementi,valore,fondo amm. 
 | 
						||
  TPrint_section& sectot = _form->get_rigatot();
 | 
						||
  sectot.find_field(FF_TOTELEM).set("");                       
 | 
						||
  sectot.find_field(FF_TOTVALORE).set("");
 | 
						||
  sectot.find_field(FF_TOTAMMO).set("");
 | 
						||
  
 | 
						||
  TRectype& recmovce = _form->cursor()->curr(LF_MOVCE);
 | 
						||
  TRelation& rel = *_form->relation();
 | 
						||
 | 
						||
	//per prima cosa stampa il saldo iniziale primordiale
 | 
						||
	ho_stampato_qualcosa = stampa_primo_saldo(tipo);
 | 
						||
 | 
						||
	TEsercizi_contabili esc;
 | 
						||
	int esercizio_stampato = 0;
 | 
						||
 | 
						||
	//poi stampa le righe dei movimenti (stampa riga 2)
 | 
						||
  if (rel.is_first_match(LF_MOVCE)) 
 | 
						||
  {     
 | 
						||
    const TDate& inies = esc[esercizio_finale].inizio();  
 | 
						||
    do
 | 
						||
    { 		
 | 
						||
      const TDate datamov = rel.curr(LF_MOVCE).get_date("DTMOV");
 | 
						||
      if (datamov >= inies)
 | 
						||
				break;
 | 
						||
      
 | 
						||
			const int esc_mov = esc.date2esc(datamov);
 | 
						||
			//se e' cambiato l'esercizio nelle datemov (i mov sono ordinati per data dalla relazione..
 | 
						||
			//..sul form) -> deve stampare gli ammortamenti (righe tre) prima di procedere con i..
 | 
						||
			//..movimenti del nuovo esercizio!!!!
 | 
						||
			if (esc_mov != esercizio_stampato)
 | 
						||
			{
 | 
						||
				ho_stampato_qualcosa |= stampa_ammortamenti(tipo, esercizio_stampato, esc_mov);
 | 
						||
				esercizio_stampato = esc_mov;
 | 
						||
			}
 | 
						||
 | 
						||
 | 
						||
      bool ammven = false;  
 | 
						||
      if (_ammvenduti)                                             // caso in cui la ditta ha "ammort. su venduti" = SI
 | 
						||
      {                                                            // controlla su %tmc se il movimento <20> una vendita
 | 
						||
        TString16 tipomov = recmovce.get("CODMOV");
 | 
						||
        const TRectype& tmc = cache().get("%TMC" , tipomov);
 | 
						||
        ammven = tmc.get_bool("B4");
 | 
						||
      } 
 | 
						||
      
 | 
						||
        real aliqnor = recammmv.get_real("PENOR");
 | 
						||
        real aliqant = recammmv.get_real("PEANT");
 | 
						||
        real aliqacc = recammmv.get_real("PEACC");
 | 
						||
        
 | 
						||
      if (ammven)                                                     // se <20> un movimento di vendita...
 | 
						||
      {          
 | 
						||
        TPrint_section& section2ven = _form->get_rigadueven();  
 | 
						||
          
 | 
						||
        if (_form->cursor()->curr(LF_MOVCE).get_char("SEGNO")=='-')   //controlla se c'<27> il - in movce
 | 
						||
        {
 | 
						||
          section2ven.find_field(FF_SEGNO).set("-1");
 | 
						||
        } 
 | 
						||
        else  
 | 
						||
        {
 | 
						||
          section2ven.find_field(FF_SEGNO).set("1");
 | 
						||
        }
 | 
						||
          
 | 
						||
        int r = 1;
 | 
						||
        if (aliqnor != ZERO)
 | 
						||
        {                           
 | 
						||
          section2ven.find_field(FF_VPENOR).show();
 | 
						||
          section2ven.find_field(FF_VPENOR).y() = r+1;            
 | 
						||
          section2ven.find_field(FF_VALINOR).show();
 | 
						||
          section2ven.find_field(FF_VALINOR).y() = r+1;
 | 
						||
          section2ven.find_field(FF_VQNOR).show();
 | 
						||
          section2ven.find_field(FF_VQNOR).y() = r+1;
 | 
						||
          r++;
 | 
						||
        }
 | 
						||
        else
 | 
						||
        {
 | 
						||
          section2ven.find_field(FF_VPENOR).hide();
 | 
						||
          section2ven.find_field(FF_VALINOR).hide();
 | 
						||
          section2ven.find_field(FF_VQNOR).hide();
 | 
						||
        }
 | 
						||
        if (aliqant != ZERO)
 | 
						||
        {                           
 | 
						||
          section2ven.find_field(FF_VPEANT).show();
 | 
						||
          section2ven.find_field(FF_VPEANT).y() = r+1;
 | 
						||
          section2ven.find_field(FF_VALIANT).show();
 | 
						||
          section2ven.find_field(FF_VALIANT).y() = r+1;
 | 
						||
          section2ven.find_field(FF_VQANT).show();
 | 
						||
          section2ven.find_field(FF_VQANT).y() = r+1;
 | 
						||
          r++;
 | 
						||
        }
 | 
						||
        else
 | 
						||
        {
 | 
						||
          section2ven.find_field(FF_VPEANT).hide();
 | 
						||
          section2ven.find_field(FF_VALIANT).hide();
 | 
						||
          section2ven.find_field(FF_VQANT).hide();
 | 
						||
        }
 | 
						||
        if (aliqacc != ZERO)
 | 
						||
        {                             
 | 
						||
          section2ven.find_field(FF_VPEACC).show();
 | 
						||
          section2ven.find_field(FF_VPEACC).y() = r+1;
 | 
						||
          section2ven.find_field(FF_VALIACC).show();
 | 
						||
          section2ven.find_field(FF_VALIACC).y() = r+1;
 | 
						||
          section2ven.find_field(FF_VQACC).show();
 | 
						||
          section2ven.find_field(FF_VQACC).y() = r+1;
 | 
						||
          r++;
 | 
						||
        }
 | 
						||
        else
 | 
						||
        {
 | 
						||
          section2ven.find_field(FF_VPEACC).hide();
 | 
						||
          section2ven.find_field(FF_VALIACC).hide();
 | 
						||
          section2ven.find_field(FF_VQACC).hide();
 | 
						||
        }
 | 
						||
          
 | 
						||
        section2ven.update();
 | 
						||
        for (int i = 0; i < r; i++)               // stampa le righe 2 con i movimenti vendita
 | 
						||
          printer().print(section2ven.row(i));
 | 
						||
        ho_stampato_qualcosa = true;
 | 
						||
      }
 | 
						||
      else                                                           // se <20> un movimento NON di vendita...
 | 
						||
      { 
 | 
						||
        TPrint_section& section2 = _form->get_rigadue();
 | 
						||
        
 | 
						||
        if (_form->cursor()->curr(LF_MOVCE).get_char("SEGNO")=='-')   //controlla se c'<27> il - in movce (es. sono le rettifiche su acquisti)
 | 
						||
        {
 | 
						||
          section2.find_field(FF_SEGNO).set("-1");
 | 
						||
        } 
 | 
						||
        else  
 | 
						||
        {
 | 
						||
          section2.find_field(FF_SEGNO).set("1");
 | 
						||
        }
 | 
						||
                                                         //decide quante righe stampare in base al numero di aliquote presenti
 | 
						||
        int r = 1;
 | 
						||
        if (aliqnor != ZERO)
 | 
						||
        {                           
 | 
						||
          section2.find_field(FF_PENOR).show();
 | 
						||
          section2.find_field(FF_PENOR).y() = r;            
 | 
						||
          section2.find_field(FF_ALINOR).show();
 | 
						||
          section2.find_field(FF_ALINOR).y() = r;
 | 
						||
          section2.find_field(FF_QNOR).show();
 | 
						||
          section2.find_field(FF_QNOR).y() = r;
 | 
						||
          r++;
 | 
						||
        }
 | 
						||
        else
 | 
						||
        {
 | 
						||
          section2.find_field(FF_PENOR).hide();
 | 
						||
          section2.find_field(FF_ALINOR).hide();
 | 
						||
          section2.find_field(FF_QNOR).hide();
 | 
						||
        }
 | 
						||
        if (aliqant != ZERO)
 | 
						||
        {                           
 | 
						||
          section2.find_field(FF_PEANT).show();
 | 
						||
          section2.find_field(FF_PEANT).y() = r;
 | 
						||
          section2.find_field(FF_ALIANT).show();
 | 
						||
          section2.find_field(FF_ALIANT).y() = r;
 | 
						||
          section2.find_field(FF_QANT).show();
 | 
						||
          section2.find_field(FF_QANT).y() = r;
 | 
						||
          r++;
 | 
						||
        }
 | 
						||
        else
 | 
						||
        {
 | 
						||
          section2.find_field(FF_PEANT).hide();
 | 
						||
          section2.find_field(FF_ALIANT).hide();
 | 
						||
          section2.find_field(FF_QANT).hide();
 | 
						||
        }
 | 
						||
        if (aliqacc != ZERO)
 | 
						||
        {                             
 | 
						||
          section2.find_field(FF_PEACC).show();
 | 
						||
          section2.find_field(FF_PEACC).y() = r;
 | 
						||
          section2.find_field(FF_ALIACC).show();
 | 
						||
          section2.find_field(FF_ALIACC).y() = r;
 | 
						||
          section2.find_field(FF_QACC).show();
 | 
						||
          section2.find_field(FF_QACC).y() = r;
 | 
						||
          r++;
 | 
						||
        }
 | 
						||
        else
 | 
						||
        {
 | 
						||
          section2.find_field(FF_PEACC).hide();
 | 
						||
          section2.find_field(FF_ALIACC).hide();
 | 
						||
          section2.find_field(FF_QACC).hide();
 | 
						||
        }  
 | 
						||
            
 | 
						||
        section2.update();        
 | 
						||
        for (int i = 0; i < r; i++)               // stampa le righe con tutti i movimenti (righe tipo 2)        
 | 
						||
          printer().print(section2.row(i));
 | 
						||
        ho_stampato_qualcosa = true;
 | 
						||
      } 
 | 
						||
 | 
						||
         
 | 
						||
    } while (rel.next_match(LF_MOVCE)); 
 | 
						||
    
 | 
						||
  }		
 | 
						||
 | 
						||
	//ammortamenti conclusivi (da stampare anche in assenza di movimenti)
 | 
						||
	ho_stampato_qualcosa |= stampa_ammortamenti(tipo, esercizio_stampato, esercizio_finale); 
 | 
						||
 | 
						||
	//controlla se ha stampato qualcosa (riga1, righe2, riga3)..
 | 
						||
  if (ho_stampato_qualcosa)
 | 
						||
  {
 | 
						||
    sectot.update();
 | 
						||
    for (word i = 0; i < sectot.height(); i++)           //..e in caso affermativo stampa riga totale
 | 
						||
      printer().print(sectot.row(i));
 | 
						||
		printer().formfeed();          //salta una pagina alla fine della scheda
 | 
						||
  }
 | 
						||
   
 | 
						||
  *_form->cursor() = pos;           //riposiziona il cursore
 | 
						||
}
 | 
						||
 | 
						||
 | 
						||
void TStampa_storico::main_loop()
 | 
						||
{ 
 | 
						||
  _mask->set(F_SITFISC,"X");
 | 
						||
  while (_mask->run() == K_ENTER)
 | 
						||
  { 
 | 
						||
    TRectype rec(LF_CESPI);
 | 
						||
    TString filtro;
 | 
						||
    TCursor& cursore = *_form->cursor();
 | 
						||
    const int esercizio = _mask->get_int(F_ESERCIZIO);        //controlla il booleano _ammvenduti nell'esercizio corrente
 | 
						||
    TString80 key; key.format("%04d",esercizio);
 | 
						||
    const TRectype& cce = cache().get("CCE", key); 
 | 
						||
    _ammvenduti = cce.get_bool("B3");
 | 
						||
    
 | 
						||
    const int r = _mask->get_int(F_TIPOSTAMPA);     //in base al tipo di stampa selezionato setta il cursore
 | 
						||
    switch (r)
 | 
						||
    {
 | 
						||
    case 0:
 | 
						||
      cursore.setkey(1);                             // setta la chiave (nel caso si fosse scelta in precedenza la 2)
 | 
						||
      if (!_mask->field(F_CODCESP).empty())
 | 
						||
        rec.put("IDCESPITE", _mask->get(F_CODCESP));
 | 
						||
      filtro.format("(CODCGRA==%d)&&(CODSPA==\"%s\")", _mask->get_int(F_GRUPPO), (const char *) _mask->get(F_SPECIE));
 | 
						||
      break;
 | 
						||
          
 | 
						||
    case 1:
 | 
						||
      cursore.setkey(2);                            // setta la chiave 2      
 | 
						||
      rec.put("CODCGRA", _mask->get_int(F_GRUPPO));
 | 
						||
      rec.put("CODSPA", _mask->get(F_SPECIE));
 | 
						||
      if (!_mask->field(F_CATCESP).empty())
 | 
						||
        rec.put("CODCAT", _mask->get_int(F_CATCESP));
 | 
						||
      break;
 | 
						||
      
 | 
						||
    case 2:                                           
 | 
						||
      cursore.setkey(1);
 | 
						||
      filtro.format("(CODCGRA==%d)&&(CODSPA==\"%s\")", _mask->get_int(F_GRUPPO), (const char *) _mask->get(F_SPECIE)); 
 | 
						||
      if (!_mask->field(F_IMPCESP).empty())
 | 
						||
        filtro << format("&&(CODIMP==\"%s\")", (const char *) _mask->get(F_IMPCESP));   //estende il filtro con il campo CODIMP
 | 
						||
      break;
 | 
						||
    default:
 | 
						||
      break;
 | 
						||
    }
 | 
						||
    cursore.setregion(rec,rec,0x2);  
 | 
						||
    cursore.setfilter(filtro,true);
 | 
						||
    
 | 
						||
    long num = cursore.items();
 | 
						||
    cursore.freeze();
 | 
						||
    printer().open();
 | 
						||
 | 
						||
    for (cursore=0; cursore.pos()<num; ++cursore)
 | 
						||
    { 
 | 
						||
      if (_mask->get_bool(F_SITFISC))
 | 
						||
        print_percespite(1);  
 | 
						||
      if (_mask->get_bool(F_SITCIV))
 | 
						||
        print_percespite(2);  
 | 
						||
      if (_mask->get_bool(F_SITGEST))
 | 
						||
        print_percespite(3);  
 | 
						||
    }
 | 
						||
    printer().close();
 | 
						||
    cursore.freeze(false);
 | 
						||
  } 
 | 
						||
}
 | 
						||
  
 | 
						||
int ce3200(int argc, char* argv[])
 | 
						||
{ 
 | 
						||
  TStampa_storico a;
 | 
						||
  a.run(argc,argv,TR("Scheda storica cespite"));
 | 
						||
  return 0;
 | 
						||
} |