Handlers per ricalcolo importi in valuta/lire con F8 o vuotando il campo

git-svn-id: svn://10.65.10.50/trunk@2361 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
villa 1995-12-29 10:45:09 +00:00
parent 322eff2a09
commit 8c1abd1a43
5 changed files with 41 additions and 1 deletions

View File

@ -125,6 +125,8 @@ TMask* TPrimanota_application::load_mask(int n)
m->set_handler(FS_VSCAB, codcab_handler);
TMask& sm = ps.sheet_mask();
sm.set_handler(102, ratalit_handler);
sm.set_handler(103, rataval_handler);
sm.set_handler(105, tipopag_handler);
sm.set_handler(106, tipopag_handler);
}

View File

@ -114,6 +114,10 @@ class TPrimanota_application : public TRelation_application
static bool recalc_handler(TMask_field& f, KEY key);
static bool codcab_handler(TMask_field& f, KEY key);
static bool tipopag_handler(TMask_field& f, KEY key);
static bool ratalit_handler(TMask_field& f, KEY key);
static bool rataval_handler(TMask_field& f, KEY key);
static bool iva_notify(TSheet_field& s, int r, KEY key);
static bool iva_handler(TMask_field& f, KEY key);

View File

@ -432,6 +432,38 @@ bool TPrimanota_application::codcab_handler(TMask_field& f, KEY key)
return TRUE;
}
bool TPrimanota_application::ratalit_handler(TMask_field& f, KEY key)
{
if (key == K_F8 || (key == K_TAB && f.focusdirty() && f.get().empty()))
{
TPagamento& pag = app().pagamento();
if (pag.in_valuta())
{
TValuta v("", TDate(), pag.cambio());
const real other(f.mask().get(103));
TString16 s(v.val2lit(other).string());
f.set(s);
}
}
return TRUE;
}
bool TPrimanota_application::rataval_handler(TMask_field& f, KEY key)
{
if (key == K_F8 || (key == K_TAB && f.focusdirty() && f.get().empty()))
{
TPagamento& pag = app().pagamento();
if (pag.in_valuta())
{
TValuta v("", TDate(), pag.cambio());
const real other(f.mask().get(102));
TString16 s(v.lit2val(other).string());
f.set(s);
}
}
return TRUE;
}
void TPrimanota_application::reset_pagamento(TMask&)
{
TPagamento& pag = pagamento();

View File

@ -683,7 +683,7 @@ word TPagamento::recalc_rate(int row, bool is_perc_modified,
{
// calcola defaults per tipo pagamento e scadenza
// nel caso di rate nuove
oldscad = scad_rata(1);
oldscad = scad_rata(srate.items() - 1);
if (_mcomm)
{
int mesi = oldscad / 30;
@ -986,6 +986,7 @@ word TPagamento::recalc_rate(int row, bool is_perc_modified,
else if (_inited)
{
if (dd <= botime) dd = lastdate;
if (j > 0 && nscd == 0) nscd = oldscad;
next_scad(dd,nscd,mcomm,j);
}
else nscd = _int_rate;

View File

@ -112,6 +112,7 @@ public:
void set_round(int n) { _round = n; }
void set_cambio(const real& ex);
bool in_valuta() const { return _cambio != 1.0; }
const real& cambio() const { return _cambio; }
// check consistency: returns word with errors flagged, 0 if ok
word validate() const;