Liquidazione: corretto il famoso credito precedente MI2011
Visualizzazione liquidazione, proseguo ma non concludo git-svn-id: svn://10.65.10.50/trunk@787 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
2e12d37e1a
commit
fbebe9c72c
@ -747,6 +747,8 @@ void TLiquidazione_app::write_liq(int month, const char* codatts)
|
||||
real risultato = 0.0;
|
||||
real vol_aff = 0.0;
|
||||
real debito_prec = 0.0;
|
||||
real ris_deb = 0.0;
|
||||
real ris_cred = 0.0;
|
||||
|
||||
while ((tmpatt = atts.get()) != NULL)
|
||||
{
|
||||
@ -759,18 +761,24 @@ void TLiquidazione_app::write_liq(int month, const char* codatts)
|
||||
_plm->get_real("R2") - _plm->get_real("R3") -
|
||||
_plm->get_real("R4"));
|
||||
|
||||
ris_deb += (_plm->get_real("R0") + _plm->get_real("R2"));
|
||||
ris_cred += (_plm->get_real("R1") + _plm->get_real("R3") +
|
||||
_plm->get_real("R4"));
|
||||
|
||||
if (month == 12)
|
||||
{
|
||||
look_pla(att);
|
||||
vol_aff += _pla->get_real("R0");
|
||||
// a credito anche il conguaglio prorata
|
||||
risultato -= _pla->get_real("R10");
|
||||
risultato -= _pla->get_real("R10");
|
||||
ris_cred += _pla->get_real("R10");
|
||||
}
|
||||
}
|
||||
}
|
||||
// toglie credito precedente decrementato di ev. rimborsi chiesti
|
||||
// e acconto versato e rettifiche a debito
|
||||
risultato -= credito_prec(month);
|
||||
ris_cred += credito_prec(month);
|
||||
|
||||
// vedi se c'era un debito precedente
|
||||
if (!is_first_month(month))
|
||||
@ -787,14 +795,18 @@ void TLiquidazione_app::write_liq(int month, const char* codatts)
|
||||
}
|
||||
}
|
||||
risultato += debito_prec;
|
||||
|
||||
ris_deb += debito_prec;
|
||||
|
||||
look_lim(month,TRUE);
|
||||
|
||||
// scorpora ulteriori detrazioni
|
||||
real dt = _lim->get_real("R6");
|
||||
risultato -= dt;
|
||||
real dt = _lim->get_real("R6");
|
||||
risultato -= dt;
|
||||
ris_cred += dt;
|
||||
|
||||
_lim->put("R0",risultato);
|
||||
_lim->put("R0",risultato);
|
||||
_lim->put("R7",ris_cred);
|
||||
_lim->put("R8",ris_deb);
|
||||
_lim->put("B0","X");
|
||||
|
||||
if (_isfinal) _lim->put("B1","X");
|
||||
|
@ -365,10 +365,12 @@ real TLiquidazione_app::credito_prec(int month)
|
||||
if (_lim->read() == NOERR)
|
||||
// considera anche il rimborso
|
||||
c = _lim->get_real("R0") - _lim->get_real("R1");
|
||||
// e le eventuali rettifiche a debito
|
||||
// e le eventuali rettifiche
|
||||
real rett = _lim->get_real("R5");
|
||||
if (rett.sign() > 0)
|
||||
c -= rett;
|
||||
c += -rett;
|
||||
// e le ulteriori detrazioni
|
||||
real detr = _lim->get_real("R6");
|
||||
c += detr;
|
||||
// e l'acconto versato a dicembre
|
||||
_del->zero();
|
||||
TString ditta = _nditte->curr().get("CODDITTA");
|
||||
|
@ -998,9 +998,11 @@ void TLiquidazione_app::set_grand(_DescrItem& d)
|
||||
iva = abs(iva);
|
||||
iva.ceil(_isannual ? ROUND_MILLELIRE : ROUND_LIRA);
|
||||
|
||||
|
||||
// se non c'e' nulla da versare non stampa una minchia
|
||||
if (!iva.is_zero())
|
||||
// se non c'e' nulla da versare stampa solo una riga vuota
|
||||
// Serve, non toglierla, stronzo.
|
||||
if (iva.is_zero())
|
||||
set_row(rw++,"");
|
||||
else
|
||||
{
|
||||
if (how == 'c')
|
||||
{
|
||||
|
@ -13,7 +13,7 @@
|
||||
#include <sheet.h>
|
||||
#include <config.h>
|
||||
#include <prefix.h>
|
||||
#include <conto.h>
|
||||
#include "conto.h"
|
||||
#include <nditte.h>
|
||||
#include <anagr.h>
|
||||
#include <comuni.h>
|
||||
|
977
cg/cg5500.cpp
977
cg/cg5500.cpp
@ -1,413 +1,564 @@
|
||||
#include "cg5500.h"
|
||||
|
||||
#include <browfile.h>
|
||||
#include <prefix.h>
|
||||
#include <msksheet.h>
|
||||
#include <mailbox.h>
|
||||
#include <execp.h>
|
||||
#include <progind.h>
|
||||
#include <urldefid.h>
|
||||
|
||||
#include "cg5500a.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,TRUE);
|
||||
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);
|
||||
sv.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();
|
||||
_mask = NULL;
|
||||
|
||||
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("cg4 -2", "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;
|
||||
}
|
||||
#include "cg5500.h"
|
||||
|
||||
#include <browfile.h>
|
||||
#include <prefix.h>
|
||||
#include <msksheet.h>
|
||||
#include <mailbox.h>
|
||||
#include <execp.h>
|
||||
#include <progind.h>
|
||||
#include <urldefid.h>
|
||||
|
||||
#include "cg5500a.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,TRUE);
|
||||
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);
|
||||
m.enable(group);
|
||||
|
||||
if (doubleclick) m.field(firstfoc).set_focus();
|
||||
|
||||
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;
|
||||
if (sh.items() == 4) month *= 3;
|
||||
((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()+1;
|
||||
if (sh.items() == 4) month *= 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);
|
||||
sv.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();
|
||||
_mask = NULL;
|
||||
|
||||
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("cg4 -2", "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;
|
||||
CURSOR oldcur = get_cursor(TASK_WIN);
|
||||
TExternal_app liq("cg4 -2");
|
||||
{
|
||||
TProgind(10l,"Estrazione liquidazione\nPrego attendere", FALSE,FALSE);
|
||||
liq.run();
|
||||
|
||||
set_cursor(TASK_WIN,CURSOR_WAIT);
|
||||
|
||||
if (liq.error())
|
||||
{
|
||||
beep();
|
||||
set_cursor(TASK_WIN, oldcur);
|
||||
return FALSE;
|
||||
}
|
||||
line = brw.set_text(f, "CALCOLO LIQUIDAZIONE D'IMPOSTA");
|
||||
brw.goto_pos(brw.lines()-16l, 9);
|
||||
|
||||
real risultato = _lim->get_real("R0");
|
||||
risultato += (rimborso + rettifica - acconto);
|
||||
|
||||
TViswin* vsw = brw.vis_win();
|
||||
long ll, ll2, lvers = -1; int x;
|
||||
|
||||
int isdebt = risultato.sign();
|
||||
long lrisd = vsw->search("RISULTATO", x, line, TRUE); // RISULTATO a debito
|
||||
long lrisc = vsw->search("RISULTATO", x, lrisd+1l, TRUE); // credito
|
||||
if (risultato.sign())
|
||||
lvers = vsw->search(isdebt < 0 ? "CREDITO ATTUALE" : "IVA DA VERSARE",
|
||||
x, line, TRUE);
|
||||
|
||||
real risc(real::ita2eng(brw.get_text(lrisc,58,15)));
|
||||
real risd(real::ita2eng(brw.get_text(lrisd,75,15)));
|
||||
|
||||
if (lrisd == -1l || lrisc == -1l) return FALSE;
|
||||
if (lvers == -1l) lvers = lrisc+1l;
|
||||
|
||||
set_cursor(TASK_WIN, oldcur);
|
||||
|
||||
for(;;)
|
||||
{
|
||||
KEY k = msk.run();
|
||||
bool write_lia = FALSE, write_lim = FALSE;
|
||||
|
||||
if (k == K_SAVE) // TBI registra: dovra' essere RICALCOLA
|
||||
{
|
||||
real n_acconto (msk.get(F_ACCONTO));
|
||||
real n_rimborso (msk.get(F_RIMBORSO));
|
||||
real n_rettifica(msk.get(F_RETTIFICA));
|
||||
TString n_desc1 (msk.get(F_DESCR1));
|
||||
TString n_desc2 (msk.get(F_DESCR2));
|
||||
|
||||
if (msk.field(F_RETTIFICA).dirty() || msk.field(F_DEBCRE).dirty())
|
||||
{
|
||||
ll = vsw->search("Rettifiche IVA a credito",x,line,TRUE);
|
||||
ll2 = vsw->search("Rettifiche IVA a debito", x,line,TRUE);
|
||||
|
||||
if (ll != -1 && ll2 != -1)
|
||||
{
|
||||
if (msk.get(F_DEBCRE) == "D")
|
||||
{
|
||||
vsw->replace(ll2, n_rettifica.string("###.###.###.###"), 75);
|
||||
vsw->replace(ll, " ", 58);
|
||||
}
|
||||
else
|
||||
{
|
||||
vsw->replace(ll, n_rettifica.string("###.###.###.###"), 58);
|
||||
vsw->replace(ll2, " ", 75);
|
||||
}
|
||||
|
||||
risultato -= rettifica; // vecchia rettifica
|
||||
|
||||
if (msk.get(F_DEBCRE) == "C")
|
||||
{
|
||||
risc -= rettifica;
|
||||
risc += n_rettifica;
|
||||
n_rettifica = -n_rettifica;
|
||||
}
|
||||
else
|
||||
{
|
||||
risd -= rettifica;
|
||||
risd += n_rettifica;
|
||||
}
|
||||
|
||||
risultato += n_rettifica;
|
||||
|
||||
vsw->replace(lrisc, risc.string("###.###.###.###"), 58);
|
||||
vsw->replace(lrisd, risd.string("###.###.###.###"), 75);
|
||||
|
||||
_lim->put("R5", n_rettifica);
|
||||
_lim->put("S7", msk.get(F_DEBCRE));
|
||||
set_risultato(vsw, lvers, risultato);
|
||||
}
|
||||
write_lim = TRUE;
|
||||
}
|
||||
if (msk.field(F_ACCONTO).dirty())
|
||||
{
|
||||
ll = vsw->search("Versamento acconto dicembre",x,line,TRUE);
|
||||
if (ll != -1)
|
||||
vsw->replace(ll, n_acconto.string("###.###.###.###"), 58);
|
||||
write_lia = TRUE;
|
||||
risultato += acconto;
|
||||
risultato -= n_acconto;
|
||||
risc -= acconto;
|
||||
risc += n_acconto;
|
||||
_lia->put("R4", acconto);
|
||||
vsw->replace(lrisc, risc.string("###.###.###.###"), 58);
|
||||
set_risultato(vsw, lvers, risultato);
|
||||
}
|
||||
if (msk.field(F_RIMBORSO).dirty())
|
||||
{
|
||||
ll = vsw->search("Iva chiesta a rimborso",x,line,TRUE);
|
||||
if (ll != -1)
|
||||
vsw->replace(ll, n_rimborso.string("###.###.###.###"), 75);
|
||||
write_lim = TRUE;
|
||||
risultato -= rimborso;
|
||||
risultato += n_rimborso;
|
||||
risd -= rimborso;
|
||||
risd += n_rimborso;
|
||||
_lim->put("R1", rimborso);
|
||||
vsw->replace(lrisd, risd.string("###.###.###.###"), 75);
|
||||
set_risultato(vsw, lvers, risultato);
|
||||
}
|
||||
if (msk.field(F_DESCR1).dirty())
|
||||
{
|
||||
_lim->put("S0", n_desc1);
|
||||
write_lim = TRUE;
|
||||
}
|
||||
if (msk.field(F_DESCR1).dirty())
|
||||
{
|
||||
_lim->put("S1", n_desc2);
|
||||
write_lim = TRUE;
|
||||
}
|
||||
|
||||
// TBI abilitare ricalcolo liquidazione
|
||||
|
||||
if (write_lia && FALSE /* TBI k == K_END */)
|
||||
_lia->rewrite();
|
||||
|
||||
if ((write_lim || write_lia) && FALSE /* TBI k == K_END */)
|
||||
{
|
||||
_lim->put("B0", "");
|
||||
_lim->rewrite();
|
||||
vsw->refresh();
|
||||
}
|
||||
}
|
||||
else if (k == K_ESC || k == K_END) break;
|
||||
}
|
||||
}
|
||||
|
||||
remove(f);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void Visliq_app::set_risultato(TViswin* vsw, long line, real& r)
|
||||
{
|
||||
TString256 ln;
|
||||
ln.spaces();
|
||||
|
||||
// does not gestisc interessi e riporti debito < 50000
|
||||
|
||||
if (r.sign() < 0)
|
||||
{
|
||||
ln.overwrite("CREDITO ATTUALE", 23);
|
||||
ln.overwrite(abs(r).string("###.###.###.###"), 58);
|
||||
}
|
||||
else if (r.sign() > 0)
|
||||
{
|
||||
ln.overwrite("IVA DA VERSARE", 23);
|
||||
ln.overwrite(r.string("###.###.###.###"), 75);
|
||||
}
|
||||
vsw->replace(line, ln, 0);
|
||||
}
|
||||
|
||||
int cg5500(int argc, char* argv[])
|
||||
{
|
||||
Visliq_app app;
|
||||
app.run(argc, argv, "Visualizzazione Liquidazione");
|
||||
return 0;
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ class Visliq_app : public TApplication
|
||||
bool look_lia(int year = 0);
|
||||
bool look_lim(int m);
|
||||
bool look_del(int month, int type);
|
||||
|
||||
void set_risultato(TViswin*, long, real&);
|
||||
|
||||
protected:
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user