diff --git a/ca/ca0400.cpp b/ca/ca0400.cpp index d93575c2d..84288a593 100755 --- a/ca/ca0400.cpp +++ b/ca/ca0400.cpp @@ -39,30 +39,32 @@ bool TPiano_conti_anal_msk::on_field_event(TOperable_field& o, TField_event e, l key << str.get(0) << "|"; key << str.get(); - _ind_bilancio = atoi(cache().get(LF_PCON, key, PCN_INDBIL)); + // _ind_bilancio = atoi(cache().get(LF_PCON, key, PCN_INDBIL)); } } else if (e == se_leave) { - TSheet_field & s = (TSheet_field &) o; - TToken_string str = s.row(s.selected()); - TString key; - - key << str.get(0) << "|"; - key << str.get(); - - const TRectype & pcon = cache().get(LF_PCON, key); - if (!pcon.empty()) + const int master_indbil = get_int(F_INDBIL); + if (master_indbil > 0) { - const int ind_bilancio = pcon.get_int(PCN_INDBIL); - if (_ind_bilancio == 0) - _ind_bilancio = ind_bilancio; - if (_ind_bilancio != ind_bilancio) - return error_box("Indicatore di bilancio errato %d", ind_bilancio); - else - return true; + TSheet_field & s = (TSheet_field &) o; + TToken_string str = s.row(s.selected()); + TString key; + + key << str.get(0) << "|"; + key << str.get(); + + const TRectype & pcon = cache().get(LF_PCON, key); + if (!pcon.empty()) + { + const int ind_bilancio = pcon.get_int(PCN_INDBIL); + + if (master_indbil != ind_bilancio) + return error_box("Indicatore di bilancio errato %d", ind_bilancio); + } } + return true; } break; default: @@ -93,6 +95,7 @@ class TAnalisi_app : public TAnal_app { TAnalisi_rec * _rows; int _maxlev; + bool _riclassificato; protected: virtual TSimple_anal_msk* create_mask() const { return new TPiano_conti_anal_msk; } @@ -240,11 +243,11 @@ void TAnalisi_app::init_indbil(TMask& mask) if (mask.field(F_KEY1+level).shown()) break; } - enabled = level < _maxlev; // Le foglie sono sempre disabilitate + enabled = level < _maxlev || _riclassificato; // Le foglie sono sempre disabilitate if (level > 0) // Devo controllare i nodi padre { TString code; // Codice del piano dei conti - for (int i = 0; i <= level; i++) + for (int i = 0; i < level; i++) { code << mask.get(F_KEY1+i); // Allungo il codice const TRectype& rec = cache().get(LF_PCONANA, code); @@ -289,10 +292,13 @@ bool TAnalisi_app::create() { TConfig& cfg = ca_config(); const TString& pdc = cfg.get("Pdci", NULL, 1); + const bool use_pdcc = cfg.get_bool("UsePdcc"); + + _riclassificato = pdc.full() && use_pdcc; + if (pdc.blank()) { - const bool use_cg0 = cfg.get_bool("UsePdcc"); - if (use_cg0) + if (use_pdcc) { TExternal_app app("cg0 -0"); app.run(true);