Files correlati : Ricompilazione Demo : [ ] Commento : Questo sorgente NON è più usato!!! Infatti la stampa (vecchia printapp) è stata sostituita con 2 report, che vengono stampati normalmente dallo stampatore standard dei report (ba8). Il sorgente viene comunque committato con le ultime modifiche che si erano provate a fare per ottemperare alcune richieste poi soddisfatte con i report in 1/10 del tempo. Il file andrebbe comunque rimosso in via definitiva, sia perchè inutile sia, soprattutto, perchè fulgido esempio di pessima programmazione! git-svn-id: svn://10.65.10.50/trunk@18856 c028cbd2-c16b-5b4b-a496-9718f37d4682
1007 lines
29 KiB
C++
Executable File
1007 lines
29 KiB
C++
Executable File
// 772200.cpp - Stampa certificazioni
|
||
|
||
#include <printapp.h>
|
||
#include <progind.h>
|
||
#include <recarray.h>
|
||
#include <sort.h>
|
||
|
||
#include <comuni.h>
|
||
#include <nditte.h>
|
||
#include <anagr.h>
|
||
#include <anafis.h>
|
||
|
||
#include "perc.h"
|
||
#include "rpag.h"
|
||
#include "scperc.h"
|
||
|
||
#include "772.h"
|
||
#include "772200.h"
|
||
#include "77lib.h"
|
||
|
||
class TSt_certif : public TPrintapp
|
||
{
|
||
char _liv; // Se stampa a livello di studio
|
||
int _anno_dic; // Anno dichiarazione nei paramentri utente o studio
|
||
|
||
// Configurazione
|
||
TString16 _section;
|
||
TConfig* _cnf,* _cns;
|
||
|
||
struct righe_pag
|
||
{
|
||
char ditta[6];
|
||
char tipoa;
|
||
char codan[6];
|
||
char perc[7];
|
||
char codc[3];
|
||
real corr;
|
||
real somme;
|
||
real quote;
|
||
real impo;
|
||
real rite;
|
||
real netto;
|
||
real inps;
|
||
};
|
||
TRelation* _rel;
|
||
TCursor* _cur;
|
||
TSort* _sort;
|
||
const char* _buf;
|
||
TLocalisamfile* _nditte;
|
||
TLocalisamfile* _anag;
|
||
TLocalisamfile* _rpag;
|
||
TLocalisamfile* _scperc;
|
||
TLocalisamfile* _comuni;
|
||
TString80 _ragsocER, _indER, _civER, _capER, _dencomER, _provER, _cofiER, _pivaER;
|
||
TString80 _ragsocPE, _indPE, _civPE, _capPE, _dencomPE, _provPE, _cofiPE, _pivaPE;
|
||
TString80 _dencomnscER, _provnscER, _dencomnscPE, _provnscPE;
|
||
TString80 _datanascER, _datanascPE, _luogo;
|
||
TString16 _key1p, _key2p, _perc_p;
|
||
TDate _data;
|
||
char _tipoa_p, _tipoa;
|
||
int _mese_da, _mese_a, _codc_p, _codc;
|
||
int _riga, _off_lung, _conta;
|
||
long _num_att, _codanagER, _codanagPE_p, _codanagPE;
|
||
real _tot_corr, _tot_somme, _tot_quote, _tot_impo, _tot_rite, _tot_netto, _tot_inps;
|
||
real _t_corr, _t_somme, _t_quote, _t_impo, _t_rite, _t_netto, _t_inps;
|
||
real _corr, _quote, _impo, _rite, _netto, _somme, _inps;
|
||
bool _intesta, _stampa, _settato_totale, _fai_footer, _stampa_righe_pagamenti;
|
||
bool _st_modulo, _st_data;
|
||
|
||
protected:
|
||
virtual void on_config_change();
|
||
virtual bool user_create() ;
|
||
virtual bool user_destroy();
|
||
virtual bool set_print(int m);
|
||
virtual bool preprocess_page (int,int);
|
||
virtual bool preprocess_print(int,int);
|
||
virtual print_action postprocess_page (int,int);
|
||
virtual void postclose_print();
|
||
virtual void preprocess_header();
|
||
virtual void preprocess_footer();
|
||
|
||
static bool mese_handler(TMask_field& f, KEY k);
|
||
static bool codditta_hnd(TMask_field& f, KEY k);
|
||
|
||
bool init_print();
|
||
|
||
public:
|
||
const TRectype& look_causali(int codc) const;
|
||
TRectype& look_schperc(long,char,long,int);
|
||
void crea_sort();
|
||
void init_sort();
|
||
void leggi_sort();
|
||
void stampa_su_modulo();
|
||
void stampa_totale(int);
|
||
void salva_totale();
|
||
int stampa_riga(int i);
|
||
int stampa_riga_pagamento(int i);
|
||
void dati_erogante();
|
||
void dati_percipiente();
|
||
void riempi_record(long,char,long,const real&,int,const real&,const real&,const real&,const real&,const real&,const real&,const real&);
|
||
|
||
// D = stampa ditta, S = stampa a livello di studio
|
||
TSt_certif(char livello='D') : _intesta(TRUE), _liv(toupper(livello)) {}
|
||
virtual ~TSt_certif() {}
|
||
};
|
||
|
||
bool TSt_certif::codditta_hnd(TMask_field& f, KEY k)
|
||
{
|
||
if (k == K_TAB && !(f.mask().is_running()) )
|
||
{
|
||
TString8 codditta; codditta << get_firm_770();
|
||
if (codditta != "0")
|
||
{
|
||
f.set(codditta);
|
||
f.check();
|
||
}
|
||
}
|
||
|
||
return TRUE;
|
||
}
|
||
|
||
void TSt_certif::on_config_change()
|
||
{
|
||
TConfig conf(_liv == 'S' ? CONFIG_USER : CONFIG_STUDIO);
|
||
_anno_dic = conf.get_int(ANNO_SEL, _section);
|
||
if (_liv == 'D')
|
||
{
|
||
TConfig confs(CONFIG_USER);
|
||
_st_data = confs.get_bool(ST_DATA, "77ps");
|
||
}
|
||
else
|
||
_st_data = conf.get_bool(ST_DATA, "77ps");
|
||
}
|
||
|
||
bool TSt_certif::mese_handler (TMask_field& f, KEY k)
|
||
{
|
||
if (k == K_ENTER)
|
||
{
|
||
const int meseda = f.mask().get_int(F_DA);
|
||
const int mesea = atoi(f.get());
|
||
if (meseda > mesea)
|
||
{
|
||
f.error_box("Il mese di inizio periodo non deve essere superiore al mese di fine periodo");
|
||
return FALSE;
|
||
}
|
||
}
|
||
return TRUE;
|
||
}
|
||
|
||
TRectype& TSt_certif::look_schperc (long cod, char t, long codan, int np)
|
||
{
|
||
TLocalisamfile& schede = *_scperc;
|
||
schede.zero();
|
||
schede.put(SPR_CODDITTA, cod);
|
||
schede.put(SPR_TIPOA, t);
|
||
schede.put(SPR_CODANAGR, codan);
|
||
schede.put(SPR_NPROG, np);
|
||
if (schede.read() != NOERR)
|
||
schede.zero();
|
||
|
||
return schede.curr();
|
||
}
|
||
|
||
const TRectype& TSt_certif::look_causali(int codc) const
|
||
{
|
||
TString4 dep; dep.format("%02d", codc);
|
||
return cache().get("%CA7", dep);
|
||
}
|
||
|
||
void TSt_certif::init_sort()
|
||
{
|
||
_sort = new TSort(sizeof(righe_pag));
|
||
|
||
// _sort->addsortkey (0, 23); // Non si puo': la sort usa strncmp!
|
||
righe_pag rig;
|
||
_sort->addsortkey((char*)&(rig.ditta) - (char*)&(rig.ditta),5);
|
||
_sort->addsortkey((char*)&(rig.tipoa) - (char*)&(rig.ditta),1);
|
||
_sort->addsortkey((char*)&(rig.codan) - (char*)&(rig.ditta),5);
|
||
_sort->addsortkey((char*)&(rig.perc) - (char*)&(rig.ditta),6);
|
||
_sort->addsortkey((char*)&(rig.codc) - (char*)&(rig.ditta),2);
|
||
|
||
_sort->init();
|
||
}
|
||
|
||
void TSt_certif::crea_sort()
|
||
{
|
||
long dittac = 0, codanc = 0;
|
||
char tipoac = '\0';
|
||
int nprogc = -1;
|
||
|
||
init_sort();
|
||
|
||
const TRecnotype totrec = _cur->items();
|
||
_cur->freeze();
|
||
|
||
TProgind prog(totrec, TR("Elaborazione in corso..."), FALSE);
|
||
const TRectype& curr = _cur->curr();
|
||
|
||
for (*_cur = 0; _cur->pos() < totrec; ++(*_cur))
|
||
{
|
||
prog.addstatus(1);
|
||
const long ditta = curr.get_long(PAG_CODDITTA);
|
||
const char tipoa = curr.get(PAG_TIPOA)[0];
|
||
const long codan = curr.get_long(PAG_CODANAGR);
|
||
const int nprog = curr.get_int(PAG_NPROG);
|
||
const TDate datapag = curr.get(PAG_DATAPAG);
|
||
if (ditta == dittac && tipoa == tipoac && codan == codanc && nprog == nprogc)
|
||
continue;
|
||
const TRectype& dep = look_schperc(ditta, tipoa, codan, nprog);
|
||
const int mese = dep.get_int(SPR_MESEC);
|
||
const int anno = dep.get_int(SPR_ANNOC);
|
||
const int codc = dep.get_int(SPR_CODCAUS);
|
||
if ( anno != 0 ) //se c'e' l'anno c'e' di certo anche il mese (Omero)
|
||
{
|
||
if ( anno != _anno_dic || (mese < _mese_da || mese > _mese_a ) )
|
||
{
|
||
dittac = ditta;
|
||
tipoac = tipoa;
|
||
codanc = codan;
|
||
nprogc = nprog;
|
||
continue;
|
||
}
|
||
}
|
||
else //anno non specificato
|
||
{
|
||
if ( datapag.year() != _anno_dic || (datapag.month() < _mese_da || mese > _mese_a) )
|
||
{
|
||
//dittac = ditta;
|
||
//tipoac = tipoa;
|
||
//codanc = codan;
|
||
//nprogc = nprog;
|
||
continue;
|
||
}
|
||
}
|
||
const real perc = curr.get_real(PAG_PERC);
|
||
const real somme = curr.get_real(PAG_SPESA);
|
||
const real corrisp = curr.get_real(PAG_COMPENSO);
|
||
const real rite = curr.get_real(PAG_RITENUTA);
|
||
const real impo = curr.get_real(PAG_IMPONIBILE);
|
||
const real netto = curr.get_real(PAG_NETTO);
|
||
const real inps = curr.get_real(PAG_INPSPERC);
|
||
const real quote = corrisp-impo;
|
||
riempi_record(ditta,tipoa,codan,perc,codc,corrisp,somme,quote,impo,rite,netto,inps);
|
||
}
|
||
|
||
_cur->freeze(false);
|
||
}
|
||
|
||
void TSt_certif::riempi_record(long d,char t,long ca,const real& p,int c,
|
||
const real& co,const real& so,
|
||
const real& qu,const real& im,const real& ri,
|
||
const real& ne, const real& inps)
|
||
{
|
||
righe_pag rig;
|
||
|
||
sprintf(rig.ditta, "%5ld", d);
|
||
rig.tipoa = t;
|
||
sprintf(rig.codan, "%5ld", ca);
|
||
TString8 pp(p.string("##@,@@"));
|
||
sprintf(rig.perc, "%s", (const char*)pp);
|
||
sprintf(rig.codc, "%02d", c);
|
||
rig.corr = co;
|
||
rig.somme = so;
|
||
rig.quote = qu;
|
||
rig.impo = im;
|
||
rig.rite = ri;
|
||
rig.netto = ne;
|
||
rig.inps = inps;
|
||
|
||
_sort->sort((const char*)&rig);
|
||
}
|
||
|
||
int TSt_certif::stampa_riga(int i)
|
||
{
|
||
const TRectype& cau = look_causali(_codc_p);
|
||
const char* d = cau.get("S0");
|
||
const int ct = cau.get_int("I0");
|
||
|
||
//nel caso si scelga di dettagliare i pagamenti, conviene metterci una riga vuota di stacco
|
||
if (_stampa_righe_pagamenti)
|
||
set_row(i++, "");
|
||
|
||
if (!_st_modulo)
|
||
{
|
||
TString16 app (_perc_p.left(3)); //stampo solo la parte intera
|
||
app.ltrim();
|
||
|
||
real lordo_netto_iva = _tot_corr + _tot_somme;
|
||
real somme_quote = _tot_somme + _tot_quote;
|
||
|
||
set_row(i, "%02d %4d %-.25s @34g%r@50g%r@66g%r", _codc_p, ct, d, &lordo_netto_iva, &somme_quote, &_tot_impo);
|
||
set_row(i++, "@83g%s@86g%r@101g%r@117g%r", (const char*)app, &_tot_rite, &_tot_inps, &_tot_netto);
|
||
}
|
||
else
|
||
{
|
||
real non_sogg = _tot_corr - _tot_impo + _tot_somme;
|
||
real imp_netto = _tot_impo - _tot_rite /* - _tot_inps */;
|
||
TString16 app (_perc_p.left(3));
|
||
app.ltrim();
|
||
set_row(i++, "@3g%4d@11g%-.28s@43g%12.0r@57g%12.0r@71g%12.0r@85g%s@89g%12.0r@104g%12.0r",
|
||
ct, d, &_tot_corr, &non_sogg, &_tot_impo, (const char*)app, &_tot_rite, &imp_netto);
|
||
set_row(i, "");
|
||
}
|
||
return i;
|
||
}
|
||
|
||
//stampa delle righe di pagamento
|
||
int TSt_certif::stampa_riga_pagamento(int i)
|
||
{
|
||
const TRectype& cau = look_causali(_codc);
|
||
const char* d = cau.get("S0");
|
||
const int ct = cau.get_int("I0");
|
||
|
||
if (!_st_modulo)
|
||
{
|
||
TString16 app (_perc_p.left(3)); //stampo solo la parte intera
|
||
app.ltrim();
|
||
|
||
real lordo_netto_iva = _corr + _somme;
|
||
real somme_quote = _somme + _quote;
|
||
|
||
set_row(i, "%02d %4d %-.25s @34g%r@50g%r@66g%r", _codc, ct, d, &lordo_netto_iva, &somme_quote, &_impo);
|
||
set_row(i++, "@83g%s@86g%r@101g%r@117g%r", (const char*)app, &_rite, &_inps, &_netto);
|
||
}
|
||
else
|
||
{
|
||
real non_sogg = _corr - _impo + _somme;
|
||
real imp_netto = _impo - _rite;
|
||
TString16 app (_perc_p.left(3));
|
||
app.ltrim();
|
||
set_row(i++, "@3g%4d@11g%-.28s@43g%12.0r@57g%12.0r@71g%12.0r@85g%s@89g%12.0r@104g%12.0r",
|
||
ct, d, &_corr, &non_sogg, &_impo, (const char*)app, &_rite, &imp_netto);
|
||
set_row(i, "");
|
||
}
|
||
return i;
|
||
}
|
||
|
||
// Totale su carta bianca
|
||
void TSt_certif::stampa_totale(int i)
|
||
{
|
||
TString dep(94); dep.fill('-');
|
||
set_row(i++, "");
|
||
set_row(i++, "@38g%s", (const char*) dep);
|
||
|
||
real lordo_netto_iva = _t_corr + _t_somme;
|
||
real somme_quote = _t_somme + _t_quote;
|
||
|
||
set_row(i, "@15gTOTALE@34g%r@50g%r@66g%r@86g%r@101g%r@117g%r",
|
||
&lordo_netto_iva, &somme_quote, &_t_impo, &_t_rite, &_t_inps, &_t_netto);
|
||
}
|
||
|
||
void TSt_certif::salva_totale()
|
||
{
|
||
//salvo gli importi del record che sto leggendo
|
||
_tot_corr += _corr;
|
||
_tot_somme+= _somme;
|
||
_tot_quote+= _quote;
|
||
_tot_impo += _impo;
|
||
_tot_rite += _rite;
|
||
_tot_netto+= _netto;
|
||
_tot_inps += _inps;
|
||
}
|
||
|
||
void TSt_certif::leggi_sort()
|
||
{
|
||
int i = 1;
|
||
reset_print();
|
||
|
||
//il concetto e' che quando sto stampando un record sto gia' leggendo i dati del record successivo!!!
|
||
if ((_buf = _sort->retrieve()) != NULL)
|
||
{
|
||
TString16 key1, key2;
|
||
struct righe_pag* rp = (struct righe_pag*)_buf;
|
||
long ditta = atol(rp->ditta);
|
||
_tipoa = rp->tipoa;
|
||
_codanagPE = atol(rp->codan);
|
||
|
||
if (_key1p == "")
|
||
{
|
||
_tipoa_p = _tipoa;
|
||
_codanagPE_p = _codanagPE;
|
||
}
|
||
|
||
//valori del singolo record di pagamento (vengono stampati solo se richiesto il dettaglio delle righe di pagamento)
|
||
TString16 perc = rp->perc;
|
||
_codc = atoi(rp->codc);
|
||
_corr = rp->corr;
|
||
_somme = rp->somme;
|
||
_quote = rp->quote;
|
||
_impo = rp->impo;
|
||
_rite = rp->rite;
|
||
_netto = rp->netto;
|
||
_inps = rp->inps;
|
||
|
||
key1.format("%c%5ld", _tipoa, _codanagPE);
|
||
key2.format("%s%02d", (const char*)perc, _codc);
|
||
|
||
if (key1 != _key1p && _key1p != "") //e' cambiato il percipiente
|
||
{
|
||
//se si vuole il dettaglio dei pagamenti si deve rinunciare al totale di causale (senn<6E> ci vien su un casino..
|
||
//..mondiale)
|
||
if (!_stampa_righe_pagamenti)
|
||
i = stampa_riga(i);
|
||
|
||
//aggiornamento totale finale
|
||
_t_corr += _tot_corr;
|
||
_t_somme += _tot_somme;
|
||
_t_quote += _tot_quote;
|
||
_t_impo += _tot_impo;
|
||
_t_rite += _tot_rite;
|
||
_t_netto += _tot_netto;
|
||
_t_inps += _tot_inps;
|
||
|
||
if (!_st_modulo)
|
||
{
|
||
//questo va stampato in ogni modo
|
||
stampa_totale(i);
|
||
//<2F> nel caso di cambiamento percipiente (e quindi anche di causale)
|
||
//azzera i totali per causale
|
||
_tot_corr = _tot_somme = _tot_quote = _tot_impo = _tot_rite = _tot_netto = _tot_inps = ZERO;
|
||
//azzera i totali per percipiente
|
||
_t_corr = _t_somme = _t_quote = _t_impo = _t_rite =_t_netto = _t_inps = ZERO;
|
||
}
|
||
|
||
_settato_totale = true;
|
||
}
|
||
else if (key2 != _key2p && _key2p != "") //<2F> cambiata la causale del pagamento all'interno dello stesso percipiente
|
||
{
|
||
//se si vuole il dettaglio dei pagamenti si deve rinunciare al totale di causale (senn<6E> ci vien su un casino..
|
||
//..mondiale)
|
||
if (!_stampa_righe_pagamenti)
|
||
stampa_riga(i);
|
||
|
||
_t_corr += _tot_corr;
|
||
_t_somme += _tot_somme;
|
||
_t_quote += _tot_quote;
|
||
_t_impo += _tot_impo;
|
||
_t_rite += _tot_rite;
|
||
_t_netto += _tot_netto;
|
||
_t_inps += _tot_inps;
|
||
|
||
//azzera i totali per causale (<28> nel caso in cui cambia la causale ma non il percipiente)
|
||
_tot_corr = _tot_somme = _tot_quote = _tot_impo = _tot_rite = _tot_netto = _tot_inps = ZERO;
|
||
|
||
if (_st_modulo)
|
||
_conta += 1;
|
||
}
|
||
|
||
//stampa i dettagli di tutte le righe di pagamento
|
||
if (_stampa_righe_pagamenti && (key1 == _key1p || _key1p.empty()))
|
||
i = stampa_riga_pagamento(i);
|
||
|
||
_codc_p = _codc;
|
||
_perc_p = perc;
|
||
_key1p = key1,
|
||
_key2p = key2;
|
||
_stampa = TRUE;
|
||
}
|
||
else if (_stampa) //sono finiti i record ma c'e' ancora un record da stampare
|
||
{
|
||
//se si vuole il dettaglio dei pagamenti si deve rinunciare al totale di causale (senn<6E> ci vien su un casino..
|
||
//..mondiale)
|
||
if (!_stampa_righe_pagamenti)
|
||
stampa_riga(i);
|
||
|
||
_t_corr += _tot_corr;
|
||
_t_somme += _tot_somme;
|
||
_t_quote += _tot_quote;
|
||
_t_impo += _tot_impo;
|
||
_t_rite += _tot_rite;
|
||
_t_netto += _tot_netto;
|
||
_t_inps += _tot_inps;
|
||
|
||
if (!_st_modulo)
|
||
stampa_totale(i);
|
||
|
||
_settato_totale = TRUE;
|
||
}
|
||
}
|
||
|
||
void TSt_certif::preprocess_footer()
|
||
{
|
||
if (_st_modulo)
|
||
{
|
||
//riga totale
|
||
real t_non_sogg = _t_corr - _t_impo + _t_somme;
|
||
real t_imp_netto = _t_impo - _t_rite;
|
||
|
||
reset_footer();
|
||
|
||
int r = 1;
|
||
|
||
TString tc, tns, ti, tr, tim;
|
||
tc = _t_corr.string();
|
||
tns = t_non_sogg.string();
|
||
ti = _t_impo.string();
|
||
tr = _t_rite.string();
|
||
tim = t_imp_netto.string();
|
||
|
||
_tot_corr=_tot_somme=_tot_quote=_tot_impo=_tot_rite=_tot_netto=_tot_inps=ZERO;
|
||
|
||
if (_settato_totale)
|
||
_t_corr = _t_somme = _t_quote = _t_impo = _t_rite =_t_netto = _t_inps = ZERO;
|
||
|
||
if (_settato_totale)
|
||
set_footer(r++, "@43g%12s@57g%12s@71g%12s@89g%12s@104g%12s", (const char*)tc,
|
||
(const char*)tns,(const char*)ti,(const char*)tr,(const char*)tim);
|
||
else
|
||
set_footer(r++, "@5gsegue...");
|
||
|
||
set_footer(r++, "");
|
||
set_footer(r++, "");
|
||
set_footer(r++, "");
|
||
set_footer(r++, "");
|
||
set_footer(r++, "");
|
||
set_footer(r++, "");
|
||
set_footer(r++, "");
|
||
set_footer(r++, "");
|
||
set_footer(r++, "@3g%s",(const char*) _ragsocER);
|
||
set_footer(r++, "");
|
||
set_footer(r++, "@3g%s %s",(const char*) _indER, (const char*) _civER);
|
||
set_footer(r++, "");
|
||
set_footer(r++, "@3g%s %s %s", (const char*) _capER, (const char*) _dencomER,
|
||
(const char*) _provER);
|
||
set_footer(r++, "");
|
||
set_footer(r, "@3g%s", (const char*)_cofiER);
|
||
//set_footer(r, "@3g%s", (const char*)_pivaER); la partita iva non <20> ancora richiesta ma andrebbe qui (occhi alle coordinate!)
|
||
r+=2;
|
||
if (_st_data)
|
||
set_footer(++r, "@16g%s", (const char*)_data);
|
||
}
|
||
else if (_fai_footer)
|
||
{
|
||
reset_footer();
|
||
|
||
TString dep(71);
|
||
dep.fill('-');
|
||
int r = 1;
|
||
|
||
set_footer(r++, "LE CIFRE GLOBALI SU ESPOSTE CORRISPONDONO ALLE SINGOLE REGISTRAZIONI RISULTANTI NEL CONTO INDIVIDUALE DEL");
|
||
set_footer(r++, "PERCIPIENTE LE CUI RITENUTE D'ACCONTO SONO STATE VERSATE NEI TERMINI DI LEGGE.");
|
||
set_footer(r++, "");
|
||
set_footer(r++, "@1g%s", (const char*) dep);
|
||
set_footer(r++, "!@5gDATI IDENTIFICATIVI DEL SOGGETTO EROGANTE O SOSTITUTO D'IMPOSTA@72g!");
|
||
set_footer(r , "!@1g%s@72g!", (const char*) dep);
|
||
set_footer(r++, "@85gIn fede.");
|
||
set_footer(r++, "!@15g%s@72g!",(const char*) _ragsocER);
|
||
set_footer(r++, "! Indirizzo:@15g%s %s@72g!",(const char*) _indER, (const char*) _civER);
|
||
set_footer(r++, "!@6g%s@15g%s %s@72g!",(const char*) _capER, (const char*) _dencomER,
|
||
(const char*) _provER);
|
||
set_footer(r, "! Cod.Fiscale: %16s@40gP.Iva: %11s@72g!", (const char*) _cofiER, (const char*)_pivaER);
|
||
set_footer(r++, "@74g----------------------------------------");
|
||
set_footer(r, "@1g%s", (const char*) dep);
|
||
set_footer(r, "@90g(Firma)");
|
||
|
||
_fai_footer = FALSE;
|
||
}
|
||
}
|
||
|
||
bool TSt_certif::preprocess_print(int file, int counter)
|
||
{
|
||
_key1p = _key2p = "";
|
||
_tot_corr = _tot_somme = _tot_quote = _tot_impo = _tot_rite = _tot_netto = _tot_inps = ZERO;
|
||
_t_corr = _t_somme = _t_quote = _t_impo = _t_rite = _t_netto = _t_inps = ZERO;
|
||
_stampa = _settato_totale = _fai_footer = FALSE;
|
||
_conta = 0;
|
||
|
||
return TRUE;
|
||
}
|
||
|
||
bool TSt_certif::preprocess_page(int file, int counter)
|
||
{
|
||
leggi_sort();
|
||
return TRUE;
|
||
}
|
||
|
||
print_action TSt_certif::postprocess_page(int file, int counter)
|
||
{
|
||
//devo usare due flag diversi: _settato_totale mi dice se fare oppure no
|
||
//un formfeed cosi' da richiamare la preprocess_footer() anche se il totale viene stampato
|
||
//prima dell'area del footer. Se pero' sto stampando proprio il totale nell'area del footer
|
||
//viene richiamata la preprocess_footer() che a questo punto deve essere eseguita solo se e' vero il
|
||
//flag _fai_footer. Infatti se controllassi il flag _settato_totale esso sarebbe vero in questo caso
|
||
//e il risultato sarebbe quello di vedere stampato il footer e a pagina vuota il totale del percipiente
|
||
//e cio' non sarebbe corretto!
|
||
if (_settato_totale)
|
||
if (!_st_modulo)
|
||
{
|
||
_intesta = TRUE;
|
||
_fai_footer = TRUE;
|
||
_tipoa_p = _tipoa; //serve alla preprocess_header
|
||
_codanagPE_p = _codanagPE; //idem
|
||
printer().formfeed();
|
||
_settato_totale = FALSE;
|
||
}
|
||
else
|
||
{
|
||
_tipoa_p = _tipoa; //serve alla preprocess_header
|
||
_codanagPE_p = _codanagPE; //idem
|
||
_conta = 0;
|
||
printer().formfeed();
|
||
_settato_totale = FALSE;
|
||
}
|
||
|
||
if (_st_modulo && _conta == 8)
|
||
{
|
||
_conta = 0;
|
||
printer().formfeed();
|
||
}
|
||
|
||
if (_buf == NULL)
|
||
return NEXT_PAGE;
|
||
|
||
salva_totale();
|
||
|
||
return REPEAT_PAGE;
|
||
}
|
||
|
||
void TSt_certif::postclose_print()
|
||
{
|
||
delete _sort;
|
||
}
|
||
|
||
bool TSt_certif::init_print()
|
||
{
|
||
TMask msk ("772200a");
|
||
msk.set_handler (F_A, mese_handler);
|
||
msk.set_handler (F_CODDITTA, codditta_hnd);
|
||
|
||
// precarica campi maschera con valori di default
|
||
_nditte->setkey(1);
|
||
_nditte->zero();
|
||
_nditte->put(NDT_CODDITTA, get_firm_770());
|
||
if (_nditte->read() == NOERR)
|
||
{
|
||
// precarico luogo
|
||
TToken_string address = get_anag_address(_nditte->get_char(NDT_TIPOA),
|
||
_nditte->get_long(NDT_CODANAGR));
|
||
msk.set(F_LUOGO, address.get(0));
|
||
}
|
||
|
||
msk.set(F_ATTESTA,1); // precarico numero attestazione
|
||
msk.set(F_A, 12); // Imposto dicembre come mese finale
|
||
|
||
// esecuzione maschera
|
||
KEY tasto = msk.run();
|
||
|
||
if (tasto == K_ENTER)
|
||
{
|
||
char tipoa_da = msk.get(F_TIPODA)[0];
|
||
long cod_da = msk.get_long(F_CODDA);
|
||
char tipoa_a = msk.get(F_TIPOA)[0];
|
||
long cod_a = msk.get_long(F_CODA);
|
||
long codditta = get_firm_770();
|
||
|
||
_num_att = msk.get_long(F_ATTESTA);
|
||
_mese_da = msk.get_int(F_DA);
|
||
_mese_a = msk.get_int(F_A);
|
||
_luogo = msk.get(F_LUOGO);
|
||
_data = msk.get(F_DATA);
|
||
|
||
//aggiunta fatta il 16/03/2009, dopo soli 14 anni che il file non veniva cambiato
|
||
_stampa_righe_pagamenti = msk.get_bool(F_DETTAGLIO);
|
||
|
||
_st_modulo = msk.get_bool(F_MODULO);
|
||
_off_lung = msk.get_int(F_LUNG);
|
||
|
||
TLocalisamfile& fl = _cur->file(LF_RPAG);
|
||
TRectype da (fl.curr());
|
||
TRectype a (fl.curr());
|
||
|
||
da.zero();
|
||
a.zero();
|
||
|
||
da.put(PAG_CODDITTA, codditta);
|
||
da.put(PAG_TIPOA, tipoa_da);
|
||
da.put(PAG_CODANAGR, cod_da);
|
||
|
||
a.put(PAG_CODDITTA, codditta);
|
||
a.put(PAG_TIPOA, tipoa_a);
|
||
a.put(PAG_CODANAGR, cod_a);
|
||
|
||
_cur->setregion(da, a);
|
||
|
||
_intesta = TRUE;
|
||
dati_erogante();
|
||
if (!_st_modulo)
|
||
{
|
||
set_real_picture ("###.###.###.###");
|
||
printer().footerlen(11);
|
||
for (int i=1; i<=11; i++)
|
||
set_footer(i, " ");
|
||
}
|
||
else
|
||
{
|
||
int area_footer = 31 - _off_lung;
|
||
printer().footerlen(area_footer);
|
||
for (int i=1; i<=area_footer; i++)
|
||
set_footer(i, " ");
|
||
}
|
||
|
||
set_print_zero(FALSE);
|
||
set_magic_currency(TRUE);
|
||
|
||
crea_sort();
|
||
_sort->endsort();
|
||
|
||
return TRUE;
|
||
}
|
||
else
|
||
return FALSE;
|
||
}
|
||
|
||
bool TSt_certif::set_print(int)
|
||
{
|
||
long codditta, codditta_prec;
|
||
int i = 0;
|
||
|
||
if (_liv == 'S')
|
||
{
|
||
codditta_prec = get_firm_770();
|
||
while ((codditta = _cnf->get_long(DITTE_SEL, _section, i++)) != 0L)
|
||
{
|
||
set_firm_770(codditta);
|
||
|
||
// init_print ritorna TRUE solo se K_ENTER
|
||
if (init_print())
|
||
print();
|
||
else
|
||
break;
|
||
}
|
||
set_firm_770(codditta_prec);
|
||
// Non richiamare di nuovo print()!
|
||
return FALSE;
|
||
}
|
||
else
|
||
return init_print();
|
||
}
|
||
|
||
void TSt_certif::stampa_su_modulo()
|
||
{
|
||
dati_percipiente();
|
||
|
||
set_header(_off_lung, "@26g%s", (const char*)_ragsocPE);
|
||
set_header(_off_lung + 1, "@8g%4d", _anno_dic);
|
||
if (_tipoa_p == 'F')
|
||
{
|
||
set_header(_off_lung + 2, "@26g%-.50s %s %s",(const char*)_dencomnscPE,
|
||
(const char*)_provnscPE,(const char*)_datanascPE);
|
||
set_header(_off_lung + 6, "@26g%-.35s", (const char*)_dencomPE);
|
||
}
|
||
set_header(_off_lung + 6, "@8g%ld", _num_att++);
|
||
set_header(_off_lung + 4, "@26g%16s", (const char*)_cofiPE);
|
||
//set_header(_off_lung + 4, "@26g%16s", (const char*)_pivaPE); la partita iva non <20> ancora richiesta ma andrebbe qui (occhi alle coordinate!)
|
||
set_header(_off_lung + 8, "@26g%-.35s %s %5s %-.35s %s", (const char*)_indPE,
|
||
(const char*)_civPE,(const char*)_capPE,(const char*)_dencomPE,(const char*)_provPE);
|
||
|
||
int app = _off_lung + 6;
|
||
for (int i = app; i <= app + 12; i++)
|
||
set_header(i, "");
|
||
}
|
||
|
||
void TSt_certif::preprocess_header()
|
||
{
|
||
int i = 1;
|
||
|
||
reset_header();
|
||
|
||
if (_st_modulo)
|
||
{
|
||
stampa_su_modulo();
|
||
return;
|
||
}
|
||
|
||
if (_intesta)
|
||
{
|
||
TString dep(73);
|
||
dep.fill('-');
|
||
dati_percipiente();
|
||
set_header(i++, "@1g-----------------------------------------------------------------");
|
||
set_header(i++, "!@12gCERTIFICAZIONE DEI COMPENSI@66g!");
|
||
set_header(i++, "!@9gASSOGGETTATI A RITENUTA D'ACCONTO@66g!");
|
||
set_header(i++, "!@3g(Art.4 commi 6-ter e 6-quater D.P.R. 22 Luglio 1998, n.332)@66g!");
|
||
set_header(i++, "@1g-----------------------------------------------------------------");
|
||
set_header(i++, "");
|
||
set_header(i++, "@59g%s", (const char*) dep);
|
||
set_header(i++, "@58g!@84gSOGGETTO PERCIPIENTE@132g!");
|
||
set_header(i++, "@58g!%s@132g!", (const char*) dep);
|
||
set_header(i, "@29gATTESTAZIONE RILASCIATA A:@58g!");
|
||
if (_tipoa_p == 'F')
|
||
set_header(i, "@60gCognome e Nome:");
|
||
else
|
||
set_header(i, "@60gDenominazione:");
|
||
set_header(i++, " %s@132g!", (const char*)_ragsocPE );
|
||
set_header(i++, "@58g!@60gDomicilio in %s %s@132g!", (const char*)_indPE,(const char*)_civPE);
|
||
set_header(i++, "@58g!@70g%5s %-.46s %s@132g!", (const char*)_capPE,(const char*)_dencomPE,(const char*)_provPE);
|
||
if (_tipoa_p == 'F')
|
||
{
|
||
set_header(i++, "@58g!@60gLuogo e data di nascita: %-.30s %s %s@132g!", (const char*)_dencomnscPE,
|
||
(const char*)_provnscPE,(const char*)_datanascPE);
|
||
set_header(i, "ANNO EROGAZIONE ATTESTAZIONE@58g!@132g!");
|
||
set_header(i++, "@60gComune di iscrizione anagrafica: %-.35s", (const char*)_dencomPE);
|
||
}
|
||
else
|
||
{
|
||
set_header(i++, "@58g!@132g!");
|
||
set_header(i++, "ANNO EROGAZIONE ATTESTAZIONE@58g!@132g!");
|
||
}
|
||
set_header(i++, "@5g%d@25g%ld@58g!@60gCodice fiscale: %16s@97gP.IVA: %11s@132g!", _anno_dic,_num_att++,(const char*)_cofiPE, (const char*)_pivaPE);
|
||
set_header(i++, "@59g%s", (const char*) dep);
|
||
set_header(i++, "");
|
||
set_header(i++, "@50g%s,li %d %s %d", (const char*)_luogo, _data.day(), itom(_data.month()), _data.year());
|
||
set_header(i++, "");
|
||
set_header(i++, "@7gPer gli adempimenti previsti dall'Art.4 commi 6-ter e 6-quater D.P.R. 22 Luglio 1998, n.332 e successive modificazioni");
|
||
set_header(i++, "si attesta che nel corso del periodo dal 01/01/%d al 31/12/%d al percipiente evidenziato in riquadro", _anno_dic, _anno_dic);
|
||
set_header(i++, "sono stati corrisposti i seguenti compensi debitamente assoggettati a ritenuta d'acconto e ad eventuale ritenuta previdenziale:");
|
||
set_header(i++, "");
|
||
_intesta = FALSE;
|
||
}
|
||
TString sep(132);
|
||
sep.fill('-');
|
||
set_header(i++, (const char*)sep);
|
||
set_header(i++, "Codice@36gTotale lordo@53gSomme e Quote@90gRitenute@108gRitenute");
|
||
set_header(i++, "Cs Trib Descrizione@36gal netto IVA@53gNon soggette@69gImponibile@83gAl@90gFiscali@108gPrevidenz.@123gNet.corr.");
|
||
set_header(i, (const char*)sep);
|
||
}
|
||
|
||
void TSt_certif::dati_erogante()
|
||
{
|
||
long codditta;
|
||
char tipoa;
|
||
TString com,comnasc;
|
||
TDate data;
|
||
|
||
codditta = get_firm_770();
|
||
|
||
_nditte->setkey(1);
|
||
_nditte->curr().zero();
|
||
_nditte->curr().put(NDT_CODDITTA, codditta);
|
||
if (_nditte->read() == NOERR)
|
||
{
|
||
tipoa = _nditte->get_char(NDT_TIPOA);
|
||
_codanagER = _nditte->get_long(NDT_CODANAGR);
|
||
}
|
||
_anag->setkey(1);
|
||
_anag->zero();
|
||
_anag->put(ANA_TIPOA, tipoa);
|
||
_anag->put(ANA_CODANAGR, _codanagER);
|
||
if (_anag->read() == NOERR)
|
||
{
|
||
_ragsocER = _anag->get(ANA_RAGSOC);
|
||
_cofiER = _anag->get(ANA_COFI);
|
||
_pivaER = _anag->get(ANA_PAIV);
|
||
|
||
if (tipoa == 'F')
|
||
{
|
||
TString80 nome = _ragsocER.mid(30);
|
||
_ragsocER.cut(30);
|
||
_ragsocER.trim(); nome.trim();
|
||
_ragsocER << ' ' << nome;
|
||
}
|
||
|
||
com = _anag->get(ANA_COMRF);
|
||
|
||
if (com != "")
|
||
{
|
||
_indER = _anag->get(ANA_INDRF);
|
||
_civER = _anag->get(ANA_CIVRF);
|
||
_capER = _anag->get(ANA_CAPRF);
|
||
}
|
||
else
|
||
{
|
||
_indER = _anag->get(ANA_INDRES);
|
||
_civER = _anag->get(ANA_CIVRES);
|
||
_capER = _anag->get(ANA_CAPRES);
|
||
com = _anag->get(ANA_COMRES);
|
||
}
|
||
}
|
||
_comuni->setkey(1);
|
||
_comuni->zero();
|
||
_comuni->put(COM_COM,com);
|
||
if (_comuni->read() == NOERR)
|
||
{
|
||
_dencomER = _comuni->get(COM_DENCOM);
|
||
_provER = _comuni->get(COM_PROVCOM);
|
||
}
|
||
}
|
||
|
||
void TSt_certif::dati_percipiente()
|
||
{
|
||
TString com;
|
||
TDate data;
|
||
TString comnasc;
|
||
|
||
_anag->setkey(1);
|
||
_anag->zero();
|
||
_anag->put(ANA_TIPOA, _tipoa_p);
|
||
_anag->put(ANA_CODANAGR, _codanagPE_p);
|
||
if (_anag->read() == NOERR)
|
||
{
|
||
_ragsocPE = _anag->get(ANA_RAGSOC);
|
||
_cofiPE = _anag->get(ANA_COFI);
|
||
_pivaPE = _anag->get(ANA_PAIV);
|
||
if (_tipoa_p == 'F')
|
||
{
|
||
TString80 nome = _ragsocPE.mid(30);
|
||
_ragsocPE.cut(30);
|
||
_ragsocPE.trim(); nome.trim();
|
||
_ragsocPE << ' ' << nome;
|
||
}
|
||
com = _anag->get(ANA_COMRF);
|
||
if (com != "")
|
||
{
|
||
_indPE = _anag->get(ANA_INDRF);
|
||
_civPE = _anag->get(ANA_CIVRF);
|
||
_capPE = _anag->get(ANA_CAPRF);
|
||
}
|
||
else
|
||
{
|
||
_indPE = _anag->get(ANA_INDRES);
|
||
_civPE = _anag->get(ANA_CIVRES);
|
||
_capPE = _anag->get(ANA_CAPRES);
|
||
com = _anag->get(ANA_COMRES);
|
||
}
|
||
}
|
||
_comuni->setkey(1);
|
||
_comuni->zero();
|
||
_comuni->put(COM_COM,com);
|
||
if (_comuni->read() == NOERR)
|
||
{
|
||
_dencomPE = _comuni->get(COM_DENCOM);
|
||
_provPE = _comuni->get(COM_PROVCOM);
|
||
}
|
||
if (_tipoa_p == 'F')
|
||
{
|
||
TLocalisamfile anagfis(LF_ANAGFIS);
|
||
anagfis.setkey(1);
|
||
anagfis.zero();
|
||
anagfis.put(ANF_CODANAGR, _codanagPE_p);
|
||
if (anagfis.read() == NOERR)
|
||
{
|
||
data = anagfis.get_date(ANF_DATANASC);
|
||
_datanascPE = data.string();
|
||
comnasc = anagfis.get(ANF_COMNASC);
|
||
}
|
||
_comuni->setkey(1);
|
||
_comuni->zero();
|
||
_comuni->put(COM_COM,comnasc);
|
||
if (_comuni->read() == NOERR)
|
||
{
|
||
_dencomnscPE = _comuni->get(COM_DENCOM);
|
||
_provnscPE = _comuni->get(COM_PROVCOM);
|
||
}
|
||
_dencomnscPE.rtrim();
|
||
_provnscPE.rtrim();
|
||
}
|
||
else
|
||
{
|
||
_dencomnscPE = "";
|
||
_provnscPE = "";
|
||
}
|
||
_indPE.rtrim();
|
||
_dencomPE.rtrim();
|
||
}
|
||
|
||
bool TSt_certif::user_create()
|
||
{
|
||
// Parametri configurazione
|
||
_section = name();
|
||
_section.cut(2);
|
||
_cnf = new TConfig(CONFIG_USER, _section);
|
||
_cns = new TConfig(CONFIG_USER, "77ps");
|
||
|
||
_rel = new TRelation (LF_RPAG);
|
||
_cur = new TCursor(_rel,"",1);
|
||
|
||
_nditte = new TLocalisamfile (LF_NDITTE);
|
||
_comuni = new TLocalisamfile (LF_COMUNI);
|
||
_anag = new TLocalisamfile (LF_ANAG);
|
||
_rpag = new TLocalisamfile (LF_RPAG);
|
||
_scperc = new TLocalisamfile (LF_SCPERC);
|
||
|
||
return true;
|
||
}
|
||
|
||
bool TSt_certif::user_destroy()
|
||
{
|
||
delete _rel;
|
||
delete _cur;
|
||
delete _nditte;
|
||
delete _anag;
|
||
delete _comuni;
|
||
delete _rpag;
|
||
delete _scperc;
|
||
delete _cnf;
|
||
delete _cns;
|
||
|
||
return true;
|
||
}
|
||
|
||
int m72200(int argc, char* argv[])
|
||
{
|
||
TSt_certif a(*argv[2]);
|
||
a.run(argc, argv, "Stampa certificazioni");
|
||
return 0;
|
||
}
|