diff --git a/or/or1100.cpp b/or/or1100.cpp index f945c4480..36f41b1ca 100755 --- a/or/or1100.cpp +++ b/or/or1100.cpp @@ -54,7 +54,9 @@ class TStampa_ordini : public TSkeleton_application protected: static bool stato_handler(TMask_field& f, KEY k); static bool detail_handler(TMask_field& f, KEY k); - static bool datacons_filter(const TRelation* rel); + + bool document_row_filter(const TRectype& row) const; + static bool document_filter(const TRelation* rel); virtual bool create(); virtual bool destroy(); @@ -180,7 +182,49 @@ void TStampa_ordini::set_totvaluta_items() } } -bool TStampa_ordini::datacons_filter(const TRelation* rel) +bool TStampa_ordini::document_row_filter(const TRectype& row) const +{ + if (_from_cons.ok() || _to_cons.ok()) + { + const TDate datacons = row.get(RDOC_DATACONS); + if (_from_cons.ok() && datacons < _from_cons) + return FALSE; + if (_to_cons.ok() && datacons > _from_cons) + return FALSE; + } + + if (_TEA_rord > ' ') + { + const bool evasa = row.get_bool(RDOC_RIGAEVASA); + if (_TEA_rord == 'E') + { + if (!evasa) + return FALSE; + if (_force_evase) // Controlla se evasa con residuo + { + const real qta = row.get(RDOC_QTA); + const real qta_evasa = row.get(RDOC_QTAEVASA); + if (qta_evasa >= qta) + return FALSE; // Non c'e' residuo + } + } + if (_TEA_rord == 'A' && evasa) + return FALSE; + } + + if (_from_art.not_empty() || _to_art.not_empty()) + { + const TString& codart = row.get(RDOC_CODART); + if (_from_art.not_empty() && codart < _from_art) + return FALSE; + if (_to_art.not_empty() && codart > _to_art) + return FALSE; + } + + return TRUE; +} + +bool TStampa_ordini::document_filter(const TRelation* rel) { const TRectype& doc = rel->curr(LF_DOC); TRectype rdoc(LF_RIGHEDOC); @@ -190,12 +234,9 @@ bool TStampa_ordini::datacons_filter(const TRelation* rel) rdoc.put(RDOC_NDOC, doc.get(DOC_NDOC)); TRecord_array righe(LF_RIGHEDOC, RDOC_NRIGA); righe.read(rdoc); - const TDate fc = app()._from_cons; - const TDate tc = app()._to_cons; for (int r = righe.rows(); r > 0; r--) { - const TDate datacons = righe.row(r).get(RDOC_DATACONS); - if (datacons >= fc && datacons <= tc) + if (app().document_row_filter(righe.row(r))) return TRUE; } return FALSE; @@ -296,9 +337,9 @@ void TStampa_ordini::filter_for_number() cur->setfilter(filter_expr); // Filtro aggiuntivo per eliminare testate di documenti in cui tutte - // le righe hanno data di consegna fuori range - if (_detail_rows && _detail_doc) - cur->set_filterfunction(datacons_filter); + // le righe hanno data di consegna fuori range. + if (_detail_doc) // Era if (_detail_rows && _detail_doc) + cur->set_filterfunction(document_filter); if (_detail_rows) { @@ -361,7 +402,7 @@ void TStampa_ordini::filter_for_number() s = ""; if (_force_evase) - s.format("&&(%d->QTAEVASA != %d->QTA)", LF_RIGHEDOC, LF_RIGHEDOC); + s.format("&&(STR(%d->QTAEVASA<%d->QTA))", LF_RIGHEDOC, LF_RIGHEDOC); cond << s; // Setta i range per la data di consegna @@ -650,7 +691,7 @@ void TStampa_ordini::filter_for_clifo_agent() s.format("&&(%d->RIGAEVASA!=\"X\")",LF_RIGHEDOC); if (_force_evase) - s << "&&(" << LF_RIGHEDOC << ">QTAEVASA != " << LF_RIGHEDOC << "->QTA)"; + s << "&&(STR(" << LF_RIGHEDOC << "->QTAEVASA<" << LF_RIGHEDOC << "->QTA))"; } if (s.not_empty()) diff --git a/or/or1100a.uml b/or/or1100a.uml index 3a6d0bb05..d2205370e 100755 --- a/or/or1100a.uml +++ b/or/or1100a.uml @@ -1,15 +1,15 @@ #include "or1100a.h" -TOOLBAR "" 0 20 0 4 +TOOLBAR "" 0 -3 0 3 BUTTON DLG_PRINT 10 2 BEGIN - PROMPT -12 -1 "" + PROMPT -12 -11 "" END BUTTON DLG_QUIT 10 2 BEGIN - PROMPT -22 -1 "" + PROMPT -22 -11 "" END ENDPAGE