Files correlati : cg7.exe cg7600a.rep cg7600l.rep cg7700a.rep cg7700b.png cg7700b.rep cg7700c.rep cg7700d.rep cg7700f.rep cg7800a.rep cg7800b.rep Aggiornamento quadri VE e VF git-svn-id: svn://10.65.10.50/branches/R_10_00@23661 c028cbd2-c16b-5b4b-a496-9718f37d4682
347 lines
11 KiB
C++
347 lines
11 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 "ivadiff.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
|
|
{
|
|
protected:
|
|
virtual void load();
|
|
|
|
public:
|
|
TQuadro_VE_recordset(TQuadro_IVA_mask * mask, const char* use, const int year) : TQuadro_IVA_recordset(mask, use, year) { load(); }
|
|
virtual ~TQuadro_VE_recordset() {}
|
|
};
|
|
|
|
void TQuadro_VE_recordset::load()
|
|
{
|
|
clear();
|
|
|
|
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.30", TString8("V03.1"));
|
|
imposta_agricola.add("7.30", TString8("VE03.2"));
|
|
imponibile_agricolo.add("7.50", TString8("VE04.1"));
|
|
imposta_agricola.add("7.50", TString8("VE04.2"));
|
|
imponibile_agricolo.add("7.65", TString8("VE05.1"));
|
|
imposta_agricola.add("7.65", TString8("VE05.2"));
|
|
imponibile_agricolo.add("7.95", TString8("VE06.1"));
|
|
imposta_agricola.add("7.65", TString8("VE06.2"));
|
|
imponibile_agricolo.add("8.30", TString8("VE07.1"));
|
|
imposta_agricola.add("8.30", TString8("VE07.2"));
|
|
imponibile_agricolo.add("8,50", TString8("VE08.1"));
|
|
imposta_agricola.add("8,50", TString8("VE08.2"));
|
|
imponibile_agricolo.add("8.80", TString8("VE09.1"));
|
|
imposta_agricola.add("8.80", TString8("VE09.2"));
|
|
imponibile_agricolo.add("10.00", TString8("VE10.1"));
|
|
imposta_agricola.add("10.00", TString8("VE10.2"));
|
|
imponibile_agricolo.add("12.30", TString8("VE11.1"));
|
|
imposta_agricola.add("12.30", TString8("VE11.2"));
|
|
|
|
imponibile.add("4.00", TString8("VE20.1"));
|
|
imposta.add("4.00", TString8("VE20.2"));
|
|
imponibile.add("5.00", TString8("VE21.1"));
|
|
imposta.add("5.00", TString8("VE21.2"));
|
|
imponibile.add("10.00",TString8("VE22.1"));
|
|
imposta.add("10.00",TString8("VE22.2"));
|
|
imponibile.add("22.00", TString8("VE23.1"));
|
|
imposta.add("22.00", TString8("VE23.2"));
|
|
|
|
TString256 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 = pim.cursor()->curr();
|
|
TString8 codiva(codtab.mid(16,4)); codiva.trim();
|
|
const TRectype & ivar = cache().get("%IVA", codiva);
|
|
const TString8 aliquota = ivar.get("R0");
|
|
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;
|
|
|
|
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
|
|
{
|
|
imp = pimr.get_real("R0");
|
|
iva = pimr.get_real("R1");
|
|
}
|
|
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())
|
|
{
|
|
const real var_cred = lim.get("R17").as_real();
|
|
|
|
if (var_cred > ZERO)
|
|
add_value("VF25.2", var_cred);
|
|
}
|
|
|
|
real val = evaluate_recordset_imponibile(REP_EXPORT, year());
|
|
|
|
add_value("VE30.2", val);
|
|
val = evaluate_recordset_imponibile(REP_INTRA, year());
|
|
add_value("VE30.3", val);
|
|
val = evaluate_recordset_imponibile(REP_SANMARINO, year());
|
|
add_value("VE30.4", val);
|
|
val = evaluate_recordset_imponibile(REP_OPASSIMIL, year());
|
|
add_value("VE30.5", val);
|
|
val = evaluate_recordset_imponibile(REP_PAART17, year()); // liquidazione
|
|
add_value("VE38.1", val);
|
|
|
|
query.zap() << "USE IVADIFF KEY 2 SELECT (BETWEEN(DATAREG,#DAL,#AL))&&(BETWEEN(DATAREGP,0,#AL))"
|
|
<< "\nFROM ANNOLIQ=" << year();
|
|
|
|
TISAM_recordset id(query);
|
|
long cur_numreg = 0;
|
|
int cur_tipoiva = 0;
|
|
int cur_tipodiff = 0;
|
|
|
|
id.set_var("#DAL", TDate(1, 1, year()));
|
|
id.set_var("#AL", TDate(31, 12, year()));
|
|
|
|
|
|
for (bool ok = id.move_first(); ok; ok = id.move_next())
|
|
{
|
|
const long numreg = id.get(RMI_NUMREG).as_int();
|
|
if (numreg != cur_numreg)
|
|
{
|
|
cur_numreg = numreg;
|
|
cur_tipoiva = id.get(ID_TIPOIVA).as_int();
|
|
cur_tipodiff = id.get(ID_TIPODIFF).as_int();
|
|
}
|
|
|
|
const char sezione = id.get(ID_SEZIONE).as_string()[0];
|
|
const int tipomov = id.get(ID_TIPOMOV).as_int();
|
|
const real imp = id.get(RMI_IMPONIBILE).as_real();
|
|
|
|
if (!imp.is_zero() && cur_tipoiva == 1) // Vendite
|
|
{
|
|
switch (tipomov)
|
|
{
|
|
case 1:
|
|
add_value("VE37.1", (sezione == 'D') ? imp : -imp); // VE37.1 iva sospensione da incassare
|
|
if (cur_tipodiff == 2)
|
|
add_value("VE37.2", (sezione == 'D') ? imp : -imp); // VE37.2 iva per cassa da incassare
|
|
break;
|
|
case 2:
|
|
add_value("VE37.1", (sezione == 'A') ? -imp : imp); // VE37.1 2 iva sospensione da incassare
|
|
if (cur_tipodiff == 2)
|
|
add_value("VE37.2", (sezione == 'A') ? -imp : imp); // VE37.2 iva per cassa da incassare
|
|
break;
|
|
case 3:
|
|
add_value("VE37.1", (sezione == 'A') ? -imp : imp); // VE37.1 2 iva sospensione da incassare
|
|
add_value("VE39.1", (sezione == 'A') ? imp : -imp); // VE39.1 iva sospensione incassata
|
|
if (cur_tipodiff == 2)
|
|
add_value("VE37.2", (sezione == 'A') ? -imp : imp); // VE37.2 iva per cassa da incassare
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
|
|
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); }
|
|
virtual void load_sheet(TSheet_field & sf);
|
|
|
|
TQuadro_VE_app() : TQuadro_IVA_app("Stampa Quadro VE", "cg7600a") {}
|
|
virtual ~TQuadro_VE_app() {}
|
|
|
|
};
|
|
|
|
void TQuadro_VE_app::load_sheet(TSheet_field & sf)
|
|
{
|
|
TToken_string & row1 = sf.row(sf.items()); row1.add("|1|Stampa esportazioni|cg7600b");
|
|
TToken_string & row2 = sf.row(sf.items()); row2.add("|2|Stampa cessioni intracomunitarie|cg7600c");
|
|
TToken_string & row3 = sf.row(sf.items()); row3.add("|3|Stampa cessioni verso San Marino|cg7600d");
|
|
TToken_string & row4 = sf.row(sf.items()); row4.add("|4|Stampa operazioni assimilate|cg7600e");
|
|
TToken_string & row5 = sf.row(sf.items()); row5.add("|5|Stampa operazioni non imp. in seguito a dich. d'intenti|cg7600f");
|
|
TToken_string & row6 = sf.row(sf.items()); row6.add("|6|Stampa altre operazioni non imponibili|cg7600g");
|
|
TToken_string & row7 = sf.row(sf.items()); row7.add("|7|Stampa esenti art. 10|cg7600h");
|
|
TToken_string & row8 = sf.row(sf.items()); row8.add("|8|Stampa operazioni non sogg. ai sensi art.7 da uno a septies|cg7600i");
|
|
TToken_string & row9 = sf.row(sf.items()); row9.add("|9|Stampa operazioni reverse charge|cg7600l");
|
|
TToken_string & row10 = sf.row(sf.items()); row10.add("|10|Stampa operazioni terremotati|cg7600m");
|
|
TToken_string & row11 = sf.row(sf.items()); row11.add("|11|Stampa operazioni effettuate con PA ai sensi art.17|cg7600n");
|
|
}
|
|
|
|
int cg7600(int argc, char* argv[])
|
|
{
|
|
TQuadro_VE_app a;
|
|
a.run(argc, argv, TR("Quadro VE"));
|
|
return 0;
|
|
} |