Patch level : 12.00 1416

Files correlati     : ve0.exe
Commento
Riprostinata la commessa precedente se l'attuale e chiusa
This commit is contained in:
Alessandro Bonazzi 2026-09-15 18:28:46 +02:00
parent 42c2419751
commit 45b418599a
2 changed files with 64 additions and 22 deletions

View File

@ -1287,7 +1287,7 @@ public:
short cms_start_sh() const { return _cms_start_sh;}
short cms_end_sh() const { return _cms_end_sh;}
TString& codcms() { return _codcms;}
const TString& codcms() const { return _codcms;}
const TString & codcms() const { return _codcms;}
TString& codcms_sh() { return _codcms_sh;}
const TString & codcms_sh() const { return _codcms_sh;}
TString& codart() { return _codart; }

View File

@ -22,7 +22,7 @@
#include "ve0100n.h"
#include "../cg/cglib.h"
#include "../db/dblib.h"
#include "../db/dblib.h"
#include "../mg/mglib.h"
#include "../db/dblib.h"
@ -499,7 +499,7 @@ bool data_hndl( TMask_field& field, KEY key )
if (m.id2pos(F_DATACAMBIO1) >= 0 && !m.get(F_CODVAL).empty())
m.set(F_DATACAMBIO1, field.get(), TRUE);
}
const TDate datadoc(m.get(F_DATADOC));
if (key == K_ENTER || field.to_check(key))
@ -993,7 +993,7 @@ bool pricerange_handler(TMask_field& f, KEY key )
}
}
return true;
return true;
}
static bool __in_handler = false;
@ -1107,8 +1107,8 @@ static void search_price(TEdit_field& f, KEY key )
TMask& row_mask = f.mask();
TSheet_field& sh = *row_mask.get_sheet();
TDocumento_mask& mask = (TDocumento_mask &)sh.mask();
TPrice_sheet sheet(f);
TPrice_sheet sheet(f);
TString_array & el = sheet.rows_array();
TRelation rel(LF_DOC);
@ -1928,10 +1928,10 @@ bool codart_handler(TMask_field& f, KEY key )
upd_colli_peso_tara(row_mask, codart);
}
condv.ricerca();
condv.ricerca();
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));
mask.doc()[current_doc_row].put(rdoc_prezzo, row_mask.get(FR_PREZZO));
TArticolo_conai cart(codart);
@ -2883,20 +2883,40 @@ bool cms_mag_handler(TMask_field& f, KEY key)
const TSheet_field& s = *m.get_sheet();
TDocumento_mask& mask = (TDocumento_mask&)s.mask();
const TRectype& curr = m.efield(mask.cms_end_sh()).browse()->cursor()->curr();
const TString80 codcms = curr.get(COMMESSE_CODCMS);
TString80 codcms = curr.get(COMMESSE_CODCMS);
TString svcms = mask.codcms_sh();
if (mask.codcms_sh() != codcms) // Cambio commessa
if (svcms != codcms) // Cambio commessa
{
if ((key == K_TAB && f.focusdirty()))
{
const TTipo_cms_check t = mask.doc().tipo().tipo_cms_check();
bool chiusa = (t != _nessuno) && 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 (t == _bloccante) ? f.error_box(FR("La commessa %s è chiusa "), (const char*)codcms) : f.yesno_box(FR("La commessa chiusa %s, vuoi utilizzarla"), (const char*)codcms);
{
bool ok = (t == _bloccante) ? error_box(FR("La commessa %s è chiusa "), (const char*)codcms) :
yesno_box(FR("La commessa chiusa %s, vuoi utilizzarla ?"), (const char*)codcms);
if (!ok)
{
codcms = svcms;
for (short i = mask.cms_start(); i <= mask.cms_end(); i++)
{
TEdit_field & e = mask.efield(i);
const TFieldref * f = e.field();
if (f != nullptr)
{
const int from = f->from();
const int to = f->to();
mask.set(i, codcms.sub(from, to), 0x2);
}
}
}
return ok;
}
}
mask.codcms_sh() = codcms;
@ -2978,7 +2998,7 @@ bool codcms_handler(TMask_field& f, KEY key)
TDocumento& doc = mask.doc();
TSheet_field& sf = mask.sfield(F_SHEET);
const bool req = ca_active(doc.get_date(DOC_DATADOC)) && doc.valid() && doc.tipo().head_ca_required();
if (f.empty())
{
if (req)
@ -2988,13 +3008,15 @@ 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);
TString80 codcms = curr_cms.get(COMMESSE_CODCMS);
mask.set(F_CMSH, 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)
TString svcms = mask.codcms();
if (svcms != codcms)
{
if ((key == K_TAB && f.focusdirty()))
{
@ -3004,7 +3026,27 @@ bool codcms_handler(TMask_field& f, KEY key)
if (chiusa && curr_cms.get_bool(COMMESSE_PROROGA))
chiusa = mask.get_date(F_DATADOC) > curr_cms.get_date(COMMESSE_DATAPROR);
if (chiusa)
return (t == _bloccante) ? f.error_box(FR("La commessa %s è chiusa "), (const char*)codcms) : f.yesno_box(FR("La commessa chiusa %s, vuoi utilizzarla"), (const char*)codcms);
{
bool ok = (t == _bloccante) ? error_box(FR("La commessa %s è chiusa "), (const char*)codcms) :
yesno_box(FR("La commessa chiusa %s, vuoi utilizzarla ?"), (const char*)codcms);
if (!ok)
{
codcms = svcms;
for (short i = mask.cms_start(); i <= mask.cms_end(); i++)
{
TEdit_field & e = mask.efield(i);
const TFieldref * f = e.field();
if (f != nullptr)
{
const int from = f->from();
const int to = f->to();
mask.set(i, codcms.sub(from, to), 0x2);
}
}
}
return ok;
}
}
doc.put(DOC_CODCMS, codcms);
FOR_EACH_PHYSICAL_RDOC(doc, r, riga)
@ -3098,7 +3140,7 @@ bool codcms_handler(TMask_field& f, KEY key)
key.add(codcms);
key.add(mask.get(F_TIPOCF));
key.add(mask.get(F_CODCF));
const TRectype & cfcms1 = __cfcm.get(key);
const int nrigaban = cfcms1.get_int(CFCMS_NRIGABAN);
@ -3109,7 +3151,7 @@ bool codcms_handler(TMask_field& f, KEY key)
key.add(mask.get(F_CODCF));
key.add("V");
key.add(nrigaban);
const TRectype & cfban = cache().get(LF_CFBAN, key);
mask.set(mask.field(F_CODABIA).active() ? F_CODABIA : F_CODABIA1, cfban.get(CFBAN_ABI), 3);
@ -3332,14 +3374,14 @@ bool gen_livelli_handler(TMask_field& f, KEY key )
if (name.starts_with("34."))
{
TFieldref fld(name.after("34."), LF_RIGHEDOC);
code << fld.read(r);
}
else
if (name.starts_with("47."))
{
TFieldref fld(name.after("47."), LF_ANAMAG);
code << fld.read(anamag);
}
}
@ -3746,4 +3788,4 @@ bool tipodocsdi_handler(TMask_field& f, KEY key)
mask.update_cartacei();
}
return true;
}
}