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

View File

@ -307,37 +307,9 @@ void TPagamento::next_scad(TDate& d, int scad, bool mcomm, int rata)
if (!last && dy < d.day())
d.set_day(dy);
}
else
{
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);
}
}
else d += scad;
}
}
void TPagamento::set_default_type(int type, bool change_existing)
{
@ -545,6 +517,7 @@ word TPagamento::validate() const
TDate d(data_rata(0));
if (d < _inizio)
res |= P_INIZIO;
for (i = 1; i < n_rate(); i++)
{
if (data_rata(i) <= d)
@ -681,7 +654,7 @@ word TPagamento::recalc_rate(int row, bool is_perc_modified,
bool exhausted = FALSE;
for (int i = first; i < srate.items(); i++)
for (int i = 0 /* first */; i < srate.items(); i++)
{
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;
return P_OK;
} // new_value != NULL
@ -1112,6 +1088,7 @@ word TPagamento::recalc_rate(int row, bool is_perc_modified,
}
}
adjust_fixed_scad();
return P_OK;
}
@ -1302,6 +1279,9 @@ void TPagamento::set_rate_auto()
if (_tpr > 0 && _tpr < 4)
set_imprata(0, tpay_rata(0) + _secndr);
// risistema rate per scadenze fisse
adjust_fixed_scad();
main_app().end_wait();
}
@ -1334,16 +1314,16 @@ void TPagamento::set_total(const real& imponibile, const real& imposta, const re
_firstr = _imponibile;
break;
case 4:
_firstr = _spese + _imponibile;
_secndr = _imposta;
_secndr = _spese + _imponibile;
_firstr = _imposta;
break;
case 5:
_firstr = _imponibile + _imposta;
_secndr = _spese;
_secndr = _imponibile + _imposta;
_firstr = _spese;
break;
case 6:
_firstr = _imponibile;
_secndr = _imposta + _spese;
_secndr = _imponibile;
_firstr = _imposta + _spese;
break;
}
@ -1460,6 +1440,43 @@ void TPagamento::set_sheet(TSheet_field& sf, int sscad)
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) :
_slicer(0.0,0), _new(FALSE), _imponibile(0.0), _imposta(0.0),
_spese(0.0), _cambio(1.0), _code(codtab), _dirty(FALSE), _inited(FALSE),

View File

@ -92,6 +92,8 @@ public:
// giorni scadenza fissi, aggiunti poi
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
// (da tabella pagamenti) e riaggiustano tutte le rate in accordo