diff --git a/cg/cg0100.cpp b/cg/cg0100.cpp index c97539b0e..82a371028 100755 --- a/cg/cg0100.cpp +++ b/cg/cg0100.cpp @@ -5,7 +5,6 @@ #include "cg0100.h" #include - #include #define ATTIVITA 1 @@ -385,23 +384,24 @@ HIDDEN bool sottoc_handler(TMask_field& f, KEY key) bool CG0100_application::user_create() { + _rel = new TRelation(LF_PCON); + _saldi = new TLocalisamfile(LF_SALDI); + _saldi->setkey(2); + _msk = new TMask("cg0100a") ; _msk->set_handler(FLD_CM1_GRUPPO, gruppo_handler); _msk->set_handler(FLD_CM1_CONTO, conto_handler); _msk->set_handler(FLD_CM1_SOTTOCONTO, sottoc_handler); _msk->set_handler(FLD_CM1_TMCF, tmcf_handler); - - _rel = new TRelation(LF_PCON); - _saldi = new TLocalisamfile(LF_SALDI); - _saldi->setkey(2); set_search_field(FH_SOTTOCONTO); + return TRUE; } bool CG0100_application::user_destroy() { - delete _msk; + delete _msk; delete _rel; delete _saldi; return TRUE; diff --git a/cg/cg0500.cpp b/cg/cg0500.cpp index b3a67ee45..39792ebfd 100755 --- a/cg/cg0500.cpp +++ b/cg/cg0500.cpp @@ -854,9 +854,9 @@ bool TCaus_app::user_create() bool TCaus_app::user_destroy() { delete _msk; - delete _rel; - delete _rcaus; delete _rcaus_rec; + delete _rcaus; + delete _rel; return TRUE; } diff --git a/cg/cg2102.cpp b/cg/cg2102.cpp index 5d95815d7..80f59d0e2 100755 --- a/cg/cg2102.cpp +++ b/cg/cg2102.cpp @@ -718,11 +718,12 @@ void TPrimanota_application::generazione_righe_cg(int r) if (can_remove(row)) // Ignora righe senza importo return; - begin_wait(); + TWait_cursor hourglass; TImporto importo; importo = row; const bool causale_ok = causale().codice()[0] > ' '; + // Se la seconda riga e' vuota la genero completamente dalla prima if (r == 0 && cg.row(1).empty_items()) { TBill contro(row, 9, 0x3); // Contropartita della prima riga @@ -732,12 +733,12 @@ void TPrimanota_application::generazione_righe_cg(int r) if (contro.ok()) { contro.add_to(row, 9, 0x3); - cg.force_update(r); + cg.force_update(0); } } if (contro.ok()) { - importo.swap_section(); + importo.swap_section(); // Inverto la sezione D/A set_cgs_row(1, importo, contro, "", ' '); TBill conto(row, 2, 0x3); conto.add_to(cg.row(1), 9, 0x3); @@ -768,8 +769,8 @@ void TPrimanota_application::generazione_righe_cg(int r) int gruppo = rowi.get_int(3); if (gruppo != 0) // Considera righe con conto ... { - gruppo = rowi.get_int(10); - if (gruppo == 0) // ... e senza contropartita + long sotto = rowi.get_long(12); + if (sotto == 0) // ... e senza contropartita { char sez = ' '; // Calcola sezione D/A della riga i if (cg.cell_disabled(i,0)) sez = 'A'; else @@ -790,8 +791,8 @@ void TPrimanota_application::generazione_righe_cg(int r) importo.swap_section(); set_cgs_imp(last, importo); - const int gruppo = row.get_int(10); - if (gruppo == 0) // Se non ho contropartita ... + const long sotto = row.get_long(12); + if (sotto == 0) // Se non ho contropartita ... { TBill contro(cg.row(last), 2, 0x3); // ... copiala dalla riga corrispondente contro.add_to(row, 9, 0x3); @@ -802,14 +803,14 @@ void TPrimanota_application::generazione_righe_cg(int r) else { TToken_string& first = cg.row(first_not_empty); - int gruppo = first.get_int(10); - if (gruppo == 0) // Se la prima riga non ha contropartita ... + long sotto = first.get_long(12); + if (sotto == 0) // Se la prima riga non ha contropartita ... { conto.add_to(first, 9, 0x3); // ... copiaci la mia partita cg.force_update(first_not_empty); } - gruppo = row.get_int(10); - if (gruppo == 0) // Se non ho contropartita ... + sotto = row.get_long(12); + if (sotto == 0) // Se non ho contropartita ... { TBill contro(first, 2, 0x3); // ... copiala dalla prima riga contro.add_to(row, 9, 0x3); @@ -817,15 +818,13 @@ void TPrimanota_application::generazione_righe_cg(int r) } } } - - end_wait(); } int TPrimanota_application::crea_somma_spese(TImporto& imp) { TConto cassa; causale().bill(2, cassa); - const TString80 desc(causale().desc_agg(2)); + const TString desc(causale().desc_agg(2)); imp.swap_section(); imp.normalize(); const int r = set_cgs_row(-1, imp, cassa, desc, 'L'); cgs().force_update(); @@ -912,7 +911,7 @@ bool TPrimanota_application::cg_notify(TSheet_field& cg, int r, KEY k) { const int k = tipo == 'K' ? 1 : RIGA_SPESE; TBill conto; a.causale().bill(k, conto); - const TString80 desc(a.causale().desc_agg(k)); + const TString desc(a.causale().desc_agg(k)); const char sez = a.causale().sezione(k); const real imp(cg.mask().get(K_RESIDUO)); TImporto importo(sez, imp); @@ -1048,23 +1047,6 @@ TSheet_field& TPrimanota_application::ivas() const return s; } -/* -TBill& TPrimanota_application::ivas_bill(TBill& c) -{ - if (iva() == iva_vendite) - { - const int spric = c.tipo_cr(); - if (spric == 2 || spric == 3) - { - const TString& td = causale().tipo_doc(); - if (td == "FV" || td == "NC" || td == "ND") - c.tipo_cr(4); - } - } - return c; -} -*/ - // Gestione del campo imponibile sullo sheet iva // Certified 90% bool TPrimanota_application::imponibile_handler(TMask_field& f, KEY key) diff --git a/cg/cgsaldac.cpp b/cg/cgsaldac.cpp index 7ca087794..b0d937bff 100755 --- a/cg/cgsaldac.cpp +++ b/cg/cgsaldac.cpp @@ -1936,6 +1936,7 @@ int TPartite_array::add_numreg(long nreg) // Uso un cursore per evitare conflitti di lettura con l'oggetta partita TCursor cur(&rel, "", 2, &part, &part); + cur.freeze(); for (cur = 0; cur.ok(); ++cur) partita(part); // Aggiungi partita se non esiste gia' diff --git a/cg/cgsaldac.h b/cg/cgsaldac.h index 9fc2ff6d5..908bf7c17 100755 --- a/cg/cgsaldac.h +++ b/cg/cgsaldac.h @@ -339,6 +339,7 @@ public: // Cerca la riga della partita relativa alla registrazione numreg TRiga_partite* mov2rig(long numreg, int numrig); + int items() const { return TAssoc_array::items(); } TPartita* first() { restart(); return next(); } TPartita* next() { return (TPartita*)get(); }