diff --git a/cg/cg2104.cpp b/cg/cg2104.cpp index 3c1ffddd6..d3150a769 100755 --- a/cg/cg2104.cpp +++ b/cg/cg2104.cpp @@ -74,6 +74,7 @@ bool TPrimanota_application::pag_notify(TSheet_field& ps, int r, KEY k) if (newu != ts.get(5)) // modificata ulteriore classificazione mod = m_ulc = TRUE; else if (m_tipo) { + // forza reset di ulc se si e' modificato il tipo rata m_ulc = TRUE; newu = ""; } @@ -147,9 +148,10 @@ bool TPrimanota_application::pag_notify(TSheet_field& ps, int r, KEY k) trw.add(newi,4); const real p = pag.recalc_percrata(r); ps.row(r).add(p.string(), 3); - rws.row(r) = ps.row(r); ps.force_update(r); } + if (mod) + rws.row(r) = ps.row(r); } if (ahiahi) // any error? Rimetti le righe com'erano prima { diff --git a/cg/pagament.cpp b/cg/pagament.cpp index 84e683b2c..091edb1fb 100755 --- a/cg/pagament.cpp +++ b/cg/pagament.cpp @@ -699,17 +699,17 @@ void TPagamento::strerr(word err, TString& s) { s = "Errore:\n"; if (err & P_RSUM) - s << "Le percentuali non sommano a 100\n"; + s << "- le percentuali non sommano a 100\n"; if (err & P_IMPNC) - s << "Le percentuali sono inconsistenti con gli importi\n"; + s << "- le percentuali sono inconsistenti con gli importi\n"; if (err & P_SCAD) - s << "Le scadenze non sono consecutive\n"; + s << "- le scadenze non sono consecutive\n"; if (err & P_INIZIO) - s << "La prima rata e' antecedente alla data del documento (" << _datadoc << ")\n"; // _inizio + s << "- la prima rata e' antecedente alla data del documento (" << _datadoc << ")\n"; // _inizio if (err & P_NEG) - s << "L'importo dato e' inferiore al minimo possibile\n"; + s << "- l'importo dato e' inferiore al minimo possibile\n"; if (err & P_TROP) - s << "L'importo dato e' superiore al massimo possibile\n"; + s << "- l'importo dato e' superiore al massimo possibile\n"; if (err & P_TOTNC) { const real tot = _firstr + _secndr; @@ -717,15 +717,17 @@ void TPagamento::strerr(word err, TString& s) for (int i = 0; i < n_rate(); i++) imp += tpay_rata(i); const char pic[3] = { '.', _round, '\0' }; - s << "La somma degli importi (" << imp.string(pic); + s << "- la somma degli importi (" << imp.string(pic); s << ") e' diversa dal\ntotale del pagamento (" << tot.string(pic) << ")\n"; } if (err & P_MCOMM) - s << "Scadenze incompatibili con il mese commerciale\n"; + s << "- scadenze incompatibili con il mese commerciale\n"; if (err & P_ZERO) - s << "Almeno una rata ha importo zero\n"; + s << "- almeno una rata ha importo zero\n"; if (err & P_SCWIDE) - s << "Le scadenze sono troppo distanti\n"; + s << "- le scadenze sono troppo distanti\n"; + if (err & P_TOOMANY) + s << "- il calcolo genera piu' di 999 rate!\n"; } const char* TPagamento::desc_tpr() const @@ -1036,6 +1038,7 @@ word TPagamento::change_value_uguali(int row, real user_val, bool is_perc) if ((to_share - user_div) < user_div) return 0; real div = to_share / user_div; real delta = to_share - (user_div * div.integer()); + if (div > real(999.0)) return P_TOOMANY; for (int i = 0; i < div.integer(); i++) { if (n_rate() <= i) add_rata(); @@ -1088,6 +1091,8 @@ word TPagamento::change_value_uguali(int row, real user_val, bool is_perc) } real div = (to_share - first_imp)/user_val; if (div < real(1.0)) return P_TROP; + if (div > real(999.0)) return P_TOOMANY; + real delta = (to_share - first_imp) - user_val * real(div.integer()); for (int i = 1; i < div.integer()+1l; i++) { @@ -1134,6 +1139,7 @@ word TPagamento::change_value_uguali_prossima(int row, real user_val, bool is_pe real div = to_share/user_div; if (div < real(1.0)) return P_TROP; + if (div > real(999.0)) return P_TOOMANY; real delta = to_share - (user_div * div.integer()); for (i = row; i < (row + div.integer()); i++) @@ -1176,6 +1182,7 @@ word TPagamento::change_value_uguali_possible(int row, real user_val, bool is_pe real div = to_share/user_div; if (div < real(1.0)) return P_TROP; + if (div > real(999.0)) return P_TOOMANY; real delta = to_share - (user_div * div.integer()); for (i = row; i < (row + div.integer()); i++) @@ -1592,7 +1599,6 @@ void TPagamento::set_sheet(TSheet_field& sf, int sscad) } else { -// sf.reset(); long scr = 0L; for (int i = 0; i < n_rate(); i++) { diff --git a/cg/pagament.h b/cg/pagament.h index 2a839e2a8..afb37b9a3 100755 --- a/cg/pagament.h +++ b/cg/pagament.h @@ -14,17 +14,18 @@ #endif // Error codes for pagation -const word P_OK = 0x0000; // ok -const word P_RSUM = 0x0001; // percentages do not sum up to 100 -const word P_IMPNC = 0x0002; // inconsistenza percentuali / importi -const word P_SCAD = 0x0004; // scadenze non consecutive -const word P_INIZIO = 0x0008; // data 1a rata < data inizio pagamenti -const word P_NEG = 0x0010; // importo specificato < minimo possibile -const word P_TROP = 0x0020; // importo specificato > massimo possibile -const word P_TOTNC = 0x0040; // totale importi != totale pagamento -const word P_MCOMM = 0x0080; // inconsistenza mese commerciale/scadenze -const word P_ZERO = 0x0100; // importo di una rata uguale a zero -const word P_SCWIDE = 0x0200; // date di scadenza separate da piu' di 10000 giorni +const word P_OK = 0x0000; // ok +const word P_RSUM = 0x0001; // percentages do not sum up to 100 +const word P_IMPNC = 0x0002; // inconsistenza percentuali / importi +const word P_SCAD = 0x0004; // scadenze non consecutive +const word P_INIZIO = 0x0008; // data 1a rata < data inizio pagamenti +const word P_NEG = 0x0010; // importo specificato < minimo possibile +const word P_TROP = 0x0020; // importo specificato > massimo possibile +const word P_TOTNC = 0x0040; // totale importi != totale pagamento +const word P_MCOMM = 0x0080; // inconsistenza mese commerciale/scadenze +const word P_ZERO = 0x0100; // importo di una rata uguale a zero +const word P_SCWIDE = 0x0200; // date di scadenza separate da piu' di 10000 giorni +const word P_TOOMANY = 0x0400; // troppe rate (piu' di 999) class TPagamento : public TObject {