diff --git a/cg/cg4300.h b/cg/cg4300.h index de0559260..a6035d9df 100755 --- a/cg/cg4300.h +++ b/cg/cg4300.h @@ -407,6 +407,8 @@ public: void iva11_set_arr (const TString& codatt); // Scorre tutti i PIM della ditta, per completare _iva11_arr prima di chiamare write_IVA11() void iva11_set_arr_pim (const TString& codatt); + // Resetta i valori di R1 ed R2 per ogni attivita' della ditta corrente se non e' stato stampato il rimborso + void iva11_reset_R1R2(); // Scrive per la ditta/attivita' corrente, i dati relativi al trasferimento IVA11 void iva11_write (); diff --git a/cg/cg4301.cpp b/cg/cg4301.cpp index 2b4471ec9..e4d52f360 100755 --- a/cg/cg4301.cpp +++ b/cg/cg4301.cpp @@ -355,6 +355,8 @@ bool TLiquidazione_app::update_firm(int month, bool recalc) // un bel descritem (NULL se non si rimborsa un cas) // da passare a describe_liq rimb_d = recalc_rimborso(month,atts, stliq); + if (_is_interactive && month == 13 && rimb_d == NULL) + iva11_reset_R1R2(); } if (month == _month && stliq) @@ -438,6 +440,7 @@ void TLiquidazione_app::zero_att(int month, const char* codatt) _pim->put("R12",""); _pim->put("R13",""); _pim->put("R14",""); + _pim->put("S0",""); _pim->put("S1",""); _pim->put("S2",""); _pim->rewrite(); @@ -614,7 +617,10 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt) int tipoatt = _rmoviva->get_int("TIPOATT"); // autofatture art. 17 per non residenti, con trattamento // speciale in liquidazione annuale - bool autodafe = (tipodoc == "AF" && tipocr == 4); + bool autodafe = tipodoc == "AF"; //Adesso il tipocr==4 non c'entra piu' un tubo + // vendite art. 40 c. 5/6/8 acq.intra., con trattamento + // speciale in liquidazione annuale (A36 in stampa) + bool art40 = (tipodoc != "AF" && tipoiva != "NS" && !rcs.get_bool("AUTOFATT") && rcs.get_bool("VALINTRA") && !intra); // indica acquisti per rivendita; viene messo in B4 di PIM per // indicare che e' soggetto al ricalcolo IVA (se voluto) in modo // da evitare di dover controllare mese e anno sul PIM @@ -651,11 +657,11 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt) */ if (!(okc && (cond1 || cond2)) && !fattrit) continue; + } // Filling dell'array per IVA11 - if (_is_interactive) + if (_is_interactive && _month == 13) iva11_set_arr(trueatt); - } if (noninc) // non incassati: non devono entrare in nessun altro calcolo { @@ -960,6 +966,11 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt) real fci = _pim->get_real("R13"); real fcv = _pim->get_real("R14"); + /* i conturbanti art. 40 c. 5/6/8 a.i. */ + TToken_string kr(_pim->get("S0"),'!'); + real a36i(kr.get(0)); + real a36v(kr.get(1)); + /* le porche fatture in ritardo */ TToken_string fr(_pim->get("S1"),'!'); real rti(fr.get(0)); @@ -1099,11 +1110,21 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt) * Li metto in R7/R8 di pim e li sommo anche nelle * vendite; la describe_pim() dovra' sommarli su tutti i * pim, scorporarli dalle rispettive vendite - * e assegnarli al codice IVA A35 in caso di liq. annuale + * e assegnarli al codice IVA AF in caso di liq. annuale */ adf += imponibile; adi += imposta; - } + } + + if (art40) // ammontare acq. intr. art40 c. 5/6/8 + { // Analogamente alle autofatture, si devono riportare a parte in annuale + // Vengono piazzati in una TToken_string con separatore = a '!'. + // La TToken_string viene registrata in S0. + // La describe_pim() sommera' tutte le storie, scorporandoli + // dalle vendite e assegnandoli al codice A36 in caso di liq annuale. + a36i += imponibile; + a36v += imposta; + } if (corrisp && !true_corrisp) { @@ -1134,6 +1155,12 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt) _pim->put("B3", ivarimb ? "X" : ""); _pim->put("B4", (_isricacq && was_riv) ? "X" : ""); _pim->put("S5", tipoiva); + + // art 40 c. 5/6/8 per A36. + kr.add(a36i.string(), 0); + kr.add(a36v.string(), 1); + _pim->put("S0",kr); + // fatture in ritardo fr.add(rti.string(), 0); @@ -1340,7 +1367,7 @@ void TLiquidazione_app::iva11_set_arr(const TString& codatt) const TString tipoes_a = _iva->get("S9"); const int tipoagr = atoi(_iva->get("S4")); const TRectype& rcs = _cur->curr(LF_CAUSALI); - const bool autofattura = rcs.get_bool("AUTOFATTURA"); + const bool autofattura = rcs.get_bool("AUTOFATT"); const bool sosp_imp = _reg->get_bool("B1"); tiporeg tipomov = (tiporeg)_reg->get_long("I0"); const bool is_vendita = tipomov == vendita; @@ -1499,12 +1526,12 @@ void TLiquidazione_app::iva11_set_arr(const TString& codatt) if (tipodoc == "AF") { _iva11_arr.add(imponibile,TAB11_A35); - _iva11_arr.add(imposta,TAB11_L2,LF_TAB1100B); + _iva11_arr.add(imposta,TAB11_L2); } else if (rcs.get_bool("VALINTRA") && !intra) { _iva11_arr.add(imponibile,TAB11_A35BIS); - _iva11_arr.add(imposta,TAB11_L2BIS,LF_TAB1100B); + _iva11_arr.add(imposta,TAB11_L2BIS); } if (!autofattura && !sosp_imp && intra && tipoes_v == "24B") @@ -1612,53 +1639,72 @@ void TLiquidazione_app::iva11_set_arr_pim(const TString& codatt) imp = _pim->get_real("R0"); iva = _pim->get_real("R1"); - // I campi qui memorizzati sono tutti su TAB1100A - if (is_acquisto && tipocr == 2) - _iva11_arr.add(imp,TAB11_IMA01); - if (is_acquisto && tipocr == 8) - _iva11_arr.add(imp,TAB11_IMA02); - - if (is_acquisto && tipodet == 1 && tipocr == 0) - _iva11_arr.add(iva,TAB11_B14); - - if (is_acquisto && tipocr == 0 && aliq == 4.00) + if (is_acquisto) { - _iva11_arr.add(_pim->get_real("R9"),TAB11_FBC101); - _iva11_arr.add(_pim->get_real("R10"),TAB11_FBC201); - } - if (is_acquisto && tipocr == 0 && aliq == 9.00) - { - _iva11_arr.add(_pim->get_real("R9"),TAB11_FBC102); - _iva11_arr.add(_pim->get_real("R10"),TAB11_FBC202); - } - if (is_acquisto && tipocr == 0 && aliq == 10.00) - { - _iva11_arr.add(_pim->get_real("R9"),TAB11_FBC103); - _iva11_arr.add(_pim->get_real("R10"),TAB11_FBC203); - } - if (is_acquisto && tipocr == 0 && aliq == 13.00) - { - _iva11_arr.add(_pim->get_real("R9"),TAB11_FBC104); - _iva11_arr.add(_pim->get_real("R10"),TAB11_FBC204); - } - if (is_acquisto && tipocr == 0 && aliq == 16.00) - { - _iva11_arr.add(_pim->get_real("R9"),TAB11_FBC105); - _iva11_arr.add(_pim->get_real("R10"),TAB11_FBC205); - } - if (is_acquisto && tipocr == 0 && aliq == 19.00) - { - _iva11_arr.add(_pim->get_real("R9"),TAB11_FBC106); - _iva11_arr.add(_pim->get_real("R10"),TAB11_FBC206); - } - if (is_acquisto && tipocr == 0 && a11 == "12") - _iva11_arr.add(_pim->get_real("R9"),TAB11_FBC107); - if (is_acquisto && tipocr == 0 && (a11 == "13" || a11 == "14")) - _iva11_arr.add(_pim->get_real("R9"),TAB11_FBC108); - if (is_acquisto && tipocr == 0 && a11 == "15") - _iva11_arr.add(_pim->get_real("R9"),TAB11_FBC109); + switch (tipocr) + { + case 2: + _iva11_arr.add(imp,TAB11_IMA01); + break; + case 8: + _iva11_arr.add(imp,TAB11_IMA02); + break; + case 1: + case 5: + _iva11_arr.add(imp,TAB11_IMA03); + break; + default: + break; + } - if (is_vendita && tipocr == 0 && ((_isagricolo && tagr==2) || !_isagricolo)) + if (tipodet == 1) + _iva11_arr.add(iva,TAB11_B14); + + if (aliq == 4.00) + { + _iva11_arr.add(_pim->get_real("R9"),TAB11_FBC101); + _iva11_arr.add(_pim->get_real("R10"),TAB11_FBC201); + } + else + if (aliq == 9.00) + { + _iva11_arr.add(_pim->get_real("R9"),TAB11_FBC102); + _iva11_arr.add(_pim->get_real("R10"),TAB11_FBC202); + } + else + if (aliq == 10.00) + { + _iva11_arr.add(_pim->get_real("R9"),TAB11_FBC103); + _iva11_arr.add(_pim->get_real("R10"),TAB11_FBC203); + } + else + if (aliq == 13.00) + { + _iva11_arr.add(_pim->get_real("R9"),TAB11_FBC104); + _iva11_arr.add(_pim->get_real("R10"),TAB11_FBC204); + } + else + if (aliq == 16.00) + { + _iva11_arr.add(_pim->get_real("R9"),TAB11_FBC105); + _iva11_arr.add(_pim->get_real("R10"),TAB11_FBC205); + } + else + if (aliq == 19.00) + { + _iva11_arr.add(_pim->get_real("R9"),TAB11_FBC106); + _iva11_arr.add(_pim->get_real("R10"),TAB11_FBC206); + } + + if (a11 == "12") + _iva11_arr.add(_pim->get_real("R9"),TAB11_FBC107); + if (a11 == "13" || a11 == "14") + _iva11_arr.add(_pim->get_real("R9"),TAB11_FBC108); + if (a11 == "15") + _iva11_arr.add(_pim->get_real("R9"),TAB11_FBC109); + } // is_acquisto + + if (is_vendita && ((_isagricolo && tagr==2) || !_isagricolo)) { if (aliq == 4.00) { @@ -1691,7 +1737,7 @@ void TLiquidazione_app::iva11_set_arr_pim(const TString& codatt) _iva11_arr.add(iva,TAB11_EC206); } } - if (is_vendita && tipocr == 0) + if (is_vendita) { if (v11 == "10") _iva11_arr.add(imp,TAB11_EC107); @@ -1719,7 +1765,7 @@ void TLiquidazione_app::iva11_set_arr_pim(const TString& codatt) if (is_vendita && tipocr == 4) _iva11_arr.add(imp,TAB11_EC113); - if (is_vendita && _isagricolo && tipocr && (tagr == 1 || tagr == 3)) + if (is_vendita && _isagricolo && (tagr == 1 || tagr == 3)) { if (aliq == 2.00) { @@ -1798,6 +1844,23 @@ void TLiquidazione_app::iva11_set_arr_pim(const TString& codatt) } } +void TLiquidazione_app::iva11_reset_R1R2() +// Azzera su file i valori di R1 ed R2 se non e' stato stampato il rimborso. +{ + TLocalisamfile& tab1100b = _tab11->lfile(LF_TAB1100B); + TString ditta,ditta_read; + ditta.format("%05ld",_nditte->curr().get_long(NDT_CODDITTA)); + tab1100b.put(TAB11_TADITT,ditta); + for (tab1100b.read(_isgteq); !tab1100b.eof(); tab1100b.next()) + { + ditta_read = tab1100b.get(TAB11_TADITT); + if (ditta != ditta_read) break; + tab1100b.zero(TAB11_R1); + tab1100b.zero(TAB11_R2); + tab1100b.rewrite(); + } +} + void TLiquidazione_app::iva11_write() // Trasferisce i dati IVA11 annuali dall'assoc_array al file tab1100 { diff --git a/cg/cg4304.cpp b/cg/cg4304.cpp index 6eefd417a..0dbba1937 100755 --- a/cg/cg4304.cpp +++ b/cg/cg4304.cpp @@ -393,7 +393,7 @@ void TLiquidazione_app::describe_pims(int month, const char* codatt) int last = _descr_arr.last(); bool isfirst = TRUE; real t0, t1, t2, t3, t4, t5; - real autodafe, autodafe_iva; + real autodafe, autodafe_iva, art40, art40_iva; bool skip_acq = atts.items() == 1 && _mixed; @@ -532,7 +532,7 @@ void TLiquidazione_app::describe_pims(int month, const char* codatt) } // ... E qui finisce. - if (corrisp) + if (corrisp) { cvi -= cfi; cvv -= cfv; @@ -556,6 +556,7 @@ void TLiquidazione_app::describe_pims(int month, const char* codatt) if (!corrisp || (!cfv.is_zero() || !cfi.is_zero())) { real adf, adi; // autofatture non residenti art. 17 + real a36i, a36v; // ammontare art 40 c. 5/6/8 real vendi = corrisp ? cfi : _pim->get_real("R0"); real vendv = corrisp ? cfv : _pim->get_real("R1"); @@ -564,17 +565,22 @@ void TLiquidazione_app::describe_pims(int month, const char* codatt) // vengono normalmente considerati nelle vendite if (month == 13) { + TToken_string kr(_pim->get("S0"),'!'); + a36i = kr.get(0); + a36v = kr.get(1); adf = _pim->get_real("R7"); adi = _pim->get_real("R8"); } - d->_r0 += vendi - adf; - d->_r1 += vendv - adi; + d->_r0 += vendi - adf - a36i; + d->_r1 += vendv - adi - a36v; t0 += vendi /* - adf */; t1 += vendv /* - adi */; autodafe += adf; autodafe_iva += adi; + art40 += a36i; + art40_iva += a36v; } } if (isnew) @@ -603,12 +609,27 @@ void TLiquidazione_app::describe_pims(int month, const char* codatt) } } } - + + if (art40.sign() > 0 || art40_iva.sign() > 0) + { + _DescrItem* ads = new _DescrItem(PIM_ROW); + ads->_s0 = ref; + ads->_s1 = "A36"; + ads->_r0 = art40; + ads->_r1 = art40_iva; + if (isfirst) + { + isfirst = FALSE; + ads->_f0 = TRUE; + } + _descr_arr.add(ads); + } + if (autodafe.sign() > 0 || autodafe_iva.sign() > 0) { _DescrItem* ads = new _DescrItem(PIM_ROW); ads->_s0 = ref; - ads->_s1 = "A35"; // cosi' vollero + ads->_s1 = "AF"; // cosi' vollero, inoltre non e' piu' A35 ma AF, come sul dio sistema ads->_r0 = autodafe; ads->_r1 = autodafe_iva; if (isfirst) @@ -1209,8 +1230,10 @@ void TLiquidazione_app::set_pim(_DescrItem& d) return; int rw = 1; - if (d._s1 == "A35") - d._s2 = "Artt.17c3/74c1"; + if (d._s1 == "AF") //Il dio sistema colpisce ancora, non va bene A35, ma AF... + d._s2 = "Artt.17c3/74c1"; // La descrizione non la metto uguale perche' cosi e' piu' fika + else if (d._s1 == "A36") // Sempre per merito del dio sistema ho dovuto aggiungere A36. + d._s2 = "Art.40c5/6/8 a.i."; else if (d._s0 == "74TER") rw++; else