Patch level : 10.0 222

Files correlati     : VE0.exe
Ricompilazione Demo : [ ]
Commento            :
Handler per la registrazione automatica di un livello di giacenza

Esmpio

[MAIN]
LIVGEN(0) = 47.GRMERC[1,2]|34.ANNO[3,4]|PROG4 <<<<<<<-----

[HANDLERS]
NHANDLER        = 2
1=105|7
2=106|8     <<<<<---------


git-svn-id: svn://10.65.10.50/trunk@18212 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
alex 2009-02-06 13:46:58 +00:00
parent 26ebee4491
commit 9ebac47880
3 changed files with 83 additions and 2 deletions

View File

@ -402,8 +402,7 @@ class TTipo_riga_documento : public TRectype // velib02
TToken_string _field_list;
TToken_string _header;
bool _select_clifo;
TArray _genconf;
int _decrp, _incrp;
protected:
@ -445,6 +444,7 @@ public:
const TString& provv() const { return _field_provv;}
const int incr_perc_prezzo() const { return _incrp;}
const int decr_perc_prezzo() const { return _decrp;}
TToken_string * genconf(int i) const { return (TToken_string *) _genconf.objptr(i);}
bool formfeed() const { return get_bool("B0"); }

View File

@ -110,6 +110,12 @@ void TTipo_riga_documento::read_formule()
_field_imposta = profile.get("IMPOSTA");
_incrp = profile.get_int("VARP+");
_decrp = profile.get_int("VARP-");
for (int i = 0; i < 4; i++)
{
const TToken_string str(profile.get("LIVGEN", NULL, i));
if (str.full())
_genconf.add(str, i);
}
add_formula_if_needed(profile, _imponibile, "IMPONIBILE", "IMPORTO(1)");
add_formula_if_needed(profile, _quant, "QUANT", "QUANT()");

View File

@ -406,6 +406,10 @@ void TDocumento_mask::user_set_row_handler(TMask& rm, short field, int index)
if (field == FR_CODART)
rm.set_handler(field, distinta_link_handler);
break;
case 8:
if (field >= FR_LIV1 && field <= FR_LIV4)
m.set_handler(field, gen_livelli_handler);
break;
default:
break;
}
@ -2630,3 +2634,74 @@ bool distinta_link_handler(TMask_field& f, KEY key )
return codart_handler( f, key);
}
bool gen_livelli_handler(TMask_field& f, KEY key )
{
if (key == K_F8 && f.get().blank())
{
TMask& row_mask = f.mask();
TSheet_field& sh = *row_mask.get_sheet();
TDocumento_mask & m = (TDocumento_mask & )sh.mask();
const TDocumento & d = m.doc();
const int row = sh.selected() + 1;
const int livello = f.dlg() - FR_LIV1;
const TRiga_documento & r = d[row];
TToken_string * str = r.tipo().genconf(livello);
if (str != NULL)
{
const TString codart = row_mask.get(FR_CODART);
if (codart.full())
{
TString code;
const TRectype & anamag = cache().get(LF_ANAMAG, codart);
const int items = str->items();
for (int i = 0; i < items; i++)
{
const TString & name = str->get(i);
if (name.starts_with("PROG"))
{
TTable lv(format("LV%1d", livello + 1));
const int chars = atoi(name.after("PROG"));
lv.put("CODTAB", code);
if (lv.read(_isequal) != NOERR)
{
lv.zero();
lv.put("CODTAB", code);
lv.write();
}
const int prog = lv.get_int("I0") + 1;
lv.put("I0", prog);
lv.rewrite();
TString s; s << prog; s.lpad(chars, '0');
code << s;
}
else
if (name.starts_with("33."))
{
TFieldref fld(name.after("33."), LF_DOC);
code << fld.read(d);
}
else
if (name.starts_with("34."))
{
TFieldref fld(name.after("34."), LF_RIGHEDOC);
code << fld.read(d);
}
else
if (name.starts_with("47."))
{
TFieldref fld(name.after("47."), LF_ANAMAG);
code << fld.read(anamag);
}
}
row_mask.set(f.dlg(), code, 0x3);
}
}
}
return true;
}