1b2466f0cd
Continua la saga della visualizzazione liquidazione git-svn-id: svn://10.65.10.50/trunk@770 c028cbd2-c16b-5b4b-a496-9718f37d4682
412 lines
9.2 KiB
C++
Executable File
412 lines
9.2 KiB
C++
Executable File
#include "cg5500.h"
|
|
|
|
#include <urldefid.h>
|
|
#include <prefix.h>
|
|
#include "cg5500a.h"
|
|
#include <msksheet.h>
|
|
#include <mailbox.h>
|
|
#include <execp.h>
|
|
#include <progind.h>
|
|
#include <browfile.h>
|
|
|
|
const char* Visliq_app::itoname(int m)
|
|
{
|
|
const char* mn;
|
|
if (_freqviva == "M")
|
|
return itom(m);
|
|
|
|
switch(m)
|
|
{
|
|
case 3:
|
|
mn = "1 Trimestre";
|
|
break;
|
|
case 6:
|
|
mn = "2 Trimestre";
|
|
break;
|
|
case 9:
|
|
mn = "3 Trimestre";
|
|
break;
|
|
case 12:
|
|
mn = "4 Trimestre";
|
|
break;
|
|
}
|
|
|
|
return mn;
|
|
}
|
|
|
|
void Visliq_app::set_freqviva()
|
|
{
|
|
if (look_lia())
|
|
_freqviva = _lia->get("S7");
|
|
else
|
|
{
|
|
TLocalisamfile ditte(LF_NDITTE,1);
|
|
ditte.zero();
|
|
ditte.put("CODDITTA", get_firm());
|
|
ditte.read();
|
|
_freqviva = ditte.get("FREQVIVA");
|
|
}
|
|
}
|
|
|
|
bool Visliq_app::create()
|
|
{
|
|
TApplication::create();
|
|
|
|
_del = new TTable("%DEL");
|
|
_lia = new TTable("LIA");
|
|
_lim = new TTable("LIM");
|
|
_del_r = &(_del->curr());
|
|
_lim_r = &(_lim->curr());
|
|
_del_ditta = new TRecfield(*_del_r,"CODTAB",0,4);
|
|
_del_anno = new TRecfield(*_del_r,"CODTAB",5,8);
|
|
_del_mese = new TRecfield(*_del_r,"CODTAB",9,10);
|
|
_del_tipo = new TRecfield(*_del_r,"CODTAB",11,11);
|
|
_lim_anno = new TRecfield(*_lim_r,"CODTAB",0,3);
|
|
_lim_mese = new TRecfield(*_lim_r,"CODTAB",4,6);
|
|
|
|
dispatch_e_menu(BAR_ITEM(1));
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
bool Visliq_app::destroy()
|
|
{
|
|
delete _lim_mese;
|
|
delete _lim_anno;
|
|
delete _del_tipo;
|
|
delete _del_mese;
|
|
delete _del_ditta;
|
|
delete _lim_r;
|
|
delete _del_r;
|
|
delete _lim;
|
|
delete _del;
|
|
|
|
return TApplication::destroy();
|
|
}
|
|
|
|
|
|
void Visliq_app::set_mask_freq(TMask& m)
|
|
{
|
|
if (_freqviva == "M")
|
|
{
|
|
m.show(F_MONTHS);
|
|
m.hide(F_TRIMS);
|
|
}
|
|
else
|
|
{
|
|
m.hide(F_MONTHS);
|
|
m.show(F_TRIMS);
|
|
}
|
|
}
|
|
|
|
|
|
bool Visliq_app::sheet_action(int r, KEY k)
|
|
{
|
|
// non si possono cancellare o aggiungere righe
|
|
return (k != K_DEL && k != K_INS);
|
|
}
|
|
|
|
|
|
|
|
const char* Visliq_app::link_handler(TMask& m,
|
|
int n, const char* txt, bool doubleclick)
|
|
{
|
|
// con click visualizza, con double click modifica
|
|
TString st(txt);
|
|
bool iscred = FALSE;
|
|
static int group;
|
|
int firstfoc;
|
|
|
|
if (group != 0) m.hide(group);
|
|
|
|
if (st.find("rimborso") != -1)
|
|
{ group = -1; firstfoc = F_RIMBORSO; }
|
|
else if (st.find("debito") != -1 || st.find("credito") != -1)
|
|
{ group = -2; firstfoc = F_RETTIFICA; }
|
|
else if (st.find("acconto") != -1)
|
|
{ group = -3; firstfoc = F_ACCONTO; }
|
|
|
|
m.show(group);
|
|
|
|
if (doubleclick)
|
|
{ m.enable(group); m.field(firstfoc).set_focus(); }
|
|
else m.disable(group);
|
|
|
|
return NULL;
|
|
}
|
|
|
|
|
|
|
|
bool Visliq_app::menu(MENU_TAG m)
|
|
{
|
|
if (m == BAR_ITEM(1))
|
|
return vis_liq();
|
|
|
|
return TApplication::menu(m);
|
|
}
|
|
|
|
// handlers
|
|
bool Visliq_app::set_ditta(TMask_field& f, KEY k)
|
|
{
|
|
long ditta = atol(f.get());
|
|
|
|
if (!prefhndl->exist(ditta))
|
|
{
|
|
warning_box("Archivi ditta %l non presenti!", ditta);
|
|
return FALSE;
|
|
}
|
|
else
|
|
{
|
|
main_app().set_firm(ditta);
|
|
((Visliq_app&)main_app()).set_freqviva();
|
|
}
|
|
|
|
((Visliq_app&)main_app()).set_mask_freq(f.mask());
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
bool Visliq_app::set_anno(TMask_field& f, KEY k)
|
|
{
|
|
((Visliq_app&)main_app()).set_year(atoi(f.get()));
|
|
((Visliq_app&)main_app()).set_freqviva();
|
|
((Visliq_app&)main_app()).set_mask_freq(f.mask());
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
|
|
bool Visliq_app::sel_mese_sh1 (TMask_field& f, KEY k)
|
|
{
|
|
if (k != K_SPACE) return TRUE;
|
|
|
|
TMask& m = *(((Visliq_app&)main_app()).get_main_mask());
|
|
TSheet_field& sh = (TSheet_field&)m.field(F_VISLIQ1);
|
|
int month = sh.selected()+1;
|
|
((Visliq_app&)main_app()).vis_one(month);
|
|
return TRUE;
|
|
}
|
|
|
|
bool Visliq_app::sel_mese_sh2 (TMask_field& f, KEY k)
|
|
{
|
|
if (k != K_SPACE) return TRUE;
|
|
|
|
TMask& m = *(((Visliq_app&)main_app()).get_main_mask());
|
|
TSheet_field& sh = (TSheet_field&)m.field(F_VISLIQ2);
|
|
int month = sh.selected();
|
|
month = month == 4 ? 13 : (month+1)*3;
|
|
((Visliq_app&)main_app()).vis_one(month);
|
|
return TRUE;
|
|
}
|
|
|
|
bool Visliq_app::vis_liq()
|
|
{
|
|
long ditta = get_firm();
|
|
set_freqviva();
|
|
|
|
TMask m("cg5500a");
|
|
|
|
m.set_handler(F_CODDITTA, set_ditta);
|
|
m.set_handler(F_YEAR, set_anno);
|
|
|
|
set_mask_freq(m);
|
|
_year = m.get_int(F_YEAR);
|
|
|
|
while (m.run() != K_ESC)
|
|
{
|
|
int month = m.get_int(_freqviva == "M" ? F_MONTHS : F_TRIMS);
|
|
if (month == 0)
|
|
vis_all();
|
|
else
|
|
vis_one(month);
|
|
}
|
|
|
|
set_firm(ditta);
|
|
|
|
return FALSE;
|
|
}
|
|
|
|
|
|
bool Visliq_app::vis_all()
|
|
{
|
|
if (!look_lia())
|
|
return FALSE;
|
|
|
|
// mask diverse per trimestrale e annuale
|
|
TMask m(_freqviva == "M" ? "cg5500b" : "cg5500c");
|
|
|
|
_mask = &m;
|
|
|
|
TSheet_field& sh = (TSheet_field&)m.field(F_VISLIQ1);
|
|
TSheet_field& sv = (TSheet_field&)m.field(F_VISLIQ2);
|
|
|
|
// disabilita aggiunta/eliminazione righe
|
|
sh.set_notify(sheet_action);
|
|
sh.set_notify(sheet_action);
|
|
|
|
sh.sheet_mask().set_handler(101,sel_mese_sh1);
|
|
sv.sheet_mask().set_handler(101,sel_mese_sh2);
|
|
|
|
m.field(F_CREDPREC).set(_lia->get_real("R0").string());
|
|
|
|
// set sheet
|
|
for (int i = 1; i <= 12; i++)
|
|
{
|
|
|
|
if (!is_month_ok(i) || !look_lim(i))
|
|
continue;
|
|
|
|
TToken_string* tt = new TToken_string(80);
|
|
|
|
tt->add(""); // questo e' il bottone
|
|
tt->add(itoname(i));
|
|
tt->add(abs(_lim->get_real("R0")).string());
|
|
tt->add(_lim->get_real("R0").sign() < 0 ? "C" : "D");
|
|
tt->add(_lim->get_real("R1").string());
|
|
tt->add(abs(_lim->get_real("R5")).string());
|
|
tt->add(_lim->get_real("R5").sign() < 0 ? "C" : "D");
|
|
|
|
sh.row(i-1) = (*tt);
|
|
}
|
|
|
|
// calcola versamenti
|
|
real versamenti[13];
|
|
TDate date[13];
|
|
|
|
for (_del->first(); !_del->eof(); _del->next())
|
|
{
|
|
if (atol(*_del_ditta) != get_firm() ||
|
|
atoi(*_del_anno) != _year)
|
|
continue;
|
|
|
|
// TBC uso solo deleghe normali (tipo == 1) e acconti (tipo == 7)
|
|
int tipod = atoi(*_del_tipo);
|
|
if (tipod != 1 || tipod != 7)
|
|
continue;
|
|
|
|
// somma versamenti nel mese adeguato
|
|
int m = atoi(*_del_mese);
|
|
|
|
if (m >= 12)
|
|
m = tipod == 7 ? 12 : 13;
|
|
|
|
versamenti[m-1] += _del->get_real("R0");
|
|
date[m-1] = _del->get_date("D0");
|
|
}
|
|
|
|
TString nomemese(26);
|
|
|
|
for (i = 1; i <= 13; i++)
|
|
{
|
|
if (!is_month_ok(i))
|
|
continue;
|
|
|
|
TToken_string* tt = new TToken_string(80);
|
|
nomemese = itoname(i == 13 ? 12 : i);
|
|
|
|
if (i == 12) nomemese << " acconto";
|
|
if (i == 13) nomemese << " saldo";
|
|
|
|
tt->add(""); // questo e' il bottone
|
|
tt->add(nomemese); // mese
|
|
tt->add(date[i-1].string()); // data vers.
|
|
tt->add(""); // TBI azienda
|
|
tt->add(""); // TBI dipendenza
|
|
tt->add(""); // TBI concessionaria
|
|
tt->add(versamenti[i-1].string());// versamenti
|
|
tt->add(versamenti[i-1].sign() < 0 ? "C" : "D"); // debito/credito
|
|
|
|
sv.row(i-1) = (*tt);
|
|
}
|
|
|
|
sh.disable();
|
|
sv.disable();
|
|
|
|
m.run();
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
|
|
bool Visliq_app::vis_one(int m)
|
|
{
|
|
TMask msk("cg5500d");
|
|
|
|
// ricalcolo liquidazione TMessage msg;
|
|
TFilename f;
|
|
f.temp();
|
|
|
|
TToken_string body(36);
|
|
body.add(_year);
|
|
body.add(m);
|
|
body.add(get_firm());
|
|
body.add("V"); // visualizzazione: no ff alla fine, zeri stampati
|
|
body.add("");
|
|
body.add(f);
|
|
|
|
TMessage msg("cg4300", "RCL", body);
|
|
msg.send();
|
|
|
|
TBrowsefile_field& brw = (TBrowsefile_field&)msk.field(F_VISFLQ);
|
|
brw.set_link_handler(link_handler);
|
|
brw.enable_link("Modifica: ", 'r');
|
|
|
|
look_lim(m);
|
|
real rimborso = _lim->get_real("R1");
|
|
real rettifica = _lim->get_real("R5");
|
|
TString desc1(_lim->get("S0"));
|
|
TString desc2(_lim->get("S1"));
|
|
real acconto;
|
|
|
|
if (m == 12)
|
|
{
|
|
look_lia();
|
|
acconto = _lia->get_real("R4");
|
|
}
|
|
|
|
msk.field(F_RIMBORSO).set(rimborso.string());
|
|
if (rettifica.sign() < 0)
|
|
{
|
|
msk.field(F_RETTIFICA).set(abs(rettifica).string());
|
|
msk.field(F_DEBCRE).set("C");
|
|
}
|
|
else
|
|
{
|
|
msk.field(F_RETTIFICA).set(rettifica.string());
|
|
msk.field(F_DEBCRE).set("D");
|
|
}
|
|
msk.field(F_DESCR1).set(desc1);
|
|
msk.field(F_DESCR2).set(desc1);
|
|
msk.field(F_ACCONTO).set(acconto.string());
|
|
|
|
long line;
|
|
|
|
TExternal_app liq("cg4 -2");
|
|
{
|
|
TProgind(10l,"Estrazione liquidazione\nPrego attendere", FALSE,FALSE);
|
|
liq.run();
|
|
|
|
if (liq.error())
|
|
{
|
|
beep();
|
|
return FALSE;
|
|
}
|
|
line = brw.set_text(f, "CALCOLO LIQUIDAZIONE D'IMPOSTA");
|
|
|
|
if (line != -1)
|
|
brw.goto_pos(line-1l, 9);
|
|
msk.run();
|
|
}
|
|
|
|
remove(f);
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
int cg5500(int argc, char* argv[])
|
|
{
|
|
Visliq_app app;
|
|
app.run(argc, argv, "Visualizzazione Liquidazione");
|
|
return 0;
|
|
}
|