From 9b9b8a17996e9bad39c01a64f4b89389d59501d5 Mon Sep 17 00:00:00 2001 From: Alessandro Bonazzi Date: Fri, 27 Nov 2020 23:58:51 +0100 Subject: [PATCH] Patch level : 12.0 1016 Files correlati : ve0.exe Commento : Aggiunte le funzioni : get_property_str get_property_bool get_property_int long get_property_long get_property_date get_property_real al tipo documento, tipo riga documento e alla riga documento Aggiunto multi_row_rif_handler (handler numero 9 delle righe documento) per caricare un campo dalle righe da cui deriva una riga. --- src/ve/velib.h | 24 ++++++++++- src/ve/velib02.cpp | 97 +++++++++++++++++++++++++++++++++++++++++++++ src/ve/velib03a.cpp | 42 ++++++++++++++++++++ src/ve/velib06.cpp | 1 + src/ve/velib06a.cpp | 39 ++++++++++++++++-- src/ve/vepriv.h | 5 +-- 6 files changed, 199 insertions(+), 9 deletions(-) diff --git a/src/ve/velib.h b/src/ve/velib.h index 0728b1fe6..513074e3d 100755 --- a/src/ve/velib.h +++ b/src/ve/velib.h @@ -386,6 +386,14 @@ public: bool auto_evasione() const { return get_bool("B15"); } const TString & auto_evasione_elab() const { return get("S12"); } + + const TString & get_property_str(const char * paragraph, const char * property_name, const char* defval = "", int idx = -1) const; + const bool get_property_bool(const char * paragraph, const char * property_name, const bool defval = false, int idx = -1) const; + const int get_property_int(const char * paragraph, const char * property_name, const int defval = 0, int idx = -1) const; + const long get_property_long(const char * paragraph, const char * property_name, const long defval = 0L, int idx = -1) const; + const TDate get_property_date(const char * paragraph, const char * property_name, const char * defval = "", int idx = -1) const; + const real get_property_real(const char * paragraph, const char * property_name, const char * defval = "", int idx = -1) const; + TTipo_documento(const char* tipodoc = NULL); TTipo_documento(const TRectype& rec); @@ -535,6 +543,13 @@ public: int read(const char* tiporig); void set_defaults(TSheet_field& s, int row) const; + const TString & get_property_str(const char * paragraph, const char * property_name, const char* defval = "", int idx = -1) const; + const bool get_property_bool(const char * paragraph, const char * property_name, const bool defval = false, int idx = -1) const; + const int get_property_int(const char * paragraph, const char * property_name, const int defval = 0, int idx = -1) const; + const long get_property_long(const char * paragraph, const char * property_name, const long defval = 0L, int idx = -1) const; + const TDate get_property_date(const char * paragraph, const char * property_name, const char * defval = "", int idx = -1) const; + const real get_property_real(const char * paragraph, const char * property_name, const char * defval = "", int idx = -1) const; + TTipo_riga_documento(const char* tiporig = NULL); TTipo_riga_documento(const TRectype& rec); virtual ~TTipo_riga_documento() { } @@ -715,7 +730,14 @@ public: void update_orders(real qta, TToken_string & tipi, TToken_string & stati, const char stato_aperto, const char stato_evaso); - TRiga_documento(TDocumento* doc, const char* tipo = NULL); + const TString & get_property_str(const char * paragraph, const char * property_name, const char* defval = "", int idx = -1) const; // ricorsive tipo riga poi tipo documento + const bool get_property_bool(const char * paragraph, const char * property_name, bool defval = false, int idx = -1) const; + const int get_property_int(const char * paragraph, const char * property_name, int defval = 0, int idx = -1) const; + const long get_property_long(const char * paragraph, const char * property_name, long defval = 0L, int idx = -1) const; + const TDate get_property_date(const char * paragraph, const char * property_name, const char * defval = "", int idx = -1) const; + const real get_property_real(const char * paragraph, const char * property_name, const char * defval = "", int idx = -1) const; + + TRiga_documento(TDocumento* doc, const char* tipo = NULL); TRiga_documento(const TRiga_documento & row); virtual ~TRiga_documento() {} }; diff --git a/src/ve/velib02.cpp b/src/ve/velib02.cpp index 685f180b4..5ea1742c4 100755 --- a/src/ve/velib02.cpp +++ b/src/ve/velib02.cpp @@ -150,6 +150,48 @@ TFormula_documento * TTipo_riga_documento::succ_formula(bool restart) return NULL; } +const TString & TTipo_riga_documento::get_property_str(const char * paragraph, const char * property_name, const char* defval, int idx) const +{ + TFilename prof; profile_name(prof); + + return ini_get_string(prof, paragraph, property_name, defval, idx); +} + +const bool TTipo_riga_documento::get_property_bool(const char * paragraph, const char * property_name, bool defval, int idx) const +{ + TFilename prof; profile_name(prof); + + return ini_get_bool(prof, paragraph, property_name, defval, idx); +} + +const int TTipo_riga_documento::get_property_int(const char * paragraph, const char * property_name, int defval, int idx) const +{ + TFilename prof; profile_name(prof); + + return ini_get_int(prof, paragraph, property_name, defval, idx); +} + +const long TTipo_riga_documento::get_property_long(const char * paragraph, const char * property_name, long defval, int idx) const +{ + TFilename prof; profile_name(prof); + + return ini_get_long(prof, paragraph, property_name, defval, idx); +} + +const TDate TTipo_riga_documento::get_property_date(const char * paragraph, const char * property_name, const char * defval, int idx) const +{ + TFilename prof; profile_name(prof); + + return ini_get_date(prof, paragraph, property_name, defval, idx); +} + +const real TTipo_riga_documento::get_property_real(const char * paragraph, const char * property_name, const char * defval, int idx) const +{ + TFilename prof; profile_name(prof); + + return ini_get_real(prof, paragraph, property_name, defval, idx); +} + /////////////////////////////////////////////////////////// // Riga documento per vendite /////////////////////////////////////////////////////////// @@ -1798,3 +1840,58 @@ bool TRiga_documento::edit(int logicnum, const char* alternate_key_fields, const app = "pe0 -3"; return TRectype::edit(logicnum, alternate_key_fields, app); } + +const TString & TRiga_documento::get_property_str(const char * paragraph, const char * property_name, const char* defval, int idx) const +{ + TString & s = get_tmp_string(2048); + + s = tipo().get_property_str(paragraph, property_name, defval, idx); + if (s == defval) + s = doc().tipo().get_property_str(paragraph, property_name, defval, idx); + return s; +} + +const bool TRiga_documento::get_property_bool(const char * paragraph, const char * property_name, bool defval, int idx) const +{ + bool b = tipo().get_property_bool(paragraph, property_name, defval, idx); + + if (b == defval) + b = doc().tipo().get_property_bool(paragraph, property_name, defval, idx); + return b; +} + +const int TRiga_documento::get_property_int(const char * paragraph, const char * property_name, int defval, int idx) const +{ + int i = get_property_int(paragraph, property_name, defval, idx); + + if (i == defval) + i = doc().tipo().get_property_int(paragraph, property_name, defval); + return i; +} + +const long TRiga_documento::get_property_long(const char * paragraph, const char * property_name, long defval, int idx) const +{ + long l = tipo().get_property_long(paragraph, property_name, defval, idx); + + if (l == defval) + l = doc().tipo().get_property_long(paragraph, property_name, defval, idx); + return l; +} + +const TDate TRiga_documento::get_property_date(const char * paragraph, const char * property_name, const char * defval, int idx) const +{ + TDate d = tipo().get_property_date(paragraph, property_name, defval, idx); + + if (d == TDate(defval)) + d = doc().tipo().get_property_date(paragraph, property_name, defval, idx); + return d; +} + +const real TRiga_documento::get_property_real(const char * paragraph, const char * property_name, const char * defval, int idx) const +{ + real r = tipo().get_property_real(paragraph, property_name, defval, idx); + + if (r == real(defval)) + r = doc().tipo().get_property_real(paragraph, property_name, defval, idx); + return r; +} diff --git a/src/ve/velib03a.cpp b/src/ve/velib03a.cpp index a4a68c07d..4f77aa7b9 100755 --- a/src/ve/velib03a.cpp +++ b/src/ve/velib03a.cpp @@ -296,6 +296,7 @@ const TPointer_array& TTipo_documento::handlers() const TConfig prof(pn, "HANDLERS"); TAssoc_array& v = prof.list_variables(); TToken_string pair; + FOR_EACH_ASSOC_STRING(v, h, k, s) { int id = 0, hnd = 0; @@ -1361,3 +1362,44 @@ TRdoc_key::TRdoc_key(const TRectype& rec) } } +const TString & TTipo_documento::get_property_str(const char * paragraph, const char * property_name, const char* defval, int idx) const +{ + TFilename prof; profile_name(prof); prof.custom_path(); + + return ini_get_string(prof, paragraph, property_name, defval, idx); +} + +const bool TTipo_documento::get_property_bool(const char * paragraph, const char * property_name, bool defval, int idx) const +{ + TFilename prof; profile_name(prof); prof.custom_path(); + + return ini_get_bool(prof, paragraph, property_name, defval, idx); +} + +const int TTipo_documento::get_property_int(const char * paragraph, const char * property_name, int defval, int idx) const +{ + TFilename prof; profile_name(prof); prof.custom_path(); + + return ini_get_int(prof, paragraph, property_name, defval, idx); +} + +const long TTipo_documento::get_property_long(const char * paragraph, const char * property_name, long defval, int idx) const +{ + TFilename prof; profile_name(prof); prof.custom_path(); + + return ini_get_long(prof, paragraph, property_name, defval, idx); +} + +const TDate TTipo_documento::get_property_date(const char * paragraph, const char * property_name, const char * defval, int idx) const +{ + TFilename prof; profile_name(prof); prof.custom_path(); + + return ini_get_date(prof, paragraph, property_name, defval, idx); +} + +const real TTipo_documento::get_property_real(const char * paragraph, const char * property_name, const char * defval, int idx) const +{ + TFilename prof; profile_name(prof); prof.custom_path(); + + return ini_get_real(prof, "MAIN", property_name, defval, idx); +} diff --git a/src/ve/velib06.cpp b/src/ve/velib06.cpp index 3f50c0a86..3890c563e 100755 --- a/src/ve/velib06.cpp +++ b/src/ve/velib06.cpp @@ -1727,6 +1727,7 @@ TVariable_mask* TDocumento_mask::riga_mask(int numriga) TFilename proname; tiporiga.profile_name(proname); TConfig pro( proname, "HANDLERS" ); TAssoc_array& handlers = pro.list_variables(); + FOR_EACH_ASSOC_STRING(handlers, obj, key, str) { int id = 0, hd = 0; diff --git a/src/ve/velib06a.cpp b/src/ve/velib06a.cpp index 3ea87c6fb..324c3bc96 100755 --- a/src/ve/velib06a.cpp +++ b/src/ve/velib06a.cpp @@ -35,8 +35,6 @@ #include "../ca/calib01.h" #include "../ca/commesse.h" - - #define MAX_VIS_RATE 5 bool numdocrif_hndl( TMask_field& field, KEY key ) @@ -584,7 +582,10 @@ void TDocumento_mask::user_set_row_handler(TMask& rm, short field, int index) if (field >= FR_LIV1 && field <= FR_LIV4) rm.set_handler(field, gen_livelli_handler); break; - default: + case 9: + rm.set_handler(field, multi_row_rif_handler); + break; + default: break; } } @@ -1903,7 +1904,8 @@ bool codart_handler(TMask_field& f, KEY key ) const char* rdoc_prezzo = mask.doc().tipo().calcolo_lordo() ? RDOC_PREZZOL : RDOC_PREZZO; mask.doc()[current_doc_row].put(rdoc_prezzo, row_mask.get(FR_PREZZO)); - TArticolo_conai cart(codart); + + TArticolo_conai cart(codart); for (int i = 0; i < FR_CMAX; i++) { @@ -3659,3 +3661,32 @@ bool nar_handler(TMask_field& f, KEY key) } return true; } +bool multi_row_rif_handler(TMask_field& f, KEY key) +{ + if (f.initial_check(key) && f.get().blank()) + { + TMask& row_mask = f.mask(); + TSheet_field& sh = *row_mask.get_sheet(); + TDocumento_mask& mask = (TDocumento_mask &)sh.mask(); + const int current_doc_row = sh.selected() + 1; + TRiga_documento & row = mask.doc()[current_doc_row]; + TToken_string refs(row.get(RDOC_ORIGINAL_ROWS), ','); + TString_array row_refs; + TString val; + + row_refs.tok2arr(refs); + FOR_EACH_ARRAY_ROW(row_refs, r, row_ref) + { + const TRectype& orig_row = cache().get(LF_RIGHEDOC, *row_ref); // ORC | 2020 | D | 3 | 8 + const TString & rif_fld = row.get_property_str("", "RIF_FLD_ROW"); + TRecfield riffld((TRectype &)orig_row, rif_fld); + const TString rifval = (const char *)riffld; + + if (val.full()) + val << " - "; + val << rifval; + } + f.set(val); + } + return true; +} \ No newline at end of file diff --git a/src/ve/vepriv.h b/src/ve/vepriv.h index 1960b6fe7..33fbc48cd 100755 --- a/src/ve/vepriv.h +++ b/src/ve/vepriv.h @@ -50,14 +50,11 @@ bool fido_hndl(TMask_field& field, KEY key); bool nar_handler(TMask_field& f, KEY key); bool subappalto_hndl(TMask_field& f, KEY key); bool reportba8_hndl(TMask_field& f, KEY key); +bool multi_row_rif_handler(TMask_field& f, KEY key); bool is_tipodoc_ok(const TString & tipodoc); short conai_peso_id(int cc); short conai_sottocat_id(int cc); const char* get_cf_esenz(const TString& tipo_conai); - - - - #endif