diff --git a/src/ve/velib.h b/src/ve/velib.h index a3f903465..931580688 100755 --- a/src/ve/velib.h +++ b/src/ve/velib.h @@ -1029,6 +1029,7 @@ public: void update_prices(); void update_descriptions(); + TCausale * get_caus_cont(int year = 0) const; TDocumento (); TDocumento (const TDocumento& d); @@ -1240,8 +1241,8 @@ public: static bool ragsoc_search_handler( TMask_field& f, KEY key ); static bool rif_search_handler( TMask_field& f, KEY key ); static bool datadocrif_handler(TMask_field& f, KEY key); - static bool sheet_handler(TMask_field& f, KEY key); - static bool liqdiff_handler( TMask_field& f, KEY key ); + static bool sheet_handler(TMask_field& f, KEY key); + static bool liqdiff_handler( TMask_field& f, KEY key ); virtual void highlight_row(int row, COLOR back = COLOR_INVALID, COLOR fore = COLOR_INVALID, bool dirty = true, bool update = true); @@ -1273,6 +1274,8 @@ public: void sel_color(); bool gestione_note_per_articolo() const; + void update_cartacei(); + TDocumento_mask(const char* tipodoc); virtual ~TDocumento_mask(); }; diff --git a/src/ve/velib03.cpp b/src/ve/velib03.cpp index ed4440135..795250e55 100755 --- a/src/ve/velib03.cpp +++ b/src/ve/velib03.cpp @@ -9,6 +9,7 @@ #include "../db/dblib.h" #include "../pr/prlib.h" #include "../li/letint.h" +#include "../f9/f9lib.h" #ifdef LIVE_STATISTICS #include "../sv/svlib01.h" @@ -3700,9 +3701,7 @@ real TDocumento::qta_bloccata_auto_evasione(const int nrow) const long num = key.get_long(3); const TString codnum = key.get(0); TDocumento d(provv, anno, codnum, num); - - - + if (d.stato() >= stato_evaso) qta_bloccata += qtas.get_real(pos); pos++; @@ -3928,4 +3927,67 @@ void TDocumento::update_descriptions() rdoc->set_descr(descr); } } -} \ No newline at end of file +} + +TCausale * TDocumento::get_caus_cont(int year) const +{ + TString4 codcaus = tipo().causale(); + TToken_string key; + const TString fld_cms_cont = ini_get_string(CONFIG_DITTA, "CMSCNTFIELD", "ve"); + TCausale * causale = nullptr; + + if (year == 0) + year = get_date(DOC_DATADOC).year(); + if (main_app().has_module(F9AUT, CHK_DONGLE)) + { + const TString & tipodocsdi = get(DOC_TIPODOCSDI); + + if (tipodocsdi.full()) + { + const TString & tipodoc_cont = cached_causale(codcaus, year).tipodoc(); + +#ifdef NEW_FP + TClasse_doc * classe = categorie_doc().tipo2class(tipodocsdi, tipodoc_cont); + + if (classe != nullptr) + + codcaus = classe->caus_cont(); +#else + codcaus = categorie_doc().tipo2caus_cont(tipodocsdi, tipodoc_cont); +#endif + } + } + + if (codcaus.blank() && fld_cms_cont.full()) + { + const TString& cms = commessa_principale(); + + if (cms.full()) + { + key.add(cms); + + const TString16 fld_val = cache().get(LF_COMMESSE, key, fld_cms_cont); + + if (fld_val.full()) + { + key = "CTCMS"; + key.add(tipo().codice()); + key.add(fld_val); + codcaus = cache().get(LF_MULTIREL, key, "DATA"); + } + } + } + if (codcaus.blank()) + { + key = get(DOC_TIPOCF); key.add(get(DOC_CODCF)); + const TRectype& cfven = cache().get(LF_CFVEN, key); + + codcaus = cfven.get(is_nota_credito() ? CFV_CODCAUSNC : CFV_CODCAUS); + + if (codcaus.blank()) + codcaus = tipo().causale(); // Istanzia la causale del documento corrente... + } + if (codcaus.full()) + causale = (TCausale *)&cached_causale(codcaus, year); + return causale; +} diff --git a/src/ve/velib04b.cpp b/src/ve/velib04b.cpp index 8116062c2..68e1cbb74 100755 --- a/src/ve/velib04b.cpp +++ b/src/ve/velib04b.cpp @@ -1056,6 +1056,8 @@ long TContabilizzazione::doc_contabilized(const TDocumento& doc, bool anticipo) TCausale* TContabilizzazione::get_caus(const TDocumento& doc, const int year) const { + return doc.get_caus_cont(year); + /* TString4 codcaus; TToken_string key; static TCategorie_doc __cats; @@ -1110,6 +1112,7 @@ TCausale* TContabilizzazione::get_caus(const TDocumento& doc, const int year) co _caus = (TCausale *) &cached_causale(codcaus, year); return _caus; +*/ } error_type TContabilizzazione::compile_head_mov(TDocumento& doc) diff --git a/src/ve/velib05.cpp b/src/ve/velib05.cpp index 17207ef73..9de74838a 100755 --- a/src/ve/velib05.cpp +++ b/src/ve/velib05.cpp @@ -350,7 +350,7 @@ const TString & TDocumentoEsteso::tipo_doc_sdi() const TString & tipo_doc_sdi = get_tmp_string(16); tipo_doc_sdi = get(DOC_TIPODOCSDI); - // Controlli da fare per clienti a cui si fotte la conversione e mi trovo dati sporchi nella colonna + // Controlli da fare per clienti a cui si fotte la conversione e mi trovo dati sporchi nella colonna !!!! ma che cazzata !!!! if (tipo_doc_sdi.len() == 4 && tipo_doc_sdi.starts_with("TD")) return tipo_doc_sdi; return tipo().tipo_doc_sdi(); diff --git a/src/ve/velib06.cpp b/src/ve/velib06.cpp index 8dcae9b89..0f3a6275b 100755 --- a/src/ve/velib06.cpp +++ b/src/ve/velib06.cpp @@ -10,7 +10,8 @@ #include #include -#include "../db/dblib.h" +#include "../db/dblib.h" +#include "../f9/f9lib.h" #include "velib04.h" #include "vepriv.h" #include "verig.h" @@ -150,6 +151,7 @@ TDocumento_mask::TDocumento_mask(const char* td) set_field_handler( F_NUMDOCRIF, datadocrif_handler); set_field_handler( F_DATADOCRIF, datadocrif_handler); set_field_handler( F_LIQDIFF, liqdiff_handler); + set_field_handler(F_TIPO_SDI, tipodocsdi_handler); set_field_handler( F_SHEET, sheet_handler); set_handler( DLG_ELABORA, elabora_handler ); set_handler( DLG_PRINT, print_handler ); @@ -4605,6 +4607,33 @@ bool TDocumento_mask::gestione_note_per_articolo() const return id2pos(F_NAR) > 0; } +void TDocumento_mask::update_cartacei() +{ + TGolem_field * g = (TGolem_field *)find_by_id(DLG_CARTACEI); + TString catdoc; + + if (g != nullptr) + { + TDocumento& curr_doc = doc(); + const TCausale * c = curr_doc.get_caus_cont(); + + if (c != nullptr) + { + if (c->iva() != nessuna_iva) + { + const TString& tipodoc = c->tipo_doc(); + TClasse_doc * cat = categorie_doc().find_causcont(c->codice()); // Cerco se ho un record che abbia specificata quella caus. contabile + + if (cat == nullptr) + cat = categorie_doc().find_tipodoc(tipodoc); + if (cat != nullptr) + catdoc = cat->catdoc(); + } + } + g->set_catdoc(catdoc); + } +} + /////////////////////////////////////////////////////////// // Gestione lettore codice a barre /////////////////////////////////////////////////////////// diff --git a/src/ve/velib06a.cpp b/src/ve/velib06a.cpp index 1cb154853..75250a785 100755 --- a/src/ve/velib06a.cpp +++ b/src/ve/velib06a.cpp @@ -2994,6 +2994,7 @@ bool codcms_handler(TMask_field& f, KEY key) mask.mask2doc(); doc.zero(DOC_SPESEUPD); doc.update_spese_aut(spese, false, &mask.sfield(F_SHEET)); + mask.update_cartacei(); } } if ((main_app().has_module(CTAUT, CHK_DONGLE) || main_app().has_module(PAAUT, CHK_DONGLE)) && (key == K_TAB && f.focusdirty())) @@ -3656,6 +3657,7 @@ 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()) @@ -3677,4 +3679,16 @@ bool multi_row_rif_handler(TMask_field& f, KEY key) } } return true; +} + +bool tipodocsdi_handler(TMask_field& f, KEY key) +{ + if (f.list_initial_check(key) || f.list_running_check(key)) + { + TDocumento_mask& mask = (TDocumento_mask &)f.mask(); + + mask.mask2doc(); + mask.update_cartacei(); + } + return true; } \ No newline at end of file diff --git a/src/ve/vepriv.h b/src/ve/vepriv.h index 33fbc48cd..cc7515e31 100755 --- a/src/ve/vepriv.h +++ b/src/ve/vepriv.h @@ -51,6 +51,7 @@ 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 tipodocsdi_handler(TMask_field& f, KEY key); bool is_tipodoc_ok(const TString & tipodoc);