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 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");
|
||||||
|
@ -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");
|
||||||
|
@ -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')
|
||||||
{
|
{
|
||||||
|
@ -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>
|
||||||
|
171
cg/cg5500.cpp
171
cg/cg5500.cpp
@ -128,10 +128,9 @@ const char* Visliq_app::link_handler(TMask& m,
|
|||||||
{ group = -3; firstfoc = F_ACCONTO; }
|
{ group = -3; firstfoc = F_ACCONTO; }
|
||||||
|
|
||||||
m.show(group);
|
m.show(group);
|
||||||
|
m.enable(group);
|
||||||
|
|
||||||
if (doubleclick)
|
if (doubleclick) m.field(firstfoc).set_focus();
|
||||||
{ m.enable(group); m.field(firstfoc).set_focus(); }
|
|
||||||
else m.disable(group);
|
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -161,7 +160,6 @@ bool Visliq_app::set_ditta(TMask_field& f, KEY k)
|
|||||||
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;
|
||||||
@ -184,6 +182,7 @@ bool Visliq_app::sel_mese_sh1 (TMask_field& f, KEY k)
|
|||||||
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_VISLIQ1);
|
TSheet_field& sh = (TSheet_field&)m.field(F_VISLIQ1);
|
||||||
int month = sh.selected()+1;
|
int month = sh.selected()+1;
|
||||||
|
if (sh.items() == 4) month *= 3;
|
||||||
((Visliq_app&)main_app()).vis_one(month);
|
((Visliq_app&)main_app()).vis_one(month);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@ -194,8 +193,8 @@ bool Visliq_app::sel_mese_sh2 (TMask_field& f, KEY k)
|
|||||||
|
|
||||||
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();
|
int month = sh.selected()+1;
|
||||||
month = month == 4 ? 13 : (month+1)*3;
|
if (sh.items() == 4) month *= 3;
|
||||||
((Visliq_app&)main_app()).vis_one(month);
|
((Visliq_app&)main_app()).vis_one(month);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@ -377,27 +376,159 @@ bool Visliq_app::vis_one(int m)
|
|||||||
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();
|
||||||
|
|
||||||
|
set_cursor(TASK_WIN,CURSOR_WAIT);
|
||||||
|
|
||||||
if (liq.error())
|
if (liq.error())
|
||||||
{
|
{
|
||||||
beep();
|
beep();
|
||||||
|
set_cursor(TASK_WIN, oldcur);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
line = brw.set_text(f, "CALCOLO LIQUIDAZIONE D'IMPOSTA");
|
line = brw.set_text(f, "CALCOLO LIQUIDAZIONE D'IMPOSTA");
|
||||||
|
brw.goto_pos(brw.lines()-16l, 9);
|
||||||
|
|
||||||
if (line != -1)
|
real risultato = _lim->get_real("R0");
|
||||||
brw.goto_pos(line-1l, 9);
|
risultato += (rimborso + rettifica - acconto);
|
||||||
msk.run();
|
|
||||||
|
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);
|
remove(f);
|
||||||
@ -405,6 +536,26 @@ remove(f);
|
|||||||
return TRUE;
|
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[])
|
int cg5500(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
Visliq_app app;
|
Visliq_app app;
|
||||||
|
@ -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:
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user