Nuove cacchiate spappolate

git-svn-id: svn://10.65.10.50/trunk@2158 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
villa 1995-11-16 09:56:22 +00:00
parent 36dc951242
commit f084026c5a
3 changed files with 128 additions and 106 deletions

View File

@ -75,7 +75,9 @@ bool TPrimanota_application::pag_notify(TSheet_field& ps, int r, KEY k)
break; break;
case K_DEL: case K_DEL:
case K_INS: case K_INS:
doit = FALSE; // permette aggiunta e cancellazione solo se non c'e'
// ricalcolo automatico
doit = !recalc;
break; break;
default: default:
break; break;
@ -124,7 +126,8 @@ bool TPrimanota_application::pag_notify(TSheet_field& ps, int r, KEY k)
{ {
if (recalc) if (recalc)
{ {
beep(); TString err(80); pag.strerr(ahiahi,err);
warning_box(err);
ps.row(r) = rws.row(r); ps.row(r) = rws.row(r);
ps.force_update(r); ps.force_update(r);
} }

View File

@ -307,38 +307,10 @@ void TPagamento::next_scad(TDate& d, int scad, bool mcomm, int rata)
if (!last && dy < d.day()) if (!last && dy < d.day())
d.set_day(dy); d.set_day(dy);
} }
else else d += scad;
{
d += scad;
}
// riaggiusta se ci sono scadenze fissate
if (_fixd[0] != 0 || _fixd[1] != 0 || _fixd[2] != 0)
{
for (int i = 0; i < 3; i++)
{
if (_fixd[i] > d.day())
{
if (d.last_day(d.month(), d.year()) >= _fixd[i])
d.set_day(_fixd[i]);
else d.set_end_month();
break;
}
}
if (i == 3)
{
if (_fixd[0] > 0 && _fixd[0] < d.day())
{
d.set_day(_fixd[0]);
d.set_month(d.month() == 12 ? 1 : d.month() + 1);
}
}
}
} }
void TPagamento::set_default_type(int type, bool change_existing) void TPagamento::set_default_type(int type, bool change_existing)
{ {
_def_tpr = type; _def_tpr = type;
@ -545,6 +517,7 @@ word TPagamento::validate() const
TDate d(data_rata(0)); TDate d(data_rata(0));
if (d < _inizio) if (d < _inizio)
res |= P_INIZIO; res |= P_INIZIO;
for (i = 1; i < n_rate(); i++) for (i = 1; i < n_rate(); i++)
{ {
if (data_rata(i) <= d) if (data_rata(i) <= d)
@ -681,7 +654,7 @@ word TPagamento::recalc_rate(int row, bool is_perc_modified,
bool exhausted = FALSE; bool exhausted = FALSE;
for (int i = first; i < srate.items(); i++) for (int i = 0 /* first */; i < srate.items(); i++)
{ {
if (i == row) if (i == row)
{ {
@ -1079,6 +1052,9 @@ word TPagamento::recalc_rate(int row, bool is_perc_modified,
// } // }
} }
// sistema scadenze fisse
adjust_fixed_scad();
need_recalc = TRUE; need_recalc = TRUE;
return P_OK; return P_OK;
} // new_value != NULL } // new_value != NULL
@ -1112,6 +1088,7 @@ word TPagamento::recalc_rate(int row, bool is_perc_modified,
} }
} }
adjust_fixed_scad();
return P_OK; return P_OK;
} }
@ -1302,6 +1279,9 @@ void TPagamento::set_rate_auto()
if (_tpr > 0 && _tpr < 4) if (_tpr > 0 && _tpr < 4)
set_imprata(0, tpay_rata(0) + _secndr); set_imprata(0, tpay_rata(0) + _secndr);
// risistema rate per scadenze fisse
adjust_fixed_scad();
main_app().end_wait(); main_app().end_wait();
} }
@ -1334,16 +1314,16 @@ void TPagamento::set_total(const real& imponibile, const real& imposta, const re
_firstr = _imponibile; _firstr = _imponibile;
break; break;
case 4: case 4:
_firstr = _spese + _imponibile; _secndr = _spese + _imponibile;
_secndr = _imposta; _firstr = _imposta;
break; break;
case 5: case 5:
_firstr = _imponibile + _imposta; _secndr = _imponibile + _imposta;
_secndr = _spese; _firstr = _spese;
break; break;
case 6: case 6:
_firstr = _imponibile; _secndr = _imponibile;
_secndr = _imposta + _spese; _firstr = _imposta + _spese;
break; break;
} }
@ -1460,6 +1440,43 @@ void TPagamento::set_sheet(TSheet_field& sf, int sscad)
main_app().end_wait(); main_app().end_wait();
} }
void TPagamento::adjust_fixed_scad()
{
if (!_inited) return;
for (int i = 0; i < n_rate(); i++)
{
TDate d = data_rata(i);
// riaggiusta se ci sono scadenze fissate
if (_fixd[0] != 0 || _fixd[1] != 0 || _fixd[2] != 0)
{
for (int i = 0; i < 3; i++)
{
if (_fixd[i] > d.day())
{
if (d.last_day(d.month(), d.year()) >= _fixd[i])
d.set_day(_fixd[i]);
else d.set_end_month();
break;
}
}
if (i == 3)
{
if (_fixd[0] > 0 && _fixd[0] < d.day())
{
d.set_day(_fixd[0]);
d.set_month(d.month() == 12 ? 1 : d.month() + 1);
}
}
}
TToken_string& tt = rata(i);
tt.add(d.string(), 3);
}
}
TPagamento::TPagamento(const char* codtab, const char* data) : TPagamento::TPagamento(const char* codtab, const char* data) :
_slicer(0.0,0), _new(FALSE), _imponibile(0.0), _imposta(0.0), _slicer(0.0,0), _new(FALSE), _imponibile(0.0), _imposta(0.0),
_spese(0.0), _cambio(1.0), _code(codtab), _dirty(FALSE), _inited(FALSE), _spese(0.0), _cambio(1.0), _code(codtab), _dirty(FALSE), _inited(FALSE),

View File

@ -92,6 +92,8 @@ public:
// giorni scadenza fissi, aggiunti poi // giorni scadenza fissi, aggiunti poi
void set_fixed_scad(int a, int ind) { _fixd[ind] = a; } void set_fixed_scad(int a, int ind) { _fixd[ind] = a; }
// aggiusta scadenze fisse (tutte in un colpo)
void adjust_fixed_scad();
// queste vengono usate solo per movimenti editabili nella struttura // queste vengono usate solo per movimenti editabili nella struttura
// (da tabella pagamenti) e riaggiustano tutte le rate in accordo // (da tabella pagamenti) e riaggiustano tutte le rate in accordo