Files correlati : cg7.exe cg7600a.png cg7600a.rep cg7700a.png cg7700a.rep cg7700a.png cg7700b.rep cg7800a.png cg7800a.rep cg7700b.rep cg7700b.png Quadri Ve VF e VJ della dichiarazioone IVA Aggiunti ai regimi speciali sulle causali 6 Acquisti di rottami e mat.di di recupero art. 74, commi 7 e 8 7 Acquisti di oro industriale e argento puro (art. 17, comma 5) 8 Acquisti di oro da investimento imp.per opzione (art. 17, comma 5) 9 Acquisti intrac. di CPU,PC, tablet,cellulari,console,microproc. 10 Importazioni rottami e altri mat.di recupero imposta non è versata 14 Acquisti di fabbricati (art. 17, comma 6, lett. a-bis) 15 Acquisti di telefoni cellulari (art. 17, comma 6, lett. b) 16 Acquisti di prodotti elettronici (art. 17, comma 6, lett. c) 17 Acquisti di servizi del comp.edile e sett.connessi art. 17,comma 6, lett. a-ter 18 Acquisti di beni e servizi del sett.energetico art. 17, c.6 d-bis,ter,d-quater 19 Acquisti delle P.A., titolari di partita IVA art. 17-ter git-svn-id: svn://10.65.10.50/branches/R_10_00@23645 c028cbd2-c16b-5b4b-a496-9718f37d4682
341 lines
7.5 KiB
C++
341 lines
7.5 KiB
C++
|
|
// Programma per la stampa del quadri IVA
|
|
#include <recarray.h>
|
|
#include <reprint.h>
|
|
#include <reputils.h>
|
|
#include <tabutil.h>
|
|
#include <utility.h>
|
|
|
|
#include "cg7401.h"
|
|
|
|
#include <nditte.h>
|
|
|
|
#include "cg7400a.h"
|
|
|
|
TQuadro_IVA_mask::TQuadro_IVA_mask(const char * maskname)
|
|
: TAutomask(maskname), _last_row_ditte(0), _last_row_reports(0)
|
|
{
|
|
const TDate oggi(TODAY);
|
|
|
|
_year = oggi.year();
|
|
build_ditte_sheet();
|
|
build_report_sheet();
|
|
}
|
|
|
|
long TQuadro_IVA_mask::get_ditta()
|
|
{
|
|
TSheet_field & sf = sfield(F_DITTE);
|
|
|
|
for (int i =_last_row_ditte + 1; i <sf.items(); i++)
|
|
{
|
|
TToken_string & row = sf.row(i);
|
|
const TString4 select = row.get(sf.cid2index(S_CHKDITTA));
|
|
|
|
if (select == "X")
|
|
{
|
|
_last_row_ditte = i;
|
|
return row.get_long(sf.cid2index(S_CODDITTA));
|
|
}
|
|
}
|
|
_last_row_ditte = -1;
|
|
return 0L;
|
|
}
|
|
|
|
static TProgram_report __stop;
|
|
|
|
TProgram_report * TQuadro_IVA_mask::get_report()
|
|
{
|
|
TSheet_field & sf = sfield(F_REPORTS);
|
|
|
|
for (int i =_last_row_reports + 1; i <sf.items(); i++)
|
|
{
|
|
TToken_string & row = sf.row(i);
|
|
const TString4 select = row.get(sf.cid2index(S_CHKREPORT));
|
|
|
|
if (select == "X")
|
|
{
|
|
_last_row_reports = i;
|
|
return & get_report(i);
|
|
}
|
|
}
|
|
_last_row_reports = -1;
|
|
return &__stop;
|
|
}
|
|
|
|
void TQuadro_IVA_mask::build_ditte_sheet()
|
|
{
|
|
TSheet_field & sf = sfield(F_DITTE);
|
|
|
|
sf.destroy();
|
|
TPointer_array firms;
|
|
|
|
TPrefix::firms(firms);
|
|
FOR_EACH_ARRAY_ITEM(firms, i, obj)
|
|
{
|
|
const long codditta = firms.get_long(i);
|
|
TString key; key.format("%05ld%04d", codditta, _year);
|
|
const bool good = cache().get("%LIA", key).full();
|
|
TToken_string & row = sf.row(sf.items());
|
|
const int pos = sf.items() - 1;
|
|
|
|
row.add(good ? "X" : "");
|
|
row.add(codditta);
|
|
row.add(cache().get(LF_NDITTE, codditta, NDT_RAGSOC));
|
|
|
|
if (!good)
|
|
sf.disable_row(pos);
|
|
}
|
|
sf.force_update();
|
|
}
|
|
|
|
void TQuadro_IVA_mask::build_report_sheet()
|
|
{
|
|
TToken_string d(80);
|
|
const char quadro = source_file()[3];
|
|
TSheet_field & sf = sfield(F_REPORTS);
|
|
|
|
sf.destroy();
|
|
((TQuadro_IVA_app &) main_app()).load_sheet(sf);
|
|
__stop.load("STOP");
|
|
const int items = sf.items();
|
|
|
|
for (int i = 0; i < items; i++)
|
|
{
|
|
TToken_string & row = sf.row(i);
|
|
TProgram_report *rep = new TProgram_report;
|
|
TFilename repname(row.get(sf.cid2index(S_NAMEREPORT)));
|
|
|
|
repname.ext("rep");
|
|
if (repname.exist() || repname.custom_path())
|
|
rep->load(repname);
|
|
_reports.add(rep);
|
|
}
|
|
}
|
|
|
|
bool TQuadro_IVA_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
|
|
{
|
|
switch (o.dlg())
|
|
{
|
|
case F_YEAR:
|
|
if (e == fe_modify)
|
|
{
|
|
_year = atoi(o.get());
|
|
build_ditte_sheet();
|
|
}
|
|
break;
|
|
case DLG_ALLFIRMS:
|
|
if (e == fe_button)
|
|
{
|
|
TSheet_field & sf = sfield(F_DITTE);
|
|
bool check = false;
|
|
int rows = sf.items();
|
|
|
|
for (int i = 0; !check && i < rows; i++)
|
|
check |= (sf.row(i).get(sf.cid2index(S_CHKDITTA))[0] == 'X') ;
|
|
|
|
for (int i = 0; i < rows; i++)
|
|
sf.row(i).add(check ? " " : "X", sf.cid2index(S_CHKDITTA));
|
|
sf.force_update();
|
|
}
|
|
break;
|
|
case DLG_ALLREPORTS:
|
|
if (e == fe_button)
|
|
{
|
|
TSheet_field & sf = sfield(F_REPORTS);
|
|
bool check = false;
|
|
int rows = sf.items();
|
|
|
|
for (int i = 0; !check && i < rows; i++)
|
|
check |= (sf.row(i).get(sf.cid2index(S_CHKREPORT))[0] == 'X');
|
|
|
|
for (int i = 0; i < rows; i++)
|
|
sf.row(i).add(check ? " " : "X", sf.cid2index(S_CHKREPORT));
|
|
sf.force_update();
|
|
}
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
const real TQuadro_IVA_recordset::evaluate_recordset(const int code, const int year, const char * field, const char * expr)
|
|
{
|
|
real val;
|
|
TProgram_report & rep = _mask->get_report(code - 1);
|
|
TISAM_recordset * set = (TISAM_recordset *) rep.recordset();
|
|
TExpression e(expr == NULL ? "\"X\"" : expr);
|
|
|
|
if (set != NULL)
|
|
{
|
|
set->set_var("#ANNO", format("%d", year));
|
|
|
|
if (set->items() > 0)
|
|
for (set->move_first(); !set->eof(); set->move_next())
|
|
{
|
|
if (expr != NULL)
|
|
{
|
|
int numvar = e.numvar();
|
|
|
|
for (int i = 0; i < numvar; i++)
|
|
{
|
|
const TString16 name = e.vars().varname(i);
|
|
const TString val = set->get(name).as_string();
|
|
|
|
e.setvar(name, val);
|
|
}
|
|
if (e.as_bool())
|
|
val += set->get(field).as_real();
|
|
}
|
|
else
|
|
val += set->get(field).as_real();
|
|
}
|
|
set->freeze();
|
|
}
|
|
|
|
return val;
|
|
}
|
|
|
|
const TVariant& TQuadro_IVA_recordset::get(const char* column_name) const
|
|
{
|
|
const TFixed_string name(column_name);
|
|
|
|
if (!name.starts_with("#") && name.find('.') > 0)
|
|
{
|
|
TObject * obj = _values.objptr(name);
|
|
TVariant & var = get_tmp_var(); var == NULL_VARIANT;
|
|
|
|
if (obj != NULL)
|
|
{
|
|
TObject * typeobj = _types.objptr(name);
|
|
|
|
if (typeobj != NULL && ((TString &) *typeobj) == "real")
|
|
{
|
|
real * value = (real *) obj;
|
|
|
|
value->round(0);
|
|
var = *value;
|
|
}
|
|
else
|
|
var = (TString &) *obj;
|
|
}
|
|
else
|
|
var = ZERO;
|
|
|
|
return var;
|
|
}
|
|
return TISAM_recordset::get(column_name);
|
|
}
|
|
|
|
void TQuadro_IVA_recordset::add_value(const char *s, real value)
|
|
{
|
|
real * val = (real *)_values.objptr(s);
|
|
|
|
if (val == NULL)
|
|
{
|
|
const TString8 key(s);
|
|
_values.add(key, val = new real);
|
|
_types.add(key, TString("real"));
|
|
}
|
|
*val += value;
|
|
}
|
|
|
|
void TQuadro_IVA_recordset::set_bool(const char *s, bool on)
|
|
{
|
|
TString * val = (TString *)_values.objptr(s);
|
|
|
|
if (val == NULL)
|
|
{
|
|
const TString8 key(s);
|
|
_values.add(key, val = new TString4);
|
|
}
|
|
*val = on ? "X" : "";
|
|
}
|
|
|
|
TQuadro_IVA_report::TQuadro_IVA_report(const char * report_name)
|
|
{
|
|
load(report_name);
|
|
}
|
|
|
|
bool TQuadro_IVA_app::create()
|
|
{
|
|
open_files(LF_TAB, LF_TABCOM, LF_NDITTE, 0);
|
|
return TSkeleton_application::create();
|
|
}
|
|
|
|
void TQuadro_IVA_app::print()
|
|
{
|
|
TReport_book book(_print_title);
|
|
long ditta;
|
|
const TString8 year = _mask->get(F_YEAR);
|
|
|
|
_mask->restart_ditte();
|
|
while ((ditta = _mask->get_ditta()) > 0)
|
|
{
|
|
TFilename name;
|
|
|
|
set_firm(ditta);
|
|
name = _name;
|
|
name.rtrim(1);
|
|
for (char c = 'a'; c <= last_quadro_report(); c++)
|
|
{
|
|
TFilename repname(name);
|
|
|
|
repname << c;
|
|
repname.ext("rep");
|
|
if (repname.exist() || repname.custom_path())
|
|
{
|
|
TQuadro_IVA_report rep(repname);
|
|
TRecordset * set = rep.recordset();
|
|
|
|
rep.set_recordset(app_recordset(set->query_text(), atoi(year)));
|
|
set = rep.recordset();
|
|
TReport_section * sec = rep.find_section('B', 1);
|
|
TReport_field * fld = sec->find_field(100);
|
|
|
|
if (fld != NULL)
|
|
fld->set(year);
|
|
set->set_var("#CODDITTA", ditta);
|
|
set->set_var("#ANNO", year);
|
|
book.add(rep);
|
|
}
|
|
}
|
|
_mask->restart_reports();
|
|
TProgram_report * rep = _mask->get_report();
|
|
TFilename repname = rep->filename();
|
|
|
|
repname.ext("");
|
|
while (repname != "STOP")
|
|
{
|
|
if (rep->filename().full())
|
|
{
|
|
TISAM_recordset * set = (TISAM_recordset *) rep->recordset();
|
|
|
|
set->set_var("#ANNO", year);
|
|
book.add(*rep);
|
|
set->unfreeze();
|
|
}
|
|
rep = _mask->get_report();
|
|
repname = rep->filename();
|
|
repname.ext("");
|
|
}
|
|
}
|
|
book.print_or_preview();
|
|
}
|
|
|
|
void TQuadro_IVA_app::main_loop()
|
|
{
|
|
const long oldditta = get_firm();
|
|
KEY k;
|
|
|
|
_mask = new TQuadro_IVA_mask(_name);
|
|
|
|
while ((k = _mask->run()) != K_QUIT)
|
|
print();
|
|
set_firm(oldditta);
|
|
}
|
|
|
|
TQuadro_IVA_app & app()
|
|
{
|
|
return (TQuadro_IVA_app &) main_app();
|
|
} |