Files correlati : Commento : Quadro VE git-svn-id: svn://10.65.10.50/branches/R_10_00@23356 c028cbd2-c16b-5b4b-a496-9718f37d4682
292 lines
8.4 KiB
C++
292 lines
8.4 KiB
C++
// Programma per la stampa del quadro VE
|
|
#include <recarray.h>
|
|
#include <tabutil.h>
|
|
#include <utility.h>
|
|
|
|
#include "cg7401.h"
|
|
#include "cgpim.h"
|
|
|
|
#include "cg7400a.h"
|
|
#include "rmoviva.h"
|
|
|
|
#define REP_EXPORT 1
|
|
#define REP_INTRA 2
|
|
#define REP_SANMARINO 3
|
|
#define REP_OPASSIMIL 4
|
|
#define REP_DICHINT 5
|
|
#define REP_ALTREOP 6
|
|
#define REP_ART10 7
|
|
#define REP_ART7 8
|
|
#define REP_REVCHARGE 9
|
|
#define REP_TERREM 10
|
|
#define REP_PAART17 11
|
|
|
|
enum tipo_sospensione { nessuna, normale, vol_affari, liquidazione };
|
|
|
|
class TQuadro_VE_recordset : public TQuadro_IVA_recordset
|
|
{
|
|
TQuadro_IVA_mask * _mask;
|
|
|
|
protected:
|
|
const real TQuadro_VE_recordset::evaluate_recordset(const int code, const int year);
|
|
virtual void load(const long year);
|
|
|
|
public:
|
|
TQuadro_VE_recordset(TQuadro_IVA_mask * mask, const char* use, const int year) : TQuadro_IVA_recordset(use, year), _mask(mask) {load(year);}
|
|
virtual ~TQuadro_VE_recordset() {}
|
|
};
|
|
|
|
const real TQuadro_VE_recordset::evaluate_recordset(const int code, const int year)
|
|
{
|
|
real val;
|
|
TProgram_report & rep = _mask->get_report(code - 1);
|
|
TISAM_recordset * set = (TISAM_recordset *) rep.recordset();
|
|
|
|
if (set != NULL)
|
|
{
|
|
set->set_var("#ANNO", format("%d", year));
|
|
|
|
if (set->items() > 0)
|
|
for (set->move_first(); !set->eof(); set->move_next())
|
|
val += set->get(RMI_IMPONIBILE).as_real();
|
|
set->freeze();
|
|
}
|
|
return val;
|
|
}
|
|
|
|
|
|
void TQuadro_VE_recordset::load(const long year)
|
|
{
|
|
TAssoc_array imponibile_agricolo;
|
|
TAssoc_array imposta_agricola;
|
|
TAssoc_array imponibile;
|
|
TAssoc_array imposta;
|
|
|
|
imponibile_agricolo.add("2.00", TString8("VE01.1"));
|
|
imposta_agricola.add("2.00", TString8("VE01.2"));
|
|
imponibile_agricolo.add("4,00", TString8("VE02.2"));
|
|
imposta_agricola.add("4,00", TString8("VE02.2"));
|
|
imponibile_agricolo.add("7.00", TString8("VE03.1"));
|
|
imposta_agricola.add("7.00", TString8("VE03.2"));
|
|
imponibile_agricolo.add("7.30", TString8("VE04.1"));
|
|
imposta_agricola.add("7.30", TString8("VE04.2"));
|
|
imponibile_agricolo.add("7.50", TString8("VE05.1"));
|
|
imposta_agricola.add("7.50", TString8("VE05.2"));
|
|
imponibile_agricolo.add("8.30", TString8("VE06.1"));
|
|
imposta_agricola.add("8.30", TString8("VE06.2"));
|
|
imponibile_agricolo.add("8,50", TString8("VE07.1"));
|
|
imposta_agricola.add("8,50", TString8("VE07.2"));
|
|
imponibile_agricolo.add("8.80", TString8("VE08.1"));
|
|
imposta_agricola.add("8.80", TString8("VE08.2"));
|
|
imponibile_agricolo.add("12.30", TString8("VE09.1"));
|
|
imposta_agricola.add("12.30", TString8("VE09.2"));
|
|
|
|
imponibile.add("4.00", TString8("VE20.1"));
|
|
imposta.add("4.00", TString8("VE20.2"));
|
|
imponibile.add("10.00",TString8("VE21.1"));
|
|
imposta.add("10.00",TString8("VE21.2"));
|
|
imponibile.add("22.00", TString8("VE22.1"));
|
|
imposta.add("22.00", TString8("VE22.2"));
|
|
|
|
TString80 query("USE PIM\nFROM CODTAB=");
|
|
|
|
query << year << "\nTO CODTAB=" << year;
|
|
|
|
TISAM_recordset pim(query);
|
|
bool good = false;
|
|
|
|
for (pim.move_first(); !pim.eof(); pim.move_next())
|
|
{
|
|
const TString80 codtab = pim.get("CODTAB").as_string();
|
|
|
|
const TString8 codreg(format("%d%-3s",year, (const char*)codtab.mid(10,3)));
|
|
const TRectype & reg = cache().get("REG", codreg);
|
|
const tiporec tipo = (tiporec) reg.get_int("I9");
|
|
const bool vendite = reg.get_int("I0") == 1;
|
|
const int month = atoi(codtab.mid(13,2));
|
|
|
|
if (vendite && tipo != liquidazione && month == 13)
|
|
{
|
|
const TRectype& pimr = cache().get("PIM", codtab);
|
|
TString8 codiva(codtab.mid(16,4)); codiva.trim();
|
|
const TRectype & ivar = cache().get("%IVA", codiva);
|
|
const TString8 aliquota = ivar.get("R0");
|
|
|
|
tiporec tipo;
|
|
real imp;
|
|
real iva;
|
|
|
|
if (classify_pim(pimr, imp, iva, tipo, true))
|
|
{
|
|
good = true;
|
|
switch (tipo)
|
|
{
|
|
case acq_norm: // acquisti normali
|
|
break;
|
|
case vend_norm: // vendite normali
|
|
case corr_norm:
|
|
if (aliquota.full())
|
|
{
|
|
const bool agricolo = ivar.get_int("I4") != 0;
|
|
|
|
if (agricolo)
|
|
{
|
|
const TString * field = (TString *) imponibile_agricolo.objptr(aliquota);
|
|
|
|
if (field != NULL) add_value(*field, imp);
|
|
field = (TString *) imposta_agricola.objptr(aliquota);
|
|
if (field != NULL) add_value(*field, iva);
|
|
}
|
|
else
|
|
{
|
|
const TString * field = (TString *) imponibile.objptr(aliquota);
|
|
|
|
if (field != NULL) add_value(*field, imp);
|
|
field = (TString *) imposta.objptr(aliquota);
|
|
if (field != NULL) add_value(*field, iva);
|
|
}
|
|
}
|
|
break;
|
|
case acq_simp:
|
|
break;
|
|
case vend_simp: // acq. e vend. sosp. imposta
|
|
break;
|
|
case bolle_doganali: // bolle doganali (acquisti)
|
|
break;
|
|
case acq_beni_riv : // acq. beni per rivendita
|
|
break;
|
|
case base_ventilazione: // base calcolo per ventil.
|
|
break;
|
|
case corr_simp: // corrispettivi n. e s. imp.
|
|
break;
|
|
case acq_beni_ammort: // acq. beni ammortizz. detr.
|
|
break;
|
|
case acq_beni_ammort_nd: // beni ammort. non detraibili
|
|
break;
|
|
case acq_beni_leasing: // beni strum. acq in leasing
|
|
break;
|
|
case acq_amm_ultdetr: // beni amm. ult. detr 6%
|
|
break;
|
|
case acq_ind_op_es: // acq. indetr. su op.es.
|
|
break;
|
|
case acq_ind_pass_int: // passaggi interni
|
|
if (vendite)
|
|
add_value("VE40.1", iva);
|
|
break;
|
|
case acq_ind_art_19: // indetr. art. 19
|
|
break;
|
|
case cess_amm: // cessioni amministrative
|
|
add_value("VE40.1", iva);
|
|
break;
|
|
case vend_rimborso: // vendite valide per rimborso
|
|
break;
|
|
case acq_rimborso: // acq. validi per rimborso
|
|
break;
|
|
case acq_bd_ind_art_19: // acq. con tipo documento BD e tipo detr 9
|
|
break;
|
|
default:
|
|
break;
|
|
|
|
};
|
|
}
|
|
else
|
|
{
|
|
const real imp = pimr.get_real("R0");
|
|
const real iva = pimr.get_real("R1");
|
|
const TString4 tipo_aliquota = ivar.get("S1");
|
|
const TString4 tipo_iva11_ven = ivar.get("S2");
|
|
const int int_tipo_iva11_ven = atoi(tipo_iva11_ven);
|
|
const bool non_imponibile = (tipo_aliquota == "NI");
|
|
const bool esente = (tipo_aliquota == "ES");
|
|
const bool reverse = int_tipo_iva11_ven >= 31 && int_tipo_iva11_ven <= 38;
|
|
const bool terremotati = int_tipo_iva11_ven == 25;
|
|
|
|
if (non_imponibile)
|
|
{
|
|
if (int_tipo_iva11_ven == 21)
|
|
add_value("VE31.1", imp);
|
|
else
|
|
if (int_tipo_iva11_ven == 22)
|
|
add_value("VE32.1", imp);
|
|
}
|
|
if (esente)
|
|
{
|
|
if ((tipo_iva11_ven == "B1") ||
|
|
(tipo_iva11_ven == "B2") ||
|
|
(tipo_iva11_ven == "B3") ||
|
|
(tipo_iva11_ven == "B4") ||
|
|
(tipo_iva11_ven == "B5"))
|
|
add_value("VE33.1", imp);
|
|
else
|
|
if ((tipo_iva11_ven == "B6"))
|
|
add_value("VE34.1", imp);
|
|
}
|
|
|
|
if (reverse)
|
|
{
|
|
const int tipo_reverse = int_tipo_iva11_ven;
|
|
|
|
switch (tipo_reverse)
|
|
{
|
|
case 31 : add_value("VE35.2", imp); break;
|
|
case 32 : add_value("VE35.3", imp); break;
|
|
case 33 : add_value("VE35.4", imp); break;
|
|
case 34 : add_value("VE35.5", imp); break;
|
|
case 35 : add_value("VE35.6", imp); break;
|
|
case 36 : add_value("VE35.7", imp); break;
|
|
case 37 : add_value("VE35.8", imp); break;
|
|
case 38 : add_value("VE35.9", imp); break;
|
|
default : break;
|
|
}
|
|
}
|
|
if (terremotati)
|
|
add_value("VE36.1", imp);
|
|
}
|
|
}
|
|
}
|
|
|
|
query = "USE LIM\n FROM CODTAB==";
|
|
|
|
query << year << "13\nTO CODTAB==" << year << "13";
|
|
|
|
TISAM_recordset lim(query);
|
|
good |= lim.items() > 0;
|
|
|
|
for (lim.move_first(); !lim.eof(); lim.move_next())
|
|
add_value("VE24.2", lim.get("R17").as_real());
|
|
|
|
real val = evaluate_recordset(REP_EXPORT, year);
|
|
|
|
add_value("VE30.2", val);
|
|
val = evaluate_recordset(REP_INTRA, year);
|
|
add_value("VE30.3", val);
|
|
val = evaluate_recordset(REP_SANMARINO, year);
|
|
add_value("VE30.4", val);
|
|
val = evaluate_recordset(REP_OPASSIMIL, year);
|
|
add_value("VE30.5", val);
|
|
|
|
// VE37.1 2 iva sospensione
|
|
|
|
val = evaluate_recordset(REP_PAART17, year); // liquidazione
|
|
add_value("VE38.1", val);
|
|
|
|
// VE39.1 iva sospensione incassata
|
|
// if (!good)
|
|
// warning_box(FR("Risultati liquidazione non presenti o da ricalcolare per l'anno %d."), year);
|
|
}
|
|
|
|
class TQuadro_VE_app : public TQuadro_IVA_app
|
|
{
|
|
public:
|
|
virtual TQuadro_IVA_recordset * app_recordset(const char* use, const int year) { return new TQuadro_VE_recordset(mask(), use, year); }
|
|
TQuadro_VE_app() : TQuadro_IVA_app("Stampa Quadro VE", "cg7600a") {}
|
|
virtual ~TQuadro_VE_app() {}
|
|
|
|
};
|
|
|
|
int cg7600(int argc, char* argv[])
|
|
{
|
|
TQuadro_VE_app a;
|
|
a.run(argc, argv, TR("Quadro VE"));
|
|
return 0;
|
|
} |