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:
parent
e9a48cd2ea
commit
5ec48bfc51
@ -124,7 +124,6 @@ bool TLiquidazione_app::user_create()
|
||||
_iva = new TTable("%IVA");
|
||||
_del = new TTable("%DEL");
|
||||
_lia = new TTable("%LIA");
|
||||
_rmb = new TTable("RMB");
|
||||
|
||||
_mov = &_cur->file(LF_MOV);
|
||||
_rmoviva = &_cur->file(LF_RMOVIVA);
|
||||
@ -140,7 +139,6 @@ bool TLiquidazione_app::user_create()
|
||||
_lam_r = &(_lam->curr());
|
||||
_pla_r = &(_pla->curr());
|
||||
_ppa_r = &(_ppa->curr());
|
||||
_rmb_r = &(_rmb->curr());
|
||||
_reg_r = &(_reg->curr());
|
||||
_rmoviva_r = &(_cur->curr(LF_RMOVIVA));
|
||||
_mov_r = &(_mov->curr());
|
||||
@ -190,12 +188,6 @@ bool TLiquidazione_app::user_create()
|
||||
_lam_anno = new TRecfield(*_lam_r,"CODTAB",0,3);
|
||||
_lam_mese = new TRecfield(*_lam_r,"CODTAB",4,6);
|
||||
|
||||
_rmb_anno = new TRecfield(*_rmb_r,"CODTAB",0,3);
|
||||
_rmb_mese = new TRecfield(*_rmb_r,"CODTAB",4,5);
|
||||
_rmb_codiva = new TRecfield(*_rmb_r,"CODTAB",6,9);
|
||||
_rmb_tiporeg = new TRecfield(*_rmb_r,"CODTAB",10,10);
|
||||
|
||||
|
||||
__firm = TApplication::get_firm();
|
||||
|
||||
if (pnd) pnd->addstatus(1);
|
||||
@ -737,7 +729,3 @@ int cg4300(int argc, char* argv[])
|
||||
main_app.run(argc, argv, title);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -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);
|
||||
|
@ -147,7 +147,7 @@ bool TLiquidazione_app::update_firm(int month, bool recalc)
|
||||
|
||||
look_lim(liq_month(month), TRUE);
|
||||
|
||||
if (_isfinal && _lim->get_bool("B1") && _month != 13)
|
||||
if (_isregis && _lim->get_bool("B1") && _month != 13)
|
||||
return TRUE;
|
||||
|
||||
TConfig cnf(CONFIG_DITTA, "cg");
|
||||
@ -360,17 +360,7 @@ bool TLiquidazione_app::update_att(int month, const char* codatt,
|
||||
|
||||
void TLiquidazione_app::zero_firm(int month)
|
||||
{
|
||||
for (_rmb->first(); !_rmb->eof(); _rmb->next())
|
||||
{
|
||||
if (atoi((const char*)(*_rmb_mese)) == month &&
|
||||
_year == (const char*)(*_rmb_anno))
|
||||
{
|
||||
_rmb->put("R0","");
|
||||
_rmb->put("R1","");
|
||||
_rmb->put("R2","");
|
||||
_rmb->rewrite();
|
||||
}
|
||||
}
|
||||
// nothing more, left for sicurezz
|
||||
}
|
||||
|
||||
void TLiquidazione_app::zero_att(int month, const char* codatt)
|
||||
@ -690,6 +680,9 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt)
|
||||
// ora superflua la tabella rimborsi, ma, come diceva
|
||||
// Garcia Lorca, me ne sbatto il culo e se non ti piace
|
||||
// vatti a far chiavare da un coyote
|
||||
// Non mi piaceva, il coyote non era intenzionato, e
|
||||
// quindi l'ho tolta, anche perche' non funzionava piu'
|
||||
// per i ventilati e per gli 'aggiustati' dopo il calcolo
|
||||
if (ivarimb)
|
||||
{
|
||||
bool ok = _isagricolo ? tipoagr == 2 : FALSE;
|
||||
@ -698,22 +691,9 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt)
|
||||
ok = (tipocr == 0 || tipocr == 1 || tipocr == 5 || tipocr == 9);
|
||||
|
||||
if (tipomov == vendita && !ok)
|
||||
ok = tipoiva != "NS" && tipodoc != "CR" &&
|
||||
tipodoc != "SC" && tipodoc != "RF" && tipocr != 4;
|
||||
ok = tipoiva != "NS" && tipocr != 4;
|
||||
|
||||
if (ok)
|
||||
{
|
||||
// aggiurna tabedda
|
||||
look_rmb(month, codiva, tipomov, TRUE);
|
||||
real imp = _rmb->get_real("R0");
|
||||
real iva = _rmb->get_real("R1");
|
||||
imp += imponibile;
|
||||
iva += imposta;
|
||||
_rmb->put("R0", imp);
|
||||
_rmb->put("R1", iva);
|
||||
_rmb->put("R2", _iva->get_real("R0"));
|
||||
_rmb->rewrite();
|
||||
}
|
||||
ivarimb = ok;
|
||||
}
|
||||
|
||||
// operazioni esenti
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -97,6 +97,11 @@ 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);
|
||||
@ -106,6 +111,7 @@ void TLiquidazione_app::recalc_corrispettivi(int month, const char* codatt)
|
||||
_pim->put("R0", imponibile);
|
||||
_pim->put("R1", imposta);
|
||||
_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
|
||||
|
||||
real imp = _rmb->get("R0");
|
||||
real iva = _rmb->get("R1");
|
||||
real per = _rmb->get("R2");
|
||||
int tipomov = (tiporeg)_pim->get_long("I1");
|
||||
|
||||
real imp = _pim->get("R0");
|
||||
real iva = _pim->get("R1");
|
||||
|
||||
// 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);
|
||||
|
||||
if (stliq && (ala - alv) > SOGLIA_MAGGIORE_ALIQUOTA_DEL_CAZZO_PER_AVER_DIRITTO_AL_RIMBORSO)
|
||||
// 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 && 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");
|
||||
|
@ -856,19 +856,19 @@ void TLiquidazione_app::set_firm(_DescrItem& d)
|
||||
}
|
||||
|
||||
reset_header();
|
||||
int soh = 1;
|
||||
|
||||
if (!_isregis)
|
||||
{
|
||||
set_header(soh++,"Ditta %s %s@109gData @<@125gPag. @#",
|
||||
set_header(1,"Ditta %s %s@109gData @<@125gPag. @#",
|
||||
(const char*)(d._s0), (const char*)(d._s1));
|
||||
set_header(soh++,"");
|
||||
set_header(2,"");
|
||||
}
|
||||
set_header(soh++,sep);
|
||||
set_header(soh++,"%s@102gFrequenza %s",
|
||||
set_header(3,sep);
|
||||
set_header(4,"%s@102gFrequenza %s",
|
||||
(const char*)tim_title,
|
||||
d._s2 == "T" ? "Trimestrale" : "Mensile");
|
||||
set_header(soh++,sep);
|
||||
set_header(soh++,"");
|
||||
set_header(5,sep);
|
||||
set_header(6,"");
|
||||
|
||||
// notify errors if any
|
||||
int j = 0;
|
||||
@ -937,17 +937,16 @@ void TLiquidazione_app::set_att(_DescrItem& d)
|
||||
(const char*)tipatt);
|
||||
|
||||
reset_header();
|
||||
int soh=1;
|
||||
if (!_isregis)
|
||||
{
|
||||
set_header(soh++,"Ditta %s %s@109gData @<@125gPag. @#",
|
||||
set_header(1,"Ditta %s %s@109gData @<@125gPag. @#",
|
||||
(const char*)(d._s0), (const char*)(d._s1));
|
||||
set_header(soh++,"");
|
||||
set_header(2,"");
|
||||
}
|
||||
set_header(soh++,sep);
|
||||
set_header(soh++,"%s@55g%s", (const char*)tim_title, (const char*)att_title);
|
||||
set_header(soh++,sep);
|
||||
set_header(soh++,"");
|
||||
set_header(3,sep);
|
||||
set_header(4,"%s@55g%s", (const char*)tim_title, (const char*)att_title);
|
||||
set_header(5,sep);
|
||||
set_header(6,"");
|
||||
|
||||
// notify errors if any
|
||||
int j = 0;
|
||||
@ -1012,6 +1011,10 @@ void TLiquidazione_app::set_pim_head()
|
||||
|
||||
void TLiquidazione_app::set_pim(_DescrItem& d)
|
||||
{
|
||||
// succede con le autocazzate non residenti non moviomentate eccetera
|
||||
if ((d._r0 + d._r1 + d._r2 + d._r3 + d._r4 + d._r5) == ZERO)
|
||||
return;
|
||||
|
||||
int rw = 1;
|
||||
if (d._s1 == "A35")
|
||||
d._s2 = "Artt.17c3/74c1";
|
||||
@ -1158,24 +1161,17 @@ void TLiquidazione_app::set_pumpam(_DescrItem& d)
|
||||
if (! (ammindi.is_zero() && ammindv.is_zero()))
|
||||
{
|
||||
printed = TRUE;
|
||||
set_row(row++, "Acquisto beni ammortizzabili IVA detraibile@50g%r@69g%r",
|
||||
set_row(row++, "Acquisto beni ammortizzabili IVA indetraibile@50g%r@69g%r",
|
||||
&ammindi,
|
||||
&ammindv);
|
||||
}
|
||||
if (! (d._r0.is_zero() && d._r1.is_zero()))
|
||||
{
|
||||
printed = TRUE;
|
||||
set_row(row++, "Acquisto beni ammortizzabili IVA indetraibile@50g%r@69g%r",
|
||||
set_row(row++, "Acquisto beni ammortizzabili IVA detraibile@50g%r@69g%r",
|
||||
&(d._r0),
|
||||
&(d._r1));
|
||||
}
|
||||
if (!(spgn.is_zero() && spgn_iva.is_zero()))
|
||||
{
|
||||
printed = TRUE;
|
||||
set_row(row++, "Spese generali@50g%r@69g%r",
|
||||
&spgn,
|
||||
&spgn_iva);
|
||||
}
|
||||
if (!(d._r6.is_zero() && d._r7.is_zero()))
|
||||
{
|
||||
printed = TRUE;
|
||||
@ -1193,6 +1189,13 @@ void TLiquidazione_app::set_pumpam(_DescrItem& d)
|
||||
&(d._r3),
|
||||
&rn);
|
||||
}
|
||||
if (!(spgn.is_zero() && spgn_iva.is_zero()))
|
||||
{
|
||||
printed = TRUE;
|
||||
set_row(row++, "Spese generali@50g%r@69g%r",
|
||||
&spgn,
|
||||
&spgn_iva);
|
||||
}
|
||||
if (d._f0)
|
||||
{
|
||||
printed = TRUE;
|
||||
@ -1368,38 +1371,39 @@ void TLiquidazione_app::set_grand(_DescrItem& d)
|
||||
set_bookmark("Prospetto di rimborso", _firm_bookmark);
|
||||
|
||||
set_row(rw++, " PROSPETTO DI RIMBORSO");
|
||||
set_row(rw++,"");
|
||||
|
||||
if (di._f0)
|
||||
{
|
||||
// esenti
|
||||
// esenti e non imponibili
|
||||
set_row(rw++,"");
|
||||
set_row(rw++,"1) Soggetto con quota di operazioni esenti e non"
|
||||
" imponibili superiore al 25%%");
|
||||
|
||||
real perc = (di._r0/di._r1) * CENTO;
|
||||
real perc = (di._r0/di._r1); perc *= CENTO; perc.round(ROUND_LIRA);
|
||||
|
||||
TString sep(strlen(REAL_PICTURE)+2); sep.fill('-');
|
||||
set_row(rw++,"");
|
||||
set_row(rw++,"@26gTotale operazioni esenti e non imp.@66g%r",
|
||||
&(di._r0));
|
||||
set_row(rw++,"@66g%t x 100 = %5.2r", &sep, &perc);
|
||||
set_row(rw++,"@66g%t x 100 = %3r%%", &sep, &perc);
|
||||
set_row(rw++,"@26gVolume di affari lordo@66g%r", &(di._r1));
|
||||
set_row(rw++,"");
|
||||
}
|
||||
|
||||
if (di._f1)
|
||||
{
|
||||
set_row(rw++,"");
|
||||
set_row(rw++,"2) Soggetto con acquisti ad aliquota media "
|
||||
"superiore a quella delle vendite");
|
||||
TString sep(strlen(REAL_PICTURE)+2); sep.fill('-');
|
||||
set_row(rw++,"");
|
||||
set_row(rw++,"@26gTotale imposte sugli acquisti@66g%r", &(di._r5));
|
||||
set_row(rw++,"@66g%t x 100 = %5.2r", &sep, &(di._r7));
|
||||
set_row(rw++,"@66g%t x 100 = %5.2r%%", &sep, &(di._r7));
|
||||
set_row(rw++,"@26gTotale imponibili sugli acquisti@66g%r",
|
||||
&(di._r3));
|
||||
set_row(rw++,"");
|
||||
set_row(rw++,"@26gTotale imposte sulle vendite@66g%r", &(di._r4));
|
||||
set_row(rw++,"@66g%t x 100 = %5.2r", &sep, &(di._r6));
|
||||
set_row(rw++,"@66g%t x 100 = %5.2r%%", &sep, &(di._r6));
|
||||
set_row(rw++,"@26gTotale imponibili sulle vendite@66g%r", &(di._r2));
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user