Patch level : 12.0 348
Files correlati : cg4.exe Modificato il calcolo del volume d'affari. Tolte le regolarizzazioni, l'IVA differita e per cassa da incassare e aggiunta l'iva differita e per cassa incassata. git-svn-id: svn://10.65.10.50/branches/R_10_00@23620 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
96eebddba6
commit
b1fcdec1a1
@ -25,6 +25,7 @@
|
|||||||
#include <clifo.h>
|
#include <clifo.h>
|
||||||
#include <occas.h>
|
#include <occas.h>
|
||||||
#include <comuni.h>
|
#include <comuni.h>
|
||||||
|
#include "ivadiff.h"
|
||||||
|
|
||||||
// -------------------- QUI comincia l'avventura --------------------------
|
// -------------------- QUI comincia l'avventura --------------------------
|
||||||
// Datemi un punto di appoggio ******************
|
// Datemi un punto di appoggio ******************
|
||||||
@ -202,6 +203,20 @@ bool TLiquidazione_app::recalc_all()
|
|||||||
return good;
|
return good;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TLiquidazione_app::build_reg_caus_list(TAssoc_array & causali)
|
||||||
|
{
|
||||||
|
TCursor c(new TRelation(LF_CAUSALI));
|
||||||
|
int items = c.items();
|
||||||
|
|
||||||
|
causali.destroy();
|
||||||
|
for (c = 0L; c.pos() < items; ++c)
|
||||||
|
{
|
||||||
|
const TString8 cau = c.curr().get(CAU_CODCAUREG);
|
||||||
|
if (cau.full())
|
||||||
|
causali.add(cau, cau);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool TLiquidazione_app::update_firm(int month, bool recalc)
|
bool TLiquidazione_app::update_firm(int month, bool recalc)
|
||||||
{
|
{
|
||||||
// Se recalc e' true considera la necessita' di ricalcolare e le
|
// Se recalc e' true considera la necessita' di ricalcolare e le
|
||||||
@ -212,7 +227,9 @@ bool TLiquidazione_app::update_firm(int month, bool recalc)
|
|||||||
|
|
||||||
// Gestione IVA differita, da non confondere con _isdifferita
|
// Gestione IVA differita, da non confondere con _isdifferita
|
||||||
_isdiff = ini_get_bool(CONFIG_DITTA, "cg", "GesLiqDiff");
|
_isdiff = ini_get_bool(CONFIG_DITTA, "cg", "GesLiqDiff");
|
||||||
|
TAssoc_array caus_reg;
|
||||||
|
|
||||||
|
build_reg_caus_list(caus_reg);
|
||||||
if (month == 13 && recalc)
|
if (month == 13 && recalc)
|
||||||
{
|
{
|
||||||
TTable pem("PEM");
|
TTable pem("PEM");
|
||||||
@ -259,6 +276,7 @@ bool TLiquidazione_app::update_firm(int month, bool recalc)
|
|||||||
if (!calc && _recalc != never) calc = !ok;
|
if (!calc && _recalc != never) calc = !ok;
|
||||||
bool gheravergot = false;
|
bool gheravergot = false;
|
||||||
bool quater = false;
|
bool quater = false;
|
||||||
|
bool first_attiv = true; // prima attività vengono calcolati gli imponibili a liquidazione differita e per cassa non incassati
|
||||||
|
|
||||||
TToken_string atts;
|
TToken_string atts;
|
||||||
TToken_string cattivs;
|
TToken_string cattivs;
|
||||||
@ -275,6 +293,8 @@ bool TLiquidazione_app::update_firm(int month, bool recalc)
|
|||||||
{
|
{
|
||||||
const TString8 codatt = ndt_att.get("CODATT");
|
const TString8 codatt = ndt_att.get("CODATT");
|
||||||
const TString80 desatt = ndt_att.get("DESCR");
|
const TString80 desatt = ndt_att.get("DESCR");
|
||||||
|
real tot_reg; // totale imponibile regolarizzazioni
|
||||||
|
|
||||||
quater = _nditte->curr().get_bool("FLIVA11Q");
|
quater = _nditte->curr().get_bool("FLIVA11Q");
|
||||||
|
|
||||||
// attività mista: ce ne sono in realtà due
|
// attività mista: ce ne sono in realtà due
|
||||||
@ -385,14 +405,14 @@ bool TLiquidazione_app::update_firm(int month, bool recalc)
|
|||||||
stliq = riepliq = false;
|
stliq = riepliq = false;
|
||||||
|
|
||||||
if (calc || !recalc)
|
if (calc || !recalc)
|
||||||
if (!update_att(month, cattiv) && stliq)
|
if (!update_att(month, cattiv, caus_reg, tot_reg) && stliq)
|
||||||
describe_error(TR("Attività non ricalcolate: possibili errori"),
|
describe_error(TR("Attività non ricalcolate: possibili errori"),
|
||||||
codatt);
|
codatt);
|
||||||
if (_recalc_regis)
|
if (_recalc_regis)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (month == 13)
|
if (month == 13)
|
||||||
recalc_annual(cattiv);
|
recalc_annual(cattiv, tot_reg, first_attiv);
|
||||||
|
|
||||||
// vediamo se c'e' qualcosa da raccontare
|
// vediamo se c'e' qualcosa da raccontare
|
||||||
gheravergot = _isannual || _isriepilogo;
|
gheravergot = _isannual || _isriepilogo;
|
||||||
@ -489,7 +509,7 @@ bool TLiquidazione_app::update_firm(int month, bool recalc)
|
|||||||
return ok || calc;
|
return ok || calc;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TLiquidazione_app::update_att(int month, const char* codatt, bool recalc)
|
bool TLiquidazione_app::update_att(int month, const char* codatt, TAssoc_array & caus_reg, real & tot_reg, bool recalc)
|
||||||
// viene passato un codice attivita' con codatt+tipoatt
|
// viene passato un codice attivita' con codatt+tipoatt
|
||||||
// vedi update_firm per il burdel dei calc e recalc
|
// vedi update_firm per il burdel dei calc e recalc
|
||||||
// occhecasino. Se _comp_acconto e' true, i movimenti considerati
|
// occhecasino. Se _comp_acconto e' true, i movimenti considerati
|
||||||
@ -511,7 +531,7 @@ bool TLiquidazione_app::update_att(int month, const char* codatt, bool recalc)
|
|||||||
if (calc || !recalc)
|
if (calc || !recalc)
|
||||||
{
|
{
|
||||||
zero_att(month,codatt);
|
zero_att(month,codatt);
|
||||||
recalc_att(month,codatt);
|
recalc_att(month,codatt, caus_reg, tot_reg);
|
||||||
if (!_recalc_regis)
|
if (!_recalc_regis)
|
||||||
{
|
{
|
||||||
// Ricalcolo ventilazione e ag. viaggio:
|
// Ricalcolo ventilazione e ag. viaggio:
|
||||||
@ -851,7 +871,7 @@ static bool is_autofattura_articolo_17(const TRectype& mov)
|
|||||||
return af;
|
return af;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TLiquidazione_app::recalc_att(int month, const char* codatt)
|
void TLiquidazione_app::recalc_att(int month, const char* codatt, TAssoc_array & caus_reg, real & tot_reg)
|
||||||
// il codatt passato e' codice att + tipo att ( IN {1|2} )
|
// il codatt passato e' codice att + tipo att ( IN {1|2} )
|
||||||
// occhecasino. Se _comp_acconto e' true, i movimenti considerati
|
// occhecasino. Se _comp_acconto e' true, i movimenti considerati
|
||||||
// saranno solo quelli di dicembre per data <= 20/12;
|
// saranno solo quelli di dicembre per data <= 20/12;
|
||||||
@ -956,6 +976,8 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt)
|
|||||||
_diff_acq_ap = ZERO;
|
_diff_acq_ap = ZERO;
|
||||||
_diff_acq_ap_iva = ZERO;
|
_diff_acq_ap_iva = ZERO;
|
||||||
|
|
||||||
|
tot_reg = ZERO;
|
||||||
|
|
||||||
// PEM
|
// PEM
|
||||||
real vt_imponibile[23];
|
real vt_imponibile[23];
|
||||||
real vt_imposta[23];
|
real vt_imposta[23];
|
||||||
@ -1418,6 +1440,24 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt)
|
|||||||
real impos_det; // Imposta detraibile
|
real impos_det; // Imposta detraibile
|
||||||
char sezfat;
|
char sezfat;
|
||||||
TLocalisamfile id(LF_IVADIFF);
|
TLocalisamfile id(LF_IVADIFF);
|
||||||
|
const tipo_sospensione sosp_imp = _reg->get_bool("B1") ? (tipo_sospensione) _reg->get_int("I9") : nessuna;
|
||||||
|
const TString & codcaus = rcs.get(CAU_CODCAUS);
|
||||||
|
TToken_string key = _rmoviva->get(RMI_NUMREG); key.add(1);
|
||||||
|
const bool soloiva = cached_causale(codcaus, atoi(_year)).reg().iva() != nessuna_iva && cache().get(LF_RMOV, key).empty();
|
||||||
|
const TRectype& clifo = cache().get_rec(LF_CLIFO, _mov->get(MOV_TIPO), _mov->get(MOV_CODCF));
|
||||||
|
const int tp = clifo.get_int(CLI_ALLEG);
|
||||||
|
|
||||||
|
#ifdef DBG
|
||||||
|
const long nr = _mov->get_long(MOV_NUMREG);
|
||||||
|
|
||||||
|
if (nr == 115414 || nr == 155995)
|
||||||
|
int i = 1 ;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if ((soloiva &&
|
||||||
|
(caus_reg.objptr(codcaus) != NULL || tp < 1)) &&
|
||||||
|
sosp_imp != vol_affari)
|
||||||
|
tot_reg += imponibile_orig;
|
||||||
|
|
||||||
if (bIsMovDiff && tm == tm_fattura)
|
if (bIsMovDiff && tm == tm_fattura)
|
||||||
{
|
{
|
||||||
@ -1820,6 +1860,8 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt)
|
|||||||
case normale:
|
case normale:
|
||||||
assp_imp += asimp_imp;
|
assp_imp += asimp_imp;
|
||||||
assp_iva += asimp_iva;
|
assp_iva += asimp_iva;
|
||||||
|
// no regolarizzazioni e reverse charge
|
||||||
|
|
||||||
vssp_imp += vsimp_imp;
|
vssp_imp += vsimp_imp;
|
||||||
vssp_iva += vsimp_iva;
|
vssp_iva += vsimp_iva;
|
||||||
break;
|
break;
|
||||||
@ -4278,7 +4320,7 @@ void TLiquidazione_app::write_liq(int month, const char* codatts)
|
|||||||
_lam->rewrite();
|
_lam->rewrite();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TLiquidazione_app::recalc_annual(const char* att)
|
void TLiquidazione_app::recalc_annual(const char* att, real tot_reg, bool & first)
|
||||||
{
|
{
|
||||||
// viene chiamata 2 volte per le att. miste; PLA e' stata
|
// viene chiamata 2 volte per le att. miste; PLA e' stata
|
||||||
// azzerata dove serve da update_firm se siamo all'annuale
|
// azzerata dove serve da update_firm se siamo all'annuale
|
||||||
@ -4305,7 +4347,7 @@ void TLiquidazione_app::recalc_annual(const char* att)
|
|||||||
CHECKD(tipoatt > 0, "Tipo att non valido ", tipoatt);
|
CHECKD(tipoatt > 0, "Tipo att non valido ", tipoatt);
|
||||||
|
|
||||||
look_pla(aaa);
|
look_pla(aaa);
|
||||||
volaff1 = _pla->get_real("R14");
|
volaff1 = _pla->get_real("R14") - tot_reg;
|
||||||
volaff2 = (const char*)_pla->get("S1");
|
volaff2 = (const char*)_pla->get("S1");
|
||||||
vendite = _pla->get_real("R0");
|
vendite = _pla->get_real("R0");
|
||||||
es_c1 = _pla->get_real("R1");
|
es_c1 = _pla->get_real("R1");
|
||||||
@ -4419,6 +4461,52 @@ void TLiquidazione_app::recalc_annual(const char* att)
|
|||||||
//_plm->rewrite();
|
//_plm->rewrite();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// nella prima attività sottrae le vendite per cassa e a liquidazione differita
|
||||||
|
if (first)
|
||||||
|
{
|
||||||
|
TString query;
|
||||||
|
query << "USE IVADIFF KEY 2 SELECT (BETWEEN(DATAREG,#DAL,#AL))&&(BETWEEN(DATAREGP,0,#AL))"
|
||||||
|
<< "\nFROM ANNOLIQ=" << _year;
|
||||||
|
TISAM_recordset id(query);
|
||||||
|
long cur_numreg = 0;
|
||||||
|
int cur_tipoiva = 0;
|
||||||
|
int cur_tipodiff = 0;
|
||||||
|
|
||||||
|
id.set_var("#DAL", TDate(1, 1, atoi(_year)));
|
||||||
|
id.set_var("#AL", TDate(31, 12, atoi(_year)));
|
||||||
|
for (bool ok = id.move_first(); ok; ok = id.move_next())
|
||||||
|
{
|
||||||
|
const long numreg = id.get(RMI_NUMREG).as_int();
|
||||||
|
if (numreg != cur_numreg)
|
||||||
|
{
|
||||||
|
cur_numreg = numreg;
|
||||||
|
cur_tipoiva = id.get(ID_TIPOIVA).as_int();
|
||||||
|
cur_tipodiff = id.get(ID_TIPODIFF).as_int();
|
||||||
|
}
|
||||||
|
const char sezione = id.get(ID_SEZIONE).as_string()[0];
|
||||||
|
const int tipomov = id.get(ID_TIPOMOV).as_int();
|
||||||
|
const real imp = id.get(RMI_IMPONIBILE).as_real();
|
||||||
|
|
||||||
|
if (!imp.is_zero() && cur_tipoiva == 1) // Vendite
|
||||||
|
{
|
||||||
|
switch (tipomov)
|
||||||
|
{
|
||||||
|
case 1:
|
||||||
|
volaff1 -= (sezione == 'D') ? imp : -imp;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
volaff1 += (sezione == 'A') ? imp : -imp;
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
volaff1 += (sezione == 'A') ? imp : -imp;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
first = false;
|
||||||
|
}
|
||||||
_pla->put("R0", vendite);
|
_pla->put("R0", vendite);
|
||||||
_pla->put("R1", es_c1);
|
_pla->put("R1", es_c1);
|
||||||
_pla->put("R2", es_c2);
|
_pla->put("R2", es_c2);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user