diff --git a/src/li/lilib01.cpp b/src/li/lilib01.cpp index 0d8da6cd1..ec629fed0 100644 --- a/src/li/lilib01.cpp +++ b/src/li/lilib01.cpp @@ -6,6 +6,13 @@ #define SOLUZIONE_UNICA 1 #define FINO_A_PLAFOND 2 +const TString make_key(const int anno, const int numplaf) +{ + static TString key; + key.cut(0).format("%04d|%06d", anno, numplaf); + return key; +} + void TLi_manager::elabTipiStati() { createTipiStati(tipi, stati); @@ -178,7 +185,7 @@ const TToken_string& TLi_manager::incrPlaf(TDocumento& d, real impNC, const bool lePlafs.add(thisPlaf, i); // Aggiungo a plafond - static TString key; key.cut(0) << thisPlaf.get(_planno) << "|" << thisPlaf.get(_plnumprot); + const TString key = make_key(thisPlaf.get_int(_planno), thisPlaf.get_int(_plnumprot)); if(plafondi.find(key) != plafondi.end()) { @@ -306,7 +313,7 @@ const TToken_string& TLi_manager::stornaDoc(const TDocumento& d, real impDC, con for(int i = 0; i < plafs.items() && impDC > ZERO; i++) { TToken_string thisPlafond = plafs.get(i); - static TString key; key.cut(0) << thisPlafond.get(_planno) << "|" << thisPlafond.get(_plnumprot); + const TString key = make_key(thisPlafond.get_int(_planno), thisPlafond.get_int(_plnumprot)); real thisImporto = thisPlafond.get(_plimporto); if(totale) { @@ -462,8 +469,7 @@ void TLi_manager::elabPlafond() iniDicInt = row.get_date("DAL"); // Aggiungo il plafond trovato all'elenco dei plafond - static TString key; - key.cut(0) << row.get("ANNO") << "|" << row.get("NUMPROT"); + const TString key = make_key(row.get_int("ANNO"), row.get_int("NUMPROT")); plafondi.insert(std::pair(key, row.get_real("IMPORTO"))); // Aggiungo il valore del plafond al totale @@ -515,7 +521,7 @@ const real TLi_manager::elabPlaRes(TToken_string t, TToken_string s, TDate ad) for(int j = 0; j < plaf.items(); j++) { TToken_string thePla(plaf.get(j)); - static TString key; key.cut(0) << thePla.get(_planno) << "|" << thePla.get(_plnumprot); + const TString key = make_key(thePla.get_int(_planno), thePla.get_int(_plnumprot)); static TString chiusura; chiusura.cut(0) << thePla.get(_plchiusura); // La get ritorna un const char* if(din[i].tipo().nota_credito()) { @@ -652,7 +658,7 @@ bool TLi_manager::checkUtilizzo(TDocumento& d, real impNC) for(int i = 0; i < lePlafs.items() && ok; i++) { TToken_string thisPlaf(lePlafs.get(i)); - static TString key; key.cut(0) << thisPlaf.get(_planno) << "|" << thisPlaf.get(_plnumprot); + const TString key = make_key(thisPlaf.get_int(_planno), thisPlaf.get_int(_plnumprot)); if(plafondi.find(key) != plafondi.end()) { ok = plafondi[key] > static_cast(lePlafs.get(_plimporto)); @@ -797,7 +803,7 @@ bool generaLiStorico(TDate dataIni) if(impLI >= utilizzato) { // Creo la chiave da scrivere e metto tutto dentro - TString key; key << rletint.get("ANNO") << "|" << rletint.get("NUMPROT") << "|" << utilizzato.string(); + const TString key = make_key(rletint.get_int("ANNO"), rletint.get_int("NUMPROT")); din[i].put("PLAFOND", key); din[i].rewrite(); } diff --git a/src/li/lilib01.h b/src/li/lilib01.h index 775b04e8f..e13fcb600 100644 --- a/src/li/lilib01.h +++ b/src/li/lilib01.h @@ -18,6 +18,7 @@ #endif #include +#include enum plafStruct { _planno, _plnumprot, _plimporto, _plchiusura, _plNC }; @@ -38,6 +39,7 @@ class TLi_manager : TObject const TString codivaDef; const TString codivaAlt; // Elenco di plafond con eventuale + // Chiave ANNO|NUMERO(6) std::map plafondi; std::map modifiche; // Progressivo, TToken_string(chiave,stato); void elabTipiStati(); // Preparo due token string con tipi[0] -> stati[0], ... diff --git a/src/ve/ve0100.cpp b/src/ve/ve0100.cpp index 5a78b8a00..1194abc54 100755 --- a/src/ve/ve0100.cpp +++ b/src/ve/ve0100.cpp @@ -1323,7 +1323,7 @@ int TMotore_application::checkPlafondWrite(TDocumento& d) real plaUtil = ZERO; - for (TRiepilogo_iva * totali = (TRiepilogo_iva *) tabIva.get(); totali != NULL; totali = (TRiepilogo_iva *) tabIva.get()) + for (TRiepilogo_iva * totali = static_cast(tabIva.get()); totali != NULL; totali = static_cast(tabIva.get())) { if(plafond.checkIva(totali->cod_iva().codice())) // Se l'iva del documento è diversa non mi interessa {