diff --git a/src/ve/velib06a.cpp b/src/ve/velib06a.cpp index d045f9da8..de31cd037 100755 --- a/src/ve/velib06a.cpp +++ b/src/ve/velib06a.cpp @@ -2915,11 +2915,18 @@ bool cms_mag_handler(TMask_field& f, KEY key) const TRectype& curr = m.efield(mask.cms_end_sh()).browse()->cursor()->curr(); const TString80 codcms = curr.get(COMMESSE_CODCMS); - if (curr.get_bool(COMMESSE_CHIUSA)) - return f.error_box(FR("Impossibile operare sulla commessa chiusa %s"), (const char*)codcms); if (mask.codcms_sh() != codcms) // Cambio commessa { + if ((key == K_TAB && f.focusdirty())) + { + bool chiusa = curr.get_bool(COMMESSE_CHIUSA); + + if (chiusa && curr.get_bool(COMMESSE_PROROGA)) + chiusa = mask.get_date(F_DATADOC) > curr.get_date(COMMESSE_DATAPROR); + if (chiusa) + return f.error_box(FR("La commessa chiusa %s, vuoi utilizzarla"), (const char*)codcms); + } mask.codcms_sh() = codcms; const TString80 codcosto = curr.get(COMMESSE_CODCOSTO); @@ -2973,14 +2980,21 @@ bool codcms_handler(TMask_field& f, KEY key) const TRectype& curr_cms = ((TEdit_field&)f).browse()->cursor()->curr(); const TString80 codcms = curr_cms.get(COMMESSE_CODCMS); mask.set(F_CMSH, codcms); - if (curr_cms.get_bool(COMMESSE_CHIUSA)) - return f.error_box(FR("Impossibile operare sulla commessa chiusa %s"), (const char*)codcms); if ((key == K_TAB && f.focusdirty()) || key == K_ENTER) { // Controlla se c'e' la gestione dei centri di costo al secondo livello if (mask.codcms() != codcms) { + if ((key == K_TAB && f.focusdirty())) + { + bool chiusa = curr_cms.get_bool(COMMESSE_CHIUSA); + + if (chiusa && curr_cms.get_bool(COMMESSE_PROROGA)) + chiusa = mask.get_date(F_DATADOC) > curr_cms.get_date(COMMESSE_DATAPROR); + if (chiusa) + return f.error_box(FR("La commessa chiusa %s, vuoi utilizzarla"), (const char*)codcms); + } doc.put(DOC_CODCMS, codcms); FOR_EACH_PHYSICAL_RDOC(doc, r, riga) {