diff --git a/cg/cg2100.cpp b/cg/cg2100.cpp index bb459d7e0..8d609e2f8 100755 --- a/cg/cg2100.cpp +++ b/cg/cg2100.cpp @@ -546,7 +546,7 @@ void TPrimanota_application::init_modify_mode(TMask& m) init_mask(m); partite().destroy(); - if (is_pagamento()) + if (is_saldaconto()) { const long numreg = m.get_long(F_NUMREG); partite().add_numreg(numreg); @@ -914,7 +914,7 @@ int TPrimanota_application::rewrite(const TMask& m) if (salvaconto) { - partite().update_reg(_rel->lfile().curr()); + partite().update_reg(_rel->curr()); partite().rewrite(); } } diff --git a/cg/cg2102.cpp b/cg/cg2102.cpp index 207134d09..d89aa5dca 100755 --- a/cg/cg2102.cpp +++ b/cg/cg2102.cpp @@ -467,16 +467,21 @@ real TPrimanota_application::calcola_saldo() const for (int i = 0; i < max; i++) { TToken_string& r = rows.row(i); - tdare += real(r.get(0)); - tavere += real(r.get()); + const real dare(r.get(0)); + const real avere(r.get()); + + tdare += dare; + tavere += avere; if (pag) { - const char sez = tdare.is_zero() ? 'A' : 'D'; - const TImporto importo(sez, sez == 'A' ? tavere : tdare); const char tipo = row_type(r); if (strchr("ACGKP", tipo) != NULL) + { + const char sez = dare.is_zero() ? 'A' : 'D'; + const TImporto importo(sez, sez == 'A' ? avere : dare); saldaconto += importo; + } } } diff --git a/cg/cg2104.cpp b/cg/cg2104.cpp index 073b93bb4..4a17a5fa8 100755 --- a/cg/cg2104.cpp +++ b/cg/cg2104.cpp @@ -400,8 +400,8 @@ bool TPrimanota_application::read_scadenze(TMask& m) m.disable(-2); // Disabilita fornitore m.disable(-3); // Disabilita cambio m.disable(F_CODPAG); // Disabilita codice pagamento - m.disable(F_ANNORIF); // Disabilita anno partita - m.disable(F_NUMRIF); // Disabilita numero partita +// m.disable(F_ANNORIF); // Disabilita anno partita +// m.disable(F_NUMRIF); // Disabilita numero partita m.disable(FS_RESET); // Disabilita tasto di reset m.set(FS_RECALC, "", TRUE); // Disabilita ricalcolo automatico m.disable(FS_RECALC); @@ -514,8 +514,8 @@ void TPrimanota_application::write_scadenze(const TMask& m) { bool sposta = newgame != NULL; if (sposta) - { - sposta = (oldgame->conto() == newgame->conto()); + { + sposta = (oldgame->conto().sottoconto() == newgame->conto().sottoconto()); if (sposta) sposta = yesno_box("Spostare le righe nella nuova partita?"); } diff --git a/cg/saldacon.cpp b/cg/saldacon.cpp index 89b06ed18..59f125215 100755 --- a/cg/saldacon.cpp +++ b/cg/saldacon.cpp @@ -448,7 +448,9 @@ bool TRiga_scadenze::modifica_pagamento(const TRectype& new_pag, const TValuta& sum.update(old_pag, new_pag, PART_IMPORTOVAL); sum.update(old_pag, new_pag, PART_RITENUTE); - partita().chiusa(TRUE); // Aggiorna flag di chiusura + // Aggiorna flags di chiusura + chiusa(TRUE); + partita().chiusa(TRUE); const bool empty = new_pag.get_char(PAGSCA_ACCSAL) != 'S' && new_pag.get_real(PAGSCA_IMPORTO).is_zero(); @@ -580,15 +582,25 @@ TPartita::TPartita(const TBill& clifo, int anno, const char* num) : _part(LF_PARTITE, PART_NRIGA), _unassigned(LF_PAGSCA, "NRIGP") { read(clifo, anno, num); +} + +const char* TPartita::build_key(TString& key) const +{ + if (_conto.tipo() > ' ') + key.format("%c%3d%3d%6ld%4d%s", _conto.tipo(), 0, 0, _conto.sottoconto(), + _anno, (const char*)_num); + else + key.format("%c%3d%3d%6ld%4d%s", + _conto.tipo(), _conto.gruppo(), _conto.conto(), _conto.sottoconto(), + _anno, (const char*)_num); + return key; } int TPartita::compare(const TSortable& s) const { - TString80 key; key.format("%c%6ld%4d%s", conto().tipo(), conto().sottoconto(), - anno(), (const char*)numero()); + TString80 key; build_key(key); const TPartita& p = (const TPartita&)s; - TString80 par; par.format("%c%6ld%4d%s", p.conto().tipo(), p.conto().sottoconto(), - p.anno(), (const char*)p.numero()); + TString80 par; p.build_key(par); return strcmp(key, par); } @@ -934,7 +946,7 @@ bool TPartita::chiusa(bool update) for (int r = part.last(); r > 0; r--) { const TRiga_scadenze& scad = part.rata(r); - if (!scad.chiusa(update)) + if (!scad.chiusa()) { forse_chiusa = FALSE; break; @@ -1120,6 +1132,11 @@ TPartita* TPartite_array::find(const TBill& clifo, int anno, const char* num, bo TPartita* TPartite_array::find(const TRectype& r, bool create) { TBill zio; zio.get(r); + if (zio.gruppo() == 0) + { + zio.set(r.get_int(PART_GRUPPOCL), r.get_int(PART_CONTOCL), + zio.sottoconto(), zio.tipo()); + } const int anno = r.get_int(PART_ANNO); const char* num = r.get_str(PART_NUMPART); return find(zio, anno, num, create); diff --git a/cg/saldacon.h b/cg/saldacon.h index cf671bc12..048013b8f 100755 --- a/cg/saldacon.h +++ b/cg/saldacon.h @@ -184,6 +184,9 @@ class TPartita : public TSortable TRecord_array _part; TRecord_array _unassigned; + +protected: + const char* build_key(TString& key) const; public: // TObject virtual bool ok() const { return _part.rows() > 0; } @@ -272,7 +275,7 @@ public: bool write(bool re = FALSE); bool rewrite() { return write(TRUE); } - int add_numreg(long numreg); // Carica tutte le partite relative alla registrazione numreg + int add_numreg(long numreg); // Carica tutte le partite relative alla registrazione numreg TImporto importo_speso(long numreg, int numrig); void update_reg(const TRectype& mov, long old_reg = 0);