diff --git a/cg/cg1500.cpp b/cg/cg1500.cpp index 7ecb4dfa3..0b4a28dbc 100755 --- a/cg/cg1500.cpp +++ b/cg/cg1500.cpp @@ -2212,6 +2212,8 @@ void TStampa_bilanci::riempi_record(char t,int g,int c,long s, void TStampa_bilanci::leggi_clifo(const TArray& gccf) { + TEsercizi_contabili ese; + TSaldo sld; TLocalisamfile saldi(LF_SALDI); // int g = 0, c=0; @@ -2261,7 +2263,6 @@ void TStampa_bilanci::leggi_clifo(const TArray& gccf) ragsoc << ' ' << nome; } - TEsercizi_contabili ese; int aprec = ese.pred(anno); saldi.zero(); saldi.put(SLD_ANNOES, anno); // W96SALDI del 05-06-96 @@ -3578,15 +3579,18 @@ TDate TStampa_bilanci::UltimaData(int g, int c, long s, int anno) // Non ho potuto usare quella di TConto!!! Chiedere a me! // Guy: E tu chi sei? const char* TStampa_bilanci::DescrizioneConto(int g, int c, long s, char tipocf) -{ - static TString80 ragsoc; +{ +/* + static TString80 ragsoc; const char* desc = NULL; TString80 key; key << g; if (c != 0) + { key << "|" << c ; - if (s != 0) - key << "|" << s; + if (s != 0) + key << "|" << s; + } const TRectype & pconti = cache().get(LF_PCON, key); if (!pconti.empty()) _tmp = pconti.get(PCN_DESCR); @@ -3597,11 +3601,11 @@ const char* TStampa_bilanci::DescrizioneConto(int g, int c, long s, char tipocf) if (!clifo.empty()) { - char tipoa = clifo.get_char("TIPOAPER"); + char tipoa = clifo.get_char(CLI_TIPOAPER); if (tipoa == 'F') //persona fisica { TString80 cognome, nome; - ragsoc = clifo.get("RAGSOC"); + ragsoc = clifo.get(CLI_RAGSOC); cognome = ragsoc.mid(0,30); nome = ragsoc.mid(30,20); cognome.trim(); nome.trim(); @@ -3610,7 +3614,7 @@ const char* TStampa_bilanci::DescrizioneConto(int g, int c, long s, char tipocf) desc = ragsoc; } else - desc = clifo.get("RAGSOC"); + desc = clifo.get(CLI_RAGSOC); _tmp = desc; } else @@ -3618,7 +3622,10 @@ const char* TStampa_bilanci::DescrizioneConto(int g, int c, long s, char tipocf) } return _tmp; - +*/ + const TBill bill(g, c, s, tipocf); + _tmp = bill.descrizione(); + return _tmp; } bool TStampa_bilanci::user_create() diff --git a/cg/cg2103.cpp b/cg/cg2103.cpp index d0683e519..6567a1ae7 100755 --- a/cg/cg2103.cpp +++ b/cg/cg2103.cpp @@ -84,11 +84,7 @@ const char* TCausale::desc_agg(int num) const if (rec != NULL) { const TString& cod = rec->get(RCA_CODDESC); - if (cod.not_empty()) - { - const TRectype& da = cache().get("%DPN", cod); - deag = da.get("S0"); - } + deag = cache().get("%DPN", cod, "S0"); } return deag; diff --git a/cg/cg3200.cpp b/cg/cg3200.cpp index d8b2fab9a..27691f8a9 100755 --- a/cg/cg3200.cpp +++ b/cg/cg3200.cpp @@ -1,10 +1,8 @@ #include "cg3.h" #include "cg3200.h" -#include "cglib01.h" #include "cglib02.h" #include "cglib03.h" -#include #include #include #include @@ -19,7 +17,6 @@ #include #include - class TMastrini_record : public TRectype { TBill _bill; @@ -2501,10 +2498,8 @@ void TMastrini_application::ricerca_dati_ditta() _ragsoc = nditte.get(NDT_RAGSOC); TString16 key; - key.format("%ld|1", app); - - const TRectype & unloc = cache().get(LF_UNLOC, key); + const TRectype& unloc = cache().get(LF_UNLOC, key); _indulc= unloc.get(ULC_INDULC); _civulc= unloc.get(ULC_CIVULC); diff --git a/cg/cglib01.cpp b/cg/cglib01.cpp index e6431bfbd..826100cae 100755 --- a/cg/cglib01.cpp +++ b/cg/cglib01.cpp @@ -330,21 +330,20 @@ const char* iva2name(TipoIVA iva) const TString& cap2comune(const TString& cap, const TString& denom) { - if (cap.len() == 5 && denom.full()) + TString80 up_denom = denom; + up_denom.upper(); + TString4 codone; + + if (cap.len() == 5 && up_denom.full()) { TString8 cappone = cap; if (cappone[2] == '1') //e' un capoluogo di provincia cappone.overwrite("00", 3, 2); - TString80 up_denom = denom; - up_denom.upper(); - TRelation relcom(LF_COMUNI); TRectype& comrec = relcom.curr(); comrec.put(COM_CAPCOM, cappone); - TString4 codone; - TCursor comuni (&relcom, "", 3, &comrec, &comrec); const TRecnotype items = comuni.items(); comuni.freeze(); @@ -360,20 +359,37 @@ const TString& cap2comune(const TString& cap, const TString& denom) cmp = fc; } } - - if (codone.full()) - return get_tmp_string() = codone; - } else - if (cap.blank() && denom.full()) + } + if (codone.blank() && denom.full()) { TLocalisamfile comuni(LF_COMUNI); comuni.setkey(2); comuni.put(COM_DENCOM, denom); if (comuni.read() == NOERR) - return comuni.get(COM_COM); + codone = comuni.get(COM_COM); + else + { + double cmp = 0.9; + comuni.zero(); + const TString4 pref = up_denom.left(4); + comuni.put(COM_DENCOM, pref); + for (int err = comuni.read(_isgteq); err == NOERR; err = comuni.next()) + { + TString80 denominazione = comuni.get(COM_DENCOM); + denominazione.upper(); + if (!denominazione.starts_with(pref)) + break; + const double fc = xvt_str_fuzzy_compare (up_denom, denominazione); + if (fc > cmp) + { + cmp = fc; + codone = comuni.get(COM_COM); + } + } + } } - return EMPTY_STRING; + return codone.full() ? (get_tmp_string() = codone) : EMPTY_STRING; } ///////////////////////////////////////////////////////////