diff --git a/cg/cg2101.cpp b/cg/cg2101.cpp index f0e7e31d7..7682ca1ed 100755 --- a/cg/cg2101.cpp +++ b/cg/cg2101.cpp @@ -193,12 +193,21 @@ bool TMovimentoPN::controlla_liquidazione(const TDate& data, TRegistro& registro int TMovimentoPN::registra(bool re, bool force) { + const TRectype& m = curr(); + long numreg = m.get_long(MOV_NUMREG); + + if (!re && numreg <= 0) // Tento di numerare automaticamente in caso di write + { + TLocalisamfile mov(LF_MOV); // Non sposto il file principale della relazione! + numreg = 1; + if (mov.last() == NOERR) + numreg += mov.get_long(MOV_NUMREG); + curr().put(MOV_NUMREG, numreg); + } + int err = re ? TRelation::rewrite(force) : TRelation::write(force); if (err != NOERR) return err; - - const TRectype& m = curr(); - const long numreg = m.get_long(MOV_NUMREG); _cg.renum_key(MOV_NUMREG, numreg); err = _cg.write(re); diff --git a/cg/cglib01.cpp b/cg/cglib01.cpp index 755916112..9e9ce583a 100755 --- a/cg/cglib01.cpp +++ b/cg/cglib01.cpp @@ -8,8 +8,10 @@ #include #include +#include #include #include +#include #include #include @@ -766,13 +768,14 @@ const TBill& TBill::add_to(TToken_string& ts, int from, int mode) } -const char* TBill::field_name(int n, bool contro) const +const char* TBill::field_name(int n, const TRectype& r, bool contro) const { CHECKD(n >= 0 && n <= 3, "Invalid bill field ", n); const char* f = NULL; if (contro) { + CHECKD(r.num() == LF_RMOV || r.num() == LF_PAGSCA, "Record non valido per contropartita: ", r.num()); switch(n) { case 0: f = RMV_GRUPPOC; break; @@ -787,8 +790,20 @@ const char* TBill::field_name(int n, bool contro) const { case 0: f = RMV_GRUPPO; break; case 1: f = RMV_CONTO; break; - case 2: f = RMV_SOTTOCONTO; break; - default:f = RMV_TIPOC; break; + case 2: + if (r.num() == LF_CLIFO) + f = CLI_CODCF; + else + f = RMV_SOTTOCONTO; + break; + default: + switch(r.num()) + { + case LF_CLIFO : f = CLI_TIPOCF; break; + case LF_RCAUSALI: f = RCA_TIPOCF; break; + default : f = RMV_TIPOC; break; + } + break; } } return f; @@ -796,21 +811,21 @@ const char* TBill::field_name(int n, bool contro) const void TBill::put(TRectype& r, bool c) const { - r.put(field_name(0, c), gruppo()); - r.put(field_name(1, c), conto()); - r.put(field_name(2, c), sottoconto()); - r.put(field_name(3, c), tipo()); + r.put(field_name(0, r, c), gruppo()); + r.put(field_name(1, r, c), conto()); + r.put(field_name(2, r, c), sottoconto()); + r.put(field_name(3, r, c), tipo()); } 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)); + if (r.type(field_name(3, r, c)) != _nullfld) + t = r.get_char(field_name(3, r, c)); - set(r.get_int(field_name(0, c)), - r.get_int(field_name(1, c)), - r.get_long(field_name(2, c)), + set(r.get_int(field_name(0, r, c)), + r.get_int(field_name(1, r, c)), + r.get_long(field_name(2, r, c)), t); set_description(NULL); diff --git a/cg/cglib01.h b/cg/cglib01.h index 935e0a12d..331ad50e7 100755 --- a/cg/cglib01.h +++ b/cg/cglib01.h @@ -178,7 +178,7 @@ class TBill : public TSortable protected: void set_description(const char* d); const TBill& copy(const TBill& b); - const char* field_name(int n, bool contro) const; + const char* field_name(int n, const TRectype& rec, bool contro) const; public: // TObject virtual int compare(const TSortable& s) const; diff --git a/cg/cgsaldac.cpp b/cg/cgsaldac.cpp index 0b973f511..08eabb975 100755 --- a/cg/cgsaldac.cpp +++ b/cg/cgsaldac.cpp @@ -593,8 +593,6 @@ TImporto TRiga_scadenze::esposto(bool valuta, const TDate & data_scad, const TDa return esposto; } - - bool TRiga_scadenze::modifica_pagamento(const TRectype& new_pag, const TValuta& valuta, char& old_ap, TImporto& old_abb, TImporto& old_diffcam, @@ -1038,12 +1036,10 @@ TImporto TRiga_partite::calcola_pagato_al(bool valuta,const TDate& al, const TDa const char sez = sezione(); const bool rischio = data_scaduto != data_rischio; const int lastr = rate(); - for (int r = lastr; r > 0; r--) { const TRiga_scadenze& scad = rata(r); const TImporto pag = scad.importo_pagato_al(valuta, al, mode); - pagato += pag; if (!pag.is_zero() && rischio) { @@ -1063,31 +1059,22 @@ char TPartita::_cli_align = ' '; char TPartita::_for_align = ' '; TPartita::TPartita(const TBill& clifo, int anno, const char* num) -: _part(LF_PARTITE, PART_NRIGA), _unassigned(LF_PAGSCA, "NRIGP"), - _align(' ') -{ - read(clifo, anno, num); -} + : _part(LF_PARTITE, PART_NRIGA), _unassigned(LF_PAGSCA, PAGSCA_NRIGP), _align(' ') +{ read(clifo, anno, num); } TPartita::TPartita(const TRectype& r) -: _part(LF_PARTITE, PART_NRIGA), _unassigned(LF_PAGSCA, "NRIGP"), - _align(' ') + : _part(LF_PARTITE, PART_NRIGA), _unassigned(LF_PAGSCA, PAGSCA_NRIGP), _align(' ') { TBill clifo; clifo.get(r); if (clifo.gruppo() == 0) - { - clifo.set(r.get_int(PART_GRUPPOCL), r.get_int(PART_CONTOCL), - clifo.sottoconto(), clifo.tipo()); - } - + clifo.set(r.get_int(PART_GRUPPOCL), r.get_int(PART_CONTOCL), clifo.sottoconto(), clifo.tipo()); const int anno = r.get_int(PART_ANNO); const TString8 num(r.get(PART_NUMPART)); read(clifo, anno, num); } TPartita::~TPartita() -{ -} +{ } const char* TPartita::build_key(TString& key) const { diff --git a/cg/cgtbbnp.uml b/cg/cgtbbnp.uml index 2acfe358c..2d18adacf 100755 --- a/cg/cgtbbnp.uml +++ b/cg/cgtbbnp.uml @@ -183,14 +183,14 @@ END NUMBER F_GRUPPO_INC 3 BEGIN - PROMPT 2 10 "Conto attivi " + PROMPT 2 10 "Conto attivi " FIELD I0 CHECKTYPE NORMAL END NUMBER F_CONTO_INC 3 BEGIN - PROMPT 21 10 "" + PROMPT 22 10 "" FIELD I1 CHECKTYPE NORMAL END @@ -229,14 +229,14 @@ END NUMBER F_GRUPPO_INCP 3 BEGIN - PROMPT 2 11 "Conto addebito " + PROMPT 2 10 "Conto addebito " FIELD I9 CHECKTYPE NORMAL END NUMBER F_CONTO_INCP 3 BEGIN - PROMPT 21 11 "" + PROMPT 22 11 "" FIELD I10 CHECKTYPE NORMAL END