From 715de709b8272eef259cee72c54826a397772055 Mon Sep 17 00:00:00 2001 From: bonazzi Date: Mon, 2 Apr 2018 10:06:24 +0000 Subject: [PATCH] Patch level : 12.0 552 Files correlati : cg4.exe cg7.exe Modificato il calcolo dell' iva per cassa e differita nella liquidazione e nei quadri della dichiarazione, metteva in ivadiff dei righi di pagamaemnto di iva esente che non avevano il rigo fattura corretto. git-svn-id: svn://10.65.10.50/branches/R_10_00@24449 c028cbd2-c16b-5b4b-a496-9718f37d4682 --- src/cg/cg4300.h | 5 +- src/cg/cg4301.cpp | 116 +++++++++------- src/cg/cg4304.cpp | 329 +++++++--------------------------------------- src/cg/cg4400.cpp | 15 ++- src/cg/ivadiff.h | 1 + 5 files changed, 123 insertions(+), 343 deletions(-) diff --git a/src/cg/cg4300.h b/src/cg/cg4300.h index 36ee611a1..faa42a406 100755 --- a/src/cg/cg4300.h +++ b/src/cg/cg4300.h @@ -473,7 +473,7 @@ public: void zero_att (int month, const char* codatt); void zero_annual (int month); void recalc_att (int month, const char* codatt, TAssoc_array & caus_reg, real & tot_reg); - void recalc_annual (const char* codatt, real tot_reg, bool & first); + void recalc_annual (const char* codatt, bool & first); _DescrItem* recalc_rimborso(int month, const char* codatts, bool print); // Le funzioni che hanno come prefisso iva11 sono per creare il file di trasferimento per IVA11 @@ -591,8 +591,7 @@ public: void set_pim_head(_DescrItem& d); // void set_liqacc_1999(_DescrItem& d); - int calc_inc_diff(int tipoiva, real& imponibile_diff, real& imposta_diff, real& imponibile_xcas, real& imposta_xcas); - int print_acc_diff_xcassa(const _DescrItem& d); + int print_acc_diff_xcassa(const _DescrItem& d); void set_liqacc_2000(_DescrItem& d); // Utility per stampare nella colonna debito o credito diff --git a/src/cg/cg4301.cpp b/src/cg/cg4301.cpp index 9e7c9eb2a..90878c8b3 100755 --- a/src/cg/cg4301.cpp +++ b/src/cg/cg4301.cpp @@ -306,7 +306,6 @@ bool TLiquidazione_app::update_firm(int month, bool recalc) { const TString8 codatt = ndt_att.get("CODATT"); const TString80 desatt = ndt_att.get("DESCR"); - real tot_reg; // totale imponibile regolarizzazioni quater = _nditte->curr().get_bool("FLIVA11Q"); @@ -343,7 +342,9 @@ bool TLiquidazione_app::update_firm(int month, bool recalc) const bool waspla = look_pla(cattiv, has_single_activity); if (!waspla) break; // Non calcolare attivitą inesistenti 29-11-2012 - + + real tot_reg = _pla->get_real("R34"); // totale imponibile regolarizzazioni + if (tipoatt == 1 && waspla) { _p8 = _pla->get_real("R5"); @@ -380,7 +381,8 @@ bool TLiquidazione_app::update_firm(int month, bool recalc) if (!_recalc_regis && tipoatt == 1 && waspla && month == 13) { - // azzera pla dove serve + // azzera pla dove serve + _pla->zero("R0"); _pla->zero("R1"); _pla->zero("R2"); @@ -395,10 +397,10 @@ bool TLiquidazione_app::update_firm(int month, bool recalc) _pla->zero("R15"); _pla->zero("R16"); _pla->zero("R17"); - _pla->zero("R18"); - _pla->put("S1","0"); + _pla->zero("R18"); + _pla->put("S1","0"); _pla->put("S2","0"); - _pla->put("S3","0"); + _pla->put("S3", "0"); _pla->rewrite(); } @@ -418,14 +420,21 @@ bool TLiquidazione_app::update_firm(int month, bool recalc) stliq = riepliq = false; if (calc || !recalc) - if (!update_att(month, cattiv, caus_reg, tot_reg) && stliq) - describe_error(TR("Attivitą non ricalcolate: possibili errori"), + if (update_att(month, cattiv, caus_reg, tot_reg) && stliq) + { + _pla->put("R34", tot_reg); + _pla->rewrite(); + tot_reg = ZERO; + + } + else + describe_error(TR("Attivitą non ricalcolate: possibili errori"), codatt); if (_recalc_regis) continue; if (month == 13) - recalc_annual(cattiv, tot_reg, first_attiv); + recalc_annual(cattiv, first_attiv); // vediamo se c'e' qualcosa da raccontare gheravergot = _isannual || _isriepilogo; @@ -543,7 +552,8 @@ bool TLiquidazione_app::update_att(int month, const char* codatt, TAssoc_array & if (calc || !recalc) { - zero_att(month,codatt); + zero_att(month,codatt); + tot_reg = ZERO; recalc_att(month,codatt, caus_reg, tot_reg); if (!_recalc_regis) { @@ -1485,8 +1495,6 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt, TAssoc_array & if (nr == 214882) int i = 1 ; - if (iva_cass && tm == vendita) - int i = 1; #endif if ((soloiva && @@ -1515,15 +1523,14 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt, TAssoc_array & continue; TDate datafat; + long numreg = _rmoviva->get_long(RMI_NUMREG); const TDate datareg = _mov->get_date(MOV_DATAREG); int mesereg = datareg.month(); - const bool ok = is_month_ok(month, mesereg) && (atoi(_year) == datareg.year()); + const bool ok = is_month_ok(mesereg, month) && (atoi(_year) == datareg.year()); - if (!ok && civa.senza_imposta()) + if (!ok || is_detr_diff == 1 || civa.tipo() == "NS") continue; - if (is_detr_diff == 1 && !ok) - continue; - if (bRowIsMovDiff && tm == tm_fattura) + if (bIsMovDiff && tm == tm_fattura) { datafat = datareg; sezfat = tipomov == vendita ? 'D' : 'A'; @@ -1559,7 +1566,7 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt, TAssoc_array & cantwrite_box(id.description()); } - if (bRowIsMovDiff && !pagscatt.empty()) + if (bIsMovDiff && !pagscatt.empty()) { const char sezpag = tipomov == vendita ? 'A' : 'D'; real totfat = _mov->get(MOV_TOTDOC); @@ -4425,7 +4432,7 @@ void TLiquidazione_app::write_liq(int month, const char* codatts) _lam->rewrite(); } -void TLiquidazione_app::recalc_annual(const char* att, real tot_reg, bool & first) +void TLiquidazione_app::recalc_annual(const char* att, bool & first) { // viene chiamata 2 volte per le att. miste; PLA e' stata // azzerata dove serve da update_firm se siamo all'annuale @@ -4452,7 +4459,8 @@ void TLiquidazione_app::recalc_annual(const char* att, real tot_reg, bool & firs CHECKD(tipoatt > 0, "Tipo att non valido ", tipoatt); look_pla(aaa); - volaff1 = _pla->get_real("R14") - tot_reg; + + volaff1 = _pla->get_real("R14"); volaff2 = (const char*)_pla->get("S1"); vendite = _pla->get_real("R0"); es_c1 = _pla->get_real("R1"); @@ -4465,7 +4473,8 @@ void TLiquidazione_app::recalc_annual(const char* att, real tot_reg, bool & firs pro_pag = _pla->get_real("R12"); iva_acq = _pla->get_real("R11"); ven_rev = _pla->get_real("R18"); - + volaff1 -= _pla->get_real("R34"); + // Per avere un risultato corretto, si deve totalizzare PIM->R3 per codice iva // e quindi effettuare lo scorporo dell'imponibile e aggiungere al relativo volume d'affari TAssoc_array corr_ann; @@ -4566,51 +4575,58 @@ void TLiquidazione_app::recalc_annual(const char* att, real tot_reg, bool & firs //_plm->rewrite(); } -// nella prima attivitą sottrae le vendite per cassa e a liquidazione differita +// nella prima attivitą calcola 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; + TImporto tot; + TImporto tot1; +// ivadiff incassata nell'anno + query << "USE IVADIFF KEY 2" + << "\n TO ANNOLIQ=" << _year; + TISAM_recordset id(query); long cur_numreg = 0; - int cur_tipoiva = 0; - int cur_tipodiff = 0; + int tipomov = 0; + int tipoiva = 0; + const int year = atoi(_year); + const TDate dal(1, 1, year); + const TDate al(31, 12,year); + TString8 codiva; + TString8 tipo_aliquota; + TToken_string key; - 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(); + const int tipoiva = id.get(ID_TIPOIVA).as_int(); + const int tipomov = id.get(ID_TIPOMOV).as_int(); + const int annoliq = id.get(ID_ANNOLIQ).as_int(); + const TDate dataregp = id.get(ID_DATAREGP).as_date(); + const TImporto imp(sezione, id.get(RMI_IMPONIBILE).as_real()); - if (!imp.is_zero() && cur_tipoiva == 1) // Vendite + key = id.get(ID_NUMREG).as_string(); + key.add(id.get(ID_NUMRIG).as_string()); + codiva = cache().get(LF_RMOVIVA, key, RMI_CODIVA); + key = codiva; + tipo_aliquota = cache().get("%IVA", key, "S1"); + + if (tipo_aliquota.blank()) { - switch (tipomov) + if ((dataregp >= dal) && (dataregp <= al)) { - 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; + if ((tipoiva == 1) && (tipomov > 2)) + tot -= imp; } + if ((annoliq == year) && (tipoiva == 1)) + tot1 += imp; } } first = false; + tot.normalize('D'); + volaff1 += tot.valore(); + tot1.normalize('D'); + volaff1 += tot1.valore(); } _pla->put("R0", vendite); _pla->put("R1", es_c1); diff --git a/src/cg/cg4304.cpp b/src/cg/cg4304.cpp index abc4c1bbc..2ada44136 100755 --- a/src/cg/cg4304.cpp +++ b/src/cg/cg4304.cpp @@ -14,6 +14,7 @@ #include #include #include +#include "ivadiff.h" // flags per annuale #define IS_PRORATA 0x0001 @@ -216,7 +217,6 @@ void TLiquidazione_app::describe_liqacc() real cre_pre (ff.get(0)); real acq_intr (ff.get(1)); d->_r9 = cre_pre; - d->_r10 = acq_intr; _descr_arr.add(d); } @@ -1581,130 +1581,6 @@ void TLiquidazione_app::set_plafond(_DescrItem& d) set_auto_ff(); } -/* Obsoleto - -void TLiquidazione_app::set_liqacc_1999(_DescrItem& d) -{ - real r1 = d._r0 + d._r1 + d._r2 + d._r4; - //real r2 = d._r5 + d._r10; - real r2 = d._r5; //MI2258 (A me sembra una cagata, ma con certa gente non si riesce a parlare) - real r3 = r2 + d._r9 + d._r7; - if ((d._r3).sign() > 0) r1 += d._r3; - else r3 += abs(d._r3); - - set_row(1,""); set_row(2,""); set_row(3,""); set_row(4,""); - set_row(5,FR("@11gCALCOLO ACCONTO SU OPERAZIONI EFFETTUATE")); - - set_row(6,""); - set_row(7,FR("@72gCredito@90gDebito")); set_row(8,""); - if (!_isdiffacc) - set_row(9,FR("@11gIva sulle operazioni annotate fino al 20 Dicembre@81g%r"), &(d._r0)); - else - set_row(9,FR("@11gIva sulle operazioni di vendita@81g%r"), &(d._r0)); - int i = 10; - if (!_isdiffacc) - { - set_row(i++,FR("@11gIva su operazioni fino al 20 Dic., ma non fatturate@81g%r"), &(d._r1)); - set_row(i++,FR("@11gIva su operazioni fino al 20 Dic., ma non annotate@81g%r"), &(d._r2)); - } - set_row(i,FR("@11gRettifiche iva a debito")); - if (d._r3.sign() > 0) - set_row(i,"@81g%r", &(d._r3)); - i++; - set_row(i++,FR("@11gIva chiesta a rimborso@81g%r"), &(d._r4)); - set_row(i++,FR("@11gRISULTATO@81g%r"), &r1); - - if (!_isdiffacc) - set_row(i++,FR("@11gIva sugli acquisti annotati fino al 20 Dicembre@64g%r"), &r2); - else - set_row(i++,FR("@11gIva sulle operazioni di acquisto@64g%r"), &r2); - if (d._r6 != ZERO) - set_row(i++,FR("@11gmeno perc. di prorata pari a lire %r"), &(d._r6)); - set_row(i++, FR("@11gCredito precedente@64g%r"), &(d._r9)); - set_row(i, FR("@11gRettifiche iva a credito")); - if ((d._r3).sign() <= 0) - { - real ab = abs(d._r3); - set_row(i,"@64g%r", &ab); - } - i++; - set_row(i++,FR("@11gRISULTATO@64g%r"), &r3); - if ((d._r8).sign() < 0) - { - real ab = abs(d._r8); - set_row(i++,FR("@23gCREDITO DA EVIDENZIARE@64g%r"), &ab); - } - else if ((d._r8).sign() > 0 && d._r8 > _ver->get(I_ACCONTOIVA)) - set_row(i++,FR("@23gACCONTO DA VERSARE@81g%r"), &(d._r8)); - else if ((d._r8).sign() > 0 && d._r8 <= _ver->get(I_ACCONTOIVA)) - set_row(i++,FR("@23gACCONTO DA NON VERSARE@64g%r"), &(d._r8)); - - set_auto_ff(); -} -*/ - -int TLiquidazione_app::calc_inc_diff(int tipoiva, real& imponibile_diff, real& imposta_diff, real& imponibile_xcas, real& imposta_xcas) -{ - CHECKD(tipoiva == 1 || tipoiva == 2, "Bad tipo iva:", tipoiva); - int flag = 0; - - imponibile_diff = imposta_diff = imponibile_xcas = imposta_xcas = ZERO; - - TString limit; limit << "ANNOLIQ=" << _year; - if (_month < 13) limit << " MESELIQ=" << _month; - TString query; // righe pagamento (TIPOMOV>=3) ed escluse NC! - query << "USE IVADIFF KEY 2 SELECT (TIPOMOV>2)&&(TIPOIVA=" << tipoiva << ")&&NUM(INDETR!='X')" - << "\nFROM " << limit << "\nTO " << limit; - - TISAM_recordset id(query); - const TRectype& rec = id.cursor()->curr(); - for (bool ok = id.move_first(); ok; ok = id.move_next()) - { - const real iva = rec.get_real(RMI_IMPOSTA); - const real imp = rec.get_real(RMI_IMPONIBILE); - if (!iva.is_zero() || !imp.is_zero()) - { - const int tipodiff = rec.get_int("TIPODIFF"); - switch (tipodiff) - { - case 1: imponibile_diff += imp; imposta_diff += iva; break; - case 2: imponibile_xcas += imp; imposta_xcas += iva; break; - default: break; - } - flag |= tipodiff; - } - } - - if (tipoiva == 2) - { - real perc_prorata; - - query = "USE PLM"; - query << "\nFROM CODTAB=" << _year << "\nTO CODTAB=" << _year; - TISAM_recordset ip(query); - const TRectype& recp = ip.cursor()->curr(); - for (bool ok = ip.move_first(); ok && perc_prorata == ZERO; ok = ip.move_next()) - { - int m = atoi(ip.get("CODTAB").as_string().mid(10)); - real p = ip.get("R12").as_real(); - if (m == _month && (p > ZERO && p <= CENTO)) - perc_prorata = p; - } - - if (perc_prorata > ZERO) - { - real ind = imposta_diff * perc_prorata / CENTO; - ind.round(TCurrency::get_firm_dec()); - imposta_diff -= ind; - ind = imposta_xcas * perc_prorata / CENTO; - ind.round(TCurrency::get_firm_dec()); - imposta_xcas -= ind; - } - } - - return flag; -} - int TLiquidazione_app::print_acc_diff_xcassa(const _DescrItem& d) { int i = 9; @@ -1818,129 +1694,6 @@ void TLiquidazione_app::set_liqacc_2000(_DescrItem& d) set_auto_ff(); } -/* - -bool TLiquidazione_app::print_dainc_diff_log(int& rw, int tipoatt, int tipoiva) -{ - TString limit; limit << "ANNOLIQ=" << _year; - if (_month < 13) limit << " MESELIQ=" << _month; - TString query; - query << "USE IVADIFF KEY 2 SELECT (TIPOMOV==1)"; - //if (_isregis && tipoiva > 0) query << "&&(TIPOIVA==" << tipoiva << ')'; - if (tipoatt > 0) - query << " &&(TIPOATT==" << tipoatt << ")"; - query << "\nBY TIPOIVA DATAREG"; - query << "\nJOIN MOV INTO NUMREG==NUMREG"; - query << "\nJOIN CLIFO TO MOV INTO TIPOCF==TIPO CODCF==CODCF"; - query << "\nFROM " << limit << "\nTO " << limit; - - int header = 0; - - TISAM_recordset id(query); - const int rfat = id.items(); - if (rfat > 0) - { - const TRectype& rec = id.cursor()->curr(); - bool header_printed = false; - for (bool ok = id.move_first(); ok; ok = id.move_next()) - { - real importo, imponibile, imposta; - const TDate nulldate; - residuo_da_liquidare(rec.get_long(RMI_NUMREG), rec.get_int(RMI_NUMRIG), nulldate, - importo, imponibile, imposta); - const int ti = rec.get_int("TIPOIVA"); - if (ti != header) - { - if (ti < 2) - set_row(rw++, TR("Fatture da incassare")); - else - set_row(rw++, TR("Fatture da pagare")); - set_row(rw++, "IVA@17gImporto@30gImponibile@49gImposta@57gC/D@74gProt.@80gN. Doc.@89gData reg.@100gCodice@107gRagione sociale"); - header = ti; - } - - const TString4 codiva = rec.get("CODIVA"); - const int protiva = id.get("MOV.PROTIVA").as_int(); - const TString8 numfat = id.get("MOV.NUMDOC").as_string(); - const TString16 datafat = rec.get("DATAREG"); - const char* tipolog = id.get("TIPODIFF").as_int() == 2 ? TR("C") : TR("D"); - - const long codcf = id.get("CLIFO.CODCF").as_int(); - TParagraph_string clifo(id.get("CLIFO.RAGSOC").as_string(), 25); - - set_row(rw++, "%s@9g%r@25g%r@41g%r@58g%s@74g%5d@80g%s@89g%s@100g%6ld@107g%s", - (const char*)codiva, &importo, &imponibile, &imposta, - tipolog, protiva, (const char*)numfat, (const char*)datafat, - codcf, clifo.get()); - const char* ragsoc2 = clifo.get(); - if (ragsoc2 != NULL && strlen(ragsoc2) > 3) - set_row(rw++, "@107g%s", ragsoc2); - } - } - - return rfat > 0; -} - -bool TLiquidazione_app::print_inc_diff_log(int& rw, int tipoatt, int tipoiva) -{ - TString limit; limit << "ANNOLIQ=" << _year; - if (_month < 13) limit << " MESELIQ=" << _month; - TString query; - query << "USE IVADIFF KEY 2 SELECT (TIPOMOV>2)"; - // if (_isregis && tipoiva > 0) query << "&&(TIPOIVA==" << tipoiva << ')'; - if (tipoatt > 0) - query << " &&(TIPOATT==" << tipoatt << ")"; - query << "\nBY TIPOIVA DATAREGP"; - query << "\nJOIN MOV INTO NUMREG==NUMREG"; - query << "\nJOIN CLIFO TO MOV INTO TIPOCF==TIPO CODCF==CODCF"; - query << "\nFROM " << limit << "\nTO " << limit; - - TISAM_recordset id(query); - const int rpag = id.items(); - if (rpag > 0) - { - const TRectype& rec = id.cursor()->curr(); - int header = 0; - for (bool ok = id.move_first(); ok; ok = id.move_next()) - { - const int ti = rec.get_int("TIPOIVA"); - if (ti != header) - { - if (ti < 2) - set_row(rw++, TR("Fatture incassate")); - else - set_row(rw++, TR("Fatture pagate")); - set_row(rw++, "IVA@17gImporto@30gImponibile@49gImposta@57gC/D@61gPagamento@74gProt.@80gN. Doc.@89gData reg.@100gCodice@107gRagione sociale"); - header = ti; - } - - const TString4 codiva = rec.get(RMI_CODIVA); - const real importo = rec.get("IMPORTO"); - const real imponibile = rec.get(RMI_IMPONIBILE); - const real imposta = rec.get(RMI_IMPOSTA); - const char* tipolog = id.get("TIPODIFF").as_int() == 2 ? TR("C") : TR("D"); - const TString16 datapag = rec.get("DATAREGP"); - const int protiva = id.get("MOV.PROTIVA").as_int(); - const TString16 numfat = id.get("MOV.NUMDOC").as_string(); - const TString16 datafat = rec.get("DATAREG"); - - const long codcf = id.get("CLIFO.CODCF").as_int(); - TParagraph_string clifo(id.get("CLIFO.RAGSOC").as_string(), 25); - - set_row(rw++, "%s@9g%r@25g%r@41g%r@58g%s@61g%s@74g%5d@80g%s@89g%s@100g%6ld@107g%s", - (const char*)codiva, &importo, &imponibile, &imposta, - tipolog, (const char*)datapag, protiva, (const char*)numfat, (const char*)datafat, - codcf, clifo.get()); - const char* ragsoc2 = clifo.get(); - if (ragsoc2 != NULL && strlen(ragsoc2) > 3) - set_row(rw++, "@107g%s", ragsoc2); - } - } - - return rpag > 0; -} -*/ - void TLiquidazione_app::set_pim_head(_DescrItem& d) { int r = 1; @@ -2792,52 +2545,62 @@ void TLiquidazione_app::set_iva_succ(int& rw) { TString query; - query << "USE IVADIFF KEY 2 SELECT (BETWEEN(DATAREG,#DAL,#AL))&&(BETWEEN(DATAREGP,0,#AL))" - << "\nFROM ANNOLIQ=" << _year; - TISAM_recordset id(query); + query << "USE IVADIFF KEY 2" + << "\nFROM ANNOLIQ=" << _year + << "\nTO ANNOLIQ=" << _year; + TISAM_recordset id(query); const TDate da_datareg(1, 1, atoi(_year)); const TDate a_datareg(31, 12, atoi(_year)); - id.set_var("#DAL", da_datareg); - id.set_var("#AL", a_datareg); - - TImporto ven_diff, ven_xcas, acq_xcas; - long cur_numreg = 0; - int cur_tipodif = 0; - int cur_tipoiva = 0; + TImporto ven_diff, ven_xcas, acq_xcas, acq_diff; + TString8 codiva; + TString8 tipo_aliquota; + TToken_string key; - 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_tipodif = id.get("TIPODIFF").as_int(); - cur_tipoiva = id.get("TIPOIVA").as_int(); - } - const char sezione = id.get("SEZIONE").as_string()[0]; - const TImporto imp(sezione, id.get(RMI_IMPONIBILE).as_real()); + for (bool ok = id.move_first(); ok; ok = id.move_next()) + { + const int tipodiff = id.get(ID_TIPODIFF).as_int(); + const int tipoiva = id.get(ID_TIPOIVA).as_int(); + const char sezione = id.get(ID_SEZIONE).as_string()[0]; + const TImporto imp(sezione, id.get(RMI_IMPONIBILE).as_real()); - if (!imp.is_zero()) - { - if (cur_tipoiva == 1) // Vendite - { - if (cur_tipodif == 1) - ven_diff += imp; - else - ven_xcas += imp; - } - else - acq_xcas += imp; - } + key = id.get(ID_NUMREG).as_string(); + key.add(id.get(ID_NUMRIG).as_string()); + codiva = cache().get(LF_RMOVIVA, key, RMI_CODIVA); + key = codiva; + tipo_aliquota = cache().get("%IVA", key, "S1"); + + if (tipo_aliquota.blank()) + { + if (tipoiva == 1) // Vendite + { + if (tipodiff == 1) + ven_diff += imp; + else + ven_xcas += imp; + } + else + { + if (tipodiff == 1) + acq_diff += imp; + else + acq_xcas += imp; + } + } } if (!ven_diff.is_zero() || !ven_xcas.is_zero() || !acq_xcas.is_zero()) { + ven_diff.normalize('D'); + ven_xcas.normalize('D'); + acq_xcas.normalize('A'); + acq_diff.normalize('A'); set_row(rw++,FR("@11g@bOPERAZIONI EFFETTUATE NELL'ANNO CON IMPOSTA ESIGIBILE NEGLI ANNI SUCCESSIVI@r")); const real vd = ven_diff.valore(); const real vc = ven_xcas.valore(); const real vt = vc+vd; - const real at = acq_xcas.valore(); + const real ac = acq_xcas.valore(); + const real ad = acq_diff.valore(); + const real at = ac+ad; set_row(rw++, "Totale vendite con IVA esigibile negli anni successivi@66g%r", &vt); set_row(rw++, "Di cui con IVA per cassa@66g%r", &vc); @@ -3015,7 +2778,7 @@ bool TLiquidazione_app::set_annual(_DescrItem& d) set_row(row++,""); const real perc_det = CENTO - d._r2; - const real vol_aff = d._r0 - d._r10; // Valutare se eliminare d._r10 come valore e sottrarlo a monte + const real vol_aff = d._r0; const TString16 s1 = perc_det.stringa(); const TString16 s2 = d._r2.stringa(); set_row(row++, FR("%% PRO-RATA (%s%%) ed IVA non detraibile (%s%%)@69g%r"), diff --git a/src/cg/cg4400.cpp b/src/cg/cg4400.cpp index 4e408eeb4..fa8a2f6ab 100755 --- a/src/cg/cg4400.cpp +++ b/src/cg/cg4400.cpp @@ -31,7 +31,7 @@ #include #include -static enum tipo_sospensione { nessuna, normale, vol_affari, liquidazione }; +enum tipo_sospensione { nessuna, normale, vol_affari, liquidazione }; inline TStampa_registri_app& app() { return (TStampa_registri_app&)main_app(); } @@ -456,8 +456,8 @@ bool TStampa_registri_app::mask_mese (TMask_field& f, KEY k) int mese; if (id == MESE) //Per stampa su libro unico mese = f.mask().get_int(MESE); - if (id == FINO_A_MESE) - mese = m.get_int(FINO_A_MESE); //Per stampa su bollato + if (id == FINO_A_MESE) + mese = m.get_int(FINO_A_MESE); //Per stampa su bollato if (id == MESE) { if (mese == 12) @@ -470,17 +470,18 @@ bool TStampa_registri_app::mask_mese (TMask_field& f, KEY k) m.hide (TIPO_RIEPILOGATIVO); m.hide (RIF_VID); } - } + } if (id == FINO_A_MESE) { if (mese == 12) m.show (TIPO_RIEPILOGATIVO); else m.hide (TIPO_RIEPILOGATIVO); - } + } } if (k==K_TAB && f.mask().is_running()) { const short id = f.dlg(); + if (id == MESE) m.send_key(K_TAB, CODICE_LIBRO_IVA); } @@ -3777,8 +3778,8 @@ bool TStampa_registri_app::set_print(int n) int giorni_del_mese = 31; if (_fino_a_mese == 12) { - giorni_del_mese = 31; - _tipo_riepilogativo = m.get(TIPO_RIEPILOGATIVO)[0]; + giorni_del_mese = 31; + _tipo_riepilogativo = m.get(TIPO_RIEPILOGATIVO)[0]; } else { diff --git a/src/cg/ivadiff.h b/src/cg/ivadiff.h index fff4337c5..6ac2fd9aa 100644 --- a/src/cg/ivadiff.h +++ b/src/cg/ivadiff.h @@ -1,3 +1,4 @@ +#define ID_NUMREG "NUMREG" #define ID_NUMRIG "NUMRIG" #define ID_NUMPRO "NUMPRO" #define ID_TIPOMOV "TIPOMOV"