diff --git a/ca/ca3800.cpp b/ca/ca3800.cpp index 13ed08d56..8d71b004f 100755 --- a/ca/ca3800.cpp +++ b/ca/ca3800.cpp @@ -3,11 +3,15 @@ #include #include +#include "../cg/cglib01.h" + #include "ca3.h" #include "ca3800.h" #include "calib01.h" #include "calib02.h" #include "commesse.h" +#include "panapdc.h" +#include "saldana.h" //////////////////////////////////////////////////////// // MASCHERA @@ -90,6 +94,71 @@ TPrint_bilancio_cms_mask::TPrint_bilancio_cms_mask() { } +/////////////////////////////////////////////////////////////// +// CACHE INDICATORI BILANCIO +/////////////////////////////////////////////////////////////// +class TIndbil_cache : public TCache +{ + bool _usepdcc; + +protected: + virtual TObject* key2obj(const char* key); + +public: + int get_indbil(const TString& conto); + TIndbil_cache(); + +}; + +TObject* TIndbil_cache::key2obj(const char* key) +{ + TString80 conto = key; + if (_usepdcc) + { + TLocalisamfile panapdc(LF_PANAPDC); + panapdc.setkey(2); + const int gr = atoi(conto.left(3)); + const int co = atoi(conto.mid(3,3)); + const long so = atol(conto.mid(6,6)); + + TRectype& panapdrec = panapdc.curr(); + for (int i = 2; i >= 0; i--) + { + panapdrec.zero(); + panapdrec.put(PANAPDC_GRUPPO, gr); + if (i > 0) + panapdrec.put(PANAPDC_CONTO, co); + if (i == 2) + panapdrec.put(PANAPDC_SOTTOCONTO, so); + if (panapdc.read() == NOERR) + { + conto = panapdrec.get(PANAPDC_CODCONTO); + break; + } + } + //se non trova il corrispondente conto analitico azzera il conto per il prossimo giro + if (i < 0) + conto.cut(0); + } + //conto analitico + TAnal_bill bill(conto); + int indbil = bill.indicatore_bilancio(); + TString* ib = new TString4; + *ib << indbil; + return ib; +} + +int TIndbil_cache::get_indbil(const TString& conto) +{ + TString* ib = (TString*)objptr(conto); + return ib ? atoi(*ib) : 0; +} + +TIndbil_cache::TIndbil_cache() +{ + TConfig& cfg = ca_config(); + _usepdcc = cfg.get_bool("UsePdcc"); +} /////////////////////////////////////////////////////////////// // RECORDSET @@ -99,9 +168,12 @@ class TPrint_bilancio_cms_recordset : public TRecordset TString_array _righe; TRecnotype _curr; TArray _colonne; + TIndbil_cache _indicatori; private: int _anno; + bool _vitaintera, _use_fasi; + char _tipostima; protected: virtual TRecnotype items() const { return _righe.items(); } @@ -128,33 +200,69 @@ bool TPrint_bilancio_cms_recordset::move_to(TRecnotype pos) void TPrint_bilancio_cms_recordset::requery() { //prende le date di inizio e fine dell'eserizio selezionato sulla maschera - TString4 anno; - anno << _anno; - const TRectype& esc = cache().get("ESC", anno); - const TDate datainiesc = esc.get("D0"); - const TDate datafinesc = esc.get("D1"); + TEsercizi_contabili esc; + TDate datainiesc, datafinesc; + esc.code2range(_anno, datainiesc, datafinesc); //deve procedere al confronto tra le date inizio-fine esercizio e quelle inizio-fine commessa.. //..per spostare il record in esame nell'array corretto - TString_array cms[4]; - TISAM_recordset commesse("USE COMMESSE"); - for (bool ok = commesse.move_first(); ok; ok = commesse.move_next()) + TAssoc_array cms[4]; + + TString query; + query = "USE SALDANA"; + //stampa standard non a vita intera + if (!_vitaintera) + query << "\nTO ANNO=" << _anno; + + TISAM_recordset saldana(""); + for (bool ok = saldana.move_first(); ok; ok = saldana.move_next()) { - const TDate dataini = commesse.get(COMMESSE_DATAINIZIO).as_date(); - const TDate datafine = commesse.get(COMMESSE_DATAFINE).as_date(); - //e' inutile considerare le commesse terminate prima dell'esercizio selezionato.. - //..cioe' nel passato oppure che iniziano nel futuro! - if (datafine >= datainiesc && dataini <= datafinesc) + const TString& conto = saldana.get(SALDANA_CONTO).as_string(); + //trova l'indicatore di bilancio + const int indbil = _indicatori.get_indbil(conto); + + if (indbil == 3 || indbil == 4) { - int indice = datafine <= datafinesc ? 0 : 2; - if (dataini >= datainiesc) - indice++; - TToken_string riga_array; - riga_array << indice; - riga_array.add(commesse.get(COMMESSE_CODCMS).as_string()); - riga_array.add(commesse.get(COMMESSE_DESCRIZ).as_string()); - cms[indice].add(riga_array); - } + const TString& codcms = saldana.get(SALDANA_COMMESSA).as_string(); + const TString& fase = saldana.get(SALDANA_FASE).as_string(); + + const TRectype& rec_commesse = cache().get(LF_COMMESSE, codcms); + + const TDate dataini = rec_commesse.get(COMMESSE_DATAINIZIO); + const TDate datafine = rec_commesse.get(COMMESSE_DATAFINE); + //e' inutile considerare le commesse terminate prima dell'esercizio selezionato.. + //..cioe' nel passato oppure che iniziano nel futuro! + if (datafine >= datainiesc && dataini <= datafinesc) + { + int indice = datafine <= datafinesc ? 0 : 2; + if (dataini >= datainiesc) + indice++; + + TString80 chiave = codcms; + if (_use_fasi) + chiave << '|' << fase; + + //cerca se la commessa (e l'eventuale fase) esistono gia' nell'assocarray delle commesse + TAssoc_array* riga_array = (TAssoc_array*)cms[indice].objptr(chiave); + //se non esiste la crea! + if (riga_array == NULL) + { + riga_array = new TAssoc_array; + cms[indice].add(chiave, riga_array); + + TString4 str_indice; //l'indice va stringato per l'assoc_array + str_indice << indice; + + riga_array->add("INDICE", str_indice); + riga_array->add("CODCMS", codcms); + riga_array->add("FASE", fase); + riga_array->add("DESCRIZ", rec_commesse.get(COMMESSE_DESCRIZ)); + } + } //if (datafine >= datainiesc &&... + + + } //if (indbil == 3 ||... + } //merging dei 4 arrayini cms nell'arrayone _righe da mandare in stampa _righe.destroy(); @@ -163,7 +271,7 @@ void TPrint_bilancio_cms_recordset::requery() const int tot = cms[i].items(); for (int j = 0; j < tot; j++) { - _righe.TArray::add(cms[i].remove(j)); +// _righe.TArray::add(cms[i].remove(j)); } } } @@ -208,6 +316,7 @@ const TVariant& TPrint_bilancio_cms_recordset::get(const char* column_name) cons void TPrint_bilancio_cms_recordset::set_filter(const TPrint_bilancio_cms_mask& msk) { _anno = msk.get_int(F_ESERCIZIO); + _tipostima = msk.get_bool(F_TIPOSTIMA); } //////////////////////////////////////////////////////// diff --git a/ca/ca3800.h b/ca/ca3800.h index f079bdd73..4ef27f320 100755 --- a/ca/ca3800.h +++ b/ca/ca3800.h @@ -8,7 +8,9 @@ #define F_REPORT 105 #define F_INIZIO_ES 106 #define F_FINE_ES 107 -#define F_TIPOSTAMPA 108 +#define F_TIPOSTIMA 108 +#define F_VITAINTERA 109 +#define F_FASI 110 #endif // __CA3800_H diff --git a/ca/ca3800.uml b/ca/ca3800.uml index fb03ed67f..474c6705d 100755 --- a/ca/ca3800.uml +++ b/ca/ca3800.uml @@ -72,12 +72,22 @@ BEGIN FLAGS "A" END -RADIOBUTTON F_TIPOSTAMPA 22 +BOOLEAN F_FASI BEGIN - PROMPT 2 7 "Tipo di stima" + PROMPT 2 7 "Esplodi Fasi" +END + +RADIOBUTTON F_TIPOSTIMA 22 +BEGIN + PROMPT 2 9 "Tipo di stima" FLAGS "Z" - ITEM "X|Tempo" - ITEM " |Costi" + ITEM "T|Tempo" + ITEM "C|Costi" +END + +BOOLEAN F_VITAINTERA +BEGIN + PROMPT 2 11 "Includi esercizi successivi (vita intera)" END STRING F_REPORT 256 64 diff --git a/ca/ca3800a.rep b/ca/ca3800a.rep index 164837a15..a6e815c5c 100755 --- a/ca/ca3800a.rep +++ b/ca/ca3800a.rep @@ -132,5 +132,5 @@