campo-sirio/sc/sc0100.cpp
guy c9d8f9771e Aggiustate maschere saldaconto extra-contabile
git-svn-id: svn://10.65.10.50/trunk@2924 c028cbd2-c16b-5b4b-a496-9718f37d4682
1996-05-28 15:48:16 +00:00

143 lines
3.3 KiB
C++
Executable File

#include <stdarg.h>
#include <config.h>
#include <mask.h>
#include <urldefid.h>
#include "sc0100.h"
#include "sc0100a.h"
HIDDEN bool gruppo_handler(TMask_field& f, KEY key)
{
static bool ignore = FALSE;
if (key == K_TAB && f.focusdirty())
{
if (!ignore)
{
TMask_field& c = f.mask().field(F_CONTO);
if (c.get().not_empty())
{
ignore = TRUE;
c.set_dirty();
c.on_key(K_TAB);
ignore = FALSE;
}
}
}
return TRUE;
}
///////////////////////////////////////////////////////////
// Gestione saldaconto extra-contabile
///////////////////////////////////////////////////////////
TSaldaconto_app::TSaldaconto_app()
: _file(32), _allow_firm(TRUE)
{}
bool TSaldaconto_app::create()
{
open_files(LF_PARTITE, LF_SCADENZE, LF_PAGSCA, 0);
_msk = new TMask("sc0100a");
_msk->set_handler(F_GRUPPO, gruppo_handler);
dispatch_e_menu(MENU_ITEM(1));
return TRUE;
}
bool TSaldaconto_app::destroy()
{
delete _msk;
close_files();
return TRUE;
}
void TSaldaconto_app::open_files(int logicnum, ...)
{
va_list marker;
va_start(marker, logicnum);
while (logicnum > 0)
{
CHECKD(_file.objptr(logicnum) == NULL, "File gia' aperto: ", logicnum);
_file.add(new TLocalisamfile(logicnum), logicnum);
logicnum = va_arg(marker, int);
}
}
void TSaldaconto_app::on_config_change()
{
TConfig cnf(CONFIG_DITTA, "cg");
_ges_val = cnf.get_bool("GesVal");
TPartita::carica_allineamento();
}
bool TSaldaconto_app::menu(MENU_TAG)
{
TMask& m = curr_mask();
bool ok = TRUE;
while (ok)
{
xvt_statbar_set("Ricerca", TRUE);
m.reset();
ok = m.run() == K_ENTER;
if (ok)
{
_allow_firm = FALSE;
edit_partite(m);
_allow_firm = TRUE;
}
}
return 0;
}
///////////////////////////////////////////////////////////
// Handlers generali
///////////////////////////////////////////////////////////
#include "sc0100p.h"
void TSaldaconto_app::gioca_cambi(TMask& m, int force)
{
if (m.get(E_VALUTA).empty())
return;
const real totale = m.get(E_TOTALE);
const real totval = m.get(E_TOTDOCVAL);
const real cambio = m.get(E_CAMBIO);
if ( (force == 0x1 || totale.is_zero()) && !(totval.is_zero() || cambio.is_zero()) )
{
const TValuta cam(m, E_VALUTA, E_DATACAMBIO, E_CAMBIO);
const real new_totale = cam.val2lit(totval);
if (new_totale != totale)
m.set(E_TOTALE, new_totale, TRUE);
}
if ( (force == 0x2 || totval.is_zero()) && !(totale.is_zero() || cambio.is_zero()) )
{
const TValuta cam(m, E_VALUTA, E_DATACAMBIO, E_CAMBIO);
const real new_totval = cam.lit2val(totale);
if (new_totval != totval)
m.set(E_TOTDOCVAL, new_totval, TRUE);
}
if ( (force == 0x4 || cambio.is_zero()) && !(totale.is_zero() || totval.is_zero()) )
{
real new_cambio = totale / totval; new_cambio.round(5);
if (new_cambio != cambio)
m.set(E_CAMBIO, new_cambio, TRUE);
}
}
///////////////////////////////////////////////////////////
int sc0100(int argc, char* argv[])
{
TSaldaconto_app* salda = new TSaldaconto_app;
salda->run(argc, argv, "Gestione Saldaconto");
return 0;
}