From b4795aed72dd3a5c87fbc4dff95ca9960c26a46f Mon Sep 17 00:00:00 2001 From: guy Date: Mon, 27 Oct 2014 08:25:58 +0000 Subject: [PATCH] Corretta gestione form per stamap ordini (mischiava Valore con Residuo) git-svn-id: svn://10.65.10.50/branches/R_10_00@23007 c028cbd2-c16b-5b4b-a496-9718f37d4682 --- or/or1100.cpp | 64 +++++++++- or/or1100a.frm | 3 +- or/or1200.cpp | 2 +- or/or1200a.frm | 4 +- or/or1200a.uml | 2 +- or/orlib01.cpp | 341 +++++++++++++++++++++++++------------------------ or/ormenu.men | 2 +- 7 files changed, 244 insertions(+), 174 deletions(-) diff --git a/or/or1100.cpp b/or/or1100.cpp index 2cb11f429..ff7fc1439 100755 --- a/or/or1100.cpp +++ b/or/or1100.cpp @@ -309,6 +309,32 @@ void TStampa_ordini::add_tiporiga(TString& cond, const char tipo) } } +static void append_range_filter(TString& filter, int file, const char* field, long from, long to) +{ + if (from > 0 || to > 0) + { + filter << "&&(BETWEEN("; + if (file > 0) filter << file << "->"; + filter << field << ',' << from << ',' << to << "))"; + } +} + +static void append_range_filter(TString& filter, int file, const char* field, const TDate& from, const TDate& to) +{ + if (from.ok() || to.ok()) + append_range_filter(filter, file, field, from.date2ansi(), to.date2ansi()); +} + +static void append_range_filter(TString& filter, int file, const char* field, const TString& from, const TString& to) +{ + if (from.full() || to.full()) + { + filter << "&&(BETWEEN("; + if (file > 0) filter << file << "->"; + filter << field << ",\"" << from << "\",\"" << to << "\"))"; + } +} + void TStampa_ordini::filter_for_number() { CHECK(_frm, "Form non valido"); @@ -383,6 +409,7 @@ void TStampa_ordini::filter_for_number() { // In caso di dettaglio per righe non va settato il filtro per dataconsegnain quanto // già impostato sulla sottosezione (vedi sotto) + /* if (_from_cons.ok()) { filter_expr << "&&"; @@ -397,6 +424,8 @@ void TStampa_ordini::filter_for_number() (const char*)_to_cons.string(ANSI)); filter_expr << s; } + */ + append_range_filter(filter_expr, 0, DOC_DATACONS, _from_cons, _to_cons); } if (filter_expr.starts_with("&&")) @@ -459,6 +488,7 @@ void TStampa_ordini::filter_for_number() cond << s; // Setta i range per la data di consegna + /* if (_from_cons.ok()) { if (cond.not_empty()) @@ -475,8 +505,11 @@ void TStampa_ordini::filter_for_number() LF_RIGHEDOC, (const char*)_to_cons.string(ANSI)); cond << s; } + */ + append_range_filter(cond, LF_RIGHEDOC, RDOC_DATACONS, _from_cons, _to_cons); // Setta i range per il codice magazzino + /* if (_from_mag.not_empty()) { if (cond.not_empty()) @@ -493,8 +526,11 @@ void TStampa_ordini::filter_for_number() LF_RIGHEDOC, (const char*)_to_mag); cond << s; } + */ + append_range_filter(cond, LF_RIGHEDOC, RDOC_CODMAG, _from_mag, _to_mag); // Setta i range per il codice articolo + /* if (_from_art.not_empty()) { if (cond.not_empty()) @@ -511,6 +547,8 @@ void TStampa_ordini::filter_for_number() LF_RIGHEDOC, (const char*)_to_art); cond << s; } + */ + append_range_filter(cond, LF_RIGHEDOC, RDOC_CODART, _from_art, _to_art); s.format("&&(%d->CODART!=\"\")", LF_RIGHEDOC); cond << s; @@ -686,6 +724,7 @@ void TStampa_ordini::filter_for_clifo_agent() } // Filtro sulla data ordine... + /* if (_from_date.ok()) { s.format("&&(ANSI(%d->DATADOC)>=\"%s\")", LF_DOC, @@ -698,8 +737,11 @@ void TStampa_ordini::filter_for_clifo_agent() (const char*)_to_date.string(ANSI)); filter_expr << s; } + */ + append_range_filter(filter_expr, LF_DOC, DOC_DATADOC, _from_date, _to_date); // Filtro sulla data consegna... + /* if (_from_cons.ok()) { s.format("&&(ANSI(DATACONS)>=\"%s\")", @@ -712,10 +754,13 @@ void TStampa_ordini::filter_for_clifo_agent() (const char*)_to_cons.string(ANSI)); filter_expr << s; } - + */ + append_range_filter(filter_expr, 0, DOC_DATACONS, _from_cons, _to_cons); + if (_detail_rows) { // Setta i range per il codice articolo + /* if (_from_art.full()) { s.format("&&(%d->CODART>=\"%s\")", @@ -729,6 +774,9 @@ void TStampa_ordini::filter_for_clifo_agent() LF_RIGHEDOC, (const char*)_to_art); filter_expr << s; } + */ + append_range_filter(filter_expr, LF_RIGHEDOC, RDOC_CODART, _from_art, _to_art); + // Setta i range per i livelli di giacenza (da 1 a 4) if (_detail_level > 0) for (int lev=1, index=0; lev <= _detail_level; lev++) @@ -999,18 +1047,22 @@ void TStampa_ordini::filter_for_articolo() filter_expr << s; // Filtro su Cli/Fo + /* if (_from_cf > 0L) { s.format("&&(STR(NUM(%d->CODCF)>=%ld))", LF_DOC, _from_cf); filter_expr << s; } - if (_to_cf > 0L) { s.format("&&(STR(NUM(%d->CODCF)<=%ld))", LF_DOC, _to_cf); filter_expr << s; } + */ + append_range_filter(filter_expr, LF_DOC, DOC_CODCF, _from_cf, _to_cf); + // Filtro sulla data ordine... + /* if (_from_date.ok()) { s.format("&&(ANSI(%d->DATADOC)>=\"%s\")", LF_DOC, @@ -1023,8 +1075,11 @@ void TStampa_ordini::filter_for_articolo() (const char*)_to_date.string(ANSI)); filter_expr << s; } + */ + append_range_filter(filter_expr, LF_DOC, DOC_DATADOC, _from_date, _to_date); // Filtro sulla data consegna... + /* if (_from_cons.ok()) { s.format("&&(ANSI(DATACONS)>=\"%s\")", @@ -1037,6 +1092,8 @@ void TStampa_ordini::filter_for_articolo() (const char*)_to_cons.string(ANSI)); filter_expr << s; } + */ + append_range_filter(filter_expr, 0, DOC_DATACONS, _from_cons, _to_cons); // Setta i range per i livelli di giacenza (da 1 a 4) if (_detail_level > 0) @@ -1062,6 +1119,7 @@ void TStampa_ordini::filter_for_articolo() } } // Setta i range per il codice magazzino (deposito incluso) + /* if (_from_mag.not_empty()) { s.format("&&(%d->CODMAG>=\"%s\")", @@ -1074,6 +1132,8 @@ void TStampa_ordini::filter_for_articolo() LF_RIGHEDOC, (const char*)_to_mag); filter_expr << s; } + */ + append_range_filter(filter_expr, LF_RIGHEDOC, RDOC_CODMAG, _from_mag, _to_mag); if (_TEA_rord > ' ') { diff --git a/or/or1100a.frm b/or/or1100a.frm index 21449c73e..763f843d5 100755 --- a/or/or1100a.frm +++ b/or/or1100a.frm @@ -119,7 +119,8 @@ BEGIN SPECIAL STRINGA FINCATURA "XX" "Fincatura sinistra e destra" KEY "Codice Valuta" PROMPT 7 1 "" - FIELD CODVAL + //FIELD CODVAL + MESSAGE _ORDINE,CODVAL END DATA BODY_COL_DATACONS 10 diff --git a/or/or1200.cpp b/or/or1200.cpp index c71f6b82b..4362dd928 100755 --- a/or/or1200.cpp +++ b/or/or1200.cpp @@ -338,7 +338,7 @@ void TStampa_dettaglio_articoli::main_loop() int or1200(int argc, char** argv) { TStampa_dettaglio_articoli a; - a.run(argc,argv,TR("Stampa disponibilita' articoli")); + a.run(argc,argv,TR("Stampa disponibilità articoli")); return 0; } diff --git a/or/or1200a.frm b/or/or1200a.frm index 532fe8d8d..d7dd63324 100755 --- a/or/or1200a.frm +++ b/or/or1200a.frm @@ -40,10 +40,10 @@ BEGIN MESSAGE _PAGENO END -NUMERO 4 40 +STRINGA 4 40 BEGIN KEY "Intestazione stampa" - PROMPT 60 2 "Stampa dettaglio disponibilita' articoli" + PROMPT 60 2 "Stampa dettaglio disponibilità articoli" END END //HEADER diff --git a/or/or1200a.uml b/or/or1200a.uml index ace42482c..2a08f4c80 100755 --- a/or/or1200a.uml +++ b/or/or1200a.uml @@ -4,7 +4,7 @@ TOOLBAR "topbar" 0 0 0 2 #include ENDPAGE -PAGE "Disponibilita' articoli" 0 0 0 0 +PAGE "Disponibilità articoli" 0 0 0 0 GROUPBOX DLG_NULL 41 7 BEGIN diff --git a/or/orlib01.cpp b/or/orlib01.cpp index 160969bf0..9982657b4 100755 --- a/or/orlib01.cpp +++ b/or/orlib01.cpp @@ -173,187 +173,196 @@ bool TOrdine_form::validate(TForm_item &cf, TToken_string &s) cf.set(qt.string()); } + } else + if (action == "CODVAL") // Comandi per stampa riepilogo per valuta + { + const TString& codval = doc.get(DOC_CODVAL); + if (is_firm_value(codval)) + cf.set(""); + else + cf.set(codval); + } else + if (action == "VALTABLE") // Comandi per stampa riepilogo per valuta + { + TString subcommand(s.get(2)); + if (subcommand == "RESET") + { + _totvaluta.destroy(); + cf.find_field("TOTVAL1").disable(); + cf.find_field("TOTVAL2").disable(); + cf.find_field("TOTVAL3").disable(); + cf.find_field("TOTVAL4").disable(); + } + else + { + const int valute = _totvaluta.items(); + TString4 codval = doc.get(DOC_CODVAL); + if (is_firm_value(codval)) codval.cut(0); + + const bool is_key = _totvaluta.is_key(codval); + const bool is_new = !is_key && valute < 4; + + if (is_new) // Aggiunge l'elemento se non c'e' + _totvaluta.add(codval,(_TTotale_valuta*)new _TTotale_valuta,is_key); + // Controlla/stampa al massimo 4 valute + if (is_key || is_new) + { + _TTotale_valuta& tv = (_TTotale_valuta&)_totvaluta[codval]; + const bool is_valord = subcommand == "VALORD"; + real& r = is_valord ? tv.totord() : tv.totres(); + TString s_id; + int i_id; + + // Abilita la sezione corrispondente e setta i valori all'interno + if (!is_key) + { + TString16 sec_name = "TOTVAL"; + sec_name << valute+1; + tv.secnum() = valute+1; + cf.find_field(sec_name).enable(); + // Setta anche il codice valuta + i_id = BODY_CODVAL + valute*10; + s_id.format("%d",i_id); + cf.find_field(s_id).set(codval); + if (valute == 0) + { + i_id--; + s_id.format("%d",i_id); + cf.find_field(s_id).set("@bTotali"); + } + } + const int sn = tv.secnum(); + i_id = is_valord ? BODY_TOTVALORD : BODY_TOTVALRES; + + i_id += (sn-1)*10; + s_id.format("%d",i_id); + r += ((real) cf.get()); // Somma il valore corrente + cf.find_field(s_id).set(r.string()); + } + } } else - if (action == "VALTABLE") // Comandi per stampa riepilogo per valuta + if (action == "CALCDISP") // messaggi per calcolo disponibilita' + { + TString command(s.get(2)); + if (command == "RESET") // resetta la tabella { - TString subcommand(s.get(2)); - if (subcommand == "RESET") + _totdisp.destroy(); + const real rz = ZERO; + const int items = _date_array->items(); + for (int i = 0; iread(rdoc.get(RDOC_CODART)) == NOERR) { - _totvaluta.destroy(); - cf.find_field("TOTVAL1").disable(); - cf.find_field("TOTVAL2").disable(); - cf.find_field("TOTVAL3").disable(); - cf.find_field("TOTVAL4").disable(); + _codmag = rdoc.get(RDOC_CODMAG); + _livello = rdoc.get(RDOC_LIVELLO); + } + else + cf.set("Errore in lettura articolo"); + } + else + if (command == "CALC") // Effettua il calcolo per questa riga articolo, + //cumulando nell'array le quantita', espresse sempre in UM principale + { + const bool is_ordine_cliente = doc.get(DOC_TIPOCF)[0] == 'C'; + const TString16 causmag(doc.get(DOC_CAUSMAG)); + const TString16 um(rdoc.get(RDOC_UMQTA)); + const TDate datacons(rdoc.get_date(RDOC_DATACONS)); + int segno = is_ordine_cliente ? -1 : +1; // default + if (causmag.not_empty()) // se la causale esiste consulta il segno + { + TCausale_magazzino cm(causmag); + segno *= cm.sgn(is_ordine_cliente ? s_ordc : s_ordf); + } + // Reperisce fattore di conversione per UM principale, + // la quantita residua + real qtares = rdoc.qtaresidua(); // ZIO PERA! ag völ la riga dal document + qtares = _art_giac->convert_to_um(qtares, "", um, true); + qtares *= segno; // mette a posto il segno... + // Trova il periodo giusto + const int index = find_period(datacons); + if (index >= _totdisp.items()) + _totdisp.add(ZERO, index); // Added by Guy! Should never happen :-) + real& rv = (real&) _totdisp[index]; + rv += qtares; + + const TDate datascimp(doc.get_date("DATASCIMP")); + + if (datascimp.ok()) + { + const int last_index = find_period(datascimp); + if (last_index >= 0) + { + real& rv = (real&) _totdisp[last_index]; + rv -= qtares; + } + } + } + else + if (command == "PRNUM") // Stampa l'unita' di misura principale + { + const TRecord_array& um = _art_giac->um(); + if (um.rows() > 0) // Controlla che ci sia almeno una unita' di misura + cf.set(um.row(1).get("UM")); // UM principale + else + cf.set(""); } else { - const int valute = _totvaluta.items(); - TString codval(doc.get(DOC_CODVAL)); - const bool is_key = _totvaluta.is_key(codval); - const bool is_new = !is_key && valute < 4; + const int period = s.get_int(3); + //const int items = _date_array->items(); + TString16 annoes; + real giacenza, scorta_min; - if (is_new) // Aggiunge l'elemento se non c'e' - _totvaluta.add(codval,(_TTotale_valuta*)new _TTotale_valuta,is_key); - // Controlla/stampa al massimo 4 valute - if (is_key || is_new) + TEsercizi_contabili esc; + annoes << esc.date2esc(doc.get_date(DOC_DATADOC)); + //TString16 codmag(rdoc.get(RDOC_CODMAG)); + //TString16 livello(rdoc.get(RDOC_LIVELLO)); + const int codmag_len = (_detail_dep || _detail_mag) ? _codmag.len() : 0; + const int livello_len = _level > 0 ? _livello.len() : 0; + //if (_art_giac->read(rdoc.get(RDOC_CODART)) == NOERR) { - _TTotale_valuta& tv = (_TTotale_valuta&)_totvaluta[codval]; - const bool is_valord = subcommand == "VALORD"; - real& r = is_valord ? tv.totord() : tv.totres(); - TString s_id; - int i_id; - - // Abilita la sezione corrispondente e setta i valori all'interno - if (!is_key) - { - TString16 sec_name = "TOTVAL"; - sec_name << valute+1; - tv.secnum() = valute+1; - cf.find_field(sec_name).enable(); - // Setta anche il codice valuta - i_id = BODY_CODVAL + valute*10; - s_id.format("%d",i_id); - cf.find_field(s_id).set(codval); - if (valute == 0) - { - i_id--; - s_id.format("%d",i_id); - cf.find_field(s_id).set("@bTotali"); - } - } - const int sn = tv.secnum(); - i_id = is_valord ? BODY_TOTVALORD : BODY_TOTVALRES; - - i_id += (sn-1)*10; - s_id.format("%d",i_id); - r += ((real) cf.get()); // Somma il valore corrente - cf.find_field(s_id).set(r.string()); - } - } - } - else - if (action == "CALCDISP") // messaggi per calcolo disponibilita' - { - TString command(s.get(2)); - if (command == "RESET") // resetta la tabella - { - _totdisp.destroy(); - const real rz = ZERO; - const int items = _date_array->items(); - for (int i = 0; iread(rdoc.get(RDOC_CODART)) == NOERR) - { - _codmag = rdoc.get(RDOC_CODMAG); - _livello = rdoc.get(RDOC_LIVELLO); - } - else - cf.set("Errore in lettura articolo"); - } - else - if (command == "CALC") // Effettua il calcolo per questa riga articolo, - //cumulando nell'array le quantita', espresse sempre in UM principale - { - const bool is_ordine_cliente = doc.get(DOC_TIPOCF)[0] == 'C'; - const TString16 causmag(doc.get(DOC_CAUSMAG)); - const TString16 um(rdoc.get(RDOC_UMQTA)); - const TDate datacons(rdoc.get_date(RDOC_DATACONS)); - int segno = is_ordine_cliente ? -1 : +1; // default - if (causmag.not_empty()) // se la causale esiste consulta il segno - { - TCausale_magazzino cm(causmag); - segno *= cm.sgn(is_ordine_cliente ? s_ordc : s_ordf); - } - // Reperisce fattore di conversione per UM principale, - // la quantita residua - real qtares = rdoc.qtaresidua(); // ZIO PERA! ag völ la riga dal document - qtares = _art_giac->convert_to_um(qtares, "", um, true); - qtares *= segno; // mette a posto il segno... - // Trova il periodo giusto - const int index = find_period(datacons); - if (index >= _totdisp.items()) - _totdisp.add(ZERO, index); // Added by Guy! Should never happen :-) - real& rv = (real&) _totdisp[index]; - rv += qtares; - - const TDate datascimp(doc.get_date("DATASCIMP")); - - if (datascimp.ok()) - { - const int last_index = find_period(datascimp); - if (last_index >= 0) - { - real& rv = (real&) _totdisp[last_index]; - rv -= qtares; - } - } - } - else - if (command == "PRNUM") // Stampa l'unita' di misura principale - { - const TRecord_array& um = _art_giac->um(); - if (um.rows() > 0) // Controlla che ci sia almeno una unita' di misura - cf.set(um.row(1).get("UM")); // UM principale - else - cf.set(""); - } - else - { - const int period = s.get_int(3); - //const int items = _date_array->items(); - TString16 annoes; - real giacenza, scorta_min; - - TEsercizi_contabili esc; - annoes << esc.date2esc(doc.get_date(DOC_DATADOC)); - //TString16 codmag(rdoc.get(RDOC_CODMAG)); - //TString16 livello(rdoc.get(RDOC_LIVELLO)); - const int codmag_len = (_detail_dep || _detail_mag) ? _codmag.len() : 0; - const int livello_len = _level > 0 ? _livello.len() : 0; - //if (_art_giac->read(rdoc.get(RDOC_CODART)) == NOERR) - { - // Serve l'anno esercizio del magazzino... + // Serve l'anno esercizio del magazzino... - // Ciclo sulle giacenze di magazzino - TRecord_array& mmgg = _art_giac->mag(annoes); - const int rows = mmgg.rows(); - // Cumula raggruppando le giacenze per lo stesso mag/dep/liv.giac - // Scurre alla ruvescia - for (int i=mmgg.last_row();i>0;i--) - { - const TRectype& rec = mmgg.row(i); // gosh!? + // Ciclo sulle giacenze di magazzino + TRecord_array& mmgg = _art_giac->mag(annoes); + const int rows = mmgg.rows(); + // Cumula raggruppando le giacenze per lo stesso mag/dep/liv.giac + // Scurre alla ruvescia + for (int i=mmgg.last_row();i>0;i--) + { + const TRectype& rec = mmgg.row(i); // gosh!? - //checkka se trattasi di medesimo liv giac/mag/dep in caso sia stato spec. il dettaglio - // altrimenti cumula el todo - if (codmag_len == 0 || (rec.get(MAG_CODMAG).compare(_codmag, codmag_len) == 0)) - if (livello_len == 0 || (rec.get(MAG_LIVELLO).compare(_livello, livello_len) == 0)) - { - giacenza += _art_giac->giacenza_corretta(rec, _giac_eff, _val_comp); - scorta_min = rec.get_real(MAG_SCORTAMIN); - } + //checkka se trattasi di medesimo liv giac/mag/dep in caso sia stato spec. il dettaglio + // altrimenti cumula el todo + if (codmag_len == 0 || (rec.get(MAG_CODMAG).compare(_codmag, codmag_len) == 0)) + if (livello_len == 0 || (rec.get(MAG_LIVELLO).compare(_livello, livello_len) == 0)) + { + giacenza += _art_giac->giacenza_corretta(rec, _giac_eff, _val_comp); + scorta_min = rec.get_real(MAG_SCORTAMIN); } - } - for (int i = 0; i< period/*items*/; i++) - giacenza += (real&)_totdisp[i]; - if (command == "PRNGIAC") // Stampa la giacenza prevista + } + } + for (int i = 0; i< period/*items*/; i++) + giacenza += (real&)_totdisp[i]; + if (command == "PRNGIAC") // Stampa la giacenza prevista + { + cf.set(giacenza.string()); + } + else + if (command == "PRNSOTT") // Stampa il sottoscorta + { + if (giacenza < scorta_min) { + giacenza = scorta_min - giacenza; cf.set(giacenza.string()); } else - if (command == "PRNSOTT") // Stampa il sottoscorta - { - if (giacenza < scorta_min) - { - giacenza = scorta_min - giacenza; - cf.set(giacenza.string()); - } - else - cf.set(""); - } - // Ignore any other command - } + cf.set(""); + } + // Ignore any other command + } } else if (action == "PREZZONS") @@ -402,7 +411,7 @@ bool TOrdine_form::validate(TForm_item &cf, TToken_string &s) } else if (action == "VALRES") { - cf.set(rdoc.valore(true, false, AUTO_DECIMALS).string()); + cf.set(rdoc.valore(false, false, AUTO_DECIMALS).string()); // true -> false totale -> residuo 22-10-2014 } else if (action == "GIACENZA") { diff --git a/or/ormenu.men b/or/ormenu.men index cca7d1e1b..f7b13577f 100755 --- a/or/ormenu.men +++ b/or/ormenu.men @@ -4,6 +4,6 @@ Picture = Module = 33 Flags = "" Item_01 = "Stampa ordini", "or1.exe -0","F" -Item_02 = "Stampa disponibilita' articoli", "or1.exe -1","F" +Item_02 = "Stampa disponibilità articoli", "or1.exe -1","F" Item_03 = "Generazione ordini a fornitore", "or1.exe -3","F" Item_04 = "Scarico e ripristino documenti", "ve5.exe -0","F"