From 02502cfdf56ffbbe4c46674ff65a8f35f98dcc95 Mon Sep 17 00:00:00 2001 From: Mattia Tollari Date: Tue, 11 Dec 2018 14:21:01 +0100 Subject: [PATCH] Patch level : 12.0 656 Files correlati : fp, agalib Commento : - Corretta gestione prezzo in valuta straniera - Aggiunta scrittura errori in fp_err.log - Sistemata scrittura sede - Aggiunta funzione stringa_eng in real uguale a stringa ma che non fa eng2ita --- src/fp/fplib01.cpp | 40 ++++++++++++++++++++++++++++------------ src/fp/fplib01.h | 8 +++++++- src/include/real.cpp | 7 +++++++ src/include/real.h | 3 +++ 4 files changed, 45 insertions(+), 13 deletions(-) diff --git a/src/fp/fplib01.cpp b/src/fp/fplib01.cpp index 9a2390c0e..789d05695 100644 --- a/src/fp/fplib01.cpp +++ b/src/fp/fplib01.cpp @@ -734,6 +734,8 @@ void TDoc_fp::log(int severity, const char* msg) if (_log == nullptr) { _log = new TLog_report; + // Tento l'eliminazione del file + std::remove("fp_err.log"); } if (severity < 0) { @@ -741,14 +743,23 @@ void TDoc_fp::log(int severity, const char* msg) } else { + static TString txt; + txt.cut(0); if (_logpaf.full()) { - TString txt; txt << _logpaf << ": " << msg; - _log->log(severity, txt); } else - _log->log(severity, msg); + txt << msg; + + _log->log(severity, txt); + + // Scrivo anche su file + std::filebuf fb; + fb.open("fp_err.log", std::ios::out|std::ios::app); + std::ostream os(&fb); + os << txt << std::endl; + fb.close(); } } @@ -840,11 +851,11 @@ const TString& TDoc_fp::converti_prezzo(const real& prezzo) const TString& ret = get_tmp_string(); ret.cut(0); - if (_is_valuta_estera) + if (_doc_cambio._is_valuta_estera) { - TCurrency ret(prezzo); - ret.change_to_euro_val(); - return ret.string(true); + TCurrency app(prezzo, _doc_cambio._cod_val, _doc_cambio._cambio, true); + app.change_to_euro_val(); + ret << app.get_num().stringa_eng(0,8); } else ret << prezzo; @@ -893,7 +904,10 @@ bool TDoc_fp::doc_to_paf(TDocumentoEsteso& doc) const char* const paese = "IT"; TCausale caus = TCausale(doc.tipo().causale(), doc.anno()); - _is_valuta_estera = !is_euro_value(doc.valuta()); + // Valorizzo la gestione del cambio + _doc_cambio._cod_val = doc.valuta(); + _doc_cambio._is_valuta_estera = !is_euro_value(doc.valuta()); + _doc_cambio._cambio = doc.cambio(); // TPaf_record paf0100f("PAF0100F"); @@ -1031,15 +1045,17 @@ bool TDoc_fp::doc_to_paf(TDocumentoEsteso& doc) // DatiSede - if (cliente.italiano()) - { + paf0400f.set("P4_SEDEIND", cliente.via_residenza()); paf0400f.set("P4_SEDENRCIVICO", cliente.civico_residenza()); paf0400f.set("P4_SEDECAP", cliente.CAP_residenza()); paf0400f.set("P4_SEDECOMUNE", cliente.comune_residenza()); - paf0400f.set("P4_SEDEPROV", cliente.provincia_residenza()); paf0400f.set("P4_SEDENAZ", cliente.stato_residenza_ISO()); - } + if (cliente.italiano()) + { + paf0400f.set("P4_SEDECAP", "00000"); + paf0400f.set("P4_SEDEPROV", cliente.provincia_residenza()); + } paf0400f.set("P4_GESTIONE", "D"); ok &= insert(paf0400f); diff --git a/src/fp/fplib01.h b/src/fp/fplib01.h index 124d32dec..754c0f39d 100644 --- a/src/fp/fplib01.h +++ b/src/fp/fplib01.h @@ -92,7 +92,13 @@ private: vector _query; TString8 _hfatt; // Codice univoco di 6 caratteri dell'ufficio P.A. o di 7 caratteri per un privato TString20 _bfatt; // Codice univoco di 20 caratteri del documento - bool _is_valuta_estera; // Se il documento è in valuta estera + struct + { + bool _is_valuta_estera; // Se il documento è in valuta estera + TString4 _cod_val; + real _cambio; + } _doc_cambio; + int parse_line(const TString& line, TString& var, TString& val) const; bool create_table(TScanner& paf, const TString& table); diff --git a/src/include/real.cpp b/src/include/real.cpp index 3adc26289..f56634ab8 100755 --- a/src/include/real.cpp +++ b/src/include/real.cpp @@ -1285,6 +1285,13 @@ const char* real::stringa (int len, int dec, char pad) const return str; } +// Certified 99% +const char* real::stringa_eng(int len, int dec, char pad) const +{ + char* str = const_cast(string(len, dec, pad)); + return str; +} + // Certified 99% const char* real::stringe(int len, int dec, char pad) const { diff --git a/src/include/real.h b/src/include/real.h index b0ee3dbb8..af17758c3 100755 --- a/src/include/real.h +++ b/src/include/real.h @@ -115,6 +115,9 @@ public: // @cmember Trasforma un reale in stringa (chiama ), ma // ritorna il formato italiano const char* stringa(int len = 0, int dec = UNDEFINED, char pad = ' ') const; + // @cmember Trasforma un reale in stringa (chiama ), ma + // ritorna il formato inglese + const char* stringa_eng(int len = 0, int dec = UNDEFINED, char pad = ' ') const; // @cmember Trasforma un reale in stringa (chiama ), //ma ritorna il formato atteso da Excel const char* stringe(int len = 0, int dec = UNDEFINED, char pad = ' ') const;