d78ec66ffa
git-svn-id: svn://10.65.10.50/trunk@1020 c028cbd2-c16b-5b4b-a496-9718f37d4682
360 lines
8.2 KiB
C++
Executable File
360 lines
8.2 KiB
C++
Executable File
// cg4306: liquidazione IVA
|
|
// funzionalita' accessorie (calcolo acconto, estrazione deleghe)
|
|
|
|
#include <defmask.h>
|
|
#include <progind.h>
|
|
#include <prefix.h>
|
|
#include <sheet.h>
|
|
#include <utility.h>
|
|
|
|
#include "cg4300.h"
|
|
#include "cg4300b.h"
|
|
#include "cg4300c.h"
|
|
|
|
// -------------------------------------------------- estrazione deleghe
|
|
bool TLiquidazione_app::set_deleghe()
|
|
{
|
|
TMask m("cg4300b.msk");
|
|
|
|
m.field(FLD_CGB_YEAR).set(_year);
|
|
m.field(FLD_CGB_YEAR).set_handler(ch_year_handler);
|
|
m.field(CHK_CGB_PRINT).set(_isprint ? "X" : "");
|
|
|
|
int k = 0;
|
|
long j;
|
|
_calcall = FALSE;
|
|
|
|
for (;;)
|
|
{
|
|
if (k == K_ESC || k == K_ENTER)
|
|
break;
|
|
|
|
k = m.run();
|
|
|
|
_isprint = m.get_bool(CHK_CGB_PRINT);
|
|
|
|
switch (k)
|
|
{
|
|
case DLG_SELECT:
|
|
|
|
_ditte->run();
|
|
for (j = 0l; j < _ditte->items(); j++)
|
|
if (_ditte->checked(j)) _selected.set(j);
|
|
break;
|
|
|
|
case BUT_CGB_ALL:
|
|
|
|
_ditte->check(-1);
|
|
for (j = 0l; j < _ditte->items(); j++)
|
|
if (_ditte->checked(j) && !_ditte->disabled(j))
|
|
_selected.set(j);
|
|
_calcall = TRUE;
|
|
k = K_ENTER;
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (k == K_ENTER)
|
|
{
|
|
_year = m.get(FLD_CGB_YEAR);
|
|
_month = atoi(m.get(FLD_CGB_MONTH));
|
|
}
|
|
|
|
return k == K_ENTER;
|
|
}
|
|
|
|
bool TLiquidazione_app::extract_deleghe()
|
|
{
|
|
char buf[256]; TArray desc;
|
|
_prind = new TProgind(_calcall ? _n_ditte : _selected.ones(),
|
|
" Estrazione deleghe \n"
|
|
" preparazione archivi \n "
|
|
" \n ",
|
|
TRUE,TRUE,40);
|
|
|
|
for (int l = 0; l < _ditte->items(); l++)
|
|
{
|
|
if (_prind->iscancelled())
|
|
break;
|
|
|
|
if (!(_calcall || _selected[l]) || _ditte->disabled(l))
|
|
continue;
|
|
|
|
TApplication::set_firm(atol(_ditte->row(l).get(1)));
|
|
|
|
_nditte->curr().zero();
|
|
_nditte->curr().put("CODDITTA",_ditte->row(l).get(1));
|
|
_nditte->read();
|
|
|
|
// must succeed
|
|
look_lia();
|
|
_freqviva = _lia->get("S7");
|
|
|
|
sprintf (buf,"Estrazione deleghe (%d):\nditta %s\n ",
|
|
_month,
|
|
(const char*)_nditte_r->get("RAGSOC"));
|
|
_prind->set_text(buf);
|
|
|
|
|
|
if (is_month_ok_strict(_month) || _month == 13)
|
|
{
|
|
_isbenzinaro = _nditte->curr(LF_ATTIV).get_bool("ART74/4");
|
|
bool mens = _freqviva == "M";
|
|
_isannual = (_month == 12 && !mens && !_isbenzinaro) ||
|
|
(_month == 13 && (mens || _isbenzinaro));
|
|
_isriepilogo = _month == 13;
|
|
_isendliq = _isannual || _isriepilogo;
|
|
|
|
extract_delega(_month, desc);
|
|
}
|
|
_prind->addstatus(1);
|
|
}
|
|
|
|
TApplication::set_firm(__firm);
|
|
delete _prind;
|
|
|
|
if (_isprint)
|
|
{
|
|
_DescrItem* ddeb = NULL;
|
|
_DescrItem* dcrd = NULL;
|
|
|
|
// scorri desc e prepara descritems
|
|
for (int i = 0; i < desc.items(); i++)
|
|
{
|
|
TToken_string& tt = (TToken_string&)desc[i];
|
|
|
|
real tp(tt.get(3));
|
|
if (tp.sign() > 0)
|
|
{
|
|
if (ddeb == NULL)
|
|
{
|
|
ddeb = new _DescrItem(DELDEB);
|
|
ddeb->_f0 = _month;
|
|
}
|
|
ddeb->_arr.add(tt);
|
|
}
|
|
else
|
|
{
|
|
if (dcrd == NULL)
|
|
{
|
|
dcrd = new _DescrItem(DELCRED);
|
|
dcrd->_f0 = _month;
|
|
}
|
|
dcrd->_arr.add(tt);
|
|
}
|
|
}
|
|
if (dcrd != NULL) _descr_arr.add(dcrd);
|
|
if (ddeb != NULL) _descr_arr.add(ddeb);
|
|
}
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
bool TLiquidazione_app::extract_delega(int month, TArray& desc)
|
|
{
|
|
TToken_string* tt = NULL;
|
|
|
|
if (look_lim(month))
|
|
{
|
|
real topay = result_liq(month);
|
|
real intr = _lim->get_real("R14");
|
|
|
|
if (!topay.is_zero())
|
|
{
|
|
tt = new TToken_string(80);
|
|
tt->add(_nditte->curr().get("CODDITTA"));
|
|
tt->add(_nditte->curr().get("RAGSOC"));
|
|
tt->add(_freqviva);
|
|
tt->add(topay.string());
|
|
tt->add(intr.string());
|
|
}
|
|
|
|
if (topay.sign() > 0)
|
|
{
|
|
look_del(month, _isannual ? 2 : 1, TRUE);
|
|
_del->put("R0",topay);
|
|
_del->put("R1",intr);
|
|
_del->rewrite();
|
|
|
|
tt->add(_del->get("S7"));
|
|
tt->add(_del->get("S8"));
|
|
tt->add(_del->get("S9"));
|
|
tt->add(_nditte->curr().get("PTEL"));
|
|
tt->add(_nditte->curr().get("TEL"));
|
|
}
|
|
}
|
|
|
|
if (tt != NULL)
|
|
desc.add(tt);
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
// -------------------------------------------- calcolo acconto dicembre
|
|
bool TLiquidazione_app::set_acconto()
|
|
{
|
|
TMask m("cg4300c.msk");
|
|
m.set(CHK_CGC_PRINT,"X");
|
|
m.field(FLD_CGC_YEAR).set_handler(ch_year_handler);
|
|
|
|
int k = 0; long j;
|
|
|
|
_calcall = FALSE;
|
|
|
|
for (;;)
|
|
{
|
|
if (k == K_ESC || k == K_ENTER)
|
|
break;
|
|
k = m.run();
|
|
|
|
_year = m.get(FLD_CGC_YEAR);
|
|
_isprint = m.get_bool(CHK_CGC_PRINT);
|
|
_isbase = m.get_bool(CHK_CGC_BASE);
|
|
_basecalc = (tbc)m.get_long(RDB_CGC_BASE);
|
|
|
|
switch (k)
|
|
{
|
|
case DLG_SELECT:
|
|
|
|
// scegli ditte
|
|
_ditte->run();
|
|
|
|
for (j = 0l; j < _ditte->items(); j++)
|
|
if (_ditte->checked(j)) _selected.set(j);
|
|
|
|
break;
|
|
case BUT_CGC_ALL:
|
|
_ditte->check(-1);
|
|
for (j = 0l; j < _ditte->items(); j++)
|
|
if (_ditte->checked(j) && !_ditte->disabled(j))
|
|
_selected.set(j);
|
|
_calcall = TRUE;
|
|
k = K_ENTER;
|
|
break;
|
|
}
|
|
}
|
|
return k == K_ENTER;
|
|
}
|
|
|
|
|
|
bool TLiquidazione_app::recalc_acconti()
|
|
{
|
|
char buf[256];
|
|
|
|
bool onemade = FALSE;
|
|
|
|
long firm = TApplication::get_firm();
|
|
_prind = new TProgind(_n_ditte,
|
|
" Calcolo acconto "
|
|
"\n Preparazione archivi "
|
|
"\n ",
|
|
TRUE,TRUE,40);
|
|
|
|
for (int l = 0; l < _ditte->items(); l++)
|
|
{
|
|
if (_prind->iscancelled())
|
|
break;
|
|
if ((_calcall || _selected[l]) && !_ditte->disabled(l))
|
|
{
|
|
if (onemade == FALSE && _isprint)
|
|
{
|
|
_DescrItem* d = new _DescrItem(ACCHEAD);
|
|
d->_f0 = _basecalc == incorso;
|
|
d->_f1 = _isbase;
|
|
_descr_arr.add(d);
|
|
}
|
|
|
|
_nditte->curr().zero();
|
|
_nditte->curr().put("CODDITTA",_ditte->row(l).get(1));
|
|
_nditte->read();
|
|
|
|
TApplication::set_firm(_nditte->curr().get_long("CODDITTA"));
|
|
sprintf (buf,"Calcolo acconto:\nditta %s",
|
|
(const char*)_nditte_r->get("RAGSOC"));
|
|
_prind->set_text(buf);
|
|
recalc_acconto();
|
|
onemade = TRUE;
|
|
}
|
|
_prind->addstatus(1);
|
|
}
|
|
|
|
TApplication::set_firm(firm);
|
|
delete _prind;
|
|
return TRUE;
|
|
}
|
|
|
|
bool TLiquidazione_app::recalc_acconto()
|
|
{
|
|
real basecalcolo, acconto;
|
|
bool isdifferita = FALSE;
|
|
bool error = FALSE;
|
|
|
|
// this is absolutely fundamental
|
|
|
|
if (_basecalc == incorso)
|
|
{
|
|
// that's pazzesc but as it turns out there's no better way
|
|
_comp_acconto = TRUE;
|
|
// force recalc of current month
|
|
_recalc = one;
|
|
// insozza il water
|
|
update_firm(12);
|
|
|
|
// calcola l'acconto
|
|
if (look_lim(12))
|
|
{
|
|
basecalcolo = result_liq(12);
|
|
if (basecalcolo.sign() > 0)
|
|
acconto = basecalcolo * ACCONTO_DICEMBRE;
|
|
}
|
|
else acconto = real(-1.0);
|
|
// pulisci il water
|
|
_comp_acconto = FALSE;
|
|
update_firm(12);
|
|
}
|
|
else if (_basecalc == precedente)
|
|
{
|
|
int yr = atoi(_year);
|
|
_year = format("%d",yr-1);
|
|
if (look_lim(12))
|
|
{
|
|
basecalcolo = result_liq(12);
|
|
if (basecalcolo.sign() > 0)
|
|
acconto = basecalcolo * ACCONTO_DICEMBRE;
|
|
}
|
|
else error = TRUE;
|
|
_year = format("%d", yr);
|
|
}
|
|
|
|
// sbatti l'acconto in LIA
|
|
if (look_lia())
|
|
{
|
|
_lia->put("R4",acconto);
|
|
isdifferita = _lia->get_bool("B1");
|
|
_lia->rewrite();
|
|
}
|
|
|
|
if (acconto.sign() > 0)
|
|
{
|
|
// crea o aggiorna delega
|
|
look_del(12,7,TRUE);
|
|
_del->put("R0", acconto);
|
|
_del->rewrite();
|
|
}
|
|
|
|
// per questa volta lasciamo perdere la describe_acconto
|
|
if (_isprint)
|
|
{
|
|
_DescrItem* d = new _DescrItem(ACCONTO);
|
|
d->_r0 = basecalcolo;
|
|
d->_r1 = acconto;
|
|
d->_f0 = _basecalc == incorso;
|
|
d->_f1 = _isbase;
|
|
d->_f2 = error;
|
|
d->_f3 = isdifferita;
|
|
d->_s0 = _nditte->curr().get("CODDITTA");
|
|
d->_s1 = _nditte->curr().get("RAGSOC");
|
|
_descr_arr.add(d);
|
|
}
|
|
return TRUE;
|
|
} |