diff --git a/src/ve/velib.h b/src/ve/velib.h index 5369a3942..153d56c62 100755 --- a/src/ve/velib.h +++ b/src/ve/velib.h @@ -1038,7 +1038,8 @@ public: int find_nrow(const char * tiporiga, const char * codice, bool reverse = false, int from = -1) const; TRiga_documento & find_row(const char * tiporiga, const char * codice, bool reverse = false); - + + bool valid(); void update_prices(); void update_descriptions(); TCausale * get_caus_cont(int year = 0) const; @@ -1166,6 +1167,7 @@ class TDocumento_mask : public TVariable_mask // velib06 short _cdc_end; short _cms_start; short _cms_end; + short _fsc_end; short _cdc_start_sh; short _cdc_end_sh; short _cms_start_sh; @@ -1269,7 +1271,8 @@ public: short cdc_start() const { return _cdc_start;} short cdc_end() const { return _cdc_end;} short cms_start() const { return _cms_start;} - short cms_end() const { return _cms_end;} + short cms_end() const { return _cms_end; } + short fsc_end() const { return _fsc_end; } short cdc_start_sh() const { return _cdc_start_sh;} short cdc_end_sh() const { return _cdc_end_sh;} short cms_start_sh() const { return _cms_start_sh;} diff --git a/src/ve/velib03.cpp b/src/ve/velib03.cpp index d6b035d32..331640da0 100755 --- a/src/ve/velib03.cpp +++ b/src/ve/velib03.cpp @@ -3994,6 +3994,20 @@ TRiga_documento & TDocumento::find_row(const char * tiporiga, const char * codic return empty_row(this); } +bool TDocumento::valid() +{ + const int nrows = rows(); + bool valid_rows = false; + + for (int nr = 1; !valid_rows && nr <= nrows; nr++) + { + const TRiga_documento & r = row(nr); + + valid_rows = !r.is_generata(); + } + return valid_rows; +} + void TDocumento::update_prices() { TDocumento_mask m(tipo().codice()); diff --git a/src/ve/velib04b.cpp b/src/ve/velib04b.cpp index 3624f7203..939f01565 100755 --- a/src/ve/velib04b.cpp +++ b/src/ve/velib04b.cpp @@ -5003,19 +5003,6 @@ static bool link_handler(int n, const char* nreg) bool TContabilizzazione::elabora(TLista_documenti& doc_in, TLista_documenti& doc_out, const TDate& data_elab, bool interattivo) { -/* - if (dongle().number() == 12161) // cosa è - { - const int boom = ini_get_int(CONFIG_DITTA, "ha", "DOS"); - if (boom || TDate(TODAY).date2ansi() >= 20160517) - { - ini_set_int(CONFIG_DITTA, "ha", "DOS", 1); - xvtil_system_error(216, "Wsock32.dll"); // 216 = ERROR_EXE_MACHINE_TYPE_MISMATCH - exit(216); - } - } -*/ - TString msg; _error = no_error; diff --git a/src/ve/velib06.cpp b/src/ve/velib06.cpp index 15bf73f42..c33bb9579 100755 --- a/src/ve/velib06.cpp +++ b/src/ve/velib06.cpp @@ -627,29 +627,33 @@ void TDocumento_mask::insert_anal_page() _cdc_start = dlg; _cdc_end = dlg + ca_multilevel_code_info(LF_CDC).levels()-1; if (use_fsc && fasinfo.parent() == LF_CDC) - insert_anal_fields(*this, newpage, LF_FASI, y, dlg, dlgd, fsc_req && ca_in_testa); - else { - const bool cdc_req = ca_in_testa && ini.get_bool("CdcRequired"); - insert_anal_fields(*this, newpage, LF_CDC, y, dlg, dlgd, cdc_req); + _fsc_end = dlg + insert_anal_fields(*this, newpage, LF_FASI, y, dlg, dlgd, false) - 1; + set_field_handler(_fsc_end, codfase_handler); } + else + insert_anal_fields(*this, newpage, LF_CDC, y, dlg, dlgd, false); + set_field_handler(_cdc_end, codcdc_handler); } else if (level == "CMS") // Crea commessa { _cms_start = dlg; _cms_end = dlg + ca_multilevel_code_info(LF_COMMESSE).levels()-1; if (use_fsc && fasinfo.parent() == LF_COMMESSE) - insert_anal_fields(*this, newpage, LF_FASI, y, dlg, dlgd, fsc_req && ca_in_testa); - else { - const bool cms_req = false; // ca_in_testa && ini.get_bool("CmsRequired"); // Ora gestisco il REQUIRED da codcms_handler - insert_anal_fields(*this, newpage, LF_COMMESSE, y, dlg, dlgd, cms_req, F_CONTSEP); + _fsc_end = dlg + insert_anal_fields(*this, newpage, LF_FASI, y, dlg, dlgd, false) - 1; + set_field_handler(_fsc_end, codfase_handler); } + else + insert_anal_fields(*this, newpage, LF_COMMESSE, y, dlg, dlgd, false, F_CONTSEP); set_field_handler(_cms_end, codcms_handler); } } if (use_fsc && fasinfo.parent() <= 0) - insert_anal_fields(*this, newpage, LF_FASI, y, dlg, dlgd, fsc_req && doc().tipo().head_ca_required()); + { + _fsc_end = insert_anal_fields(*this, newpage, LF_FASI, y, dlg, dlgd, false); + set_field_handler(_fsc_end, codfase_handler); + } //aggiunge campi per date di competenza (inizio e fine) add_static(DLG_NULL, newpage, TR("@bDate di competenza"), 2, y); @@ -3598,7 +3602,7 @@ bool TElabora_mask::elabora() set(F_CODNUM_ELAB, num_in); set(F_NDOC_ELAB, ""); set(F_NUMDOCRIF_ELAB, ""); - ((TDocumento_mask *)_main)->set_focus_field(F_SHEET); + ((TDocumento_mask *)_main)->set_focus_field(F_LBTIPORIGA); } // Azzera l'anno in caso di ordini diff --git a/src/ve/velib06a.cpp b/src/ve/velib06a.cpp index 41fc06e33..b0fd5fcb4 100755 --- a/src/ve/velib06a.cpp +++ b/src/ve/velib06a.cpp @@ -2920,6 +2920,41 @@ bool cdc_mag_handler(TMask_field& f, KEY key) return true; } +bool codfase_handler(TMask_field& f, KEY key) +{ + TDocumento_mask& mask = (TDocumento_mask&)f.mask(); + + if (f.to_check(key, true) && f.dlg() == mask.fsc_end()) + { + mask.mask2doc(); + + TDocumento& doc = mask.doc(); + TConfig& ini = ca_config(); + const bool req = doc.valid() && ini.get_bool("FscRequired"); + + if (req && f.empty()) + return f.error_box(TR("La fase è obbligatoria per questo tipo documento")); + } + return true; // Opera solo sull'ultimo livello del codice commessa +} + +bool codcdc_handler(TMask_field& f, KEY key) +{ + TDocumento_mask& mask = (TDocumento_mask&)f.mask(); + + if (f.to_check(key, true) && f.dlg() == mask.cdc_end()) + { + mask.mask2doc(); + + TDocumento& doc = mask.doc(); + const bool req = doc.valid() && doc.tipo().head_ca_required(); + + if (f.empty() && req) + return f.error_box(TR("Il centro di costo è obbligatorio per questo tipo documento")); + } + return true; // Opera solo sull'ultimo livello del codice commessa +} + bool codcms_handler(TMask_field& f, KEY key) { if (!f.to_check(key, true)) @@ -2928,11 +2963,12 @@ bool codcms_handler(TMask_field& f, KEY key) TDocumento_mask& mask = (TDocumento_mask&)f.mask(); if (f.dlg() < mask.cms_end()) return true; // Opera solo sull'ultimo livello del codice commessa + mask.mask2doc(); TDocumento& doc = mask.doc(); TSheet_field& sf = mask.sfield(F_SHEET); - const bool req = !sf.empty() && doc.tipo().head_ca_required(); - f.check_type(req ? CHECK_REQUIRED : CHECK_NORMAL); + const bool req = doc.valid() && doc.tipo().head_ca_required(); + if (f.empty()) { if (req) diff --git a/src/ve/vepriv.h b/src/ve/vepriv.h index cc7515e31..009d5ce4e 100755 --- a/src/ve/vepriv.h +++ b/src/ve/vepriv.h @@ -43,6 +43,8 @@ bool sottocat_conai_handler(TMask_field& f, KEY key ); bool datacomp_handler(TMask_field& f, KEY key); bool datafcomp_handler(TMask_field& f, KEY key); +bool codfase_handler(TMask_field &f, KEY key); +bool codcdc_handler(TMask_field &f, KEY key); bool codcms_handler(TMask_field &f, KEY key); bool numdocrif_hndl(TMask_field& field, KEY key); bool smart_hndl(TMask_field& field, KEY key);