Patch level : 2.0 678

Files correlati     : 772.exe
Ricompilazione Demo : [ ]
Commento            :

CM20091
Immettendo in questo caso specifico di Medicasa da Persona fisica F/60014
a Persona fisica F/60460 e controllando il percipiente Porta Gianluigi i si
accorge che per lo steso percipiente vengono stampate 3 certificazioni per
valori diversi  (la n° 1,la 10, la 12). Se al contrario richiedo la sola
persona fisica F/60316 la certificazione è correttamente una sola,
di cui il totale è la somma delle tre stampate in precedenza.


git-svn-id: svn://10.65.10.50/trunk@11736 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 2004-02-02 13:49:53 +00:00
parent e15b71e0e0
commit 028a37ab42

View File

@ -1,11 +1,9 @@
// 772200.cpp - Stampa certificazioni // 772200.cpp - Stampa certificazioni
#include <config.h>
#include <mask.h>
#include <printapp.h> #include <printapp.h>
#include <progind.h> #include <progind.h>
#include <relation.h> #include <recarray.h>
#include <sort.h> #include <sort.h>
#include <tabutil.h>
#include <comuni.h> #include <comuni.h>
#include <nditte.h> #include <nditte.h>
@ -44,10 +42,8 @@ class TSt_certif : public TPrintapp
real netto; real netto;
real inps; real inps;
}; };
righe_pag* _rig;
TRelation* _rel; TRelation* _rel;
TCursor* _cur; TCursor* _cur;
TProgind* _prog;
TSort* _sort; TSort* _sort;
const char* _buf; const char* _buf;
TLocalisamfile* _nditte; TLocalisamfile* _nditte;
@ -55,7 +51,6 @@ class TSt_certif : public TPrintapp
TLocalisamfile* _rpag; TLocalisamfile* _rpag;
TLocalisamfile* _scperc; TLocalisamfile* _scperc;
TLocalisamfile* _comuni; TLocalisamfile* _comuni;
TTable* _ca7;
TString80 _ragsocER, _indER, _civER, _capER, _dencomER, _provER, _cofiER; TString80 _ragsocER, _indER, _civER, _capER, _dencomER, _provER, _cofiER;
TString80 _ragsocPE, _indPE, _civPE, _capPE, _dencomPE, _provPE, _cofiPE; TString80 _ragsocPE, _indPE, _civPE, _capPE, _dencomPE, _provPE, _cofiPE;
TString80 _dencomnscER, _provnscER, _dencomnscPE, _provnscPE; TString80 _dencomnscER, _provnscER, _dencomnscPE, _provnscPE;
@ -90,7 +85,7 @@ protected:
bool init_print(); bool init_print();
public: public:
TRectype& look_causali(); const TRectype& look_causali();
TRectype& look_schperc(long,char,long,int); TRectype& look_schperc(long,char,long,int);
void crea_sort(); void crea_sort();
void init_sort(); void init_sort();
@ -167,33 +162,24 @@ TRectype& TSt_certif::look_schperc (long cod, char t, long codan, int np)
return schede.curr(); return schede.curr();
} }
TRectype& TSt_certif::look_causali() const TRectype& TSt_certif::look_causali()
{ {
TString16 dep; TString4 dep; dep.format("%02d", _codc_p);
return cache().get("%CA7", dep);
_ca7->zero();
dep.format("%02d", _codc_p);
_ca7->put("CODTAB", dep);
_ca7->read();
if (_ca7->bad())
_ca7->zero();
return _ca7->curr();
} }
void TSt_certif::init_sort() void TSt_certif::init_sort()
{ {
_rig = new righe_pag;
_sort = new TSort(sizeof(righe_pag)); _sort = new TSort(sizeof(righe_pag));
/* // _sort->addsortkey (0, 23); // Non si puo': la sort usa strncmp!
_sort->addsortkey ((char*)&(_rig->ditta) - (char*)&(_rig->ditta),5); righe_pag rig;
_sort->addsortkey ((char*)&(_rig->tipoa) - (char*)&(_rig->ditta),1); _sort->addsortkey((char*)&(rig.ditta) - (char*)&(rig.ditta),5);
_sort->addsortkey ((char*)&(_rig->codan) - (char*)&(_rig->ditta),5); _sort->addsortkey((char*)&(rig.tipoa) - (char*)&(rig.ditta),1);
_sort->addsortkey ((char*)&(_rig->perc) - (char*)&(_rig->ditta),6); _sort->addsortkey((char*)&(rig.codan) - (char*)&(rig.ditta),5);
_sort->addsortkey ((char*)&(_rig->codc) - (char*)&(_rig->ditta),2); _sort->addsortkey((char*)&(rig.perc) - (char*)&(rig.ditta),6);
*/ _sort->addsortkey((char*)&(rig.codc) - (char*)&(rig.ditta),2);
_sort->addsortkey (0, 23);
_sort->init(); _sort->init();
} }
@ -210,10 +196,15 @@ void TSt_certif::crea_sort()
nprogc = -1; nprogc = -1;
init_sort(); init_sort();
*_cur = 0l;
for (int i = 0; i < _cur->items(); i++, ++(*_cur)) const TRecnotype totrec = _cur->items();
_cur->freeze();
TProgind prog(totrec, TR("Elaborazione in corso..."), FALSE);
for (*_cur = 0; _cur->pos() < totrec; ++(*_cur))
{ {
_prog->addstatus(1); prog.addstatus(1);
ditta = _cur->curr().get_long(PAG_CODDITTA); ditta = _cur->curr().get_long(PAG_CODDITTA);
tipoa = _cur->curr().get(PAG_TIPOA)[0]; tipoa = _cur->curr().get(PAG_TIPOA)[0];
codan = _cur->curr().get_long(PAG_CODANAGR); codan = _cur->curr().get_long(PAG_CODANAGR);
@ -256,6 +247,8 @@ void TSt_certif::crea_sort()
riempi_record(ditta,tipoa,codan,perc,codc,corrisp,somme,quote,impo,rite,netto,inps); 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, void TSt_certif::riempi_record(long d,char t,long ca,const real& p,int c,
@ -263,48 +256,49 @@ void TSt_certif::riempi_record(long d,char t,long ca,const real& p,int c,
const real& qu,const real& im,const real& ri, const real& qu,const real& im,const real& ri,
const real& ne, const real& inps) const real& ne, const real& inps)
{ {
sprintf(_rig->ditta, "%5ld", d); righe_pag rig;
_rig->tipoa = t;
sprintf(_rig->codan, "%5ld", ca); sprintf(rig.ditta, "%5ld", d);
//sprintf(_rig->perc, "%2d", p); rig.tipoa = t;
TString16 pp(p.string("###,@@")); sprintf(rig.codan, "%5ld", ca);
sprintf(_rig->perc, "%s", (const char*)pp); TString8 pp(p.string("##@,@@"));
sprintf(_rig->codc, "%02d", c); sprintf(rig.perc, "%s", (const char*)pp);
_rig->corr = co; sprintf(rig.codc, "%02d", c);
_rig->somme = so; rig.corr = co;
_rig->quote = qu; rig.somme = so;
_rig->impo = im; rig.quote = qu;
_rig->rite = ri; rig.impo = im;
_rig->netto = ne; rig.rite = ri;
_rig->inps = inps; rig.netto = ne;
rig.inps = inps;
_sort->sort((const char*)_rig); _sort->sort((const char*)&rig);
} }
int TSt_certif::stampa_riga(int i, int ct, const char* d) int TSt_certif::stampa_riga(int i, int ct, const char* d)
{ {
if (!_st_modulo) if (!_st_modulo)
{ {
TString16 app (_perc_p.left(3)); //stampo solo la parte intera TString16 app (_perc_p.left(3)); //stampo solo la parte intera
app.ltrim(); app.ltrim();
real lordo_netto_iva = _tot_corr + _tot_somme; real lordo_netto_iva = _tot_corr + _tot_somme;
real somme_quote = _tot_somme + _tot_quote; 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,"%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); set_row(i++,"@83g%s@86g%r@101g%r@117g%r",(const char*)app,&_tot_rite,&_tot_inps,&_tot_netto);
} }
else else
{ {
real non_sogg = _tot_corr - _tot_impo + _tot_somme; real non_sogg = _tot_corr - _tot_impo + _tot_somme;
real imp_netto = _tot_impo - _tot_rite /* - _tot_inps */; real imp_netto = _tot_impo - _tot_rite /* - _tot_inps */;
TString16 app (_perc_p.left(3)); TString16 app (_perc_p.left(3));
app.ltrim(); 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", 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); ct,d,&_tot_corr,&non_sogg,&_tot_impo,(const char*)app,&_tot_rite,&imp_netto);
set_row(i, ""); set_row(i, "");
} }
return i; return i;
} }
// Totale su carta bianca // Totale su carta bianca
@ -324,14 +318,14 @@ void TSt_certif::stampa_totale(int i)
void TSt_certif::salva_totale() void TSt_certif::salva_totale()
{ {
//salvo gli importi del record che sto leggendo //salvo gli importi del record che sto leggendo
_tot_corr += _corr; _tot_corr += _corr;
_tot_somme+= _somme; _tot_somme+= _somme;
_tot_quote+= _quote; _tot_quote+= _quote;
_tot_impo += _impo; _tot_impo += _impo;
_tot_rite += _rite; _tot_rite += _rite;
_tot_netto+= _netto; _tot_netto+= _netto;
_tot_inps += _inps; _tot_inps += _inps;
} }
void TSt_certif::leggi_sort() void TSt_certif::leggi_sort()
@ -369,9 +363,9 @@ void TSt_certif::leggi_sort()
if (key1 != _key1p && _key1p != "") //e' cambiato il percipiente if (key1 != _key1p && _key1p != "") //e' cambiato il percipiente
{ {
TRectype cau = look_causali(); const TRectype& cau = look_causali();
TString descr = cau.get("S0"); const TString& descr = cau.get("S0");
int codtrib = cau.get_int("I0"); const int codtrib = cau.get_int("I0");
i = stampa_riga(i, codtrib, descr); i = stampa_riga(i, codtrib, descr);
@ -398,9 +392,9 @@ void TSt_certif::leggi_sort()
} }
else if (key2 != _key2p && _key2p != "") else if (key2 != _key2p && _key2p != "")
{ {
TRectype cau = look_causali(); const TRectype& cau = look_causali();
TString descr = cau.get("S0"); const TString& descr = cau.get("S0");
int codtrib = cau.get_int("I0"); const int codtrib = cau.get_int("I0");
stampa_riga(i, codtrib, descr); stampa_riga(i, codtrib, descr);
@ -437,9 +431,9 @@ void TSt_certif::leggi_sort()
} }
else if (_stampa) //sono finiti i record ma c'e' ancora un record da stampare else if (_stampa) //sono finiti i record ma c'e' ancora un record da stampare
{ {
TRectype cau = look_causali(); const TRectype& cau = look_causali();
TString descr = cau.get("S0"); const TString& descr = cau.get("S0");
int codtrib = cau.get_int("I0"); const int codtrib = cau.get_int("I0");
/* /*
_tipoa_p = _tipoa; _tipoa_p = _tipoa;
@ -685,14 +679,9 @@ bool TSt_certif::init_print()
set_print_zero(FALSE); set_print_zero(FALSE);
set_magic_currency(TRUE); set_magic_currency(TRUE);
_prog = new TProgind(_cur->items(),"Elaborazione in corso...",FALSE);
crea_sort(); crea_sort();
_sort->endsort(); _sort->endsort();
delete _rig;
delete _prog;
return TRUE; return TRUE;
} }
else else
@ -1007,8 +996,6 @@ bool TSt_certif::user_create()
_anag = new TLocalisamfile (LF_ANAG); _anag = new TLocalisamfile (LF_ANAG);
_rpag = new TLocalisamfile (LF_RPAG); _rpag = new TLocalisamfile (LF_RPAG);
_scperc = new TLocalisamfile (LF_SCPERC); _scperc = new TLocalisamfile (LF_SCPERC);
_ca7 = new TTable ("%CA7");
_rig = new righe_pag;
return TRUE; return TRUE;
} }
@ -1022,8 +1009,6 @@ bool TSt_certif::user_destroy()
delete _comuni; delete _comuni;
delete _rpag; delete _rpag;
delete _scperc; delete _scperc;
delete _ca7;
delete _rig;
delete _cnf; delete _cnf;
delete _cns; delete _cns;