699 lines
19 KiB
C++
Executable File
699 lines
19 KiB
C++
Executable File
// Programma per la gestione e la stampa della dichiarazione periodica IVA
|
||
#include <applicat.h>
|
||
#include <automask.h>
|
||
#include <currency.h>
|
||
#include <form.h>
|
||
#include <prefix.h>
|
||
#include <progind.h>
|
||
#include <recarray.h>
|
||
#include <recset.h>
|
||
#include <sheet.h>
|
||
#include <tabutil.h>
|
||
|
||
#include <nditte.h>
|
||
#include <causali.h>
|
||
#include <mov.h>
|
||
#include <rmoviva.h>
|
||
|
||
#include "cg5700.h"
|
||
#include "cglib03.h"
|
||
|
||
class TDich_periodica_selfirm_mask : public TAutomask
|
||
{
|
||
TArray_sheet * _ditte;
|
||
TString_array _nomiditte;
|
||
int _year;
|
||
|
||
protected:
|
||
bool select_button();
|
||
void build_ditte_sheet();
|
||
|
||
public:
|
||
const int get_year() const { return _year; }
|
||
virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly);
|
||
TDich_periodica_selfirm_mask();
|
||
virtual ~TDich_periodica_selfirm_mask();
|
||
};
|
||
|
||
TDich_periodica_selfirm_mask::TDich_periodica_selfirm_mask() : TAutomask("cg5700a")
|
||
{
|
||
_ditte = new TArray_sheet(-1, -1, 70, 15, TR("Selezione Ditte"), HR("Codice@6R|Ragione Sociale@50"));
|
||
}
|
||
|
||
TDich_periodica_selfirm_mask::~TDich_periodica_selfirm_mask()
|
||
{
|
||
delete _ditte;
|
||
}
|
||
|
||
void TDich_periodica_selfirm_mask::build_ditte_sheet()
|
||
{
|
||
TTable pum("PUM");
|
||
|
||
_ditte->destroy();
|
||
TPointer_array firms;
|
||
TPrefix::firms(firms);
|
||
|
||
long good_company = -1;
|
||
|
||
FOR_EACH_ARRAY_ITEM(firms, i, obj)
|
||
{
|
||
TToken_string* d = new TToken_string(63);
|
||
const long codditta = firms.get_long(i);
|
||
d->add(codditta);
|
||
d->add(cache().get(LF_NDITTE, codditta, NDT_RAGSOC));
|
||
const long pos = _ditte->add(d);
|
||
|
||
pum.put("CODTAB", _year);
|
||
if (pum.read(_isgteq) == NOERR && atoi(pum.get("CODTAB").left(4)) == _year)
|
||
{
|
||
if (good_company <= 0)
|
||
good_company = pos;
|
||
}
|
||
else
|
||
_ditte->disable_row(pos);
|
||
}
|
||
|
||
if (good_company >= 0)
|
||
{
|
||
TToken_string& row = _ditte->row(good_company);
|
||
set(F_CODDITTA, row.get(0));
|
||
set(F_RAGSOC, row.get(1));
|
||
}
|
||
else
|
||
{
|
||
reset(F_CODDITTA);
|
||
reset(F_RAGSOC);
|
||
}
|
||
}
|
||
|
||
bool TDich_periodica_selfirm_mask::select_button()
|
||
{
|
||
if (_ditte->run() == K_ENTER)
|
||
{
|
||
TToken_string& row = _ditte->row(_ditte->selected());
|
||
set(F_CODDITTA, row.get(0));
|
||
set(F_RAGSOC, row.get(1));
|
||
return true;
|
||
}
|
||
return false;
|
||
}
|
||
|
||
bool TDich_periodica_selfirm_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
|
||
{
|
||
switch (o.dlg())
|
||
{
|
||
case F_CODDITTA:
|
||
if (e == fe_button)
|
||
return select_button();
|
||
|
||
if (e == fe_modify)
|
||
{
|
||
bool found = false;
|
||
const long ditta = atol(o.get());
|
||
for (long i = 0; i < _ditte->items(); i++)
|
||
{
|
||
TToken_string& row = _ditte->row(i);
|
||
if (ditta == row.get_long(0))
|
||
{
|
||
if (_ditte->row_enabled(i))
|
||
{
|
||
set(F_CODDITTA, row.get(0));
|
||
set(F_RAGSOC, row.get(1));
|
||
found = true;
|
||
}
|
||
break;
|
||
}
|
||
}
|
||
if (!found)
|
||
o.reset();
|
||
return found;
|
||
}
|
||
break;
|
||
case F_RAGSOC:
|
||
if (e == fe_button)
|
||
return select_button();
|
||
if (e == fe_modify)
|
||
{
|
||
bool found = false;
|
||
TString16 ditta = o.get();
|
||
for (int i = 0; i < _ditte->items(); i++)
|
||
{
|
||
TToken_string& row = _ditte->row(i);
|
||
TString ts(row.get(1));
|
||
if (ts.find(ditta) != -1)
|
||
{
|
||
if (_ditte->row_enabled(i))
|
||
{
|
||
set(F_CODDITTA, row.get(0));
|
||
set(F_RAGSOC, row.get(1));
|
||
found = true;
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
if (!found) o.reset();
|
||
return found;
|
||
}
|
||
break;
|
||
case F_YEAR:
|
||
if (e == fe_init && o.empty())
|
||
{
|
||
const TDate oggi(TODAY);
|
||
o.set(oggi.year()-1);
|
||
e = fe_modify;
|
||
}
|
||
if (e == fe_modify)
|
||
{
|
||
_year = atoi(o.get());
|
||
build_ditte_sheet();
|
||
}
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
|
||
return true;
|
||
}
|
||
|
||
bool change_prompt(TString& p, int year)
|
||
{
|
||
bool changed = false;
|
||
if (p.left(2) == "VP")
|
||
{
|
||
const int vp = atoi(p.mid(2,2));
|
||
if (year >= 2001)
|
||
{
|
||
if (vp >= 5)
|
||
{
|
||
switch (vp)
|
||
{
|
||
case 6:
|
||
p = TR("VP11 - IVA detratta per il periodo");
|
||
break;
|
||
case 9:
|
||
p = TR("VP14 - IVA non versata o in eccesso da dich. prec.");
|
||
break;
|
||
default:
|
||
TString4 n;
|
||
n.format("%2d", vp+5);
|
||
p.overwrite(n, 2);
|
||
break;
|
||
}
|
||
changed = true;
|
||
}
|
||
}
|
||
}
|
||
return changed;
|
||
}
|
||
|
||
|
||
class TDich_periodica_iva_form : public TForm
|
||
{
|
||
public:
|
||
TDich_periodica_iva_form(int anno);
|
||
};
|
||
|
||
TDich_periodica_iva_form::TDich_periodica_iva_form(int anno) : TForm("cg5700a")
|
||
{
|
||
TPrint_section& b = section('B', odd_page);
|
||
TString p;
|
||
for (int i = b.fields()-1; i > 0; i--)
|
||
{
|
||
TForm_item& f = b.field(i);
|
||
p = f.prompt();
|
||
if (change_prompt(p, anno))
|
||
f.set_prompt(p);
|
||
}
|
||
}
|
||
|
||
///////////////////////////////////////////////////////////
|
||
// TDich_periodica_iva_mask
|
||
///////////////////////////////////////////////////////////
|
||
|
||
struct Tcd
|
||
{
|
||
real cd1_1, cd1_1s, cd1_2, cd1_3, cd1_4, cd1_5;
|
||
real cd2_1, cd2_1s, cd2_2, cd2_3, cd2_4, cd2_5;
|
||
real cd3_1, cd3_2, cd3_3, cd3_4;
|
||
|
||
void Reset() { memset(this,0, sizeof(Tcd)); }
|
||
};
|
||
|
||
class TDich_periodica_iva_mask : public TAutomask
|
||
{
|
||
TDich_periodica_selfirm_mask * _sf;
|
||
bool _dirty_versament; // Sporco versamento...
|
||
|
||
protected:
|
||
void read_iva_data();
|
||
real imposta_diff(int tipo) const;
|
||
void calc_cd_new(int anno, Tcd& s) const;
|
||
//void calc_cd_old(int anno, Tcd& s) const;
|
||
|
||
public:
|
||
void set_prospect();
|
||
void print_prospect();
|
||
virtual bool on_key(KEY k);
|
||
virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly);
|
||
TDich_periodica_iva_mask(TDich_periodica_selfirm_mask *m);
|
||
};
|
||
|
||
TDich_periodica_iva_mask::TDich_periodica_iva_mask(TDich_periodica_selfirm_mask *m)
|
||
: TAutomask("cg5700b")
|
||
{
|
||
_sf = m;
|
||
|
||
const int anno = _sf->get_int(F_YEAR);
|
||
if (anno > 2000)
|
||
{
|
||
TString p;
|
||
for (int i = fields()-1; i > 0; i--)
|
||
{
|
||
TMask_field& f = fld(i);
|
||
p = f.prompt();
|
||
if (change_prompt(p, anno))
|
||
f.set_prompt(p);
|
||
}
|
||
}
|
||
}
|
||
|
||
// tipo=1 vendite; 2=acquisti
|
||
real TDich_periodica_iva_mask::imposta_diff(int tipo) const
|
||
{
|
||
real imposta;
|
||
|
||
const int anno = _sf->get_year();
|
||
TString query;
|
||
query << "USE IVADIFF KEY 2"
|
||
<< "\nSELECT (TIPOMOV>2)&&(MESELIQ<13)&&(TIPOIVA=" << tipo << ')'
|
||
<< "\nFROM ANNOLIQ=" << anno
|
||
<< "\nTO ANNOLIQ=" << anno;
|
||
TISAM_recordset id(query);
|
||
|
||
TProgress_monitor pi(id.items(), TR("Calcolo IVA differita"));
|
||
for (bool ok = id.move_first(); ok; ok = id.move_next())
|
||
{
|
||
imposta += id.get(RMI_IMPOSTA).as_real();
|
||
pi.add_status();
|
||
}
|
||
return imposta;
|
||
}
|
||
|
||
void TDich_periodica_iva_mask::calc_cd_new(int anno, Tcd& s) const
|
||
{
|
||
s.Reset();
|
||
|
||
TString query;
|
||
query << "USE MOV KEY 2"
|
||
<< "\nSELECT (ANNOIVA==#ANNO)"
|
||
<< "\nFROM DATAREG=#DAL"
|
||
<< "\nTO DATAREG=#AL";
|
||
|
||
TISAM_recordset movs(query);
|
||
movs.set_var("#ANNO", long(anno));
|
||
movs.set_var("#DAL", TDate(1,1,anno));
|
||
movs.set_var("#AL", TDate(31,12,anno));
|
||
|
||
const TRectype& mov = movs.cursor()->curr(LF_MOV);
|
||
|
||
TProgress_monitor pi(movs.items(), TR("Ricalcolo righe IVA"));
|
||
|
||
TFilename ivalog; ivalog.tempdir(); ivalog.add("cg5700log.txt");
|
||
ofstream flog(ivalog);
|
||
flog << "NUMREG\tRIGA\tDATA\tREG\tDIFF\tIMPONIBILE\tIVA\tIMPOSTA\tCD\tNORMALE\tDIFFERITA\tXCASSA\tSPLIT\tNOTE" << endl;
|
||
|
||
for (bool go = movs.move_first(); go; go = movs.move_next())
|
||
{
|
||
if (!pi.add_status())
|
||
break;
|
||
|
||
TToken_string tok(127, '\t');
|
||
tok.add(mov.get(MOV_NUMREG));
|
||
tok.add(0);
|
||
tok.add(mov.get(MOV_DATAREG));
|
||
tok.add(mov.get(MOV_REG));
|
||
|
||
TString8 regkey; regkey.format("%04d%s", anno, (const char*)mov.get(MOV_REG));
|
||
const TRectype& reg = cache().get("REG", regkey);
|
||
const int tipo_reg = reg.get_int("I0");
|
||
|
||
bool skipped = false;
|
||
if (tipo_reg != 1 && tipo_reg != 2)
|
||
{
|
||
tok.add("Registro n<> vendite n<> acquisti", 13);
|
||
flog << tok << endl;
|
||
skipped = true;
|
||
}
|
||
const int sosp_imp = reg.get_bool("B1") ? reg.get_int("I9") : 0;
|
||
if (sosp_imp == 1 || sosp_imp == 3)
|
||
{
|
||
tok.add("Registro in sospensione", 13);
|
||
flog << tok << endl;
|
||
skipped = true;
|
||
}
|
||
|
||
const TString& tipodoc = mov.get(MOV_TIPODOC);
|
||
if (tipodoc == "AF")
|
||
{
|
||
tok.add("Autofattura", 13);
|
||
flog << tok << endl;
|
||
skipped = true;
|
||
}
|
||
|
||
const TRectype& cau = cache().get(LF_CAUSALI, mov.get(MOV_CODCAUS));
|
||
const bool iva_intra = cau.get_bool(CAU_INTRACOM);
|
||
const bool iva_split = anno >= 2015 && tipo_reg == 1 && is_split_payment(mov);
|
||
const bool iva_diff = !iva_split && is_IVA_diff(mov);
|
||
const bool iva_cassa = !iva_diff && is_IVAxCassa(mov);
|
||
const bool iva_speciale = iva_split || iva_diff || iva_cassa;
|
||
|
||
if (iva_speciale)
|
||
tok.add(iva_split ? "SPLIT" : (iva_diff ? "DIFF" : "XCASSA"), 4);
|
||
|
||
TRecord_array rmoviva(mov.get(MOV_NUMREG), LF_RMOVIVA);
|
||
const int nlast = rmoviva.last_row();
|
||
for (int nr = 1; nr <= nlast; nr++)
|
||
{
|
||
const TRectype& rmi = rmoviva.row(nr);
|
||
const real imponibile = rmi.get(RMI_IMPONIBILE);
|
||
const real imposta = rmi.get(RMI_IMPOSTA);
|
||
const int tipo_cr = rmi.get_int(RMI_TIPOCR);
|
||
const TString& codiva = rmi.get(RMI_CODIVA);
|
||
const TString4 iva_vpn = skipped ? EMPTY_STRING : cache().get("%IVA", codiva, tipo_reg == 1 ? "S10" : "S11");
|
||
tok.add(nr, 1);
|
||
tok.add(imponibile.stringe(0, 2), 5);
|
||
tok.add(codiva, 6);
|
||
tok.add(imposta.stringe(0, 2), 7);
|
||
tok.add(iva_vpn, 8);
|
||
if (iva_vpn.blank())
|
||
{
|
||
if (!skipped) tok.add("Codice IVA non rilevante", 13);
|
||
flog << tok << endl;
|
||
continue;
|
||
}
|
||
|
||
if (tipo_reg == 1)
|
||
{
|
||
s.cd1_1 += imponibile;
|
||
if (iva_speciale)
|
||
s.cd1_1s += imponibile;
|
||
|
||
if (iva_vpn.starts_with("CD1"))
|
||
{
|
||
if (tipo_cr == 4)
|
||
s.cd1_5 += imponibile;
|
||
}
|
||
if (!iva_intra)
|
||
{
|
||
if (iva_vpn == "CD12")
|
||
s.cd1_2 += imponibile; else
|
||
if (iva_vpn == "CD13")
|
||
s.cd1_3 += imponibile;
|
||
}
|
||
else
|
||
{
|
||
if (iva_vpn == "CD14")
|
||
s.cd1_4 += imponibile;
|
||
}
|
||
} else
|
||
if (tipo_reg == 2)
|
||
{
|
||
s.cd2_1 += imponibile;
|
||
if (iva_speciale)
|
||
s.cd2_1s += imponibile;
|
||
if (iva_vpn.starts_with("CD2"))
|
||
{
|
||
if (tipo_cr == 2 || tipo_cr == 3 || tipo_cr == 8)
|
||
s.cd2_5 += imponibile;
|
||
}
|
||
if (!iva_intra)
|
||
{
|
||
if (iva_vpn == "CD22")
|
||
s.cd2_2 += imponibile;
|
||
else
|
||
if (iva_vpn == "CD23")
|
||
s.cd2_3 += imponibile;
|
||
}
|
||
else
|
||
{
|
||
if (iva_vpn == "CD24")
|
||
s.cd2_4 += imponibile;
|
||
}
|
||
if (iva_vpn == "CD31")
|
||
{
|
||
s.cd3_1 += imponibile;
|
||
s.cd3_2 += imposta;
|
||
}
|
||
if (iva_vpn == "CD33")
|
||
{
|
||
s.cd3_3 += imponibile;
|
||
s.cd3_4 += imposta;
|
||
}
|
||
}
|
||
|
||
TToken_string row = tok;
|
||
row.add("", 13);
|
||
const int index = iva_split ? 12 : (iva_cassa ? 11 : (iva_diff ? 10 : 9));
|
||
row.add(imponibile.stringe(0, 2), index);
|
||
flog << row << endl;
|
||
}
|
||
}
|
||
}
|
||
|
||
/*
|
||
void TDich_periodica_iva_mask::calc_cd_old(int anno, Tcd& s) const
|
||
{
|
||
s.Reset();
|
||
|
||
TRelation relpum("PUM");
|
||
TRectype& pum = relpum.curr();
|
||
TString4 key; key.format("%04d", anno);
|
||
pum.put("CODTAB", key);
|
||
TCursor cur(&relpum, "", 1, &pum, &pum);
|
||
|
||
const TRecnotype items = cur.items();
|
||
cur.freeze();
|
||
for (cur = 0L; cur.pos() < items; ++cur)
|
||
{
|
||
const TString& codtab = pum.get("CODTAB");
|
||
const TString& annoiva = codtab.left(4);
|
||
if (annoiva != key)
|
||
break;
|
||
if (atoi(codtab.right(2)) == 13) // Solo annuale
|
||
{
|
||
s.cd1_1 += pum.get_real("R14");
|
||
s.cd1_2 += pum.get_real("R15");
|
||
s.cd1_3 += pum.get_real("R16");
|
||
s.cd1_4 += pum.get_real("R17");
|
||
s.cd2_1 += pum.get_real("R18");
|
||
s.cd2_2 += pum.get_real("R19");
|
||
s.cd2_3 += pum.get_real("R20");
|
||
s.cd2_4 += pum.get_real("R21");
|
||
s.cd3_1 += pum.get_real("R22");
|
||
s.cd3_2 += pum.get_real("R23");
|
||
s.cd3_3 += pum.get_real("R24");
|
||
s.cd3_4 += pum.get_real("R25");
|
||
s.cd2_5 += pum.get_real("R26");
|
||
s.cd1_5 += pum.get_real("R27");
|
||
|
||
// Novit<69> 2016
|
||
s.cd1_1s += pum.get_real("R29"); // vendite in split dal 2015 (gi<67> comprese in cd1_1!)
|
||
}
|
||
}
|
||
}
|
||
*/
|
||
|
||
void TDich_periodica_iva_mask::read_iva_data()
|
||
{
|
||
const int anno = _sf->get_year();
|
||
TString8 key; key.format("%4d13", anno);
|
||
const TRectype& lim = cache().get("LIM", key);
|
||
|
||
if (lim.get_bool("B0"))
|
||
{
|
||
const TRectype& lam = cache().get("LAM", key);
|
||
TString descrizione(120); descrizione << lim.get("S0") << lim.get("S1");
|
||
const bool exclude_sign = descrizione.find("$$") >= 0 || descrizione.find(">>") >= 0;
|
||
|
||
//Tcd cd_old; calc_cd_old(anno, cd_old);
|
||
Tcd cd_new; calc_cd_new(anno, cd_new);
|
||
|
||
real cd1_1 = cd_new.cd1_1; cd1_1.round();
|
||
real cd1_1s = cd_new.cd1_1s; cd1_1s.round();
|
||
real cd1_2 = cd_new.cd1_2; cd1_2.round();
|
||
real cd1_3 = cd_new.cd1_3; cd1_3.round();
|
||
real cd1_4 = cd_new.cd1_4; cd1_4.round();
|
||
real cd1_5 = cd_new.cd1_5; cd1_5.round();
|
||
|
||
real cd2_1 = cd_new.cd2_1; cd2_1.round();
|
||
real cd2_1s = cd_new.cd2_1s; cd2_1s.round();
|
||
real cd2_2 = cd_new.cd2_2; cd2_2.round();
|
||
real cd2_3 = cd_new.cd2_3; cd2_3.round();
|
||
real cd2_4 = cd_new.cd2_4; cd2_4.round();
|
||
real cd2_5 = cd_new.cd2_5; cd2_5.round();
|
||
|
||
real cd3_1 = cd_new.cd3_1; cd3_1.round();
|
||
real cd3_2 = cd_new.cd3_2; cd3_2.round();
|
||
real cd3_3 = cd_new.cd3_3; cd3_3.round();
|
||
real cd3_4 = cd_new.cd3_4; cd3_4.round();
|
||
|
||
const real rettifica = lim.get_real("R5"); // Rettifiche
|
||
|
||
real cd4 = lam.get_real("R0"); // Iva esigibile per il periodo
|
||
cd4 += imposta_diff(1);
|
||
if (rettifica > ZERO)
|
||
cd4 += rettifica;
|
||
cd4.round();
|
||
|
||
real cd5 = lam.get_real("R1"); // Iva che si detrae per il periodo
|
||
cd5 += imposta_diff(2);
|
||
if (rettifica < ZERO && !exclude_sign)
|
||
cd5 += abs(rettifica);
|
||
cd5.round();
|
||
|
||
const real cd6 = cd4 - cd5; // IVA a debito o credito per il periodo
|
||
real cd6_1, cd6_2;
|
||
if (cd6 >= ZERO)
|
||
cd6_1 = cd6;
|
||
else
|
||
cd6_2 = -cd6;
|
||
|
||
set(F_CD1_1, cd1_1); set(F_CD1_2, cd1_2); set(F_CD1_3, cd1_3); set(F_CD1_4, cd1_4); set(F_CD1_5, cd1_5);
|
||
set(F_CD2_1, cd2_1); set(F_CD2_2, cd2_2); set(F_CD2_3, cd2_3); set(F_CD2_4, cd2_4); set(F_CD2_5, cd2_5);
|
||
set(F_CD3_1, cd3_1); set(F_CD3_2, cd3_2); set(F_CD3_3, cd3_3); set(F_CD3_4, cd3_4);
|
||
set(F_CD4, cd4); set(F_CD5, cd5);
|
||
set(F_CD6_1, cd6_1); set(F_CD6_2, cd6_2);
|
||
|
||
set(F_CD1_1S, cd1_1s); // dal 2016
|
||
}
|
||
else
|
||
error_box("Risultati liquidazione non presenti o da ricalcolare per l'anno %d.", anno);
|
||
}
|
||
|
||
void TDich_periodica_iva_mask::print_prospect()
|
||
{
|
||
const int anno = _sf->get_int(F_YEAR);
|
||
TDich_periodica_iva_form frm(anno);
|
||
|
||
frm.find_field('B', odd_page, FF_YEAR).set(get(F_YEAR));
|
||
|
||
frm.find_field('B', odd_page, FF_CD1_1).set(get(F_CD1_1));
|
||
frm.find_field('B', odd_page, FF_CD1_2).set(get(F_CD1_2));
|
||
frm.find_field('B', odd_page, FF_CD1_3).set(get(F_CD1_3));
|
||
frm.find_field('B', odd_page, FF_CD1_4).set(get(F_CD1_4));
|
||
frm.find_field('B', odd_page, FF_CD1_5).set(get(F_CD1_5));
|
||
|
||
frm.find_field('B', odd_page, FF_CD2_1).set(get(F_CD2_1));
|
||
frm.find_field('B', odd_page, FF_CD2_2).set(get(F_CD2_2));
|
||
frm.find_field('B', odd_page, FF_CD2_3).set(get(F_CD2_3));
|
||
frm.find_field('B', odd_page, FF_CD2_4).set(get(F_CD2_4));
|
||
frm.find_field('B', odd_page, FF_CD2_5).set(get(F_CD2_5));
|
||
|
||
frm.find_field('B', odd_page, FF_CD3_1).set(get(F_CD3_1));
|
||
frm.find_field('B', odd_page, FF_CD3_2).set(get(F_CD3_2));
|
||
|
||
frm.find_field('B', odd_page, FF_CD3_3).set(get(F_CD3_3));
|
||
frm.find_field('B', odd_page, FF_CD3_4).set(get(F_CD3_3));
|
||
|
||
frm.find_field('B', odd_page, FF_CD4).set(get(F_CD4));
|
||
frm.find_field('B', odd_page, FF_CD5).set(get(F_CD5));
|
||
|
||
frm.find_field('B', odd_page, FF_CD6_1).set(get(F_CD6_1));
|
||
frm.find_field('B', odd_page, FF_CD6_2).set(get(F_CD6_2));
|
||
|
||
TRectype f(LF_NDITTE);
|
||
f.put(NDT_CODDITTA, get(F_CODDITTA));
|
||
|
||
frm.cursor()->setregion(f,f);
|
||
frm.print();
|
||
}
|
||
|
||
void TDich_periodica_iva_mask::set_prospect()
|
||
{
|
||
CHECK(_sf, "Invalid mask");
|
||
|
||
_dirty_versament = false;
|
||
|
||
const int anno = _sf->get_year();
|
||
const long ditta = _sf->get_long(F_CODDITTA);
|
||
|
||
set(F_YEAR, anno);
|
||
set(F_CODDITTA, ditta);
|
||
set(F_RAGSOC, _sf->get(F_RAGSOC));
|
||
|
||
TFirm frm(ditta);
|
||
|
||
TIva_round ir;
|
||
ir.set_default_iva_mode(anno, false, ditta);
|
||
|
||
read_iva_data();
|
||
}
|
||
|
||
bool TDich_periodica_iva_mask::on_key(KEY k)
|
||
{
|
||
return TAutomask::on_key(k);
|
||
}
|
||
|
||
bool TDich_periodica_iva_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
|
||
{
|
||
return true;
|
||
}
|
||
|
||
class TDich_periodica_iva_app : public TSkeleton_application
|
||
{
|
||
protected:
|
||
virtual bool create();
|
||
virtual bool destroy();
|
||
virtual void main_loop();
|
||
public:
|
||
virtual bool firm_change_enabled() const { return false; }
|
||
TDich_periodica_iva_app () {};
|
||
virtual ~TDich_periodica_iva_app () {};
|
||
};
|
||
|
||
bool TDich_periodica_iva_app::create()
|
||
{
|
||
open_files(LF_TAB, LF_TABCOM, LF_NDITTE, 0);
|
||
return TSkeleton_application::create();
|
||
}
|
||
|
||
bool TDich_periodica_iva_app::destroy()
|
||
{
|
||
return TSkeleton_application::destroy();
|
||
}
|
||
|
||
void TDich_periodica_iva_app::main_loop()
|
||
{
|
||
const long ditta = get_firm();
|
||
|
||
TDich_periodica_selfirm_mask* m1 = new TDich_periodica_selfirm_mask();
|
||
while (m1->run() != K_QUIT)
|
||
{
|
||
if (m1->get(F_CODDITTA).empty() || m1->get(F_RAGSOC).empty())
|
||
{
|
||
error_box(TR("Selezionare una ditta"));
|
||
continue;
|
||
}
|
||
|
||
set_firm(m1->get_long(F_CODDITTA));
|
||
|
||
TDich_periodica_iva_mask* m2 = new TDich_periodica_iva_mask(m1);
|
||
m2->reset();
|
||
m2->enable_default();
|
||
m2->set_prospect();
|
||
if (m2->run() == K_ENTER)
|
||
m2->print_prospect();
|
||
delete m2;
|
||
}
|
||
delete m1;
|
||
|
||
set_firm(ditta);
|
||
}
|
||
|
||
int cg5700(int argc, char* argv[])
|
||
{
|
||
TDich_periodica_iva_app a;
|
||
a.run(argc, argv, TR("Comunicazione annuale dati IVA"));
|
||
return 0;
|
||
}
|