diff --git a/src/cg/cg4301.cpp b/src/cg/cg4301.cpp index 1339f5374..6488b579f 100755 --- a/src/cg/cg4301.cpp +++ b/src/cg/cg4301.cpp @@ -1539,6 +1539,8 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt, TAssoc_array & real incdiff_iva; // Liquidazione differita incassate imposta real impon_ind; // Imponibile indetraibile real impos_ind; // Imposta indetraibile + real impon_ind_succ; // Imponibile indetraibile da periodo successivo + real impos_ind_succ; // Imposta indetraibile da periodo successivo real impon_det; // Imponibile detraibile real impos_det; // Imposta detraibile char sezfat; @@ -1940,82 +1942,6 @@ 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; @@ -2043,6 +1969,12 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt, TAssoc_array & imposta = ZERO; } + + if (tipoind > 0 && _mov->get_int(MOV_MESELIQ) > 0) + { + impon_ind_succ += imponibile; + impos_ind_succ += imposta; + } /* Riga imponibile > 9 = ritenute; non si considerano (Scudler 1994) */ @@ -2697,7 +2629,12 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt, TAssoc_array & curr.add("R10", bdv); curr.add("R13", fci); curr.add("R14", fcv); - } + } + if (i == 1) + { + curr.add("R15", impon_ind_succ); + curr.add("R16", impos_ind_succ); + } // questi servono per i ricalcoli altrui (classify_pim) o // per trucchetti di ricalcolo successivi curr.add("R11",fsi); @@ -4247,7 +4184,7 @@ void TLiquidazione_app::write_liq(int month, const char* codatts) const real ris = vf1 + vf2; // gia' esclusi: NS, B3, cess. amm // calcola nuovo prorata dal 1998 per ogni attivita' (miste: 1+2) - const real rsa = ris - (es_c1a-es_c1a_am) - (es_c3-es_c3_am) - ven_rev; + const real rsa = ris - (es_c1a-es_c1a_am) - (es_c3-es_c3_am); const real rsn = rsa - es_c1; if (!rsa.is_zero()) { @@ -4402,14 +4339,20 @@ void TLiquidazione_app::write_liq(int month, const char* codatts) // if (_isintr && ( true_trim || (month == 12 && _isbenzinaro && _gest4) // || (month == 13 && !(_isbenzinaro && _gest4)) )) // cambiato 2019 - if (_isintr && (month == 3 || month == 6 || month == 9 || month == 12 || month ==13)) + if (_isintr && (month == 3 || month == 6 || month == 9 || month == 12)) // non pił in 13 || month ==13)) { const real interesse = interesse_trimestrale(_month); const real r = risultato - imposta_non_versata; // CM 26-09-2000 real ivi = r.sign() > 0 ? (r * interesse / CENTO) : ZERO; - round_al_centesimo(ivi); - lim.put("R14", ivi); - lim.put("R10", interesse_trimestrale(_month)); + round_al_centesimo(ivi); + lim.put("R14", ivi); + lim.put("R10", interesse_trimestrale(_month)); + } + else + { + lim.zero("R14"); + lim.zero("R10"); + } //questo serve anche per la visualizzazione e per l'estrazione deleghe diff --git a/src/cg/cg4304.cpp b/src/cg/cg4304.cpp index b11bf6048..36c29595b 100755 --- a/src/cg/cg4304.cpp +++ b/src/cg/cg4304.cpp @@ -507,7 +507,7 @@ void TLiquidazione_app::describe_pims(int month, const char* codatt, const bool const TString8 ref(atts.items() == 1 ? codatt : "ALL"); int last = _descr_arr.last(); bool issosp = false; - real t0, t1, t2, t3, t4, t5, t26, t27, t28, t29, t30, t31, t32, t33; + real t0, t1, t2, t3, t4, t5, t15, t16, t26, t27, t28, t29, t30, t31, t32, t33; real rt0, rt1, rt2, rt3, rt4, rt5; real autodafe, autodafe_iva, art40, art40_iva; real diffimp, diffiva, diffincimp, diffinciva; @@ -615,8 +615,6 @@ void TLiquidazione_app::describe_pims(int month, const char* codatt, const bool continue; // questi non vanno in liquidazione, i totali sono gia' calcolati altrove - if ((tipodet == 1 || tipodet == 3 || tipodet == 9) && !is_rit) - continue; // se ha tutti gli importi nulli viene da un annullamento di // progressivi esistenti (achtung fatture con scontrino) @@ -675,7 +673,17 @@ void TLiquidazione_app::describe_pims(int month, const char* codatt, const bool d->_s1 = codiva; _descr_arr.insert(d, i); } - + if ((tipodet == 1 || tipodet == 3 || tipodet == 9) && !is_rit) + { + if (PIM_PIS == PIS_ROW) + { + d->_r15 += tab->get_real("R0"); + d->_r16 += tab->get_real("R1"); + t15 += tab->get_real("R0"); + t16 += tab->get_real("R1"); + } + continue; + } if (tipomov == acquisto) { // Ci sono anche le fatture in ritardo (solo in annuale)! Con tipo detraibilita' 1,3,9 @@ -692,7 +700,7 @@ void TLiquidazione_app::describe_pims(int month, const char* codatt, const bool rt4 += is_rit ? rit_imp : tab->get_real("R0"); rt5 += is_rit ? rit_iva : tab->get_real("R1"); } - } + } else // vendita { const bool is_key = corr_ann.is_key(codiva); @@ -799,8 +807,8 @@ void TLiquidazione_app::describe_pims(int month, const char* codatt, const bool autodafe += adf; art40 += va7i; art40_iva += va7v; - } - } + } + } // if (tipomov == vendita) // ci sono anche gli acquisti per cassa! { /* Non voglio piu' il riepilogo delle fatture emesse IVA diff @@ -820,7 +828,7 @@ void TLiquidazione_app::describe_pims(int month, const char* codatt, const bool { d = wd; break; - } + } if (wd->_flags == TOT_ROW_D) break; if (found && wd->_s1 > codiva) @@ -857,59 +865,59 @@ void TLiquidazione_app::describe_pims(int month, const char* codatt, const bool t31 += diffiva_acq; } */ - if (!diffincimp.is_zero() || !diffinciva.is_zero() || - !diffincimp_acq.is_zero() || !diffinciva_acq.is_zero()) + if (!diffincimp.is_zero() || !diffinciva.is_zero() || + !diffincimp_acq.is_zero() || !diffinciva_acq.is_zero()) + { + const word id = describe_pis ? PIS_ROW_DI : PIM_ROW_DI; + d = NULL; + int j; + for (j = totpos + 1; j < _descr_arr.items(); j++) { - const word id = describe_pis ? PIS_ROW_DI : PIM_ROW_DI; - d = NULL; - int j; - for (j = totpos + 1; j < _descr_arr.items(); j++) - { - _DescrItem& wd = (_DescrItem&)_descr_arr[j]; - const bool found = wd._flags == id && wd._s0 == ref; + _DescrItem& wd = (_DescrItem&)_descr_arr[j]; + const bool found = wd._flags == id && wd._s0 == ref; - if (found && wd._s1 == codiva) - { - d = &wd; - break; - } - if (wd._flags == TOT_ROW_DI) - break; - if (found && wd._s1 > codiva) - break; - } - if (d == NULL) + if (found && wd._s1 == codiva) { - const bool isfirst = headi == NULL; - if (isfirst) - { - headi = new _DescrItem(describe_pis ? PIS_HEAD_DI : PIM_HEAD_DI); - _descr_arr.insert(headi, j++); - headi->_f0 = false; - headi->_f1 = true; - headi->_f2 = atoi(activity.right(1)); // Tipo attivitą = 1 (servizi) o 2 (mista) - headi->_f3 = tipomov; - totdi = new _DescrItem(TOT_ROW_DI); - _descr_arr.insert(totdi, j); - } - d = new _DescrItem(id); - _descr_arr.insert(d, j); - d->_f0 = isfirst; - d->_s0 = ref; - d->_s1 = codiva; + d = &wd; + break; } - d->_r28 += diffincimp; - d->_r29 += diffinciva; - t28 += diffincimp; - t29 += diffinciva; - d->_r32 += diffincimp_acq; - d->_r33 += diffinciva_acq; - t32 += diffincimp_acq; - t33 += diffinciva_acq; + if (wd._flags == TOT_ROW_DI) + break; + if (found && wd._s1 > codiva) + break; } + if (d == NULL) + { + const bool isfirst = headi == NULL; + if (isfirst) + { + headi = new _DescrItem(describe_pis ? PIS_HEAD_DI : PIM_HEAD_DI); + _descr_arr.insert(headi, j++); + headi->_f0 = false; + headi->_f1 = true; + headi->_f2 = atoi(activity.right(1)); // Tipo attivitą = 1 (servizi) o 2 (mista) + headi->_f3 = tipomov; + totdi = new _DescrItem(TOT_ROW_DI); + _descr_arr.insert(totdi, j); + } + d = new _DescrItem(id); + _descr_arr.insert(d, j); + d->_f0 = isfirst; + d->_s0 = ref; + d->_s1 = codiva; + } + d->_r28 += diffincimp; + d->_r29 += diffinciva; + t28 += diffincimp; + t29 += diffinciva; + d->_r32 += diffincimp_acq; + d->_r33 += diffinciva_acq; + t32 += diffincimp_acq; + t33 += diffinciva_acq; } } - } // End of _pim cycle + } + } // End of _pim cycle real impc,ivac; // Aggiunge lo scorporo dei corrispettivi const int ditems = _descr_arr.items(); @@ -979,6 +987,7 @@ void TLiquidazione_app::describe_pims(int month, const char* codatt, const bool tot->_r0 = t0; tot->_r1 = t1; tot->_r2 = t2; tot->_r3 = t3; tot->_r4 = t4; tot->_r5 = t5; + tot->_r15 = t15; tot->_r16 = t16; } if (totd != NULL) { @@ -1158,7 +1167,7 @@ void TLiquidazione_app::describe_pims(int month, const char* codatt, const bool // calcola nuovo prorata per ogni attivita' (miste: 1+2) real pr; - const real rsa = ris - (e3-e5) - (e4-e6) - vrc; + const real rsa = ris - (e3-e5) - (e4-e6); const real rsn = rsa - e1; if (!rsa.is_zero()) @@ -1771,19 +1780,24 @@ void TLiquidazione_app::set_pim_head(_DescrItem& d) } else { - if (d._flags == PIM_HEAD || d._flags == PIS_HEAD) + if (d._flags == PIM_HEAD) { - set_row(r++,FR(" Cod.@41gVENDITE@71gCORRISPETTIVI@106gACQUISTI")); - set_row(r++,FR(" IVA Descrizione@30gImponibile@49gImposta@63gImponibile" - "@82gImposta@96gImponibile@115gImposta")); - set_row(r,""); + set_row(r++, FR(" Cod.@41gVENDITE@71gCORRISPETTIVI@106gACQUISTI")); + set_row(r++, FR(" IVA Descrizione@30gImponibile@49gImposta@63gImponibile@82gImposta@96gImponibile@115gImposta")); + set_row(r, ""); } -/* else + else { - set_row(r++,FR(" Cod.@41gVENDITE")); - set_row(r++,FR(" IVA Descrizione@30gImponibile@49gImposta")); - } */ - } + if (d._flags == PIS_HEAD) + { + set_row(r++, FR(" Cod.@41gVENDITE@71gCORRISPETTIVI@106gACQUISTI")); + set_row(r++, FR(" @99gACQUISTI INDETRAIBILI")); + set_row(r++, FR(" IVA Descrizione@30gImponibile@49gImposta@63gImponibile@82gImposta@96gImponibile@115gImposta")); +// set_row(r++, FR(" @96gImponibile@115gImposta")); + set_row(r, ""); + } + } + } } void TLiquidazione_app::set_pim(_DescrItem& d) @@ -1814,26 +1828,33 @@ void TLiquidazione_app::set_pim(_DescrItem& d) if (d._s2.len() > 19) d._s2.cut(19); } - if (d._flags == PIM_ROW || d._flags == PIS_ROW) - { - set_row(rw++,"%-4s %s@25g%r@41g%r@58g%r@74g%r@91g%r@107g%r", - (const char*)d._s1, (const char*)d._s2, - &(d._r0), &(d._r1), &(d._r2), &(d._r3), &(d._r4), &(d._r5)); + if (d._flags == PIM_ROW) + { + set_row(rw++, "%-4s %s@25g%r@41g%r@58g%r@74g%r@91g%r@107g%r", (const char*)d._s1, (const char*)d._s2, + &(d._r0), &(d._r1), &(d._r2), &(d._r3), &(d._r4), &(d._r5)); } else - if (d._flags == PIM_ROW_D || d._flags == PIS_ROW_D) + if (d._flags == PIS_ROW) { - set_row(rw++,"%-4s %s@25g%r@41g%r@91g%r@107g%r", - (const char*)d._s1, (const char*)d._s2, - &(d._r26), &(d._r27), &(d._r30), &(d._r31)); + set_row(rw++, "%-4s %s@25g%r@41g%r@58g%r@74g%r@91g%r@107g%r", (const char*)d._s1, (const char*)d._s2, + &(d._r0), &(d._r1), &(d._r2), &(d._r3), &(d._r4), &(d._r5)); + if (d._r15 != ZERO) + set_row(rw++, "@91g%r@107g%r", &(d._r15), &(d._r16)); } - else - if (d._flags == PIM_ROW_DI || d._flags == PIS_ROW_DI) + else + if (d._flags == PIM_ROW_D || d._flags == PIS_ROW_D) { set_row(rw++,"%-4s %s@25g%r@41g%r@91g%r@107g%r", (const char*)d._s1, (const char*)d._s2, - &(d._r28), &(d._r29), &(d._r32), &(d._r33)); + &(d._r26), &(d._r27), &(d._r30), &(d._r31)); } + else + if (d._flags == PIM_ROW_DI || d._flags == PIS_ROW_DI) + { + set_row(rw++,"%-4s %s@25g%r@41g%r@91g%r@107g%r", + (const char*)d._s1, (const char*)d._s2, + &(d._r28), &(d._r29), &(d._r32), &(d._r33)); + } } @@ -1844,8 +1865,8 @@ void TLiquidazione_app::set_plm_diff(const _DescrItem& d) set_row(rw++,""); set_row(rw++,""); if (d._flags == TOT_ROW_D) { - set_row(rw++,FR("Totale@25g%r@41g%r@91g%r@107g%r"), &(d._r26), &(d._r27), &(d._r30), &(d._r31)); - } + set_row(rw++, FR("Totale@25g%r@41g%r@91g%r@107g%r"), &(d._r26), &(d._r27), &(d._r30), &(d._r31)); + } else { // Totale incassi/pagamenti ad IVA differita o per cassa @@ -1868,7 +1889,9 @@ void TLiquidazione_app::set_plm(_DescrItem& d) set_row(rw++,""); set_row(rw++,""); set_row(rw++,FR("Totale@25g%r@41g%r@58g%r@74g%r@91g%r@107g%r"), &(d._r0), &(d._r1), &(d._r2), &(d._r3), &(d._r4), &(d._r5)); - set_row(rw++,""); + if(d._r15 != ZERO) + set_row(rw++, FR("@91g%r@107g%r"), &(d._r15), &(d._r16)); + set_row(rw++,""); } if (!(d._r7.is_zero() && d._r8.is_zero())) {