2001-04-30 14:22:43 +00:00
|
|
|
|
#include <applicat.h>
|
|
|
|
|
#include <printer.h>
|
|
|
|
|
#include <recarray.h>
|
|
|
|
|
#include <utility.h>
|
|
|
|
|
|
2004-03-16 20:40:21 +00:00
|
|
|
|
#include "../cg/cglib01.h"
|
2001-04-30 14:22:43 +00:00
|
|
|
|
#include "ce3.h"
|
|
|
|
|
#include "ce3200a.h"
|
|
|
|
|
#include "ce3200.h"
|
|
|
|
|
#include "celib.h"
|
2006-09-20 15:48:33 +00:00
|
|
|
|
#include "ammce.h"
|
2001-04-30 14:22:43 +00:00
|
|
|
|
#include "cespi.h"
|
|
|
|
|
#include "movce.h"
|
2006-09-20 15:48:33 +00:00
|
|
|
|
#include "salce.h"
|
2001-04-30 14:22:43 +00:00
|
|
|
|
|
|
|
|
|
//-----FORM--------------------------------------------------------------------------------------//
|
|
|
|
|
|
|
|
|
|
class TForm_schedacesp : public TForm_cespiti
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
virtual bool validate(TForm_item &cf, TToken_string &s);
|
2006-09-21 09:59:33 +00:00
|
|
|
|
void set_testata() {set_header(1,true);}
|
|
|
|
|
void set_pedata() {set_footer(1,false); set_footer(1,true);}
|
2001-04-30 14:22:43 +00:00
|
|
|
|
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())
|
|
|
|
|
{
|
2001-06-25 10:41:20 +00:00
|
|
|
|
case F_CATCESP:
|
|
|
|
|
case F_DESCRCAT:
|
|
|
|
|
return ditta_cespiti().on_category_event(o, e, jolly); //ultimo ritrovato per selezionare la categoria (da celib)
|
2001-04-30 14:22:43 +00:00
|
|
|
|
case F_SITFISC :
|
|
|
|
|
if (e == fe_close)
|
|
|
|
|
{
|
|
|
|
|
if (!get_bool(F_SITFISC) && !get_bool(F_SITCIV) && !get_bool(F_SITGEST))
|
2003-05-12 15:03:40 +00:00
|
|
|
|
return error_box(TR("Selezionare almeno una delle Situazioni da stampare"));
|
2001-04-30 14:22:43 +00:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
default: break;
|
|
|
|
|
}
|
2006-09-21 09:59:33 +00:00
|
|
|
|
return true;
|
2001-04-30 14:22:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//-----SKELETON APPLICATION------------------------------------------------------------------------------------------//
|
|
|
|
|
|
|
|
|
|
class TStampa_storico : public TSkeleton_application
|
|
|
|
|
{
|
|
|
|
|
TStampastorico_mask * _mask;
|
|
|
|
|
TForm_schedacesp * _form;
|
2006-09-20 15:48:33 +00:00
|
|
|
|
TEsercizi_contabili _esc;
|
2001-04-30 14:22:43 +00:00
|
|
|
|
bool _ammvenduti;
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
virtual bool create();
|
|
|
|
|
virtual bool destroy();
|
|
|
|
|
virtual void main_loop();
|
|
|
|
|
|
2006-09-20 15:48:33 +00:00
|
|
|
|
void print_header(const int tipo);
|
2001-04-30 14:22:43 +00:00
|
|
|
|
void print_footer();
|
2006-09-20 15:48:33 +00:00
|
|
|
|
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);
|
2001-04-30 14:22:43 +00:00
|
|
|
|
|
|
|
|
|
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));
|
2004-03-16 20:40:21 +00:00
|
|
|
|
TDate inies(_mask->get(F_INIZIO_ES));
|
2001-04-30 14:22:43 +00:00
|
|
|
|
--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:
|
2003-05-12 15:03:40 +00:00
|
|
|
|
_form->find_field('H', odd_page, FF_SITUAZIONE).set(TR("fiscale"));
|
2001-04-30 14:22:43 +00:00
|
|
|
|
break;
|
|
|
|
|
case 2:
|
2003-05-12 15:03:40 +00:00
|
|
|
|
_form->find_field('H', odd_page, FF_SITUAZIONE).set(TR("civilistica"));
|
2001-04-30 14:22:43 +00:00
|
|
|
|
break;
|
|
|
|
|
case 3:
|
2003-05-12 15:03:40 +00:00
|
|
|
|
_form->find_field('H', odd_page, FF_SITUAZIONE).set(TR("gestionale"));
|
2001-04-30 14:22:43 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
_form->set_testata();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TStampa_storico::print_footer()
|
|
|
|
|
{
|
|
|
|
|
_form->set_pedata();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-09-20 15:48:33 +00:00
|
|
|
|
bool TStampa_storico::stampa_primo_saldo(const int tipo)
|
2001-04-30 14:22:43 +00:00
|
|
|
|
{
|
2006-09-20 15:48:33 +00:00
|
|
|
|
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);
|
2006-09-22 10:59:14 +00:00
|
|
|
|
const TDate& datainies = _esc[esercizio].inizio();
|
|
|
|
|
const TDate& datafines = _esc[esercizio].fine();
|
2006-09-20 15:48:33 +00:00
|
|
|
|
const int numele = recsalce.get_int("NUMELE");
|
2001-04-30 14:22:43 +00:00
|
|
|
|
|
|
|
|
|
TPrint_section& section1 = _form->get_rigauno(); //preparazione stampa riga dettaglio 1
|
2006-09-22 10:59:14 +00:00
|
|
|
|
section1.reset_fields();
|
2006-09-20 15:48:33 +00:00
|
|
|
|
const TDate dtcomp = cespite().get_date("DTCOMP");
|
2001-04-30 14:22:43 +00:00
|
|
|
|
section1.reset();
|
2006-09-20 15:48:33 +00:00
|
|
|
|
bool devo_stampare = false;
|
|
|
|
|
|
2006-09-22 10:59:14 +00:00
|
|
|
|
if ((datainies >= dtcomp && numele > 0) || (esercizio == _esc.date2esc(dtcomp) && numele == 0)) //datasaldo >= data acquisto
|
2001-04-30 14:22:43 +00:00
|
|
|
|
{
|
2006-09-22 10:59:14 +00:00
|
|
|
|
section1.find_field(FF_DATAUNO).set(datainies);
|
2003-05-12 15:03:40 +00:00
|
|
|
|
section1.find_field(FF_DESCRUNO).set(TR("Ripresa saldi"));
|
2006-09-20 15:48:33 +00:00
|
|
|
|
section1.find_field(FF_NUMELEUNO).set(recsalce.get(SALCE_NUMELE));
|
2001-04-30 14:22:43 +00:00
|
|
|
|
real sum = recsalce.get_real("CSTO");
|
2008-03-11 16:59:33 +00:00
|
|
|
|
if (tipo == 2)
|
|
|
|
|
sum -= recsalce.get_real("VNONAMMC");
|
|
|
|
|
else
|
2001-04-30 14:22:43 +00:00
|
|
|
|
sum -= recsalce.get_real("VNONAMM");
|
2008-03-11 16:59:33 +00:00
|
|
|
|
sum -= recsalce.get_real("VNONAMM06");
|
2001-04-30 14:22:43 +00:00
|
|
|
|
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());
|
2006-09-20 15:48:33 +00:00
|
|
|
|
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();
|
2001-04-30 14:22:43 +00:00
|
|
|
|
sum = recammce.get_real("QNOR");
|
|
|
|
|
sum += recammce.get_real("QANT");
|
|
|
|
|
sum += recammce.get_real("QACC");
|
|
|
|
|
section1.find_field(FF_FONDIUNO).set(sum.string());
|
2006-09-20 15:48:33 +00:00
|
|
|
|
devo_stampare |= sum != ZERO;
|
2001-04-30 14:22:43 +00:00
|
|
|
|
}
|
2006-09-22 10:59:14 +00:00
|
|
|
|
else //cespite dopo l'esercizio selezionato ma che presenta un saldo precedente (improponibile)
|
2001-04-30 14:22:43 +00:00
|
|
|
|
{
|
2006-09-22 10:59:14 +00:00
|
|
|
|
section1.find_field(FF_DESCRUNO).set(TR("Data acq. errata"));
|
|
|
|
|
devo_stampare = true;
|
2001-04-30 14:22:43 +00:00
|
|
|
|
}
|
2006-09-20 15:48:33 +00:00
|
|
|
|
|
|
|
|
|
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;
|
2001-04-30 14:22:43 +00:00
|
|
|
|
|
2006-09-20 15:48:33 +00:00
|
|
|
|
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;
|
2001-04-30 14:22:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-09-20 15:48:33 +00:00
|
|
|
|
//parte principale del programma
|
|
|
|
|
void TStampa_storico::print_percespite(const int tipo)
|
2001-04-30 14:22:43 +00:00
|
|
|
|
{
|
2006-09-21 09:59:33 +00:00
|
|
|
|
bool ho_stampato_qualcosa = false;
|
2001-04-30 14:22:43 +00:00
|
|
|
|
print_header(tipo); // stampa l'intestazione;tipo si riferisce al tipo di situazione da stampare
|
|
|
|
|
print_footer(); //stampa data e pagenumber
|
|
|
|
|
|
2006-09-20 15:48:33 +00:00
|
|
|
|
const int esercizio_finale = _mask->get_int(F_ESERCIZIO);
|
2001-04-30 14:22:43 +00:00
|
|
|
|
const long pos = _form->cursor()->pos(); //memorizza posizione cursore
|
2006-09-22 10:59:14 +00:00
|
|
|
|
|
|
|
|
|
//scelta dei tipi ammort. su AMMMV
|
|
|
|
|
TRectype& recammmv = _form->cursor()->curr(LF_AMMMV);
|
2006-09-20 15:48:33 +00:00
|
|
|
|
bool continua = _form->cursor()->is_first_match(LF_AMMMV);
|
2001-04-30 14:22:43 +00:00
|
|
|
|
while (recammmv.get_int("TPAMM") != tipo && continua)
|
2006-09-20 15:48:33 +00:00
|
|
|
|
continua = _form->cursor()->next_match(LF_AMMMV);
|
2001-04-30 14:22:43 +00:00
|
|
|
|
|
2006-09-22 10:59:14 +00:00
|
|
|
|
//resetta il totale elementi,valore,fondo amm.
|
|
|
|
|
TPrint_section& sectot = _form->get_rigatot();
|
2001-04-30 14:22:43 +00:00
|
|
|
|
sectot.find_field(FF_TOTELEM).set("");
|
|
|
|
|
sectot.find_field(FF_TOTVALORE).set("");
|
|
|
|
|
sectot.find_field(FF_TOTAMMO).set("");
|
|
|
|
|
|
2006-09-22 10:59:14 +00:00
|
|
|
|
TRectype& recmovce = _form->cursor()->curr(LF_MOVCE);
|
2001-04-30 14:22:43 +00:00
|
|
|
|
TRelation& rel = *_form->relation();
|
|
|
|
|
|
2006-09-20 15:48:33 +00:00
|
|
|
|
//per prima cosa stampa il saldo iniziale primordiale
|
|
|
|
|
ho_stampato_qualcosa = stampa_primo_saldo(tipo);
|
2006-07-11 13:10:51 +00:00
|
|
|
|
|
2006-09-20 15:48:33 +00:00
|
|
|
|
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;
|
2001-04-30 14:22:43 +00:00
|
|
|
|
|
2006-09-20 15:48:33 +00:00
|
|
|
|
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;
|
2001-04-30 14:22:43 +00:00
|
|
|
|
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));
|
2006-09-21 09:59:33 +00:00
|
|
|
|
ho_stampato_qualcosa = true;
|
2001-04-30 14:22:43 +00:00
|
|
|
|
}
|
|
|
|
|
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));
|
2006-09-20 15:48:33 +00:00
|
|
|
|
ho_stampato_qualcosa = true;
|
2001-04-30 14:22:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} while (rel.next_match(LF_MOVCE));
|
|
|
|
|
|
2006-09-20 15:48:33 +00:00
|
|
|
|
}
|
2001-04-30 14:22:43 +00:00
|
|
|
|
|
2006-09-20 15:48:33 +00:00
|
|
|
|
//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)..
|
2001-04-30 14:22:43 +00:00
|
|
|
|
if (ho_stampato_qualcosa)
|
2006-09-20 15:48:33 +00:00
|
|
|
|
{
|
|
|
|
|
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
|
|
|
|
|
}
|
|
|
|
|
|
2001-04-30 14:22:43 +00:00
|
|
|
|
*_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);
|
2006-09-21 09:59:33 +00:00
|
|
|
|
cursore.setfilter(filtro,true);
|
2001-04-30 14:22:43 +00:00
|
|
|
|
|
|
|
|
|
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();
|
2006-09-21 09:59:33 +00:00
|
|
|
|
cursore.freeze(false);
|
2001-04-30 14:22:43 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2004-03-16 20:40:21 +00:00
|
|
|
|
|
2001-04-30 14:22:43 +00:00
|
|
|
|
int ce3200(int argc, char* argv[])
|
|
|
|
|
{
|
|
|
|
|
TStampa_storico a;
|
2006-09-20 15:48:33 +00:00
|
|
|
|
a.run(argc,argv,TR("Scheda storica cespite"));
|
2001-04-30 14:22:43 +00:00
|
|
|
|
return 0;
|
2008-03-11 16:59:33 +00:00
|
|
|
|
}
|