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) : TLiquidazione_app::TLiquidazione_app(int m) :
_ditte(NULL), _selected(10000), _ditte(NULL), _selected(10000),
_year(4), _nomiditte(100), _menu(m) _year(4), _nomiditte(100), _menu(m), _firm_bookmark(-1)
{ {
_isprint = _is_interactive = _canprint = TRUE; _isprint = _is_interactive = _canprint = TRUE;
_isplafond = _printonly = _is_visliq = FALSE; _isplafond = _printonly = _is_visliq = FALSE;

View File

@ -40,13 +40,18 @@ class TProgind;
#define SOGLIA_TRIM_ALTRE real(1000000000) #define SOGLIA_TRIM_ALTRE real(1000000000)
// minima percentuale di operazioni esenti per aver diritto al rimborso // minima percentuale di operazioni esenti per aver diritto al rimborso
// infrannuale // infrannuale
#define MIN_PARTE_ESENTE real(0.50) #define MIN_PARTE_ESENTE real(0.25)
// percentuale IVA da versare in acconto a dicembre // percentuale IVA da versare in acconto a dicembre
#define ACCONTO_DICEMBRE real(0.88) #define ACCONTO_DICEMBRE real(0.88)
// percentuale degli imponibili da usare nel calcolo aliquota // percentuale degli imponibili da usare nel calcolo aliquota
// media acquisti e vendite per controllo diritto al rimborso // media acquisti e vendite per controllo diritto al rimborso
// infraanuuale secondo norme 1994 // 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 // 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_5 = 0.0;
real agr_6 = 0.0; real agr_6 = 0.0;
real agr_7 = 0.0; real agr_7 = 0.0;
real for_rimb = 0.0;
real acq_ies = 0.0; real acq_ies = 0.0;
real acq_ies_iva = 0.0; real acq_ies_iva = 0.0;
real ult_detr = 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 tipoag = atoi(_iva->get("S5"));
int tipopla = atoi(_iva->get("S3")); int tipopla = atoi(_iva->get("S3"));
int tipodet = atoi(_rmoviva->get("TIPODET")); int tipodet = atoi(_rmoviva->get("TIPODET"));
bool ivarimb = _iva->get_bool("B3"); bool ivarimb = !_iva->get_bool("B3");
TString tipocr_s = _rmoviva->get("TIPOCR"); TString tipocr_s = _rmoviva->get("TIPOCR");
int tipocr = atoi(tipocr_s); int tipocr = atoi(tipocr_s);
real imponibile = _rmoviva->get_real("IMPONIBILE"); 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; bool ok = _isagricolo ? tipoagr == 2 : FALSE;
if (tipomov == acquisto && !ok) if (tipomov == acquisto && !ok)
ok = (tipocr == 0 || tipocr == 1 || tipocr == 5); ok = (tipocr == 0 || tipocr == 1 || tipocr == 5 || tipocr == 9);
if (tipomov == vendita && !ok) if (tipomov == vendita && !ok)
ok = tipoiva.empty() && tipodoc != "CR" && ok = tipoiva != "NS" && tipodoc != "CR" &&
tipodoc != "SC" && tipodoc != "RF"; tipodoc != "SC" && tipodoc != "RF" && tipocr != 4;
if (ok) if (ok)
{ {

View File

@ -304,24 +304,32 @@ _DescrItem* TLiquidazione_app::recalc_rimborso(int month, const char* codatts)
// ---------------------- condizione 2 // ---------------------- condizione 2
// u'casinu pazzescu d'u nuiu guvernu // 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 vtot = 0.0;
real atot = 0.0; real atot = 0.0;
real ivav = 0.0; real ivav = 0.0;
real ivaa = 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 year = atoi((const char*)_year);
int ryear = atoi((const char*)(*_rmb_anno)); int ryear = atoi((const char*)(*_rmb_anno));
int rmese = atoi((const char*)(*_rmb_mese)); int rmese = atoi((const char*)(*_rmb_mese));
if (year != ryear || (rmese < (month - 2) || rmese > month)) if (year != ryear || (rmese < (month - 2) || rmese > month))
continue; continue;
real imp = _rmb->get("R0"); real imp = _rmb->get("R0");
real iva = _rmb->get("R1"); 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++) for (int i = 0; i < arr.items(); i++)
{ {
rObj& robj = (rObj&)arr[i]; rObj& robj = (rObj&)arr[i];
if (robj._imp < imp) if (robj._imp < imp)
break; break;
} }
arr.insert(rb, i); arr.insert(rb, i);
// totali imponibili // totali imponibili
if ((tiporeg)atoi((const char*)(*_rmb_tiporeg)) == vendita) if ((tiporeg)atoi((const char*)(*_rmb_tiporeg)) == vendita)
vtot += imp; vtot += imp;
else else
atot += imp; atot += imp;
} }
// se ci sono due o piu' imponibili uguali devo // se ci sono due o piu' imponibili uguali devo
// sostituire l'imposta con la media delle aliquote // sostituire l'imposta con la media delle aliquote
// ciclo uguale sui due array // ciclo uguale sui due array
for (int w = 0; w < 2; w++) for (int w = 0; w < 2; w++)
{ {
TArray& arr = w == 0 ? varr : aarr; TArray& arr = w == 0 ? varr : aarr;
for (int i = 0; i < arr.items(); i++) for (int i = 0; i < arr.items(); i++)
{ {
rObj& robj = (rObj&)arr[i]; rObj& robj = (rObj&)arr[i];
real impref = robj._imp; real impref = robj._imp;
real perc = robj._perc; real perc = robj._perc;
for (int j = i+1; j < arr.items(); j++) for (int j = i+1; j < arr.items(); j++)
{ {
rObj& rbj = (rObj&)arr[j]; rObj& rbj = (rObj&)arr[j];
if (rbj._imp != impref) if (rbj._imp != impref)
break; break;
perc += rbj._perc; 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 --;
}
} }
} // riaggiustesbimo
if (j > i+1)
// 51 per cento {
vtot *= PERC_IMP_RIMBORSABILE; // funzionerebbe comunque ma risparmiamo una
atot *= PERC_IMP_RIMBORSABILE; // divisione per 1
real ndiv(j-i);
real alv = 0.0; // aliquota media vendite perc /= ndiv;
real ala = 0.0; // aliquota media acquisti for (; i < j; i++)
{
for (w = 0; w < 2; w++) 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; TArray& arr = w == 0 ? varr : aarr;
real timp = w == 0 ? vtot : atot; real timp = w == 0 ? vtot : atot;
real tiva = 0.0; real tiva = 0.0;
for (int i = 0; i < arr.items(); i++) for (int i = 0; i < arr.items(); i++)
{ {
rObj& robj = (rObj&)arr[i]; rObj& robj = (rObj&)arr[i];
if (timp >= robj._imp) if (timp >= robj._imp)
{ {
tiva += robj._iva; tiva += robj._iva;
timp -= robj._imp; timp -= robj._imp;
} }
else else
{ {
real perc = timp/robj._imp; real perc = timp/robj._imp;
if (!perc.is_zero()) if (!perc.is_zero())
{ {
real ttiv = robj._iva * perc; real ttiv = robj._iva * perc;
ttiv.round(ROUND_LIRA); ttiv.round(ROUND_LIRA);
tiva += ttiv; tiva += ttiv;
} }
break; break;
} }
} }
if (w == 0) ivav = tiva; if (w == 0) ivav = tiva;
else ivaa = 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 // finalmente
alv = ivav/vtot; alv.round(2); alv = ivav/vtot; alv.round(2);
ala = ivaa/atot; ala.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; rimborsami = TRUE;
if (d == NULL) d = new _DescrItem(RIMBORSO); if (d == NULL) d = new _DescrItem(RIMBORSO);