From 7dbfb5ffc93328ea5202e41291726d6af68bec7e Mon Sep 17 00:00:00 2001 From: guy Date: Mon, 6 May 2013 08:57:55 +0000 Subject: [PATCH] Corretto aggiornamento statistiche dei documenti git-svn-id: svn://10.65.10.50/branches/R_10_00@22856 c028cbd2-c16b-5b4b-a496-9718f37d4682 --- ve/velib.h | 6 +++--- ve/velib03.cpp | 54 ++++++++++++++++++++++++++++---------------------- 2 files changed, 33 insertions(+), 27 deletions(-) diff --git a/ve/velib.h b/ve/velib.h index 42d47ade2..62ea02340 100755 --- a/ve/velib.h +++ b/ve/velib.h @@ -1106,9 +1106,9 @@ public: TDoc_key(const int anno, const TString& codnum, const long ndoc, const char provv = 'D'); TDoc_key(const TRectype& rec); - TDoc_key(const char* key):TToken_string(key){} - TDoc_key(const TToken_string& key):TToken_string(key){} - TDoc_key(const TDoc_key& key):TToken_string(key){} + TDoc_key(const char* key) : TToken_string(key) {} + TDoc_key(const TToken_string& key) : TToken_string(key) {} + TDoc_key(const TDoc_key& key) : TToken_string(key) {} TDoc_key() {} }; diff --git a/ve/velib03.cpp b/ve/velib03.cpp index fb0c3241f..76892b1b0 100755 --- a/ve/velib03.cpp +++ b/ve/velib03.cpp @@ -248,8 +248,8 @@ void TDocumento::init() add_file(LF_RIGHEDOC, RDOC_NRIGA); set_memo_fld("G1"); - _tipocf = new TRecfield(*this, DOC_TIPOCF); - _codcf = new TRecfield(*this, DOC_CODCF); + _tipocf = new TRecfield(*this, DOC_TIPOCF); + _codcf = new TRecfield(*this, DOC_CODCF); _cod_occas = new TRecfield(*this, DOC_OCFPI); _sconto = _esenzione = NULL; @@ -310,10 +310,11 @@ const TString& TDocumento::codiva_bolli() const void TDocumento::check_modules() { if (_has_mag == 3) - { - _has_mag = dongle().active(MGAUT); - _has_stat_ven = dongle().active(SVAUT); - _has_provv = dongle().active(PRAUT); + { + const TDongle& din = dongle(); + _has_mag = din.active(MGAUT); + _has_stat_ven = din.active(SVAUT); + _has_provv = din.active(PRAUT); } } @@ -779,7 +780,7 @@ TRiga_documento& TDocumento::new_row(const char *tipo) int TDocumento::read(TBaseisamfile& f, word op, word lockop) { - int err = TMultiple_rectype::read(f, op ,lockop); + int err = TMultiple_rectype::read(f, op, lockop); _cli_for.zero(); _occas.zero(); @@ -789,26 +790,30 @@ int TDocumento::read(TBaseisamfile& f, word op, word lockop) set_riga_esenzione(); _stato_originale = stato(); - if (err == NOERR && tipo_valido() && tipo().statistiche() && _has_stat_ven) + if (err == NOERR && _has_stat_ven && tipo_valido() && tipo().statistiche() ) { - TString80 key(get(DOC_PROVV)); key << get(DOC_ANNO); key << get(DOC_CODNUM); key << get(DOC_NDOC); + const TDoc_key key(head()); TObject* o = _docs_to_agg.objptr(key); const bool is_nota_credito = tipo().nota_credito(); - if ( lockop >= _lock && o == NULL) + if (lockop >= _lock && o == NULL) { - TStats_agg * st_agg = new TStats_agg; + TStats_agg* st_agg = new TStats_agg; for (int i = physical_rows(); i > 0; i--) + { if (is_nota_credito) st_agg->add(row(i)); else st_agg->sub(row(i)); + } _docs_to_agg.add(key, st_agg, true); } else + { if (lockop == _unlock && o != NULL) _docs_to_agg.remove(key); + } } _old_agente.cut(0); @@ -1169,7 +1174,7 @@ int TDocumento::write_rewrite(TBaseisamfile & f, bool re) const myself.update_raee(); myself.set_row_ids(); - const bool check_movmag = dongle().active(MGAUT) && tipo().mov_mag(); + const bool check_movmag = _has_mag && tipo().mov_mag(); if (check_movmag) { const bool do_movmag = tipo().stato_with_mov_mag(stato_doc) && get(DOC_CAUSMAG).not_empty(); @@ -1503,10 +1508,10 @@ int TDocumento::write_rewrite(TBaseisamfile & f, bool re) const } if (_has_provv && tipo().provvigioni() && tipo().stato_provvigioni() <= stato()) myself.update_provvigioni(false); - if (tipo().statistiche() && _has_stat_ven) + if (_has_stat_ven && tipo().statistiche()) { - TString80 key(get(DOC_PROVV)); key << get(DOC_ANNO); key << get(DOC_CODNUM); key << get(DOC_NDOC); - TStats_agg * st_agg = (TStats_agg *) _docs_to_agg.objptr(key); + const TDoc_key key(myself.head()); + TStats_agg* st_agg = (TStats_agg*)_docs_to_agg.objptr(key); const bool is_nota_credito = tipo().nota_credito(); if (st_agg == NULL) @@ -1514,19 +1519,22 @@ int TDocumento::write_rewrite(TBaseisamfile & f, bool re) const st_agg = new TStats_agg; _docs_to_agg.add(key, st_agg, true); } - int i; - for (i = physical_rows(); i > 0; i--) + for (int i = physical_rows(); i > 0; i--) + { if (is_nota_credito) st_agg->sub(myself.row(i)); else st_agg->add(myself.row(i)); + } st_agg->update(); - for (i = physical_rows(); i > 0; i--) + for (int i = physical_rows(); i > 0; i--) + { if (is_nota_credito) st_agg->add(myself.row(i)); else st_agg->sub(myself.row(i)); + } } } return err; @@ -1536,7 +1544,7 @@ int TDocumento::remove(TBaseisamfile& f) const { if (!cancellabile() && !yesno_box("Documento non cancellabile,\nContinuare ugualmente")) return NOERR; - const bool check_movmag = dongle().active(MGAUT) && tipo().mov_mag(); + const bool check_movmag = _has_mag && tipo().mov_mag(); const bool doc_bloccato = bloccato(); if (check_movmag) @@ -1564,11 +1572,10 @@ int TDocumento::remove(TBaseisamfile& f) const } if (!doc_bloccato) { - if (tipo().statistiche() && _has_stat_ven) + if (_has_stat_ven && tipo().statistiche()) { - TString80 key(get(DOC_PROVV)); key << get(DOC_ANNO); key << get(DOC_CODNUM); key << get(DOC_NDOC); - TStats_agg * st_agg = (TStats_agg *) _docs_to_agg.objptr(key); - + const TDoc_key key(head()); + TStats_agg* st_agg = (TStats_agg*)_docs_to_agg.objptr(key); if (st_agg != NULL) { st_agg->update(); @@ -1578,7 +1585,6 @@ int TDocumento::remove(TBaseisamfile& f) const if (_has_provv && tipo().provvigioni()) { TDocumento& myself = *((TDocumento *)this); - myself.update_provvigioni(true); } }