campo-sirio/sc/sc0100.cpp
guy ee4a6d9353 Correzione errori minori
git-svn-id: svn://10.65.10.50/trunk@2594 c028cbd2-c16b-5b4b-a496-9718f37d4682
1996-02-13 16:37:29 +00:00

106 lines
2.5 KiB
C++
Executable File

#include <stdarg.h>
#include <config.h>
#include <mask.h>
#include <urldefid.h>
#include "sc0100.h"
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");
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();
while (m.run() == K_ENTER)
{
_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 app;
app.run(argc, argv, "Gestione Saldaconto");
return 0;
}