diff --git a/cg/cglib01.cpp b/cg/cglib01.cpp index 27cdf2d31..7fd4aff08 100755 --- a/cg/cglib01.cpp +++ b/cg/cglib01.cpp @@ -647,7 +647,7 @@ const char* TBill::field_name(int n, bool contro) const { CHECKD(n >= 0 && n <= 3, "Invalid bill field ", n); - const char* f; + const char* f = NULL; if (contro) { switch(n) @@ -681,10 +681,14 @@ void TBill::put(TRectype& r, bool c) const bool TBill::get(const TRectype& r, bool c) { + char t = ' '; + if (r.type(field_name(3, c)) != _nullfld) + t = r.get_char(field_name(3, c)); + set(r.get_int(field_name(0, c)), r.get_int(field_name(1, c)), r.get_long(field_name(2, c)), - r.get_char(field_name(3, c))); + t); set_description(NULL); _tipo_cr = -1; @@ -814,7 +818,7 @@ bool TBill::read(TRectype &r) if (tipo() <= ' ' || sottoconto() <= 0) { - TString16 key; key.format("%d|%d|%ld", gruppo(), conto(), sottoconto()); + const char* key = string(); const TRectype& pcon = cache().get(LF_PCON, key); if (!pcon.empty()) { @@ -879,7 +883,7 @@ int TBill::tipo_cr() const int TBill::indicatore_bilancio() const { - TString16 str; + TString8 str; str.format("%d|%d", gruppo(), conto()); const int ib = atoi(cache().get(LF_PCON, str, PCN_INDBIL)); if (ib == 0) @@ -904,6 +908,17 @@ const char* TBill::string(int mode) const { TString& s = get_tmp_string(); + if (mode & 0x8) + { + if (_sottoconto != 0) + s.format("%03d%03d%06ld", _gruppo, _conto, _sottoconto); else + if (_conto != 0) + s.format("%03d%03d", _gruppo, _conto); else + if (_gruppo != 0) + s.format("%03d", _gruppo); + return s; + } + if (mode & 0x4) { const int cr = tipo_cr(); @@ -932,7 +947,6 @@ const char* TBill::string(int mode) const bool TBill::required_cdc() const { TString16 key; - for (int i = 2; i >= 0; i--) { key.format("%d|%d|%ld", gruppo(), i > 0 ? conto() : 0, i > 1 ? sottoconto() : 0); diff --git a/cg/cglib01.h b/cg/cglib01.h index df5992f01..6301573c9 100755 --- a/cg/cglib01.h +++ b/cg/cglib01.h @@ -229,8 +229,8 @@ public: bool sospeso() const; char sezione() const; - void put(TRectype& r, bool contro = FALSE) const; - bool get(const TRectype& r, bool contro = FALSE); + void put(TRectype& r, bool contro = false) const; + bool get(const TRectype& r, bool contro = false); void set(TMask& m, short g, short c, short s, short t = 0, short d = 0) const; void get(const TMask& m, short g, short c, short s, short t = 0, short d = 0);