campo-sirio/cg/cg1600.cpp

4967 lines
143 KiB
C++
Raw Normal View History

#include <assoc.h>
#include <config.h>
#include <mask.h>
#include <printapp.h>
#include <progind.h>
#include <sort.h>
#include <tabutil.h>
#include <utility.h>
#include <comuni.h>
#include <nditte.h>
#include <unloc.h>
#include <clifo.h>
#include <pconti.h>
#include <anagr.h>
#include <rmov.h>
#include <mov.h>
#include <saldi.h>
#include "cglib.h"
#include "cg1.h"
#include "cg1600.h"
bool our_handler (TMask_field & f,KEY k);
class Anno_es : public TObject
{
TDate _inizio, _fine;
TToken_string *_str;
public:
long anno();
TDate inizio();
TDate fine() ;
Anno_es(long anno, TDate& inizio, TDate& fine);
~Anno_es() { delete _str; }
};
TDate Anno_es::inizio()
{
_inizio = _str->get(1);
return _inizio;
}
TDate Anno_es::fine()
{
_fine = _str->get(2);
return _fine;
}
long Anno_es::anno()
{
return _str->get_int(0);
}
Anno_es::Anno_es(long anno, TDate& inizio, TDate& fine)
{
_str = new TToken_string(35);
_inizio = inizio;
_fine = fine;
_str->add(anno); _str->add(_inizio.string()); _str->add(_fine.string());
}
class Anni_es : public TAssoc_array
{
TTable * _tabesc;
public:
void add(long anno, TDate& inizio, TDate& fine);
void aggiungi_anno(long anno, TDate& inizio, TDate& fine);
Anno_es * trova(long anno, TDate& inizio, TDate& fine);
Anni_es();
~Anni_es() { delete _tabesc; }
};
Anni_es::Anni_es()
{
_tabesc = new TTable (TAB_ESC);
}
void Anni_es::add(long annoe, TDate& in, TDate& fin)
{
TString key = format("%04ld", annoe);
Anno_es anno(annoe, in, fin);
TAssoc_array::add(key, anno);
}
Anno_es * Anni_es::trova(long annoe, TDate& in, TDate& fin)
{
TString key = format("%04ld", annoe);
Anno_es *anno = (Anno_es*) objptr ((const char*) key);
if (anno == NULL) {
in = ""; fin = "";
}
else {
in = anno->inizio();
fin = anno->fine();
}
return anno;
}
void Anni_es::aggiungi_anno(long annoese, TDate& inizio, TDate& fine)
{
TString dep;
TString key = format("%04ld", annoese);
Anno_es * anno;
if (!is_key((const char *) key))
{
_tabesc->curr().zero();
dep = format ("%04d",annoese);
_tabesc->curr().put("CODTAB", (const char*) dep);
_tabesc->read();
if (_tabesc->bad())
_tabesc->curr().zero();
inizio = _tabesc->curr().get_date("D0");
fine = _tabesc->curr().get_date("D1");
anno = new Anno_es(annoese, inizio, fine);
TAssoc_array::add(key, anno);
}
else
anno = trova (annoese, inizio, fine);
}
class _riga_sez_opp : public TObject
{
TToken_string * _str;
public:
int gruppo() { return atoi(_str->get(0)); }
int conto() { return atoi(_str->get(1)); }
int sottoc() { return atoi(_str->get(2)); }
const char * sezione () { return _str->get(3); }
const char * lettera () { return _str->get(4); }
const char * num_rom () { return _str->get(5); }
int numero () { return atoi(_str->get(6)); }
real saldo_conto ();
real saldo_conto_raf();
void incrementa_saldo(real& nuovo_saldo,real& nuovo_saldo_raf);
_riga_sez_opp(int g, int c, long s,
const char * sezione, const char * lettera,
const char * num_rom, int num, real& saldo, real& saldo_raf);
~_riga_sez_opp();
};
real _riga_sez_opp::saldo_conto ()
{
real r(_str->get(7));
return r;
}
real _riga_sez_opp::saldo_conto_raf ()
{
real r(_str->get(8));
return r;
}
void _riga_sez_opp::incrementa_saldo(real& sld,real& sld_raf)
{
real sld_prec = saldo_conto();
real sld_prec_raf = saldo_conto_raf();
sld_prec += sld;
sld_prec_raf += sld_raf;
_str->add(sld_prec.string(), 7);
_str->add(sld_prec_raf.string(), 8);
}
_riga_sez_opp::_riga_sez_opp(int g, int c, long s,
const char * sezione, const char * lettera,
const char * num_rom, int num, real& saldo, real& saldo_raf)
{
_str = new TToken_string(30);
_str->add(format("%d",g));
_str->add(format("%d",c));
_str->add(format("%ld",s));
_str->add(sezione);
_str->add(lettera);
_str->add(num_rom);
_str->add(format("%d",num));
_str->add(saldo.string());
_str->add(saldo_raf.string());
}
_riga_sez_opp::~_riga_sez_opp()
{
delete _str;
}
class Righe_sez_opp : public TAssoc_array
{
public:
_riga_sez_opp* riga() { return (_riga_sez_opp*) get(); }
int gruppo() { return riga()->gruppo(); }
int conto() { return riga()->conto(); }
int sottoc() { return riga()->sottoc(); }
const char * sezione () { return riga()->sezione(); }
const char * lettera () { return riga()->lettera(); }
const char * num_rom () { return riga()->num_rom(); }
int numero () { return riga()->numero(); }
real saldo_conto () { return riga()->saldo_conto(); }
real saldo_conto_raf () { return riga()->saldo_conto_raf(); }
void add (int g, int c, long s,
const char * sezione, const char * lettera,
const char * num_rom, int num, real saldo, real saldo_raf);
};
void Righe_sez_opp::add(int g, int c, long s,
const char * sezione, const char * lettera,
const char * num_rom, int num, real saldo, real saldo_raf)
{
_riga_sez_opp * riga;
TString key = format("%s%s%s%d",sezione,lettera,num_rom,num);
if (!is_key((const char *) key))
{
riga = new _riga_sez_opp (g, c, s, sezione, lettera, num_rom, num, saldo, saldo_raf);
TAssoc_array::add(key,riga);
}
else
{
riga = (_riga_sez_opp*) objptr ((const char*) key);
riga->incrementa_saldo(saldo,saldo_raf);
// add(key,riga,TRUE);
}
}
int date2esc(const TDate& d, int* prevesc = NULL);
class CG1600_application : public TPrintapp
{
friend bool data_limite (TMask_field & f,KEY k);
friend bool tipo_stampa (TMask_field & f,KEY k);
friend bool data_bil_raff (TMask_field & f,KEY k);
friend bool tipo_bilancio (TMask_field & f,KEY k);
friend bool data_inizio (TMask_field & f,KEY k);
friend bool data_fine (TMask_field & f,KEY k);
friend bool anno_esercizio (TMask_field & f,KEY k);
struct bil_ivd
{
char sez;
char let;
char numr[5];
char num[4];
char gruppo[4];
char conto[4];
char sottoc[8];
real saldo;
real saldorafr;
real sld_prg_dare;
real sld_prg_avere;
real mov_dare;
real mov_avere;
char tipocf;
bool conto_dettagliato;
};
bil_ivd* _bil;
TMask* _msk;
TTable* _tabesc;
TTable* _tabivd;
TLocalisamfile* _nditte;
TLocalisamfile* _comuni;
TLocalisamfile* _unloc;
TLocalisamfile* _anag;
TLocalisamfile* _pconti;
TLocalisamfile* _clifo;
TLocalisamfile* _saldi;
const char* _buff;
TSort* _sort;
Anni_es* _anni_es;
Righe_sez_opp _sezopps;
TSaldi_list* _listasld;
TProgind* _prog;
TParagraph_string* _descr;
Saldo* _sld;
TDate _data_fine_ese,_data_fine_ese_prec,_data_fine_raf,_data_fine_raf_prec;
TDate _datastampa,_datalimite,_databilrafr,_datai,_datairaf;
TDate _dataini,_datafine,_data_ini_ese,_data_ini_raf;
int _annoese,_annoeserafr,_anno_esercizio,_anno_esercizio_raf;
bool _competenza,_intera_struttura,_stampamov,_stampacod,_stampa_modulo;
bool _sbilancio_patr_gia_stampato,_attivo_o_passivo;
bool _stampa_mov_prov,_diffprod_fatto,_risimp_fatto;
TString _classe_stampata, _classe_da_stampare,_numr_tot,_num_tot,_numr;
char _sez_da_stamp,_let_da_stamp,_sez_stamp,_let_stamp,_sez_tot,_let_tot,_let,_sez_saldo,_sez,_tot_sez_saldo;
TString _numr_da_stamp,_num_da_stamp,_numr_stamp,_num_stamp,_descr_sez;
int _tipo_bilancio, _tipo_stampa;
int _cont_let,_cont_numr,_cont_num,_cont_gcs,_num;
real _sale,_salerafr,_totale_ordine,_totale_economico;
real _totale_ordine_raf,_totale_economico_raf;
real _totale_numero,_totale_numr,_totale_lettera,_totale_sezione;
real _totale_patrimoniale,_totale_attivita,_totale_passivita;
real _totale_num_raf,_totale_numr_raf,_totale_let_raf,_totale_sez_raf;
real _totale_patrim_raf,_totale_attiv_raf,_totale_passiv_raf;
real _totale_ordine_attivo,_totale_ordine_passivo,_totale_ordine_attivo_raf;
real _totale_ordine_passivo_raf;
real _mov_periodo_dare,_mov_periodo_avere,_prg_prec_dare,_prg_prec_avere,_saldo_ini_dare,_saldo_ini_avere;
real _sld_prg_dare,_sld_prg_avere,_mov_dare,_mov_avere;
real _tot_num_saldo,_tot_numr_saldo,_tot_let_saldo,_tot_gen_saldo;
real _tot_num_prg_d,_tot_numr_prg_d,_tot_let_prg_d,_tot_gen_prg_d;
real _tot_num_prg_a,_tot_numr_prg_a,_tot_let_prg_a,_tot_gen_prg_a;
real _tot_num_mov_d,_tot_numr_mov_d,_tot_let_mov_d,_tot_gen_mov_d;
real _tot_num_mov_a,_tot_numr_mov_a,_tot_let_mov_a,_tot_gen_mov_a;
real _tot_num_saldo_d,_tot_numr_saldo_d,_tot_let_saldo_d,_tot_gen_saldo_d;
real _tot_num_saldo_a,_tot_numr_saldo_a,_tot_let_saldo_a,_tot_gen_saldo_a;
real _totale_parziale,_totale_parziale_raf;
real _tot_parz_sld,_tot_parz_sld_d,_tot_parz_sld_a,_tot_parz_prg_d;
real _tot_parz_prg_a,_tot_parz_mov_d,_tot_parz_mov_a;
int _i;
bool _reset_righe_stampa,_totale_attivita_gia_stampato,_totale_passivita_gia_stampato,_statopatr_no_stamp;
bool _sbilancio_ordine;
TString _causale_ap, _causale_chi;
public:
TDate _inizioEs, _fineEs;
bool menu (MENU_TAG m) { return TPrintapp::menu(m) ; }
virtual bool user_create() ;
virtual bool user_destroy();
bool set_print(int);
virtual bool preprocess_page (int,int);
virtual print_action postprocess_page (int,int);
virtual void postclose_print ();
virtual void preprocess_header();
virtual void set_page(int,int);
bool preprocess_stampa_scalare(int);
bool preprocess_stampa_verifica(int);
void crea_intestazione();
void intesta_scalare();
void intesta_verifica();
void intesta_verifica_fissa();
void init_sort();
void crea_sort_tabella();
void crea_sort_piano_conti_scalare();
void crea_sort_piano_conti_verifica();
void setta_righe_descr(TParagraph_string*,const TString&,const TString&);
void setta_righe_descr_verifica(TParagraph_string*,const TString&,const TString&);
void scrivi_record(const TString&,const TString&,const TString&,int,int,int,long,const real&,const real&,const real&,const real&,const real&,const real&,char,bool conto_dettagliato = TRUE);
void riempi_record(const TString&,const TString&,const TString&,int,int,int,long,const real&,const real&,const real&,const real&,const real&,const real&,char,bool conto_dettagliato = TRUE);
const char* descrizione_sezione(char);
const char* descrizione_lettera(char, char);
const char* descrizione_numeroromano(char, char, int);
const char* descrizione_numero(char, char, int, int);
const char* descrizione_sottoconto(int, int, long);
const char* descr_sottoc_clifo(char,long);
void setta_righe(const char*);
void setta_righe_verifica();
void stampa_totali();
void stampa_totali_con_raffronto();
void stampa_totali_verifica();
bool calcola_saldo(real&, real&,int,int,long,int);
bool calcola(int,int,long,const TDate&,const TDate&);
bool sottoc_clifo_scalare (int,int,int,int,real&,real&);
void sottoc_clifo_verifica(int,int,int,char,TString&,TString&,TString&,int,int,bool);
const char* causale_apertura() { return _causale_ap;}
const char* causale_chiusura() { return _causale_chi;}
void stampa_saldo_132(const real&);
void stampa_saldo_198(real&, real&);
void set_bil_key(bil_ivd* b, char sezione, char lettera,
const char* numero_romano, int numero,
bool conti_ordine = TRUE, int conto = 0,
int gruppo = 0, long sottoconto = 0L, char tipocf = ' ');
void set_bil_val(bil_ivd* b, const real& saldo = ZERO,
const real& saldorafr = ZERO,
const real& sld_prg_dare = ZERO,
const real& sld_prg_avere = ZERO,
const real& mov_dare = ZERO,
const real& mov_avere = ZERO,bool conto_dettagliato = TRUE);
CG1600_application() {}
};
HIDDEN inline CG1600_application & a() {return (CG1600_application&) main_app(); }
void CG1600_application::postclose_print()
{
delete _sort;
}
void CG1600_application::set_bil_key(bil_ivd* b, char sezione, char lettera,
const char* numero_romano, int numero,
bool conti_ordine, int gruppo, int conto,
long sottoconto, char tipocf)
{
b->sez = sezione;
//Se esiste solamente la sezione,significa che e' un conto d'ordine
//Forzo la lettera della classe a Z, per ottenere, grazie
//all'ordinamento del sort, i record dei conti d'ordine per ultimi
b->let = (conti_ordine && lettera == '\0' && sezione < '3') ? 'Z' : lettera;
strcpy(b->numr, numero_romano);
sprintf(b->num , "%2d", numero);
if (gruppo < 0)
{
strcpy(b->gruppo, "ZZZ");
strcpy(b->conto, "ZZZ");
strcpy(b->sottoc, "ZZZZZZ");
b->tipocf = ' ';
}
else
if (gruppo == 0)
{
strcpy(b->gruppo, "AAA");
strcpy(b->conto, "AAA");
strcpy(b->sottoc, "AAAAAA");
b->tipocf = ' ';
}
else
{
sprintf(b->gruppo , "%3d", gruppo);
sprintf(b->conto , "%3d", conto);
sprintf(b->sottoc , "%6ld", sottoconto);
b->tipocf = tipocf;
}
}
void CG1600_application::set_bil_val(bil_ivd* b, const real& saldo,
const real& saldorafr,
const real& sld_prg_dare,
const real& sld_prg_avere,
const real& mov_dare,
const real& mov_avere,bool conto_dettagliato)
{
b->saldo = saldo;
b->saldorafr = saldorafr;
b->sld_prg_dare = sld_prg_dare;
b->sld_prg_avere = sld_prg_avere;
b->mov_dare = mov_dare;
b->mov_avere = mov_avere;
b->conto_dettagliato = conto_dettagliato;
}
HIDDEN int date2esc(const TDate& d, int* prevesc)
{
if (prevesc) *prevesc = 0;
TTable esc("ESC");
for (int err = esc.first(); err == NOERR; err = esc.next())
{
const TDate ia(esc.get("D0")); // Data inizio esercizio
const TDate fa(esc.get("D1")); // Data fine esercizio
a()._inizioEs = ia;
a()._fineEs = fa;
const anno = esc.get_int("CODTAB");
if (d >= ia && d <= fa)
return anno;
if (prevesc) *prevesc = anno;
}
return 0;
}
bool data_limite (TMask_field& f, KEY key)
{
if (key == K_ENTER)
{
TMask& m = f.mask();
int tipobil,tipostampa;
TDate datalim;
TDate in="", fin="";
tipobil = m.get_int(F_TIPOBIL);
tipostampa = m.get_int(F_TIPOSTAMPA);
int annoese = m.get_int(F_ANNOESE);
if ((tipobil == 1) && (tipostampa == 1))
{
datalim = m.get(F_DATALIM);
if (annoese != 0)
{
a()._anni_es->aggiungi_anno(annoese, in, fin);
a()._data_fine_ese = fin;
a()._data_ini_ese = in;
a()._anno_esercizio = annoese;
if (datalim == botime)
a()._datalimite = a()._data_fine_ese;
else
if ((datalim < in)||(datalim > fin))
{
f.error_box("La data limite non appartiene all' esercizio indicato");
return FALSE;
}
else
a()._datalimite = datalim;
}
else
if (annoese == 0)
{
if (datalim == botime)
{
f.error_box("La data limite deve essere indicata obbligatoriamente");
return FALSE;
}
int anno = date2esc(datalim);
if (anno == 0)
{
f.error_box("La data limite indicata non appartiene ad alcun esercizio attivo della ditta");
return FALSE;
}
a()._data_ini_ese = a()._inizioEs;
a()._data_fine_ese = a()._fineEs;
a()._datalimite = datalim;
a()._anno_esercizio = anno;
}
}
}
TString data1 = a()._datalimite.string();
TString data2 = a()._data_ini_ese.string();
TString data3 = a()._data_fine_ese.string();
return TRUE;
}
bool data_bil_raff (TMask_field& f, KEY key)
{
TMask& m = f.mask();
int tipobil,tipostampa;
TDate datalim, dataraf;
TDate in = "", fin = "", in_raf = "", fin_raf = "";
if (key == K_ENTER)
{
tipobil = atoi(m.get(F_TIPOBIL));
tipostampa = atoi(m.get(F_TIPOSTAMPA));
int annoese = m.get_int(F_ANNOESE);
int annoraf = m.get_int(F_ANNORAFFR);
if (tipobil == 1) //&& (tipostampa == 1))
{
dataraf = m.get(F_DATABILRAF);
datalim = m.get(F_DATALIM);
if (annoraf == 0)
{
int anno;
if (datalim != botime)
{
date2esc(datalim);
in = a()._inizioEs;
}
else
a()._anni_es->aggiungi_anno(annoese, in, fin);
TString instr = in.string();
if (dataraf != botime)
{
anno = date2esc(dataraf);
in_raf = a()._inizioEs;
fin_raf = a()._fineEs;
a()._anno_esercizio_raf = anno;
}
else
anno == 1;
/****
if (dataraf == botime)
{
f.error_box("La data bilancio da raffrontare deve essere indicata obbligatoriamente");
return FALSE;
}
else
{
********/
if (dataraf > in)
{
f.error_box("La data bilancio da raffrontare non puo' essere maggiore o uguale alla data inizio esercizio in corso");
return FALSE;
}
if (anno == 0)
{
f.error_box("La data bilancio da raffrontare indicata non appartiene ad alcun esercizio attivo della ditta");
return FALSE;
}
a()._databilrafr = dataraf;
a()._data_ini_raf = in_raf;
a()._data_fine_raf = fin_raf;
//}
}
else
if (annoraf != 0)
{
a()._anni_es->aggiungi_anno(annoraf, in_raf, fin_raf);
a()._data_fine_raf = fin_raf;
a()._data_ini_raf = in_raf;
if (dataraf == botime)
a()._databilrafr = fin_raf;
else
if (dataraf < in_raf || dataraf > fin_raf)
{
f.error_box("La data bilancio da raffrontare deve appartenere all' esercizio da raffrontare");
return FALSE;
}
else
a()._databilrafr = dataraf;
a()._anno_esercizio_raf = annoraf;
}
}
} // IF (key == K_ENTER)
TString data1 = in.string();
TString data2 = in_raf.string();
TString data3 = fin_raf.string();
TString data4 = a()._databilrafr.string();
TString data5 = a()._data_ini_raf.string();
TString data6 = a()._data_fine_raf.string();
return TRUE;
}
bool anno_ese_raff (TMask_field& f, KEY key)
{
int annoese, annoraf, anno;
TDate datalim;
if (key == K_ENTER)
{
annoese = f.mask().get_int(F_ANNOESE);
annoraf = f.mask().get_int(F_ANNORAFFR);
if (annoraf != 0)
{
if (annoese != 0)
{
if (annoraf >= annoese)
{
f.error_box("L' anno esercizio da raffrontare deve essere inferiore all' anno esercizio in corso");
return FALSE;
}
}
else
if (annoese == 0)
{
datalim = f.mask().get(F_DATALIM);
if (datalim != botime)
{
anno = date2esc(datalim);
if (annoraf >= anno)
{
f.error_box("L' anno esercizio da raffrontare deve essere inferiore all' anno di esercizio di appartenenza della data limite");
return FALSE;
}
}
}
}
}
return TRUE;
}
bool tipo_bilancio (TMask_field& f, KEY key)
{
int tipo_bil, anno;
if (key == K_SPACE)
{
tipo_bil = f.mask().get_int(F_TIPOBIL);
anno = f.mask().get_int(F_ANNOESE);
if (tipo_bil == 1)
{
f.mask().hide (98);
f.mask().hide (99);
f.mask().hide(96);
f.mask().hide(97);
}
else
if (tipo_bil == 2)
{
if (anno != 0)
{
f.mask().show (96);
f.mask().show (97);
f.mask().hide (98);
f.mask().hide (99);
}
else
if (anno == 0)
{
f.mask().show(98);
f.mask().show(99);
f.mask().hide(96);
f.mask().hide(97);
}
}
}
return TRUE;
}
bool anno_esercizio (TMask_field& f, KEY key)
{
int tipo_bil, anno;
if (key == K_TAB || f.focusdirty())
{
tipo_bil = f.mask().get_int(F_TIPOBIL);
anno = f.mask().get_int(F_ANNOESE);
if (tipo_bil == 1)
{
f.mask().hide (98);
f.mask().hide (99);
f.mask().hide(96);
f.mask().hide(97);
}
else
if (tipo_bil == 2)
{
if (anno != 0)
{
f.mask().show (96);
f.mask().show (97);
f.mask().hide (98);
f.mask().hide (99);
}
else
if (anno == 0)
{
f.mask().show(98);
f.mask().show(99);
f.mask().hide(96);
f.mask().hide(97);
}
}
}
return TRUE;
}
bool tipo_stampa(TMask_field& f,KEY k)
{
int tipo_stampa;
if (k == K_ENTER)
{
tipo_stampa = f.mask().get_int(F_TIPOSTAMPA);
int anno = f.mask().get_int(F_ANNOESE);
if (tipo_stampa == 2)
if (anno == 0)
{
error_box("Nella stampa all' ultima immissione l' anno esercizio e' obbligatorio");
return FALSE;
}
}
return TRUE;
}
bool data_inizio(TMask_field& f, KEY k)
{
int anno;
TDate data;
TDate in="", fin="";
anno = f.mask().get_int(F_ANNOESE);
data = f.mask().get (F_DATAINI);
a()._anno_esercizio = anno;
if (k == K_ENTER)
{
if (anno != 0)
{
a()._anni_es->aggiungi_anno(anno, in, fin);
a()._data_ini_ese = in;
a()._data_fine_ese = fin;
a()._anno_esercizio = anno;
if (data == botime)
a()._dataini = in;
else
if (data < in || data > fin)
{
f.error_box("La data non appartiene all' esercizio indicato");
return FALSE;
}
else
a()._dataini = data;
}
else
if (anno == 0)
{
if (data == botime)
{
f.error_box("La data deve essere obbligatoriamente indicata");
return FALSE;
}
int anno = date2esc(data);
if (anno == 0)
{
f.error_box("La data limite indicata non appartiene ad alcun esercizio attivo della ditta");
return FALSE;
}
a()._anno_esercizio = anno;
a()._dataini = data;
}
}
TString datastr = a()._dataini.string();
TString data1 = a()._data_ini_ese.string();
TString data2 = a()._data_fine_ese.string();
return TRUE;
}
bool data_fine(TMask_field& f, KEY k)
{
int annoes;
TDate data, data_ini;
TDate in="", fin="";
annoes = f.mask().get_int(F_ANNOESE);
data = f.mask().get (F_DATAFINE);
data_ini = f.mask().get (F_DATAINI);
a()._anno_esercizio = annoes;
if (k == K_ENTER)
{
if (annoes != 0)
{
a()._anni_es->aggiungi_anno(annoes, in, fin);
a()._data_ini_ese = in;
a()._data_fine_ese = fin;
if (data == botime)
a()._datafine = fin;
else
if (data < in || data > fin)
{
f.error_box("La data non appartiene all' esercizio indicato");
return FALSE;
}
else
a()._datafine = data;
}
else
if (annoes == 0)
{
if (data == botime)
{
f.error_box("La data deve essere obbligatoriamente indicata");
return FALSE;
}
date2esc(data_ini);
TString data3 = a()._inizioEs.string();
TString data4 = a()._fineEs.string();
if (data < a()._inizioEs || data > a()._fineEs)
{
f.error_box("La data non appartiene all' esercizio indicato");
return FALSE;
}
else
a()._datafine = data;
}
if (data < data_ini)
{
f.error_box("La data finale non puo' essere inferiore alla data di partenza");
return FALSE;
}
}
TString datastr = a()._datafine.string();
TString data1 = a()._data_ini_ese.string();
TString data2 = a()._data_fine_ese.string();
return TRUE;
}
void CG1600_application::scrivi_record(const TString& sez,
const TString& let, const TString& numerorom,int numero,
int g,int c,long s,const real& saldo,const real& saldorafr,
const real& sld_dare,const real& sld_avere,
const real& mov_dare,const real& mov_avere,char tipocf,bool conto_dettagliato)
{
//Se esiste solamente la sezione,significa che e' un conto d'ordine
//Forzo la lettera della classe a Z, per ottenere, grazie
//all'ordinamento del sort, i record dei conti d'ordine per ultimi
set_bil_key(_bil, sez[0], let[0], numerorom, numero, TRUE, g, c, s, tipocf);
set_bil_val(_bil, saldo, saldorafr, sld_dare, sld_avere, mov_dare, mov_avere,conto_dettagliato);
_sort->sort ((const char*) _bil);
}
void CG1600_application::riempi_record(const TString& sez,
const TString& let, const TString& numerorom,int numero,
int g,int c,long s,const real& saldo,const real& saldorafr,
const real& sld_dare,const real& sld_avere,
const real& mov_dare,const real& mov_avere,char tipocf,bool conto_dettagliato)
{
set_bil_key(_bil, sez[0], let[0], numerorom, numero, FALSE, g, c, s, tipocf);
set_bil_val(_bil, saldo, saldorafr, sld_dare, sld_avere, mov_dare, mov_avere,conto_dettagliato);
_sort->sort ((const char*) _bil);
}
void CG1600_application::crea_sort_tabella()
{
TRecnotype recno_prec=0l, recno_curr=0l;
TString codtab_prec;
TTable tabivd(TAB_IVD);
TRecfield codtab_curr(tabivd.curr(),"CODTAB");
TRecfield sezione (tabivd.curr(),"CODTAB",0,0);
TRecfield lettera (tabivd.curr(),"CODTAB",1,1);
TRecfield numerorom (tabivd.curr(),"CODTAB",2,5);
TRecfield numero (tabivd.curr(),"CODTAB",6,7);
int preclen;
bool FINITO=FALSE;
tabivd.first();
codtab_prec = tabivd.get("CODTAB");
// Compilo tanti record quante sono le classi IV direttiva trovate sulla
// tabella %IVD, usando dei gruppi, conti e sottoconti fittizi. Successivamente
// nel caso di stampa completa verranno stampati anche questi record; nel caso
// di stampa non completa non verranno stampati.
do
{
recno_prec = tabivd.recno();
tabivd.next();
if (tabivd.eof())
{
tabivd.zero();
FINITO=TRUE;
}
recno_curr = tabivd.recno();
preclen = codtab_prec.len();
if (!strncmp(codtab_curr,codtab_prec,preclen))
codtab_prec = (const char *)codtab_curr;
else
{
tabivd.readat(recno_prec);
const char sez = *((const char*) sezione);
const char let = *((const char*) lettera);
TString16 nrom((const char*)numerorom);
const int nu = (int) numero;
set_bil_key(_bil, sez, let,(const char*)nrom, nu, FALSE,-1);
set_bil_val(_bil);
_sort->sort ((const char*) _bil);
tabivd.readat(recno_curr);
codtab_prec = (const char *)codtab_curr;
}
} while (!FINITO);
}
// Passo al sort tutti i record presenti su piano dei conti, aventi la classe
// IV direttiva CEE.
void CG1600_application::crea_sort_piano_conti_scalare()
{
TLocalisamfile pconti(LF_PCON);
TString sez,let,numerorom;
TString sez_conto,let_conto,numr_conto,sez_opp,let_opp,numr_opp;
int num_conto, indbil;
char sezione,lettera,tmcf;
int numero,g,c,num_opp;
long s;
bool sez_opposta = FALSE;
bool no_sez_opposta = FALSE;
bool classe_conto = FALSE;
bool conto_dettagliato = FALSE;
bool stsottbil;
int gruppo_prec,conto_prec;
real saldo,saldo_raf,saldo_conto,saldo_conto_raf;
real saldo_conto_opp,saldo_conto_raf_opp;
TString saldostr,saldo_rafstr;
c = 0;
num_conto = 0;
tmcf = ' ';
indbil = 0;
saldo_conto = ZERO;
saldo_conto_raf = ZERO;
saldo_conto_opp = ZERO;
saldo_conto_raf_opp = ZERO;
gruppo_prec = -1;
conto_prec = -1;
for (pconti.first(); !pconti.eof(); pconti.next())
{
_prog->addstatus(1);
g = pconti.get_int (PCN_GRUPPO);
c = pconti.get_int (PCN_CONTO);
s = pconti.get_long(PCN_SOTTOCONTO);
sez = pconti.get(PCN_SEZIVD);
let = pconti.get(PCN_LETTIVD);
sezione = sez[0];
lettera = let[0];
numerorom = pconti.get(PCN_NUMRIVD);
numero = pconti.get_int (PCN_NUMIVD);
saldo = ZERO;
saldo_raf = ZERO;
//Anche se il conto non e' da dettagliare ma contiene la classe e' da
//mandare ugualmente in stampa con il totale di tutti i suoi sottoconti letti
if (classe_conto)
{
if (c != conto_prec && conto_prec != -1)
{
if (no_sez_opposta)
{
TString saldo_contostr,saldo_conto_rafstr;
saldo_contostr = saldo_conto.string();
saldo_conto_rafstr = saldo_conto_raf.string();
riempi_record(sez_conto,let_conto,numr_conto,num_conto,gruppo_prec,conto_prec,0,saldo_conto,saldo_conto_raf,ZERO,ZERO,ZERO,ZERO,tmcf,conto_dettagliato);
saldo_conto = ZERO;
saldo_conto_raf = ZERO;
classe_conto = FALSE;
no_sez_opposta = FALSE;
}
if (sez_opposta)
{
int items = _sezopps.items();
_sezopps.restart();
for (int i=0; i<items; i++)
{
_riga_sez_opp * lriga = _sezopps.riga();
TString sez_opp = lriga->sezione();
TString let_opp = lriga->lettera();
TString numr_opp = lriga->num_rom();
if (numr_opp == " ") //Sembrerebbe che il metodo sezione() quando il numero romano non esiste, ritorni
numr_opp.ltrim(); //una TString contenente uno spazio e non un NULL, sconvolgendo l' ordinamento.
//Per evitare tutto cio' aggiungo il metodo ltrim(), che toglie gli spazi.
//Pero', essendo il numero romano un campo Zerofill, uso ltrim() solo se non c'e'.
int num_opp = lriga->numero();
real saldo_conto = lriga->saldo_conto();
real saldo_conto_raf = lriga->saldo_conto_raf();
riempi_record(sez_opp,let_opp,numr_opp,num_opp,gruppo_prec,conto_prec,0,saldo_conto,saldo_conto_raf,ZERO,ZERO,ZERO,ZERO,tmcf,conto_dettagliato);
}
sez_opposta = FALSE;
_sezopps.destroy();
}
}
}
//Senza questo controllo conto_prec quando viene letto un gruppo verrebbe
//settato a 0 (il conto non c'e'), quindi nella eventuale lettura del conto
//nel ciclo successivo, qualsiasi conto sarebbe diverso da quello precedente.
if (g != gruppo_prec)
conto_prec = -1;
else
conto_prec = c;
gruppo_prec = g;
// Se si tratta di un conto e contiene la classe, allora lo passo al sort.
// Gli eventuali sottoconti avranno la stessa classe.
if ((g != 0) && (c != 0) && (s == 0))
{
stsottbil = pconti.get_bool(PCN_STSOTTBIL);
tmcf = pconti.get (PCN_TMCF)[0];
indbil = pconti.get_int (PCN_INDBIL);
//Se sono nello stesso gruppo, ma ho un conto diverso da quello precedentemente
//analizzato, e se questi contiene la classe IV dir. CEE,
//allore devo controllare se va dettagliato (STSOTTBIL)
if (sez != "0")
{
if (!stsottbil || tmcf == 'C' || tmcf == 'F')
conto_dettagliato = FALSE;
else
conto_dettagliato = TRUE;
sez_conto = sez;
if (let != "")
let_conto = let;
else
if ((sez == "1")||(sez == "2"))
let_conto = "Z";
else
let_conto = let;
numr_conto = numerorom;
num_conto = numero;
classe_conto = TRUE;
if (tmcf == 'C' || tmcf == 'F')
{
if (sottoc_clifo_scalare(g, c,_anno_esercizio,indbil,saldo_conto,saldo_conto_raf))
{
if (sez == "2") //Se la sezione e 2 cambio segno comunque
{
//if (saldo_conto < ZERO)
saldo_conto = -saldo_conto;
//if (saldo_conto_raf < ZERO)
saldo_conto_raf = -saldo_conto_raf;
}
no_sez_opposta = TRUE;
}
}
}
else
{
classe_conto = FALSE; // Metto conto dettagliato = TRUE perche' potrebbero esserci dei sottoconti
conto_dettagliato = TRUE; // di questo conto che hanno la classe e quindi vanno stampati.
}
}
// Se si tratta di un sottoconto e contiene la classe, allora lo passo al sort.
if ((g != 0) && (c != 0) && (s != 0))
{
bool rec_es_corr = FALSE;
bool rec_es_prec = FALSE;
if (!calcola_saldo(saldo,saldo_raf,g,c,s,indbil))
continue;
// classe_conto indica se il conto precedentemente letto conteneva
// la classe. In caso affermativo anche questo sottoconto appena
// letto avra' la stessa classe del conto.
saldostr = saldo.string();
saldo_rafstr = saldo_raf.string();
bool stessa_sezione = (saldo * saldo_raf) > ZERO;
if (classe_conto)
{
sez_opp = pconti.get(PCN_SEZIVDOPP);
if (sez_opp != "0")
{
let_opp = pconti.get(PCN_LETTIVDOPP);
numr_opp = pconti.get(PCN_NUMRIVDOPP);
num_opp = pconti.get_int(PCN_NUMIVDOPP);
if (sez_conto == "1" && saldo < ZERO)// || (sez_conto == "2" && saldo > ZERO) )
{
saldo = -saldo;
rec_es_corr = TRUE;
}
if (sez_conto == "1" && saldo_raf < ZERO) //|| (sez_conto == "2" && saldo_raf > ZERO) )
{
saldo_raf = -saldo_raf;
rec_es_prec = TRUE;
}
if (sez_conto == "2" && saldo > ZERO)
{
rec_es_corr = TRUE;
}
if (sez_conto == "2" && saldo_raf > ZERO)
{
rec_es_prec = TRUE;
}
if (rec_es_corr && rec_es_prec)
{
if (conto_dettagliato)
{
_sezopps.add(g,c,s,sez_opp,let_opp,numr_opp,num_opp,saldo,saldo_raf);
riempi_record(sez_opp,let_opp,numr_opp,num_opp,g,c,s,saldo,saldo_raf,ZERO,ZERO,ZERO,ZERO,tmcf);
sez_opposta = TRUE;
}
else
sez_opposta = FALSE;
}
else
if (rec_es_corr)
{
if (conto_dettagliato)
{
_sezopps.add(g,c,s,sez_opp,let_opp,numr_opp,num_opp,saldo,ZERO);
riempi_record(sez_opp,let_opp,numr_opp,num_opp,g,c,s,saldo,ZERO,ZERO,ZERO,ZERO,ZERO,tmcf);
if (saldo_raf != ZERO)
{
if (sez_conto == "2")
if (saldo_raf < ZERO)
saldo_raf = -saldo_raf;
riempi_record(sez_conto,let_conto,numr_conto,num_conto,g,c,s,ZERO,saldo_raf,ZERO,ZERO,ZERO,ZERO,tmcf);
//saldo_conto += saldo;
saldo_conto_raf += saldo_raf;
no_sez_opposta = TRUE;
}
sez_opposta = TRUE;
}
else
sez_opposta = FALSE;
}
else
if (rec_es_prec)
{
if (conto_dettagliato)
{
_sezopps.add(g,c,s,sez_opp,let_opp,numr_opp,num_opp,ZERO,saldo_raf);
riempi_record(sez_opp,let_opp,numr_opp,num_opp,g,c,s,ZERO,saldo_raf,ZERO,ZERO,ZERO,ZERO,tmcf);
if (saldo != ZERO)
{
if (sez_conto == "2")
if (saldo < ZERO)
saldo = -saldo;
riempi_record(sez_conto,let_conto,numr_conto,num_conto,g,c,s,saldo,ZERO,ZERO,ZERO,ZERO,ZERO,tmcf);
saldo_conto += saldo;
//saldo_conto_raf += saldo_raf;
no_sez_opposta = TRUE;
}
sez_opposta = TRUE;
}
else
sez_opposta = FALSE;
}
else
{
if (sez_conto == "2")
{
if (saldo < ZERO)
saldo = -saldo;
if (saldo_raf < ZERO)
saldo_raf = -saldo_raf;
}
if (conto_dettagliato)
riempi_record(sez_conto,let_conto,numr_conto,num_conto,g,c,s,saldo,saldo_raf,ZERO,ZERO,ZERO,ZERO,tmcf);
saldo_conto += saldo;
saldo_conto_raf += saldo_raf;
no_sez_opposta = TRUE;
}
}
else
{
if (sez_conto == "2")
{
saldo = -saldo;
saldo_raf = -saldo_raf;
}
if (conto_dettagliato)
riempi_record(sez_conto,let_conto,numr_conto,num_conto,g,c,s,saldo,saldo_raf,ZERO,ZERO,ZERO,ZERO,tmcf);
saldo_conto += saldo;
saldo_conto_raf += saldo_raf;
no_sez_opposta = TRUE;
}
}
else
{
sez_opp = pconti.get(PCN_SEZIVDOPP);
if (sez_opp != "0")
{
let_opp = pconti.get(PCN_LETTIVDOPP);
numr_opp = pconti.get(PCN_NUMRIVDOPP);
num_opp = pconti.get_int(PCN_NUMIVDOPP);
if (sez == "1" && saldo < ZERO) //|| (sez == "2" && saldo > ZERO) )
{
saldo = -saldo;
rec_es_corr = TRUE;
}
if (sez == "1" && saldo_raf < ZERO) //|| (sez == "2" && saldo_raf > ZERO) )
{
saldo_raf = -saldo_raf;
rec_es_prec = TRUE;
}
if (sez == "2" && saldo > ZERO)
{
rec_es_corr = TRUE;
}
if (sez == "2" && saldo_raf > ZERO)
{
rec_es_prec = TRUE;
}
if (rec_es_corr && rec_es_prec)
riempi_record(sez_opp,let_opp,numr_opp,num_opp,g,c,s,saldo,saldo_raf,ZERO,ZERO,ZERO,ZERO,tmcf);
else
if (rec_es_corr)
{
riempi_record(sez_opp,let_opp,numr_opp,num_opp,g,c,s,saldo,ZERO,ZERO,ZERO,ZERO,ZERO,tmcf);
if (saldo_raf != ZERO)
{
if (sez == "2")
if (saldo_raf < ZERO)
saldo_raf = -saldo_raf;
riempi_record(sez,let,numerorom,numero,g,c,s,ZERO,saldo_raf,ZERO,ZERO,ZERO,ZERO,tmcf);
}
}
else
if (rec_es_prec)
{
riempi_record(sez_opp,let_opp,numr_opp,num_opp,g,c,s,ZERO,saldo_raf,ZERO,ZERO,ZERO,ZERO,tmcf);
if (saldo != ZERO)
{
if (sez == "2")
if (saldo < ZERO)
saldo = -saldo;
riempi_record(sez,let,numerorom,numero,g,c,s,saldo,ZERO,ZERO,ZERO,ZERO,ZERO,tmcf);
}
}
else
if (sez != "0")
{
if (sez == "2")
{
if (saldo < ZERO)
saldo = -saldo;
if (saldo_raf < ZERO)
saldo_raf = -saldo_raf;
}
riempi_record(sez,let,numerorom,numero,g,c,s,saldo,saldo_raf,ZERO,ZERO,ZERO,ZERO,tmcf);
}
}
else
if (sez != "0")
{
if (sez == "2")
{
saldo = -saldo;
saldo_raf = -saldo_raf;
}
riempi_record(sez,let,numerorom,numero,g,c,s,saldo,saldo_raf,ZERO,ZERO,ZERO,ZERO,tmcf);
}
}
}
}
conto_prec = 0;
if (classe_conto)
{
if (c != conto_prec && conto_prec != -1)
{
if (no_sez_opposta)
{
riempi_record(sez_conto,let_conto,numr_conto,num_conto,gruppo_prec,c,0,saldo_conto,saldo_conto_raf,ZERO,ZERO,ZERO,ZERO,tmcf,conto_dettagliato);
saldo_conto = ZERO;
saldo_conto_raf = ZERO;
classe_conto = FALSE;
no_sez_opposta = FALSE;
}
if (sez_opposta)
{
int items = _sezopps.items();
_sezopps.restart();
for (int i=0; i<items; i++)
{
_riga_sez_opp * lriga = _sezopps.riga();
TString sez_opp = lriga->sezione();
TString let_opp = lriga->lettera();
TString numr_opp = lriga->num_rom();
if (numr_opp == " ")
numr_opp.ltrim();
int num_opp = lriga->numero();
real saldo_conto = lriga->saldo_conto();
real saldo_conto_raf = lriga->saldo_conto_raf();
riempi_record(sez_opp,let_opp,numr_opp,num_opp,gruppo_prec,conto_prec,0,saldo_conto,saldo_conto_raf,ZERO,ZERO,ZERO,ZERO,tmcf,conto_dettagliato);
}
sez_opposta = FALSE;
_sezopps.destroy();
}
}
}
}
void CG1600_application::crea_sort_piano_conti_verifica()
{
TLocalisamfile pconti(LF_PCON);
TString sez,let,numerorom;
TString sez_conto,let_conto,numr_conto;
int num_conto;
char sezione,lettera,tmcf;
int numero,g,c;
long s;
bool classe_conto = FALSE;
bool conto_dettagliato = FALSE;
bool stsottbil;
int gruppo_prec,conto_prec, indbil;
real saldo,sld_prg_dare,sld_prg_avere,mov_dare,mov_avere;
real saldo_conto,sld_prg_dare_conto,sld_prg_avere_conto,mov_dare_conto,mov_avere_conto;
_sld->set_annoes(_anno_esercizio);
saldo_conto = ZERO;
sld_prg_dare_conto = ZERO;
sld_prg_avere_conto = ZERO;
mov_dare_conto = ZERO;
mov_avere_conto = ZERO;
indbil = 0;
gruppo_prec = -1;
conto_prec = -1;
c = 0;
num_conto = 0;
tmcf = ' ';
for (pconti.first(); !pconti.eof(); pconti.next())
{
_prog->addstatus(1);
g = pconti.get_int (PCN_GRUPPO);
c = pconti.get_int (PCN_CONTO);
s = pconti.get_long(PCN_SOTTOCONTO);
sez = pconti.get(PCN_SEZIVD);
let = pconti.get(PCN_LETTIVD);
sezione = sez[0];
lettera = let[0];
numerorom = pconti.get(PCN_NUMRIVD);
numero = pconti.get_int (PCN_NUMIVD);
real app;
saldo = ZERO;
sld_prg_dare = ZERO;
sld_prg_avere = ZERO;
mov_dare = ZERO;
mov_avere = ZERO;
app = ZERO;
if (classe_conto)
{
if (c != conto_prec && conto_prec != -1)
{
riempi_record(sez_conto,let_conto,numr_conto,num_conto,gruppo_prec,conto_prec,0,saldo_conto,ZERO,sld_prg_dare_conto,sld_prg_avere_conto,mov_dare_conto,mov_avere_conto,tmcf,conto_dettagliato);
saldo_conto = ZERO;
sld_prg_dare_conto = ZERO;
sld_prg_avere_conto = ZERO;
mov_dare_conto = ZERO;
mov_avere_conto = ZERO;
classe_conto = FALSE;
}
}
//Senza questo controllo conto_prec quando viene letto un gruppo verrebbe
//settato a 0 (il conto non c'e'), quindi nella eventuale lettura del conto
//nel ciclo successivo, qualsiasi conto sarebbe diverso da quello precedente.
if (g != gruppo_prec)
conto_prec = -1;
else
conto_prec = c;
gruppo_prec = g;
// Se si tratta di un conto e contiene la classe, allora lo passo al sort.
// Gli eventuali sottoconti avranno la stessa classe.
if ((g != 0) && (c != 0) && (s == 0))
{
stsottbil = pconti.get_bool(PCN_STSOTTBIL);
tmcf = pconti.get(PCN_TMCF)[0];
indbil = pconti.get_int(PCN_INDBIL);
//Se sono nello stesso gruppo, ma ho un conto diverso da quello precedentemente
//analizzato , se contiene la classe IV dir. CEE
//allora devo controllare se va dettagliato (STSOTTBIL)
if (sez != "0")
{
if ((tmcf == 'C') || (tmcf == 'F'))
{
sottoc_clifo_verifica(g, c,_anno_esercizio, tmcf,sez,let,numerorom,numero,indbil,stsottbil);
continue;
}
else
if (!stsottbil)
conto_dettagliato = FALSE;
else
conto_dettagliato = TRUE;
sez_conto = sez;
if (let != "")
let_conto = let;
else
if ((sez == "1")||(sez == "2"))
let_conto = "Z";
else
let_conto = let;
numr_conto = numerorom;
num_conto = numero;
classe_conto = TRUE;
}
else
{
classe_conto = FALSE; // Metto conto dettagliato = TRUE perche' potrebbero esserci dei sottoconti
conto_dettagliato = TRUE; // di questo conto che hanno la classe e quindi vanno stampati.
}
}
// Se si tratta di un sottoconto e contiene la classe, allora lo passo al sort.
if ((g != 0) && (c != 0) && (s != 0))
{
// classe_conto indica se il conto precedentemente letto conteneva la classe,
// ma quest' ultima non era presente a livello di gruppo. In caso affermativo
// anche questo sottoconto appena letto avra' la stessa classe del conto.
if (_tipo_stampa == 1)
{
if(!calcola(g,c,s,_data_fine_ese,_data_fine_ese_prec))
continue;
if (_dataini == _data_ini_ese)
{
sld_prg_dare = _saldo_ini_dare;
sld_prg_avere = _saldo_ini_avere;
mov_dare = _mov_periodo_dare;
mov_avere = _mov_periodo_avere;
saldo = sld_prg_dare-sld_prg_avere+mov_dare-mov_avere;
}
else if (_dataini > _data_ini_ese)
{
sld_prg_dare = _prg_prec_dare;
sld_prg_avere = _prg_prec_avere;
mov_dare = _mov_periodo_dare;
mov_avere = _mov_periodo_avere;
saldo = sld_prg_dare-sld_prg_avere+mov_dare-mov_avere;
}
}
else
if (_tipo_stampa == 2)
{
if (!_sld->ultima_immissione_verifica(_anno_esercizio,g,c,s,indbil))
continue;
app = _sld->saldoini();
if (app < ZERO)
{
app = -app;
sld_prg_dare = ZERO;
sld_prg_avere = app;
}
else
{
sld_prg_dare = app;
sld_prg_avere = ZERO;
}
mov_dare = _sld->prgdare();
mov_avere = _sld->prgavere();
saldo = sld_prg_dare-sld_prg_avere+mov_dare-mov_avere;
}
if (classe_conto)
{
if (conto_dettagliato)
riempi_record(sez_conto,let_conto,numr_conto,num_conto,g,c,s,saldo,ZERO,sld_prg_dare,sld_prg_avere,mov_dare,mov_avere,tmcf);
saldo_conto += saldo;
sld_prg_dare_conto += sld_prg_dare;
sld_prg_avere_conto += sld_prg_avere;
mov_dare_conto += mov_dare;
mov_avere_conto += mov_avere;
}
else
{
if (sez != "0")
scrivi_record(sez,let,numerorom,numero,g,c,s,saldo,ZERO,sld_prg_dare,sld_prg_avere,mov_dare,mov_avere,tmcf);
}
}
}
conto_prec = 0;
if (classe_conto)
{
if (c != conto_prec && conto_prec != -1)
{
riempi_record(sez_conto,let_conto,numr_conto,num_conto,gruppo_prec,c,0,saldo_conto,ZERO,sld_prg_dare_conto,sld_prg_avere_conto,mov_dare_conto,mov_avere_conto,tmcf,conto_dettagliato);
saldo_conto = ZERO;
sld_prg_dare_conto = ZERO;
sld_prg_avere_conto = ZERO;
mov_dare_conto = ZERO;
mov_avere_conto = ZERO;
classe_conto = FALSE;
}
}
}
void CG1600_application::sottoc_clifo_verifica(int g,int c,int anno,char tipocf,TString& sez,TString& let,TString& numerorom,int numero,int indbil,bool stsottbil)
{
long s;
_listasld = new TSaldi_list (g,c,anno);
real saldo,sld_prg_dare,sld_prg_avere,mov_dare,mov_avere;
real saldo_conto,sld_prg_dare_conto,sld_prg_avere_conto,mov_dare_conto,mov_avere_conto;
real app;
TString sez_conto,let_conto,numr_conto;
int num_conto;
saldo_conto = ZERO;
sld_prg_dare_conto = ZERO;
sld_prg_avere_conto = ZERO;
mov_dare_conto = ZERO;
mov_avere_conto = ZERO;
int items = _listasld->items();
sez_conto = sez;
if (let != "")
let_conto = let;
else
if ((sez == "1")||(sez == "2"))
let_conto = "Z";
else
let_conto = let;
numr_conto = numerorom;
num_conto = numero;
_listasld->restart();
for (int i=0 ; i < items; i++)
{
const TRectype* r=_listasld->saldi();
if (r == NULL) break;
s = r->get_long(SLD_SOTTOCONTO);
saldo = ZERO;
sld_prg_dare = ZERO;
sld_prg_avere = ZERO;
mov_dare = ZERO;
mov_avere = ZERO;
app = ZERO;
if (_tipo_stampa == 1)
{
if (!calcola(g,c,s,_data_fine_ese,_data_fine_ese_prec))
continue;
if (_dataini == _data_ini_ese)
{
sld_prg_dare = _saldo_ini_dare;
sld_prg_avere = _saldo_ini_avere;
mov_dare = _mov_periodo_dare;
mov_avere = _mov_periodo_avere;
saldo = sld_prg_dare-sld_prg_avere+mov_dare-mov_avere;
}
else if (_dataini > _data_ini_ese)
{
sld_prg_dare = _prg_prec_dare;
sld_prg_avere = _prg_prec_avere;
mov_dare = _mov_periodo_dare;
mov_avere = _mov_periodo_avere;
saldo = sld_prg_dare-sld_prg_avere+mov_dare-mov_avere;
}
}
else
if (_tipo_stampa == 2)
{
if (!_sld->ultima_immissione_bilancio(_anno_esercizio,g,c,s,indbil))
continue;
app = _sld->saldoini();
if (app < ZERO)
{
app = -app;
sld_prg_dare = ZERO;
sld_prg_avere = app;
}
else
{
sld_prg_dare = app;
sld_prg_avere = ZERO;
}
mov_dare = _sld->prgdare();
mov_avere = _sld->prgavere();
saldo = sld_prg_dare-sld_prg_avere+mov_dare-mov_avere;
}
if (stsottbil)
riempi_record(sez_conto,let_conto,numr_conto,num_conto,g,c,s,saldo,ZERO,sld_prg_dare,sld_prg_avere,mov_dare,mov_avere,tipocf);
saldo_conto += saldo;
sld_prg_dare_conto += sld_prg_dare;
sld_prg_avere_conto += sld_prg_avere;
mov_dare_conto += mov_dare;
mov_avere_conto += mov_avere;
}
if (items > 0)
riempi_record(sez_conto,let_conto,numr_conto,num_conto,g,c,0,saldo_conto,ZERO,sld_prg_dare_conto,sld_prg_avere_conto,mov_dare_conto,mov_avere_conto,tipocf,stsottbil);
saldo_conto = ZERO;
sld_prg_dare_conto = ZERO;
sld_prg_avere_conto = ZERO;
mov_dare_conto = ZERO;
mov_avere_conto = ZERO;
delete _listasld;
}
bool CG1600_application::sottoc_clifo_scalare(int g,int c,int anno,int indbil,real& saldo_conto,real& saldo_conto_raf)
{
long s;
int aep = 0;
if (anno) aep = anno-1;
_listasld = new TSaldi_list (g,c,anno,aep);
real saldo,saldo_raf;
bool trovato = FALSE;
int items = _listasld->items();
for (int i=0 ; i < items; i++)
{
const TRectype* r=_listasld->saldi();
if (r == NULL) break;
s = r->get_long(SLD_SOTTOCONTO);
saldo = ZERO;
saldo_raf = ZERO;
if (!calcola_saldo(saldo,saldo_raf,g,c,s,indbil))
continue;
saldo_conto += saldo;
saldo_conto_raf += saldo_raf;
trovato = TRUE;
}
delete _listasld;
return trovato;
}
//La funzione calcola_saldo calcola il saldo dell'esercizio in corso e di
//quello da raffrontare. Inoltre ritorna vero se il sottoconto e' movimentato
//e falso se non e' movimentato, e quindi non deve essere stampato.
bool CG1600_application::calcola_saldo(real& saldo, real& saldo_raf,int g,int c,long s,int indbil)
{
bool no_movimentato = TRUE;
bool no_movimentato_raf = TRUE;
bool esiste = FALSE;
TString saldostr,saldo_rafstr;
_sld->set_annoes(_anno_esercizio);
if (_tipo_bilancio == 1)
{
if (_tipo_stampa == 1) //bilancio per data limite
{
esiste = _sld->data_limite_bilancio(_tipo_stampa,g,c,s,_datai,_datalimite,indbil,_stampa_mov_prov);
saldo = _sld->saldo();
if (!esiste && (!_sld->esiste_saldo() || !_sld->significativo()))
no_movimentato = TRUE;
else
if (!_stampamov)
{
if (saldo == ZERO)
{
if (!_sld->esiste_saldo() || !_sld->significativo())
no_movimentato = TRUE;
else
no_movimentato = FALSE;
}
else
no_movimentato = FALSE;
}
else
{
if (saldo == ZERO)
no_movimentato = TRUE;
else
no_movimentato = FALSE;
}
}
else if (_tipo_stampa == 2)
{
if (!_sld->ultima_immissione_bilancio(_anno_esercizio,g,c,s,indbil))
{
if (!_sld->esiste_saldo() || !_sld->significativo())
no_movimentato = TRUE;
else
no_movimentato = FALSE;
}
else
no_movimentato = FALSE;
saldo = _sld->saldo();
}
saldostr = saldo.string();
if (_annoeserafr != 0 || _databilrafr != botime)
{
_sld->set_annoes(_anno_esercizio_raf);
if (_databilrafr != _data_fine_raf) //(_tipo_stampa == 1) bilancio per data limite
{
#ifdef DBG
TString16 datadep (_databilrafr.string());
TString16 datadep2 (_datairaf.string());
#endif
esiste = _sld->data_limite_bilancio(DataLimite,g,c,s,_datairaf,_databilrafr,indbil,_stampa_mov_prov);
saldo_raf = _sld->saldo();
if (!esiste && (!_sld->esiste_saldo() || !_sld->significativo()))
no_movimentato_raf = TRUE;
else
if (!_stampamov)
{
if (saldo_raf == ZERO)
{
if (!_sld->esiste_saldo() || !_sld->significativo())
no_movimentato_raf = TRUE;
else
no_movimentato_raf = FALSE;
}
else
no_movimentato_raf = FALSE;
}
else
{
if (saldo_raf == ZERO)
no_movimentato_raf = TRUE;
else
no_movimentato_raf = FALSE;
}
}
else if (_databilrafr == _data_fine_raf) //(_tipo_stampa == 2)
{
if (!_sld->ultima_immissione_bilancio(_anno_esercizio_raf,g,c,s,indbil))
{
if (!_sld->esiste_saldo() || !_sld->significativo())
no_movimentato_raf = TRUE;
else
no_movimentato_raf = FALSE;
}
else
no_movimentato_raf = FALSE;
saldo_raf = _sld->saldo();
}
saldo_rafstr = saldo_raf.string();
}
}
if ((no_movimentato) && (no_movimentato_raf))
return FALSE;
else
return TRUE;
}
bool CG1600_application::calcola(int g, int c, long s,
const TDate& fine_es, const TDate& fine_es_prec)
{
TString sezione;
real importo;
int annoe;
long num_reg;
TDate datareg, datacomp, data;
bool conto_mov = FALSE;
TLocalisamfile rmov(LF_RMOV);
TLocalisamfile mov (LF_MOV);
_mov_periodo_dare = ZERO;
_mov_periodo_avere = ZERO;
_prg_prec_dare = ZERO;
_prg_prec_avere = ZERO;
_saldo_ini_dare = ZERO;
_saldo_ini_avere = ZERO;
rmov.setkey(2);
rmov.zero();
rmov.put(RMV_GRUPPO,g);
if (c != 0)
rmov.put(RMV_CONTO,c);
if (s != 0)
rmov.put(RMV_SOTTOCONTO,s);
TRectype rec(rmov.curr());
rmov.read(_isgteq);
for ( ; !rmov.eof(); rmov.next())
{
if (rmov.curr() != rec) break;
annoe = rmov.get_int(RMV_ANNOES);
datareg = rmov.get_date(RMV_DATAREG);
num_reg = rmov.get_long(RMV_NUMREG);
sezione = rmov.get(RMV_SEZIONE);
importo = rmov.get_real(RMV_IMPORTO);
if (importo == ZERO)
continue;
mov.setkey(1);
mov.zero();
mov.put(MOV_NUMREG, num_reg);
mov.read();
if (mov.bad()) mov.zero();
const bool movprovv = mov.get(MOV_PROVVIS).not_empty();
datacomp = mov.get_date(MOV_DATACOMP);
if (!_stampa_mov_prov && movprovv) //se non richiesto
continue; //stampa mov provv.
//li scarto
const TString codcaus(mov.get(MOV_CODCAUS));
if (codcaus.not_empty())
if (codcaus == causale_chiusura()) //la causale e' uguale a quella di chiusura
continue;
if (_annoese == 0)
data = datareg;
if (_annoese != 0)
data = datacomp;
//calcolo i movimenti del periodo
if ( (data >= _dataini) && (data <= _datafine) )
if ((codcaus == causale_apertura() && _data_ini_ese != _dataini) ||
(codcaus != causale_apertura()))
{
conto_mov = TRUE;
if (sezione == "D")
_mov_periodo_dare += importo;
else _mov_periodo_avere += importo;
}
//il saldo inizio es. e' dato dall'importo dare - importo avere di quei movimenti che hanno causale == apertura e data reg >= data inizio es. e <= data limite sup.
if (_dataini == _data_ini_ese) //calcolo il saldo iniziale
{
if (codcaus == causale_apertura())
{
if (sezione == "D")
_saldo_ini_dare += importo;
else _saldo_ini_avere += importo;
conto_mov = TRUE;
}
}
else if (_dataini > _data_ini_ese) //calcolo i progressivi precedenti
if ( (data >= _data_ini_ese) && (data < _dataini) )
{
if (sezione == "D")
_prg_prec_dare += importo;
else _prg_prec_avere += importo;
conto_mov = TRUE;
}
}
return conto_mov;
}
bool CG1600_application::set_print(int)
{
KEY tasto;
{
TConfig conf(CONFIG_DITTA);
_causale_ap = conf.get("CoCaCh");
_causale_chi = conf.get("CoCaCh");
}
_msk->set_handler(F_DATALIM, data_limite);
_msk->set_handler(F_TIPOSTAMPA, tipo_stampa);
_msk->set_handler(F_TIPOBIL, tipo_bilancio);
_msk->set_handler(F_ANNOESE, anno_esercizio);
_msk->set_handler(F_DATAINI, data_inizio);
_msk->set_handler(F_DATAFINE, data_fine);
_msk->set_handler(F_DATABILRAF, data_bil_raff);
_msk->set_handler(F_ANNORAFFR, anno_ese_raff);
tasto = _msk->run();
if (tasto == K_ENTER)
{
_datastampa = (_msk->get(F_DATASTAMPA));
_annoese = _msk->get_int(F_ANNOESE);
_annoeserafr = _msk->get_int(F_ANNORAFFR);
_intera_struttura = (bool)(_msk->get(F_STAMPAINT) == "X");
_stampamov = (bool)(_msk->get(F_STAMPAMOV) == "X");
_stampacod = (bool)(_msk->get(F_STAMPACOD) == "X");
_stampa_modulo = (bool)(_msk->get(F_STAMPAMODULO) == "X");
_tipo_bilancio = atoi(_msk->get(F_TIPOBIL));
_stampa_mov_prov = (bool)(_msk->get(F_STAMPAMOVPROV) == "X");
if (_tipo_bilancio == 1)
{
_tipo_stampa = atoi(_msk->get(F_TIPOSTAMPA));
_prog = new TProgind(_pconti->items(),"Elaborazione in corso... prego attendere",FALSE);
}
else if (_tipo_bilancio == 2)
{
_tipo_stampa = atoi(_msk->get(F_TIPOSTAMPA1));
_prog = new TProgind(_pconti->items(),"Elaborazione in corso... prego attendere",FALSE);
}
_cont_let = 0;
_cont_numr = 0;
_cont_num = 0;
_cont_gcs = 0;
_reset_righe_stampa = TRUE;
set_real_picture("###.###.###.###");
// if (_stampamov)
// set_print_zero(FALSE);
// else
set_print_zero(TRUE);
_totale_attivita_gia_stampato = FALSE;
_totale_passivita_gia_stampato = FALSE;
_statopatr_no_stamp = TRUE;
_diffprod_fatto = TRUE;
_risimp_fatto = TRUE;
_sbilancio_ordine = FALSE;
_sbilancio_patr_gia_stampato = FALSE;
_attivo_o_passivo = FALSE;
_sez_stamp = ' ';
_let_stamp = ' ';
_numr_stamp = "";
_num_stamp = "";
_sez_tot = ' ';
_let_tot = ' ';
_numr_tot = "";
_num_tot = "";
_sale = _salerafr = _totale_ordine = _totale_economico = ZERO;
_totale_ordine_raf = _totale_economico_raf = _totale_numero = ZERO;
_totale_numr = _totale_lettera = _totale_sezione = ZERO;
_totale_patrimoniale = _totale_attivita = _totale_passivita = ZERO;
_totale_num_raf = _totale_numr_raf = _totale_let_raf = ZERO;
_totale_sez_raf = _totale_patrim_raf = _totale_attiv_raf = ZERO;
_totale_passiv_raf = _totale_ordine_attivo = _totale_ordine_passivo = ZERO;
_totale_ordine_attivo_raf = _totale_ordine_passivo_raf = ZERO;
_mov_periodo_dare = _mov_periodo_avere = _prg_prec_dare = ZERO;
_prg_prec_avere = _saldo_ini_dare = _saldo_ini_avere = ZERO;
_sld_prg_dare = _sld_prg_avere = _mov_dare = _mov_avere = ZERO;
_tot_num_saldo = _tot_numr_saldo = _tot_let_saldo = _tot_gen_saldo = ZERO;
_tot_num_prg_d = _tot_numr_prg_d = _tot_let_prg_d = _tot_gen_prg_d = ZERO;
_tot_num_prg_a = _tot_numr_prg_a = _tot_let_prg_a = _tot_gen_prg_a = ZERO;
_tot_num_mov_d = _tot_numr_mov_d = _tot_let_mov_d = _tot_gen_mov_d = ZERO;
_tot_num_mov_a = _tot_numr_mov_a = _tot_let_mov_a = _tot_gen_mov_a = ZERO;
_tot_num_saldo_d = _tot_numr_saldo_d = _tot_let_saldo_d = ZERO;
_tot_gen_saldo_d = _tot_num_saldo_a = _tot_numr_saldo_a = ZERO;
_tot_let_saldo_a = _tot_gen_saldo_a = _totale_parziale = ZERO;
_totale_parziale_raf = _tot_parz_sld = _tot_parz_sld_d = ZERO;
_tot_parz_sld_a = _tot_parz_prg_d = _tot_parz_prg_a = ZERO;
_tot_parz_mov_d = _tot_parz_mov_a = ZERO;
_datai = _data_ini_ese;
_datairaf = _data_ini_raf;
TString data1 = _data_ini_ese.string();
TString data2 = _data_ini_raf.string();
// Se si tratta di stampa intera struttura allora passo al sort anche tutte
// le classi presenti sulla tabella IV dir. CEE, altrimenti passo solamente
// le classi associate ai conti/sottoconti del Piano dei conti.
init_sort();
if (_intera_struttura)
crea_sort_tabella();
if (_tipo_bilancio == 1)
crea_sort_piano_conti_scalare();
else if (_tipo_bilancio == 2)
crea_sort_piano_conti_verifica();
_sort->endsort();
crea_intestazione();
delete _bil;
delete _prog;
return TRUE;
}
return FALSE;
}
void CG1600_application::stampa_totali()
{
bool gia_stampato_conto_ord = FALSE;
TString16 diff_prod;
TString16 ris_imp;
diff_prod.format("%c%c",'9','B');
ris_imp.format ("%c%c%8s%2s",'9','E',"","21");
TString16 classe;
classe.format("%c%c%8s%2s", _sez_da_stamp,_let_da_stamp,(const char*)_numr_da_stamp,(const char*)_num_da_stamp);
_num = atoi(_num_tot);
_numr = _numr_tot;
_let = _let_tot;
if (_buff == NULL)
{
_num_tot = "";
_numr_tot = "";
_let_tot = ' ';
_sez_tot = ' ';
}
if ((_sez_stamp == '1' || _sez_stamp == '2') && _let_stamp != 'Z')
_attivo_o_passivo = TRUE;
if (_num_da_stamp!=_num_tot)
{
if (_let_stamp != 'Z')
{
if (_sez_stamp != '5')
if (_cont_gcs != 0)//(_cont_gcs >= 2)
{
//Fai il totale del numero arabo e stampalo
if (_num != 0)
{
set_row (_i,"@18gTotale@25g%2d@27g)", _num);
set_row (_i++,"@86g%r", &_totale_numero);
}
}
}
if (_sez_stamp == '9')
{
if (classe > ris_imp && _risimp_fatto)
{
if (_num_tot == "20" || _num_tot == "21")
{
set_row (_i,"@4gTotale delle partite straordinarie");
set_row (_i++,"@86g%r", &_totale_parziale);
set_row (_i,"@4gRisultato prima delle imposte");
set_row (_i++,"@86g%r", &_totale_economico);
_risimp_fatto = FALSE;
}
}
}
_cont_gcs = 0;
_totale_numero = 0;
}
if (_numr_da_stamp!=_numr_tot)
{
if (_let_stamp != 'Z')
{
if (_sez_stamp != '5')
{
if (_cont_gcs != 0)//(_cont_gcs >= 2)
{
//Fai il totale del numero arabo e stampalo
if (_num != 0)
{
set_row (_i,"@18gTotale@25g%2d@27g)", _num);
set_row (_i++,"@86g%r", &_totale_numero);
}
}
if (_cont_num != 0)//(_cont_num >= 2)
{
//Fai il totale del numero romano e stampalo
int numeror = atoi(_numr);
TString numrom = itor(numeror);
if (numrom != "")
{
set_row (_i,"@14gTotale@21g%s", (const char*) numrom);
set_row (_i++,"@86g%r", &_totale_numr);
}
}
}
}
_cont_gcs = 0;
_cont_num = 0;
_totale_numero = 0;
_totale_numr = 0;
}
if (_let_da_stamp!=_let_tot)
{
if (_sez_stamp == '9')
{
TString16 classe;
classe.format("%c%c%8s%2s",_sez_stamp,_let_stamp,(const char*)_numr_stamp,(const char*)_num_stamp);
if (_cont_gcs != 0)//(_cont_gcs >= 2)
{
//Fai il totale del numero arabo e stampalo
if (_num != 0)
{
set_row (_i,"@18gTotale@25g%2d@27g)", _num);
set_row (_i++,"@86g%r", &_totale_numero);
}
}
if (_cont_num != 0)//(_cont_num >= 2)
{
//Fai il totale del numero romano e stampalo
int numeror = atoi(_numr);
TString numrom = itor(numeror);
if (numrom != "")
{
set_row (_i,"@14gTotale@21g%s", (const char*) numrom);
set_row (_i++,"@86g%r", &_totale_numr);
}
}
if (_cont_numr != 0)//(_cont_numr >= 2)
{
//Fai il totale della lettera e stampalo
if (_let_stamp == 'D')
set_row (_i,"@4gTotale delle rettifiche");
else
if (_let != ' ')
if (_sez_stamp == '9' && _let_stamp != 'E')
set_row (_i,"@3gTotale@10g%c@12g)", _let);
else
if (_sez_stamp != '9')
set_row (_i,"@3gTotale@10g%c@12g)", _let);
if (_let != ' ')
{
if (_sez_stamp == '9' && _let_stamp != 'E')
set_row (_i++,"@86g%r", &_totale_lettera);
else
if (_sez_stamp != '9')
set_row (_i++,"@86g%r", &_totale_lettera);
}
}
if (classe > diff_prod && _diffprod_fatto)
{
if (_let_tot == 'A' || _let_tot == 'B') //Solo se esiste una delle due lettere
{
set_row (_i++,"@4gDifferenza tra valore e costi della produzione@86g%r", &_totale_economico);
_diffprod_fatto = FALSE;
}
}
}
else
{
if (_let_stamp != 'Z')
{
if (_sez_stamp != '5')
{
if (_cont_gcs != 0)//(_cont_gcs >= 2)
{
//Fai il totale del numero arabo e stampalo
if (_num != 0)
{
set_row (_i,"@18gTotale@25g%2d@27g)", _num);
set_row (_i++,"@86g%r", &_totale_numero);
}
}
if (_cont_num != 0)//(_cont_num >= 2)
{
//Fai il totale del numero romano e stampalo
int numeror = atoi(_numr);
TString numrom = itor(numeror);
if (numrom != "")
{
set_row (_i,"@14gTotale@21g%s", (const char*) numrom);
set_row (_i++,"@86g%r", &_totale_numr);
}
}
if (_cont_numr != 0)//(_cont_numr >= 2)
{
//Fai il totale della lettera e stampalo
if (_let != ' ')
{
set_row (_i,"@3gTotale@10g%c@12g)", _let);
set_row (_i++,"@86g%r", &_totale_lettera);
}
}
}
}
if ((_sez_stamp == '1')&&(_let_da_stamp == 'Z'))
{
char app = ' ';
set_row (_i++,"@0g%c", app);
set_row (_i,"@0gTOTALE ATTIVO");
set_row (_i++,"@86g%r", &_totale_sezione);
_totale_attivita = _totale_sezione;
_totale_sezione = ZERO;
_totale_attivita_gia_stampato = TRUE;
}
if ((_sez_stamp == '2')&&(_let_da_stamp == 'Z'))
{
char app = ' ';
set_row (_i++,"@0g%c", app);
set_row (_i,"@0gTOTALE PASSIVO");
set_row (_i++,"@86g%r", &_totale_sezione);
_totale_passivita = _totale_sezione;
_totale_sezione = ZERO;
_totale_passivita_gia_stampato = TRUE;
}
if ((_sez_stamp == '1')&&(_let_stamp == 'Z'))
{
char app = ' ';
set_row (_i++,"@0g%c", app);
set_row (_i,"@0gTOTALE CONTI D' ORDINE ATTIVI");
set_row (_i++,"@86g%r", &_totale_ordine_attivo);
// _totale_ordine_attivo = ZERO;
gia_stampato_conto_ord = TRUE;
}
if ((_sez_stamp == '2')&&(_let_stamp == 'Z'))
{
char app = ' ';
set_row (_i++,"@0g%c", app);
set_row (_i,"@0gTOTALE CONTI D' ORDINE PASSIVI");
set_row (_i++,"@86g%r", &_totale_ordine_passivo);
_i++;
if (!_attivo_o_passivo)
{
real totale = _totale_ordine_attivo - _totale_ordine_passivo;
if (totale != ZERO)
{
set_row (_i++,"@0gSALDO CONTI D' ORDINE");
set_row (_i,"@0gSBILANCIO");
set_row (_i++,"@86g%r", &totale);
}
_totale_ordine_attivo = ZERO;
_totale_ordine_passivo = ZERO;
_sbilancio_ordine = TRUE;
}
gia_stampato_conto_ord = TRUE;
}
}
_cont_gcs = 0;
_cont_num = 0;
_cont_numr = 0;
_totale_numero = 0;
_totale_numr = 0;
_totale_lettera = 0;
}
if (_sez_da_stamp != _sez_tot)
{
if (_let_stamp != 'Z')
{
if (_sez_stamp != '5')
{
if (_cont_gcs != 0)//(_cont_gcs >= 2)
{
//Fai il totale del numero arabo e stampalo
if (_num != 0)
{
set_row (_i,"@18gTotale@25g%2d@27g)", _num);
set_row (_i++,"@86g%r", &_totale_numero);
}
}
if (_cont_num != 0)//(_cont_num >= 2)
{
//Fai il totale del numero romano e stampalo
int numeror = atoi(_numr);
TString numrom = itor(numeror);
if (numrom != "")
{
set_row (_i,"@14gTotale@21g%s", (const char*) numrom);
set_row (_i++,"@86g%r", &_totale_numr);
}
}
if (_cont_numr != 0)//(_cont_numr >= 2)
{
//Fai il totale della lettera e stampalo
if (_let != ' ')
{
if (_sez_stamp == '9' && _let_stamp != 'E')
{
set_row (_i,"@3gTotale@10g%c@12g)", _let);
set_row (_i++,"@86g%r", &_totale_lettera);
}
else
if (_sez_stamp != '9')
{
set_row (_i,"@3gTotale@10g%c@12g)", _let);
set_row (_i++,"@86g%r", &_totale_lettera);
}
}
}
}
}
if (!_totale_attivita_gia_stampato)
if ((_sez_stamp == '1') && (_let_stamp != 'Z'))
{
char app = ' ';
set_row (_i++,"@0g%c", app);
set_row (_i,"@0gTOTALE ATTIVO");
set_row (_i++,"@86g%r", &_totale_sezione);
_totale_attivita = _totale_sezione;
_totale_sezione = ZERO;
}
if (!_totale_passivita_gia_stampato)
if ((_sez_stamp == '2') && (_let_stamp != 'Z'))
{
char app = ' ';
set_row (_i++,"@0g%c", app);
set_row (_i,"@0gTOTALE PASSIVO");
set_row (_i++,"@86g%r", &_totale_sezione);
_totale_passivita = _totale_sezione;
_totale_sezione = ZERO;
}
if (!gia_stampato_conto_ord)
{
if (_sez_stamp == '2')
{
if (!_sbilancio_patr_gia_stampato)
{
_totale_patrimoniale = _totale_attivita - _totale_passivita;
if (_totale_patrimoniale != ZERO)
{
char app = ' ';
set_row (_i++,"@0g%c", app);
set_row (_i++,"@0gSALDO STATO PATRIMONIALE");
set_row (_i,"@0gSBILANCIO (ATTIVO - PASSIVO)");
//_totale_patrimoniale = _totale_attivita - _totale_passivita;
set_row (_i++,"@86g%r", &_totale_patrimoniale);
_totale_patrimoniale = ZERO;
}
_sbilancio_patr_gia_stampato = TRUE;
}
}
if ((_sez_stamp == '1')&&(_let_stamp == 'Z'))
{
char app = ' ';
set_row (_i++,"@0g%c", app);
set_row (_i,"@0gTOTALE CONTI D' ORDINE ATTIVI");
set_row (_i++,"@86g%r", &_totale_ordine_attivo);
// _totale_ordine_attivo = ZERO;
}
if ((_sez_stamp == '2')&&(_let_stamp == 'Z'))
{
char app = ' ';
set_row (_i++,"@0g%c", app);
set_row (_i,"@0gTOTALE CONTI D' ORDINE PASSIVI");
set_row (_i++,"@86g%r", &_totale_ordine_passivo);
_i++;
if (!_sbilancio_ordine)
{
real totale = _totale_ordine_attivo - _totale_ordine_passivo;
if (totale != ZERO)
{
set_row (_i++,"@0g%c", app);
set_row (_i++,"@0gSALDO CONTI D' ORDINE");
set_row (_i,"@0gSBILANCIO");
set_row (_i++,"@86g%r", &totale);
_sbilancio_ordine = TRUE;
}
_totale_ordine_passivo = ZERO;
_totale_ordine_attivo = ZERO;
}
}
}
if (_sez_stamp == '2')
{
char app = ' ';
if (!_sbilancio_patr_gia_stampato)
{
_totale_patrimoniale = _totale_attivita - _totale_passivita;
if (_totale_patrimoniale != ZERO)
{
set_row (_i++,"@0g%c", app);
set_row (_i++,"@0gSALDO STATO PATRIMONIALE");
set_row (_i,"@0gSBILANCIO (ATTIVO - PASSIVO)");
//_totale_patrimoniale = _totale_attivita - _totale_passivita;
set_row (_i++,"@86g%r", &_totale_patrimoniale);
_totale_patrimoniale = ZERO;
}
}
if (!_sbilancio_ordine)
{
real totale = _totale_ordine_attivo - _totale_ordine_passivo;
if (totale != ZERO && !_sbilancio_ordine)
{
set_row (_i++,"@0g%c", app);
set_row (_i++,"@0gSALDO CONTI D' ORDINE");
set_row (_i,"@0gSBILANCIO");
set_row (_i++,"@86g%r", &totale);
}
}
}
if (_sez_stamp == '5')
{
char app = ' ';
set_row (_i++,"@0g%c", app);
set_row (_i,"@0gTOTALE CONTI D' ORDINE");
set_row (_i++,"@86g%r", &_totale_ordine);
_totale_ordine = ZERO;
}
if (_sez_stamp == '9')
{
if (_buff == NULL)
{
if ((_let_stamp == 'A' || _let_stamp == 'B') && _diffprod_fatto)//Solo se esiste una delle due lettere
{
set_row (_i++,"@4gDifferenza tra valore e costi della produzione@86g%r", &_totale_economico);
_diffprod_fatto = FALSE;
}
if (_risimp_fatto)
{
if (_let_da_stamp == 'E' && (_num_da_stamp == "20" || _num_da_stamp == "21"))
{
set_row (_i,"@4gTotale delle partite straordinarie");
set_row (_i++,"@86g%r", &_totale_parziale);
set_row (_i,"@4gRisultato prima delle imposte");
set_row (_i++,"@86g%r", &_totale_economico);
_risimp_fatto = FALSE;
}
}
}
char app = ' ';
set_row (_i++,"@0g%c", app);
if (_totale_economico != ZERO)
{
set_row (_i,"@0gRISULTATO CONTO ECONOMICO");
set_row (_i++,"@86g%r", &_totale_economico);
_totale_economico = ZERO;
}
}
_cont_gcs = 0;
_cont_num = 0;
_cont_numr = 0;
_cont_let = 0;
_totale_numero = 0;
_totale_numr = 0;
_totale_lettera = 0;
}
}
void CG1600_application::stampa_totali_con_raffronto()
{
bool gia_stampato_conto_ord = FALSE;
TString16 diff_prod;
TString16 ris_imp;
diff_prod.format("%c%c",'9','B');
ris_imp.format ("%c%c%8s%2s",'9','E',"","21");
TString16 classe;
classe.format("%c%c%8s%2s", _sez_da_stamp,_let_da_stamp,(const char*)_numr_da_stamp,(const char*)_num_da_stamp);
_num = atoi(_num_tot);
_numr = _numr_tot;
_let = _let_tot;
if (_buff == NULL)
{
_num_tot = "";
_numr_tot = "";
_let_tot = ' ';
_sez_tot = ' ';
}
if ((_sez_stamp == '1' || _sez_stamp == '2') && _let_stamp != 'Z')
_attivo_o_passivo = TRUE;
if (_num_da_stamp!=_num_tot)
{
if (_let_stamp != 'Z')
{
if (_sez_stamp != '5')
if (_cont_gcs != 0)//(_cont_gcs >= 2)
{
//Fai il totale del numero arabo e stampalo
if (_num != 0)
{
set_row (_i,"@18gTotale@25g%2d@27g)", _num);
set_row (_i,"@86g%r", &_totale_numero);
set_row (_i++,"@112g%r", &_totale_num_raf);
}
}
}
if (_sez_stamp == '9')
{
if (classe > ris_imp && _risimp_fatto)
{
if (_num_tot == "20" || _num_tot == "21")
{
set_row (_i,"@4gTotale delle partite straordinarie");
set_row (_i,"@86g%r", &_totale_parziale);
set_row (_i++,"@112g%r", &_totale_parziale_raf);
set_row (_i,"@4gRisultato prima delle imposte");
set_row (_i,"@86g%r", &_totale_economico);
set_row (_i++,"@112g%r", &_totale_economico_raf);
_risimp_fatto = FALSE;
}
}
}
_cont_gcs = 0;
_totale_numero = 0;
_totale_num_raf = 0;
}
if (_numr_da_stamp!=_numr_tot)
{
if (_let_stamp != 'Z')
{
if (_sez_stamp != '5')
{
if (_cont_gcs != 0)//(_cont_gcs >= 2)
{
//Fai il totale del numero arabo e stampalo
if (_num != 0)
{
set_row (_i,"@18gTotale@25g%2d@27g)", _num);
set_row (_i,"@86g%r", &_totale_numero);
set_row (_i++,"@112g%r", &_totale_num_raf);
}
}
if (_cont_num != 0)//(_cont_num >= 2)
{
//Fai il totale del numero romano e stampalo
int numeror = atoi(_numr);
TString numrom = itor(numeror);
if (numrom != "")
{
set_row (_i,"@14gTotale@21g%s", (const char*) numrom);
set_row (_i,"@86g%r", &_totale_numr);
set_row (_i++,"@112g%r", &_totale_numr_raf);
}
}
}
}
_cont_gcs = 0;
_cont_num = 0;
_totale_numero = 0;
_totale_numr = 0;
_totale_num_raf = 0;
_totale_numr_raf = 0;
}
if (_let_da_stamp!=_let_tot)
{
if (_sez_stamp == '9')
{
TString16 classe;
classe.format("%c%c%8s%2s",_sez_stamp,_let_stamp,(const char*)_numr_stamp,(const char*)_num_stamp);
if (_cont_gcs != 0)//(_cont_gcs >= 2)
{
//Fai il totale del numero arabo e stampalo
if (_num != 0)
{
set_row (_i,"@18gTotale@25g%2d@27g)", _num);
set_row (_i++,"@86g%r", &_totale_numero);
}
}
if (_cont_num != 0)//(_cont_num >= 2)
{
//Fai il totale del numero romano e stampalo
int numeror = atoi(_numr);
TString numrom = itor(numeror);
if (numrom != "")
{
set_row (_i,"@14gTotale@21g%s", (const char*) numrom);
set_row (_i++,"@86g%r", &_totale_numr);
}
}
if (_cont_numr != 0)//(_cont_numr >= 2)
{
//Fai il totale della lettera e stampalo
if (_let_stamp == 'D')
set_row (_i,"@4gTotale delle rettifiche");
else
if (_let != ' ')
if (_sez_stamp == '9' && _let_stamp != 'E')
set_row (_i,"@3gTotale@10g%c@12g)", _let);
else
if (_sez_stamp != '9')
set_row (_i,"@3gTotale@10g%c@12g)", _let);
if (_let != ' ')
{
if (_sez_stamp == '9' && _let_stamp != 'E')
{
set_row (_i,"@86g%r", &_totale_lettera);
set_row (_i++,"@112g%r", &_totale_let_raf);
}
else
if (_sez_stamp != '9')
{
set_row (_i,"@86g%r", &_totale_lettera);
set_row (_i++,"@112g%r", &_totale_let_raf);
}
}
}
if (classe > diff_prod && _diffprod_fatto)
{
if (_let_tot == 'A' || _let_tot == 'B')
{
set_row (_i++,"@4gDifferenza tra valore e costi della produzione@86g%r@112g%r", &_totale_economico,&_totale_economico_raf);
_diffprod_fatto = FALSE;
}
}
}
else
{
if (_let_stamp != 'Z')
{
if (_sez_stamp != '5')
{
if (_cont_gcs != 0)//(_cont_gcs >= 2)
{
//Fai il totale del numero arabo e stampalo
if (_num != 0)
{
set_row (_i,"@18gTotale@25g%2d@27g)", _num);
set_row (_i,"@86g%r", &_totale_numero);
set_row (_i++,"@112g%r", &_totale_num_raf);
}
}
if (_cont_num != 0)//(_cont_num >= 2)
{
//Fai il totale del numero romano e stampalo
int numeror = atoi(_numr);
TString numrom = itor(numeror);
if (numrom != "")
{
set_row (_i,"@14gTotale@21g%s", (const char*) numrom);
set_row (_i,"@86g%r", &_totale_numr);
set_row (_i++,"@112g%r", &_totale_numr_raf);
}
}
if (_cont_numr != 0)//(_cont_numr >= 2)
{
//Fai il totale della lettera e stampalo
if (_let != ' ')
{
set_row (_i,"@3gTotale@10g%c@12g)", _let);
set_row (_i,"@86g%r", &_totale_lettera);
set_row (_i++,"@112g%r", &_totale_let_raf);
}
}
}
}
if ((_sez_stamp == '1')&&(_let_da_stamp == 'Z'))
{
char app = ' ';
set_row (_i++,"@0g%c", app);
set_row (_i,"@0gTOTALE ATTIVO");
set_row (_i,"@86g%r", &_totale_sezione);
set_row (_i++,"@112g%r", &_totale_sez_raf);
_totale_attivita = _totale_sezione;
_totale_attiv_raf = _totale_sez_raf;
_totale_sezione = ZERO;
_totale_sez_raf = ZERO;
_totale_attivita_gia_stampato = TRUE;
}
if ((_sez_stamp == '2')&&(_let_da_stamp == 'Z'))
{
char app = ' ';
set_row (_i++,"@0g%c", app);
set_row (_i,"@0gTOTALE PASSIVO");
set_row (_i,"@86g%r", &_totale_sezione);
set_row (_i++,"@112g%r", &_totale_sez_raf);
_totale_passivita = _totale_sezione;
_totale_passiv_raf = _totale_sez_raf;
_totale_sezione = ZERO;
_totale_sez_raf = ZERO;
_totale_passivita_gia_stampato = TRUE;
}
if ((_sez_stamp == '1')&&(_let_stamp == 'Z'))
{
char app = ' ';
set_row (_i++,"@0g%c", app);
set_row (_i,"@0gTOTALE CONTI D' ORDINE ATTIVI");
set_row (_i,"@86g%r", &_totale_ordine_attivo);
set_row (_i++,"@112g%r", &_totale_ordine_attivo_raf);
//_totale_ordine_attivo = ZERO;
//_totale_ordine_attivo_raf = ZERO;
gia_stampato_conto_ord = TRUE;
}
if ((_sez_stamp == '2')&&(_let_stamp == 'Z'))
{
char app = ' ';
set_row (_i++,"@0g%c", app);
set_row (_i,"@0gTOTALE CONTI D' ORDINE PASSIVI");
set_row (_i,"@86g%r", &_totale_ordine_passivo);
set_row (_i++,"@112g%r", &_totale_ordine_passivo_raf);
_i++;
gia_stampato_conto_ord = TRUE;
if (!_attivo_o_passivo)
{
real totale = _totale_ordine_attivo - _totale_ordine_passivo;
real tot_raf = _totale_ordine_attivo_raf - _totale_ordine_passivo_raf;
if (totale != ZERO || tot_raf != ZERO)
{
set_row (_i++,"@0gSALDO CONTI D' ORDINE");
set_row (_i,"@0gSBILANCIO");
set_row (_i,"@86g%r", &totale);
set_row (_i++,"@112g%r", &tot_raf);
}
_totale_ordine_attivo = ZERO;
_totale_ordine_attivo_raf = ZERO;
_totale_ordine_passivo = ZERO;
_totale_ordine_passivo_raf = ZERO;
_sbilancio_ordine = TRUE;
_sbilancio_patr_gia_stampato = TRUE; //Se passa di qui non ci sono ne attivi ne passivo
}
}
}
_cont_gcs = 0;
_cont_num = 0;
_cont_numr = 0;
_totale_numero = 0;
_totale_numr = 0;
_totale_lettera = 0;
_totale_num_raf = 0;
_totale_numr_raf = 0;
_totale_let_raf = 0;
}
if (_sez_da_stamp != _sez_tot)
{
if (_let_stamp != 'Z')
{
if (_sez_stamp != '5')
{
if (_cont_gcs != 0)//(_cont_gcs >= 2)
{
//Fai il totale del numero arabo e stampalo
if (_num != 0)
{
set_row (_i,"@18gTotale@25g%2d@27g)", _num);
set_row (_i,"@86g%r", &_totale_numero);
set_row (_i++,"@112g%r", &_totale_num_raf);
}
}
if (_cont_num != 0)//(_cont_num >= 2)
{
//Fai il totale del numero romano e stampalo
int numeror = atoi(_numr);
TString numrom = itor(numeror);
if (numrom != "")
{
set_row (_i,"@14gTotale@21g%s", (const char*) numrom);
set_row (_i++,"@86g%r", &_totale_numr);
set_row (_i++,"@112g%r", &_totale_numr_raf);
}
}
if (_cont_numr != 0)//(_cont_numr >= 2)
{
//Fai il totale della lettera e stampalo
if (_let != ' ')
{
if (_sez_stamp == '9' && _let_stamp != 'E')
{
set_row (_i,"@3gTotale@10g%c@12g)", _let);
set_row (_i++,"@86g%r", &_totale_lettera);
set_row (_i++,"@112g%r", &_totale_let_raf);
}
else
if (_sez_stamp != '9')
{
set_row (_i,"@3gTotale@10g%c@12g)", _let);
set_row (_i++,"@86g%r", &_totale_lettera);
set_row (_i++,"@112g%r", &_totale_let_raf);
}
}
}
}
}
if (!_totale_attivita_gia_stampato)
if ((_sez_stamp == '1') && (_let_stamp != 'Z'))
{
char app = ' ';
set_row (_i++,"@0g%c", app);
set_row (_i,"@0gTOTALE ATTIVO");
set_row (_i,"@86g%r", &_totale_sezione);
set_row (_i++,"@112g%r", &_totale_sez_raf);
_totale_attivita = _totale_sezione;
_totale_attiv_raf = _totale_sez_raf;
_totale_sezione = ZERO;
_totale_sez_raf = ZERO;
_totale_attivita_gia_stampato = TRUE;
}
if (!_totale_passivita_gia_stampato)
if ((_sez_stamp == '2') && (_let_stamp != 'Z'))
{
char app = ' ';
set_row (_i++,"@0g%c", app);
set_row (_i,"@0gTOTALE PASSIVO");
set_row (_i,"@86g%r", &_totale_sezione);
set_row (_i++,"@112g%r", &_totale_sez_raf);
_totale_passivita = _totale_sezione;
_totale_passiv_raf = _totale_sez_raf;
_totale_sezione = ZERO;
_totale_sez_raf = ZERO;
_totale_passivita_gia_stampato = TRUE;
}
if (!gia_stampato_conto_ord)
{
if (_sez_stamp == '2')
{
if (!_sbilancio_patr_gia_stampato)
{
_totale_patrimoniale = _totale_attivita - _totale_passivita;
_totale_patrim_raf = _totale_attiv_raf - _totale_passiv_raf;
if (_totale_patrimoniale != ZERO || _totale_patrim_raf != ZERO)
{
char app = ' ';
set_row (_i++,"@0g%c", app);
set_row (_i++,"@0gSALDO STATO PATRIMONIALE");
set_row (_i,"@0gSBILANCIO (ATTIVO - PASSIVO)");
//_totale_patrimoniale = _totale_attivita - _totale_passivita;
//_totale_patrim_raf = _totale_attiv_raf - _totale_passiv_raf;
set_row (_i,"@86g%r", &_totale_patrimoniale);
set_row (_i++,"@112g%r", &_totale_patrim_raf);
_totale_patrimoniale = 0;
_totale_patrim_raf = 0;
}
_sbilancio_patr_gia_stampato = TRUE;
}
}
if ((_sez_stamp == '1')&&(_let_stamp == 'Z'))
{
char app = ' ';
set_row (_i++,"@0g%c", app);
set_row (_i,"@0gTOTALE CONTI D' ORDINE ATTIVI");
set_row (_i,"@86g%r", &_totale_ordine_attivo);
set_row (_i++,"@112g%r", &_totale_ordine_attivo_raf);
//_totale_ordine_attivo = ZERO;
//_totale_ordine_attivo_raf = ZERO;
}
if ((_sez_stamp == '2')&&(_let_stamp == 'Z'))
{
char app = ' ';
set_row (_i++,"@0g%c", app);
set_row (_i,"@0gTOTALE CONTI D' ORDINE PASSIVI");
set_row (_i,"@86g%r", &_totale_ordine_passivo);
set_row (_i++,"@112g%r", &_totale_ordine_passivo_raf);
_i++;
if (!_sbilancio_ordine)
{
real totale = _totale_ordine_attivo - _totale_ordine_passivo;
real tot_raf = _totale_ordine_attivo_raf - _totale_ordine_passivo_raf;
if (totale != ZERO || tot_raf != ZERO)
{
set_row (_i++,"@0g%c", app);
set_row (_i++,"@0gSALDO CONTI D' ORDINE");
set_row (_i,"@0gSBILANCIO");
set_row (_i,"@86g%r", &totale);
set_row (_i++,"@112g%r", &tot_raf);
_sbilancio_ordine = TRUE;
}
_totale_ordine_attivo = ZERO;
_totale_ordine_attivo_raf = ZERO;
_totale_ordine_passivo = ZERO;
_totale_ordine_passivo_raf = ZERO;
_sbilancio_ordine = TRUE;
}
}
}
if (_sez_stamp == '2')
{
char app = ' ';
if (!_sbilancio_patr_gia_stampato)
{
_totale_patrimoniale = _totale_attivita - _totale_passivita;
_totale_patrim_raf = _totale_attiv_raf - _totale_passiv_raf;
if (_totale_patrimoniale != ZERO || _totale_patrim_raf != ZERO)
{
set_row (_i++,"@0g%c", app);
set_row (_i++,"@0gSALDO STATO PATRIMONIALE");
set_row (_i,"@0gSBILANCIO (ATTIVO - PASSIVO)");
//_totale_patrimoniale = _totale_attivita - _totale_passivita;
//_totale_patrim_raf = _totale_attiv_raf - _totale_passiv_raf;
set_row (_i,"@86g%r", &_totale_patrimoniale);
set_row (_i++,"@112g%r", &_totale_patrim_raf);
_totale_patrimoniale = 0;
_totale_patrim_raf = 0;
}
}
if (!_sbilancio_ordine)
{
real totale = _totale_ordine_attivo - _totale_ordine_passivo;
real tot_raf = _totale_ordine_attivo_raf - _totale_ordine_passivo_raf;
if ((totale != ZERO || tot_raf != ZERO) && !_sbilancio_ordine)
{
set_row (_i++,"@0g%c", app);
set_row (_i++,"@0gSALDO CONTI D' ORDINE");
set_row (_i,"@0gSBILANCIO");
set_row (_i,"@86g%r", &totale);
set_row (_i++,"@112g%r", &tot_raf);
}
}
}
if (_sez_stamp == '5')
{
char app = ' ';
set_row (_i++,"@0g%c", app);
set_row (_i,"@0gTOTALE CONTI D' ORDINE");
set_row (_i,"@86g%r", &_totale_ordine);
set_row (_i++,"@112g%r", &_totale_ordine_raf);
_totale_ordine = 0;
_totale_ordine_raf = 0;
}
if (_sez_stamp == '9')
{
if (_buff == NULL)
{
if ((_let_stamp == 'A' || _let_stamp == 'B') && _diffprod_fatto)
{
set_row (_i++,"@4gDifferenza tra valore e costi della produzione@86g%r@112g%r", &_totale_economico,&_totale_economico_raf);
_diffprod_fatto = FALSE;
}
if (_risimp_fatto)
{
if (_let_da_stamp == 'E' && (_num_da_stamp == "20" || _num_da_stamp == "21"))
{
set_row (_i,"@4gTotale delle partite straordinarie");
set_row (_i,"@86g%r", &_totale_parziale);
set_row (_i++,"@112g%r", &_totale_parziale_raf);
set_row (_i,"@4gRisultato prima delle imposte");
set_row (_i,"@86g%r", &_totale_economico);
set_row (_i++,"@112g%r", &_totale_economico_raf);
_risimp_fatto = FALSE;
}
}
}
char app = ' ';
set_row (_i++,"@0g%c", app);
if (_totale_economico != ZERO || _totale_economico_raf != ZERO)
{
set_row (_i,"@0gRISULTATO CONTO ECONOMICO");
set_row (_i,"@86g%r", &_totale_economico);
set_row (_i++,"@112g%r", &_totale_economico_raf);
_totale_economico = 0;
_totale_economico_raf = 0;
}
}
_cont_gcs = 0;
_cont_num = 0;
_cont_numr = 0;
_cont_let = 0;
_totale_numero = 0;
_totale_numr = 0;
_totale_lettera = 0;
_totale_num_raf = 0;
_totale_numr_raf = 0;
_totale_let_raf = 0;
}
}
void CG1600_application::stampa_totali_verifica()
{
TString16 ris_imp;
ris_imp.format ("%c%c%8s%2s",'9','E',"","21");
_num = atoi(_num_tot);
_numr = _numr_tot;
_let = _let_tot;
_sez = _sez_tot;
if (_buff == NULL)
{
_num_tot = "";
_numr_tot = "";
_let_tot = ' ';
_sez_tot = ' ';
}
if (_num_da_stamp!=_num_tot)
{
if (_cont_gcs != 0)//(_cont_gcs >= 2)
{
//Fai il totale del numero arabo e stampalo
if (((_sez == '1')||(_sez == '2')||(_sez == '9'))&&(_let != 'Z'))
{
if (_num != 0)
set_row (_i,"@8gTotale@15g%2d@17g)",_num);
}
else
if (_num != 0)
set_row (_i,"@8gTotale");
if (_num != 0)
{
set_row (_i,"@49g%r", &_tot_num_prg_d);
set_row (_i,"@65g%r", &_tot_num_prg_a);
set_row (_i,"@82g%r", &_tot_num_mov_d);
set_row (_i,"@98g%r", &_tot_num_mov_a);
}
if (!_stampa_modulo)
{
if (_tot_num_saldo < ZERO)
{
_tot_num_saldo = -_tot_num_saldo;
_tot_sez_saldo = 'A';
}
else
_tot_sez_saldo = 'D';
if (_num != 0)
stampa_saldo_132(_tot_num_saldo);
}
else
{
if (_num != 0)
stampa_saldo_198(_tot_num_saldo_d,_tot_num_saldo_a);
// _tot_num_saldo_d = 0;
// _tot_num_saldo_a = 0;
}
if (_sez_stamp == '9')
{
TString16 classe;
classe.format("%c%c%8s%2s", _sez_da_stamp,_let_da_stamp,(const char*)_numr_da_stamp,(const char*)_num_da_stamp);
if (classe > ris_imp && _risimp_fatto)
{
if (_num_tot == "20" || _num_tot == "21")
{
set_row (_i,"@4gTotale delle partite straordinarie");
set_row (_i,"@49g%r", &_tot_parz_prg_d);
set_row (_i,"@65g%r", &_tot_parz_prg_a);
set_row (_i,"@82g%r", &_tot_parz_mov_d);
set_row (_i,"@98g%r", &_tot_parz_mov_a);
_risimp_fatto = FALSE;
if (!_stampa_modulo)
{
if (_tot_parz_sld < ZERO)
{
_tot_parz_sld = -_tot_parz_sld;
_tot_sez_saldo = 'A';
}
else
_tot_sez_saldo = 'D';
if (_num != 0)
stampa_saldo_132(_tot_parz_sld);
}
else
{
if (_num != 0)
stampa_saldo_198(_tot_parz_sld_d,_tot_parz_sld_a);
}
}
}
}
}
_cont_gcs = 0;
_tot_num_prg_d = ZERO;
_tot_num_prg_a = ZERO;
_tot_num_mov_d = ZERO;
_tot_num_mov_a = ZERO;
_tot_num_saldo = ZERO;
}
if (_numr_da_stamp!=_numr_tot)
{
if (_cont_gcs != 0)//(_cont_gcs >= 2)
{
//Fai il totale del numero arabo e stampalo
if (((_sez == '1')||(_sez == '2')||(_sez == '9'))&&(_let != 'Z'))
{
if (_num != 0)
set_row (_i,"@8gTotale@15g%2d@17g)", _num);
}
else
if (_num != 0)
set_row (_i,"@8gTotale");
if (_num != 0)
{
set_row (_i,"@49g%r", &_tot_num_prg_d);
set_row (_i,"@65g%r", &_tot_num_prg_a);
set_row (_i,"@82g%r", &_tot_num_mov_d);
set_row (_i,"@98g%r", &_tot_num_mov_a);
}
if (!_stampa_modulo)
{
if (_tot_num_saldo < ZERO)
{
_tot_num_saldo = -_tot_num_saldo;
_tot_sez_saldo = 'A';
}
else
_tot_sez_saldo = 'D';
if (_num != 0)
stampa_saldo_132(_tot_num_saldo);
}
else
{
if (_num != 0)
stampa_saldo_198(_tot_num_saldo_d,_tot_num_saldo_a);
//_tot_num_saldo_d = 0;
//_tot_num_saldo_a = 0;
}
}
if (_cont_num != 0)//(_cont_num >= 2)
{
//Fai il totale del numero romano e stampalo
int numeror = atoi(_numr);
TString numrom = itor(numeror);
if (numrom != "")
{
set_row (_i,"@8gTotale@15g%s", (const char*) numrom);
set_row (_i,"@49g%r", &_tot_numr_prg_d);
set_row (_i,"@65g%r", &_tot_numr_prg_a);
set_row (_i,"@82g%r", &_tot_numr_mov_d);
set_row (_i,"@98g%r", &_tot_numr_mov_a);
}
if (!_stampa_modulo)
{
if (_tot_numr_saldo < ZERO)
{
_tot_numr_saldo = -_tot_numr_saldo;
_tot_sez_saldo = 'A';
}
else
_tot_sez_saldo = 'D';
if (numrom != "")
stampa_saldo_132(_tot_numr_saldo);
}
else
{
if (numrom != "")
stampa_saldo_198(_tot_numr_saldo_d,_tot_numr_saldo_a);
// _tot_numr_saldo_d = 0;
// _tot_numr_saldo_a = 0;
}
}
_cont_gcs = 0;
_cont_num = 0;
_tot_num_prg_d = ZERO;
_tot_num_prg_a = ZERO;
_tot_num_mov_d = ZERO;
_tot_num_mov_a = ZERO;
_tot_num_saldo = ZERO;
_tot_numr_prg_d = ZERO;
_tot_numr_prg_a = ZERO;
_tot_numr_mov_d = ZERO;
_tot_numr_mov_a = ZERO;
_tot_numr_saldo = ZERO;
}
if ((_let_da_stamp!=_let_tot) || (_sez_da_stamp != _sez_tot))
{
if (_cont_gcs != 0)//(_cont_gcs >= 2)
{
//Fai il totale del numero arabo e stampalo
if (((_sez == '1')||(_sez == '2')||(_sez == '9'))&&(_let != 'Z'))
{
if (_num != 0)
set_row (_i,"@8gTotale@15g%2d@17g)",_num);
}
else
if (_num != 0)
set_row (_i,"@8gTotale");
if (_num != 0)
{
set_row (_i,"@49g%r", &_tot_num_prg_d);
set_row (_i,"@65g%r", &_tot_num_prg_a);
set_row (_i,"@82g%r", &_tot_num_mov_d);
set_row (_i,"@98g%r", &_tot_num_mov_a);
}
if (!_stampa_modulo)
{
if (_tot_num_saldo < ZERO)
{
_tot_num_saldo = -_tot_num_saldo;
_tot_sez_saldo = 'A';
}
else
_tot_sez_saldo = 'D';
if (_num != 0)
stampa_saldo_132(_tot_num_saldo);
}
else
{
if (_num != 0)
stampa_saldo_198(_tot_num_saldo_d,_tot_num_saldo_a);
// _tot_num_saldo_d = 0;
// _tot_num_saldo_a = 0;
}
}
if (_cont_num != 0)//(_cont_num >= 2)
{
//Fai il totale del numero romano e stampalo
int numeror = atoi(_numr);
TString numrom = itor(numeror);
if (numrom != "")
{
set_row (_i,"@8gTotale@15g%s", (const char*) numrom);
set_row (_i,"@49g%r", &_tot_numr_prg_d);
set_row (_i,"@65g%r", &_tot_numr_prg_a);
set_row (_i,"@82g%r", &_tot_numr_mov_d);
set_row (_i,"@98g%r", &_tot_numr_mov_a);
}
if (!_stampa_modulo)
{
if (_tot_numr_saldo < ZERO)
{
_tot_numr_saldo = -_tot_numr_saldo;
_tot_sez_saldo = 'A';
}
else
_tot_sez_saldo = 'D';
if (numrom != "")
stampa_saldo_132(_tot_numr_saldo);
}
else
{
if (numrom != "")
stampa_saldo_198(_tot_numr_saldo_d,_tot_numr_saldo_a);
// _tot_numr_saldo_d = 0;
// _tot_numr_saldo_a = 0;
}
}
if (_cont_numr != 0)//(_cont_numr >= 2)
{
//Fai il totale della lettera e stampalo
if (_let != ' ')
{
if (_sez_stamp == '9' && _let_stamp != 'E')
{
set_row (_i,"@8gTotale@15g%c@16g)", _let);
set_row (_i,"@49g%r", &_tot_let_prg_d);
set_row (_i,"@65g%r", &_tot_let_prg_a);
set_row (_i,"@82g%r", &_tot_let_mov_d);
set_row (_i,"@98g%r", &_tot_let_mov_a);
}
else
if (_sez_stamp != '9')
{
set_row (_i,"@8gTotale@15g%c@16g)", _let);
set_row (_i,"@49g%r", &_tot_let_prg_d);
set_row (_i,"@65g%r", &_tot_let_prg_a);
set_row (_i,"@82g%r", &_tot_let_mov_d);
set_row (_i,"@98g%r", &_tot_let_mov_a);
}
}
if (!_stampa_modulo)
{
if (_tot_let_saldo < ZERO)
{
_tot_let_saldo = -_tot_let_saldo;
_tot_sez_saldo = 'A';
}
else
_tot_sez_saldo = 'D';
if (_let != ' ')
if (_sez_stamp == '9' && _let_stamp != 'E')
stampa_saldo_132(_tot_let_saldo);
else
if (_sez_stamp != '9')
stampa_saldo_132(_tot_let_saldo);
}
else
{
if (_let != ' ')
if (_sez_stamp == '9' && _let_stamp != 'E')
stampa_saldo_198(_tot_let_saldo_d,_tot_let_saldo_a);
else
stampa_saldo_198(_tot_let_saldo_d,_tot_let_saldo_a);
// _tot_let_saldo_d = 0;
// _tot_let_saldo_a = 0;
}
}
_cont_gcs = 0;
_cont_num = 0;
_cont_numr = 0;
_tot_num_prg_d = ZERO;
_tot_num_prg_a = ZERO;
_tot_num_mov_d = ZERO;
_tot_num_mov_a = ZERO;
_tot_num_saldo = ZERO;
_tot_numr_prg_d = ZERO;
_tot_numr_prg_a = ZERO;
_tot_numr_mov_d = ZERO;
_tot_numr_mov_a = ZERO;
_tot_numr_saldo = ZERO;
_tot_let_prg_d = ZERO;
_tot_let_prg_a = ZERO;
_tot_let_mov_d = ZERO;
_tot_let_mov_a = ZERO;
_tot_let_saldo = ZERO;
}
}
void CG1600_application::stampa_saldo_198(real& saldo_d,real& saldo_a)
{
set_row (_i,"@115g%r", &saldo_d);
set_row (_i,"@48g!@81g!@114g!@131g!");
set_row (_i,"@133g%r", &saldo_a);
set_row (_i++,"@48g!@81g!@114g!@131g!");
saldo_d = real(ZERO);
saldo_a = real(ZERO);
}
void CG1600_application::stampa_saldo_132(const real& saldo)
{
set_row (_i,"@115g%r", &saldo);
set_row (_i,"@48g!@81g!@114g!");
set_row (_i++,"@131g%c", _tot_sez_saldo);
}
print_action CG1600_application::postprocess_page(int file, int counter)
{
struct bil_ivd* bil = (struct bil_ivd*) _buff;
bil = (struct bil_ivd*) _buff;
if (_tipo_bilancio == 1)
{
if (_sez_da_stamp != _sez_stamp)
{
if (_sez_da_stamp == '5')
{
if (!_intera_struttura)
{
if (bil->gruppo[0] != 'Z')
{
reset_print();
_i = 1;
setta_righe("CONTI D' ORDINE");
_reset_righe_stampa = FALSE;
}
}
else
{
reset_print();
_i = 1;
setta_righe("CONTI D' ORDINE");
_reset_righe_stampa = FALSE;
}
}
if (_sez_da_stamp == '9')
{
if (!_intera_struttura)
{
if (bil->gruppo[0] != 'Z')
{
reset_print();
_i = 1;
setta_righe("CONTO ECONOMICO");
_reset_righe_stampa = FALSE;
}
}
else
{
reset_print();
_i = 1;
setta_righe("CONTO ECONOMICO");
_reset_righe_stampa = FALSE;
}
}
}
set_auto_ff(FALSE);
}
if (_buff == NULL)
return NEXT_PAGE;
_sale = 0;
_salerafr = 0;
return REPEAT_PAGE;
}
bool CG1600_application::preprocess_page(int file, int counter)
{
if (_tipo_bilancio == 1)
{
if (preprocess_stampa_scalare(counter))
return TRUE;
else
return FALSE;
}
else if (_tipo_bilancio == 2)
{
if (preprocess_stampa_verifica(counter))
return TRUE;
else
return FALSE;
}
return TRUE;
}
bool CG1600_application::preprocess_stampa_scalare(int counter)
{
struct bil_ivd* bil = (struct bil_ivd*) _buff;
int g,c;
long s;
bool fai = TRUE;
TString saldostr,saldo_rafstr;
bool conto_dettagliato = TRUE;
if (!counter)
{
reset_print();
_i = 1;
}
if (_reset_righe_stampa)
{
reset_print();
_i = 1;
}
else
_reset_righe_stampa = TRUE;
if (counter)
{
if (!_intera_struttura)
{
if (bil->gruppo[0] != 'Z')
{
_sez_stamp = bil->sez;
_let_stamp = bil->let;
_numr_stamp = bil->numr;
_numr_stamp.ltrim();
_num_stamp = bil->num;
_num_stamp.ltrim();
_sez_tot = bil->sez;
_let_tot = bil->let;
_numr_tot = bil->numr;
_numr_tot.ltrim();
_num_tot = bil->num;
_num_tot.ltrim();
}
}
else
{
_classe_stampata = format ("%1c%1c%8s%2d",bil->sez,bil->let,(const char*) bil->numr,bil->num);
_sez_stamp = bil->sez;
_let_stamp = bil->let;
_numr_stamp = bil->numr;
_numr_stamp.ltrim();
_num_stamp = bil->num;
_num_stamp.ltrim();
_sez_tot = bil->sez;
_let_tot = bil->let;
_numr_tot = bil->numr;
_numr_tot.ltrim();
_num_tot = bil->num;
_num_tot.ltrim();
}
}
_buff = _sort->retrieve();
if (_buff == NULL)
{
if (_annoeserafr == 0 && _databilrafr == botime)
stampa_totali();
else
stampa_totali_con_raffronto();
_sez_da_stamp = ' ';
_sez_stamp = ' ';
return TRUE;
}
if (_buff != NULL)
{
bil = (struct bil_ivd*) _buff;
_classe_da_stampare = format ("%1c%1c%8s%2d",bil->sez,bil->let,(const char*) bil->numr,bil->num);
_sez_da_stamp = bil->sez;
_let_da_stamp = bil->let;
_numr_da_stamp = bil->numr;
_numr_da_stamp.ltrim();
_num_da_stamp = bil->num;
_num_da_stamp.ltrim();
g = atoi(bil->gruppo);
c = atoi(bil->conto);
s = atol(bil->sottoc);
conto_dettagliato = bil->conto_dettagliato;
if (_intera_struttura)
fai = TRUE;
else
{
if (bil->gruppo[0] != 'Z')
fai = TRUE;
else
fai = FALSE;
}
if (counter)
{
if (fai)
if (_annoeserafr == 0 && _databilrafr == botime)
stampa_totali();
else
stampa_totali_con_raffronto();
}
//Fare ricerca di dataregmov
if (!_intera_struttura)
{
if (bil->gruppo[0]=='Z')
return FALSE;
_sale = bil->saldo;
if (_annoeserafr != 0 || _databilrafr != botime)
_salerafr = bil->saldorafr;
/***
if (_stampamov)
{
if (_annoeserafr != 0 || _databilrafr != botime)
{
if ((_sale.is_zero()) && (_salerafr.is_zero()))
return FALSE;
}
else
if (_sale.is_zero())
return FALSE;
}
***/
}
else
{
if (bil->gruppo[0]=='Z')
// {
if (_classe_da_stampare == _classe_stampata)
// {
// sprintf (bil->gruppo,"%s", " ");
// sprintf (bil->conto ,"%s", " ");
// sprintf (bil->sottoc,"%s", " ");
// }
// else
return FALSE;
// }
_sale = bil->saldo;
if (_annoeserafr != 0 || _databilrafr != botime)
_salerafr = bil->saldorafr;
/***
if (_stampamov)
{
if (_annoeserafr != 0 || _databilrafr != botime)
{
if ((_sale.is_zero()) && (_salerafr.is_zero()))
return FALSE;
}
else
{
if (_sale.is_zero())
return FALSE;
}
}
***/
}
saldostr = _sale.string();
saldo_rafstr = _salerafr.string();
// Faccio passare solo i sottoconti o i conti non dettagliati (che non hanno sottoconti)
// perch<63> l' importo dei conti dettagliati non <20> altri che il totale degli importi di
// tutti i suoi sottoconti; dunque se li sommassi anche loro, sommerei l'importo due volte.
// Pero' devo ricordarmi di cambiare ugualmente segno ai conti che vanno dettagliati.
if (g != 0 && c != 0 && s == 0 && conto_dettagliato)
if (_sez_da_stamp == '9')
{
_sale = -_sale;
if (_annoeserafr != 0 || _databilrafr != botime)
_salerafr = -_salerafr;
}
if ((g != 0 && c != 0 && s != 0)||(g != 0 && c != 0 && s == 0 && !conto_dettagliato))
{
// if (_sez_da_stamp == '5')
// if (_sale < ZERO)
// _sale = -_sale;
if (_sez_da_stamp == '9')
// if (_sale> ZERO)
_sale = -_sale;
_totale_numero += _sale;
_totale_numr += _sale;
_totale_lettera += _sale;
if ((_sez_da_stamp == '1')||(_sez_da_stamp == '2'))
{
if (_let_da_stamp != 'Z')
_totale_sezione += _sale;
else
{
if (_sez_da_stamp == '1')
_totale_ordine_attivo += _sale;
else
if (_sez_da_stamp == '2')
_totale_ordine_passivo += _sale;
}
}
if (_sez_da_stamp == '5')
_totale_ordine += _sale;
if (_sez_da_stamp == '9')
{
_totale_economico += _sale;
if (_let_da_stamp == 'E' && (_num_da_stamp == "20" || _num_da_stamp == "21"))
_totale_parziale += _sale;
}
if (_annoeserafr != 0 || _databilrafr != botime)
{
//if (_sez_da_stamp == '5')
// if (_salerafr < ZERO)
// _salerafr = -_salerafr;
if (_sez_da_stamp == '9')
//if (_salerafr> ZERO)
_salerafr = -_salerafr;
_totale_num_raf += _salerafr;
_totale_numr_raf += _salerafr;
_totale_let_raf += _salerafr;
if ((_sez_da_stamp == '1')||(_sez_da_stamp == '2'))
{
if (_let_da_stamp != 'Z')
_totale_sez_raf += _salerafr;
else
{
if (_sez_da_stamp == '1')
_totale_ordine_attivo_raf += _salerafr;
else
if (_sez_da_stamp == '2')
_totale_ordine_passivo_raf += _salerafr;
}
}
if (_sez_da_stamp == '5')
_totale_ordine_raf += _salerafr;
if (_sez_da_stamp == '9')
{
_totale_economico_raf += _salerafr;
if (_let_da_stamp == 'E' && (_num_da_stamp == "20" || _num_da_stamp == "21"))
_totale_parziale_raf += _salerafr;
}
}
}
return TRUE;
}
else
return FALSE;
}
bool CG1600_application::preprocess_stampa_verifica(int counter)
{
struct bil_ivd* bil = (struct bil_ivd*) _buff;
int g,c;
long s;
bool fai = TRUE;
bool conto_dettagliato = TRUE;
if (!counter)
{
reset_print();
_i = 1;
}
if (_reset_righe_stampa)
{
reset_print();
_i = 1;
}
else
_reset_righe_stampa = TRUE;
if (counter)
{
if (!_intera_struttura)
{
if (bil->gruppo[0] != 'Z')
{
_sez_stamp = bil->sez;
_let_stamp = bil->let;
_numr_stamp = bil->numr;
_numr_stamp.ltrim();
_num_stamp = bil->num;
_num_stamp.ltrim();
_sez_tot = bil->sez;
_let_tot = bil->let;
_numr_tot = bil->numr;
_numr_tot.ltrim();
_num_tot = bil->num;
_num_tot.ltrim();
}
}
else
{
_classe_stampata = format ("%1c%1c%8s%2d",bil->sez,bil->let,(const char*) bil->numr,bil->num);
_sez_stamp = bil->sez;
_let_stamp = bil->let;
_numr_stamp = bil->numr;
_numr_stamp.ltrim();
_num_stamp = bil->num;
_num_stamp.ltrim();
_sez_tot = bil->sez;
_let_tot = bil->let;
_numr_tot = bil->numr;
_numr_tot.ltrim();
_num_tot = bil->num;
_num_tot.ltrim();
}
}
_buff = _sort->retrieve();
if (_buff == NULL)
{
stampa_totali_verifica();
set_row (_i,"@0g****** ******** TOTALE GENERALE");
set_row (_i,"@49g%r", &_tot_gen_prg_d);
set_row (_i,"@65g%r", &_tot_gen_prg_a);
set_row (_i,"@82g%r", &_tot_gen_mov_d);
set_row (_i,"@98g%r", &_tot_gen_mov_a);
if (!_stampa_modulo)
{
if (_tot_gen_saldo < ZERO)
{
_tot_gen_saldo = -_tot_gen_saldo;
_tot_sez_saldo = 'A';
}
else
_tot_sez_saldo = 'D';
stampa_saldo_132(_tot_gen_saldo);
}
else
stampa_saldo_198(_tot_gen_saldo_d,_tot_gen_saldo_a);
_sez_da_stamp = ' ';
_sez_stamp = ' ';
return TRUE;
}
if (_buff != NULL)
{
bil = (struct bil_ivd*) _buff;
_classe_da_stampare = format ("%1c%1c%8s%2d",bil->sez,bil->let,(const char*) bil->numr,bil->num);
_sez_da_stamp = bil->sez;
_let_da_stamp = bil->let;
_numr_da_stamp = bil->numr;
_numr_da_stamp.ltrim();
_num_da_stamp = bil->num;
_num_da_stamp.ltrim();
g = atoi(bil->gruppo);
c = atoi(bil->conto);
s = atol(bil->sottoc);
conto_dettagliato = bil->conto_dettagliato;
if (_intera_struttura)
fai = TRUE;
else
{
if (bil->gruppo[0] != 'Z')
fai = TRUE;
else
fai = FALSE;
}
if (counter)
{
if (fai)
stampa_totali_verifica();
}
_sale = bil->saldo;
_sld_prg_dare = bil->sld_prg_dare;
_sld_prg_avere = bil->sld_prg_avere;
_mov_dare = bil->mov_dare;
_mov_avere = bil->mov_avere;
if (!_intera_struttura)
{
if (bil->gruppo[0]=='Z')
return FALSE;
if (_stampamov)
{
if (_sale.is_zero())
return FALSE;
}
}
else
{
if (bil->gruppo[0]=='Z')
// {
if (_classe_da_stampare == _classe_stampata)
// {
// sprintf (bil->gruppo,"%s", " ");
// sprintf (bil->conto ,"%s", " ");
// sprintf (bil->sottoc,"%s", " ");
// }
// else
return FALSE;
// }
if (_stampamov)
{
if (_sale.is_zero())
return FALSE;
}
}
if ((g != 0) && (c != 0) && (s == 0) && (conto_dettagliato))
{
//if (_sld_prg_avere < ZERO)
// _sld_prg_avere = -_sld_prg_avere;
//if (_mov_avere < ZERO)
// _mov_avere = -_mov_avere;
if (_sale < ZERO)
{
_sale = -_sale;
_sez_saldo = 'A';
}
else
_sez_saldo = 'D';
}
if ((g != 0 && c != 0 && s != 0)||(g != 0 && c != 0 && s == 0 && !conto_dettagliato))
{
_tot_num_saldo += _sale;
_tot_numr_saldo += _sale;
_tot_let_saldo += _sale;
_tot_gen_saldo += _sale;
if (_sez_da_stamp == '9')
if (_let_da_stamp == 'E' && (_num_da_stamp == "20" || _num_da_stamp == "21"))
_tot_parz_sld += _sale;
//if (_sld_prg_avere < ZERO)
// _sld_prg_avere = -_sld_prg_avere;
//if (_mov_avere < ZERO)
// _mov_avere = -_mov_avere;
if (_sale < ZERO)
{
_sale = -_sale;
_sez_saldo = 'A';
if (_stampa_modulo)
{
_tot_num_saldo_a += _sale;
_tot_numr_saldo_a += _sale;
_tot_let_saldo_a += _sale;
_tot_gen_saldo_a += _sale;
if (_sez_da_stamp == '9')
if (_let_da_stamp == 'E' && (_num_da_stamp == "20" || _num_da_stamp == "21"))
_tot_parz_sld_a += _sale;
}
}
else
{
_sez_saldo = 'D';
if (_stampa_modulo)
{
_tot_num_saldo_d += _sale;
_tot_numr_saldo_d += _sale;
_tot_let_saldo_d += _sale;
_tot_gen_saldo_d += _sale;
if (_sez_da_stamp == '9')
if (_let_da_stamp == 'E' && (_num_da_stamp == "20" || _num_da_stamp == "21"))
_tot_parz_sld_d += _sale;
}
}
_tot_num_prg_d += _sld_prg_dare;
_tot_numr_prg_d += _sld_prg_dare;
_tot_let_prg_d += _sld_prg_dare;
_tot_gen_prg_d += _sld_prg_dare;
_tot_num_prg_a += _sld_prg_avere;
_tot_numr_prg_a += _sld_prg_avere;
_tot_let_prg_a += _sld_prg_avere;
_tot_gen_prg_a += _sld_prg_avere;
_tot_num_mov_d += _mov_dare;
_tot_numr_mov_d += _mov_dare;
_tot_let_mov_d += _mov_dare;
_tot_gen_mov_d += _mov_dare;
_tot_num_mov_a += _mov_avere;
_tot_numr_mov_a += _mov_avere;
_tot_let_mov_a += _mov_avere;
_tot_gen_mov_a += _mov_avere;
if (_sez_da_stamp == '9')
if (_let_da_stamp == 'E' && (_num_da_stamp == "20" || _num_da_stamp == "21"))
{
_tot_parz_prg_d += _sld_prg_dare;
_tot_parz_prg_a += _sld_prg_avere;
_tot_parz_mov_d += _mov_dare;
_tot_parz_mov_a += _mov_avere;
}
}
return TRUE;
}
else
return FALSE;
}
void CG1600_application::set_page(int file, int counter)
{
if (_tipo_bilancio == 1)
{
if (_sez_da_stamp != _sez_stamp)
{
if ((_sez_da_stamp=='1')||((_sez_da_stamp=='2')&&(_statopatr_no_stamp)))
{
setta_righe ("STATO PATRIMONIALE");
_statopatr_no_stamp = FALSE;
}
if (_sez_da_stamp == '2')
setta_righe("");
if ((_sez_da_stamp == '5') || (_sez_da_stamp == '9'))
set_auto_ff(TRUE);
}
else
{
if (_buff != NULL)
setta_righe("");
}
}
else if (_tipo_bilancio == 2)
{
if (_buff != NULL)
setta_righe_verifica();
}
}
void CG1600_application::setta_righe(const char * titolo)
{
struct bil_ivd* bil = (struct bil_ivd*) _buff;
int numeror, numero, gruppo, conto;
char sezione,lettera;
long sottoc;
TString numrom,numr;
TString descr_let,descr_numr,descr_num,descr_sottoc,descr_classe;
bool stampa_classe = TRUE;
TString lettera1 = "@1g)@3g%s";
TString lettera2 = "@3g%s";
TString numr1 = "@12g-@14g%s";
TString numr2 = "@14g%s";
TString num = "@15g)@18g%s";
TString num2 = "@18g%s";
_descr->set_width(40);
sezione = bil->sez;
lettera = bil->let;
numr = bil->numr;
// numr.ltrim();
numeror = atoi(bil->numr);
numrom = itor(numeror);
numero = atoi(bil->num);
// num = bil->num;
gruppo = atoi(bil->gruppo);
conto = atoi(bil->conto);
sottoc = atoi(bil->sottoc);
descr_let = descrizione_lettera(sezione,lettera);
descr_numr = descrizione_numeroromano(sezione,lettera,numeror);
descr_num = descrizione_numero(sezione,lettera,numeror,numero);
descr_sottoc = descrizione_sottoconto(gruppo,conto,sottoc);
//Se la classe prelevata dal record corrente del sort e' diversa dalla classe
//prelevata dal record precedente, allora stampo la nuova classe con i relativi
//sottoconti. In caso contrario continuo a stampare solo i sottoconti.
if (_sez_da_stamp != _sez_stamp)
{
set_row (_i++,"@0g%s", titolo);
char app = ' ';
set_row(_i++,"@0g%c", app);
if ((_sez_da_stamp == '1')&&(_let_da_stamp == 'Z'))
{
char app = ' ';
set_row (_i++,"@0g%c", app);
set_row (_i++,"@0gCONTI D' ORDINE ATTIVI");
set_row (_i++,"@0g%c", app);
stampa_classe = FALSE;
}
else
if ((_sez_da_stamp == '1')&&(_let_da_stamp != 'Z'))
{
char app = ' ';
set_row (_i++,"@0g%c", app);
set_row (_i++,"@0gATTIVO");
set_row (_i++,"@0g%c", app);
}
if ((_sez_da_stamp == '2')&&(_let_da_stamp == 'Z'))
{
char app = ' ';
set_row(_i++,"@0g%c", app);
set_row (_i++,"@0gCONTI D' ORDINE PASSIVI");
set_row(_i++,"@0g%c", app);
stampa_classe = FALSE;
}
else
if ((_sez_da_stamp == '2')&&(_let_da_stamp != 'Z'))
{
char app = ' ';
set_row(_i++,"@0g%c", app);
set_row (_i++,"@0gPASSIVO");
set_row(_i++,"@0g%c", app);
}
if (stampa_classe)
{
if ((_sez_da_stamp=='1')||(_sez_da_stamp=='2')||(_sez_da_stamp== '9'))
{
//set_row(_i++,"@0g%s", (const char*) _descr_sez);
if (!_intera_struttura || (_intera_struttura && bil->gruppo[0] != 'Z'))
{
_cont_let = 1;
_cont_numr = 1;
_cont_num = 1;
_cont_gcs = 0;
}
if (lettera != ' ')
{
set_row(_i,"@0g%c", bil->let);
*_descr = (const char*) descr_let;
setta_righe_descr(_descr,lettera1,lettera2);
//set_row(_i++,"@1g)@3g%s", (const char*) descr_let);
}
if (numrom != "")
{
set_row(_i,"@3g%8s", (const char*) numrom);
*_descr = (const char*) descr_numr;
setta_righe_descr(_descr,numr1,numr2);
//set_row(_i++,"@12g-@14g%s", (const char*) descr_numr);
}
if (numero != 0)
{
set_row(_i,"@13g%s", bil->num);
*_descr = (const char*) descr_num;
setta_righe_descr(_descr,num,num2);
//set_row(_i++,"@15g)@18g%s", (const char*) descr_num);
}
}
}
}
else
if ((_let_da_stamp!=_let_stamp)&&(_sez_da_stamp==_sez_stamp))
{
if ((_sez_da_stamp == '1')&&(_let_da_stamp == 'Z'))
{
char app = ' ';
set_row (_i++,"@0g%c", app);
set_row (_i++,"@0gCONTI D' ORDINE ATTIVI");
set_row (_i++,"@0g%c", app);
stampa_classe = FALSE;
}
if ((_sez_da_stamp == '2')&&(_let_da_stamp == 'Z'))
{
char app = ' ';
set_row(_i++,"@0g%c", app);
set_row (_i++,"@0gCONTI D' ORDINE PASSIVI");
set_row(_i++,"@0g%c", app);
stampa_classe = FALSE;
}
if (stampa_classe)
{
if ((_sez_da_stamp=='1')||(_sez_da_stamp=='2')||(_sez_da_stamp=='9'))
{
set_row(_i,"@0g%c", bil->let);
*_descr = (const char*) descr_let;
setta_righe_descr(_descr,lettera1,lettera2);
//set_row(_i++,"@1g)@3g%s", (const char*) descr_let);
//_cont_let += 1;
if (!_intera_struttura || (_intera_struttura && bil->gruppo[0] != 'Z'))
{
_cont_numr = 1;
_cont_num = 1;
_cont_gcs = 0;
}
if (numrom != "")
{
set_row(_i,"@3g%8s", (const char*) numrom);
*_descr = (const char*) descr_numr;
setta_righe_descr(_descr,numr1,numr2);
//set_row(_i++,"@12g-@14g%s", (const char*) descr_numr);
}
if (numero != 0)
{
set_row(_i,"@13g%s", bil->num);
*_descr = (const char*) descr_num;
setta_righe_descr(_descr,num,num2);
//set_row(_i++,"@15g)@18g%s", (const char*) descr_num);
}
}
}
}
else
if ((_numr_da_stamp!=_numr_stamp)&&(_sez_da_stamp==_sez_stamp)&&(_let_da_stamp==_let_stamp))
{
if ((_sez_da_stamp=='1')||(_sez_da_stamp=='2')||(_sez_da_stamp=='9'))
{
set_row(_i,"@3g%8s", (const char*) numrom);
*_descr = (const char*) descr_numr;
setta_righe_descr(_descr,numr1,numr2);
//set_row(_i++,"@12g-@14g%s", (const char*) descr_numr);
//_cont_numr += 1;
//_cont_numr = 1;
if (!_intera_struttura || (_intera_struttura && bil->gruppo[0] != 'Z'))
{
_cont_num = 1;
_cont_gcs = 0;
}
if (numero != 0)
{
set_row(_i,"@13g%s", bil->num);
*_descr = (const char*) descr_num;
setta_righe_descr(_descr,num,num2);
//set_row(_i++,"@15g)@18g%s", (const char*) descr_num);
}
}
}
else
if ((_num_da_stamp!=_num_stamp)&&(_sez_da_stamp==_sez_stamp)&&(_let_da_stamp==_let_stamp)&&(_numr_da_stamp==_numr_stamp))
{
if ((_sez_da_stamp=='1')||(_sez_da_stamp=='2')||(_sez_da_stamp=='9'))
{
set_row(_i,"@13g%s", bil->num);
*_descr = (const char*) descr_num;
setta_righe_descr(_descr,num,num2);
//set_row(_i++,"@15g)@18g%s", (const char*) descr_num);
//_cont_num += 1;
if (!_intera_struttura || (_intera_struttura && bil->gruppo[0] != 'Z'))
_cont_gcs = 0;
}
}
if (bil->gruppo[0] != 'A')
{
if (!_stampacod)
{
if (!_intera_struttura || (_intera_struttura && bil->gruppo[0] != 'Z'))
{
_cont_gcs += 1;
set_row (_i,"@18g%s", bil->gruppo);
set_row (_i,"@22g%s", bil->conto);
set_row (_i,"@26g%s", bil->sottoc);
set_row (_i,"@33g%s", (const char*) descr_sottoc);
set_row (_i,"@86g%r", &_sale);
if (_annoeserafr != 0 || _databilrafr != botime)
set_row (_i,"@112g%r", &_salerafr);
_i++;
}
}
else
{
if (!_intera_struttura || (_intera_struttura && bil->gruppo[0] != 'Z'))
{
_cont_gcs += 1;
if ((sezione != '0')&&(lettera == ' ')&&(numrom == "")&&(numero == 0))
descr_classe = _descr_sez;
if ((sezione != '0')&&(lettera != ' ')&&(numrom == "")&&(numero == 0))
descr_classe = descr_let;
if ((sezione != '0')&&(lettera != ' ')&&(numrom != "")&&(numero == 0))
descr_classe = descr_numr;
if ((sezione != '0')&&(lettera != ' ')&&(numrom != "")&&(numero != 0))
descr_classe = descr_num;
if (descr_classe != descr_sottoc)
{
set_row (_i,"@20g%s", (const char*) descr_sottoc);
set_row (_i,"@86g%r", &_sale);
if (_annoeserafr != 0 || _databilrafr != botime)
set_row (_i,"@112g%r", &_salerafr);
_i++;
}
}
}
}
}
void CG1600_application::setta_righe_verifica()
{
struct bil_ivd* bil = (struct bil_ivd*) _buff;
int numeror, numero, gruppo, conto;
char sezione,lettera,tmcf;
long sottoc;
TString numrom,numr;
TString descr_let,descr_numr,descr_num,descr_sottoc,descr_classe;
TString lettera1 = "@1g)@3g%s";
TString lettera2 = "@3g%s";
TString numr1 = "@8g)@10g%s";
TString numr2 = "@10g%s";
TString num = "@2g)@4g%s";
TString num2 = "@4g%s";
_descr->set_width(35);
sezione = bil->sez;
lettera = bil->let;
numr = bil->numr;
numeror = atoi(bil->numr);
numrom = itor(numeror);
numero = atoi(bil->num);
// num = bil->num;
gruppo = atoi(bil->gruppo);
conto = atoi(bil->conto);
sottoc = atoi(bil->sottoc);
tmcf = bil->tipocf;
descr_let = descrizione_lettera(sezione,lettera);
descr_numr = descrizione_numeroromano(sezione,lettera,numeror);
descr_num = descrizione_numero(sezione,lettera,numeror,numero);
if ((tmcf == 'C') || (tmcf == 'F'))
{
if (gruppo != 0 && conto != 0 && sottoc != 0)
{
TConto tc (gruppo,conto,sottoc,tmcf);
descr_sottoc = tc.descrizione();
}
else
descr_sottoc = descrizione_sottoconto(gruppo,conto,sottoc);
}
else
descr_sottoc = descrizione_sottoconto(gruppo,conto,sottoc);
//Se la classe prelevata dal record corrente del sort e' diversa dalla classe
//prelevata dal record precedente, allora stampo la nuova classe con i relativi
//sottoconti. In caso contrario continuo a stampare solo i sottoconti.
if (_sez_da_stamp != _sez_stamp)
{
char app = ' ';
set_row (_i,"@0g%c", app);
set_row (_i++,"@48g!@81g!@114g!");
if ((_sez_da_stamp=='1')||(_sez_da_stamp=='2')||(_sez_da_stamp== '9'))
{
if (_let_da_stamp != 'Z')
{
if (!_intera_struttura || (_intera_struttura && bil->gruppo[0] != 'Z'))
{
_cont_let = 1;
_cont_numr = 1;
_cont_num = 1;
_cont_gcs = 0;
}
if (lettera != '\0')
{
set_row(_i,"@0g%c", bil->let);
*_descr = (const char*) descr_let;
setta_righe_descr_verifica(_descr,lettera1,lettera2);
//set_row(_i,"@1g)@3g%s", (const char*) descr_let);
//set_row (_i++,"@48g!@81g!@114g!");
}
if (numrom != "")
{
set_row(_i,"@0g%8s", (const char*) numrom);
*_descr = (const char*) descr_numr;
setta_righe_descr_verifica(_descr,numr1,numr2);
//set_row(_i,"@8g)@10g%s", (const char*) descr_numr);
//set_row (_i++,"@48g!@81g!@114g!");
}
if (numero != 0)
{
set_row(_i,"@0g%s", bil->num);
*_descr = (const char*) descr_num;
setta_righe_descr_verifica(_descr,num,num2);
//set_row(_i,"@2g)@4g%s", (const char*) descr_num);
//set_row (_i++,"@48g!@81g!@114g!");
}
}
}
}
else
if ((_let_da_stamp!=_let_stamp)&&(_sez_da_stamp==_sez_stamp))
{
char app = ' ';
set_row (_i,"@0g%c", app);
set_row (_i++,"@48g!@81g!@114g!");
if ((_sez_da_stamp=='1')||(_sez_da_stamp=='2')||(_sez_da_stamp=='9'))
{
if (_let_da_stamp != 'Z')
{
set_row(_i,"@0g%c", bil->let);
*_descr = (const char*) descr_let;
setta_righe_descr_verifica(_descr,lettera1,lettera2);
//set_row(_i,"@1g)@3g%s", (const char*) descr_let);
//set_row (_i++,"@48g!@81g!@114g!");
//_cont_let += 1;
if (!_intera_struttura || (_intera_struttura && bil->gruppo[0] != 'Z'))
{
_cont_numr = 1;
_cont_num = 1;
_cont_gcs = 0;
}
if (numrom != "")
{
set_row(_i,"@0g%8s", (const char*) numrom);
*_descr = (const char*) descr_numr;
setta_righe_descr_verifica(_descr,numr1,numr2);
//set_row(_i,"@8g)@10g%s", (const char*) descr_numr);
//set_row (_i++,"@48g!@81g!@114g!");
}
if (numero != 0)
{
set_row(_i,"@0g%s", bil->num);
*_descr = (const char*) descr_num;
setta_righe_descr_verifica(_descr,num,num2);
//set_row(_i,"@2g)@4g%s", (const char*) descr_num);
//set_row (_i++,"@48g!@81g!@114g!");
}
}
}
}
else
if ((_numr_da_stamp!=_numr_stamp)&&(_sez_da_stamp==_sez_stamp)&&(_let_da_stamp==_let_stamp))
{
char app = ' ';
set_row (_i,"@0g%c", app);
set_row (_i++,"@48g!@81g!@114g!");
if ((_sez_da_stamp=='1')||(_sez_da_stamp=='2')||(_sez_da_stamp=='9'))
{
if (_let_da_stamp != 'Z')
{
set_row(_i,"@0g%8s", (const char*) numrom);
*_descr = (const char*) descr_numr;
setta_righe_descr_verifica(_descr,numr1,numr2);
//set_row(_i,"@8g)@10g%s", (const char*) descr_numr);
//set_row (_i++,"@48g!@81g!@114g!");
//_cont_numr += 1;
//_cont_numr = 1;
if (!_intera_struttura || (_intera_struttura && bil->gruppo[0] != 'Z'))
{
_cont_num = 1;
_cont_gcs = 0;
}
if (numero != 0)
{
set_row(_i,"@0g%s", bil->num);
*_descr = (const char*) descr_num;
setta_righe_descr_verifica(_descr,num,num2);
//set_row(_i,"@2g)@4g%s", (const char*) descr_num);
//set_row (_i++,"@48g!@81g!@114g!");
}
}
}
}
else
if ((_num_da_stamp!=_num_stamp)&&(_sez_da_stamp==_sez_stamp)&&(_let_da_stamp==_let_stamp)&&(_numr_da_stamp==_numr_stamp))
{
char app = ' ';
set_row (_i,"@0g%c", app);
set_row (_i++,"@48g!@81g!@114g!");
if ((_sez_da_stamp=='1')||(_sez_da_stamp=='2')||(_sez_da_stamp=='9'))
{
if (_let_da_stamp != 'Z')
{
set_row(_i,"@0g%s", bil->num);
*_descr = (const char*) descr_num;
setta_righe_descr_verifica(_descr,num,num2);
//set_row(_i,"@2g)@4g%s", (const char*) descr_num);
//set_row (_i++,"@48g!@81g!@114g!");
_cont_num += 1;
_cont_gcs = 0;
}
}
}
if (bil->gruppo[0] != 'A')
{
if (!_stampacod)
{
if (!_intera_struttura || (_intera_struttura && bil->gruppo[0] != 'Z'))
{
_cont_gcs += 1;
set_row (_i,"@0g%s", bil->gruppo);
set_row (_i,"@4g%s", bil->conto);
set_row (_i,"@8g%s", bil->sottoc);
set_row (_i,"@15g%s", (const char*) descr_sottoc);
set_row (_i,"@49g%r", &_sld_prg_dare);
set_row (_i,"@65g%r", &_sld_prg_avere);
set_row (_i,"@82g%r", &_mov_dare);
set_row (_i,"@98g%r", &_mov_avere);
if (_stampa_modulo)
{
if (_sez_saldo == 'D')
{
set_row (_i,"@115g%r", &_sale);
set_row (_i,"@48g!@81g!@114g!@131g!");
}
else
if (_sez_saldo == 'A')
{
set_row (_i,"@133g%r", &_sale);
set_row (_i,"@48g!@81g!@114g!@131g!");
}
}
else
{
set_row (_i,"@115g%r", &_sale);
set_row (_i,"@131g%c", _sez_saldo);
set_row (_i,"@48g!@81g!@114g!");
}
}
}
else
{
if (!_intera_struttura || (_intera_struttura && bil->gruppo[0] != 'Z'))
{
_cont_gcs += 1;
if ((sezione != '0')&&(lettera == ' ')&&(numrom == "")&&(numero == 0))
descr_classe = _descr_sez;
if ((sezione != '0')&&(lettera != ' ')&&(numrom == "")&&(numero == 0))
descr_classe = descr_let;
if ((sezione != '0')&&(lettera != ' ')&&(numrom != "")&&(numero == 0))
descr_classe = descr_numr;
if ((sezione != '0')&&(lettera != ' ')&&(numrom != "")&&(numero != 0))
descr_classe = descr_num;
if (descr_classe != descr_sottoc)
{
set_row (_i,"@2g%s", (const char*) descr_sottoc);
set_row (_i,"@49g%r", &_sld_prg_dare);
set_row (_i,"@66g%r", &_sld_prg_avere);
set_row (_i,"@82g%r", &_mov_dare);
set_row (_i,"@99g%r", &_mov_avere);
if (_stampa_modulo)
{
if (_sez_saldo == 'D')
{
set_row (_i,"@115g%r", &_sale);
set_row (_i,"@48g!@81g!@114g!@131g!");
}
else
if (_sez_saldo == 'A')
{
set_row (_i,"@133g%r", &_sale);
set_row (_i,"@48g!@81g!@114g!@131g!");
}
}
else
{
set_row (_i,"@115g%r", &_sale);
set_row (_i,"@131g%c", _sez_saldo);
set_row (_i,"@48g!@81g!@114g!");
}
}
}
}
}
}
void CG1600_application::setta_righe_descr(TParagraph_string* str,const TString& formato,const TString& formato2)
{
const char* r;
int i = 1;
while ((r = str->get()) != NULL)
{
if (i == 1)
set_row (_i,formato, r);
else
if (i > 1)
set_row (_i,formato2,r);
_i++;
i++;
}
}
void CG1600_application::setta_righe_descr_verifica(TParagraph_string* str,const TString& formato,const TString& formato2)
{
const char* r;
int i = 1;
while ((r = str->get()) != NULL)
{
if (i == 1)
set_row (_i,formato, r);
else
if (i > 1)
set_row (_i,formato2,r);
set_row (_i,"@48g!@81g!@114g!");
_i++;
i++;
}
}
const char* CG1600_application::descrizione_sezione(char sezione)
{
TTable tabivd(TAB_IVD);
TString dep, dep2;
tabivd.zero();
dep = format("%1c", sezione);
tabivd.put("CODTAB", dep);
tabivd.read();
dep2 = tabivd.get("CODTAB");
if (dep == dep2)
tmp = tabivd.get("S0");
else
tmp = "";
return tmp;
}
const char* CG1600_application::descrizione_lettera(char sezione, char lettera)
{
TTable tabivd(TAB_IVD);
TString dep, dep2;
tabivd.zero();
dep = format("%1c%1c", sezione, lettera);
tabivd.put("CODTAB", dep);
tabivd.read();
dep2 = tabivd.get("CODTAB");
if (dep == dep2)
tmp = tabivd.get("S0");
else
tmp = "";
return tmp;
}
const char* CG1600_application::descrizione_numeroromano(char sezione, char lettera, int numr)
{
TTable tabivd(TAB_IVD);
TString dep, dep2;
tabivd.zero();
if (numr != 0)
dep = format("%1c%1c%04d", sezione, lettera, numr);
else
dep = format("%c%c ", sezione, lettera);
tabivd.put("CODTAB", dep);
tabivd.read();
dep2 = tabivd.get("CODTAB");
if (dep == dep2)
tmp = tabivd.get("S0");
else
tmp = "";
return tmp;
}
const char* CG1600_application::descrizione_numero(char sezione, char lettera, int numr, int numero)
{
TTable tabivd(TAB_IVD);
TString dep,dep2;
tabivd.zero();
if (numr != 0)
dep = format("%1c%1c%04d%02d",sezione, lettera, numr, numero);
else
dep = format("%c%c %02d",sezione,lettera,numero);
tabivd.put("CODTAB", dep);
tabivd.read();
dep2 = tabivd.get("CODTAB");
if (dep == dep2)
tmp = tabivd.get("S0");
else
tmp = "";
return tmp;
}
const char* CG1600_application::descrizione_sottoconto(int gruppo, int conto, long sottoc)
{
TLocalisamfile pconti (LF_PCON);
pconti.zero();
pconti.put(PCN_GRUPPO , gruppo);
if (conto != 0)
pconti.put(PCN_CONTO , conto );
if (sottoc != 0)
pconti.put(PCN_SOTTOCONTO, sottoc);
pconti.read();
if (pconti.bad())
pconti.zero();
tmp = pconti.get(PCN_DESCR);
return tmp;
}
const char* CG1600_application::descr_sottoc_clifo(char tipocf,long s)
{
TLocalisamfile clifo (LF_CLIFO);
clifo.zero();
clifo.put(CLI_TIPOCF,tipocf);
if (s != 0)
clifo.put(CLI_CODCF, s);
clifo.read();
if (clifo.bad())
clifo.zero();
tmp = clifo.get(CLI_RAGSOC);
return tmp;
}
void CG1600_application::preprocess_header()
{
}
// Crea l'intestazione per la stampa a 132 e a 198 caratteri
void CG1600_application::crea_intestazione()
{
TString datastampastr;
TString sep(132),sep1(147);
TString app(8);
TLocalisamfile nditte (LF_NDITTE);
TLocalisamfile comuni (LF_COMUNI);
TLocalisamfile unloc (LF_UNLOC);
TLocalisamfile anag (LF_ANAG);
TString codice_ditta,ragsoc,indulc,civulc,capulc,com,prov,comulc;
TString cofi,paiv,tipoa,codanagr;
reset_header();
nditte.setkey(1);
codice_ditta << get_firm();
nditte.curr().zero();
nditte.curr().put(NDT_CODDITTA,codice_ditta);
nditte.read();
app=nditte.curr().get(NDT_CODDITTA);
ragsoc=nditte.curr().get(NDT_RAGSOC);
tipoa =nditte.curr().get(NDT_TIPOA);
codanagr = nditte.get(NDT_CODANAGR);
unloc.setkey(1);
unloc.curr().zero();
unloc.curr().put(ULC_CODDITTA,app);
unloc.curr().put(ULC_CODULC,"1");
unloc.read();
indulc=unloc.curr().get(ULC_INDULC);
civulc=unloc.curr().get(ULC_CIVULC);
capulc=unloc.curr().get(ULC_CAPULC);
comulc=unloc.curr().get(ULC_COMULC);
comuni.setkey(1);
comuni.curr().zero();
comuni.curr().put(COM_COM,comulc);
comuni.read();
com=comuni.curr().get(COM_DENCOM);
prov=comuni.curr().get(COM_PROVCOM);
anag.setkey(1);
anag.curr().zero();
anag.curr().put(ANA_TIPOA,tipoa);
anag.curr().put(ANA_CODANAGR,codanagr);
anag.read();
cofi=anag.curr().get(ANA_COFI);
paiv=anag.curr().get(ANA_PAIV);
set_header (1, "@0gDITTA@6g%-5s", (const char*) codice_ditta);
set_header (1, "@12g%-45s", (const char*) ragsoc);
set_header (1, "@59g%-25s", (const char*) indulc);
set_header (1, "@86g%-9s", (const char*) civulc);
set_header (1, "@97g%-5s", (const char*) capulc);
set_header (1, "@103g%-25s", (const char*) com);
set_header (1, "@129g%-3s", (const char*) prov);
if (_stampa_modulo)
{
sep1 << "Pag. @#";
sep1.right_just(139);
set_header(2,(const char*) sep1);
}
else
{
sep << "Pag. @#";
sep.right_just(132);
set_header(2,(const char*) sep);
}
datastampastr = _datastampa.string();
set_header (2,"@0gPartita iva@12g%-11s", (const char*) paiv);
set_header (2,"@30gCodice fiscale@45g%-16s", (const char*) cofi);
if (_stampa_modulo)
set_header (2,"@131gData@136g%s",(const char*) datastampastr);
else
set_header (2,"@105gData@110g%s",(const char*) datastampastr);
if (_tipo_bilancio == 1)
{
intesta_scalare();
}
else if (_tipo_bilancio == 2)
{
intesta_verifica();
}
}
void CG1600_application::intesta_verifica_fissa()
{
TString sep(132),app(32),sep1(147);
if (_tipo_stampa == 1)
{
if (_dataini == _data_ini_ese)
set_header(5,"@57gSALDO INIZIALE@87gMOVIMENTI DEL PERIODO");
else if (_dataini > _data_ini_ese)
set_header(5,"@54gPROGRESSIVI PRECEDENTI@87gMOVIMENTI DEL PERIODO");
}
else if (_tipo_stampa == 2)
set_header(5,"@57gSALDO INIZIALE@87gMOVIMENTI DEL PERIODO");
if (_stampa_modulo)
set_header(5,"@129gSALDO");
set_header(5,"@48g!@81g!@114g!");
if (_stampa_modulo)
{
set_header(5,"@147g!");
set_header(6,"@131g!@147g!");
}
set_header(6,"@48g!@81g!@114g!");
app = "--------------------------------";
if (_stampa_modulo)
{
set_header(6,"@49g%s@82g%s@115g%s", (const char*) app, (const char*) app,(const char*) app);
set_header(7,"@1gdescrizione voce@48g!@57gDare@65g!@72gAvere@81g!@90gDare@98g!@105gAvere@114g!@122gDare@131g!@138gAvere@147g!");
sep1.fill('-'); //Stampa 132 - (sep(132))
set_header (8, (const char *) sep1);
}
else
{
set_header(6,"@49g%s@82g%s@122gSALDO", (const char*) app, (const char*) app);
set_header(7,"@1gdescrizione voce@48g!@57gDare@65g!@72gAvere@81g!@90gDare@98g!@105gAvere@114g!");
sep.fill('-'); //Stampa 132 - (sep(132))
set_header (8, (const char *) sep);
}
}
void CG1600_application::intesta_scalare()
{
TString datalimitestr,databilrafrstr;
TString sep(132);
set_header (3,"@0gSTAMPA BILANCIO CONFORME ALLA IV DIRETTIVA");
set_header (3,"@89gEsercizio@99g%d", _anno_esercizio);
if (_annoeserafr != 0 || _databilrafr != botime)
{
set_header (3,"@115gEsercizio@125g%d", _anno_esercizio_raf);
databilrafrstr = _databilrafr.string();
set_header (4,"@112galla data@122g%s", (const char*) databilrafrstr);
}
if (_tipo_stampa == 1)
{
datalimitestr = _datalimite.string();
set_header (4,"@86galla data@96g%s", (const char*) datalimitestr);
}
else if (_tipo_stampa == 2)
set_header (4,"@90gall' ultima immissione");
sep.fill('-'); //Stampa 132 - (sep(132))
set_header (5, (const char *) sep);
}
void CG1600_application::intesta_verifica()
{
TString sep(132),sep1(147);
set_header (3,"@0gBILANCIO DI VERIFICA IV DIRETTIVA");
if (_tipo_stampa == 1)
{
TString datainistr = _dataini.string();
TString datafinestr = _datafine.string();
set_header (3,"@43gdalla data@54g%s", (const char*) datainistr);
set_header (3,"@65galla data@75g%s", (const char*) datafinestr);
}
else if (_tipo_stampa == 2)
set_header (3,"@42gall' ultima immissione");
if (_stampa_modulo)
{
sep1.fill('-'); //Stampa 132 - (sep(132))
set_header (4, (const char *) sep1);
}
else
{
sep.fill('-'); //Stampa 132 - (sep(132))
set_header (4, (const char *) sep);
}
intesta_verifica_fissa();
}
void CG1600_application::init_sort()
{
_bil = new bil_ivd;
_sort = new TSort (sizeof(bil_ivd));
_sort -> addsortkey ((char*)&(_bil->sez) - (char*)&(_bil->sez),1);
_sort -> addsortkey ((char*)&(_bil->let) - (char*)&(_bil->sez),1);
_sort -> addsortkey ((char*)&(_bil->numr) - (char*)&(_bil->sez),4);
_sort -> addsortkey ((char*)&(_bil->num) - (char*)&(_bil->sez),2);
_sort -> addsortkey ((char*)&(_bil->gruppo) - (char*)&(_bil->sez),3);
_sort -> addsortkey ((char*)&(_bil->conto) - (char*)&(_bil->sez),3);
_sort -> addsortkey ((char*)&(_bil->sottoc) - (char*)&(_bil->sez),6);
_sort->init();
}
bool CG1600_application::user_create()
{
_nditte = new TLocalisamfile (LF_NDITTE);
_comuni = new TLocalisamfile (LF_COMUNI);
_unloc = new TLocalisamfile (LF_UNLOC);
_anag = new TLocalisamfile (LF_ANAG);
_pconti = new TLocalisamfile (LF_PCON);
_clifo = new TLocalisamfile (LF_CLIFO);
_saldi = new TLocalisamfile (LF_SALDI);
_descr = new TParagraph_string ("",40);
_tabivd = new TTable (TAB_IVD);
_tabesc = new TTable (TAB_ESC);
_anni_es = new Anni_es();
_sld = new Saldo();
_msk = new TMask("cg1600a");
return TRUE;
}
bool CG1600_application::user_destroy()
{
delete _msk;
delete _tabivd;
delete _tabesc;
delete _nditte;
delete _comuni;
delete _unloc;
delete _anag;
delete _pconti;
delete _clifo;
delete _saldi;
delete _descr;
delete _anni_es;
delete _sld;
return TRUE;
}
int cg1600 (int argc, char* argv[])
{
CG1600_application a;
a.run(argc, argv, "Stampa Bilancio IV direttiva CEE");
return 0;
}