Prove tecniche di rimborso

Aggiustato menu indice per ditta singola


git-svn-id: svn://10.65.10.50/trunk@1417 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
villa 1995-05-31 10:33:01 +00:00
parent a88c72ee56
commit 86cc17e39e
4 changed files with 121 additions and 83 deletions

View File

@ -23,7 +23,7 @@ inline TLiquidazione_app& app()
TLiquidazione_app::TLiquidazione_app(int m) :
_ditte(NULL), _selected(10000),
_year(4), _nomiditte(100), _menu(m)
_year(4), _nomiditte(100), _menu(m), _firm_bookmark(-1)
{
_isprint = _is_interactive = _canprint = TRUE;
_isplafond = _printonly = _is_visliq = FALSE;

View File

@ -40,13 +40,18 @@ class TProgind;
#define SOGLIA_TRIM_ALTRE real(1000000000)
// minima percentuale di operazioni esenti per aver diritto al rimborso
// infrannuale
#define MIN_PARTE_ESENTE real(0.50)
#define MIN_PARTE_ESENTE real(0.25)
// percentuale IVA da versare in acconto a dicembre
#define ACCONTO_DICEMBRE real(0.88)
// percentuale degli imponibili da usare nel calcolo aliquota
// media acquisti e vendite per controllo diritto al rimborso
// infraanuuale secondo norme 1994
#define PERC_IMP_RIMBORSABILE real(0.51)
// ANNULLATO ANCOR PRIMA DI ESISTERE; LO LASCIO PER MEMORIA FUTURA
// (due giorni di lavoro)
#define PERC_IMP_RIMBORSABILE real(0.51)
// NUOVO ENNESIMO CRITERIO RIMBORSO; mi si scusera' un minimo di
// risentimento
#define SOGLIA_MAGGIORE_ALIQUOTA_DEL_CAZZO_PER_AVER_DIRITTO_AL_RIMBORSO real(0.1)
//
// ------------------------------------------------------------------
// Fine parametri modificabili

View File

@ -451,7 +451,6 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt)
real agr_5 = 0.0;
real agr_6 = 0.0;
real agr_7 = 0.0;
real for_rimb = 0.0;
real acq_ies = 0.0;
real acq_ies_iva = 0.0;
real ult_detr = 0.0;
@ -531,7 +530,7 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt)
int tipoag = atoi(_iva->get("S5"));
int tipopla = atoi(_iva->get("S3"));
int tipodet = atoi(_rmoviva->get("TIPODET"));
bool ivarimb = _iva->get_bool("B3");
bool ivarimb = !_iva->get_bool("B3");
TString tipocr_s = _rmoviva->get("TIPOCR");
int tipocr = atoi(tipocr_s);
real imponibile = _rmoviva->get_real("IMPONIBILE");
@ -674,11 +673,11 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt)
bool ok = _isagricolo ? tipoagr == 2 : FALSE;
if (tipomov == acquisto && !ok)
ok = (tipocr == 0 || tipocr == 1 || tipocr == 5);
ok = (tipocr == 0 || tipocr == 1 || tipocr == 5 || tipocr == 9);
if (tipomov == vendita && !ok)
ok = tipoiva.empty() && tipodoc != "CR" &&
tipodoc != "SC" && tipodoc != "RF";
ok = tipoiva != "NS" && tipodoc != "CR" &&
tipodoc != "SC" && tipodoc != "RF" && tipocr != 4;
if (ok)
{

View File

@ -304,24 +304,32 @@ _DescrItem* TLiquidazione_app::recalc_rimborso(int month, const char* codatts)
// ---------------------- condizione 2
// u'casinu pazzescu d'u nuiu guvernu
// due array dove ficcare i totali per
// codiva in ordine di imponibile
TArray varr, aarr;
real vtot = 0.0;
real atot = 0.0;
real ivav = 0.0;
real ivaa = 0.0;
real alv = 0.0; // aliquota media vendite
real ala = 0.0; // aliquota media acquisti
// scorri i bellissimi progressivi mensili rimborso
for (_rmb->first(); !_rmb->eof(); _rmb->next())
{
/***********************************************************************
Sembra che sia stato annullato subito dopo che ho finito di scrivere
queste 150 righe di casino
***********************************************************************
// due array dove ficcare i totali per
// codiva in ordine di imponibile
TArray varr, aarr;
// scorri i bellissimi progressivi mensili rimborso
for (_rmb->first(); !_rmb->eof(); _rmb->next())
{
int year = atoi((const char*)_year);
int ryear = atoi((const char*)(*_rmb_anno));
int rmese = atoi((const char*)(*_rmb_mese));
if (year != ryear || (rmese < (month - 2) || rmese > month))
continue;
continue;
real imp = _rmb->get("R0");
real iva = _rmb->get("R1");
@ -336,98 +344,124 @@ _DescrItem* TLiquidazione_app::recalc_rimborso(int month, const char* codatts)
for (int i = 0; i < arr.items(); i++)
{
rObj& robj = (rObj&)arr[i];
if (robj._imp < imp)
break;
rObj& robj = (rObj&)arr[i];
if (robj._imp < imp)
break;
}
arr.insert(rb, i);
// totali imponibili
if ((tiporeg)atoi((const char*)(*_rmb_tiporeg)) == vendita)
vtot += imp;
vtot += imp;
else
atot += imp;
}
// se ci sono due o piu' imponibili uguali devo
// sostituire l'imposta con la media delle aliquote
// ciclo uguale sui due array
for (int w = 0; w < 2; w++)
{
atot += imp;
}
// se ci sono due o piu' imponibili uguali devo
// sostituire l'imposta con la media delle aliquote
// ciclo uguale sui due array
for (int w = 0; w < 2; w++)
{
TArray& arr = w == 0 ? varr : aarr;
for (int i = 0; i < arr.items(); i++)
{
rObj& robj = (rObj&)arr[i];
real impref = robj._imp;
real perc = robj._perc;
for (int j = i+1; j < arr.items(); j++)
{
rObj& rbj = (rObj&)arr[j];
if (rbj._imp != impref)
break;
perc += rbj._perc;
}
// riaggiustesbimo
if (j > i+1)
{
// funzionerebbe comunque ma risparmiamo una
// divisione per 1
real ndiv(j-i);
perc /= ndiv;
for (; i < j; i++)
{
rObj& rbj = (rObj&)arr[i];
rbj._iva = rbj._imp * (perc/CENTO);
rbj._iva.round(ROUND_LIRA);
}
i --;
}
rObj& robj = (rObj&)arr[i];
real impref = robj._imp;
real perc = robj._perc;
for (int j = i+1; j < arr.items(); j++)
{
rObj& rbj = (rObj&)arr[j];
if (rbj._imp != impref)
break;
perc += rbj._perc;
}
}
// 51 per cento
vtot *= PERC_IMP_RIMBORSABILE;
atot *= PERC_IMP_RIMBORSABILE;
real alv = 0.0; // aliquota media vendite
real ala = 0.0; // aliquota media acquisti
for (w = 0; w < 2; w++)
{
// riaggiustesbimo
if (j > i+1)
{
// funzionerebbe comunque ma risparmiamo una
// divisione per 1
real ndiv(j-i);
perc /= ndiv;
for (; i < j; i++)
{
rObj& rbj = (rObj&)arr[i];
rbj._iva = rbj._imp * (perc/CENTO);
rbj._iva.round(ROUND_LIRA);
}
i --;
}
}
}
// 51 per cento
vtot *= PERC_IMP_RIMBORSABILE;
atot *= PERC_IMP_RIMBORSABILE;
for (w = 0; w < 2; w++)
{
TArray& arr = w == 0 ? varr : aarr;
real timp = w == 0 ? vtot : atot;
real tiva = 0.0;
for (int i = 0; i < arr.items(); i++)
{
rObj& robj = (rObj&)arr[i];
if (timp >= robj._imp)
{
tiva += robj._iva;
timp -= robj._imp;
}
else
{
real perc = timp/robj._imp;
if (!perc.is_zero())
{
real ttiv = robj._iva * perc;
ttiv.round(ROUND_LIRA);
tiva += ttiv;
}
break;
}
rObj& robj = (rObj&)arr[i];
if (timp >= robj._imp)
{
tiva += robj._iva;
timp -= robj._imp;
}
else
{
real perc = timp/robj._imp;
if (!perc.is_zero())
{
real ttiv = robj._iva * perc;
ttiv.round(ROUND_LIRA);
tiva += ttiv;
}
break;
}
}
if (w == 0) ivav = tiva;
else ivaa = tiva;
}
**************************************************************************/
// scorri i bellissimi progressivi mensili rimborso
for (_rmb->first(); !_rmb->eof(); _rmb->next())
{
int year = atoi((const char*)_year);
int ryear = atoi((const char*)(*_rmb_anno));
int rmese = atoi((const char*)(*_rmb_mese));
if (year != ryear || (rmese < (month - 2) || rmese > month))
continue;
real imp = _rmb->get("R0");
real iva = _rmb->get("R1");
real per = _rmb->get("R2");
// totali imponibili
if ((tiporeg)atoi((const char*)(*_rmb_tiporeg)) == vendita)
{
vtot += imp;
ivav += iva;
}
else
{
atot += imp;
ivaa += iva;
}
}
// finalmente
alv = ivav/vtot; alv.round(2);
ala = ivaa/atot; ala.round(2);
if (ala > alv)
if ((ala - alv) > SOGLIA_MAGGIORE_ALIQUOTA_DEL_CAZZO_PER_AVER_DIRITTO_AL_RIMBORSO)
{
rimborsami = TRUE;
if (d == NULL) d = new _DescrItem(RIMBORSO);