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:
alex 2009-05-11 13:00:22 +00:00
parent 172f3fe9b8
commit 38280476f9
3 changed files with 119 additions and 70 deletions

View File

@ -21,6 +21,7 @@
#define F_ZOOM_ALL F_USERFLD+6 #define F_ZOOM_ALL F_USERFLD+6
#define F_SHRINK_ROW F_USERFLD+7 #define F_SHRINK_ROW F_USERFLD+7
#define F_ZOOM_ROW F_USERFLD+8 #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--) #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_espandi_riga_handler(TMask_field& f, KEY k);
static bool pe_copia_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_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_handler( short fieldid, int index);
virtual void user_set_row_handler(TMask& rm, short field, 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)); const bool price_enabled = (r + 1 == doc.physical_rows()) || (level >= doc[r + 2].get_int(RDOC_LEVEL));
short id; short id;
row_mask.enable(FR_PREZZO, price_enabled); sh.enable_cell(r, sh.cid2index(FR_PREZZO), price_enabled);
row_mask.enable(FR_JOLLY2, price_enabled); sh.enable_cell(r, sh.cid2index(FR_JOLLY2), price_enabled && mask.get_bool(F_USEK));
row_mask.enable(FR_JOLLY3, price_enabled); sh.enable_cell(r, sh.cid2index(FR_JOLLY3), price_enabled);
for (id = FR_CDC1; id < FR_CDC12; id++) 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++) 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; break;
case K_CTRL + K_INS: // Inserimento 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) if (next_level > level)
{ {
sh.disable_cell(father_sheet_row, sh.cid2index(FR_PREZZO)); 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)); sh.disable_cell(father_sheet_row, sh.cid2index(FR_JOLLY3));
father_row.zero(RDOC_PREZZO); father_row.zero(RDOC_PREZZO);
father_row.zero(RDOC_K); 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]; const TRiga_documento& riga = doc()[numriga + 1];
TEdit_field & tree = m->add_string(FR_JOLLY1, 0, "Albero ", 2, 20, 10, "D_"); 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 & 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_CODART, pe_codart_handler);
m->set_handler(FR_QTA, pe_qta_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); m->set_handler(FR_JOLLY2, pe_k_handler);
tree.set_field(RDOC_TREE); tree.set_field(RDOC_TREE);
k.set_field(RDOC_K); k.set_field(RDOC_K);
v.set_field(RDOC_PREZZOV); v.set_field(RDOC_COSTO);
} }
return m; return m;
@ -278,6 +281,7 @@ void TGestione_preventivo_msk::doc2mask(bool reload_clifo, bool force_load, bool
TSheet_field& s = sfield(F_SHEET); TSheet_field& s = sfield(F_SHEET);
const int righe = s.items(); const int righe = s.items();
const TDocumento & d = doc(); const TDocumento & d = doc();
const bool has_k = get_bool(F_USEK);
for (int i = 0; i < righe; i++) 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)); 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_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); s.enable_cell(i, s.cid2index(FR_JOLLY3), price_enabled);
for (short id = FR_CDC1; id < FR_CDC12; id++) for (short id = FR_CDC1; id < FR_CDC12; id++)
s.enable_cell(i, s.cid2index(id), prodfin); 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; 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 // // HANDLER DI RIGA //
/////////////////////// ///////////////////////
@ -457,13 +485,15 @@ bool TGestione_preventivo_msk::pe_codart_handler(TMask_field& f, KEY k)
const int r = sh->selected(); const int r = sh->selected();
TRiga_documento & row = doc[r + 1]; 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 TArticolo_giacenza & art = cached_article(codart);
const real costo = art.get_real(ANAMAG_ULTCOS1);
if (row_mask.field(FR_JOLLY2).enabled())
{
const real ric = art.get(ANAMAG_PERCRIC); const real ric = art.get(ANAMAG_PERCRIC);
TString80 k; TString80 k;
@ -480,13 +510,19 @@ bool TGestione_preventivo_msk::pe_codart_handler(TMask_field& f, KEY k)
if (k.full()) if (k.full())
row_mask.set(FR_JOLLY2, k); 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, ""); row_mask.set(FR_PREZZO, "");
else
if (row_mask.field(FR_JOLLY3).active()) if (row_mask.field(FR_JOLLY3).enabled())
{
if (row_mask.get(FR_PREZZO).blank())
mask.update_prezzo_vendita(row_mask); mask.update_prezzo_vendita(row_mask);
} }
else
row_mask.set(FR_JOLLY3, "");
}
if (k == K_F8) if (k == K_F8)
{ {
TSheet_field * sh = row_mask.get_sheet(); TSheet_field * sh = row_mask.get_sheet();
@ -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(); TGestione_preventivo_msk & mask = (TGestione_preventivo_msk &) sh->mask();
TDocumento & doc = mask.doc(); TDocumento & doc = mask.doc();
const int rows = doc.physical_rows(); const int rows = doc.physical_rows();
const bool has_k = mask.get_bool(F_USEK);
for (int i = 1; i <= rows; i++) 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; short id;
sh->enable_cell(i - 1, sh->cid2index(FR_PREZZO), price_enabled); 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); sh->enable_cell(i - 1, sh->cid2index(FR_JOLLY3), price_enabled);
for (id = FR_CDC1; id < FR_CDC12; id++) for (id = FR_CDC1; id < FR_CDC12; id++)
sh->enable_cell(i - 1, id, prodfin); sh->enable_cell(i - 1, id, prodfin);
@ -600,7 +637,9 @@ bool TGestione_preventivo_msk::pe_qta_handler(TMask_field& f, KEY k)
} }
void TGestione_preventivo_msk::update_prezzo_vendita(TMask & row_mask) void TGestione_preventivo_msk::update_prezzo_vendita(TMask & row_mask)
{ {
real prezzo = row_mask.get_real(FR_PREZZO); if (row_mask.get(FR_PREZZO).blank())
{
real costo = row_mask.get(FR_JOLLY3);
TString k(row_mask.get(FR_JOLLY2)); TString k(row_mask.get(FR_JOLLY2));
TString ge; TString ge;
real perc; real perc;
@ -610,11 +649,11 @@ void TGestione_preventivo_msk::update_prezzo_vendita(TMask & row_mask)
if (k.blank()) if (k.blank())
k = get(F_K); k = get(F_K);
if (scontoexpr2perc(k, false, ge, perc)) if (scontoexpr2perc(k, false, ge, perc))
prezzo *= (2 - perc); costo *= (2 - perc);
TCurrency_documento c(prezzo, doc(), true); TCurrency_documento prezzo(costo, doc(), true);
row_mask.set(FR_PREZZO, prezzo.get_num().string());
row_mask.set(FR_JOLLY3, c.get_num().string()); }
} }
bool TGestione_preventivo_msk::pe_k_handler(TMask_field& f, KEY k) 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(); TMask& row_mask = f.mask();
TSheet_field * sh = row_mask.get_sheet(); 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(); 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->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); 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); k.set_field(DOC_K);
m->add_number(F_LIVELLO, sh.page(), "Livello Successivo ", 33, y, 1); m->add_number(F_LIVELLO, sh.page(), "Livello Successivo ", 33, y, 1);

