Registrazione rate con scadenza coincidente

warning appropriati


git-svn-id: svn://10.65.10.50/trunk@2585 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
villa 1996-02-09 08:39:50 +00:00
parent 1df10c5463
commit 859357a423

View File

@ -679,6 +679,7 @@ TToken_string& TPagamento::set_rata(int index, const real& impval, const real& i
word TPagamento::validate() const word TPagamento::validate() const
{ {
word res = 0x0000; word res = 0x0000;
int warnscad = 0;
real r(0.0); real r(0.0);
int first = _tpr < 4 ? 0 : 1; int first = _tpr < 4 ? 0 : 1;
@ -741,11 +742,17 @@ word TPagamento::validate() const
for (i = 1; i < n_rate(); i++) for (i = 1; i < n_rate(); i++)
{ {
if (data_rata(i) <= d) if (data_rata(i) < d)
{ res |= P_SCAD; break; } { res |= P_SCAD; break; }
if (data_rata(i) == d)
warnscad++;
d = data_rata(i); d = data_rata(i);
} }
} }
if (warnscad && !yesno_box("N. %d rate cadono nello stesso giorno. Si desidera proseguire?", warnscad+1))
res |= P_SCAD;
return res; return res;
} }
@ -877,6 +884,7 @@ word TPagamento::recalc_rate(int row, bool is_perc_modified,
TDate lastdate = data_rata(0); TDate lastdate = data_rata(0);
int first = _tpr < 4 ? 0 : 1; int first = _tpr < 4 ? 0 : 1;
TString_array srate(_rate); // rate come erano TString_array srate(_rate); // rate come erano
int warnscad = 0;
if (oldscad <= 0) oldscad = _int_rate; if (oldscad <= 0) oldscad = _int_rate;
if (oldtype <= 0) oldtype = _def_tpr; if (oldtype <= 0) oldtype = _def_tpr;
@ -937,8 +945,9 @@ word TPagamento::recalc_rate(int row, bool is_perc_modified,
// controlla errore sulla data scadenza // controlla errore sulla data scadenza
if (i > 0) if (i > 0)
{ {
oldscad = (int)(lastdate - data_rata(i-1)); oldscad = lastscad = (int)(lastdate - data_rata(i-1));
if (oldscad <= 0l) return P_SCAD; if (oldscad < 0l) return P_SCAD;
// if (oldscad == 0l) warnscad++;
} }
else else
{ {
@ -967,7 +976,10 @@ word TPagamento::recalc_rate(int row, bool is_perc_modified,
long sc = atol(scad); long sc = atol(scad);
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 (row > 0 && sc == 0 &&
!yesno_box("Due o piu' rate cadranno nello stesso giorno. Si conferma l'immissione?"))
return P_SCAD;
if (sc > 10000L) return P_SCWIDE; if (sc > 10000L) return P_SCWIDE;
if (_mcomm && row > 0 && (sc % 30) != 0) if (_mcomm && row > 0 && (sc % 30) != 0)
return P_MCOMM; return P_MCOMM;
@ -1005,15 +1017,20 @@ word TPagamento::recalc_rate(int row, bool is_perc_modified,
if (_inited && i > 0) if (_inited && i > 0)
{ {
if (data_rata(i) <= data_rata(i-1)) if (data_rata(i) < data_rata(i-1))
return P_SCAD; return P_SCAD;
// else if (data_rata(i) == data_rata(i-1))
// warnscad ++;
} }
else if (_inited && lastdate < _inizio) else if (_inited && lastdate < _inizio)
return P_INIZIO; return P_INIZIO;
} }
} }
} }
// if (warnscad && !yesno_box("N. %d rate cadono nello stesso giorno. Si conferma l'immissione?", warnscad))
// return P_SCAD;
adjust_fixed_scad(); adjust_fixed_scad();
return P_OK; return P_OK;
} }