campo-sirio/cg/cgpim.cpp
alex 6fce3dd611 Patch level : 2.2 no patch
Files correlati     :
Ricompilazione Demo : [ ]
Commento            :

Riportate le patch fino alla 172


git-svn-id: svn://10.65.10.50/trunk@12526 c028cbd2-c16b-5b4b-a496-9718f37d4682
2004-11-30 22:02:59 +00:00

252 lines
7.2 KiB
C++
Executable File

#include <stdlib.h>
#include <isam.h>
// funzione per classificare i PIM e sommare tutto cio' che contengono
#include "cgpim.h"
bool classify_pim(const TRectype& pimr, real& imp, real& iva, tiporec& t, bool tipost)
{
static int last_checked = -1;
// 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;
for (int i = last_checked + 1; i <= MAX_TIPOREC+1; i++)
{
tiporec tocheck = (tiporec)i;
bool found = FALSE;
switch(tocheck)
{
case acq_norm:
//found = tipomov == 2 && tipoiva != "NS";
found = tipomov == 2;
found &= (tipodet == 0 /* || tipodet == 1 || tipodet == 3 ||
tipodet == 5 || tipodet == 9 */);
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");
}
}
break;
case vend_norm:
//found = tipomov == 1 /* && corrisp == 1 */ && tipoiva != "NS";
found = tipomov == 1 /* && corrisp == 1 */;
if (found)
{
imp = pimr.get_real("R0");
iva = pimr.get_real("R1");
}
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 (i == MAX_TIPOREC+1)
last_checked = -1;
else if (found)
{
t = tocheck;
last_checked = i;
break;
}
}
return last_checked != -1;
}