From a08bb6b87f8cbb67efd8243270f967ea22393f4a Mon Sep 17 00:00:00 2001 From: alex Date: Sat, 11 Jul 2009 22:12:05 +0000 Subject: [PATCH] Patch level : 10.0 366 Files correlati : sc2.exe Ricompilazione Demo : [ ] Commento Bug 0001334 La stampa deve prevedere l'ordinamento per valuta ed un totale a rottura di valuta. git-svn-id: svn://10.65.10.50/trunk@19104 c028cbd2-c16b-5b4b-a496-9718f37d4682 --- sc/sc2600.cpp | 280 +++++++++++++++++++++++++++++-------------------- sc/sc2600.h | 1 + sc/sc2600a.uml | 6 ++ 3 files changed, 172 insertions(+), 115 deletions(-) diff --git a/sc/sc2600.cpp b/sc/sc2600.cpp index 43efa09e1..5eebbffe9 100755 --- a/sc/sc2600.cpp +++ b/sc/sc2600.cpp @@ -1,5 +1,6 @@ #include #include +#include #include "../cg/cgsaldac.h" #include "../cg/cglib02.h" @@ -50,8 +51,9 @@ public: virtual TObject* dup() const { return new TLineTotal(*this); } virtual TLineTotal & copy(const TLineTotal & l); + virtual void zero(); TLineTotal(const TLineTotal* l) { copy(*l); } - TLineTotal(); + TLineTotal() { zero();} }; TLineTotal & TLineTotal::copy(const TLineTotal & l) @@ -66,7 +68,7 @@ TLineTotal & TLineTotal::copy(const TLineTotal & l) return *this; } -TLineTotal::TLineTotal() +void TLineTotal::zero() { for (int i = 0; i < NUMERO_FASCE; i++) { @@ -84,12 +86,15 @@ class TProspettoScadenze : public TPrintapp _cur3, _cur4; TSelection_ext_mask *_m; TLocalisamfile *_scad,*_pagsca; + TTable *_val; tipo_st _tipost; // Tipo di stampa impostato bool _end_printed, + _start, + _stvaluta, _ordcod, // VERO=ordine per codice, FALSO=ordine per ragione sociale _sinfasce, _nsinfasce; - TString _anno,_numdoc,_protiva,_datadoc,_codval, + TString _anno,_numdoc,_protiva,_datadoc,_codval, _codvalsel, _cod, _cod_pre, _des, _des_pre; TDate _limop, _limscad, _datas, _limbf; // Data limite operazione, data limite scaduto e data di stampa int _gcr, // Giorni per Calcolo Rischio (valido solo per stampa clienti) @@ -109,10 +114,11 @@ class TProspettoScadenze : public TPrintapp public: virtual bool preprocess_page(int file, int counter); - virtual bool preprocess_print(int file, int counter); + virtual bool open_print(); virtual void postclose_print(); virtual print_action postprocess_print(int file, int counter); virtual print_action postprocess_page(int file, int counter); + virtual void close_print(); virtual void preprocess_header() {}; virtual void preprocess_footer() ; virtual bool user_create(); @@ -123,6 +129,7 @@ public: void export_totali_rows(); void print_totali(int nriga); void print_header(); + int calc_last_column(); void update_totals(bool what, real& esp, real s[NUMERO_FASCE], real ns[NUMERO_FASCE]); void compute_unassigned(TPartita& p, const TDate & datalim); @@ -139,7 +146,9 @@ inline TProspettoScadenze& app() {return (TProspettoScadenze&)main_app();} void TProspettoScadenze::print_real(TString& dest, const real& num) { - const TCurrency cur(num, EMPTY_STRING); + const bool stampa_in_valuta = _stvaluta && !_codval.blank(); + const TString& val = stampa_in_valuta ? _codval : EMPTY_STRING; + const TCurrency cur(num, val); dest = cur.string(true); dest.right_just(10); } @@ -187,7 +196,7 @@ void TProspettoScadenze::compute_unassigned(TPartita& p, const TDate & datalim) { const TRectype& rec = ra.row(r); const TRiga_partite& sum = p.riga(rec.get_int(PAGSCA_NRIGP)); - const char * field = PAGSCA_IMPORTO; + const char * field = (_stvaluta && sum.in_valuta() ? PAGSCA_IMPORTOVAL : PAGSCA_IMPORTO); const TDate & datascad = sum.get_date(PART_DATAPAG); if ((datascad <= datalim)) @@ -229,11 +238,11 @@ void TProspettoScadenze::compute_all(TPartita& p, TBill& bill) { const TRiga_scadenze& rs = rp.rata(n); const TDate d(rs.get_date(SCAD_DATASCAD)); - const char* field = PAGSCA_IMPORTO; - const char* sfield = SCAD_IMPORTO; + const char* field = (_stvaluta && rs.in_valuta()) ? PAGSCA_IMPORTOVAL : PAGSCA_IMPORTO; + const char* sfield = (_stvaluta && rs.in_valuta()) ? SCAD_IMPORTOVAL : SCAD_IMPORTO; const char ssez = rp.sezione(); TImporto scd(ssez,rs.get_real(sfield)); // Importo in scadenza... - TImporto pag(rs.importo_pagato(false)); // Quanto e' stato pagato per questa scadenza? + TImporto pag(rs.importo_pagato(_stvaluta)); // Quanto e' stato pagato per questa scadenza? TImporto bf; TImporto work_imp; @@ -355,7 +364,7 @@ void TProspettoScadenze::compute_all(TPartita& p, TBill& bill) } residuo += res; bool sbf; - TImporto esp = rs.esposto(false, _limscad, _limbf, sbf); + TImporto esp = rs.esposto(_stvaluta, _limscad, _limbf, sbf); esposto += esp.valore(); } } @@ -456,7 +465,8 @@ bool TProspettoScadenze::preprocess_page(int file, int counter) _numdoc = rp.get(PART_NUMDOC); _protiva = rp.get(PART_PROTIVA); _datadoc = (const char*) rp.get_date(PART_DATADOC); - _codval = " "; + _codval = (_stvaluta ? rp.get(PART_CODVAL): ""); + if (_codval.empty()) _codval = " "; // Now performing fulkrum... compute_all(p, bill); } @@ -466,11 +476,123 @@ bool TProspettoScadenze::preprocess_page(int file, int counter) return true; } -bool TProspettoScadenze::preprocess_print(int file, int counter) -{ - return true; +bool TProspettoScadenze::open_print() +{ + if (_stvaluta) + { + const int err = _start ? _val->first() : _val->next(); + if (err != NOERR) + return false; + } + _codvalsel = _val->get("CODTAB"); + reset_files(); + reset_print(); + printer().footerlen(5); + if (_m->get_who() == 'C') + _tipost = clienti; + else + _tipost = fornitori; + riempi_conti_mastro(_m->get_who()); + if (_m->get_key() == 1) + _ordcod = true; + else + _ordcod = false; + _end_printed = false; + _gcr = _m->get_int(F_GIORNI); + _datas = (const char *)(_m->get(F_DATASTAMPA)); + _limop = (const char *)(_m->get(F_DATAOPERAZIONE)); + _limscad = (const char *)(_m->get(F_DATASCADUTO)); + _limbf = _limscad - (long)_gcr; // Limite inferiore per le scadenze a Buon Fine. + _sinfasce = _m->get_bool(F_SCADINFASCE); + _sfasce = _m->get_int(F_SCADFASCE); + _nsinfasce = _m->get_bool(F_ASCADINFASCE); + _nsfasce = _m->get_int(F_ASCADFASCE); + _s_date.destroy(); + _ns_date.destroy(); + for (int i = 0; i <= NUMERO_FASCE; i++) + { + _s_date.add(new TDate); + _ns_date.add(new TDate); + } + int limiti[NUMERO_FASCE + 1] = LIMITI; + for (int j = 0; j <= _sfasce; j++) + (TDate &)_s_date[j] = _limscad - (const long) limiti[j]; + for (int k = 0; k <= _nsfasce; k++) + (TDate &)_ns_date[k] = _limscad + (const long) limiti[k]; + _anno.cut(0);_numdoc.cut(0);_protiva.cut(0);_datadoc.cut(0); + _codval.cut(0);_cod.cut(0); _des.cut(0); _cod_pre.cut(0); + for (int it=0; it < _t.items(); it++) + { + TAssoc_array& aa = (TAssoc_array&) _t[it]; + aa.destroy(); // Totali lineari (singolo e generale) + } + + get_cursor(_cur1)->set_filterfunction(fil_function,true); + get_cursor(_cur2)->set_filterfunction(fil_function,true); + get_cursor(_cur3)->set_filterfunction(fil_function,true); + get_cursor(_cur4)->set_filterfunction(fil_function,true); + _last_game.cut(0); + + TRectype filter_from(LF_PARTITE), filter_to(LF_PARTITE); + + switch (_tipost) + { + case clienti: + case fornitori: + { + TString filter; + + filter_from.put("TIPOC", _tipost == clienti ? "C" : "F"); + filter_to = filter_from; + if (_stvaluta) + { + if (is_firm_value(_codvalsel)) + filter << "(CODVAL==\"\")||"; + filter << "(CODVAL==\"" << _codvalsel << "\")"; + } + if (_ordcod) // Per codice... + { + select_cursor(_cur1); + get_cursor(_cur1)->setregion(filter_from, filter_to); + get_cursor(_cur1)->setfilter(filter); + } + else // ... e ragione sociale + { + select_cursor(_cur2); + get_cursor(_cur2)->setregion(filter_from, filter_to); + get_cursor(_cur2)->setfilter(filter); + } + add_file(LF_PARTITE); + add_file(LF_CLIFO,LF_PARTITE); + } + break; + default: break; + } // End of inner switch + if (_excel) + { + _colnames.destroy(); + if (_sinfasce) + { + _colnames.add(format("Scaduto > %3d gg", limiti[_sfasce])); + for (int i = _sfasce; i > 0; i--) + _colnames.add(format("Scaduto <= %3d gg", limiti[i])); + } + else + _colnames.add("Scaduto"); + if (_nsinfasce) + { + for (int i = 1; i <= _nsfasce; i++) + _colnames.add(format("A Scadere <= %3d gg", limiti[i])); + _colnames.add(format("A Scadere > %3d gg", limiti[_nsfasce])); + } + else + _colnames.add("A Scadere"); + _recset = new TPRSC_recordset(_colnames); + } + _start = false ; + return true; } - + print_action TProspettoScadenze::postprocess_print(int file, int counter) { print_action rt = NEXT_PAGE; @@ -510,6 +632,12 @@ void TProspettoScadenze::postclose_print() } } +void TProspettoScadenze::close_print() +{ + if (_stvaluta) + repeat_print(); +} + print_action TProspettoScadenze::postprocess_page(int file, int counter) { return NEXT_PAGE; @@ -529,10 +657,14 @@ bool TProspettoScadenze::user_create() _scad = new TLocalisamfile(LF_SCADENZE); _pagsca = new TLocalisamfile(LF_PAGSCA); + _val = new TTable("%VAL"); _t.add(new TAssoc_array);_t.add(new TAssoc_array); TConfig conf (CONFIG_DITTA,"cg"); _m = new TSelection_ext_mask("sc2600a"); + _m->enable(F_VALUTA,conf.get_bool("GesVal")); + _stvaluta = false; + _start = true; enable_print_menu(); return true; @@ -544,6 +676,7 @@ bool TProspettoScadenze::user_destroy() if (_rel2) delete _rel2; if (_scad) delete _scad; if (_pagsca) delete _pagsca; + if (_val) delete _val; if (_m) delete _m; _t.destroy(); return true; @@ -569,105 +702,18 @@ void TProspettoScadenze::riempi_conti_mastro(const char cf) bool TProspettoScadenze::set_print(int) { - KEY k = _m->run(); - _excel = k != K_ENTER; - if (k != K_QUIT) - { - reset_files(); - reset_print(); - printer().footerlen(5); - if (_m->get_who() == 'C') - _tipost = clienti; - else - _tipost = fornitori; - riempi_conti_mastro(_m->get_who()); - if (_m->get_key() == 1) - _ordcod = true; - else - _ordcod = false; - _end_printed = false; - _gcr = _m->get_int(F_GIORNI); - _datas = (const char *)(_m->get(F_DATASTAMPA)); - _limop = (const char *)(_m->get(F_DATAOPERAZIONE)); - _limscad = (const char *)(_m->get(F_DATASCADUTO)); - _limbf = _limscad - (long)_gcr; // Limite inferiore per le scadenze a Buon Fine. - _sinfasce = _m->get_bool(F_SCADINFASCE); - _sfasce = _m->get_int(F_SCADFASCE); - _nsinfasce = _m->get_bool(F_ASCADINFASCE); - _nsfasce = _m->get_int(F_ASCADFASCE); - _s_date.destroy(); - _ns_date.destroy(); - for (int i = 0; i <= NUMERO_FASCE; i++) - { - _s_date.add(new TDate); - _ns_date.add(new TDate); - } - int limiti[NUMERO_FASCE + 1] = LIMITI; - for (int j = 0; j <= _sfasce; j++) - (TDate &)_s_date[j] = _limscad - (const long) limiti[j]; - for (int k = 0; k <= _nsfasce; k++) - (TDate &)_ns_date[k] = _limscad + (const long) limiti[k]; - _anno.cut(0);_numdoc.cut(0);_protiva.cut(0);_datadoc.cut(0); - _codval.cut(0);_cod.cut(0); _des.cut(0); _cod_pre.cut(0); - for (int it=0; it < _t.items(); it++) - { - TAssoc_array& aa = (TAssoc_array&) _t[it]; - aa.destroy(); // Totali lineari (singolo e generale) - } + const bool repeat = _stvaluta && need_to_repeat_print(); + bool print = repeat; - get_cursor(_cur1)->set_filterfunction(fil_function,true); - get_cursor(_cur2)->set_filterfunction(fil_function,true); - get_cursor(_cur3)->set_filterfunction(fil_function,true); - get_cursor(_cur4)->set_filterfunction(fil_function,true); - _last_game.cut(0); - - TRectype filter_from(LF_PARTITE), filter_to(LF_PARTITE); - - switch (_tipost) - { - case clienti: - case fornitori: - filter_from.put("TIPOC", _tipost == clienti ? "C" : "F"); - filter_to = filter_from; - if (_ordcod) // Per codice... - { - select_cursor(_cur1); - get_cursor(_cur1)->setregion(filter_from, filter_to); - } - else // ... e ragione sociale - { - select_cursor(_cur2); - get_cursor(_cur2)->setregion(filter_from, filter_to); - } - add_file(LF_PARTITE); - add_file(LF_CLIFO,LF_PARTITE); - break; - default: break; - } // End of inner switch - if (_excel) - { - _colnames.destroy(); - if (_sinfasce) - { - _colnames.add(format("Scaduto > %3d gg", limiti[_sfasce])); - for (int i = _sfasce; i > 0; i--) - _colnames.add(format("Scaduto <= %3d gg", limiti[i])); - } - else - _colnames.add("Scaduto"); - if (_nsinfasce) - { - for (int i = 1; i <= _nsfasce; i++) - _colnames.add(format("A Scadere <= %3d gg", limiti[i])); - _colnames.add(format("A Scadere > %3d gg", limiti[_nsfasce])); - } - else - _colnames.add("A Scadere"); - _recset = new TPRSC_recordset(_colnames); - } - return true; - } // End if - return false; + if (!repeat) + { + KEY k = _m->run(); + _excel = k != K_ENTER; + print = k != K_QUIT; + _start = true; + } + _stvaluta = _m->get_bool(F_VALUTA); + return print; } void TProspettoScadenze::print_totali_rows(int nriga, bool what) @@ -897,9 +943,13 @@ void TProspettoScadenze::print_header() TString datas = _datas.string(); TString limop = _limop.string(); TString limscad = _limscad.string(); + TString s1; - set_header (soh++, "Ditta : %ld %s@%ldgData %s @%ldgPag. @#", - firm, (const char *)s, last_column - 30, (const char *)datas, last_column - 10); + if (_stvaluta) + s1 << "Valuta : " << _codvalsel << " " << _val->get("S0"); + + set_header (soh++, "Ditta : %ld %s@%ldg%s@%ldgData %s @%ldgPag. @#", + firm, (const char *)s, (last_column - s1.len()) / 2, (const char *)s1,last_column - 30, (const char *)datas, last_column - 10); switch (_tipost) { diff --git a/sc/sc2600.h b/sc/sc2600.h index 48ba9e075..442ec4582 100755 --- a/sc/sc2600.h +++ b/sc/sc2600.h @@ -6,6 +6,7 @@ #define F_DATAOPERAZIONE 104 #define F_DATASCADUTO 105 #define F_GIORNI 106 +#define F_VALUTA 107 #define F_SCADINFASCE 201 #define F_SCADFASCE 202 #define F_ASCADINFASCE 203 diff --git a/sc/sc2600a.uml b/sc/sc2600a.uml index ad38d8acf..881519877 100755 --- a/sc/sc2600a.uml +++ b/sc/sc2600a.uml @@ -67,6 +67,12 @@ BEGIN HELP "Inserire il numero di giorni per il calcolo del rischio" END +BOOLEAN F_VALUTA +BEGIN + PROMPT 2 7 "Stampa in valuta" + HELP "Selezionare se si vuole la stampa in valuta" +END + RADIOBUTTON SC_CLIFO 20 BEGIN PROMPT 1 9 "Selezione"