From 195bcc038164b51d8db574976e7ecd713933784f Mon Sep 17 00:00:00 2001 From: guy Date: Mon, 5 Feb 1996 08:27:17 +0000 Subject: [PATCH] Correzioni saldaconto git-svn-id: svn://10.65.10.50/trunk@2553 c028cbd2-c16b-5b4b-a496-9718f37d4682 --- cg/cg2100.cpp | 4 +- cg/cg2100a.uml | 4 +- cg/cg2100p.uml | 1 + cg/cg2102.cpp | 127 +++++++++++++++++++--------- cg/cg2102.h | 1 + cg/cg2104.cpp | 101 ++++++++++++----------- cg/cg2105.cpp | 218 ++++++++++++++++++++++++++----------------------- cg/saldacon.h | 1 + 8 files changed, 266 insertions(+), 191 deletions(-) diff --git a/cg/cg2100.cpp b/cg/cg2100.cpp index ee6141524..e120d685e 100755 --- a/cg/cg2100.cpp +++ b/cg/cg2100.cpp @@ -279,12 +279,10 @@ bool TPrimanota_application::read_caus(const char* cod, int year) { m->efield(F_CODPAG).enable(!nota_credito); - m->show(F_ANNORIF, _is_saldaconto); // Mostra/nasconde anno e riferimento partita - m->show(F_NUMRIF, _is_saldaconto); - TEdit_field& numrif = m->efield(F_NUMRIF); numrif.set_justify(iva == iva_acquisti ? _num_for : _num_cli); numrif.set_trim(!numrif.right_justified()); + activate_numrif(FALSE); const bool av = causale().reg().agenzia_viaggi(); m->show(F_DATA74TER, av); diff --git a/cg/cg2100a.uml b/cg/cg2100a.uml index 3a61ab00c..7073dd277 100755 --- a/cg/cg2100a.uml +++ b/cg/cg2100a.uml @@ -75,9 +75,8 @@ END STRING F_CODCAUS 3 BEGIN PROMPT 1 9 "Causale " - HELP "Codice della causale dell'operazione" FLAGS "UZ" - FIELD LF_MOV->CODCAUS + FIELD CODCAUS USE LF_CAUSALI KEY 1 INPUT CODCAUS F_CODCAUS DISPLAY "Codice" CODCAUS @@ -94,7 +93,6 @@ END STRING F_DESCRCAUS 50 BEGIN PROMPT 21 9 "" - HELP "Descrizione della causale dell'operazione" USE LF_CAUSALI KEY 2 CHECKTYPE NORMAL INPUT DESCR F_DESCRCAUS diff --git a/cg/cg2100p.uml b/cg/cg2100p.uml index 498b8be64..7c435efbd 100755 --- a/cg/cg2100p.uml +++ b/cg/cg2100p.uml @@ -52,6 +52,7 @@ BEGIN FLAGS "DU" GROUP 3 PICTURE ".5" + FIELD ANTIOUTPUT CHECKTYPE REQUIRED END diff --git a/cg/cg2102.cpp b/cg/cg2102.cpp index 88d8449bc..cba32e4ca 100755 --- a/cg/cg2102.cpp +++ b/cg/cg2102.cpp @@ -296,11 +296,17 @@ void TPrimanota_application::disable_cgs_cells(int n, char tipo) switch(tipo) { case 'T': // Totale documento - if (!causale().corrispettivi()) + if (causale().corrispettivi()) { + last = 2; + } + else + { + last = 3; cg.disable_cell(n, 5); cg.disable_cell(n, 6); - } + } + break; case 'A': // Abbuoni attivi case 'C': // Differenza cambio case 'D': // IVA Detraibile @@ -1391,24 +1397,23 @@ bool TPrimanota_application::cg_gruppo_handler(TMask_field& f, KEY key) bool TPrimanota_application::cg_conto_handler(TMask_field& f, KEY key) { bool ok = TRUE; + if (key == K_ENTER) { - if (!app().causale().corrispettivi()) + TMask& m = f.mask(); + if (m.get(CG_ROWTYPE)[0] == 'T' && !app().causale().corrispettivi()) { - TMask& m = f.mask(); - if (m.get(CG_ROWTYPE)[0] == 'T') // Se riga totale documento + const char tipo = app().clifo(); // Tipo conto richiesto dal movimento + char cf = m.get(f.dlg()-2)[0]; + if (cf < ' ') cf = ' '; // Tipo conto della riga + if (cf != tipo) // Incongruenza! { - const char tipo = app().clifo(); // Tipo conto richiesto dal movimento - char cf = m.get(f.dlg()-2)[0]; - if (cf < ' ') cf = ' '; // Tipo conto della riga - if (cf != tipo) // Incongruenza! - { - const char* d = tipo == ' ' ? "normale" : (tipo == 'C' ? "clienti" : "fornitori"); - ok = f.error_box("La riga totale richiede un conto %s.", d); - } - } - } + const char* d = tipo == 'C' ? "clienti" : "fornitori"; + ok = f.error_box("La riga totale richiede un conto %s.", d); + } + } } + return ok; } @@ -1752,7 +1757,7 @@ bool TPrimanota_application::numdoc_handler(TMask_field& f, KEY key) const TString16 n = f.get(); if (n.not_empty() && !app().npart_is_prot()) // Copiare numero documento nel numero partita? { - if (m.field(F_NUMRIF).active() && m.get(F_NUMRIF).empty()) + if (m.field(F_NUMRIF).active() && m.get(F_NUMRIF).blank()) m.set(F_NUMRIF, n, TRUE); } } @@ -2216,7 +2221,7 @@ bool TPrimanota_application::protiva_handler(TMask_field& f, KEY key) } else if (key == K_TAB && m.insert_mode() && app().npart_is_prot() && - m.field(F_NUMRIF).active() && m.get(F_NUMRIF).empty()) + m.field(F_NUMRIF).active() && m.get(F_NUMRIF).blank()) { const TString& piva = f.get(); if (piva.not_empty()) @@ -2324,18 +2329,69 @@ bool TPrimanota_application::corrvaluta_handler(TMask_field& f, KEY key) return TRUE; } +bool TPrimanota_application::activate_numrif(bool init_pag) +{ + CHECK(iva() != nessuna_iva, "Non esiste il numero riferimento in questa maschera!"); + TMask& m = curr_mask(); + + bool shown = is_saldaconto(); // Il numero riferimento esiste + + if (shown) + { + const bool solaiva = m.get_bool(F_SOLAIVA); + if (solaiva) shown = FALSE; + } + + if (shown != m.field(F_NUMRIF).shown()) + { + m.show(F_ANNORIF, shown); + m.show(F_NUMRIF, shown); + if (!shown) + { + m.reset(F_ANNORIF); + m.reset(F_NUMRIF); + } + } + // Gestione pagina 3 + const bool page = shown && is_fattura() && !m.get(F_NUMRIF).blank(); + if (page != m.page_enabled(2)) + { + m.enable_page(2, page); + if (page && init_pag && m.is_running()) + { + if (m.edit_mode()) + { + const TString16 dt(m.get(F_DATADOC)); + set_pagamento(NULL, dt); // Reset pagamento + set_totale_pagamento(); + + TSheet_field& ps = (TSheet_field&)m.field(FS_RATESHEET); + pagamento().set_sheet(ps); // Aggiorna lo sheet + pag_rows() = ps.rows_array(); // copia sheet + } + else + set_scadenze(m); // Inizializza pagamento + } + } + + return shown; +} + +// Handler del checkbox di movimento di sola IVA bool TPrimanota_application::solaiva_handler(TMask_field& f, KEY key) { if (key == K_SPACE) { - TMask& m = f.mask(); + TMask& m = f.mask(); + TPrimanota_application& a = app(); + bool anchecg = f.get().empty(); bool recalcg = anchecg; - if (m.is_running() && app().is_fattura()) + if (m.is_running() && a.is_fattura()) { - const TPartita* game = app().partite().first(); + const TPartita* game = a.partite().first(); if (anchecg) { @@ -2350,37 +2406,32 @@ bool TPrimanota_application::solaiva_handler(TMask_field& f, KEY key) bool del = TRUE; if (game != NULL) del = f.yesno_box("Si desidera cancellare il saldaconto?"); - if (del) - { - m.set(F_NUMRIF, "", TRUE); - m.reset(F_ANNORIF); - } - else + if (!del) { f.reset(); anchecg = TRUE; recalcg = FALSE; } } + a.activate_numrif(TRUE); } - m.enable(F_ANNORIF, anchecg); - m.enable(F_NUMRIF, anchecg); - m.show(F_SHEETCG, anchecg); m.show(F_DARE, anchecg); m.show(F_AVERE, anchecg); if (m.is_running() && recalcg) { - TSheet_field& iva = app().ivas(); + TSheet_field& iva = a.ivas(); const int righe = iva.items(); TProgind pi(righe, "Generazione righe contabilita'", FALSE, TRUE, 16); - app().cgs().reset(); - app().add_cgs_tot(m); - if (m.get(F_RITFIS).not_empty()) app().add_cgs_rit(TRUE); - if (m.get(F_RITSOC).not_empty()) app().add_cgs_rit(FALSE); + TSheet_field& cg = a.cgs(); + cg.reset(); + + a.add_cgs_tot(m); // Genera totale documento + if (m.get(F_RITFIS).not_empty()) a.add_cgs_rit(TRUE); // Genera ritenute fiscali + if (m.get(F_RITSOC).not_empty()) a.add_cgs_rit(FALSE); // Genera ritenute sociali TToken_string oldrow(128); for (int i = 0; i < righe; i++) @@ -2390,15 +2441,15 @@ bool TPrimanota_application::solaiva_handler(TMask_field& f, KEY key) { oldrow = r; r = ""; - iva_notify(iva, i, K_SPACE); + iva_notify(iva, i, K_SPACE); // Simula la creazione di una nuova riga iva r = oldrow; iva_notify(iva, i, K_ENTER); } pi.setstatus(i+1); } - app().fill_sheet(m); - app().cgs().force_update(); - m.set_focus(); + a.fill_sheet(m); // Aggiunge righe vuote + cg.force_update(); + m.set_focus(); // Ripristina il focus al campo (a causa della progind) } } return TRUE; diff --git a/cg/cg2102.h b/cg/cg2102.h index 35c438cf3..e3d80ae41 100755 --- a/cg/cg2102.h +++ b/cg/cg2102.h @@ -178,6 +178,7 @@ protected: bool is_fattura() const { return gestione_saldaconto() && causale().tipomov() == 1; } bool is_nota_credito() const { return gestione_saldaconto() && causale().tipomov() == 2; } bool is_pagamento() const { return gestione_saldaconto() && causale().tipomov() >= 3; } + bool activate_numrif(bool set_pag); void fill_sheet(TMask& m) const; void init_mask(TMask& m); diff --git a/cg/cg2104.cpp b/cg/cg2104.cpp index a0890a776..e3f438318 100755 --- a/cg/cg2104.cpp +++ b/cg/cg2104.cpp @@ -247,16 +247,10 @@ bool TPrimanota_application::pag_sheet_handler(TMask_field& f, KEY key) const char* const pic = in_valuta ? ".3" : "."; const TString is(imp.string(pic)); const TString ts(tot.string(pic)); - const bool recalc = yesno_box("Il totale delle rate e' %s mentre\n" - "il totale del documento e' %s.\n" - "Si desidera ricalcolare le rate e poi\n" - "registrare in un secondo momento?", - (const char*)is, (const char*)ts); - if (recalc) - { - app().set_scadenze(m); - ok = FALSE; // Permette di guardare il risultato prima di registrare - } + ok = yesno_box("Il totale delle rate e' %s mentre\n" + "il totale del documento e' %s.\n" + "Si desidera registrare ugualmente?", + (const char*)is, (const char*)ts); } } @@ -304,19 +298,20 @@ bool TPrimanota_application::tipopag_handler(TMask_field& f, KEY key) bool TPrimanota_application::codpag_handler(TMask_field& f, KEY key) { bool ok = TRUE; - TMask& m = f.mask(); - const bool set_scad = m.page_enabled(2); // E' attiva pagina 3 + TMask& m = f.mask(); + TPrimanota_application& a = app(); + const bool set_scad = a.is_fattura() && m.page_enabled(2); // E' attiva pagina 3 if (key == K_ENTER) { - const bool required = app().is_fattura() && (m.insert_mode() || set_scad); + const bool required = a.is_fattura() && (m.insert_mode() || set_scad); if (required && f.get().empty()) { - error_box("Il codice di pagamento e' obbligatorio!\n" - "Se possibile esso verra' proposto, ma potra'\n" - "essere modificato prima di registrare il movimento."); + f.error_box("Il codice di pagamento e' obbligatorio!\n" + "Se possibile esso verra' proposto, ma potra'\n" + "essere modificato prima di registrare il movimento."); - const char typ = app().clifo(); + const char typ = a.clifo(); const long cod = m.get_long(typ == 'C' ? F_CLIENTE : F_FORNITORE); TLocalisamfile clifo(LF_CLIFO); @@ -336,7 +331,7 @@ bool TPrimanota_application::codpag_handler(TMask_field& f, KEY key) } if (key == K_TAB && f.focusdirty() && m.insert_mode() && set_scad) - app().set_scadenze(m); + a.set_scadenze(m); return ok; } @@ -346,7 +341,7 @@ bool TPrimanota_application::annorif_handler(TMask_field& f, KEY key) bool ok = TRUE; const TMask& m = f.mask(); - if (f.to_check(key) && f.get().empty() && + if (f.to_check(key, TRUE) && f.get().empty() && (m.insert_mode() || m.get(F_NUMRIF).not_empty())) { const TString& anno = m.get(F_DATADOC).right(4); @@ -364,27 +359,39 @@ bool TPrimanota_application::numrif_handler(TMask_field& f, KEY key) if (f.to_check(key, TRUE)) { + TPrimanota_application& a = app(); TMask& m = f.mask(); - const bool empty = f.get().blank(); - - if (empty && f.focusdirty() && m.insert_mode() && !m.get_bool(F_SOLAIVA)) + + if (f.focusdirty() && m.insert_mode() && f.get().blank()) { - f.set(m.get(app()._npart_is_prot ? F_PROTIVA : F_NUMDOC)); + f.set(m.get(a._npart_is_prot ? F_PROTIVA : F_NUMDOC)); + if (m.get(F_CODPAG).empty()) { - TMask_field& clifo = m.field(app().iva() == iva_vendite ? F_CLIENTE : F_FORNITORE); + TMask_field& clifo = m.field(a.iva() == iva_vendite ? F_CLIENTE : F_FORNITORE); + clifo.set_dirty(); clifo.on_hit(); } + + TMask_field& anno = m.field(F_ANNORIF); + if (anno.get().empty()) + { + anno.set_dirty(); + anno.on_hit(); + } + ok = error_box("Il numero di riferimento partita e' obbligatorio!\n" "Se possibile esso verra' proposto, ma potra'\n" "essere modificato prima di registrare il movimento."); } - m.enable_page(2, !f.get().blank()); + + if (key == K_TAB && a.is_fattura()) + a.activate_numrif(TRUE); - if (key == K_ENTER && m.edit_mode()) + if (ok && key == K_ENTER && m.edit_mode()) { - const TPartita* old = app().partite().first(); - if (old && old->ok() && empty) // Se esisteva una partita ma ora non piu' + const TPartita* old = a.partite().first(); + if (old && old->ok() && f.get().blank()) // Se esisteva una partita ma ora non piu' { const KEY k = yesnocancel_box("Attenzione la fattura della partita %d %s verra' eliminata.\n" "Premere SI per cancellarla, NO per ripristinarla, ANNULLA per modificarla", @@ -512,8 +519,7 @@ bool TPrimanota_application::recalc_handler(TMask_field& f, KEY key) // cio' implica, evidentemente, che si memorizzi non solo il // nuovo tpr ma anche il fatto che lo si e' cambiato, in quanto // se si riattiva il ricalcolo occorre rimetterlo come era - // in precedenza, aggiungendo (su conferma) un pompino - // di emergenza salvaguai al gentile cliente + // in precedenza. // --------------------------------------------------------- TMask& m = f.mask(); TSheet_field& ps = (TSheet_field&)m.field(FS_RATESHEET); @@ -847,8 +853,8 @@ void TPrimanota_application::write_scadenze(const TMask& m) const TString desc(m.get(F_DESCR)); const TString codpag(m.get(F_CODPAG)); const TString codcaus(causale().codice()); - const TValuta cambio (m, SK_VALUTA, SK_DATACAMBIO, SK_CAMBIO); - const TString agente (m.get(FS_AGENTE)); + const TValuta cambio(m, SK_VALUTA, SK_DATACAMBIO, SK_CAMBIO); + const TString agente(m.get(FS_AGENTE)); const char sezione = get_cgs_imp(0).sezione(); // Dare/Avere TBill clifo; @@ -900,20 +906,23 @@ void TPrimanota_application::write_scadenze(const TMask& m) TToken_string& row = ps.row(i); TRiga_scadenze& scadenza = partita.new_row(); - scadenza.put(SCAD_CODPAG, codpag); - scadenza.put(SCAD_TIPOPAG, pag.tipo_rata(i)); - scadenza.put(SCAD_ULTCLASS, pag.ulc_rata(i)); - scadenza.put(SCAD_IMPORTO, pag.tlit_rata(i)); - scadenza.put(SCAD_IMPORTO, row.get(1)); // 1 = Importo - scadenza.put(SCAD_IMPORTOVAL, row.get(2)); // 2 = Importo in valuta - scadenza.put(SCAD_DATASCAD, pag.data_rata(i)); - scadenza.put(SCAD_CODABIPR, row.get(7)); - scadenza.put(SCAD_CODCABPR, row.get(8)); - scadenza.put(SCAD_CODABI, row.get(9)); - scadenza.put(SCAD_CODCAB, row.get(10)); - scadenza.put(SCAD_DESCR, row.get(11)); //11 = Note - scadenza.put(SCAD_BLOCCATA, row.get(12)); //12 = Non pagabile - scadenza.put(SCAD_CODAG, agente); +<<<<<<< cg2104.cpp + scadenza.put(SCAD_CODPAG, codpag); // Codice pagamento + scadenza.put(SCAD_CODAG, agente); // Codice agente + + scadenza.put(SCAD_DATASCAD, row.get(0)); // 0 = Data scadenza + scadenza.put(SCAD_IMPORTO, row.get()); // 1 = Importo + scadenza.put(SCAD_IMPORTOVAL, row.get()); // 2 = Importo in valuta + row.get(); // 3 = Percentuale + scadenza.put(SCAD_TIPOPAG, row.get()); // 4 = Tipo pagamento + scadenza.put(SCAD_ULTCLASS, row.get()); // 5 = Ulteriore classificazione + row.get(); // 6 = Descrizione pagamento + scadenza.put(SCAD_CODABIPR, row.get()); // 7 = Ns ABI + scadenza.put(SCAD_CODCABPR, row.get()); // 8 = Ns CAB + scadenza.put(SCAD_CODABI, row.get()); // 9 = Vs ABI + scadenza.put(SCAD_CODCAB, row.get()); //10 = Vs CAB + scadenza.put(SCAD_DESCR, row.get()); //11 = Note + scadenza.put(SCAD_BLOCCATA, row.get()); //12 = Non pagabile } } diff --git a/cg/cg2105.cpp b/cg/cg2105.cpp index c9a4ee8a2..40ce2c1b1 100755 --- a/cg/cg2105.cpp +++ b/cg/cg2105.cpp @@ -14,6 +14,81 @@ #include // Archivio partite #include // Archivio scadenze +/////////////////////////////////////////////////////////// +// Definizione Maschera partite +/////////////////////////////////////////////////////////// + +class TGame_mask : public TMask +{ + const TBill _conto; // Conto fisso del cliente/fornitore + long _numreg; // Numero movimento contabile + int _numrig; // Riga contabile corrente (prima = 1!) + TImporto _importo; // Importo su riga contabile + TImporto _residuo, _resval; // Residuo della riga contabile + int _riga_partite; // Riga corrente delle partite + bool _changed; // Flag di modifica partite + bool _valfirst; // La colonna della valuta precede le lire + + tipo_movimento _tipomov; // Dati per la creazione di un nuovo movimento + char _sezione; + TDate _datadoc; + TString _codpag, _descr, _numdoc; + + TDecoder _causali; // Decodificatore delle causali + +protected: + static bool annopart_handler(TMask_field& f, KEY k); + static bool numpart_handler(TMask_field& f, KEY k); + static bool partite_notify(TSheet_field& partite, int r, KEY k); + static bool scadenze_notify(TSheet_field& partite, int r, KEY k); + static bool show_all_handler(TMask_field& f, KEY k); + static bool edit_scadenza_handler(TMask_field& f, KEY k); + static bool nuovo_handler(TMask_field& f, KEY k); + static bool cambio_handler(TMask_field& f, KEY k); + + void add_importo(TToken_string& s, const TImporto& i, bool val = FALSE, int pos = -1); + void add_descrizione(TToken_string& s, const TRiga_partite& riga, int pos = -1); + TImporto get_importo(TToken_string& s, int pos) const; + + void fill_partite(); + + real aggiorna_residuo(); + + int update_partita(const TPartita& game, int prow); + void update_saldo_clifo(); + 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; + + char calcola_sezione() const; + void align_number(TMask_field& f) const; + long number_distance(const char* key, const char* num) const; + bool same_number(const char* key, const char* num) const; + void append_conto(TString& s) const; + +#ifdef __EXTRA__ + bool edit_fattura(TPartita& p, int nriga); + bool prima_nota(const long nreg); +#endif + + const TRiga_partite* cerca_prima_riga() const; + void aggiorna_valuta(const TValuta& val); + void aggiorna_sorelle(const TRiga_partite& part) const; + +public: + TSheet_field& partite() const { return (TSheet_field&)field(P_PARTITE); } + TSheet_field& scadenze() const { return (TSheet_field&)field(P_SCADENZE); } + const TBill& conto() const { return _conto; } + + const TImporto& residuo(bool val) const { return val ? _resval : _residuo; } + bool changed() const { return _changed; } + + TGame_mask(const TBill& bill, long numreg, int riga); + virtual ~TGame_mask() {} +}; + + + /////////////////////////////////////////////////////////// // Maschera pagamenti /////////////////////////////////////////////////////////// @@ -22,6 +97,7 @@ class TPay_mask : public TMask { TDate _datadoc; real _da_pagare, _pagabile; + const TGame_mask& _parent; TDecoder _causale; @@ -38,12 +114,13 @@ public: void set_pag(const TRectype& oldpag, const TRiga_scadenze& scad, const TImporto& importo); void get_pag(TRectype& oldpag) const; - TPay_mask(); + TPay_mask(const TGame_mask& parent); virtual ~TPay_mask() {} }; -TPay_mask::TPay_mask() - : TMask("cg2100s"), _causale(LF_CAUSALI, CAU_CODCAUS, CAU_DESCR) +TPay_mask::TPay_mask(const TGame_mask& parent) + : TMask("cg2100s"), _parent(parent), + _causale(LF_CAUSALI, CAU_CODCAUS, CAU_DESCR) { } @@ -118,10 +195,7 @@ void TPay_mask::set_pag(const TRectype& oldpag, const TRiga_scadenze& scad, const long numreg = sum.get_long(PART_NREG); const int numrig = sum.get_int(PART_NUMRIG); - if (in_valuta) - _pagabile = val.lit2val(residuo.valore()); - else - _pagabile = residuo.valore(); + _pagabile = _parent.residuo(in_valuta).valore(); TReal_field& resp = (TReal_field&)field(S_RESIDUOPAG); resp.set_decimals(in_valuta ? 3 : 0); @@ -186,8 +260,11 @@ void TPay_mask::gioca_cambi(int force) { const real totale = get(S_IMPORTO); const real totval = get(S_IMPORTOVAL); - const TValuta cambio(*this, S_VALUTA, S_DATACAMBIO, S_CAMBIO); - +#ifdef __EXTRA__ + const TValuta cambio(this, S_VALUTA, S_DATACAMBIO, S_CAMBIO); +#else + const TValuta cambio(_parent, P_VALUTA, P_DATACAMBIO, P_CAMBIO); +#endif if ( (force == 0x1 || totale.is_zero()) && !(totval.is_zero() || cambio.in_lire()) ) { const real new_totale = cambio.val2lit(totval); @@ -289,7 +366,7 @@ bool TPay_mask::cambio_handler(TMask_field& f, KEY k) if (k == K_TAB && f.focusdirty()) { TPay_mask& m = (TPay_mask&)f.mask(); - m.gioca_cambi(0x1); + m.gioca_cambi(); } return TRUE; } @@ -326,73 +403,6 @@ bool TPay_mask::conto_handler(TMask_field& f, KEY k) // Maschera partite /////////////////////////////////////////////////////////// -class TGame_mask : public TMask -{ - const TBill _conto; // Conto fisso del cliente/fornitore - long _numreg; // Numero movimento contabile - int _numrig; // Riga contabile corrente (prima = 1!) - TImporto _importo; // Importo su riga contabile - TImporto _residuo; // Residuo della riga contabile - int _riga_partite; // Riga corrente delle partite - bool _changed; // Flag di modifica partite - bool _valfirst; // La colonna della valuta precede le lire - - tipo_movimento _tipomov; // Dati per la creazione di un nuovo movimento - char _sezione; - TDate _datadoc; - TString _codpag, _descr, _numdoc; - - TDecoder _causali; // Decodificatore delle causali - -protected: - static bool annopart_handler(TMask_field& f, KEY k); - static bool numpart_handler(TMask_field& f, KEY k); - static bool partite_notify(TSheet_field& partite, int r, KEY k); - static bool scadenze_notify(TSheet_field& partite, int r, KEY k); - static bool show_all_handler(TMask_field& f, KEY k); - static bool edit_scadenza_handler(TMask_field& f, KEY k); - static bool nuovo_handler(TMask_field& f, KEY k); - static bool cambio_handler(TMask_field& f, KEY k); - - void add_importo(TToken_string& s, const TImporto& i, bool val = FALSE, int pos = -1); - void add_descrizione(TToken_string& s, const TRiga_partite& riga, int pos = -1); - TImporto get_importo(TToken_string& s, int pos) const; - - void fill_partite(); - real aggiorna_residuo(); - - int update_partita(const TPartita& game, int prow); - void update_saldo_clifo(); - 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; - - char calcola_sezione() const; - void align_number(TMask_field& f) const; - long number_distance(const char* key, const char* num) const; - bool same_number(const char* key, const char* num) const; - void append_conto(TString& s) const; - -#ifdef __EXTRA__ - bool edit_fattura(TPartita& p, int nriga); - bool prima_nota(const long nreg); -#endif - - const TRiga_partite* cerca_prima_riga() const; - void aggiorna_valuta(const TValuta& val); - void aggiorna_sorelle(const TRiga_partite& part) const; - -public: - TSheet_field& partite() const { return (TSheet_field&)field(P_PARTITE); } - TSheet_field& scadenze() const { return (TSheet_field&)field(P_SCADENZE); } - const TBill& conto() const { return _conto; } - - bool changed() const { return _changed; } - - TGame_mask(const TBill& bill, long numreg, int riga); - virtual ~TGame_mask() {} -}; - void TGame_mask::append_conto(TString& s) const { switch (conto().tipo()) @@ -518,12 +528,15 @@ bool TGame_mask::show_all_handler(TMask_field& f, KEY k) bool TGame_mask::cambio_handler(TMask_field& f, KEY k) { - if (k == K_TAB && f.focusdirty() && - yesno_box("Aggiornare gli importi dei pagamenti?")) + if (k == K_TAB && f.focusdirty()) { TGame_mask& gm = (TGame_mask&)f.mask(); - const TValuta val(gm, P_VALUTA, P_DATACAMBIO, P_CAMBIO); - gm.aggiorna_valuta(val); + const bool needed = app().partite().mov2rig(gm._numreg, gm._numrig) > 0; + if (needed && yesno_box("Aggiornare gli importi dei pagamenti?")) + { + const TValuta val(gm, P_VALUTA, P_DATACAMBIO, P_CAMBIO); + gm.aggiorna_valuta(val); + } } return TRUE; } @@ -553,10 +566,10 @@ real TGame_mask::aggiorna_residuo() const TValuta cambio(*this, P_VALUTA, P_DATACAMBIO, P_CAMBIO); if (cambio.in_valuta()) { - TImporto resval = _importo; cambio.lit2val(resval); - resval -= app().partite().importo_speso(_numreg, _numrig, TRUE); // Residuo della riga - resval.normalize(sez); - set(P_RESIDUOVAL, resval.valore()); + _resval = _importo; cambio.lit2val(_resval); + _resval -= app().partite().importo_speso(_numreg, _numrig, TRUE); // Residuo della riga + _resval.normalize(sez); + set(P_RESIDUOVAL, _resval.valore()); } } @@ -648,8 +661,7 @@ bool TGame_mask::partite_notify(TSheet_field& partite, int r, KEY k) gm.set(P_ANNO, anno); // Aggiorna campi di ricerca gm.set(P_NUMERO, num); - TValuta cambio; - bool prima_valuta = FALSE; + TString prima_valuta; // Codice prima valuta if (anno > 0) { @@ -664,17 +676,18 @@ bool TGame_mask::partite_notify(TSheet_field& partite, int r, KEY k) TToken_string riga_fattura(80); const int lastrow = game->last(); + + if (lastrow > 0 && prima_valuta.empty()) + prima_valuta = game->riga(lastrow).get(PART_CODVAL); + + const bool in_valuta = prima_valuta.not_empty(); + for (int ri = game->first(); ri <= lastrow; ri = game->succ(ri)) { const TRiga_partite& riga = game->riga(ri); if (!riga.is_fattura()) continue; - cambio.get(riga); - const bool in_valuta = cambio.in_valuta(); - if (in_valuta) - prima_valuta = TRUE; - riga_fattura.cut(0); riga_fattura.add(ri); riga_fattura.add(""); @@ -839,8 +852,8 @@ bool TGame_mask::partite_notify(TSheet_field& partite, int r, KEY k) { TToken_string& sp = scadenze.row(scadenze.add("")); sp.add("Saldo partita", 4); - if (cambio.in_valuta()) - sp << ' ' << cambio.codice(); + if (prima_valuta.not_empty()) + sp << ' ' << prima_valuta; gm.add_importo(sp, tot_lit); gm.add_importo(sp, tot_val, TRUE); @@ -850,15 +863,16 @@ bool TGame_mask::partite_notify(TSheet_field& partite, int r, KEY k) delete game; } - if (prima_valuta != gm._valfirst) + if (prima_valuta.not_empty() != gm._valfirst) { sheet.swap_columns(106, 107); // Scambia le colonne dell'importo in lire e in valuta - gm._valfirst = prima_valuta; + gm._valfirst = prima_valuta.not_empty(); } - sheet.force_update(); - if (sheet.items() > 0 && sheet.selected() > 0) + if (sheet.items() > 0) sheet.select(0, TRUE); + else + sheet.force_update(); main_app().end_wait(); } @@ -1425,8 +1439,10 @@ void TGame_mask::fill_partite() // correttamente gli archivi. if (gioco->ok()) { - const TBill& zio = gioco->conto(); - if (zio.tipo() <= ' ' || zio.sottoconto() == conto().sottoconto()) + const TBill& k = gioco->conto(); + const bool u = (k.tipo() > ' ' && k.sottoconto() == conto().sottoconto()) || + k == conto(); + if (u) update_partita(*gioco, -1); } } @@ -1487,7 +1503,7 @@ bool TGame_mask::edit_pagamento(TPartita& p, int nriga, int nrata, int nrigp) co TRectype oldpag = p.pagamento(nriga, nrata, nrigp); TRiga_partite& somma = p.riga(nrigp); - TPay_mask* pm = new TPay_mask; // We must create masks on the heap + TPay_mask* pm = new TPay_mask(*this); // We must create masks on the heap TPay_mask& m = *pm; if (nriga == TPartita::UNASSIGNED) diff --git a/cg/saldacon.h b/cg/saldacon.h index 99e32dd03..98cc17707 100755 --- a/cg/saldacon.h +++ b/cg/saldacon.h @@ -52,6 +52,7 @@ public: int pred(int r) const { return _recarr.pred_row(r); } int succ(int r) const { return _recarr.succ_row(r); } bool exist(int r) const { return _recarr.exist(r); } + int rows() const { return _recarr.rows(); } TTree_rectype(const TRectype& testata, const TRectype& riga, const char* num); TTree_rectype(int testata, int riga, const char* num);