diff --git a/cg/cg2100.cpp b/cg/cg2100.cpp index 2793042df..118b0ef8a 100755 --- a/cg/cg2100.cpp +++ b/cg/cg2100.cpp @@ -23,7 +23,6 @@ TPrimanota_application::TPrimanota_application() memset(_msk, 0, sizeof(_msk)); } - TMask* TPrimanota_application::load_mask(int n) { if (n == 2 && _msk[0] != NULL) @@ -254,8 +253,10 @@ bool TPrimanota_application::read_caus(const char* cod, int year) m->enable_page(2, _is_saldaconto && !nota_credito); m->show(F_ANNORIF, _is_saldaconto); // Mostra/nasconde anno e riferimento partita m->show(F_NUMRIF, _is_saldaconto); - - m->field(F_NUMRIF).set_justify(iva == iva_acquisti ? _num_for : _num_cli); + + TEdit_field& numrif = m->efield(F_NUMRIF); + numrif.set_justify(iva == iva_acquisti ? _num_for : _num_cli); + numrif.set_trim(!numrif.right_justified()); const bool av = causale().reg().agenzia_viaggi(); m->show(F_DATA74TER, av); @@ -557,14 +558,6 @@ void TPrimanota_application::init_insert_mode(TMask& m) void TPrimanota_application::init_modify_mode(TMask& m) { init_mask(m); - - partite().destroy(); - if (is_saldaconto()) - { - const long numreg = m.get_long(F_NUMREG); - partite().add_numreg(numreg); - } - calcola_saldo(); // Verifica eventuali sbilanci contabili } @@ -674,6 +667,7 @@ int TPrimanota_application::read(TMask& m) calcola_imp(); // Calcola totale imponibile ed imposte + partite().destroy(); const int tm = causale().tipomov(); if (tm != 0 && tm != 2) // Ci sono scadenze { diff --git a/cg/cg2100p.uml b/cg/cg2100p.uml index 65244679d..dd55e4c57 100755 --- a/cg/cg2100p.uml +++ b/cg/cg2100p.uml @@ -161,6 +161,7 @@ END STRING 102 7 BEGIN PROMPT 1 3 "Partita " + FLAGS "_" END DATA 103 diff --git a/cg/cg2100s.uml b/cg/cg2100s.uml index d42e8ea4f..c4568eaf3 100755 --- a/cg/cg2100s.uml +++ b/cg/cg2100s.uml @@ -38,7 +38,7 @@ END STRING S_NUM 7 BEGIN PROMPT 15 1 "Numero " - FLAGS "DR" + FLAGS "D_" FIELD NUMPART END @@ -155,9 +155,10 @@ BEGIN GROUP 2 END -LIST S_SALDOACC 1 12 +RADIOBUTTON S_SALDOACC 1 24 BEGIN - PROMPT 2 10 "Saldo/Acc." + PROMPT 2 9 "" + FLAGS "Z" ITEM "A|Acconto" ITEM "S|Saldo" FIELD ACCSAL diff --git a/cg/cg2104.cpp b/cg/cg2104.cpp index 411ab587f..bb51a8a79 100755 --- a/cg/cg2104.cpp +++ b/cg/cg2104.cpp @@ -68,7 +68,7 @@ bool TPrimanota_application::pag_notify(TSheet_field& ps, int r, KEY k) mod = m_imp = TRUE; } if (newt != ts.get(4)) // modificato tipo pagamento - mod = m_tipo = TRUE; + mod = m_tipo = m_ulc = TRUE; if (newu != ts.get(5)) // modificata ulteriore classificazione mod = m_ulc = TRUE; @@ -460,9 +460,9 @@ bool TPrimanota_application::read_scadenze(TMask& m) void TPrimanota_application::write_scadenze(const TMask& m) { - const int anno = m.get_int(F_ANNORIF); - const TString16 numpart(m.get(F_NUMRIF)); const long nreg = m.get_long(F_NUMREG); + const int anno = m.get_int(F_ANNORIF); + const TString numpart(m.get(F_NUMRIF)); TPartita* newgame = NULL; if (anno > 0 && numpart.not_empty()) diff --git a/cg/cg2105.cpp b/cg/cg2105.cpp index 6311210f9..685f89fcb 100755 --- a/cg/cg2105.cpp +++ b/cg/cg2105.cpp @@ -199,8 +199,12 @@ protected: int nuova_riga(TPartita& partita) const; int nuovo_pagamento(TPartita& partita, int nriga, int rata) const; bool edit_pagamento(TPartita& p, int nriga, int nrata, int nrigp) const; + + bool same_number(const char* s1, const char* s2) const; + #ifdef __EXTRA__ bool edit_fattura(TPartita& p, int nriga); + void prima_nota(const long nreg); #endif bool cerca_valuta(TValuta& val) const; @@ -280,12 +284,15 @@ bool TGame_mask::numpart_handler(TMask_field& f, KEY k) { TToken_string& row = sheet.row(i); if (anno == row.get_int(0)) // Se corrisponde l'anno e ... - if (num == row.get()) // corrisponde il numero partita ... + { + TString16 n = row.get(); n.trim(); + if (num == n) // corrisponde il numero partita ... { sheet.select(i); // ... seleziona la partita partite_notify(sheet, i, K_TAB); // ed esplodi le sue righe break; } + } } if (i >= sheet.items()) f.warning_box("Partita inesistente"); @@ -423,175 +430,180 @@ bool TGame_mask::partite_notify(TSheet_field& partite, int r, KEY k) TString_array& scadenze = gm.scadenze().rows_array(); scadenze.destroy(); - const TBill& zio = gm.conto(); // Conto cliente/fornitore TToken_string& row = partite.row(r); const int anno = row.get_int(0); // Anno partita const TString16 num = row.get(); // Numero partita gm.set(P_ANNO, anno); // Aggiorna campi di ricerca gm.set(P_NUMERO, num); - TPartita* game = app().partite().exist(zio, anno, num); // Cerca la partita tra quelle editate - const bool should_delete_game = (game == NULL); // Ricorda di fare delete - if (should_delete_game) // Se non c'era ... - game = new TPartita(zio, anno, num); // ... creane una temporanea - - TImporto tot_lit, tot_val; - TToken_string riga_fattura; - - const int lastrow = game->last(); - for (int ri = game->first(); ri <= lastrow; ri = game->succ(ri)) + if (anno > 0) { - const TRiga_partite& riga = game->riga(ri); - const bool in_valuta = riga.in_valuta(); + const TBill& zio = gm.conto(); // Conto cliente/fornitore - if (riga.rate() > 0) // Se ci sono rate stampa la riga con la fattura - { - riga_fattura.add(ri); - riga_fattura.add(""); - riga_fattura.add(""); - riga_fattura.add(riga.get(PART_DATADOC)); - riga_fattura.add(riga.get(PART_DESCR)); - add_importo(riga_fattura, TImporto(riga.sezione(), riga.get_real(SCAD_IMPORTO))); - if (in_valuta) - add_importo(riga_fattura, TImporto(riga.sezione(), riga.get_real(SCAD_IMPORTOVAL)), TRUE); - else - riga_fattura.add(""); - riga_fattura.add(riga.get(PART_NREG)); - riga_fattura.add(riga.get(PART_DATAREG)); - riga_fattura.add(riga.get(PART_NUMDOC)); - riga_fattura.add(riga.get(PART_PROTIVA)); - scadenze.add(riga_fattura); - } + TPartita* game = app().partite().exist(zio, anno, num); // Cerca la partita tra quelle editate + const bool should_delete_game = (game == NULL); // Ricorda di fare delete + if (should_delete_game) // Se non c'era ... + game = new TPartita(zio, anno, num); // ... creane una temporanea - for (int ra = 1; ra <= riga.rate(); ra++) + TImporto tot_lit, tot_val; + TToken_string riga_fattura; + + const int lastrow = game->last(); + for (int ri = game->first(); ri <= lastrow; ri = game->succ(ri)) { - const TRiga_scadenze& scad = riga.rata(ra); + const TRiga_partite& riga = game->riga(ri); + const bool in_valuta = riga.in_valuta(); - TToken_string& row = scadenze.row(scadenze.add(riga_fattura)); - row.add(ra, 1); - row.add(scad.get(SCAD_DATASCAD), 2); - add_importo(row, TImporto(riga.sezione(), scad.get_real(SCAD_IMPORTO)), FALSE, 5); - if (in_valuta) - add_importo(row, TImporto(riga.sezione(), scad.get_real(SCAD_IMPORTOVAL)), TRUE, 6); - - const int lastp = scad.last(); - for (int pa = scad.first(); pa <= lastp; pa = scad.succ(pa)) + if (riga.rate() > 0) // Se ci sono rate stampa la riga con la fattura { - const TRectype& pag = scad.row(pa); + riga_fattura.add(ri); + riga_fattura.add(""); + riga_fattura.add(""); + riga_fattura.add(riga.get(PART_DATADOC)); + riga_fattura.add(riga.get(PART_DESCR)); + add_importo(riga_fattura, TImporto(riga.sezione(), riga.get_real(SCAD_IMPORTO))); + if (in_valuta) + add_importo(riga_fattura, TImporto(riga.sezione(), riga.get_real(SCAD_IMPORTOVAL)), TRUE); + else + riga_fattura.add(""); + riga_fattura.add(riga.get(PART_NREG)); + riga_fattura.add(riga.get(PART_DATAREG)); + riga_fattura.add(riga.get(PART_NUMDOC)); + riga_fattura.add(riga.get(PART_PROTIVA)); + scadenze.add(riga_fattura); + } + + for (int ra = 1; ra <= riga.rate(); ra++) + { + const TRiga_scadenze& scad = riga.rata(ra); + + TToken_string& row = scadenze.row(scadenze.add(riga_fattura)); + row.add(ra, 1); + row.add(scad.get(SCAD_DATASCAD), 2); + add_importo(row, TImporto(riga.sezione(), scad.get_real(SCAD_IMPORTO)), FALSE, 5); + if (in_valuta) + add_importo(row, TImporto(riga.sezione(), scad.get_real(SCAD_IMPORTOVAL)), TRUE, 6); + + const int lastp = scad.last(); + for (int pa = scad.first(); pa <= lastp; pa = scad.succ(pa)) + { + const TRectype& pag = scad.row(pa); + const TRiga_partite& sum = game->riga(pa); + const char sez = sum.sezione(); + + TToken_string& row = scadenze.row(scadenze.add("")); + row.add(ri); + row.add(ra); + row.add(scad.get(SCAD_DATASCAD)); + row.add(sum.get(PART_DATADOC)); + row.add(sum.get(PART_DESCR)); + add_importo(row, TImporto(sez, pag.get_real(PAGSCA_IMPORTO))); + if (in_valuta) + add_importo(row, TImporto(sez, pag.get_real(PAGSCA_IMPORTOVAL)), 2); + else + row.add(""); + row.add(sum.get(PART_NREG)); + row.add(sum.get(PART_DATAREG)); + row.add(sum.get(PART_NUMDOC)); + row.add(""); + row.add(pa); + } + + TImporto abb(scad.importo_pagato(TRUE, 0x2)); + if (!abb.is_zero()) + { + TToken_string& rabb = scadenze.row(scadenze.add("")); + rabb.add("Abbuoni rata ", 4); rabb << ra; + if (in_valuta) + { + add_importo(rabb, scad.importo_pagato(FALSE, 0x2)); + add_importo(rabb, abb); + } + else + { + add_importo(rabb, abb, TRUE); + rabb.add(""); + } + } + + if (in_valuta) + { + TImporto diff(scad.importo_pagato(FALSE, 0x4)); + if (!diff.is_zero()) + { + TToken_string& rdiff = scadenze.row(scadenze.add("")); + rdiff.add("Differ. cambio rata ", 4); rdiff << ra; + add_importo(rdiff, diff.normalize()); + } + } + + TToken_string& rsal = scadenze.row(scadenze.add("")); + rsal.add("Saldo rata ", 4); rsal << ra; + if (!scad.chiusa()) + { + TImporto sl(scad.residuo(FALSE, 0x7)); + sl.normalize(); + add_importo(rsal, sl); + tot_lit += sl; + + if (in_valuta) + { + sl = scad.residuo(TRUE, 0x3); + sl.normalize(); + add_importo(rsal, sl, TRUE); + tot_val += sl; + } + } + } + + TRecord_array& unas = game->unassigned(); + const int lastp = unas.last_row(); + for (int pa = unas.first_row(); pa <= lastp; pa = unas.succ_row(pa)) + { + const TRectype& pag = unas.row(pa); const TRiga_partite& sum = game->riga(pa); - const char sez = sum.sezione(); + TImporto imp(sum.sezione(), ZERO); TToken_string& row = scadenze.row(scadenze.add("")); - row.add(ri); - row.add(ra); - row.add(scad.get(SCAD_DATASCAD)); + row.add(pag.get(PAGSCA_NRIGA)); + row.add(pag.get(PAGSCA_NRATA)); + row.add(""); row.add(sum.get(PART_DATADOC)); row.add(sum.get(PART_DESCR)); - add_importo(row, TImporto(sez, pag.get_real(PAGSCA_IMPORTO))); - if (in_valuta) - add_importo(row, TImporto(sez, pag.get_real(PAGSCA_IMPORTOVAL)), 2); + TImporto i(sum.sezione(), pag.get_real(PAGSCA_IMPORTO)); + i.normalize(); + tot_lit += i; + add_importo(row, i); + if (in_valuta) + { + i = TImporto(sum.sezione(), pag.get_real(PAGSCA_IMPORTOVAL)); + tot_val += i; + i.normalize(); + add_importo(row, i, TRUE); + } else - row.add(""); + row.add(""); row.add(sum.get(PART_NREG)); row.add(sum.get(PART_DATAREG)); row.add(sum.get(PART_NUMDOC)); row.add(""); row.add(pa); } - - TImporto abb(scad.importo_pagato(TRUE, 0x2)); - if (!abb.is_zero()) - { - TToken_string& rabb = scadenze.row(scadenze.add("")); - rabb.add("Abbuoni rata ", 4); rabb << ra; - if (in_valuta) - { - add_importo(rabb, scad.importo_pagato(FALSE, 0x2)); - add_importo(rabb, abb); - } - else - { - add_importo(rabb, abb, TRUE); - rabb.add(""); - } - } - - if (in_valuta) - { - TImporto diff(scad.importo_pagato(FALSE, 0x4)); - if (!diff.is_zero()) - { - TToken_string& rdiff = scadenze.row(scadenze.add("")); - rdiff.add("Differ. cambio rata ", 4); rdiff << ra; - add_importo(rdiff, diff.normalize()); - } - } - - TToken_string& rsal = scadenze.row(scadenze.add("")); - rsal.add("Saldo rata ", 4); rsal << ra; - if (!scad.chiusa()) - { - TImporto sl(scad.residuo(FALSE, 0x7)); - sl.normalize(); - add_importo(rsal, sl); - tot_lit += sl; - - if (in_valuta) - { - sl = scad.residuo(TRUE, 0x3); - sl.normalize(); - add_importo(rsal, sl, TRUE); - tot_val += sl; - } - } } - TRecord_array& unas = game->unassigned(); - const int lastp = unas.last_row(); - for (int pa = unas.first_row(); pa <= lastp; pa = unas.succ_row(pa)) - { - const TRectype& pag = unas.row(pa); - const TRiga_partite& sum = game->riga(pa); - TImporto imp(sum.sezione(), ZERO); - - TToken_string& row = scadenze.row(scadenze.add("")); - row.add(pag.get(PAGSCA_NRIGA)); - row.add(pag.get(PAGSCA_NRATA)); - row.add(""); - row.add(sum.get(PART_DATADOC)); - row.add(sum.get(PART_DESCR)); - TImporto i(sum.sezione(), pag.get_real(PAGSCA_IMPORTO)); - i.normalize(); - tot_lit += i; - add_importo(row, i); - if (in_valuta) - { - i = TImporto(sum.sezione(), pag.get_real(PAGSCA_IMPORTOVAL)); - tot_val += i; - i.normalize(); - add_importo(row, i, TRUE); - } - else - row.add(""); - row.add(sum.get(PART_NREG)); - row.add(sum.get(PART_DATAREG)); - row.add(sum.get(PART_NUMDOC)); - row.add(""); - row.add(pa); + if (lastrow > 0) + { + TToken_string& sp = scadenze.row(scadenze.add("")); + sp.add("Saldo ", 4); sp << anno << ' ' << num; + add_importo(sp, tot_lit.normalize()); + add_importo(sp, tot_val.normalize(), TRUE); } - } - if (lastrow > 0) - { - TToken_string& sp = scadenze.row(scadenze.add("")); - sp.add("Saldo ", 4); sp << anno << ' ' << num; - add_importo(sp, tot_lit.normalize()); - add_importo(sp, tot_val.normalize(), TRUE); + if (should_delete_game) + delete game; } gm.scadenze().force_update(); - if (should_delete_game) - delete game; } if (k == K_INS) { @@ -615,15 +627,20 @@ bool TGame_mask::scadenze_notify(TSheet_field& scadenze, int r, KEY k) int TGame_mask::nuova_riga(TPartita& partita) const { - TRiga_partite& part = partita.new_row(); // Creazione nuova riga vuota + TRiga_partite& part = partita.new_row(); // Creazione nuova riga vuota const int nriga = part.get_int(PART_NRIGA); // Copia dati movimento corrente - part.put(PART_NREG, _numreg); // Numero operazione - part.put(PART_NUMRIG, _numrig); // Riga su cui ho cliccato + part.put(PART_NREG, _numreg); // Numero operazione + part.put(PART_NUMRIG, _numrig); // Riga su cui ho cliccato + // Forza il gruppo/conto cliente corretto + part.put(PART_GRUPPOCL, conto().gruppo()); + part.put(PART_CONTOCL, conto().conto()); + + // Setta il cambio corrente const real cambio(get(P_CAMBIO)); - part.put(PART_CAMBIO, cambio); + part.put(PART_CAMBIO, cambio); part.put(PART_CODVAL, get(P_VALUTA)); part.put(PART_DATACAM, get(P_DATACAMBIO)); @@ -745,7 +762,6 @@ int TGame_mask::nuovo_pagamento(TPartita& partita, int nriga, int rata) const return nrigp; } - bool TGame_mask::edit_scadenza_handler(TMask_field& f, KEY k) { if (k == K_SPACE) @@ -773,6 +789,13 @@ bool TGame_mask::edit_scadenza_handler(TMask_field& f, KEY k) if (nrata != 0 && nrigp == 0) { +#ifdef __EXTRA__ + gm._tipomov = 3; + gm._descr = ""; + gm._numdoc = ""; + gm._datadoc = TDate(TODAY); + gm._sezione = game.riga(nriga).sezione() == 'D' ? 'A' : 'D'; +#endif nrigp = gm.nuovo_pagamento(game, nriga, nrata); nreg = gm._numreg; } @@ -793,38 +816,19 @@ bool TGame_mask::edit_scadenza_handler(TMask_field& f, KEY k) } } else + { +#ifdef __EXTRA__ + gm.prima_nota(nreg); +#else return f.error_box("Modificare il movimento %ld", nreg); +#endif + } } else { // Si vogliono editare le rate #ifdef __EXTRA__ if (nreg > 0) - { - bool can_run = TRUE; - if (gm._changed) - { - can_run = yesno_box("Salvare le parite modificate?"); - if (can_run) - { - app().partite().rewrite(); - gm._changed = FALSE; // Resetta flag di cambiato - } - } - if (can_run) - { - const char* pn = "cg2 -0"; - TExternal_app prima_nota(pn); - TString16 numreg; numreg << "1|" << nreg; - TMessage msg(pn, MSG_LN, numreg); - msg.send(); // Messaggio di collegamento al movimento nreg - app().partite().destroy(); // Distrugge tutte le partite in memoria - prima_nota.run(); // Lancia la prima nota - - const int anno = gm.get_int(P_ANNO); - const TString16 numero = gm.get(P_NUMERO); - gm.fill_partite(anno, numero); // Ripristina partite - } - } + gm.prima_nota(nreg); else gm.edit_fattura(game, nriga); #else @@ -988,6 +992,12 @@ int TGame_mask::update_partita(const TPartita& game, int prow) } else prow = partite().items()-1; + + if (prow == 0) + { + const char all = game.allineamento_richiesto(); + field(P_NUMERO).set_justify(all == 'R'); + } return prow; } @@ -1029,6 +1039,13 @@ void TGame_mask::update_saldo_clifo() r << conto().sottoconto(); } +bool TGame_mask::same_number(const char* s1, const char* s2) const +{ + TString t1(s1); t1.trim(); + TString t2(s2); t2.trim(); + return t1 == t2; +} + void TGame_mask::fill_partite(int annorif, const char* numrif) { const bool all = get(P_SHOWALL).not_empty(); @@ -1043,7 +1060,8 @@ void TGame_mask::fill_partite(int annorif, const char* numrif) for (TPartita* gioco = app().partite().first(); gioco != NULL; gioco = app().partite().next()) { const int added = update_partita(*gioco, -1); // Memorizza posizione di inserimento - if (first_game < 0 && gioco->anno() == annorif && gioco->numero() == numrif) + if (first_game < 0 && gioco->anno() == annorif && + same_number(gioco->numero(), numrif)) first_game = added; } @@ -1074,7 +1092,8 @@ void TGame_mask::fill_partite(int annorif, const char* numrif) if (all || !game.chiusa()) added = update_partita(game, -1); - if (first_game < 0 && added >= 0 && anno == annorif && num == numrif) + if (first_game < 0 && added >= 0 && + anno == annorif && same_number(num, numrif)) first_game = added; } partita.put(PART_NRIGA, 9999); // Forza lettura partita successiva nella prossima read @@ -1092,7 +1111,7 @@ void TGame_mask::fill_partite(int annorif, const char* numrif) else { scadenze().destroy(); - scadenze().force_update(); +// scadenze().force_update(); } app().end_wait(); } diff --git a/cg/pagament.cpp b/cg/pagament.cpp index 9a538c098..ed326f85d 100755 --- a/cg/pagament.cpp +++ b/cg/pagament.cpp @@ -688,6 +688,8 @@ word TPagamento::recalc_rate(int row, bool is_perc_modified, TToken_string& ss = (TToken_string&)srate[k]; tt.add(typ,2); ss.add(typ,2); + tt.add(ulc,5); + ss.add(ulc,5); need_recalc = TRUE; // no error is possible } @@ -1384,9 +1386,8 @@ void TPagamento::set_sheet(TSheet_field& sf, int sscad) ts.add(paid ? "X" : "", 11); // 11 - Pagaya } - // destroy remaining and don't avoid screen update forever and ever for (int d = sf.items()-1; d >= i; d--) - sf.destroy(d); + sf.destroy(d); sf.enable_column(2, in_valuta); } diff --git a/cg/saldacon.cpp b/cg/saldacon.cpp index ec4822fb7..53317f5b9 100755 --- a/cg/saldacon.cpp +++ b/cg/saldacon.cpp @@ -527,10 +527,16 @@ int TRiga_partite::ultima_ratapagata() const return r; } +bool TRiga_partite::is_fattura() const +{ + return get_int(PART_TIPOMOV) == 1; +} + + int TRiga_partite::read(TBaseisamfile& f, word op) { int err = TRectype::read(f, op); - if (err == NOERR && get_int(PART_TIPOMOV) == 1) + if (err == NOERR && is_fattura()) { TRiga_scadenze* s = new TRiga_scadenze(this); err = rows_array().read(s); // Deve esistere almento una scadenza @@ -541,8 +547,26 @@ int TRiga_partite::read(TBaseisamfile& f, word op) return err; } -int TRiga_partite::ultimo_pagamento(int r) const +int TRiga_partite::write(TBaseisamfile& f) const { + const int err = is_fattura() ? TTree_rectype::write(f) : TRectype::write(f); + return err; +} + +int TRiga_partite::rewrite(TBaseisamfile& f) const +{ + const int err = is_fattura() ? TTree_rectype::rewrite(f) : TRectype::rewrite(f); + return err; +} + +int TRiga_partite::remove(TBaseisamfile& f) const +{ + const int err = is_fattura() ? TTree_rectype::remove(f) : TRectype::remove(f); + return err; +} + +int TRiga_partite::ultimo_pagamento(int r) const +{ const TRiga_scadenze& s = rata(r); return s.last(); } @@ -657,7 +681,14 @@ char TPartita::allineamento_richiesto() const { char all; if (_cli_align <= ' ' || _for_align <= ' ') + { +#ifdef DBG + warning_box("Questa applicazione usa le partite ma ignora i " + "parametri ditta relativi al loro allineamento: " + "continuiamo pure cosi', facciamoci del male!"); +#endif carica_allineamento(); + } switch (conto().tipo()) { case 'C': all = _cli_align; break; @@ -685,19 +716,16 @@ void TPartita::allinea(char all) if (all <= ' ') all = allineamento_richiesto(); - if (_num.len() < NUMLEN) - { - if (all == 'R') - _num.right_just(NUMLEN); - else - _num.trim(); + if (all == 'R') + _num.right_just(NUMLEN); + else + _num.trim(); - if (ok()) - { - _part.renum_key(PART_NUMPART, _num); - _unassigned.renum_key(PAGSCA_NUMPART, _num); - } - } + if (ok()) + { + _part.renum_key(PART_NUMPART, _num); + _unassigned.renum_key(PAGSCA_NUMPART, _num); + } } @@ -719,12 +747,10 @@ bool TPartita::read(const TBill& clifo, int year, const char* num) part.put(PART_NUMPART, _num); TRectype filter(part.curr()); - - // Cerca la partita usando l'allineamento richiesto dai parametri ditta + // Cerca la partita usando l'allineamento richiesto dall'utente if (part.read(_isgteq) == NOERR && part.curr() == filter) { - // Memorizza l'allineamento utilizzato per la lettura - _align = allineamento_corrente(); + // Trovata! } else { @@ -737,13 +763,18 @@ bool TPartita::read(const TBill& clifo, int year, const char* num) // Riprova a cercarla col nuovo allineamento filter.put(PART_NUMPART, _num); if (part.read(_isgteq) == NOERR && part.curr() == filter) - _align = allineamento_corrente(); // Esiste: memorizzo l'allineamento + { + // Esiste: memorizzo l'allineamento + } else + { allinea(); // Non esite: e' una nuova partita! + } } } else _num.trim(); + _align = allineamento_corrente(); TRiga_partite* partita = new TRiga_partite(this); // Record campione della partita TString16 str; @@ -1110,6 +1141,13 @@ bool TPartita::modifica_pagamento(const TRectype& new_pag) bool TPartita::chiusa(bool update) { bool chiusa = FALSE; + + const int ultima = last(); + if (ultima > 0) + { + const TRiga_partite& row = riga(ultima); + chiusa = row.get_bool(PART_CHIUSA); + } if (update) { @@ -1141,15 +1179,6 @@ bool TPartita::chiusa(bool update) } } } - else - { - const int ultima = last(); - if (ultima > 0) - { - const TRiga_partite& row = riga(ultima); - chiusa = row.get_bool(PART_CHIUSA); - } - } return chiusa; } diff --git a/cg/saldacon.h b/cg/saldacon.h index 38fb60263..1942b27b8 100755 --- a/cg/saldacon.h +++ b/cg/saldacon.h @@ -154,13 +154,17 @@ protected: public: // TTree_rectype virtual TObject* dup() const { return new TRiga_partite(*this); } virtual int read(TBaseisamfile& f, word op); + virtual int write(TBaseisamfile& f) const; + virtual int rewrite(TBaseisamfile& f) const; + virtual int remove(TBaseisamfile& f) const; public: int rate() const { return _recarr.rows(); } TRiga_scadenze& rata(int r) const { return (TRiga_scadenze&)_recarr.row(r); } void elimina_rate(); TRiga_scadenze& new_row(int r = 0); - + + bool is_fattura() const; int ultima_ratapagata() const; int ultimo_pagamento(int rata) const; int rata_con_abbuoni_diffcam() const; @@ -192,11 +196,15 @@ class TPartita : public TSortable protected: const char* build_key(TString& key) const; + + char allineamento_iniziale() const { return _align; } + char allineamento_corrente() const; + void allinea(char all = ' '); public: // TObject virtual bool ok() const { return _part.rows() > 0; } virtual int compare(const TSortable& s) const; - + public: enum { NUMLEN = 7, UNASSIGNED = 9999 }; @@ -251,10 +259,7 @@ public: bool modifica_pagamento(const TRectype& new_pag); static void carica_allineamento(); - char allineamento_iniziale() const { return _align; } - char allineamento_corrente() const; char allineamento_richiesto() const; - void allinea(char all = ' '); TPartita(const TBill& clifo, int anno, const char* num); TPartita(const TRectype& part);