Corrette alcune rimanenti caciarole

git-svn-id: svn://10.65.10.50/trunk@2102 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
villa 1995-11-07 11:37:38 +00:00
parent 09381b469a
commit e5e953f263
2 changed files with 164 additions and 149 deletions

View File

@ -7,6 +7,8 @@
#include <scadenze.h> #include <scadenze.h>
#include <pagsca.h> #include <pagsca.h>
inline void swap(int& x, int& y) {int tmp = x; x = y; y = tmp; }
int TPagamento::_rata_ifield(int n, int f) const int TPagamento::_rata_ifield(int n, int f) const
{ {
TToken_string& t = (TToken_string&)_rate[n]; TToken_string& t = (TToken_string&)_rate[n];
@ -52,15 +54,20 @@ void TPagamento::set_inizio(const TDate& d)
void TPagamento::set_intervallo_rate(int in) void TPagamento::set_intervallo_rate(int in)
{ {
_dirty = TRUE;
_int_rate = in;
if (_mcomm && (in % 30) != 0) if (_mcomm && (in % 30) != 0)
{
if (yesno_box("E' specificato \"mese commerciale\". Si desidera annullarlo?"))
_mcomm = FALSE; _mcomm = FALSE;
for (int i = 0; i < n_rate(); i++) else
return;
}
for (int i = 1; i < n_rate(); i++)
{ {
TToken_string& ts = rata(i); TToken_string& ts = rata(i);
ts.add(i == 0 ? (scad_rata(0) == 0 ? 0 : in) : in, 0); ts.add(in, 0);
} }
_int_rate = in;
_dirty = TRUE;
} }
void TPagamento::set_mese_commerciale(bool v, int& sscad) void TPagamento::set_mese_commerciale(bool v, int& sscad)
@ -499,8 +506,6 @@ TToken_string& TPagamento::set_rata(int index, const real& howmuch, const real&
return *tt; return *tt;
} }
word TPagamento::validate() const word TPagamento::validate() const
{ {
word res = 0x0000; word res = 0x0000;
@ -559,6 +564,8 @@ void TPagamento::strerr(word err, TString& s)
s << "\n L'importo dato e' superiore al massimo possibile"; s << "\n L'importo dato e' superiore al massimo possibile";
if (err & P_TOTNC) if (err & P_TOTNC)
s << "\n La somma degli importi e' diversa dal totale del pagamento"; s << "\n La somma degli importi e' diversa dal totale del pagamento";
if (err & P_MCOMM)
s << "\n Scadenze incompatibili con il mese commerciale";
} }
const char* TPagamento::desc_tpr() const const char* TPagamento::desc_tpr() const
@ -691,6 +698,7 @@ word TPagamento::recalc_rate(int row, bool is_perc_modified,
{ {
rata(row).add(ulc, 5); rata(row).add(ulc, 5);
srate.row(row).add(ulc, 5); srate.row(row).add(ulc, 5);
need_recalc = TRUE;
} }
if (scad != NULL) if (scad != NULL)
@ -730,7 +738,8 @@ word TPagamento::recalc_rate(int row, bool is_perc_modified,
for (int i = 0; i < row; i ++) for (int i = 0; i < row; i ++)
sc -= scad_rata(i); sc -= scad_rata(i);
if (sc < 0 || (row > 0 && sc == 0)) return P_SCAD; if (sc < 0 || (row > 0 && sc == 0)) return P_SCAD;
if (_mcomm && (sc % 30) != 0) _mcomm = FALSE; if (_mcomm && (sc % 30) != 0)
return P_MCOMM;
TToken_string& tt = rata(row); TToken_string& tt = rata(row);
TToken_string& ss = (TToken_string&)srate[row]; TToken_string& ss = (TToken_string&)srate[row];
tt.add(sc,0); tt.add(sc,0);
@ -814,6 +823,7 @@ word TPagamento::recalc_rate(int row, bool is_perc_modified,
int type = oldtype; int type = oldtype;
TString nulc = oldulc; TString nulc = oldulc;
int nscd = oldscad; int nscd = oldscad;
int frstd = scad_rata(0);
const int frs = (rdiff == 3 || rdiff == 4) ? row+1 : first; const int frs = (rdiff == 3 || rdiff == 4) ? row+1 : first;
const real mx = (rdiff == 3 || rdiff == 4) ? remainder : rmax; const real mx = (rdiff == 3 || rdiff == 4) ? remainder : rmax;
@ -847,7 +857,7 @@ word TPagamento::recalc_rate(int row, bool is_perc_modified,
TToken_string& trt = (TToken_string&)srate[k]; TToken_string& trt = (TToken_string&)srate[k];
if (_inited) dd = trt.get(3); if (_inited) dd = trt.get(3);
type = atoi(trt.get(2)); type = atoi(trt.get(2));
nscd = k == 0 ? 0 : atoi(trt.get(0)); nscd = k == 0 ? frstd : atoi(trt.get(0));
if (type == 0) type = 1; if (type == 0) type = 1;
if (k > 0 && nscd == 0) nscd = oldscad; if (k > 0 && nscd == 0) nscd = oldscad;
if (_inited && dd == lastdate && k > 0) if (_inited && dd == lastdate && k > 0)
@ -915,7 +925,7 @@ word TPagamento::recalc_rate(int row, bool is_perc_modified,
TToken_string& trt = (TToken_string&)srate[j]; TToken_string& trt = (TToken_string&)srate[j];
if (_inited) dd = trt.get(3); if (_inited) dd = trt.get(3);
type = atoi(trt.get(2)); type = atoi(trt.get(2));
nscd = j == 0 ? 0 : atoi(trt.get(0)); nscd = atoi(trt.get(0));
if (type == 0) type = 1; if (type == 0) type = 1;
if (j > 0 && nscd == 0) nscd = oldscad; if (j > 0 && nscd == 0) nscd = oldscad;
if (_inited && dd == lastdate && j > 0) if (_inited && dd == lastdate && j > 0)
@ -949,7 +959,6 @@ word TPagamento::recalc_rate(int row, bool is_perc_modified,
remove_rata(j); remove_rata(j);
break; break;
} }
// }
sum += newv; sum += newv;
} }
else // rdiff == 4; uguali finche' possibile else // rdiff == 4; uguali finche' possibile
@ -970,13 +979,14 @@ word TPagamento::recalc_rate(int row, bool is_perc_modified,
TToken_string& trt = (TToken_string&)srate[j]; TToken_string& trt = (TToken_string&)srate[j];
if (_inited) dd = trt.get(3); if (_inited) dd = trt.get(3);
type = atoi(trt.get(2)); type = atoi(trt.get(2));
nscd = j == 0 ? 0 : atoi(trt.get(0)); nscd = atoi(trt.get(0));
if (type == 0) type = 1; if (type == 0) type = 1;
if (j > 0 && nscd == 0) nscd = oldscad; if (j > 0 && nscd == 0) nscd = oldscad;
if (_inited && dd == lastdate && j > 0) if (_inited && dd == lastdate && j > 0)
next_scad(dd,nscd,mcomm,j); next_scad(dd,nscd,mcomm,j);
} }
else if (_inited) next_scad(dd,nscd,mcomm,j); else if (_inited)
next_scad(dd,nscd,mcomm,j);
TToken_string& ttr = set_rata(j, is_perc_modified ? newv : ZERO, TToken_string& ttr = set_rata(j, is_perc_modified ? newv : ZERO,
nscd, type); nscd, type);
@ -989,7 +999,6 @@ word TPagamento::recalc_rate(int row, bool is_perc_modified,
} }
} }
} }
} }
else // exhausted else // exhausted
{ {
@ -1057,7 +1066,6 @@ word TPagamento::recalc_rate(int row, bool is_perc_modified,
// real tot = tpay_rata(0) + _secndr; // real tot = tpay_rata(0) + _secndr;
// tr.add(tot.string(), 4); // tr.add(tot.string(), 4);
// } // }
} }
need_recalc = TRUE; need_recalc = TRUE;
@ -1088,7 +1096,7 @@ word TPagamento::recalc_rate(int row, bool is_perc_modified,
if (data_rata(i) <= data_rata(i-1)) if (data_rata(i) <= data_rata(i-1))
return P_SCAD; return P_SCAD;
} }
else if (lastdate < _inizio) else if (_inited && lastdate < _inizio)
return P_INIZIO; return P_INIZIO;
} }
} }
@ -1123,7 +1131,7 @@ bool TPagamento::read(TTable* t, TTable* r)
_fixd[1] = t->get_int("I1"); _fixd[1] = t->get_int("I1");
_fixd[2] = t->get_int("I2"); _fixd[2] = t->get_int("I2");
// TBI aggiusta _inizio secondo INSCAD; vedi mese commerciale etc. // aggiusta _inizio secondo INSCAD; vedi mese commerciale etc.
if (_inscad == 'M') if (_inscad == 'M')
{ {
if (_mcomm) _inizio.set_day(_inizio.month() == 2 ? 28 : 30); if (_mcomm) _inizio.set_day(_inizio.month() == 2 ? 28 : 30);
@ -1385,10 +1393,15 @@ void TPagamento::set_sheet(TSheet_field& sf, int sscad)
} }
else else
if (_rate.items() > 0) // not inited: set edit sheet if (_rate.items() > 0) // not inited: set edit sheet
<<<<<<< pagament.cpp
{
if (sf.items() > 0) sf.destroy();
=======
{ {
TString_array& arr = sf.rows_array(); TString_array& arr = sf.rows_array();
arr.destroy(); // Avoid screen update by now arr.destroy(); // Avoid screen update by now
>>>>>>> 1.44
for (int i = 0, scr = 0; i < n_rate(); i++) for (int i = 0, scr = 0; i < n_rate(); i++)
{ {
TToken_string& s = sf.row(-1); TToken_string& s = sf.row(-1);

View File

@ -22,6 +22,7 @@ const word P_INIZIO = 0x0008; // data 1a rata < data inizio pagamenti
const word P_NEG = 0x0010; // importo specificato < minimo possibile const word P_NEG = 0x0010; // importo specificato < minimo possibile
const word P_TROP = 0x0020; // importo specificato > massimo possibile const word P_TROP = 0x0020; // importo specificato > massimo possibile
const word P_TOTNC = 0x0040; // totale importi != totale pagamento const word P_TOTNC = 0x0040; // totale importi != totale pagamento
const word P_MCOMM = 0x0080; // inconsistenza mese commerciale/scadenze
class TPagamento : public TObject class TPagamento : public TObject
{ {
@ -81,6 +82,7 @@ public:
bool mese_commerciale() const { return _mcomm; } bool mese_commerciale() const { return _mcomm; }
bool rate_differenziate() const { return _rdiff; } bool rate_differenziate() const { return _rdiff; }
int tipo_prima_rata() const { return _tpr; } int tipo_prima_rata() const { return _tpr; }
int intervallo_rate() const { return _int_rate; }
int decs() const { return _round; } int decs() const { return _round; }
const TString& name() const { return _name; } const TString& name() const { return _name; }