From b799d17f08a13aa14575b39ec631e6aff766e437 Mon Sep 17 00:00:00 2001 From: guy Date: Fri, 5 Jan 1996 15:17:50 +0000 Subject: [PATCH] Corretti ultimi :-) errori della Gabri git-svn-id: svn://10.65.10.50/trunk@2395 c028cbd2-c16b-5b4b-a496-9718f37d4682 --- cg/cg2100.cpp | 5 ++++ cg/cg2100s.uml | 2 +- cg/cg2102.cpp | 12 ++------- cg/cg2102.h | 1 + cg/cg2104.cpp | 49 +++++++++++++++--------------------- cg/cg2105.cpp | 24 +++++++++++++----- cg/conto.cpp | 41 +++++++++++++++++++++++++----- cg/conto.h | 12 +++++++-- cg/pagament.cpp | 67 ++++++++++++++++++++++++++++++++++++++----------- 9 files changed, 145 insertions(+), 68 deletions(-) diff --git a/cg/cg2100.cpp b/cg/cg2100.cpp index 467dd82c1..7dafef16c 100755 --- a/cg/cg2100.cpp +++ b/cg/cg2100.cpp @@ -426,6 +426,11 @@ TMask* TPrimanota_application::get_mask(int mode) return load_mask(_iva == nessuna_iva ? 1 : 2); } +bool TPrimanota_application::firm_change_enabled() const +{ + const bool ok = _msk[2] == NULL && TRelation_application::firm_change_enabled(); + return ok; +} void TPrimanota_application::on_firm_change() { diff --git a/cg/cg2100s.uml b/cg/cg2100s.uml index fb34ef136..ddc5154f9 100755 --- a/cg/cg2100s.uml +++ b/cg/cg2100s.uml @@ -233,6 +233,7 @@ BEGIN OUTPUT S_DESCRCONTO DESCR CHECKTYPE NORMAL VALIDATE REQIF_FUNC 1 S_IMPORTO + WARNING "Contropartita assente" GROUP 2 END @@ -261,7 +262,6 @@ BEGIN OUTPUT S_CODDESC CODTAB OUTPUT S_DESCAGG S0 CHECKTYPE NORMAL - VALIDATE NOT_EMPTY_CHECK_FIELD END STRING S_DESCAGG 50 diff --git a/cg/cg2102.cpp b/cg/cg2102.cpp index f4ee6936f..8aa6bc37d 100755 --- a/cg/cg2102.cpp +++ b/cg/cg2102.cpp @@ -1978,17 +1978,9 @@ bool TPrimanota_application::totdocval_handler(TMask_field& f, KEY key) { app().gioca_cambi(); - const TMask& m = f.mask(); + TMask& m = f.mask(); if (app().is_fattura() && m.insert_mode()) // Se e' una fattura - { - TPagamento& pag = app().pagamento(); - const real totval(f.get()); - const TValuta cambio(m, SK_VALUTA, SK_DATACAMBIO, SK_CAMBIO); - const real impostaval = cambio.lit2val(m.get_real(F_IMPOSTE)); - pag.set_total(totval, impostaval, ZERO); - pag.set_rate_auto(); - pag.set_sheet(app().pags()); - } + app().set_scadenze(m); } return TRUE; diff --git a/cg/cg2102.h b/cg/cg2102.h index e692b12f4..a27f48766 100755 --- a/cg/cg2102.h +++ b/cg/cg2102.h @@ -152,6 +152,7 @@ protected: // TRelation_application virtual int rewrite(const TMask& m); virtual bool remove(); virtual void write_enable(bool) {} + virtual bool firm_change_enabled() const; protected: void check_saldi(); diff --git a/cg/cg2104.cpp b/cg/cg2104.cpp index cc8b3539c..dd3baa0e7 100755 --- a/cg/cg2104.cpp +++ b/cg/cg2104.cpp @@ -376,22 +376,18 @@ bool TPrimanota_application::cambio_handler(TMask_field& f, KEY key) { app().gioca_cambi(0x1); // Forza il ricalcolo del totale in lire + TMask& m = f.mask(); if (app().is_fattura()) { TPagamento& pag = app().pagamento(); const real ex(f.get()); pag.set_cambio(ex); // Aggiorna cambio sul pagamento - TMask& m = f.mask(); m.set(FS_CAMBIO, ex); // Copia a pagina 3 - if (m.insert_mode()) // Ricalcola tutte le rate - { - pag.set_rate_auto(); - TSheet_field& ps = (TSheet_field&)m.field(FS_RATESHEET); - pag.set_sheet(ps); - app().pag_rows() = ps.rows_array(); - } + TSheet_field& ps = (TSheet_field&)m.field(FS_RATESHEET); + pag.set_sheet(ps); + app().pag_rows() = ps.rows_array(); } } return TRUE; @@ -540,19 +536,19 @@ void TPrimanota_application::set_scadenze(TMask& m) real imponibile, imposta; const real spese(0.0); - const real cambio(m.get(SK_CAMBIO)); TPagamento& pag = pagamento(); - if (cambio <= 1.0) + pag.set_cambio(m.get_real(SK_CAMBIO)); + + if (pag.in_valuta()) { - imposta = m.get_real(F_IMPOSTE); - imponibile = m.get_real(F_TOTALE) - imposta; + imposta = m.get_real(F_IMPOSTE) / pag.cambio(); imposta.round(3); + imponibile = m.get_real(SK_TOTDOCVAL) - imposta; } else { - pag.set_cambio(cambio); - imponibile = m.get_real(SK_TOTDOCVAL); - imposta = ZERO; + imposta = m.get_real(F_IMPOSTE); + imponibile = m.get_real(F_TOTALE) - imposta; } if (m.field(FS_RECALC).enabled()) @@ -618,17 +614,17 @@ bool TPrimanota_application::read_scadenze(TMask& m) real spese(0.0); if (in_valuta) { - cambio.lit2val(imposta); + cambio.lit2val(imposta); // Converte in valuta imposte e spese cambio.lit2val(spese); } - imponibile -= imposta; + imponibile -= imposta; // Nel pagamento il totale deve essere senza imposta pag.set_total(imponibile, imposta, spese); TSheet_field& ps = (TSheet_field&)m.field(FS_RATESHEET); - pag.zap_rate(); - for (int i = partita.rate(); i > 0; i--) + pag.zap_rate(); // Azzera pagamento + for (int i = 1; i <= partita.rate(); i++) // E' necessario andare in avanti!!! { const TRiga_scadenze& scadenza = partita.rata(i); real importo = scadenza.get(SCAD_IMPORTO); @@ -682,14 +678,9 @@ void TPrimanota_application::write_scadenze(const TMask& m) if (anno > 0 && !numpart.blank()) { - const TString ndoc(m.get(F_NUMDOC)); const int tmov = causale().tipomov(); - const TDate ddoc(m.get(F_DATADOC)); - const TDate dreg(m.get(F_DATAREG)); - const TString reg (causale().reg().name()); const TString desc(m.get(F_DESCR)); const TString codpag(m.get(F_CODPAG)); - const long protiva = m.get_long(F_PROTIVA); const TString codcaus(causale().codice()); const TValuta cambio (m, SK_VALUTA, SK_DATACAMBIO, SK_CAMBIO); const TString agente (m.get(FS_AGENTE)); @@ -706,13 +697,13 @@ void TPrimanota_application::write_scadenze(const TMask& m) partita.put(PART_TIPOMOV, tmov); partita.put(PART_NREG, nreg); partita.put(PART_NUMRIG, 1); - partita.put(PART_DATAREG, dreg); - partita.put(PART_DATADOC, ddoc); - partita.put(PART_NUMDOC, ndoc); + partita.put(PART_DATAREG, m.get(F_DATAREG)); + partita.put(PART_DATADOC, m.get(F_DATADOC)); + partita.put(PART_NUMDOC, m.get(F_NUMDOC)); partita.put(PART_DESCR, desc); partita.put(PART_CODCAUS, codcaus); - partita.put(PART_REG, reg); - partita.put(PART_PROTIVA, protiva); + partita.put(PART_REG, causale().reg().name()); + partita.put(PART_PROTIVA, m.get_long(F_PROTIVA)); partita.put(PART_SEZ, sezione); partita.put(PART_IMPTOTDOC, m.get(F_TOTALE)); cambio.put(partita); diff --git a/cg/cg2105.cpp b/cg/cg2105.cpp index 9201d7e10..5403a45bf 100755 --- a/cg/cg2105.cpp +++ b/cg/cg2105.cpp @@ -27,7 +27,7 @@ protected: static bool importolire_handler(TMask_field& f, KEY k); static bool cambio_handler(TMask_field& f, KEY k); static bool datapag_handler(TMask_field& f, KEY k); - + static bool conto_handler(TMask_field& f, KEY k); void gioca_cambi(int force = 0x0); public: @@ -147,7 +147,9 @@ void TPay_mask::set_pag(const TRectype& oldpag, const TRiga_scadenze& scad, disable(-4); _datadoc = sum.get_date(PART_DATADOC); - set_handler(S_DATAPAG, datapag_handler); + set_handler(S_DATAPAG, datapag_handler); + set_handler(S_GRUPPO, conto_handler); + set_handler(S_CONTO, conto_handler); const bool mostra_conto = !sum.is_nota_credito(); #endif @@ -276,6 +278,20 @@ bool TPay_mask::datapag_handler(TMask_field& f, KEY k) return TRUE; } +bool TPay_mask::conto_handler(TMask_field& f, KEY k) +{ + if (k == K_TAB && f.focusdirty()) + { + TMask& m = f.mask(); + TBill conto; conto.get(m, S_GRUPPO, S_CONTO, S_SOTTOCONTO); + const TString& desc = conto.descrizione(); + if (desc.empty()) + m.reset(S_SOTTOCONTO); + m.set(S_DESCRCONTO, desc); + } + return TRUE; +} + /////////////////////////////////////////////////////////// // Maschera partite @@ -1433,10 +1449,6 @@ bool TGame_mask::edit_pagamento(TPartita& p, int nriga, int nrata, int nrigp) co bool TPrimanota_application::edit_partite(const TMask& m, int riga) { - const TImporto imp = get_cgs_imp(riga); - if (imp.is_zero()) // Esci se importo e' nullo - return FALSE; - const char tipo = m.get(103)[0]; const int gruppo = m.get_int(104); const int conto = m.get_int(105); diff --git a/cg/conto.cpp b/cg/conto.cpp index 4a848f827..ca0704d4a 100755 --- a/cg/conto.cpp +++ b/cg/conto.cpp @@ -2,6 +2,7 @@ #include #include +#include #include #include "conto.h" @@ -126,6 +127,34 @@ bool TBill::get(const TRectype& r, bool c) return ok(); } +void TBill::set(TMask& m, short g, short c, short s, short t, short d) const +{ + m.set(g, gruppo()); + m.set(c, conto()); + m.set(s, sottoconto()); + if (t) + { + char typ[2] = { tipo(), '\0' }; + m.set(t, typ); + } + if (d) + m.set(d, ((TBill*)this)->descrizione()); +} + +void TBill::get(const TMask& m, short g, short c, short s, short t, short d) +{ + const int gr = m.get_int(g); + const int co = m.get_int(c); + const long so = m.get_long(s); + char ti = ' '; + if (t) + ti = m.get(t)[0]; + TString80 de; + if (d) + de = m.get(d); + set(gr, co, so, ti, de); +} + // Certified 100% bool TBill::ok() const @@ -182,7 +211,7 @@ bool TBill::find() _sospeso = clifo.get_bool("SOSPESO"); const char tipoa = clifo.get_char("TIPOAPER"); - if (tipoa == 'F') + if (tipoa == 'F') // Se persona fisica allora aggiusta la ragione sociale { TString nome(_descrizione.mid(30)); if (nome.not_empty()) @@ -206,8 +235,7 @@ bool TBill::find() bool TBill::read(TRectype &r) { - TLocalisamfile pcon(LF_PCON, FALSE); - pcon.setkey(1); + TLocalisamfile pcon(LF_PCON); pcon.put("GRUPPO", _gruppo); pcon.put("CONTO", _conto); pcon.put("SOTTOCONTO", _sottoconto); @@ -246,12 +274,13 @@ int TBill::tipo_att() } // Certified 99% -const TString& TBill::descrizione() +const TString& TBill::descrizione() const { if (_descrizione.empty() && !empty()) { - if (!find()) - _descrizione = "Sconosciuto"; + TBill& myself = (TBill&)*this; + if (!myself.find()) + myself._descrizione = "Sconosciuto"; } return _descrizione; } diff --git a/cg/conto.h b/cg/conto.h index 4a438a28e..eb286afa0 100755 --- a/cg/conto.h +++ b/cg/conto.h @@ -2,9 +2,14 @@ #define __CONTO_H #ifndef __ISAM_H -#include +class TRectype; #endif +#ifndef __MASK_H +class TMask; +#endif + + class TBill : public TSortable { char _tipo; // ' ' = Conto, 'C' = Cliente, 'F' = 'Fornitore' @@ -47,7 +52,7 @@ public: long codclifo() const { return _sottoconto; } bool find(); - const TString& descrizione(); + const TString& descrizione() const; int tipo_cr(); void tipo_cr(int tcr) { _tipo_cr = tcr; } @@ -59,6 +64,9 @@ public: void put(TRectype& r, bool contro = FALSE) const; bool get(const TRectype& r, bool contro = FALSE); + void set(TMask& m, short g, short c, short s, short t = 0, short d = 0) const; + void get(const TMask& m, short g, short c, short s, short t = 0, short d = 0); + const char* string(int mode = 0); }; diff --git a/cg/pagament.cpp b/cg/pagament.cpp index 56b5d6920..43f0ddeed 100755 --- a/cg/pagament.cpp +++ b/cg/pagament.cpp @@ -326,25 +326,63 @@ void TPagamento::set_numero_rate(int n, int sscad, int rdiff) } void TPagamento::set_cambio(const real& cambio) -{ +{ + const bool era_valuta = _cambio != 1.0; + if (cambio.sign() <= 0) _cambio = 1.0; else _cambio = cambio; - set_round(_cambio == 1.0 ? 0 : 3); - + const bool in_valuta = _cambio != 1.0; - real lit; - for (int i = _rate.items()-1; i >= 0; i--) + set_round(in_valuta ? 3 : 0); // Ricalcola arrotondamento + + real imp; // Importo di parcheggio + + if (era_valuta) { - TToken_string& row = (TToken_string&)_rate[i]; + for (int i = _rate.items()-1; i >= 0; i--) + { + TToken_string& row = (TToken_string&)_rate[i]; + if (in_valuta) + { + imp = tpay_rata(i) * _cambio; imp.round(0); + row.add(imp.string(), 7); + } + else + { + imp = tlit_rata(i); + row.add(imp.string(), 4); + row.add("", 7); + } + } + + if (!in_valuta) + { + real imponibile = _imponibile * _cambio; imponibile.round(_round); + real imposta = _imposta * _cambio; imposta.round(_round); + real spese = _spese * _cambio; spese.round(_round); + set_total(imponibile, imposta, spese); + } + } + else + { if (in_valuta) { - lit = tpay_rata(i) * _cambio; - row.add(lit.string(), 7); + for (int i = _rate.items()-1; i >= 0; i--) + { + TToken_string& row = (TToken_string&)_rate[i]; + imp = tpay_rata(i); + row.add(imp.string(), 7); + imp /= cambio; imp.round(_round); + row.add(imp.string() , 4); + } + + real imponibile = _imponibile / _cambio; imponibile.round(_round); + real imposta = _imposta / _cambio; imposta.round(_round); + real spese = _spese / _cambio; spese.round(_round); + set_total(imponibile, imposta, spese); } - else - row.add("", 7); } } @@ -640,8 +678,9 @@ void TPagamento::strerr(word err, TString& s) real imp; for (int i = 0; i < n_rate(); i++) imp += tpay_rata(i); - s << "La somma degli importi (" << imp.string("."); - s << ") e' diversa dal totale del pagamento (" << tot.string(".") << ")\n"; + const char pic[3] = { '.', _round, '\0' }; + s << "La somma degli importi (" << imp.string(pic); + s << ") e' diversa dal totale del pagamento (" << tot.string(pic) << ")\n"; } if (err & P_MCOMM) s << "Scadenze incompatibili con il mese commerciale\n"; @@ -1497,7 +1536,7 @@ void TPagamento::set_sheet(TSheet_field& sf, int sscad) if (_inited) { - const bool in_valuta = _cambio > 1.0; + const bool in_valuta = _cambio != 1.0; // si istanzia uno sheet di primanota for (int i = 0; i < n_rate(); i++) @@ -1534,7 +1573,7 @@ void TPagamento::set_sheet(TSheet_field& sf, int sscad) } else { - sf.destroy(); + sf.reset(); for (int i = 0, scr = 0; i < n_rate(); i++) { TToken_string& s = sf.row(-1);