Patch level : 12.0 996

Files correlati     : cg4.exe
Commento            :

- Sistemato enum tipo sospensione (lista progressivi liquidazione stampa
  registri apertura esercizio iva apertura conti ricostruzione saldi)
- Sistemanto enum tiporeg
- Sistemato enum tiposal ( conferma movimeni provvisori
- Aggiuta cache di registri
- Una fattura con pgamenti antecedenti alla fattura stessa e flag di
  liquidazione nel periodo precedente non veniva liquidato ne nel mese
  corrente ne nel mese precedente
This commit is contained in:
Alessandro Bonazzi 2020-09-14 15:43:54 +02:00
parent 1b39afe46c
commit 473b8b83c7
3 changed files with 49 additions and 217 deletions

@ -31,7 +31,20 @@
// Datemi un punto di appoggio ******************
// e mi ci appoggero' ******************
// ----------------------------------------------------- ******************
#ifdef DBG
bool check_nreg(long nreg)
{
long __nreg[] = { 41221L, 0L };
int i = 0;
while (__nreg[i] > 0L)
if (__nreg[i++] == nreg)
return true;
return false;
}
#endif
bool TLiquidazione_app::recalc_all()
{
TString msg;
@ -140,40 +153,6 @@ bool TLiquidazione_app::recalc_all()
* provocano il ricalcolo dei progressivi mensili ma non la stampa
*/
_canprint = is_month_ok_strict(_month) || _month == 13;
/* --------------------------------------------------------------
* Ricalcola i mesi necessari: annuale e' un mese unico da 1/1 al 31/12
* --------------------------------------------------------------
*/
/* int need_refresh = false;
if (_recalc != ever)
{
int m = _month == 13 ? _month : 1;
for (; m < _month; m++)
if (is_month_ok_strict(m))
{
const TRectype & lim = get_lim(m);
if (lim.empty() || !lim.get_bool("B0"))
{
need_refresh = true;
break;
}
}
if (need_refresh && yesno_box(TR("Alcuni mesi precedenti non "
"risultano ricalcolati. E' consigliabile il ricalcolo. "
"Si desidera eseguirlo?")))
_recalc = ever;
}
int m;
for (m = 1; m <= _month; m++) // fino a 13 compreso
{
if (is_month_plain(m) || _recalc == ever)
update_firm(m);
} */
if (_freqviva == "T")
{
for (int m = _month - 2; m <= _month; m++)
@ -924,27 +903,7 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt, TAssoc_array &
real esenti_b14 = ZERO;
real vendite_rev = ZERO; // Vendire in reverse charge (da escludere in prorata)
real cred_fattrit;
/* Comunicazione dati iva annuale dal 2016 calcolata in cg5
// Comunicazione dati iva annuale (dal 2003)
real cessioni_cd1_1 = ZERO; // Totale operazioni attive
real cessioni_cd1_2 = ZERO; // non imponibili
real cessioni_cd1_3 = ZERO; // esenti
real cessioni_cd1_4 = ZERO; // intra
real cessioni_cd1_5 = ZERO; // beni strumentali
real acquisti_cd2_1 = ZERO; // Totale operazioni passive
real acquisti_cd2_2 = ZERO; // non imponibili
real acquisti_cd2_3 = ZERO; // esenti
real acquisti_cd2_4 = ZERO; // intra
real acquisti_cd2_5 = ZERO; // beni strumentali
real oroargento_cd3_1 = ZERO; // imponibile acquisto oro e argento
real oroargento_cd3_2 = ZERO; // imposta acquisto oro e argento
real rottami_cd3_3 = ZERO; // imponibile acquisto rottami
real rottami_cd3_4 = ZERO; // imposta acquisto rottami
real cessioni_cd1_1s = ZERO; // Totale operazioni attive in split payment
*/
real esni_rimb = ZERO; // ci sommo tutti esenti e ni validi per rimborso
real esni_rimb = ZERO; // ci sommo tutti esenti e ni validi per rimborso
real corr_CEE = ZERO;
real corr_noCEE = ZERO;
real acq_CEE = ZERO;
@ -1164,8 +1123,7 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt, TAssoc_array &
#ifdef DBG
long nr = _mov->get_long(MOV_NUMREG);
if (nr == 41221L || nr == -1L)
int i = 1;
check_nreg(nr);
#endif
const int liqmonth = _mov->get_int(MOV_MESELIQ);
@ -1206,36 +1164,6 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt, TAssoc_array &
const bool cau_intra = rcs.get_bool(CAU_INTRACOM);
const bool cau_valintra = rcs.get_bool(CAU_VALINTRA);
/*
// Gestione SPLIT PAYMENT dal 01-01-2015: movimenti a enti pubblici senza ritenuta e senza reverse charge
if (tipomov == vendita && (tm == tm_fattura || tm == tm_nota_credito) &&
!cau_intra && date.year() >= 2015 && is_split_payment(_mov->curr()))
{
Dal 2016 calcoliamo comunicazione annuale in cg5
// aggiunto il 27-01-2016: in tredicesima devo compilare anche CD1_1
if (month == 13 && date.year() == year_int)
{
do // scansione semplificata delle righe IVA
{
const int rmi_tipoatt = max(_rmoviva->get_int(RMI_TIPOATT), 1); // Poteva capitare tipoatt == 0
if (rmi_tipoatt != tipatt)
continue;
const TString& codiva = _rmoviva->get(RMI_CODIVA);
if (!look_iva(codiva))
continue;
const TString& iva_vpn = _iva->get("S10");
if (iva_vpn.full())
{
const real impZonibile_orig = _rmoviva->get(RMI_IMPONIBILE);
cessioni_cd1_1s += imponibile_orig;
cessioni_cd1_1 += imponibile_orig;
}
} while (_cur->next_match(LF_RMOVIVA));
}
continue; // Ignora movimento di split payment
} */
// Inizio gestione IVA differita
const bool iva_diff = _mov->get_bool(MOV_LIQDIFF) && is_IVA_diff(_mov->curr());
const bool iva_cass = !iva_diff && !_isviaggio && tm > tm_nessuno && is_IVAxCassa(_mov->curr());
@ -1246,7 +1174,8 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt, TAssoc_array &
TPointer_array pagscatt; // Righe di pagsca interessate
#ifdef DBG
int i = 1;
check_nreg(nr);
#endif
if (fattrit)
@ -1290,6 +1219,7 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt, TAssoc_array &
bool regular_month = orizzonte >= date;
bool first_month = regular_month && date > inizio + 1L;
#ifdef DBG
check_nreg(nr);
if (rp.get_long(PART_NREG) == 100616)
int i = 1;
#endif
@ -1301,7 +1231,8 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt, TAssoc_array &
{
const TRectype& p0 = (const TRectype&)pagscatt[p];
const TRectype& p1 = (const TRectype&)pagscatt[p - 1];
if (p0.get_int(PAGSCA_NRIGP) == p1.get_int(PAGSCA_NRIGP))
if (p0.get_int(PAGSCA_NRIGP) == p1.get_int(PAGSCA_NRIGP))
{
const real imp = p0.get_real(PAGSCA_IMPORTO);
((TRectype&)p1).add(PAGSCA_IMPORTO, imp);
@ -1483,6 +1414,7 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt, TAssoc_array &
TCodiceIVA civa(codiva);
#ifdef DBG
check_nreg(nr);
if (tipomov == vendite)
int i = 1;
if (!bIsMovDiff && (civa.percentuale() == 20))
@ -1560,10 +1492,7 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt, TAssoc_array &
// const int tp = clifo.get_int(CLI_ALLEG);
#ifdef DBG
long nr = _mov->get_long(MOV_NUMREG);
if (nr == 41221L)
int i = 1;
check_nreg(nr);
#endif
if ((soloiva &&
@ -1593,17 +1522,20 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt, TAssoc_array &
TDate datafat= _mov->get_date(MOV_DATAREG);
long numreg = _rmoviva->get_long(RMI_NUMREG);
sezfat = tipomov == vendita ? 'D' : 'A';
sezfat = tipomov == vendita ? 'D' : 'A';
if (is_detr_diff == 1 || civa.tipo() == "NS")
continue;
if (bIsMovDiff && tm == tm_fattura)
{
const TDate datareg = _mov->get_date(MOV_DATAREG);
int mesereg = datareg.month();
int mesereg = liqmonth == 0 ? datareg.month() : liqmonth;
bool ok = is_month_ok(mesereg, month) && (atoi(_year) == datareg.year());
if (ok)
#ifdef DBG
check_nreg(nr);
#endif
if (ok)
{
datafat = datareg;
id.put(RMI_NUMREG, _rmoviva->get(RMI_NUMREG));
@ -1650,14 +1582,15 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt, TAssoc_array &
const TRectype& pagsca = *(TRectype*)obj;
const int nrigp = pagsca.get_int(PAGSCA_NRIGP);
TDate datapag;
if (nrigp > 0 && nrigp < 9999)
{
const TPartita& p = arrpart.partita(pagsca);
const TRiga_partite& rp = p.riga(nrigp);
datapag = rp.get(PART_DATAREG);
if (!datapag.ok())
datapag = rp.get(PART_DATADOC);
if (!datapag.ok())
datapag = rp.get(PART_DATADOC);
if (!datapag.ok())
datapag = rp.get(PART_DATAPAG);
if (datapag < datafat)
@ -1666,13 +1599,10 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt, TAssoc_array &
else
datapag = _mov->get_date(MOV_DATAINC) ;
bool ok = is_month_ok(datapag.month(), month) && (atoi(_year) == datapag.year());
bool ok = is_month_ok(liqmonth == 0 ? datapag.month() : liqmonth, month) && (atoi(_year) == datapag.year());
if (ok)
{
// if (!ok && (iva_cass && end_cassa && month < 13))
// ok = (datareg.year() < atoi(_year)) || (mesereg <= month);
id.zero();
id.put(RMI_NUMREG, _rmoviva->get(RMI_NUMREG));
id.put(RMI_NUMRIG, _rmoviva->get(RMI_NUMRIG));
@ -1690,8 +1620,17 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt, TAssoc_array &
TDate datareg = _mov->get(MOV_DATADOC);
if (datareg < datafat)
datareg = datafat;
if (liqmonth == 0)
{
if (datareg < datafat)
datareg = datafat;
}
else
if (liqmonth != datareg.month())
{
datareg.set_month(liqmonth);
datareg.set_end_month();
}
id.put(MOV_DATAREG, datareg);
CHECKD(rmi_tipoatt > 0, "Invalid tipo att ", rmi_tipoatt);
id.put("TIPOATT", rmi_tipoatt);
@ -1717,14 +1656,6 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt, TAssoc_array &
id.put(PART_TIPOMOV, tipomov_pag);
id.put("NUMREGP", nregpag);
id.put("NUMRIGP", nrigpag);
/* TDate d = rp.get(PART_DATAPAG);
if (!d.ok())
d = rp.get(PART_DATADOC);
if (!d.ok())
d = rp.get(PART_DATAREG);
if (d < datafat)
d = datafat; */
id.put("DATAREGP", datapag);
id.put("ANNOLIQ", datapag.year());
pagtmp = p.importo_pagsca(pagsca);
@ -1949,87 +1880,12 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt, TAssoc_array &
}
}
}
/* Calcoli sprecati: dal 2016 calcolimao la comuncazione annuale direttamente in cg5
const TString& iva_vpn = _iva->get(tipomov == vendita ? "S10" : "S11");
// Aggiunto "&& is_detraibile==0" al test altrimenti somma due volte imponibile_orig (22/01/2015)
if (!bIsMovDiff && iva_vpn.full() && _mov->get_int(MOV_ANNOIVA) == year_int && is_detraibile == 0)
{
switch (tipomov)
{
case vendita: // CD1 - 1 2 3 4
{
// bool is_valid = !corrisp && tipodoc != "AF" && (cau_intra || !cau_valintra) &&
// sosp_imp != normale && sosp_imp != liquidazione;
bool is_valid = tipodoc != "AF" && sosp_imp != normale && sosp_imp != liquidazione;
if (is_valid)
{
cessioni_cd1_1 += imponibile_orig;
if (iva_vpn.starts_with("CD1"))
{
if (tipocr == 4)
cessioni_cd1_5 += imponibile_orig;
}
if (!cau_intra)
{
if (iva_vpn == "CD12")
cessioni_cd1_2 += imponibile_orig; else
if (iva_vpn == "CD13")
cessioni_cd1_3 += imponibile_orig;
}
else
{
if (iva_vpn == "CD14")
cessioni_cd1_4 += imponibile_orig;
}
}
}
break;
case acquisto: // CD2 - 1 2 3 4
{
acquisti_cd2_1 += imponibile_orig;
if (iva_vpn.starts_with("CD2"))
{
if (tipocr == 2 || tipocr == 3 || tipocr == 8)
acquisti_cd2_5 += imponibile_orig;
}
if (!cau_intra)
{
if (iva_vpn == "CD22")
acquisti_cd2_2 += imponibile_orig;
else
if (iva_vpn == "CD23")
acquisti_cd2_3 += imponibile_orig;
}
else
{
if (iva_vpn == "CD24")
acquisti_cd2_4 += imponibile_orig;
}
if (iva_vpn == "CD31")
{
oroargento_cd3_1 += imponibile_orig;
oroargento_cd3_2 += imposta_orig;
}
if (iva_vpn == "CD33")
{
rottami_cd3_3 += imponibile_orig;
rottami_cd3_4 += imposta_orig;
}
}
break;
default:
break;
}
}
*/
}
bool bMovDiffToAdd = true;
#ifdef DBG
check_nreg(nr);
if (!bIsMovDiff && (civa.percentuale() == 20))
real p = imposta_orig / imponibile_orig * CENTO;
#endif
@ -2040,7 +1896,8 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt, TAssoc_array &
real imponibile = is_detraibile == 0 ? impon_det : impon_ind;
real imposta = is_detraibile == 0? impos_det : impos_ind;
const TDate datareg = _mov->get_date(MOV_DATAREG);
const bool ok = (is_month_ok(month, liqmonth == 0 ? datareg.month() : liqmonth) || month == 13) && (atoi(_year) == datareg.year());
const bool ok = (is_month_ok(month, liqmonth == 0 ? datareg.month() : liqmonth) || month == 13) &&
(atoi(_year) == datareg.year());
if (civa.senza_imposta() && !ok)
continue;
@ -2937,8 +2794,6 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt, TAssoc_array &
// Somma i vari prorata calcolati per gli anni precedenti
prorata += prorata_precedente1 + prorata_precedente2;
prorata += prorata_diff;
/* if (!lia.get_bool("B7"))
prorata = ZERO; */
acquisti_iva -= prorata; // Rettifica acquisti_iva
fdiffinc_iva_acq -= prorata_diff; // Rettifica acquisti_iva differiti incassati
}
@ -3049,24 +2904,6 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt, TAssoc_array &
_pum->put("R12", esni_rimb);
_pum->put("R28", vendite_rev); // Vendite in reverse charge da escludere da prorata
/* Dal 2016 calcoliamo comunicazione annuale in cg5
_pum->put("R14", cessioni_cd1_1);
_pum->put("R15", cessioni_cd1_2);
_pum->put("R16", cessioni_cd1_3);
_pum->put("R17", cessioni_cd1_4);
_pum->put("R18", acquisti_cd2_1);
_pum->put("R19", acquisti_cd2_2);
_pum->put("R20", acquisti_cd2_3);
_pum->put("R21", acquisti_cd2_4);
_pum->put("R22", oroargento_cd3_1);
_pum->put("R23", oroargento_cd3_2);
_pum->put("R24", rottami_cd3_3);
_pum->put("R25", rottami_cd3_4);
_pum->put("R26", acquisti_cd2_5);
_pum->put("R27", cessioni_cd1_5);
_pum->put("R29", cessioni_cd1_1s); // cessioni in split
*/
_pam->put("R0", acquisti);
_pam->put("R1", vendite);
_pam->put("R6", assp_imp);
@ -4441,10 +4278,6 @@ void TLiquidazione_app::write_liq(int month, const char* codatts)
* false per ditte mensili e liq. annuale
* Ulteriormente smentito e rettificato
*/
// bool true_trim = (month == 3 || month == 6 || month == 9);
// if (_isintr && ( true_trim || (month == 12 && _isbenzinaro && _gest4)
// || (month == 13 && !(_isbenzinaro && _gest4)) )) // cambiato 2019
if (_isintr && (month == 3 || month == 6 || month == 9 || month == 12)) // non più in 13 || month ==13))
{
const real interesse = interesse_trimestrale(_month);

@ -119,7 +119,6 @@ bool TLiquidazione_app::is_date_ok(const TDate& d, int month, int liqmonth, int
const int regmonth = d.month();
const int regyear = d.year();
// if (regyear() != year) return false;
if (year < 1998 || _recalc_regis) // Vecchia selezione o calcolo progressivi per stampa registri bollati
{
if (regyear != year || regmonth > month)

@ -1208,7 +1208,7 @@ messaggio TStampa_registri_app::controlla_liquidazione()
lim.put("CODTAB", chiave);
if (lim.read() != NOERR || lim.get_bool("B0"))
{
if (lim.get_bool("B1")) // qui
if (lim.get_bool("B1"))
mesi_cal ="";
else
mesi_cal << itom(i) << '\n';