From 798a82df2af3fa7fd332a35f7763681ec581cc0e Mon Sep 17 00:00:00 2001 From: alex Date: Wed, 20 May 2009 11:33:33 +0000 Subject: [PATCH] Patch level : 10.0 316 Files correlati : pe0.exe Ricompilazione Demo : [ ] Commento : Preventivazione (CRPA) git-svn-id: svn://10.65.10.50/trunk@18888 c028cbd2-c16b-5b4b-a496-9718f37d4682 --- pe/pe0400.cpp | 49 +++++++++++++++++++++++++++++++++++++++++-------- ve/velib06a.cpp | 2 +- 2 files changed, 42 insertions(+), 9 deletions(-) diff --git a/pe/pe0400.cpp b/pe/pe0400.cpp index 375cbcd5c..386136786 100755 --- a/pe/pe0400.cpp +++ b/pe/pe0400.cpp @@ -513,7 +513,8 @@ bool TGestione_preventivo_msk::pe_codart_handler(TMask_field& f, KEY k) } row_mask.set(FR_JOLLY3, costo); } - if (mask.get(F_USEK).full() || !row_mask.field(FR_PREZZO).enabled()) + const bool has_k = mask.get_bool(F_USEK); + if (has_k || !row_mask.field(FR_PREZZO).enabled()) row_mask.set(FR_PREZZO, ""); if (row_mask.field(FR_JOLLY3).enabled()) @@ -534,11 +535,14 @@ bool TGestione_preventivo_msk::pe_codart_handler(TMask_field& f, KEY k) TDocumento & doc = mask.doc(); const int rows = doc.physical_rows(); const bool has_k = mask.get_bool(F_USEK); + const int start_level = doc[sh->selected() + 1].get_int(RDOC_LEVEL); - for (int i = 1; i <= rows; i++) + for (int i = sh->selected() + 2; i <= rows; i++) { TRiga_documento & row = doc[i]; const int level = row.get_int(RDOC_LEVEL); + if (level <= start_level) + break; const bool prodfin = level == 0; const bool price_enabled = (i == doc.physical_rows()) || (level >= doc[i + 1].get_int(RDOC_LEVEL)); short id; @@ -546,16 +550,45 @@ bool TGestione_preventivo_msk::pe_codart_handler(TMask_field& f, KEY k) sh->enable_cell(i - 1, sh->cid2index(FR_PREZZO), 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); + + const TString& codart = row.get(RDOC_CODARTMAG); + const TArticolo_giacenza & art = cached_article(codart); + const bool has_k = mask.get_bool(F_USEK); + + if (has_k || ! price_enabled) + row.zero(RDOC_PREZZO); + + if (price_enabled && has_k) + { + const real ric = art.get(ANAMAG_PERCRIC); + TString80 k; + + if (ric != ZERO) + k = ric.string(); + + if (k.blank()) + { + const TString catmer = art.get(ANAMAG_GRMERC); + k = cache().get("GMC", catmer, "S2"); + if (k.blank()) + k = cache().get("GMC", catmer.left(3), "S2"); + } + if (k.full()) + row.put(RDOC_K, k); + } + if (price_enabled) + { + const real costo = art.get_real(mask._field_costo); + row.put(RDOC_COSTO, costo); + } + for (id = FR_CDC1; id < FR_CDC12; id++) sh->enable_cell(i - 1, id, prodfin); for (id = FR_DESCDC1; id < FR_DESCDC12; id++) sh->enable_cell(i - 1, id, prodfin); - if (row.get(RDOC_TREE).blank()) - { - row.put(RDOC_TREE, mask.build_tree_string(level)); - row.autoload(*sh); - mask.highlight_row(i -1, COLOR_INVALID, COLOR_INVALID, true, false); - } + row.put(RDOC_TREE, mask.build_tree_string(level)); + row.autoload(*sh); + mask.highlight_row(i -1, COLOR_INVALID, COLOR_INVALID, true, false); } sh->force_update(); } diff --git a/ve/velib06a.cpp b/ve/velib06a.cpp index 38adabf23..632a2454b 100755 --- a/ve/velib06a.cpp +++ b/ve/velib06a.cpp @@ -1780,7 +1780,7 @@ bool codart_handler(TMask_field& f, KEY key ) curr_row.autoload(sh); } sh.force_update(); - sh.select(row-1); + sh.select(current_doc_row-1); } } mask.update_giacenza();