From bc38b3776ad5add71772c4c6e7d150ba0511ddd1 Mon Sep 17 00:00:00 2001 From: guy Date: Mon, 13 Feb 2012 15:02:35 +0000 Subject: [PATCH] Patch level : 10.0 Files correlati : 772.exe Ricompilazione Demo : [ ] Commento : Corretto filtro su competenza in stampa movimenti percipiente git-svn-id: svn://10.65.10.50/branches/R_10_00@22574 c028cbd2-c16b-5b4b-a496-9718f37d4682 --- m770/772300.cpp | 26 +++++++++++---- m770/77lib.h | 4 +-- m770/77lib01.cpp | 87 ++++++++++++++++++++++-------------------------- 3 files changed, 61 insertions(+), 56 deletions(-) diff --git a/m770/772300.cpp b/m770/772300.cpp index f44cf818a..614c734dc 100755 --- a/m770/772300.cpp +++ b/m770/772300.cpp @@ -82,7 +82,7 @@ HIDDEN TStampa_mov& app() { return (TStampa_mov&) main_app(); } bool filter_func (const TRelation * rel) { const int anno_corr = app()._anno; - TRectype sch_curr(rel->lfile().curr()); + const TRectype& sch_curr = rel->curr(); TSchedaP scheda(sch_curr); return esiste_pag_in_anno(scheda, anno_corr); } @@ -293,10 +293,17 @@ bool TStampa_mov::preprocess_page(int file, int counter) _iva = sch_curr.get_real(SPR_IVA); _totdoc = sch_curr.get_real(SPR_TOTALE); - const int anno_doc = datadoc.year(); - TSchedaP scheda(sch_curr); - bool esiste_pag_anno_in_periodo = esiste_pag_in_periodo(scheda, _datada, _dataa); - bool stampa_scheda = (anno_doc == _anno_dic) || esiste_pag_anno_in_periodo; + bool stampa_scheda = false; + if (_datada > botime || _dataa < eotime) + { + const TSchedaP scheda(sch_curr); + stampa_scheda = esiste_pag_in_periodo(scheda, _datada, _dataa); + } + else + { + const int anno_doc = datadoc.year(); + stampa_scheda = anno_doc == _anno_dic; + } if (!stampa_scheda) return true; @@ -481,7 +488,6 @@ bool TStampa_mov::init_print() TRectype da(LF_SCPERC), a(LF_SCPERC); TString filter; - da.put(SPR_CODDITTA, _codditta); da.put(SPR_TIPOA, _tipoa_da); da.put(SPR_CODANAGR, _cod_da); @@ -498,6 +504,12 @@ bool TStampa_mov::init_print() filter << "(" << SPR_ANNOC << "<=" << _dataa.year() << ")&&(" << SPR_MESEC << "<=" << _dataa.month() <<")"; } + if (filter.full()) + { + filter.insert("("); + filter << ")||(" << SPR_ANNOC << "==0)"; + } + current_cursor()->setregion(da, a); current_cursor()->setfilter(filter); @@ -603,6 +615,6 @@ bool TStampa_mov::user_destroy() int m72300(int argc, char* argv[]) { TStampa_mov a(*argv[2]); - a.run(argc, argv, "Stampa movimenti per percipienti"); + a.run(argc, argv, TR("Stampa movimenti per percipienti")); return 0; } diff --git a/m770/77lib.h b/m770/77lib.h index 674bf4997..b01d62f04 100755 --- a/m770/77lib.h +++ b/m770/77lib.h @@ -56,9 +56,9 @@ bool scrivi_erede(const long codditta, const long deceduto, const long erede); bool riscrivi_erede(const long codditta, const long deceduto, const long erede, const long val); // Determina se esiste un pagamento con annopag = anno passato come par. -bool esiste_pag_in_anno(TSchedaP& sch, const int anno=0, const TDate& data_da=NULLDATE, const TDate& data_a=NULLDATE, const int annocomp=0); +bool esiste_pag_in_anno(const TSchedaP& sch, const int anno=0, const TDate& data_da=NULLDATE, const TDate& data_a=NULLDATE, const int annocomp=0); // La stessa cosa tra due date -bool esiste_pag_in_periodo(TSchedaP& sch, const TDate& data_da, const TDate& data_a); +bool esiste_pag_in_periodo(const TSchedaP& sch, const TDate& data_da, const TDate& data_a); //////////////////////////////////////////////////////////////////////// diff --git a/m770/77lib01.cpp b/m770/77lib01.cpp index f04625e9c..a4e7d6892 100755 --- a/m770/77lib01.cpp +++ b/m770/77lib01.cpp @@ -344,46 +344,39 @@ bool riscrivi_erede(const long codditta, const long deceduto, const long erede, return TRUE; } -bool esiste_pag_in_periodo(TSchedaP& sch, const TDate& data_da, const TDate& data_a) -{ - return esiste_pag_in_anno(sch, 0, data_da, data_a); -} +bool esiste_pag_in_periodo(const TSchedaP& sch, const TDate& data_da, const TDate& data_a) +{ return esiste_pag_in_anno(sch, 0, data_da, data_a); } // Determina se esiste un pagamento con annopag = anno passato come par. // oppure se passato, sostituisce anno pagamento con anno competenza -bool esiste_pag_in_anno(TSchedaP& sch, const int annodic, const TDate& data_da, const TDate& data_a, const int annocomp) +bool esiste_pag_in_anno(const TSchedaP& sch, const int annodic, const TDate& data_da, const TDate& data_a, const int annocomp) { - TLocalisamfile* rpag = new TLocalisamfile(LF_RPAG); - const bool filtra_anno = annodic != 0; - const bool filtra_periodo = !filtra_anno; - - rpag->zero(); - rpag->put(PAG_CODDITTA, sch.codditta()); - rpag->put(PAG_TIPOA, sch.tipoa()); - rpag->put(PAG_CODANAGR, sch.codanagr()); - rpag->put(PAG_NPROG, sch.nprog()); - TRectype mst(rpag->curr()); - for (rpag->read(_isgteq); !rpag->eof(); rpag->next()) + TLocalisamfile rpag(LF_RPAG); + rpag.put(PAG_CODDITTA, sch.codditta()); + rpag.put(PAG_TIPOA, sch.tipoa()); + rpag.put(PAG_CODANAGR, sch.codanagr()); + rpag.put(PAG_NPROG, sch.nprog()); + const TRectype mst(rpag.curr()); + for (int err = rpag.read(_isgteq); err == NOERR; err = rpag.next()) { - if (rpag->curr() > mst) break; - const TDate datapag = rpag->get_date(PAG_DATAPAG); + if (rpag.curr() > mst) + break; + + const TDate datapag = rpag.get_date(PAG_DATAPAG); - if (filtra_anno) + if (annodic != 0) { - int annopag = datapag.year(); - if (annocomp) - annopag = annocomp; + const int annopag = annocomp > 0 ? annocomp : datapag.year(); if (annopag == annodic) - return TRUE; + return true; } - - if (filtra_periodo) + else { - if (datapag <= data_a && datapag >= data_da) - return TRUE; + if (datapag >= data_da && datapag <= data_a) + return true; } } - return FALSE; + return false; } // in: tipo e codice anagrafico di cui si vuole l'indirizzo @@ -554,19 +547,13 @@ int num_quadri_L_agg(const long codditta) filt.format("CODDITTA=%ld", codditta); // istanza relazione per cursore - TRelation* rl; - rl = new TRelation (LF_QUAL); + TRelation rl(LF_QUAL); // istanza cursore - TCursor* cl; - cl = new TCursor(rl,filt,1); + TCursor cl (&rl,filt,1); // numero righe compilate - int righe = (int)cl->items(); - - // libera istanze - delete cl; - delete rl; + int righe = (int)cl.items(); // quadri esauriti sul modulo base righe -= rbase; @@ -951,16 +938,16 @@ TSchedaP::TSchedaP (const long codditta, const char tipoa, const long codanagr, TSchedaP::TSchedaP(const TRectype& rec) { - _codditta = rec.get_long("CODDITTA"); - _tipoa = rec.get("TIPOA")[0]; - _codanagr = rec.get_long("CODANAGR"); - _nprog = rec.get_int("NPROG"); + _codditta = rec.get_long(SCH_CODDITTA); + _tipoa = rec.get_char(SCH_TIPOA); + _codanagr = rec.get_long(SCH_CODANAGR); + _nprog = rec.get_int(SCH_NPROG); } TVersamento::TVersamento(const TRectype& rec) { _codditta = rec.get_long(VER_CODDITTA); - _tipoa = rec.get(VER_TIPOA)[0]; + _tipoa = rec.get_char(VER_TIPOA); _codanagr = rec.get_long(VER_CODANAGR); _nprog = rec.get_int(VER_NPROG); _nriga = rec.get_int(VER_NRIGA); @@ -1026,10 +1013,13 @@ int TVersamento_stampa::num_pags(TLocalisamfile* pag) int TVersamento_stampa::read_pags(TLocalisamfile* frpag) { - TLocalisamfile* tmp = frpag ? NULL : new TLocalisamfile(LF_RPAG); - TLocalisamfile& rpag = frpag ? *frpag : *tmp; + const bool exists = frpag == NULL; + if (!exists) + frpag = new TLocalisamfile(LF_RPAG); + + TLocalisamfile& rpag = *frpag; int ctr = 0; - TRecnotype recno = frpag ? frpag->recno() : 0L; + const TRecnotype recno = exists ? frpag->recno() : 0L; rpag.zero(); rpag.put(PAG_CODDITTA, (long)_codditta); @@ -1046,8 +1036,11 @@ int TVersamento_stampa::read_pags(TLocalisamfile* frpag) _num_last_pag = nriga; ctr++; } - _gia_letti_pag = TRUE; - if (frpag) frpag->readat(recno); // ripristina la posizione prec. + _gia_letti_pag = true; + if (exists) + frpag->readat(recno); // ripristina la posizione prec. + else + delete frpag; return ctr; }