Sistemati per sempre i rimborsi, insieme a mille altre cagate

git-svn-id: svn://10.65.10.50/trunk@1568 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
villa 1995-07-06 10:18:09 +00:00
parent e9a48cd2ea
commit 5ec48bfc51
6 changed files with 4418 additions and 4435 deletions

File diff suppressed because it is too large Load Diff

View File

@ -247,7 +247,6 @@ class TLiquidazione_app : public TPrint_application
TTable* _iva;
TTable* _del;
TTable* _lia;
TTable* _rmb;
// a reference rectype per file/table
TRectype* _mov_r;
@ -266,7 +265,6 @@ class TLiquidazione_app : public TPrint_application
TRectype* _lam_r;
TRectype* _del_r;
TRectype* _att_r;
TRectype* _rmb_r;
// recfields for each stronz codtab
TRecfield* _pim_anno;
@ -305,10 +303,6 @@ class TLiquidazione_app : public TPrint_application
TRecfield* _lim_mese;
TRecfield* _lam_anno;
TRecfield* _lam_mese;
TRecfield* _rmb_anno;
TRecfield* _rmb_mese;
TRecfield* _rmb_codiva;
TRecfield* _rmb_tiporeg;
// supporto per l'ultima figata
int _firm_bookmark;
@ -447,7 +441,6 @@ public:
bool look_iva(const char* cod);
bool look_reg(const char* reg);
bool look_lia(long ditta = 0l, bool create = FALSE, int anno = 0);
bool look_rmb(int month, const char* codiva, tiporeg tr, bool create);
// trova il mytical ufficio concessione da mettere nelle deleghe
bool look_conc(TString& uffcon, TString& uffiva);

File diff suppressed because it is too large Load Diff

View File