View File

@ -39,6 +39,8 @@ void TGenerazione_esecutivo::genera_matricola(TRiga_documento & row)
const TRectype & anamag = cache().get(LF_ANAMAG, codart); const TRectype & anamag = cache().get(LF_ANAMAG, codart);
const int items = str->items(); const int items = str->items();
if (anamag.get_bool(ANAMAG_ARTPROD))
{
for (int i = 0; i < items; i++) for (int i = 0; i < items; i++)
{ {
const TString & name = str->get(i); const TString & name = str->get(i);
@ -86,6 +88,7 @@ void TGenerazione_esecutivo::genera_matricola(TRiga_documento & row)
} }
} }
} }
}
} }
void TGenerazione_esecutivo::post_process_output(TLista_documenti& doc_out) void TGenerazione_esecutivo::post_process_output(TLista_documenti& doc_out)
@ -138,10 +141,6 @@ void TGenerazione_ordine::post_process_output(TLista_documenti& doc_out)
if (level != 0) if (level != 0)
{ {
const TString & p = row.get(RDOC_PREZZOV);
row.put(RDOC_PREZZO, p);
const real importo = row.importo(true, false); const real importo = row.importo(true, false);
total += importo; total += importo;

View File

@ -174,7 +174,7 @@ Col(9) = FR_UMQTA
Col(10) = FR_QTA Col(10) = FR_QTA
Col(11) = FR_LORDO Col(11) = FR_LORDO
Col(12) = FR_PREZZO Col(12) = FR_PREZZO
Col(13) = FR_JOLLY3|Prezzo di vendita|18 Col(13) = FR_JOLLY3|Costo|18
Col(14) = FR_SCONTO Col(14) = FR_SCONTO
Col(15) = FR_JOLLY2|K|25 Col(15) = FR_JOLLY2|K|25
Col(16) = FR_PERCPROV Col(16) = FR_PERCPROV