diff --git a/src/include/utility.cpp b/src/include/utility.cpp index 283ff91eb..b9e086b8a 100755 --- a/src/include/utility.cpp +++ b/src/include/utility.cpp @@ -197,17 +197,17 @@ long fsize(const char* name) return (name && *name) ? xvt_fsys_file_attr(name, XVT_FILE_ATTR_SIZE) : 0L; } -time_t atime(const char* file) +const time_t atime(const char* file) { return xvt_fsys_file_attr(file, XVT_FILE_ATTR_ATIME); } -time_t ctime(const char* file) +const time_t ctime(const char* file) { return xvt_fsys_file_attr(file, XVT_FILE_ATTR_CTIME); } -time_t mtime(const char* file) +const time_t mtime(const char* file) { return xvt_fsys_file_attr(file, XVT_FILE_ATTR_MTIME); } diff --git a/src/include/utility.h b/src/include/utility.h index 0a954d762..90a49c781 100755 --- a/src/include/utility.h +++ b/src/include/utility.h @@ -61,9 +61,9 @@ long fsize(const char* file); bool dexist(const char* file); void log_message(const char* fmt, ...); -time_t atime(const char* file); // access time -time_t ctime(const char* file); // creation time -time_t mtime(const char* file); // modification time +const time_t atime(const char* file); // access time +const time_t ctime(const char* file); // creation time +const time_t mtime(const char* file); // modification time struct tm * altime(const char* file); // access local time struct tm * cltime(const char* file); // creation local time struct tm * mltime(const char* file); // creation local time diff --git a/src/mg/mglib.h b/src/mg/mglib.h index bda4c2a22..ac12488e2 100755 --- a/src/mg/mglib.h +++ b/src/mg/mglib.h @@ -48,7 +48,9 @@ #include "../mg/rmovmag.h" #endif -#include +#ifndef __REPUTILS_H +#include +#endif // campi comuni alla maschere di magazzino typedef enum @@ -346,7 +348,7 @@ public: const TString & get_scat(int i) {return _sc.objptr(i) != NULL ? (const TString &)_sc[i] : EMPTY_STRING;} const real get_peso(int i) {return _peso.objptr(i) != NULL ? (const real &)_peso[i] : ZERO;} - TArticolo_conai(const TString& codart); + TArticolo_conai(const TString& codart, TLog_report * log = nullptr); }; // ******************************* diff --git a/src/mg/mglib02.cpp b/src/mg/mglib02.cpp index 820f387ee..4ccfee57a 100755 --- a/src/mg/mglib02.cpp +++ b/src/mg/mglib02.cpp @@ -11,6 +11,7 @@ #include "mglib.h" #include "../cg/cglib.h" #include "../ve/veconf.h" +#include "../ve/velib.h" #include "anamag.h" #include "mag.h" @@ -1868,8 +1869,9 @@ const char* conai2anamagfld(const TString& conai_cat) return "ERROR"; } +static const char* __conai_default_values[CONAI_CLASSES] = { "AC99", "AL99", "CA40", "LE99", "PL12", "VE99" }; // Conai nell'articolo -TArticolo_conai::TArticolo_conai(const TString& codart) +TArticolo_conai::TArticolo_conai(const TString& codart, TLog_report * log) : _codart(codart) { /* Devo caricarmi tutti i codici conai presenti nell'articolo @@ -1880,6 +1882,7 @@ TArticolo_conai::TArticolo_conai(const TString& codart) TLocalisamfile conart(LF_CONART); conart.put(CONART_CODART, _codart); int err = conart.read(_isgteq); + while (err == NOERR && _codart == conart.get(CONART_CODART)) { const int i = conart.get_int(CONART_NRIGA) - 1; @@ -1896,6 +1899,7 @@ TArticolo_conai::TArticolo_conai(const TString& codart) * La risposta è semplice, tutti i programmi che non verranno aggiornati da queste modifiche (es. Importazione Pack/SKNT) * scrivono li e quindi va tenuta la compatibilità */ + if (_sc.empty()) { TLocalisamfile anamag(LF_ANAMAG); @@ -1909,7 +1913,7 @@ TArticolo_conai::TArticolo_conai(const TString& codart) for (int i = 0; i < 6; i++) { const TString& con = conaisc.mid(i * 4, 4); - + if (con.full()) { const TString& categoria = con.left(2); @@ -1919,7 +1923,12 @@ TArticolo_conai::TArticolo_conai(const TString& codart) if (fldname != "ERROR") { _sc.add(con); - _peso.add(ranamag.get_real(fldname)); + + const real peso = ranamag.get_real(fldname); + + _peso.add(peso); + if ((log != nullptr) && (peso==ZERO)) + log->log(0, format("articolo :%s - peso unitario a zero", (const char *)_codart)); } #ifdef DBG else @@ -1930,6 +1939,25 @@ TArticolo_conai::TArticolo_conai(const TString& codart) } #endif } + else + { + TString categoria = __conai_default_values[i]; + const TString& sottocat = categoria.right(2); + categoria = categoria.left(2); + const TString fldname = conai2anamagfld(categoria); + const real peso = ranamag.get_real(fldname); + if (peso != ZERO) + { + _sc.add((TString)__conai_default_values[i]); + + const real peso = ranamag.get_real(fldname); + + _peso.add(peso); + if (log != nullptr) + log->log(0, format("articolo :%s - peso unitario: kg %s senza categoria, impostato a: %s%s", (const char *)_codart, + (const char *)peso.stringa(), (const char *)categoria, (const char *)sottocat)); + } + } } } }