Iniziata gestione valuta nelle fattura extra-contabili
git-svn-id: svn://10.65.10.50/trunk@2179 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
e5bd999951
commit
4d69a66186
@ -21,6 +21,8 @@ class TFattura_mask : public TMask
|
||||
|
||||
protected:
|
||||
static bool totdoc_handler(TMask_field& f, KEY k);
|
||||
static bool totval_handler(TMask_field& f, KEY k);
|
||||
static bool cambio_handler(TMask_field& f, KEY k);
|
||||
static bool pag_notify(TSheet_field& ps, int r, KEY k);
|
||||
static bool pag_handler(TMask_field& f, KEY key);
|
||||
static bool reset_handler(TMask_field& f, KEY key);
|
||||
@ -44,8 +46,18 @@ public:
|
||||
TFattura_mask::TFattura_mask(TRiga_partite& fattura, const TString& codpag)
|
||||
: TMask("sc0100b"), _fattura(fattura), _pag(NULL)
|
||||
{
|
||||
enable(FS_IMPONIBILI);
|
||||
enable(FS_IMPONIBILI); // Abilita il totale documento
|
||||
|
||||
enable(FS_VALUTA); // Abilita campi valuta
|
||||
enable(FS_DATACAMBIO);
|
||||
enable(FS_CAMBIO);
|
||||
|
||||
hide(FS_IMPOSTE); // Elimina le imposte (non gestite in extra-contabile)
|
||||
show(FS_TOTVAL); // Attiva il totale documento in valuta
|
||||
|
||||
set_handler(FS_IMPONIBILI, totdoc_handler);
|
||||
set_handler(FS_TOTVAL, totval_handler);
|
||||
set_handler(FS_CAMBIO, cambio_handler);
|
||||
set_handler(FS_RESET, reset_handler);
|
||||
set_handler(FS_RECALC, recalc_handler);
|
||||
set_handler(FS_NRATE, nrate_handler);
|
||||
@ -183,14 +195,73 @@ bool TFattura_mask::totdoc_handler(TMask_field& f, KEY k)
|
||||
{
|
||||
TFattura_mask& fm = (TFattura_mask&)f.mask();
|
||||
TPagamento& pag = fm.pagamento();
|
||||
const real tot(f.get());
|
||||
pag.set_total(tot, ZERO, ZERO);
|
||||
const bool valuta = fm.get(FS_VALUTA).not_empty();
|
||||
TMask_field& totval = fm.field(FS_TOTVAL);
|
||||
if (valuta && totval.get().empty())
|
||||
{
|
||||
const real cambio(fm.get(FS_CAMBIO));
|
||||
if (!cambio.is_zero())
|
||||
{
|
||||
real tot(f.get());
|
||||
tot /= cambio;
|
||||
fm.set(FS_CAMBIO, tot.string(), TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
if (!valuta)
|
||||
{
|
||||
const real tot(valuta ? totval.get() : f.get());
|
||||
pag.set_total(tot, ZERO, ZERO);
|
||||
pag.set_rate_auto();
|
||||
fm.pag2sheet();
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool TFattura_mask::totval_handler(TMask_field& f, KEY key)
|
||||
{
|
||||
if (key == K_TAB && f.focusdirty())
|
||||
{
|
||||
TFattura_mask& fm = (TFattura_mask&)f.mask();
|
||||
real totval(f.get());
|
||||
real cambio(fm.get(FS_CAMBIO));
|
||||
real totale(fm.get(FS_IMPONIBILI));
|
||||
if (totale.is_zero())
|
||||
{
|
||||
totale = totval * cambio;
|
||||
fm.set(FS_IMPONIBILI, totale.string(), TRUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (cambio.is_zero())
|
||||
{
|
||||
cambio = totale / totval;
|
||||
fm.set(FS_CAMBIO, cambio.string(), TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
TPagamento& pag = fm.pagamento();
|
||||
pag.set_total(totval, ZERO, ZERO);
|
||||
pag.set_rate_auto();
|
||||
fm.pag2sheet();
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool TFattura_mask::cambio_handler(TMask_field& f, KEY key)
|
||||
{
|
||||
if (key == K_TAB && f.focusdirty())
|
||||
{
|
||||
const real cambio(f.get());
|
||||
TFattura_mask& fm = (TFattura_mask&)f.mask();
|
||||
TPagamento& pag = fm.pagamento();
|
||||
pag.set_cambio(cambio);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
bool TFattura_mask::pag_handler(TMask_field& f, KEY key)
|
||||
{
|
||||
if (key == K_TAB || key == K_ENTER)
|
||||
|
Loading…
x
Reference in New Issue
Block a user