Files correlati : cg7.exe cg7l00a.png cg7400a.png cg7400b.png cg7400c.png
cg7500a.png cg7600a.png cg7600a.rep cg7700a.png
cg7700a.rep cg7700b.png cg7700b.rep cg7800a.png cg7900a.png
cg7900b.png cg7a00a.png cg7b00a.png cg7c00a.png
cg7d00a.png cg7d00b.png cg7e00a.png cg7f00a.png
cg7f00b.png cg7g00a.png cg7g00b.png cg7h00a.png
Commento :
Quadri dichiarazione IVA
287 lines
7.8 KiB
C++
Executable File
287 lines
7.8 KiB
C++
Executable File
#include <stdlib.h>
|
|
|
|
#include <isam.h>
|
|
|
|
// funzione per classificare i PIM e sommare tutto cio' che contengono
|
|
#include "cgpim.h"
|
|
|
|
void classify_pim_array(const TRectype& pimr, TArray & imponibili, TArray & imposte, bool tipost, const bool dich)
|
|
{
|
|
real imp;
|
|
real iva;
|
|
tiporec tprec;
|
|
int last_tprec = -1;
|
|
|
|
imponibili.destroy();
|
|
imposte.destroy();
|
|
while (classify_pim(pimr, imp, iva, tprec, tipost, last_tprec, dich))
|
|
{
|
|
imponibili.add(imp, tprec);
|
|
imposte.add(iva, tprec);
|
|
}
|
|
#ifdef DBG
|
|
if (imponibili.items() == 0)
|
|
{
|
|
message_box("PIM scartato %s", (const char *)pimr.get("CODTAB"));
|
|
}
|
|
#endif
|
|
}
|
|
|
|
bool classify_pim(const TRectype& pimr, real& imp, real& iva, tiporec& t, bool tipost, int & last_tiporec, const bool dich)
|
|
{
|
|
// parse CODTAB of pim record
|
|
const TString80 ctab = pimr.get("CODTAB");
|
|
|
|
const int tipocr = atoi(ctab.mid(15,1)); // tipo costo_ricavo
|
|
const int tipodet = atoi(ctab.mid(20,1)); // tipo detraibilita'
|
|
const int corrisp = (int)pimr.get_long("I0"); // netto = 1, lordo = 2
|
|
const int tipomov = (int)pimr.get_long("I1"); // 1 = vendita, 2 = acquisto
|
|
|
|
// const bool vola = pimr.get_bool("B2");
|
|
const bool rimb = pimr.get_bool("B3");
|
|
const bool ricl = pimr.get_bool("B4");
|
|
|
|
const TString4 tipoiva = pimr.get("S5");
|
|
|
|
// cominciamo cosi'
|
|
imp = ZERO; iva = ZERO;
|
|
bool found = false;
|
|
|
|
|
|
|
|
#ifdef DBG
|
|
TString8 codiva = ctab.mid(16, 4);
|
|
static const char * codici[] = { "22", "22R", nullptr };
|
|
|
|
codiva.trim();
|
|
for (int i = 0; codici[i] != nullptr; i++)
|
|
if (strcmp(codiva, codici[i]) == 0)
|
|
int z = 1;
|
|
#endif
|
|
|
|
for (int i = ++last_tiporec; i <= stop_tiporec; i++)
|
|
{
|
|
tiporec tocheck = (tiporec)i;
|
|
|
|
switch (tocheck)
|
|
{
|
|
case acq_norm:
|
|
found = tipomov == 2 && tipodet == 0;
|
|
if (found)
|
|
{
|
|
if (tipost) //stampa
|
|
{
|
|
imp = pimr.get_real("R0") - pimr.get_real("R9");
|
|
iva = pimr.get_real("R1") - pimr.get_real("R10");
|
|
}
|
|
else //visualizza
|
|
{
|
|
imp = pimr.get_real("R0");
|
|
iva = pimr.get_real("R1");
|
|
}
|
|
if (dich)
|
|
{
|
|
imp += pimr.get_real("R32");
|
|
iva += pimr.get_real("R33");
|
|
}
|
|
}
|
|
break;
|
|
case vend_norm:
|
|
found = tipomov == 1;
|
|
if (found)
|
|
{
|
|
imp = pimr.get_real("R0");
|
|
iva = pimr.get_real("R1");
|
|
if (dich)
|
|
{
|
|
imp += pimr.get_real("R28");
|
|
imp -= pimr.get_real("R34");
|
|
iva += pimr.get_real("R29");
|
|
}
|
|
}
|
|
break;
|
|
case acq_simp:
|
|
if (tipomov == 2)
|
|
{
|
|
imp = pimr.get_real("R11");
|
|
iva = pimr.get_real("R12");
|
|
}
|
|
found = !imp.is_zero() || !iva.is_zero();
|
|
break;
|
|
case vend_simp:
|
|
if (tipomov == 1 /* && corrisp == 1 */)
|
|
{
|
|
imp = pimr.get_real("R11");
|
|
iva = pimr.get_real("R12");
|
|
}
|
|
found = !imp.is_zero() || !iva.is_zero();
|
|
break;
|
|
case bolle_doganali:
|
|
//if (tipomov == 2 && tipoiva != "NS")
|
|
if (tipomov == 2 && tipodet != 9) // scarta le bolle doganali con tipo detr. == 9
|
|
{
|
|
imp = pimr.get_real("R9");
|
|
iva = pimr.get_real("R10");
|
|
}
|
|
found = !imp.is_zero() || !iva.is_zero();
|
|
break;
|
|
case base_ventilazione:
|
|
found = (tipomov == 2 && tipodet != 9 && tipocr == 1);
|
|
found &= (tipoiva != "NS" && tipoiva != "NI" && tipoiva != "ES");
|
|
found &= (ricl ? TRUE : tipodet == 3);
|
|
if (found)
|
|
{
|
|
imp = pimr.get_real("R0");
|
|
iva = pimr.get_real("R1");
|
|
}
|
|
found &= !imp.is_zero() || !iva.is_zero();
|
|
break;
|
|
case acq_beni_riv:
|
|
/*
|
|
found = (tipomov == 2 && tipodet != 9 &&
|
|
(tipocr == 1 || (tipocr == 5 && tipodet == 3)));
|
|
found &= tipoiva != "NS" && tipoiva != "NI" && tipoiva != "ES";
|
|
found &= (ricl ? TRUE : tipodet == 3);
|
|
*/
|
|
found = (tipomov == 2 && (tipocr == 1 || tipocr == 5));
|
|
if (found)
|
|
{
|
|
imp = pimr.get_real("R0");
|
|
iva = pimr.get_real("R1");
|
|
}
|
|
found &= (!imp.is_zero() || !iva.is_zero());
|
|
break;
|
|
case corr_norm:
|
|
found = tipomov == 1 && corrisp == 2 && tipoiva != "NS";
|
|
if (found)
|
|
{
|
|
imp = pimr.get_real("R0");
|
|
iva = pimr.get_real("R1");
|
|
found &= (!imp.is_zero() || !iva.is_zero());
|
|
}
|
|
break;
|
|
case corr_simp:
|
|
if (tipomov == 1 && corrisp == 2)
|
|
{
|
|
imp = pimr.get_real("R11");
|
|
iva = pimr.get_real("R12");
|
|
}
|
|
found = !imp.is_zero() || !iva.is_zero();
|
|
break;
|
|
case acq_beni_ammort:
|
|
//found = tipomov == 2 && tipocr == 2 &&
|
|
// tipodet == 0 && tipoiva != "NS";
|
|
found = tipomov == 2 && tipocr == 2 && tipodet == 0;
|
|
if (found)
|
|
{
|
|
imp = pimr.get_real("R0");
|
|
iva = pimr.get_real("R1");
|
|
found &= (!imp.is_zero() || !iva.is_zero());
|
|
}
|
|
break;
|
|
case acq_beni_ammort_nd:
|
|
//found = tipomov == 2 && tipocr ==2 &&
|
|
// tipodet != 0 && tipoiva != "NS";
|
|
found = tipomov == 2 && tipocr ==2 && tipodet != 0;
|
|
if (found)
|
|
{
|
|
imp = pimr.get_real("R0");
|
|
iva = pimr.get_real("R1");
|
|
found &= (!imp.is_zero() || !iva.is_zero());
|
|
}
|
|
break;
|
|
case acq_beni_leasing:
|
|
//found = tipomov == 2 && tipocr == 8 && tipoiva != "NS";
|
|
found = tipomov == 2 && tipocr == 8;
|
|
if (found)
|
|
{
|
|
imp = pimr.get_real("R0");
|
|
iva = pimr.get_real("R1");
|
|
found &= (!imp.is_zero() || !iva.is_zero());
|
|
}
|
|
break;
|
|
case acq_amm_ultdetr:
|
|
//found = tipomov == 2 && tipocr == 3 && tipoiva != "NS";
|
|
found = tipomov == 2 && tipocr == 3;
|
|
if (found)
|
|
{
|
|
imp = pimr.get_real("R0");
|
|
iva = pimr.get_real("R1");
|
|
found &= (!imp.is_zero() || !iva.is_zero());
|
|
}
|
|
break;
|
|
case acq_ind_op_es:
|
|
found = tipomov == 2 && tipodet == 1 && tipoiva != "NS";
|
|
if (found)
|
|
{
|
|
imp = pimr.get_real("R0");
|
|
iva = pimr.get_real("R1");
|
|
found &= (!imp.is_zero() || !iva.is_zero());
|
|
}
|
|
break;
|
|
case acq_ind_pass_int:
|
|
found = tipomov == 2 && tipodet == 3 && tipoiva != "NS";
|
|
if (found)
|
|
{
|
|
imp = pimr.get_real("R0");
|
|
iva = pimr.get_real("R1");
|
|
found &= (!imp.is_zero() || !iva.is_zero());
|
|
}
|
|
break;
|
|
case acq_ind_art_19:
|
|
found = tipomov == 2 && tipodet == 9 && tipoiva != "NS";
|
|
if (found)
|
|
{
|
|
imp = pimr.get_real("R0") - pimr.get_real("R9"); // toglie le bolle doganali (sono a parte)
|
|
iva = pimr.get_real("R1") - pimr.get_real("R10");
|
|
found &= (!imp.is_zero() || !iva.is_zero());
|
|
}
|
|
break;
|
|
case cess_amm:
|
|
//found = tipomov == 1 && tipocr == 4 && tipoiva != "NS";
|
|
found = tipomov == 1 && tipocr == 4;
|
|
if (found)
|
|
{
|
|
imp = pimr.get_real("R0");
|
|
iva = pimr.get_real("R1");
|
|
found &= /*(*/!imp.is_zero();// || !iva.is_zero());
|
|
}
|
|
break;
|
|
case vend_rimborso:
|
|
found = tipomov == 1 && rimb && tipoiva != "NS";
|
|
if (found)
|
|
{
|
|
imp = pimr.get_real("R0");
|
|
iva = pimr.get_real("R1");
|
|
found &= (!imp.is_zero() || !iva.is_zero());
|
|
}
|
|
break;
|
|
case acq_rimborso:
|
|
found = tipomov == 2 && rimb && tipoiva != "NS";
|
|
if (found)
|
|
{
|
|
imp = pimr.get_real("R0");
|
|
iva = pimr.get_real("R1");
|
|
found &= (!imp.is_zero() || !iva.is_zero());
|
|
}
|
|
break;
|
|
case acq_bd_ind_art_19:
|
|
found = tipomov == 2 && tipodet == 9 && tipoiva != "NS";
|
|
if (found)
|
|
{
|
|
imp = pimr.get_real("R9");
|
|
iva = pimr.get_real("R10");
|
|
found &= (!imp.is_zero() || !iva.is_zero());
|
|
}
|
|
break;
|
|
}
|
|
if (found)
|
|
{
|
|
t = tocheck;
|
|
last_tiporec = i;
|
|
break;
|
|
}
|
|
}
|
|
return found;
|
|
}
|