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:
villa 1994-12-23 11:56:34 +00:00
parent 2e12d37e1a
commit fbebe9c72c
6 changed files with 593 additions and 426 deletions

View File

@ -747,6 +747,8 @@ void TLiquidazione_app::write_liq(int month, const char* codatts)
real risultato = 0.0; real risultato = 0.0;
real vol_aff = 0.0; real vol_aff = 0.0;
real debito_prec = 0.0; real debito_prec = 0.0;
real ris_deb = 0.0;
real ris_cred = 0.0;
while ((tmpatt = atts.get()) != NULL) 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("R2") - _plm->get_real("R3") -
_plm->get_real("R4")); _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) if (month == 12)
{ {
look_pla(att); look_pla(att);
vol_aff += _pla->get_real("R0"); vol_aff += _pla->get_real("R0");
// a credito anche il conguaglio prorata // 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 // toglie credito precedente decrementato di ev. rimborsi chiesti
// e acconto versato e rettifiche a debito // e acconto versato e rettifiche a debito
risultato -= credito_prec(month); risultato -= credito_prec(month);
ris_cred += credito_prec(month);
// vedi se c'era un debito precedente // vedi se c'era un debito precedente
if (!is_first_month(month)) if (!is_first_month(month))
@ -787,14 +795,18 @@ void TLiquidazione_app::write_liq(int month, const char* codatts)
} }
} }
risultato += debito_prec; risultato += debito_prec;
ris_deb += debito_prec;
look_lim(month,TRUE); look_lim(month,TRUE);
// scorpora ulteriori detrazioni // scorpora ulteriori detrazioni
real dt = _lim->get_real("R6"); real dt = _lim->get_real("R6");
risultato -= dt; 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"); _lim->put("B0","X");
if (_isfinal) _lim->put("B1","X"); if (_isfinal) _lim->put("B1","X");

View File

@ -365,10 +365,12 @@ real TLiquidazione_app::credito_prec(int month)
if (_lim->read() == NOERR) if (_lim->read() == NOERR)
// considera anche il rimborso // considera anche il rimborso
c = _lim->get_real("R0") - _lim->get_real("R1"); 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"); 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 // e l'acconto versato a dicembre
_del->zero(); _del->zero();
TString ditta = _nditte->curr().get("CODDITTA"); TString ditta = _nditte->curr().get("CODDITTA");

View File

@ -998,9 +998,11 @@ void TLiquidazione_app::set_grand(_DescrItem& d)
iva = abs(iva); iva = abs(iva);
iva.ceil(_isannual ? ROUND_MILLELIRE : ROUND_LIRA); iva.ceil(_isannual ? ROUND_MILLELIRE : ROUND_LIRA);
// se non c'e' nulla da versare stampa solo una riga vuota
// se non c'e' nulla da versare non stampa una minchia // Serve, non toglierla, stronzo.
if (!iva.is_zero()) if (iva.is_zero())
set_row(rw++,"");
else
{ {
if (how == 'c') if (how == 'c')
{ {

View File

@ -13,7 +13,7 @@
#include <sheet.h> #include <sheet.h>
#include <config.h> #include <config.h>
#include <prefix.h> #include <prefix.h>
#include <conto.h> #include "conto.h"
#include <nditte.h> #include <nditte.h>
#include <anagr.h> #include <anagr.h>
#include <comuni.h> #include <comuni.h>

View File

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

View File

@ -31,7 +31,7 @@ class Visliq_app : public TApplication
bool look_lia(int year = 0); bool look_lia(int year = 0);
bool look_lim(int m); bool look_lim(int m);
bool look_del(int month, int type); bool look_del(int month, int type);
void set_risultato(TViswin*, long, real&);
protected: protected: