From fbc375cfdcb43a236d98f5e5fcd4cb86ac4e6d3c Mon Sep 17 00:00:00 2001 From: Alessandro Bonazzi Date: Tue, 20 Apr 2021 22:11:35 +0200 Subject: [PATCH] Patch level : 12.0 1058 Files correlati : cg0100a.msk src/cg/cg2100c.msk cg7.exe cg7600o.rep cg7600a.rep cg7700a.rep cg7700b.rep Commento : Aggiunto tipo costo ricavo per acquisti di materie prime al piano dei conti e alla prima nota Modelli IVA 2021 --- src/cg/cg0100a.uml | 1 + src/cg/cg21iva.uml | 1 + src/cg/cg7401.cpp | 32 ++++++++++---- src/cg/cg7401.h | 10 +++-- src/cg/cg7600.cpp | 102 ++++++++++++++++++++++++++++++++++++--------- src/cg/cg7600a.rep | 4 +- src/cg/cg7600o.rep | 86 ++++++++++++++++++++++++++++++++++++++ src/cg/cg7700.cpp | 18 +++----- src/cg/cg7700a.rep | 4 +- src/cg/cg7700b.rep | 2 +- src/cg/cg7800.cpp | 22 ++++++++-- src/cg/cglib.h | 3 ++ 12 files changed, 233 insertions(+), 52 deletions(-) create mode 100644 src/cg/cg7600o.rep diff --git a/src/cg/cg0100a.uml b/src/cg/cg0100a.uml index 34105cd3b..524ec6505 100755 --- a/src/cg/cg0100a.uml +++ b/src/cg/cg0100a.uml @@ -416,6 +416,7 @@ BEGIN ITEM "8|8. Altri beni strumentali acquistati in leasing" ITEM "9|9. Spese Generali" ITEM "17|17. Operazioni nei confronti dei condominii" + ITEM "51|51. Acquisti materie prime per la produzione" END LIST FLD_CM1_RICSER 1 18 diff --git a/src/cg/cg21iva.uml b/src/cg/cg21iva.uml index 6126ec2f8..f58094277 100755 --- a/src/cg/cg21iva.uml +++ b/src/cg/cg21iva.uml @@ -247,6 +247,7 @@ BEGIN ITEM "8|8. Altri beni strumentali acquistati in leasing" ITEM "9|9. Spese generali" ITEM "17|17. Operazioni nei confronti dei condominii" + ITEM "51|51. Acquisti materie prime per la produzione" FLAGS "D" HELP "Tipo Costo/Ricavo del conto" END diff --git a/src/cg/cg7401.cpp b/src/cg/cg7401.cpp index 3f999cf6e..1e03e860d 100644 --- a/src/cg/cg7401.cpp +++ b/src/cg/cg7401.cpp @@ -159,6 +159,17 @@ bool TQuadro_IVA_mask::on_field_event(TOperable_field& o, TField_event e, long j return true; } +TISAM_recordset & TQuadro_IVA_recordset::get_recordset(const int code, const int year) +{ + real val; + TProgram_report & rep = _mask->get_report(code - 1); + TISAM_recordset * set = (TISAM_recordset *)rep.recordset(); + + CHECK(set != nullptr, TR("Null report")); + set->set_var("#ANNO", format("%d", year == 0 ? _year : year)); + return *set; +} + const real TQuadro_IVA_recordset::evaluate_recordset(const int code, const int year, const char * field, const char * expr) { real val; @@ -227,17 +238,20 @@ const TVariant& TQuadro_IVA_recordset::get(const char* column_name) const return TISAM_recordset::get(column_name); } -void TQuadro_IVA_recordset::add_value(const char *s, real value) +void TQuadro_IVA_recordset::add_value(const char *s, const real value) { - real * val = (real *)_values.objptr(s); + if (s && *s) + { + real * val = (real *)_values.objptr(s); - if (val == nullptr) - { - const TString8 key(s); - _values.add(key, val = new real); - _types.add(key, TString("real")); - } - *val += value; + if (val == nullptr) + { + const TString8 key(s); + _values.add(key, val = new real); + _types.add(key, TString("real")); + } + *val += value; + } } void TQuadro_IVA_recordset::set_bool(const char *s, bool on) diff --git a/src/cg/cg7401.h b/src/cg/cg7401.h index c81b67c59..bf1c3807c 100644 --- a/src/cg/cg7401.h +++ b/src/cg/cg7401.h @@ -43,15 +43,17 @@ class TQuadro_IVA_recordset : public TISAM_recordset protected: const TMask & mask() { return *_mask; } - void add_value(const char *s, real value); + void add_value(const char *s, const real value); + void sub_value(const char *s, const real value) { add_value(s, -value); } void set_bool(const char *s, bool on = false); void set(const char *s,const char * value); virtual void load() pure; virtual const TVariant& get(const char* column_name) const; void clear() { _values.destroy(); _types.destroy(); } - const real evaluate_recordset(const int code, const int year, const char * field, const char * expr = NULL); - const real evaluate_recordset_imponibile(const int code, const int year, const char * expr = NULL) { return evaluate_recordset(code, year, RMI_IMPONIBILE, expr); } - const real evaluate_recordset_imposta(const int code, const int year, const char * expr = NULL) { return evaluate_recordset(code, year, RMI_IMPOSTA, expr); } + TISAM_recordset & get_recordset(const int code, const int year = 0); + const real evaluate_recordset(const int code, const int year, const char * field, const char * expr = nullptr); + const real evaluate_recordset_imponibile(const int code, const int year, const char * expr = nullptr) { return evaluate_recordset(code, year, RMI_IMPONIBILE, expr); } + const real evaluate_recordset_imposta(const int code, const int year, const char * expr = nullptr) { return evaluate_recordset(code, year, RMI_IMPOSTA, expr); } public: TQuadro_IVA_recordset(TQuadro_IVA_mask * mask, const char* use, const int year) : TISAM_recordset(use), _mask(mask), _year(year) { } diff --git a/src/cg/cg7600.cpp b/src/cg/cg7600.cpp index 517230d90..6ee35f88c 100644 --- a/src/cg/cg7600.cpp +++ b/src/cg/cg7600.cpp @@ -21,6 +21,7 @@ #define REP_REVCHARGE 9 #define REP_TERREM 10 #define REP_PAART17 11 +#define REP_REGOLARIZ 12 class TQuadro_VE_recordset : public TQuadro_IVA_recordset { @@ -72,17 +73,23 @@ void TQuadro_VE_recordset::load() imposta.add("5.00", TString8("VE21.2")); imponibile.add("10.00",TString8("VE22.1")); imposta.add("10.00",TString8("VE22.2")); - - // le imposte che non esisto più le mette nella più vicina - imponibile.add("20.00", TString8("VE23.1")); - imposta.add("20.00", TString8("VE23.2")); - imponibile.add("21.00", TString8("VE23.1")); - imposta.add("21.00", TString8("VE23.2")); + imponibile.add("4.00", TString8("VE20.1")); + imposta.add("4.00", TString8("VE20.2")); + imponibile.add("5.00", TString8("VE21.1")); + imposta.add("5.00", TString8("VE21.2")); + imponibile.add("10.00", TString8("VE22.1")); + imposta.add("10.00", TString8("VE22.2")); + // le imposte che non esisto più le mette nella più vicina - imponibile.add("22.00", TString8("VE23.1")); - imposta.add("22.00", TString8("VE23.2")); + imponibile.add("20.00", TString8("VE23.1")); + imposta.add("20.00", TString8("VE23.2")); + imponibile.add("21.00", TString8("VE23.1")); + imposta.add("21.00", TString8("VE23.2")); + + imponibile.add("22.00", TString8("VE23.1")); + imposta.add("22.00", TString8("VE23.2")); TString256 query("USE PIM\nFROM CODTAB="); @@ -129,25 +136,28 @@ void TQuadro_VE_recordset::load() break; case vend_norm: // vendite normali case corr_norm: - if (aliquota.full()) + if (atoi(aliquota) != 0) { const bool agricolo = ivar.get_int("I4") != 0; if (agricolo) { - const TString * field = (TString *) imponibile_agricolo.objptr(aliquota); - - if (field != NULL) add_value(*field, imp); - field = (TString *) imposta_agricola.objptr(aliquota); - if (field != NULL) add_value(*field, iva); + add_value(*(TString *)imponibile_agricolo.objptr(aliquota), imp); + add_value(*(TString *)imposta_agricola.objptr(aliquota), iva); } else { - const TString * field = (TString *) imponibile.objptr(aliquota); + if (aliquota == "20.00" || aliquota == "21.00") + { + real imposta_corretta = imp; - if (field != NULL) add_value(*field, imp); - field = (TString *) imposta.objptr(aliquota); - if (field != NULL) add_value(*field, iva); + imposta_corretta *= 0.22; + imposta_corretta.round(0); + add_value("VE25.2", iva - imposta_corretta); + iva = imposta_corretta; + } + add_value(STRING_TOKEN(imponibile.objptr(aliquota)), imp); + add_value(STRING_TOKEN(imposta.objptr(aliquota)), iva); } } break; @@ -241,8 +251,61 @@ void TQuadro_VE_recordset::load() } } - query = "USE LIM\n FROM CODTAB=="; + TISAM_recordset & exp = get_recordset(REP_PAART17); + for (exp.move_first(); !exp.eof(); exp.move_next()) + { + TString8 cod(exp.get(FIELD_NAME(LF_RMOVIVA, RMI_CODIVA)).as_string()); + const TCodiceIVA & codiva = cached_codIVA(cod); + const TString & aliquota = codiva.aliquota(); + + if (aliquota.full()) + { + const real imp = exp.get(FIELD_NAME(LF_RMOVIVA, RMI_IMPONIBILE)).as_real(); + + if (codiva.is_agricola()) + sub_value(STRING_TOKEN(imponibile_agricolo.objptr(aliquota)), imp); + else + sub_value(STRING_TOKEN(imponibile.objptr(aliquota)), imp); + } + } + + TISAM_recordset & reg = get_recordset(REP_REGOLARIZ); + + for (reg.move_first(); !reg.eof(); reg.move_next()) + { + TString8 cod(reg.get(FIELD_NAME(LF_RMOVIVA, RMI_CODIVA)).as_string()); + const TCodiceIVA & codiva = cached_codIVA(cod); + const TString & aliquota = codiva.aliquota(); + + if (aliquota.full()) + { + const real imp = reg.get(FIELD_NAME(LF_RMOVIVA, RMI_IMPONIBILE)).as_real(); + real iva = reg.get(FIELD_NAME(LF_RMOVIVA, RMI_IMPOSTA)).as_real(); + + if (codiva.is_agricola()) + { + sub_value(STRING_TOKEN(imponibile_agricolo.objptr(aliquota)), imp); + sub_value(STRING_TOKEN(imposta_agricola.objptr(aliquota)), iva); + } + else + { + if (aliquota == "20.00" || aliquota == "21.00") + { + real imposta_corretta = imp; + + imposta_corretta *= 0.22; + imposta_corretta.round(0); + sub_value("VE25.2", imposta_corretta - iva); + iva = imposta_corretta; + } + sub_value(STRING_TOKEN(imponibile.objptr(aliquota)), imp); + sub_value(STRING_TOKEN(imposta.objptr(aliquota)), iva); + } + } + } + + query = "USE LIM\n FROM CODTAB=="; query << year() << "13\nTO CODTAB==" << year() << "13"; TISAM_recordset lim(query); @@ -391,6 +454,7 @@ void TQuadro_VE_app::load_sheet(TSheet_field & sf) TToken_string & row9 = sf.row(sf.items()); row9.add("|9|Stampa operazioni reverse charge|cg7600l"); TToken_string & row10 = sf.row(sf.items()); row10.add("|10|Stampa operazioni terremotati|cg7600m"); TToken_string & row11 = sf.row(sf.items()); row11.add("|11|Stampa operazioni effettuate con PA ai sensi art.17|cg7600n"); + TToken_string & row12 = sf.row(sf.items()); row12.add("|12|Stampa regolarizzazioni reverse charge|cg7600o"); } int cg7600(int argc, char* argv[]) diff --git a/src/cg/cg7600a.rep b/src/cg/cg7600a.rep index 979c8001c..5365e5bd8 100644 --- a/src/cg/cg7600a.rep +++ b/src/cg/cg7600a.rep @@ -124,7 +124,7 @@ #101+#201+#301+#401+#501+#601+#701+#801+#901+#1001+#1101+#2001+#2101+#2201+#2301