From 4b020940c705391880717122490c77aa842773aa Mon Sep 17 00:00:00 2001 From: alex Date: Thu, 4 Jan 1996 13:39:57 +0000 Subject: [PATCH] Correzioni per test sulle rate = 0 e sull' importo della prima riga quando ho le imposte git-svn-id: svn://10.65.10.50/trunk@2389 c028cbd2-c16b-5b4b-a496-9718f37d4682 --- cg/pagament.cpp | 23 +++++++++++++++++------ cg/pagament.h | 1 + 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/cg/pagament.cpp b/cg/pagament.cpp index 6efcad489..56b5d6920 100755 --- a/cg/pagament.cpp +++ b/cg/pagament.cpp @@ -587,12 +587,20 @@ word TPagamento::validate() const if (_inited) { - real tot; + real tot; + for (int i = 0; i < n_rate(); i++) - tot += tpay_rata(i); + { + const real tpay(tpay_rata(i)); + + if (tpay.is_zero()) + res |= P_ZERO; + tot += tpay; + } if (tot != _firstr+_secndr) - res |= P_TOTNC; + res |= P_TOTNC; + // check errori date scadenze (se istanziate) @@ -637,6 +645,8 @@ void TPagamento::strerr(word err, TString& s) } if (err & P_MCOMM) s << "Scadenze incompatibili con il mese commerciale\n"; + if (err & P_ZERO) + s << "Almeno una rata ha importo zero\n"; } const char* TPagamento::desc_tpr() const @@ -737,10 +747,11 @@ word TPagamento::recalc_rate(int row, bool is_perc_modified, { newv = new_value; rmax = is_perc_modified ? real(100.0) : (_tpr < 4 ? _firstr : _secndr); - real max_value(rmax); + real test_value(newv); if (_tpr > 0 && _tpr < 4 && row == 0) - max_value += _secndr; - if (newv > max_value) return P_RSUM; + test_value -= _secndr; + if (test_value < ZERO) return P_NEG; + if (test_value > rmax) return P_TROP; } bool exhausted = FALSE; diff --git a/cg/pagament.h b/cg/pagament.h index 846eabf5a..c1d2b3eb2 100755 --- a/cg/pagament.h +++ b/cg/pagament.h @@ -23,6 +23,7 @@ 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 class TPagamento : public TObject {