Patch level : 10.0 296
Files correlati : pe0.exe Ricompilazione Demo : [ ] Commento : Preventivazione (Dinamica) git-svn-id: svn://10.65.10.50/trunk@18848 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
172f3fe9b8
commit
38280476f9
118
pe/pe0400.cpp
118
pe/pe0400.cpp
@ -21,6 +21,7 @@
|
||||
#define F_ZOOM_ALL F_USERFLD+6
|
||||
#define F_SHRINK_ROW F_USERFLD+7
|
||||
#define F_ZOOM_ROW F_USERFLD+8
|
||||
#define F_USEK F_USERFLD+9
|
||||
#define FOR_EACH_DOC_ROW_BACK(d, r, row) const TRiga_documento* row = NULL; for (int r = d.rows(); r > 0 && (row = &d[r]) != NULL; r--)
|
||||
|
||||
//////////////////////////////////////////
|
||||
@ -53,6 +54,7 @@ public:
|
||||
static bool pe_espandi_riga_handler(TMask_field& f, KEY k);
|
||||
static bool pe_copia_handler(TMask_field& f, KEY k);
|
||||
static bool pe_incolla_handler(TMask_field& f, KEY k);
|
||||
static bool pe_usek_handler(TMask_field& f, KEY k);
|
||||
|
||||
virtual void user_set_handler( short fieldid, int index);
|
||||
virtual void user_set_row_handler(TMask& rm, short field, int index);
|
||||
@ -138,13 +140,14 @@ bool TGestione_preventivo_msk::ss_notify(TSheet_field& ss, int r, KEY key)
|
||||
const bool price_enabled = (r + 1 == doc.physical_rows()) || (level >= doc[r + 2].get_int(RDOC_LEVEL));
|
||||
short id;
|
||||
|
||||
row_mask.enable(FR_PREZZO, price_enabled);
|
||||
row_mask.enable(FR_JOLLY2, price_enabled);
|
||||
row_mask.enable(FR_JOLLY3, price_enabled);
|
||||
sh.enable_cell(r, sh.cid2index(FR_PREZZO), price_enabled);
|
||||
sh.enable_cell(r, sh.cid2index(FR_JOLLY2), price_enabled && mask.get_bool(F_USEK));
|
||||
sh.enable_cell(r, sh.cid2index(FR_JOLLY3), price_enabled);
|
||||
for (id = FR_CDC1; id < FR_CDC12; id++)
|
||||
row_mask.enable(id, prodfin);
|
||||
sh.enable_cell(r, sh.cid2index(id), prodfin);
|
||||
for (id = FR_DESCDC1; id < FR_DESCDC12; id++)
|
||||
row_mask.enable(id, prodfin);
|
||||
sh.enable_cell(r, sh.cid2index(id), prodfin);
|
||||
sh.force_update(r);
|
||||
}
|
||||
break;
|
||||
case K_CTRL + K_INS: // Inserimento
|
||||
@ -176,7 +179,7 @@ bool TGestione_preventivo_msk::ss_notify(TSheet_field& ss, int r, KEY key)
|
||||
if (next_level > level)
|
||||
{
|
||||
sh.disable_cell(father_sheet_row, sh.cid2index(FR_PREZZO));
|
||||
sh.disable_cell(father_sheet_row, sh.cid2index(FR_JOLLY2));
|
||||
sh.disable_cell(father_sheet_row, sh.cid2index(FR_JOLLY2) || !mask.get_bool(F_USEK));
|
||||
sh.disable_cell(father_sheet_row, sh.cid2index(FR_JOLLY3));
|
||||
father_row.zero(RDOC_PREZZO);
|
||||
father_row.zero(RDOC_K);
|
||||
@ -256,7 +259,7 @@ TVariable_mask * TGestione_preventivo_msk::riga_mask(int numriga)
|
||||
const TRiga_documento& riga = doc()[numriga + 1];
|
||||
TEdit_field & tree = m->add_string(FR_JOLLY1, 0, "Albero ", 2, 20, 10, "D_");
|
||||
TEdit_field & k = m->add_string(FR_JOLLY2, 0, "K ", 25, 20, 25);
|
||||
TEdit_field & v = m->add_currency(FR_JOLLY3, 0, "Vendita ", 50, 20, 15, "U");
|
||||
TEdit_field & v = m->add_currency(FR_JOLLY3, 0, "Costo", 53, 20, 15, "U");
|
||||
|
||||
m->set_handler(FR_CODART, pe_codart_handler);
|
||||
m->set_handler(FR_QTA, pe_qta_handler);
|
||||
@ -264,7 +267,7 @@ TVariable_mask * TGestione_preventivo_msk::riga_mask(int numriga)
|
||||
m->set_handler(FR_JOLLY2, pe_k_handler);
|
||||
tree.set_field(RDOC_TREE);
|
||||
k.set_field(RDOC_K);
|
||||
v.set_field(RDOC_PREZZOV);
|
||||
v.set_field(RDOC_COSTO);
|
||||
}
|
||||
return m;
|
||||
|
||||
@ -278,6 +281,7 @@ void TGestione_preventivo_msk::doc2mask(bool reload_clifo, bool force_load, bool
|
||||
TSheet_field& s = sfield(F_SHEET);
|
||||
const int righe = s.items();
|
||||
const TDocumento & d = doc();
|
||||
const bool has_k = get_bool(F_USEK);
|
||||
|
||||
for (int i = 0; i < righe; i++)
|
||||
{
|
||||
@ -287,7 +291,7 @@ void TGestione_preventivo_msk::doc2mask(bool reload_clifo, bool force_load, bool
|
||||
const bool price_enabled = (i + 1 == d.physical_rows()) || (level >= d[i + 2].get_int(RDOC_LEVEL));
|
||||
|
||||
s.enable_cell(i, s.cid2index(FR_PREZZO), price_enabled);
|
||||
s.enable_cell(i, s.cid2index(FR_JOLLY2), price_enabled);
|
||||
s.enable_cell(i, s.cid2index(FR_JOLLY2), price_enabled && has_k);
|
||||
s.enable_cell(i, s.cid2index(FR_JOLLY3), price_enabled);
|
||||
for (short id = FR_CDC1; id < FR_CDC12; id++)
|
||||
s.enable_cell(i, s.cid2index(id), prodfin);
|
||||
@ -439,6 +443,30 @@ bool TGestione_preventivo_msk::pe_incolla_handler(TMask_field& f, KEY k)
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool TGestione_preventivo_msk::pe_usek_handler(TMask_field& f, KEY k)
|
||||
{
|
||||
if (k == K_SPACE)
|
||||
{
|
||||
TGestione_preventivo_msk& mask = (TGestione_preventivo_msk&)f.mask();
|
||||
const bool has_k = mask.get_bool(F_USEK);
|
||||
const TDocumento & d = mask.doc();
|
||||
const int righe = d.physical_rows();
|
||||
TSheet_field & sh = mask.sfield(F_SHEET);
|
||||
|
||||
for (int i = 0; i < righe; i++)
|
||||
{
|
||||
const TRiga_documento & row = d[i + 1];
|
||||
const int level = row.get_int(RDOC_LEVEL);
|
||||
const bool prodfin = level == 0;
|
||||
const bool price_enabled = (i + 1 == d.physical_rows()) || (level >= d[i + 2].get_int(RDOC_LEVEL));
|
||||
|
||||
sh.enable_cell(i, sh.cid2index(FR_JOLLY2), price_enabled && has_k);
|
||||
}
|
||||
sh.force_update();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
///////////////////////
|
||||
// HANDLER DI RIGA //
|
||||
///////////////////////
|
||||
@ -457,13 +485,15 @@ bool TGestione_preventivo_msk::pe_codart_handler(TMask_field& f, KEY k)
|
||||
const int r = sh->selected();
|
||||
TRiga_documento & row = doc[r + 1];
|
||||
|
||||
if (row_mask.field(FR_JOLLY2).active())
|
||||
{
|
||||
const TString& codart = row.get(RDOC_CODARTMAG);
|
||||
const TString& codart = row.get(RDOC_CODARTMAG);
|
||||
|
||||
if (codart.full())
|
||||
if (codart.full())
|
||||
{
|
||||
const TArticolo_giacenza & art = cached_article(codart);
|
||||
const real costo = art.get_real(ANAMAG_ULTCOS1);
|
||||
|
||||
if (row_mask.field(FR_JOLLY2).enabled())
|
||||
{
|
||||
const TArticolo_giacenza & art = cached_article(codart);
|
||||
const real ric = art.get(ANAMAG_PERCRIC);
|
||||
TString80 k;
|
||||
|
||||
@ -480,12 +510,18 @@ bool TGestione_preventivo_msk::pe_codart_handler(TMask_field& f, KEY k)
|
||||
if (k.full())
|
||||
row_mask.set(FR_JOLLY2, k);
|
||||
}
|
||||
row_mask.set(FR_JOLLY3, costo);
|
||||
}
|
||||
if (!row_mask.field(FR_PREZZO).active())
|
||||
if (mask.get(F_USEK).full() || !row_mask.field(FR_PREZZO).enabled())
|
||||
row_mask.set(FR_PREZZO, "");
|
||||
|
||||
if (row_mask.field(FR_JOLLY3).enabled())
|
||||
{
|
||||
if (row_mask.get(FR_PREZZO).blank())
|
||||
mask.update_prezzo_vendita(row_mask);
|
||||
}
|
||||
else
|
||||
if (row_mask.field(FR_JOLLY3).active())
|
||||
mask.update_prezzo_vendita(row_mask);
|
||||
row_mask.set(FR_JOLLY3, "");
|
||||
}
|
||||
if (k == K_F8)
|
||||
{
|
||||
@ -496,6 +532,7 @@ bool TGestione_preventivo_msk::pe_codart_handler(TMask_field& f, KEY k)
|
||||
TGestione_preventivo_msk & mask = (TGestione_preventivo_msk &) sh->mask();
|
||||
TDocumento & doc = mask.doc();
|
||||
const int rows = doc.physical_rows();
|
||||
const bool has_k = mask.get_bool(F_USEK);
|
||||
|
||||
for (int i = 1; i <= rows; i++)
|
||||
{
|
||||
@ -506,7 +543,7 @@ bool TGestione_preventivo_msk::pe_codart_handler(TMask_field& f, KEY k)
|
||||
short id;
|
||||
|
||||
sh->enable_cell(i - 1, sh->cid2index(FR_PREZZO), price_enabled);
|
||||
sh->enable_cell(i - 1, sh->cid2index(FR_JOLLY2), price_enabled);
|
||||
sh->enable_cell(i - 1, sh->cid2index(FR_JOLLY2), price_enabled && has_k);
|
||||
sh->enable_cell(i - 1, sh->cid2index(FR_JOLLY3), price_enabled);
|
||||
for (id = FR_CDC1; id < FR_CDC12; id++)
|
||||
sh->enable_cell(i - 1, id, prodfin);
|
||||
@ -600,21 +637,23 @@ bool TGestione_preventivo_msk::pe_qta_handler(TMask_field& f, KEY k)
|
||||
}
|
||||
void TGestione_preventivo_msk::update_prezzo_vendita(TMask & row_mask)
|
||||
{
|
||||
real prezzo = row_mask.get_real(FR_PREZZO);
|
||||
TString k(row_mask.get(FR_JOLLY2));
|
||||
TString ge;
|
||||
real perc;
|
||||
TSheet_field * sh = row_mask.get_sheet();
|
||||
const int r = sh->selected();
|
||||
if (row_mask.get(FR_PREZZO).blank())
|
||||
{
|
||||
real costo = row_mask.get(FR_JOLLY3);
|
||||
TString k(row_mask.get(FR_JOLLY2));
|
||||
TString ge;
|
||||
real perc;
|
||||
TSheet_field * sh = row_mask.get_sheet();
|
||||
const int r = sh->selected();
|
||||
|
||||
if (k.blank())
|
||||
k = get(F_K);
|
||||
if (scontoexpr2perc(k, false, ge, perc))
|
||||
prezzo *= (2 - perc);
|
||||
|
||||
TCurrency_documento c(prezzo, doc(), true);
|
||||
|
||||
row_mask.set(FR_JOLLY3, c.get_num().string());
|
||||
if (k.blank())
|
||||
k = get(F_K);
|
||||
if (scontoexpr2perc(k, false, ge, perc))
|
||||
costo *= (2 - perc);
|
||||
|
||||
TCurrency_documento prezzo(costo, doc(), true);
|
||||
row_mask.set(FR_PREZZO, prezzo.get_num().string());
|
||||
}
|
||||
}
|
||||
|
||||
bool TGestione_preventivo_msk::pe_k_handler(TMask_field& f, KEY k)
|
||||
@ -622,7 +661,7 @@ bool TGestione_preventivo_msk::pe_k_handler(TMask_field& f, KEY k)
|
||||
TMask& row_mask = f.mask();
|
||||
TSheet_field * sh = row_mask.get_sheet();
|
||||
|
||||
if (row_mask.field(FR_JOLLY3).active() && sh != NULL && k == K_TAB && f.focusdirty())
|
||||
if (row_mask.field(FR_JOLLY3).enabled() && sh != NULL && k == K_TAB && f.focusdirty())
|
||||
{
|
||||
TGestione_preventivo_msk & mask = (TGestione_preventivo_msk &) sh->mask();
|
||||
|
||||
@ -695,7 +734,18 @@ TMask* TGestione_preventivo_app::get_mask( int mode )
|
||||
m->add_button(F_ZOOM_ROW, sh.page(), "+", 76, y -1, 1, 1, "", BMP_SARROWD);
|
||||
m->set_handler(F_ZOOM_ROW, TGestione_preventivo_msk::pe_espandi_riga_handler);
|
||||
|
||||
TEdit_field & k = m->add_string(F_K, sh.page(), "K ", 2, y, 25);
|
||||
TBoolean_field & fk = m->add_boolean(F_USEK, sh.page(), "", 2, y);
|
||||
|
||||
fk.set_field(DOC_USEK);
|
||||
m->set_handler(F_USEK, TGestione_preventivo_msk::pe_usek_handler);
|
||||
|
||||
TToken_string * fk_false = fk.message(0, true);
|
||||
TToken_string * fk_true = fk.message(1, true);
|
||||
|
||||
*fk_false << "CLEAR," << F_K;
|
||||
*fk_true << "ENABLE," << F_K;
|
||||
|
||||
TEdit_field & k = m->add_string(F_K, sh.page(), "K ", 5, y, 25);
|
||||
|
||||
k.set_field(DOC_K);
|
||||
m->add_number(F_LIVELLO, sh.page(), "Livello Successivo ", 33, y, 1);
|
||||
|
@ -39,50 +39,53 @@ void TGenerazione_esecutivo::genera_matricola(TRiga_documento & row)
|
||||
const TRectype & anamag = cache().get(LF_ANAMAG, codart);
|
||||
const int items = str->items();
|
||||
|
||||
for (int i = 0; i < items; i++)
|
||||
if (anamag.get_bool(ANAMAG_ARTPROD))
|
||||
{
|
||||
const TString & name = str->get(i);
|
||||
if (name.starts_with("PROG"))
|
||||
for (int i = 0; i < items; i++)
|
||||
{
|
||||
TTable mat(format("VE%1d", livello + 1));
|
||||
const int chars = atoi(name.after("PROG"));
|
||||
|
||||
mat.put("CODTAB", code);
|
||||
if (mat.read(_isequal) != NOERR)
|
||||
const TString & name = str->get(i);
|
||||
if (name.starts_with("PROG"))
|
||||
{
|
||||
mat.zero();
|
||||
TTable mat(format("VE%1d", livello + 1));
|
||||
const int chars = atoi(name.after("PROG"));
|
||||
|
||||
mat.put("CODTAB", code);
|
||||
mat.write();
|
||||
}
|
||||
const int prog = mat.get_int("I0") + 1;
|
||||
mat.put("I0", prog);
|
||||
mat.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(row.doc());
|
||||
if (mat.read(_isequal) != NOERR)
|
||||
{
|
||||
mat.zero();
|
||||
mat.put("CODTAB", code);
|
||||
mat.write();
|
||||
}
|
||||
const int prog = mat.get_int("I0") + 1;
|
||||
mat.put("I0", prog);
|
||||
mat.rewrite();
|
||||
TString s; s << prog; s.lpad(chars, '0');
|
||||
code << s;
|
||||
}
|
||||
else
|
||||
if (name.starts_with("34."))
|
||||
if (name.starts_with("33."))
|
||||
{
|
||||
TFieldref fld(name.after("34."), LF_RIGHEDOC);
|
||||
TFieldref fld(name.after("33."), LF_DOC);
|
||||
|
||||
code << fld.read(row);
|
||||
code << fld.read(row.doc());
|
||||
}
|
||||
else
|
||||
if (name.starts_with("47."))
|
||||
if (name.starts_with("34."))
|
||||
{
|
||||
TFieldref fld(name.after("47."), LF_ANAMAG);
|
||||
|
||||
code << fld.read(anamag);
|
||||
TFieldref fld(name.after("34."), LF_RIGHEDOC);
|
||||
|
||||
code << fld.read(row);
|
||||
}
|
||||
else
|
||||
if (name.starts_with("47."))
|
||||
{
|
||||
TFieldref fld(name.after("47."), LF_ANAMAG);
|
||||
|
||||
code << fld.read(anamag);
|
||||
}
|
||||
}
|
||||
row.put(RDOC_LIVELLO, code);
|
||||
}
|
||||
row.put(RDOC_LIVELLO, code);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -138,10 +141,6 @@ void TGenerazione_ordine::post_process_output(TLista_documenti& doc_out)
|
||||
|
||||
if (level != 0)
|
||||
{
|
||||
const TString & p = row.get(RDOC_PREZZOV);
|
||||
|
||||
row.put(RDOC_PREZZO, p);
|
||||
|
||||
const real importo = row.importo(true, false);
|
||||
|
||||
total += importo;
|
||||
|
@ -174,7 +174,7 @@ Col(9) = FR_UMQTA
|
||||
Col(10) = FR_QTA
|
||||
Col(11) = FR_LORDO
|
||||
Col(12) = FR_PREZZO
|
||||
Col(13) = FR_JOLLY3|Prezzo di vendita|18
|
||||
Col(13) = FR_JOLLY3|Costo|18
|
||||
Col(14) = FR_SCONTO
|
||||
Col(15) = FR_JOLLY2|K|25
|
||||
Col(16) = FR_PERCPROV
|
||||
|
Loading…
x
Reference in New Issue
Block a user