1995-12-01 11:49:57 +00:00
|
|
|
#include <stdarg.h>
|
1995-11-06 11:10:50 +00:00
|
|
|
|
1996-02-13 16:37:29 +00:00
|
|
|
#include <config.h>
|
1995-12-01 11:49:57 +00:00
|
|
|
#include <mask.h>
|
|
|
|
#include <urldefid.h>
|
1995-11-06 11:10:50 +00:00
|
|
|
|
1995-12-01 11:49:57 +00:00
|
|
|
#include "sc0100.h"
|
1996-02-29 11:15:34 +00:00
|
|
|
#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
|
|
|
|
///////////////////////////////////////////////////////////
|
1995-11-06 11:10:50 +00:00
|
|
|
|
1996-02-13 16:37:29 +00:00
|
|
|
TSaldaconto_app::TSaldaconto_app()
|
|
|
|
: _file(32), _allow_firm(TRUE)
|
|
|
|
{}
|
|
|
|
|
1995-12-01 11:49:57 +00:00
|
|
|
bool TSaldaconto_app::create()
|
|
|
|
{
|
|
|
|
open_files(LF_PARTITE, LF_SCADENZE, LF_PAGSCA, 0);
|
1996-02-29 11:15:34 +00:00
|
|
|
|
1995-12-01 11:49:57 +00:00
|
|
|
_msk = new TMask("sc0100a");
|
1996-02-29 11:15:34 +00:00
|
|
|
_msk->set_handler(F_GRUPPO, gruppo_handler);
|
|
|
|
|
1995-12-01 11:49:57 +00:00
|
|
|
dispatch_e_menu(MENU_ITEM(1));
|
|
|
|
return TRUE;
|
1995-11-27 17:10:46 +00:00
|
|
|
}
|
|
|
|
|
1995-12-01 11:49:57 +00:00
|
|
|
bool TSaldaconto_app::destroy()
|
1995-11-27 17:10:46 +00:00
|
|
|
{
|
1995-12-01 11:49:57 +00:00
|
|
|
delete _msk;
|
|
|
|
close_files();
|
|
|
|
return TRUE;
|
1995-11-27 17:10:46 +00:00
|
|
|
}
|
|
|
|
|
1995-12-01 11:49:57 +00:00
|
|
|
void TSaldaconto_app::open_files(int logicnum, ...)
|
|
|
|
{
|
|
|
|
va_list marker;
|
|
|
|
va_start(marker, logicnum);
|
|
|
|
while (logicnum > 0)
|
1995-11-27 17:10:46 +00:00
|
|
|
{
|
1995-12-01 11:49:57 +00:00
|
|
|
CHECKD(_file.objptr(logicnum) == NULL, "File gia' aperto: ", logicnum);
|
|
|
|
_file.add(new TLocalisamfile(logicnum), logicnum);
|
|
|
|
logicnum = va_arg(marker, int);
|
1995-11-27 17:10:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1995-12-01 11:49:57 +00:00
|
|
|
void TSaldaconto_app::on_config_change()
|
1995-11-27 17:10:46 +00:00
|
|
|
{
|
1996-02-13 16:37:29 +00:00
|
|
|
TConfig cnf(CONFIG_DITTA, "cg");
|
|
|
|
_ges_val = cnf.get_bool("GesVal");
|
1995-12-01 11:49:57 +00:00
|
|
|
TPartita::carica_allineamento();
|
1995-11-27 17:10:46 +00:00
|
|
|
}
|
|
|
|
|
1995-12-01 11:49:57 +00:00
|
|
|
bool TSaldaconto_app::menu(MENU_TAG)
|
|
|
|
{
|
|
|
|
TMask& m = curr_mask();
|
1996-03-15 09:38:11 +00:00
|
|
|
|
|
|
|
bool ok = TRUE;
|
|
|
|
while (ok)
|
|
|
|
{
|
|
|
|
xvt_statbar_set("Ricerca", TRUE);
|
|
|
|
ok = m.run() == K_ENTER;
|
|
|
|
if (ok)
|
|
|
|
{
|
|
|
|
_allow_firm = FALSE;
|
|
|
|
edit_partite(m);
|
|
|
|
_allow_firm = TRUE;
|
|
|
|
}
|
1996-02-13 16:37:29 +00:00
|
|
|
}
|
1995-12-01 11:49:57 +00:00
|
|
|
return 0;
|
1995-11-27 17:10:46 +00:00
|
|
|
}
|
|
|
|
|
1996-02-13 16:37:29 +00:00
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
// 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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
1995-12-01 11:49:57 +00:00
|
|
|
int sc0100(int argc, char* argv[])
|
1995-11-27 17:10:46 +00:00
|
|
|
{
|
1996-02-29 11:15:34 +00:00
|
|
|
TSaldaconto_app salda;
|
|
|
|
salda.run(argc, argv, "Gestione Saldaconto");
|
1995-11-06 11:10:50 +00:00
|
|
|
return 0;
|
1995-11-27 17:10:46 +00:00
|
|
|
}
|