From 641ae4ecade54c3d2ae2c71f434549db54f6050d Mon Sep 17 00:00:00 2001 From: ale Date: Fri, 4 Oct 1996 15:38:31 +0000 Subject: [PATCH] - Correzione errore MI6078 della stampa mastrini (riporti a fine pagina) - Correzione errori MI2170 - MI2185 - MI2186 sulla lista controllo movimenti da ricevere git-svn-id: svn://10.65.10.50/trunk@3707 c028cbd2-c16b-5b4b-a496-9718f37d4682 --- cg/cg3200.cpp | 336 +++++++++++++++++++++++++++++++++++++------------- cg/cg6700.cpp | 68 ++++++---- 2 files changed, 290 insertions(+), 114 deletions(-) diff --git a/cg/cg3200.cpp b/cg/cg3200.cpp index 4f4a9ab37..d339805d9 100755 --- a/cg/cg3200.cpp +++ b/cg/cg3200.cpp @@ -63,7 +63,7 @@ class TMastrini_application : public TPrintapp real _riporto_dare,_riporto_avere,_riporto_parziale_dare,_riporto_parziale_avere; real _totale_periodo_dare,_totale_periodo_avere,_totale_prima_dare,_totale_prima_avere; real _saldo_periodo,_saldo_progre,_saldo_progre_al,_saldo_progre_prec; - real _saldo_movimenti,_saldo_progressivi,_totale_saldo; + real _saldo_movimenti,_saldo_progressivi,_totale_saldo,_riporto_footer_dare,_riporto_footer_avere; TString _ragsoc,_indulc,_civulc,_capulc,_com,_prov,_comulc; long _codice_ditta,_s_prec; TString _tipodoc,_codcaus,_descrcaus,_descrdociva,_regiva,_g_contr,_c_contr,_s_contr; @@ -74,12 +74,12 @@ class TMastrini_application : public TPrintapp long _sottocontocontr; bool _stampaprogre,_stampatotiva,_stampatot,_prima_volta,_stampa_mov_prov; - bool _stampato; + bool _stampato,_devi_stampare_footer; int _annomsk,_annoesmsk,_annoes,_annomsksucc,_tipo_mask,_anno_ghost; int _anno_corrente,_anno_precedente,_indbil,_numero_pag; long _sottoc,_numreg,_numgio,_protiva; - bool _stampa_progressivi_si,_competenza,_inizio_stampa,_puoi_stampare; + bool _stampa_progressivi_si,_competenza,_inizio_stampa,_puoi_stampare,_stampa_footer_si; bool _cambia_mastrino,_gia_stampata_intestazione; char _tmcf,_tipo_contr; @@ -100,7 +100,8 @@ protected: virtual bool preprocess_page (int,int); virtual print_action postprocess_page (int,int); virtual print_action postprocess_print(int,int); - virtual void preprocess_header(); + virtual void preprocess_header(); + virtual void preprocess_footer(); virtual void set_page(int,int); virtual void process_link(int id, const char* txt); @@ -821,44 +822,48 @@ void TMastrini_application::fai_stampa132() //_rw += 2; _rw = crea_intestazione(_rw); _rw = stampa_progre_riporto(_rw); - - for (int i = _indice_array; i < _item; i++) + + if (_item != 0) { - TString& data = (TString&)_riga[i]; + for (int i = _indice_array; i < _item; i++) + { + TString& data = (TString&)_riga[i]; - int g1 = data.find("g",1); - int c1 = data.find("@",g1); - int g2 = data.find("g",c1); + int g1 = data.find("g",1); + int c1 = data.find("@",g1); + int g2 = data.find("g",c1); - TString fmt1 = ""; - TString fmt2 = ""; - TString str1,str2; + TString fmt1 = ""; + TString fmt2 = ""; + TString str1,str2; - if (g1 != -1) - { - fmt1 = data.sub(0,g1+1); - fmt1 << "%s"; - str1 = data.sub(g1+1,c1); + if (g1 != -1) + { + fmt1 = data.sub(0,g1+1); + fmt1 << "%s"; + str1 = data.sub(g1+1,c1); + } + if (c1 != -1) + { + fmt2 = data.sub(c1,g2+1); + fmt2 << "%s"; + str2 = data.sub(g2+1); + } + + if (fmt1 != "") + set_row (_rw,fmt1,(const char*) str1); + if (fmt2 != "") + set_row (_rw,fmt2,(const char*) str2); + + _rw++; } - if (c1 != -1) - { - fmt2 = data.sub(c1,g2+1); - fmt2 << "%s"; - str2 = data.sub(g2+1); - } - - if (fmt1 != "") - set_row (_rw,fmt1,(const char*) str1); - if (fmt2 != "") - set_row (_rw,fmt2,(const char*) str2); - - _rw++; - } + } } else _rw = 1; - - _riga.destroy(); + + if (_item != 0) + _riga.destroy(); } set_row (_rw,"@0g#t", &_dataregs); @@ -902,44 +907,48 @@ void TMastrini_application::fai_stampa198() //_rw += 2; _rw = crea_intestazione(_rw); _rw = stampa_progre_riporto(_rw); - - for (int i = _indice_array; i < _item; i++) + + if (_item != 0) { - TString& data = (TString&)_riga[i]; + for (int i = _indice_array; i < _item; i++) + { + TString& data = (TString&)_riga[i]; - int g1 = data.find("g",1); - int c1 = data.find("@",g1); - int g2 = data.find("g",c1); + int g1 = data.find("g",1); + int c1 = data.find("@",g1); + int g2 = data.find("g",c1); - TString fmt1 = ""; - TString fmt2 = ""; - TString str1,str2; + TString fmt1 = ""; + TString fmt2 = ""; + TString str1,str2; - if (g1 != -1) - { - fmt1 = data.sub(0,g1+1); - fmt1 << "%s"; - str1 = data.sub(g1+1,c1); - } - if (c1 != -1) - { - fmt2 = data.sub(c1,g2+1); - fmt2 << "%s"; - str2 = data.sub(g2+1); + if (g1 != -1) + { + fmt1 = data.sub(0,g1+1); + fmt1 << "%s"; + str1 = data.sub(g1+1,c1); + } + if (c1 != -1) + { + fmt2 = data.sub(c1,g2+1); + fmt2 << "%s"; + str2 = data.sub(g2+1); + } + + if (fmt1 != "") + set_row (_rw,fmt1,(const char*) str1); + if (fmt2 != "") + set_row (_rw,fmt2,(const char*) str2); + + _rw++; } - - if (fmt1 != "") - set_row (_rw,fmt1,(const char*) str1); - if (fmt2 != "") - set_row (_rw,fmt2,(const char*) str2); - - _rw++; } } else _rw = 1; - - _riga.destroy(); + + if (_item != 0) + _riga.destroy(); } set_row (_rw,"@0g#t", &_dataregs); @@ -1000,7 +1009,8 @@ void TMastrini_application::stampa_totali132() set_row (_rw,"@85g%15s", (const char*)str); str = _totprogre_avere_al.string("###.###.###.###"); set_row (_rw,"@101g%15s", (const char*)str); - } + } + _devi_stampare_footer = FALSE; } void TMastrini_application::carica_array_totali132() @@ -1149,6 +1159,8 @@ void TMastrini_application::stampa_totali132_II() if (_item_lista <= diff) _lista.destroy(); + + _devi_stampare_footer = FALSE; } void TMastrini_application::stampa_totali198() @@ -1184,7 +1196,8 @@ void TMastrini_application::stampa_totali198() set_row (_rw,"@117g%15s", (const char*)str); str = _saldo_progressivi.string("###.###.###.###"); set_row (_rw,"@133g%15s", (const char*)str); - } + } + _devi_stampare_footer = FALSE; } void TMastrini_application::carica_array_totali198() @@ -1329,7 +1342,9 @@ void TMastrini_application::stampa_totali198_II() } if (_item_lista <= diff) - _lista.destroy(); + _lista.destroy(); + + _devi_stampare_footer = FALSE; } void TMastrini_application::setta_riga (int r, TString riga) @@ -1362,6 +1377,8 @@ bool TMastrini_application::preprocess_page(int file, int counter) case LF_SALDI: // Usati in crea_intestazione() + + _devi_stampare_footer = TRUE; if (_nummast == 3 || _nummast == 2) { @@ -1772,23 +1789,36 @@ bool TMastrini_application::preprocess_page(int file, int counter) int riga,cur_row,diff; if ( (_conta_mastrini % 2) != 0 ) - { - riga = (printer().formlen() / 2); //- 1; - cur_row = printer().formlen() - printer().rows_left(); + { + int app = 0; + riga = (printer().formlen() / 2); + if (printer().rows_left() == 0) + app = printer().formlen() - _rw; + else + app = printer().rows_left(); + cur_row = printer().formlen() - app; diff = riga - cur_row; } else { - riga = printer().formlen(); //- 1; + riga = printer().formlen(); cur_row = printer().formlen() - printer().rows_left(); diff = riga - cur_row; } - + + bool stampa_riporti; + int lim = 0; - if (_item > diff) - lim = diff; - else - lim = _item; + if (_item >= diff) + { + lim = diff - 1; + stampa_riporti = TRUE; + } + else + { + lim = _item; + stampa_riporti = FALSE; + } _indice_array = 0; @@ -1827,7 +1857,83 @@ bool TMastrini_application::preprocess_page(int file, int counter) k++; _indice_array++; } - + if (stampa_riporti) + { + _rw = k; + if (lim == 0) + { + if (_numcarat == 1) + { + TString app (132); + app.spaces(); + set_row (_rw, "@0g%s", (const char*) app); + } + else + { + TString app (198); + app.spaces(); + set_row (_rw, "@0g%s", (const char*) app); + } + } + real dep_dare,dep_avere; + if (_stampa_footer_si) + { + _riporto_footer_dare = _progredare + _riporto_parziale_dare; + _riporto_footer_avere = _progreavere + _riporto_parziale_avere; + + real imp_d,imp_a; + imp_d = _sezione == "D" ? _importo : ZERO; + imp_a = _sezione == "A" ? _importo : ZERO; + if (lim != 0) + { + _riporto_footer_dare += imp_d; + _riporto_footer_avere += imp_a; + } + dep_dare = _riporto_footer_dare; + dep_avere = _riporto_footer_avere; + + _stampa_footer_si = FALSE; + } + else + { + _riporto_footer_dare += _riporto_parziale_dare; + _riporto_footer_avere += _riporto_parziale_avere; + + real imp_d,imp_a; + imp_d = _sezione == "D" ? _importo : ZERO; + imp_a = _sezione == "A" ? _importo : ZERO; + if (lim != 0) + { + _riporto_footer_dare += imp_d; + _riporto_footer_avere += imp_a; + } + dep_dare = _riporto_footer_dare; + dep_avere = _riporto_footer_avere; + } + + TString dare (dep_dare.string("###.###.###.###")); + TString avere (dep_avere.string("###.###.###.###")); + if (_numcarat == 1) + { + set_row (_rw,"@32gA RIPORTO@85g%s", (const char*) dare); + set_row (_rw,"@101g%s", (const char*) avere); + } + else + if (_numcarat == 2) + { + set_row (_rw,"@32gA RIPORTO@101g%s", (const char*) dare); + set_row (_rw,"@117g%s", (const char*) avere); + } + if (lim == 0) + { + rmov.prev(); + _riga.destroy(); + _item = 0; + return TRUE; + } + _rw--; +// return TRUE; + } //_riga.destroy(); } //if (_nummast == 2) @@ -1864,7 +1970,7 @@ bool TMastrini_application::preprocess_page(int file, int counter) const int righe_rimaste = printer().rows_left(); _stampato = righe_rimaste >= 1; - + _saldo_progressivi_str=_saldo_progressivi.string("###.###.###.###"); _saldo_movimenti_str=_saldo_movimenti.string("###.###.###.###"); if (_numcarat == 2) @@ -1893,7 +1999,7 @@ bool TMastrini_application::preprocess_page(int file, int counter) if (datasucc != _dataregrmov) set_row (_rw,"@133g#t", &_saldo_progressivi_str); rmov.readat(rec); - } + } _rw = 1; return TRUE; @@ -1945,8 +2051,11 @@ print_action TMastrini_application::postprocess_page(int file, int counter) reset_print(); // per evitare che stampi di nuovo il totale prec. _stampa_progressivi_si = TRUE; + _stampa_footer_si = TRUE; _riporto_dare = ZERO; - _riporto_avere = ZERO; + _riporto_avere = ZERO; + _riporto_footer_dare = ZERO; + _riporto_footer_avere = ZERO; _riporto_parziale_dare = ZERO; _riporto_parziale_avere = ZERO; _ddociva_len = 0; @@ -1962,9 +2071,12 @@ print_action TMastrini_application::postprocess_page(int file, int counter) if (counter && item_lista == 0) { reset_print(); // per evitare che stampi di nuovo il totale prec. - _stampa_progressivi_si = TRUE; + _stampa_progressivi_si = TRUE; + _stampa_footer_si = TRUE; _riporto_dare = ZERO; - _riporto_avere = ZERO; + _riporto_avere = ZERO; + _riporto_footer_dare = ZERO; + _riporto_footer_avere = ZERO; _riporto_parziale_dare = ZERO; _riporto_parziale_avere = ZERO; _ddociva_len = 0; @@ -2077,10 +2189,6 @@ print_action TMastrini_application::postprocess_page(int file, int counter) return REPEAT_PAGE; } case LF_RMOV: -// if (_sezione == "D") -// _riporto_parziale_dare += _importo; -// else if (_sezione == "A") -// _riporto_parziale_avere += _importo; force_setpage(); break; default: @@ -2226,6 +2334,7 @@ bool TMastrini_application::preprocess_print(int file, int counter) _prima_volta = TRUE; _stampa_progressivi_si = TRUE; + _stampa_footer_si = TRUE; } return TRUE; @@ -2291,9 +2400,8 @@ bool TMastrini_application::set_print(int) _anno_precedente = _tabesc->get_int("CODTAB"); } // LA'! - -//Per la stampa in continuo riservo due righe di footer, mentre per le altre no. - if (_nummast == 3) + + if (_nummast == 1 || _nummast == 3) printer().footerlen(2); else printer().footerlen(0); @@ -2403,6 +2511,58 @@ void TMastrini_application::preprocess_header() } } +void TMastrini_application::preprocess_footer() +{ + reset_footer(); + + if (_nummast != 1 && _nummast != 3) + return; + + if (_devi_stampare_footer) + { + real dep_dare,dep_avere; + + if (_stampa_footer_si) + { + _riporto_footer_dare = _progredare + _riporto_parziale_dare; + _riporto_footer_avere = _progreavere + _riporto_parziale_avere; + + real imp_d,imp_a; + imp_d = _sezione == "D" ? _importo : ZERO; + imp_a = _sezione == "A" ? _importo : ZERO; + dep_dare = _stampato ? _riporto_footer_dare : _riporto_footer_dare - imp_d; + dep_avere = _stampato ? _riporto_footer_avere : _riporto_footer_avere - imp_a; + + _stampa_footer_si = FALSE; + } + else + { + _riporto_footer_dare += _riporto_parziale_dare; + _riporto_footer_avere += _riporto_parziale_avere; + + real imp_d,imp_a; + imp_d = _sezione == "D" ? _importo : ZERO; + imp_a = _sezione == "A" ? _importo : ZERO; + dep_dare = _stampato ? _riporto_footer_dare : _riporto_footer_dare - imp_d; + dep_avere = _stampato ? _riporto_footer_avere : _riporto_footer_avere - imp_a; + } + + TString dare (dep_dare.string("###.###.###.###")); + TString avere (dep_avere.string("###.###.###.###")); + if (_numcarat == 1) + { + set_footer (2,"@32gA RIPORTO@85g%s", (const char*) dare); + set_footer (2,"@101g%s", (const char*) avere); + } + else + if (_numcarat == 2) + { + set_footer (2,"@32gA RIPORTO@101g%s", (const char*) dare); + set_footer (2,"@117g%s", (const char*) avere); + } + } +} + void TMastrini_application::conto(int gruppo, int conto, bool no_contropartita) { TLocalisamfile pconti(LF_PCON); diff --git a/cg/cg6700.cpp b/cg/cg6700.cpp index 6f96c61e9..a55271e6f 100755 --- a/cg/cg6700.cpp +++ b/cg/cg6700.cpp @@ -91,7 +91,7 @@ class TRic_ListaMov : public TPrintapp bool _mov_sez, _errore_grave, _esiste_conto, _seconda_volta, _errore_grave_SC; bool _is_iva, _is_salda, _risposta, _continua, _intestaSC, _errore_grave_totale; bool _prima_volta,_calcola,_prima_rata_pag,_ho_stampato; - char _sdt, _sezione, _tipocf, _sez; + char _sdt, _sezione, _tipocf, _sez, _tipocf_p; int _ae, _anno, _gruppo, _conto, _tipocr, _tipod, _tiporeg, _tipomov, _tipopag, _nriga; int _gruppoc, _contoc, _gruppocr, _contocr, _annoiva, _gruppocl, _contocl, _numrig, _annoese; int _gruppo_p, _conto_p, _anno_prec; @@ -160,6 +160,7 @@ public: void calcola_importo(char tipo,int g,int c,long s,int anno,TString& numpart,int nriga); void aggiorna_partita(real& importo,real& importoval,real& abbuoni,real& diffcam,real& ritenute,TString& sez,TString& sezabb,TString& sezdc); void azzera_impdocval(); + int cerca_anno_solare_esercizio(int codice_esercizio); void apri_file_SC(); void chiudi_file_SC(); @@ -526,6 +527,24 @@ void TRic_ListaMov::stampa_errori_mov(int riga) } } +int TRic_ListaMov::cerca_anno_solare_esercizio(int codice) +{ + TTable ese ("ESC"); + TDate datafine; + int anno = 0; + TString dep (format("%04d", codice)); + + ese.zero(); + ese.put("CODTAB", dep); + if (ese.read() == NOERR) + datafine = ese.get_date("D1"); + + if (datafine != botime) + anno = datafine.year(); + + return anno; +} + bool TRic_ListaMov::controlla_mov() { bool check_reg = TRUE; @@ -635,8 +654,9 @@ bool TRic_ListaMov::controlla_mov() _err.set(9); } if (check_reg && _ae) - { - TRegistro rg (_registro, _ae); + { + int anno = cerca_anno_solare_esercizio(_ae); + TRegistro rg (_registro, anno); if (rg.name().empty()) { _errore_grave = TRUE; @@ -651,8 +671,9 @@ bool TRic_ListaMov::controlla_mov() } } else if (!causreg.blank() && _ae) - { - TRegistro rg (causreg, _ae); + { + int anno = cerca_anno_solare_esercizio(_ae); + TRegistro rg (causreg, anno); if (rg.name().empty()) { _errore_grave = TRUE; @@ -1478,14 +1499,11 @@ bool TRic_ListaMov::controlla_scadenze() scad.readat(nrec); // il codice di pagamento. return TRUE; } - } - if (tipopag < 1 || tipopag > 9) - { - scad.readat(nrec); - return TRUE; - } - if (codpag.not_empty()) // Modifica 01-10-96 idem come sopra - { + if (tipopag < 1 || tipopag > 9) + { + scad.readat(nrec); + return TRUE; + } cerca_tipopag_codpag(codpag,tipopag); if (tipopag != _tipopag_pag) { @@ -1673,14 +1691,11 @@ void TRic_ListaMov::stampa_errori_scadenze(int riga) _errore_grave_SC = TRUE; set_row(++riga, "@30g*** Codice pagamento non valido o non presente in tabella"); } - } - if (tipopag < 1 || tipopag > 9) - { - _errore_grave_SC = TRUE; - set_row(++riga, "@30g%s", (const char*) err_msg[19]); - } - if (codpag.not_empty()) // Modifica 01-10-96 idem come sopra - { + if (tipopag < 1 || tipopag > 9) + { + _errore_grave_SC = TRUE; + set_row(++riga, "@30g%s", (const char*) err_msg[19]); + } cerca_tipopag_codpag(codpag,tipopag); if (tipopag != _tipopag_pag) { @@ -2294,7 +2309,7 @@ bool TRic_ListaMov::preprocess_page(int file,int counter) // I riga di testata int r = 1; set_row(r++, ""); - if (_gruppo != _gruppo_p || _conto != _conto_p || _codcf != _codcf_p) + if (_tipocf != _tipocf_p || _gruppo != _gruppo_p || _conto != _conto_p || _codcf != _codcf_p) { set_row(r++, ""); set_row(r,"@b%s", (const char*) ccf); @@ -2306,13 +2321,13 @@ bool TRic_ListaMov::preprocess_page(int file,int counter) set_row(r++," @b%-50s", (const char*) _descr_anag); } // II riga di testata (L'intestazione viene stampata solo a rottura di partita) - if (_gruppo != _gruppo_p || _conto != _conto_p || _codcf != _codcf_p - || _numpart != _numpart_prec || _anno != _anno_prec) + if (_tipocf != _tipocf_p || _gruppo != _gruppo_p || _conto != _conto_p || + _codcf != _codcf_p || _numpart != _numpart_prec || _anno != _anno_prec) set_row(r,"@0g@rRif. partita"); set_row(r,"@14gN.riga@22gN.operaz./riga Data oper. Data doc. N.doc. Reg Prot. Causale"); set_row(r++,"@142gTipo/Data pag. Cod.val Cambio Data cambio Sez"); - if (_gruppo != _gruppo_p || _conto != _conto_p || _codcf != _codcf_p - || _numpart != _numpart_prec || _anno != _anno_prec) + if (_tipocf != _tipocf_p || _gruppo != _gruppo_p || _conto != _conto_p || + _codcf != _codcf_p || _numpart != _numpart_prec || _anno != _anno_prec) { set_row(r,"%4d", _anno); set_row(r,"@4g/%-7s", (const char*) _numpart); @@ -2346,6 +2361,7 @@ bool TRic_ListaMov::preprocess_page(int file,int counter) set_row(r,"@183g%10s", (const char*) datacam_str); set_row(r,"@196g%c", _sez); + _tipocf_p = _tipocf; _gruppo_p = _gruppo; _conto_p = _conto; _codcf_p = _codcf;