From 5b229e95f6124088fe1184ce4df0ee79437977fa Mon Sep 17 00:00:00 2001 From: guy Date: Fri, 15 Dec 1995 17:12:03 +0000 Subject: [PATCH] Praticamente finita la stampa dei totali EC git-svn-id: svn://10.65.10.50/trunk@2305 c028cbd2-c16b-5b4b-a496-9718f37d4682 --- sc/pec.frm | 392 ++++++++++++++++++++++++++++++++++++++++++++++++ sc/sc2100.cpp | 231 ++++++++++++++++++---------- sc/sc2100a.uml | 1 - sc/sc21pec.h | 2 +- sc/scselect.cpp | 3 + 5 files changed, 547 insertions(+), 82 deletions(-) create mode 100755 sc/pec.frm diff --git a/sc/pec.frm b/sc/pec.frm new file mode 100755 index 000000000..89c3aa213 --- /dev/null +++ b/sc/pec.frm @@ -0,0 +1,392 @@ +USE 20 +JOIN 13 INTO COM=COMCF + +END + +DESCRIPTION +BEGIN + 20->* "Clienti/Fornitori" + 13->* "Comuni" +END + +GENERAL +BEGIN + OFFSET 0 0 + FONT "Arial" + SIZE 12 +END + +SECTION GRAPHICS ODD + +LINEA 1 172 1 +BEGIN + PROMPT 1 10 "@B@R" +END + +LINEA 2 172 1 +BEGIN + PROMPT 1 12 "@B@R" +END + +LINEA 3 172 1 +BEGIN + PROMPT 1 58 "@B@R" +END + +LINEA 10 1 57 +BEGIN + PROMPT 1 10 "@B@R" +END + +LINEA 11 1 57 +BEGIN + PROMPT 24 10 "@R" +END + +LINEA 12 1 57 +BEGIN + PROMPT 36 10 "@R" +END + +LINEA 13 1 57 +BEGIN + PROMPT 56 10 "@R" +END + +LINEA 14 1 57 +BEGIN + PROMPT 76 10 "@R" +END + +LINEA 15 1 57 +BEGIN + PROMPT 96 10 "@R" +END + +LINEA 16 1 57 +BEGIN + PROMPT 116 10 "@B@R" +END + +END + +SECTION HEADER ODD 12 + +STRINGA 100 +BEGIN + KEY "Flags generali VALUTA|FINCATURA" + PROMPT 0 0 "X|2" + FLAGS "DH" +END + +STRINGA 1 +BEGIN + KEY "Spettabile/Egregio" + PROMPT 2 1 "Spettabile" +END + +NUMERO 218 +BEGIN + KEY "Pagina" + PROMPT 70 1 "Pagina " +END + +NUMERO 3 +BEGIN + KEY "Codice cliente/fornitore" + PROMPT 2 2 "" + FIELD CODCF +END + +STRINGA 4 +BEGIN + KEY "Ragione sociale" + PROMPT 8 2 "" + FIELD RAGSOC +END + +STRINGA 5 +BEGIN + KEY "Indirizzo" + PROMPT 2 3 "" + FIELD INDCF +END + +STRINGA 6 +BEGIN + KEY "Numero civico" + PROMPT 52 3 "" + FIELD CIVCF +END + +NUMERO 7 +BEGIN + KEY "C.A.P." + PROMPT 2 4 "C.A.P. " + FIELD CAPCF +END + +STRINGA 8 +BEGIN + KEY "Localita'" + PROMPT 26 4 "" + FIELD LOCALITACF +END + +STRINGA 9 +BEGIN + KEY "Comune" + PROMPT 2 5 "" + FIELD 13->DENCOM +END + +STRINGA 10 +BEGIN + KEY "Provincia" + PROMPT 52 5 "" + FIELD 13->PROVCOM +END + +STRINGA 11 +BEGIN + KEY "Prefisso telefonico" + PROMPT 2 6 "Telefono " + FIELD PTEL +END + +STRINGA 12 +BEGIN + KEY "Telefono" + PROMPT 24 6 "/ " + FIELD TEL +END + +STRINGA 101 +BEGIN + KEY "Luogo d'invio" + PROMPT 2 7 "" +END + +DATA 102 +BEGIN + KEY "Data d'invio" + PROMPT 52 7 "" + FORMAT "1444-" +END + +STRING 103 +BEGIN + KEY "Testo fisso" + PROMPT 2 8 "" +END + +END + +SECTION BODY ODD 1 + +STRINGA 201 +BEGIN + KEY "Cod." + PROMPT 2 1 "" + FLAGS "H" +END + +STRINGA 202 22 1 +BEGIN + KEY "Descrizione" + PROMPT 2 1 "" +END + +DATA 205 +BEGIN + KEY "Data doc." + PROMPT 24 1 "" + FLAGS "H" +END + +STRINGA 206 +BEGIN + KEY "Num.doc." + PROMPT 34 1 "" + FLAGS "H" +END + +NUMERO 207 +BEGIN + KEY "Prot." + PROMPT 44 1 "" + FLAGS "H" +END + +NUMERO 208 +BEGIN + KEY "Totale documento" + PROMPT 60 1 "" + FLAGS "H" +END + +DATA 209 +BEGIN + KEY "Data" + PROMPT 25 1 "" +END + +NUMERO 210 +BEGIN + KEY "Dare" + PROMPT 37 1 "" + PICTURE "###.###.###.###" +END + +NUMERO 211 +BEGIN + KEY "Avere" + PROMPT 57 1 "" + PICTURE "###.###.###.###" +END + +NUMERO 212 +BEGIN + KEY "Scaduto" + PROMPT 77 1 "" + PICTURE "###.###.###.###" +END + +NUMERO 213 +BEGIN + KEY "Esposto" + PROMPT 97 1 "" + PICTURE "###.###.###.###" +END + +STRINGA 214 +BEGIN + KEY "" + PROMPT 115 1 "" +END + +NUMERO 215 +BEGIN + KEY "Importi in lire" + PROMPT 117 1 "" + PICTURE "###.###.###.###" +END + +NUMERO 216 +BEGIN + KEY "Cambio" + PROMPT 2 1 "" + PICTURE "###.###.###.###" + FLAGS "H" +END + +DATA 217 +BEGIN + KEY "Data cam." + PROMPT 2 1 "" + FLAGS "H" +END + +STRING 301 +BEGIN + KEY "Descrizione saldo partita" + PROMPT 2 1 "*** Saldo partita" + FLAGS "DH" +END + +STRING 302 +BEGIN + KEY "Descrizione abbuoni" + PROMPT 2 1 "*** Abbuoni" + FLAGS "DH" +END + +STRING 303 +BEGIN + KEY "Descrizione differenza cambi" + PROMPT 2 1 "*** Differenza cambi" + FLAGS "DH" +END + +STRING 304 +BEGIN + KEY "Ritenute" + PROMPT 2 1 "*** Ritenute" + FLAGS "DH" +END + + +END // Fine body + +SECTION FOOTER ODD 9 + +STRING 400 +BEGIN + KEY "Descrizione riporto" + PROMPT 2 1 "*** Riporto" + FLAGS "DH" +END + +STRING 401 +BEGIN + KEY "Descrizione totale" + PROMPT 2 1 "Saldo al " +END + +NUMERO 210 +BEGIN + KEY "Dare" + PROMPT 37 1 "" + PICTURE "###.###.###.###" +END + +NUMERO 211 +BEGIN + KEY "Avere" + PROMPT 57 1 "" + PICTURE "###.###.###.###" +END + +STRING 402 +BEGIN + KEY "Descrizione totale scaduto" + PROMPT 2 2 "Totale scaduto al " +END + +NUMERO 212 +BEGIN + KEY "Scaduto" + PROMPT 77 1 "" + PICTURE "###.###.###.###" +END + +STRING 403 +BEGIN + KEY "Descrizione totale esposto" + PROMPT 2 3 "Totale esposto" +END + +NUMERO 213 +BEGIN + KEY "Esposto" + PROMPT 97 1 "" + PICTURE "###.###.###.###" +END + +STRING 404 +BEGIN + KEY "Descrizione totale importi in lire" + PROMPT 2 4 "Importi in lire della valuta " +END + +NUMERO 215 +BEGIN + KEY "Importi in lire" + PROMPT 117 1 "" + PICTURE "###.###.###.###" +END + +END // Fine footer + + +END // Fine Form diff --git a/sc/sc2100.cpp b/sc/sc2100.cpp index c16a0f6f8..fd62da5e2 100755 --- a/sc/sc2100.cpp +++ b/sc/sc2100.cpp @@ -38,14 +38,15 @@ class TEC_form : public TForm TDate _dlo, _dls, _dir; // Data limite operazione, scaduto e inizio rischio int _giorni_rischio; // Numero giorni rischio nella maschera di selezione bool _in_valuta; // Il form e' in valuta + int _fincatura; // 0 = nessuna, 1 = testo, 2 = grafica word _num_rip; // Numero di righe usate per i riporti word _total_rows; // Numero di righe usate per i totali protected: - void init_memo(); + void init_header(const TMask& m); word ordina_totali_per_valuta(THash_object* tot[MAXTOT]); void change_magic_names(const THash_object& o, TString& s); - void print_total(int riga, const THash_object& o, short id); + void print_total(int riga, const THash_object& o); void stampa_testata(TPrinter& p); void stampa_pedata(TPrinter& p); @@ -112,7 +113,7 @@ public: int riga() const { return _riga; } int rata() const { return _rata; } - void reset_causale() { _causale.cut(0); _descrizione.cut(0); } + void reset_uguali(); void descrizione(const char* s) { _descrizione = s; } void importo(const TImporto& i) { _importo = i; } void importo_lire(const real& i) { _importo_lire = i; } @@ -173,23 +174,37 @@ int TEC_row::compare(const TSortable& s) const else c = _data > r._data ? +1 : -1; return c; -} +} +// Annulla i campi uguali alla riga precedente +void TEC_row::reset_uguali() +{ + _num_doc = ""; + _data_doc = botime; + _num_prot = 0; + _totale = ZERO; +} void TEC_row::set_imp(TForm_item& fi, const real& imp, bool valuta) const { - TString old_picture; + TString old_picture(20); if (valuta) { old_picture = fi.picture(); - TString new_picture(20); - new_picture = old_picture; - if (old_picture.find(',') > 0) - new_picture << ".###"; + + if (old_picture.empty()) + { + new_picture = valuta ? ".3" : "."; + } else - new_picture << ",###"; - + { + new_picture = old_picture; + if (old_picture.find(',') > 0) + new_picture << ".###"; + else + new_picture << ",###"; + } fi.set_picture(new_picture); } @@ -299,29 +314,29 @@ public: TImporto TEC_array::importo(const TPartita& game, const TRectype& pag, bool valuta) const { const int nriga = pag.get_int(PAGSCA_NRIGA); - const TRiga_partite& fat = game.riga(nriga); + const TRiga_partite& fat = game.riga(nriga); // Riga di fattura const bool fat_val = fat.in_valuta(); const int nrigp = pag.get_int(PAGSCA_NRIGP); - const TRiga_partite& sum = game.riga(nrigp); + const TRiga_partite& sum = game.riga(nrigp); // Riga di pagamento const char sez = sum.sezione(); const char* const field = valuta && fat_val ? PAGSCA_IMPORTOVAL : PAGSCA_IMPORTO; - TImporto imp(sez, pag.get_real(PAGSCA_IMPORTO)); + TImporto imp(sez, pag.get_real(field)); // Importo base if (!fat_val) - imp.valore() += pag.get_real(PAGSCA_RITENUTE); + imp.valore() += pag.get_real(PAGSCA_RITENUTE); // Sommo le ritenute se sono il lire - if (pag.get_char(PAGSCA_ACCSAL) == 'S') + if (pag.get_char(PAGSCA_ACCSAL) == 'S') // Se il pagamento ha abbuoni o differenze cambio { real abb(pag.get(PAGSCA_ABBUONI)); - if (!valuta && fat_val) + if (!valuta && fat_val) // Se voglio gli abbuoni in lire ma la fattura non lo e' { - const TValuta val(sum); - val.val2lit(abb); - abb += pag.get_real(PAGSCA_DIFFCAM); + const TValuta val(sum); // Leggo il cambio dalla riga di partita + val.val2lit(abb); // Converto in lire gli abbuoni + abb += pag.get_real(PAGSCA_DIFFCAM); // Sommo l'eventuale differenza cambio (gia' in lire) } - imp.valore() += abb; + imp.valore() += abb; // Sommo il tutto all'importo base (sez e' uguale per tutti i valori) } return imp; @@ -490,24 +505,32 @@ void TEC_array::add_row(const TRiga_partite& row) } } - const TImporto diffcam(row.importo(in_valuta, 0x4)); + TImporto diffcam(row.importo(FALSE, 0x4)); if (!diffcam.is_zero()) { - TEC_row& rec = new_row(row, data, diffcam, 3); + TEC_row& rec = new_row(row, data, TImporto('D', ZERO), 3); rec.descrizione(form().describe(PEC_DIFFCAM)); if (in_valuta) { - TImporto il(row.importo(FALSE, 0x4)); - il.normalize(sezione); - rec.importo_lire(il.valore()); + diffcam.normalize(sezione); + rec.importo_lire(diffcam.valore()); } + else + rec.importo(diffcam); } - const TImporto ritenute(row.importo(in_valuta, 0x8)); + TImporto ritenute(row.importo(FALSE, 0x8)); if (!ritenute.is_zero()) { - TEC_row& r = new_row(row, data, ritenute, 4); - r.descrizione(form().describe(PEC_RITENUTE)); + TEC_row& rec = new_row(row, data, TImporto('D', ZERO), 4); + rec.descrizione(form().describe(PEC_RITENUTE)); + if (in_valuta) + { + ritenute.normalize(sezione); + rec.importo_lire(ritenute.valore()); + } + else + rec.importo(ritenute); } } } @@ -577,8 +600,8 @@ static int tot_compare(const void* o1, const void* o2) if (o1 == o2) // Sfrutto una piccola debolezza di qsort: return 0; // ogni tanto confronta oggetti con se stessi - const THash_object* h1 = (const THash_object*)o1; - const THash_object* h2 = (const THash_object*)o2; + const THash_object* h1 = *((const THash_object**)o1); + const THash_object* h2 = *((const THash_object**)o2); return stricmp(h1->key(), h2->key()); } @@ -601,13 +624,12 @@ void TEC_form::stampa_riporti(TPrinter& pr) { THash_object* tot[MAXTOT]; _num_rip = ordina_totali_per_valuta(tot); - - const word maxtot = section('F').height(); + + const word maxtot = section('F').height() - 1; // La prima riga e' riservata alla fincatura if (_num_rip > maxtot) _num_rip = maxtot; const TString& riporto = describe(PEC_RIPORTO, 'F'); - TString desc(80); TPrint_section& body = section('B'); for (word j = 0; j < _num_rip; j++) @@ -623,7 +645,7 @@ void TEC_form::stampa_riporti(TPrinter& pr) rip.esposto(t.esposto()); rip.importo_lire(t.importo_lire()); rip.print_on(body); - pr.setfooterline(j, body.row(0)); + pr.setfooterline(j+1, body.row(0)); } } @@ -664,44 +686,83 @@ void TEC_form::change_magic_names(const THash_object& o, TString& s) } } -void TEC_form::print_total(int riga, const THash_object& o, short id) -{ - TForm_item& desc_field = find_field('F', odd_page, id); - if (desc_field.shown()) - { - const int old_width = desc_field.width(); - desc_field.set_width(80); // Allunga campo descrizione - - TString s(80); s = desc_field.prompt(); - change_magic_names(o, s); - - const TTotal& t = (const TTotal&)o.obj(); - TEC_row row(s, t.importo()); - - TPrint_section& body = section('B'); - row.print_on(body); - desc_field.set_width(old_width); // Ripristina lunghezza originaria - - printer().setfooterline(riga + desc_field.y() -1, body.row(0)); +void TEC_form::print_total(int riga, const THash_object& o) +{ + const short MAXID = 4; + const short f_id[MAXID] = { PEC_TSALDO, PEC_TSCADUTO, PEC_TESPOSTO, PEC_TIMPLIRE }; + TString_array prompt(MAXID); + + TPrint_section& foot = section('F'); + + // Sostituisce magic-names nei prompt + TString s(80); + for (int i = 0; i < MAXID; i++) + { + TForm_item& desc_field = foot.find_field(f_id[i]); + if (desc_field.shown()) + { + s = desc_field.prompt(); + prompt.add(s, i); + change_magic_names(o, s); + desc_field.set_prompt(s); + } + } + + const TTotal& t = (const TTotal&)o.obj(); + const TImporto& imp = t.importo(); + TForm_item& dare = foot.find_field(PEC_DARE); + TForm_item& avere = foot.find_field(PEC_AVERE); + if (imp.sezione() == 'D') + { + dare.set(imp.valore().string()); + avere.set(""); } + else + { + dare.set(""); + avere.set(imp.valore().string()); + } + + TForm_item& scaduto = foot.find_field(PEC_SCADUTO); + scaduto.set(t.scaduto().string()); + + TForm_item& esposto = foot.find_field(PEC_ESPOSTO); + scaduto.set(t.esposto().string()); + + TForm_item& implire = foot.find_field(PEC_IMPLIRE); + implire.set(t.importo_lire().string()); + + foot.update(); + + // Ripristina prompt originari + for (i = 0; i < MAXID; i++) + { + const TString* p = (const TString*)prompt.objptr(i); + if (p) + { + TForm_item& desc_field = foot.find_field(f_id[i]); + desc_field.set_prompt(*p); + } + } + + for (word r = 0; r < _total_rows; r++) + printer().setfooterline(riga + r, foot.row(r)); } void TEC_form::stampa_pedata(TPrinter& pr) { THash_object* tot[MAXTOT]; word num_rip = ordina_totali_per_valuta(tot); - - const word maxtot = section('F').height() / _total_rows; + + // La prima riga del footer deve essere lasciata libera per la fincatura + // Ogni sottosezione di totale occupa _total_rows righe: per cui devo calcolare + // quanti totali ci stanno nelle righe riservate al footer + const word maxtot = (section('F').height()-1) / _total_rows; if (num_rip > maxtot) num_rip = maxtot; - TString desc(80); - TPrint_section& body = section('B'); - for (word j = 0; j < num_rip; j++) - { - print_total(j * _total_rows, *tot[j], PEC_TSALDO); - } + print_total(j*_total_rows+1, *tot[j]); } void TEC_form::ultima_pagina() @@ -771,7 +832,7 @@ bool TEC_form::print_game(const TPartita& game) const int ri = riga.riga(); const int ra = riga.rata(); if (ri == ultima_riga && ra == ultima_rata+1) - riga.reset_causale(); + riga.reset_uguali(); ultima_riga = ri; ultima_rata = ra; @@ -812,9 +873,17 @@ const TString& TEC_form::describe(short id, char sez, pagetype pt) const return fi.prompt(); } -void TEC_form::init_memo() +void TEC_form::init_header(const TMask& m) { - TForm_item& fi = find_field('H', odd_page, PEC_MEMO); + TPrint_section& head = section('H'); + + TForm_item& luogo_invio = head.find_field(PEC_LUOGOIN); + luogo_invio.set(m.get(F_LUOGOSEND)); + + TForm_item& data_invio = head.find_field(PEC_DATAIN); + data_invio.set(m.get(F_DATASEND)); + + TForm_item& fi = head.find_field(PEC_MEMO); if (fi.shown()) { TLocalisamfile f(LF_RFORM); @@ -826,6 +895,12 @@ void TEC_form::init_memo() if (err == NOERR) fi.set(f.get("TESTO")); } + + if (_fincatura) + { + TPrint_section& fink = section('G'); + if (fink.fields() > 0) fink.update(); // Setta il backgroud di stampa + } } TEC_form::TEC_form(const TEC_mask& m, bool gesval) @@ -836,14 +911,10 @@ TEC_form::TEC_form(const TEC_mask& m, bool gesval) { _form = this; - TForm_item& imp_lire = find_field('B', odd_page, PEC_IMPLIRE); - _in_valuta = gesval && imp_lire.shown(); // Il profilo e' in valuta se c'e' la colonna importo in lire - - _lingua = m.get_prof_lang(); // Lingua profilo - TCursor_sheet& cs = m.cur_sheet(); _cursore = cs.cursor(); + _lingua = m.get_prof_lang(); // Lingua profilo _dlo = m.get(F_DATALIMOP); _dls = m.get(F_DATALIMSC); _giorni_rischio = m.get_int(F_GIORISCH); @@ -854,14 +925,12 @@ TEC_form::TEC_form(const TEC_mask& m, bool gesval) pr.setheaderhandler(ec_header_handler); TPrint_section& head = section('H'); pr.headerlen(head.height()); - - TForm_item& luogo_invio = head.find_field(PEC_LUOGOIN); - luogo_invio.set(m.get(F_LUOGOSEND)); - - TForm_item& data_invio = head.find_field(PEC_DATAIN); - data_invio.set(m.get(F_DATASEND)); - - init_memo(); // Set fixed memo text + + TForm_item& flags = head.find_field(PEC_FLAGS); + TToken_string f(flags.prompt()); + _in_valuta = gesval && f.get_char(0) == 'X'; // Il profilo e' in valuta se c'e' il flag di valuta + _fincatura = f.get_int(1); + init_header(m); // Set fixed text pr.setfooterhandler(ec_footer_handler); const TPrint_section& foot = section('F'); @@ -959,8 +1028,10 @@ bool TStampaEC_application::print_selected() one_printed = TRUE; else analfabeti++; - } - printer().formfeed(); + } + + if (one_printed) + printer().formfeed(); printer().close(); if (analfabeti > 0) diff --git a/sc/sc2100a.uml b/sc/sc2100a.uml index 5893d499b..4a81e2c94 100755 --- a/sc/sc2100a.uml +++ b/sc/sc2100a.uml @@ -52,7 +52,6 @@ BEGIN DISPLAY "Descrizione@50" S0 OUTPUT F_LINPROF CODTAB CHECKTYPE NORMAL - VALIDATE CHECK_FIELD F_CODPROF WARNING "Codice profilo o lingua errato" END diff --git a/sc/sc21pec.h b/sc/sc21pec.h index 5795697f8..e3be24e57 100755 --- a/sc/sc21pec.h +++ b/sc/sc21pec.h @@ -34,6 +34,6 @@ #define PEC_TSALDO 401 #define PEC_TSCADUTO 402 #define PEC_TESPOSTO 403 -#define PEC_TLIRE 404 +#define PEC_TIMPLIRE 404 #endif diff --git a/sc/scselect.cpp b/sc/scselect.cpp index 377ccb575..0b8004472 100755 --- a/sc/scselect.cpp +++ b/sc/scselect.cpp @@ -94,6 +94,9 @@ void TSelection_mask::select_clifo_range(long from, long to) const int key = get_key(); TString s_from(50), s_to(50); + if (to == 0 && items) + to = c.row(items-1).get_long(key); + if (from > to) // Controlla limiti { long tmp = to;