2002-02-26 16:20:19 +00:00
|
|
|
|
#include <prefix.h>
|
|
|
|
|
#include <recarray.h>
|
|
|
|
|
|
1996-04-24 16:55:28 +00:00
|
|
|
|
#include "cglib03.h"
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////
|
|
|
|
|
// classe TInteressi_IVA_table //
|
|
|
|
|
// per la lettura versamenti e //
|
|
|
|
|
// e interessi IVA dalla tabella //
|
|
|
|
|
///////////////////////////////////
|
|
|
|
|
|
1998-04-30 15:59:34 +00:00
|
|
|
|
TInteressi_IVA_table::TInteressi_IVA_table() : TTable("%VER")
|
1996-04-24 16:55:28 +00:00
|
|
|
|
{
|
|
|
|
|
}
|
1994-12-20 09:36:33 +00:00
|
|
|
|
|
1996-04-24 16:55:28 +00:00
|
|
|
|
TInteressi_IVA_table::~TInteressi_IVA_table()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int TInteressi_IVA_table::read(int anno, int mese)
|
|
|
|
|
{
|
1998-03-09 10:29:06 +00:00
|
|
|
|
TString16 k;
|
2001-05-01 08:17:07 +00:00
|
|
|
|
k.format("%04d%02d",anno,mese);
|
1998-04-30 15:59:34 +00:00
|
|
|
|
zero();put("CODTAB",k);
|
|
|
|
|
if (TTable::read(_isgteq) == NOERR)
|
1996-04-24 16:55:28 +00:00
|
|
|
|
{
|
1998-11-04 18:04:26 +00:00
|
|
|
|
TString16 cod = TTable::get("CODTAB");
|
1996-04-24 16:55:28 +00:00
|
|
|
|
|
|
|
|
|
if (cod > k)
|
1998-04-30 15:59:34 +00:00
|
|
|
|
if (prev() != NOERR)
|
|
|
|
|
zero();
|
1996-04-24 16:55:28 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
1998-04-30 15:59:34 +00:00
|
|
|
|
if (last() != NOERR)
|
|
|
|
|
zero();
|
|
|
|
|
return status();
|
1996-04-24 16:55:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
real TInteressi_IVA_table::get(int what)
|
|
|
|
|
{
|
1998-03-09 10:29:06 +00:00
|
|
|
|
TString16 fieldname;
|
1996-04-24 16:55:28 +00:00
|
|
|
|
fieldname.format("R%d",what);
|
1998-04-30 15:59:34 +00:00
|
|
|
|
return get_real(fieldname);
|
1996-04-24 16:55:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////
|
1994-12-05 14:21:36 +00:00
|
|
|
|
// TRigaiva_array
|
|
|
|
|
// Tabella per il calcolo degli imponibili Iva
|
1996-04-24 16:55:28 +00:00
|
|
|
|
///////////////////////////////////////////////
|
1994-12-05 14:21:36 +00:00
|
|
|
|
|
1994-12-20 09:36:33 +00:00
|
|
|
|
bool TRigaiva_array::add_riga(const real& imponibile, const real& imposta, const real& imponibilep, const real& impostap, const char* codiva, const int tipodet, const int tipocr, bool intra, const int tipoatt)
|
1994-12-05 14:21:36 +00:00
|
|
|
|
{
|
|
|
|
|
bool found = FALSE;
|
|
|
|
|
for (int i = 0; i < items(); i++)
|
|
|
|
|
{
|
|
|
|
|
TRigaiva& r = riga(i);
|
1994-12-20 09:36:33 +00:00
|
|
|
|
if (r._codiva==codiva && tipodet==r._tipodet && tipocr==r._tipocr && tipoatt==r._tipoatt)
|
1994-12-05 14:21:36 +00:00
|
|
|
|
{
|
|
|
|
|
found = TRUE;
|
|
|
|
|
r._imponibile += imponibile;
|
|
|
|
|
r._imposta += imposta;
|
|
|
|
|
r._imponibilep += imponibilep;
|
|
|
|
|
r._impostap += impostap;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!found)
|
|
|
|
|
{
|
1994-12-20 09:36:33 +00:00
|
|
|
|
TRigaiva* r = new TRigaiva(imponibile,imposta,imponibilep,impostap,codiva,tipodet,tipocr,intra,tipoatt);
|
1994-12-05 14:21:36 +00:00
|
|
|
|
add(r);
|
|
|
|
|
}
|
|
|
|
|
return found;
|
|
|
|
|
}
|
|
|
|
|
|
1994-12-20 09:36:33 +00:00
|
|
|
|
bool TRiga_array::add_riga(const real& imponibile, const real& imposta, const real& implordo, const real& imponibilep, const real& impostap, const real& implordop, const char* codiva)
|
1994-12-05 14:21:36 +00:00
|
|
|
|
{
|
|
|
|
|
bool found = FALSE;
|
|
|
|
|
for (int i = 0; i < items(); i++)
|
|
|
|
|
{
|
|
|
|
|
TRiga& r = riga(i);
|
1994-12-20 09:36:33 +00:00
|
|
|
|
if (r._codiva==codiva)
|
1994-12-05 14:21:36 +00:00
|
|
|
|
{
|
|
|
|
|
found = TRUE;
|
|
|
|
|
r._imponibile += imponibile;
|
|
|
|
|
r._imposta += imposta;
|
1994-12-20 09:36:33 +00:00
|
|
|
|
r._implordo += implordo;
|
1994-12-05 14:21:36 +00:00
|
|
|
|
r._imponibilep += imponibilep;
|
|
|
|
|
r._impostap += impostap;
|
1994-12-20 09:36:33 +00:00
|
|
|
|
r._implordop += implordop;
|
1994-12-05 14:21:36 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!found)
|
1994-12-20 09:36:33 +00:00
|
|
|
|
{
|
|
|
|
|
TRiga* r = new TRiga(imponibile,imposta,implordo,imponibilep,impostap,implordop,codiva);
|
1994-12-05 14:21:36 +00:00
|
|
|
|
add(r);
|
|
|
|
|
}
|
|
|
|
|
return found;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TDociva_array::add_riga(const char* _descrdociva, const real& _importo,const int _natdoc)
|
|
|
|
|
{
|
|
|
|
|
bool found = FALSE;
|
|
|
|
|
for (int i = 0; i < items(); i++)
|
|
|
|
|
{
|
|
|
|
|
TDociva& r = riga(i);
|
|
|
|
|
if (r._descrdoc==_descrdociva)
|
|
|
|
|
{
|
|
|
|
|
found = TRUE;
|
|
|
|
|
if ((r._ndoc == 1)||(r._ndoc == 2)||(r._ndoc == 9))//||(r._ndoc == 4))
|
|
|
|
|
r._totdociva += _importo;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!found)
|
|
|
|
|
{
|
|
|
|
|
if ((_natdoc == 1)||(_natdoc == 2)||(_natdoc == 9))//||(_natdoc == 4))
|
|
|
|
|
{
|
|
|
|
|
TDociva* r = new TDociva(_descrdociva,_importo,_natdoc);
|
|
|
|
|
add(r);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return found;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TTipodoc_array::add_riga(const char* tipodoc, const char* descrdoc, const real& totdoc)
|
|
|
|
|
{
|
|
|
|
|
bool found = FALSE;
|
|
|
|
|
for (int i = 0; i < items(); i++)
|
|
|
|
|
{
|
|
|
|
|
TTipodoc& r = (TTipodoc&)(*this)[i];
|
|
|
|
|
if (r._tipodoc==tipodoc)
|
|
|
|
|
{
|
|
|
|
|
found = TRUE;
|
|
|
|
|
r._totdoc += totdoc;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!found)
|
|
|
|
|
{
|
|
|
|
|
TTipodoc* r = new TTipodoc(tipodoc,descrdoc,totdoc);
|
|
|
|
|
add(r);
|
|
|
|
|
}
|
|
|
|
|
return found;
|
|
|
|
|
}
|
2002-02-26 16:20:19 +00:00
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
// Arrotondamenti iva
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
TRound_mode TIva_round::_def_mode = rm_unknown;
|
|
|
|
|
int TIva_round::_def_decimals = 0;
|
|
|
|
|
|
|
|
|
|
void TIva_round::set_default_mode(TRound_mode m, int d)
|
|
|
|
|
{
|
|
|
|
|
_def_mode = _mode = m;
|
|
|
|
|
_def_decimals = _decimals = d;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TIva_round::set_mode(TRound_mode m, int d)
|
|
|
|
|
{
|
|
|
|
|
_mode = m;
|
|
|
|
|
_decimals = d;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TIva_round::set_default_iva_mode(int year, bool declaration, long ditta)
|
|
|
|
|
{
|
|
|
|
|
if (year < 1990)
|
|
|
|
|
year = TDate(TODAY).year();
|
|
|
|
|
|
|
|
|
|
if (year >= 2002 && is_euro_value(NULL))
|
|
|
|
|
{
|
|
|
|
|
if (ditta <= 0)
|
|
|
|
|
ditta = prefix().get_codditta();
|
|
|
|
|
TString16 key; key.format("%05ld%04d", ditta, year);
|
|
|
|
|
const TRectype& lia = cache().get("%LIA", key);
|
|
|
|
|
const int dec = lia.get_int(declaration ? "I2" : "I1");
|
|
|
|
|
set_default_mode(rm_round, dec);
|
|
|
|
|
}
|
|
|
|
|
else
|
2002-05-08 16:25:49 +00:00
|
|
|
|
set_default_mode(rm_millelire, -3);
|
2002-02-26 16:20:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TIva_round::round(real& n) const
|
|
|
|
|
{
|
|
|
|
|
CHECK(_mode != rm_unknown, "Non <20> stato impostato il metodo di arrotondamento");
|
|
|
|
|
switch (_mode)
|
|
|
|
|
{
|
|
|
|
|
case rm_ceil:
|
|
|
|
|
n.ceil(_decimals);
|
|
|
|
|
break;
|
|
|
|
|
case rm_millelire:
|
|
|
|
|
n -= 0.0001; // Le 500 lire vanno arrontondate per difetto
|
|
|
|
|
default:
|
|
|
|
|
n.round(_decimals);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TIva_round::TIva_round()
|
|
|
|
|
{
|
|
|
|
|
_mode = _def_mode;
|
|
|
|
|
_decimals = _def_decimals;
|
|
|
|
|
}
|
|
|
|
|
|