@ -432,26 +432,6 @@ bool TLiquidazione_app::look_ppa(int month, const char* codatt, int type, bool c
return ok;
}
bool TLiquidazione_app::look_rmb(int month, const char* codiva, tiporeg tr, bool create)
{
_rmb->zero();
(*_rmb_anno) = _year;
(*_rmb_mese) = format("%02d",month);
(*_rmb_codiva) = codiva;
(*_rmb_tiporeg) = (int)tr;
TString ctab = _rmb->get("CODTAB");
_rmb->read();
bool ok = _rmb->good();
if (!ok && create)
{
_rmb->zero();
_rmb->put("CODTAB",ctab);
_rmb->write();
}
return ok;
}
bool TLiquidazione_app::look_del(int month, int type, bool create)
{

View File

@ -97,7 +97,12 @@ void TLiquidazione_app::recalc_corrispettivi(int month, const char* codatt)
ive += imposta;
_plm->put("R0",ive);
_plm->rewrite();
// .. e il volume di affari nei pam
real vaf = _pam->get_real("R1");
vaf += imponibile;
_pam->put("R1", vaf);
_pam->rewrite();
// Aggiorno i luridi pim
look_pim(month, codatt, ci->_codreg, "", ci->_codiva, ci->_tipodet, TRUE);
@ -105,7 +110,8 @@ void TLiquidazione_app::recalc_corrispettivi(int month, const char* codatt)
imposta += _pim->get_real("R1");
_pim->put("R0", imponibile);
_pim->put("R1", imposta);
_pim->rewrite();
_pim->rewrite();
}
}
@ -141,10 +147,6 @@ void TLiquidazione_app::recalc_ventilation(int month, const char* codatt)
TString16 tipoiva(_iva->get("S1"));
TString16 reg = *_pim_codreg;
// pare che questo fosse totalmente folle e idiota
// ci si chiede quindi che cazzo abbia detto la Scudeler
// if (!_isricacq && tipodet != 3)
// continue;
/*
* caso particolare SENSU Vladimiro (1995) #MI3001
@ -221,6 +223,11 @@ void TLiquidazione_app::recalc_ventilation(int month, const char* codatt)
ive += imposta;
_plm->put("R0",ive);
_plm->rewrite();
// .. e il volume di affari nei pam
real vaf = _pam->get_real("R1");
vaf += imponibile;
_pam->put("R1", vaf);
_pam->rewrite();
// Aggiorno i luridi pim
look_pim(month, codatt, vi->_codreg, "0", vv->_codiva, vi->_tipodet, TRUE);
@ -260,6 +267,12 @@ public:
};
// defines per stabilire quale cazzo di metodo piace oggi alla prassi
// ------------------------------------------------------------------
// Considera tutti i mesi del trimestre fino a quello indicato
// se lasciato indefinito usa solo il mese passato
#define OGGI_GLI_TIRA_DI_USARE_TRE_MESI
_DescrItem* TLiquidazione_app::recalc_rimborso(int month, const char* codatts,
bool stliq)
{
@ -279,17 +292,25 @@ _DescrItem* TLiquidazione_app::recalc_rimborso(int month, const char* codatts,
while ((tmpatt = atts.get()) != NULL)
{
att = tmpatt;
#ifdef OGGI_GLI_TIRA_DI_USARE_TRE_MESI
for (int m = (month == 13 ? 1 : (next_trim(month)-2)); m <= month; m++)
{
#else
int m = month;
#endif
if (!look_plm(m,att)) continue;
vol_aff += _pam->get_real("R1");
es_ni += _pum->get_real("R12");
}
#ifdef OGGI_GLI_TIRA_DI_USARE_TRE_MESI
}
#endif
}
// condizione 1
if (stliq && !vol_aff.is_zero() && (es_ni/vol_aff) > MIN_PARTE_ESENTE)
real prc = es_ni/vol_aff; prc.round(2);
if (stliq && !vol_aff.is_zero() && prc > MIN_PARTE_ESENTE)
{
rimborsami = TRUE;
d = new _DescrItem(RIMBORSO);
@ -426,23 +447,32 @@ _DescrItem* TLiquidazione_app::recalc_rimborso(int month, const char* codatts,
**************************************************************************/
// scorri i bellissimi progressivi mensili rimborso
for (_rmb->first(); !_rmb->eof(); _rmb->next())
// scorri i bellissimi progressivi mensili
for (_pim->first(); !_pim->eof(); _pim->next())
{
int year = atoi((const char*)_year);
int ryear = atoi((const char*)(*_rmb_anno));
int rmese = atoi((const char*)(*_rmb_mese));
int ryear = atoi(*_pim_anno);
int rmese = atoi(*_pim_mese);
// B3 significa che e' acq. o vendita valido per rimb. per aliquota
if (!_pim->get_bool("B3")) continue;
#ifdef OGGI_GLI_TIRA_DI_USARE_TRE_MESI
if (year != ryear ||
(month != 13 && (rmese < (next_trim(month)-2) || rmese > month)))
continue;
#else
if (year != ryear || (month != rmese))
continue;
#endif
int tipomov = (tiporeg)_pim->get_long("I1");
real imp = _pim->get("R0");
real iva = _pim->get("R1");
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)
if (tipomov == vendita)
{
vtot += imp;
ivav += iva;
@ -455,12 +485,20 @@ _DescrItem* TLiquidazione_app::recalc_rimborso(int month, const char* codatts,
}
// finalmente
alv = ivav/vtot; alv.round(2);
ala = ivaa/atot; ala.round(2);
alv = ivav/vtot; alv.round(4);
ala = ivaa/atot; ala.round(4);
// vedi condizioni
rimborsami = ala > alv;
if (rimborsami)
{
// vedi di quanto ala eccede alv; deve essere > 10%
real ecc = ((ala/alv) - real(1.0));
rimborsami = (ecc >= SOGLIA_MAGGIORE_ALIQUOTA_DEL_CAZZO_PER_AVER_DIRITTO_AL_RIMBORSO);
}
if (stliq && (ala - alv) > SOGLIA_MAGGIORE_ALIQUOTA_DEL_CAZZO_PER_AVER_DIRITTO_AL_RIMBORSO)
if (stliq && rimborsami)
{
rimborsami = TRUE;
if (d == NULL) d = new _DescrItem(RIMBORSO);
d->_f1 = TRUE;
d->_r2 = vtot;
@ -471,7 +509,7 @@ _DescrItem* TLiquidazione_app::recalc_rimborso(int month, const char* codatts,
d->_r7 = ala * CENTO;
}
if (rimborsami)
if (rimborsami && is_month_ok_strict(month))
{
look_lim(month);
_lim->put("B2", "X");

File diff suppressed because it is too large Load Diff