From 13d62fd1ac03f296465b0a44cc96bf3516d0dd69 Mon Sep 17 00:00:00 2001 From: AlexBonazzi Date: Thu, 28 Feb 2019 09:27:01 +0100 Subject: [PATCH] Patch level : 12.0 714 Files correlati : cg4.exe Commento : Corretto calcolo rimborsi in liquidazione per il credito utilizzabile --- src/cg/cg0800.cpp | 1 + src/cg/cg4300.cpp | 31 +++++++++++++++++++++++++++---- src/cg/cg4300.h | 1 + src/cg/cg4300a.uml | 6 ++++-- src/cg/cg4301.cpp | 6 +++++- src/cg/cg4302.cpp | 10 ++++++++-- src/cg/cg4304.cpp | 6 ++++++ src/cg/cg4400a.uml | 6 ++++-- src/cg/cg4b00.cpp | 2 ++ src/cg/cglib05.cpp | 34 +++++++++++++++++++++++++++++----- src/cg/cglib05.h | 9 ++++++--- 11 files changed, 93 insertions(+), 19 deletions(-) diff --git a/src/cg/cg0800.cpp b/src/cg/cg0800.cpp index 7aebf1db4..8b2a68824 100644 --- a/src/cg/cg0800.cpp +++ b/src/cg/cg0800.cpp @@ -79,6 +79,7 @@ void TRiepilogoIVA_app::main_loop() { damese = 1; amese = 12; + recset->set_annuale(true); } const TDate da(1, damese, anno); diff --git a/src/cg/cg4300.cpp b/src/cg/cg4300.cpp index a07935810..842f2b6bf 100755 --- a/src/cg/cg4300.cpp +++ b/src/cg/cg4300.cpp @@ -586,10 +586,15 @@ bool TLiquidazione_app::ch_year_handler(TMask_field& f, KEY key) (wht)f.mask().get_int(CG43_RDB_VERS) : all); TMask& msk = f.mask(); const int vers = msk.get_int(CG43_RDB_VERS); - const int m = (vers == 3) ? msk.get_int(CG43_LST_TRIM) : msk.get_int(CG43_LST_MESE); + int m = (vers == 3) ? msk.get_int(CG43_LST_TRIM) : msk.get_int(CG43_LST_MESE); + + app()._is_liq_acconto = (m == 20); + if (app()._is_liq_acconto) + m = 12; + const TRectype & lim = app().get_lim(m); const bool def = lim.get_bool("B1"); - const bool calc = !def && (lim.empty() || lim.get_bool("B0")); + const bool calc = app()._is_liq_acconto || (!def && (lim.empty() || lim.get_bool("B0"))); msk.set(CG43_CHK_CALCULATE, app()._lim_cleared && calc, 0x3); msk.set(CG43_CHK_FINAL, app()._lim_cleared && def, 0x3); @@ -690,6 +695,11 @@ bool TLiquidazione_app::what_freq_handler(TMask_field& f, KEY key) if (key == K_SPACE) { int month = f.mask().get_int(CG43_LST_MESE); + + app()._is_liq_acconto = (month == 20); + if (app()._is_liq_acconto) + month = 12; + if (f.get()[0] == '3') // trimestre intelligente { if (month > 3) @@ -778,7 +788,11 @@ bool TLiquidazione_app::chk_calculate_handler(TMask_field& f, KEY key) TMask& m = f.mask(); // Abilita solo se il mese di ricalcolo e' != 13 (annuale) e non e' checkkato il campo const int vers = m.get_int(CG43_RDB_VERS); - const int mese = vers == 3 ? m.get_int(CG43_LST_TRIM) : m.get_int(CG43_LST_MESE); + int mese = vers == 3 ? m.get_int(CG43_LST_TRIM) : m.get_int(CG43_LST_MESE); + + app()._is_liq_acconto = (mese == 20); + if (app()._is_liq_acconto) + mese = 12; const bool abilita = m.get_bool(CG43_CHK_CALCULATE) && mese != 13; m.enable(CG43_LST_CALC, abilita); } @@ -893,10 +907,19 @@ bool TLiquidazione_app::set_liquidazione() // handlers have set everything _month = _what == trimestre ? m.get_int(CG43_LST_TRIM) : m.get_int(CG43_LST_MESE); + app()._is_liq_acconto = (_month == 20); + if (app()._is_liq_acconto) + { + _month = 12; + _recalc = one; + } + else + _recalc = m.get_bool(CG43_CHK_CALCULATE) ? one : never; + + _year = m.get(CG43_FLD_ANNO); _date = m.get(CG43_FLD_DATA); _isprint = m.get_bool(CG43_CHK_STAMPA); - _recalc = m.get_bool(CG43_CHK_CALCULATE) ? one : never; _printonly = !m.get_bool(CG43_CHK_CALCULATE); _definitiva = m.get_bool(CG43_CHK_FINAL); diff --git a/src/cg/cg4300.h b/src/cg/cg4300.h index cddfe7c78..b9f35ef5c 100755 --- a/src/cg/cg4300.h +++ b/src/cg/cg4300.h @@ -304,6 +304,7 @@ class TLiquidazione_app : public TPrint_application int _monthinatt; // mese inizio attivita' (serve per differita) bool _lim_cleared; bool _definitiva; + bool _is_liq_acconto; bool _end_cassa; real _diff_ven_ap, _diff_ven_ap_iva, _diff_acq_ap, _diff_acq_ap_iva; diff --git a/src/cg/cg4300a.uml b/src/cg/cg4300a.uml index 4b896ee9e..36aba7a53 100755 --- a/src/cg/cg4300a.uml +++ b/src/cg/cg4300a.uml @@ -27,15 +27,16 @@ BEGIN CHECKTYPE REQUIRED END -LIST CG43_LST_MESE 15 +LIST CG43_LST_MESE 20 BEGIN PROMPT 28 3 "Periodo " HELP "Mese per cui effettuare il calcolo liquidazione" ITEM "13|13a liquid." + ITEM "20|Acconto Dicembre" FLAGS "MP" END -LIST CG43_LST_TRIM 15 +LIST CG43_LST_TRIM 20 BEGIN PROMPT 28 3 "Periodo " HELP "Trimestre di cui effettuare il calcolo liquidazione" @@ -44,6 +45,7 @@ BEGIN ITEM "9|3 Trimestre " ITEM "12|4 Trimestre" ITEM "13|13a liquid." + ITEM "20|Acconto Dicembre" END BOOLEAN CG43_CHK_CALCULATE diff --git a/src/cg/cg4301.cpp b/src/cg/cg4301.cpp index a9fb93283..1a0adccbe 100755 --- a/src/cg/cg4301.cpp +++ b/src/cg/cg4301.cpp @@ -4170,8 +4170,12 @@ void TLiquidazione_app::write_liq(int month, const char* codatts) if (risul > ZERO) { if (gestione_manuale_credito_compensabile) + { credito_utilizzato_iva = lim.get_real("R15"); - credito_utilizzato_iva = min(risul, credito_utilizzato_iva); + credito_utilizzato_iva = min(risul, credito_utilizzato_iva); + } + else + credito_utilizzato_iva = min(risul, credito_utilizzabile); res_cred += credito_utilizzato_iva; risultato -= credito_utilizzato_iva; } diff --git a/src/cg/cg4302.cpp b/src/cg/cg4302.cpp index 6494e6ac9..ba6bee792 100755 --- a/src/cg/cg4302.cpp +++ b/src/cg/cg4302.cpp @@ -57,7 +57,8 @@ bool TLiquidazione_app::is_month_ok(int x, int mtocalc) const { // per l'annuale ritorna true per tutti i mesi da liquidare ret = x <= 13; - } + } + return ret; } @@ -138,7 +139,12 @@ bool TLiquidazione_app::is_date_ok(const TDate& d, int month, int liqmonth, int else // Nuova selezione dal 1998 in poi { if (month <= 12) - return (regyear == year) && ((regmonth == month && liqmonth == 0) || (liqmonth == month)); + { + if (_is_liq_acconto) + return (regyear == year) && ((regmonth == month && liqmonth == 0) || (liqmonth == month)) && (d.day() <= _ver->giorno_acc()); + else + return (regyear == year) && ((regmonth == month && liqmonth == 0) || (liqmonth == month)); + } else // Annuale, month == 13 return (regyear == year && liqmonth != 12) || (regyear == year + 1 && liqmonth == 12); } diff --git a/src/cg/cg4304.cpp b/src/cg/cg4304.cpp index 178473231..5fcddd4b9 100755 --- a/src/cg/cg4304.cpp +++ b/src/cg/cg4304.cpp @@ -1440,6 +1440,9 @@ void TLiquidazione_app::set_firm(_DescrItem& d) if (d._s2 == "T") tim_title << format(FR(" del %d° Trimestre %s"), d._f1/3, (const char*) _year); else + if (_is_liq_acconto) + tim_title << format(FR(" al %d %s %s"), _ver->giorno_acc(), itom(d._f1), (const char*)_year); + else tim_title << format(FR(" del mese di %s %s"), itom(d._f1), (const char*)_year); } @@ -1501,6 +1504,9 @@ void TLiquidazione_app::set_att(_DescrItem& d) if (d._s4 == "T") tim_title << format(FR(" del %d° Trimestre %s"), d._f1 / 3, (const char*)_year); else + if (_is_liq_acconto) + tim_title << format(FR(" al %d %s %s"), _ver->giorno_acc(), itom(d._f1), (const char*)_year); + else tim_title << format(FR(" del mese di %s %s"), itom(d._f1), (const char*)_year); } diff --git a/src/cg/cg4400a.uml b/src/cg/cg4400a.uml index 8961e2c40..6aff78fc7 100755 --- a/src/cg/cg4400a.uml +++ b/src/cg/cg4400a.uml @@ -158,18 +158,20 @@ BEGIN GROUP 3 END -LISTBOX FINO_A_MESE 10 +LISTBOX FINO_A_MESE 20 BEGIN PROMPT 3 9 "Fino al mese " HELP "Mese fino al quale eseguire la stampa" + ITEM "20|Acconto di dicembre" FLAGS "M" GROUP 1 END -LISTBOX MESE 10 +LISTBOX MESE 20 BEGIN PROMPT 3 9 "Mese " HELP "Mese di cui eseguire la stampa" + ITEM "20|Acconto di dicembre" FLAGS "M" GROUP 2 END diff --git a/src/cg/cg4b00.cpp b/src/cg/cg4b00.cpp index d8ee42f44..e35ac5c07 100644 --- a/src/cg/cg4b00.cpp +++ b/src/cg/cg4b00.cpp @@ -125,6 +125,8 @@ void TRiepilogoIVA_app::main_loop() recset->set_registrazioneIVAritardo(m.get_bool(F_REGRIT)); recset->set_from(m.get_date(F_DADATA)); recset->set_to(m.get_date(F_ADATA)); + recset->set_annuale((m.get_date(F_DADATA).month() == 1) && (m.get_date(F_ADATA).month() == 12) + ); recset->set_from_conto(m.get_long(F_DAGRUPPO), m.get_long(F_DACONTO), m.get_long(F_DASOTTOC)); if (m.get_long(F_DAGRUPPO) != 0) diff --git a/src/cg/cglib05.cpp b/src/cg/cglib05.cpp index 8e249deab..adee1cddf 100644 --- a/src/cg/cglib05.cpp +++ b/src/cg/cglib05.cpp @@ -1,4 +1,16 @@ #include "cglib05.h" +#include + +enum tiporeg { + vendita = 1, + acquisto = 2, + riepilogativo = 3, + incassi = 4, + giornale = 5, + sociale = 6, + cespiti = 7 +}; + /////////////////////////////////////////////////////////// // TRiepilogoIVA_recordset /////////////////////////////////////////////////////////// @@ -51,7 +63,7 @@ void TRiepilogoIVA_recordset::requery() TAssoc_array work_array; TString16 reg_fieldname; reg_fieldname << LF_MOV << "." << MOV_REG; TString16 datareg_fieldname; datareg_fieldname << LF_MOV << "." << MOV_DATAREG; - TString16 datacomp_fieldname; datacomp_fieldname << LF_MOV << "." << MOV_MESELIQ; + TString16 datadoc_fieldname; datadoc_fieldname << LF_MOV << "." << MOV_DATADOC; TString16 meseliq_fieldname; meseliq_fieldname << LF_MOV << "." << MOV_MESELIQ; int p = wrk.find("FROMDATE"); @@ -114,7 +126,19 @@ void TRiepilogoIVA_recordset::requery() } if (registrazioneIVAritardo()) { - TDate datacomp = recset.get(datacomp_fieldname).as_date(); + const TDate datadoc = recset.get(datadoc_fieldname).as_date(); + const TString4 codreg = recset.get(reg_fieldname).as_string(); + const TRegistro reg(codreg); + const TipoIVA tipo = reg.iva(); // 1=Vendite; 2=Acquisti + + const bool fatt_rit_2018 = recset.get(TOSTRING(LF_MOV) "." MOV_DATAREG).as_bool() && (data.year() >= 2018); + const int year_diff = data.year() - datadoc.year(); + const bool fattritind = ((tipo == iva_acquisti) && fatt_rit_2018) && + ((year_diff > 2) || ((year_diff >= 1) && data.month() >= 5)); + const bool fattrit = ((tipo == iva_acquisti) && !fattritind && fatt_rit_2018) && (year_diff >= 1); + + if (fattrit && !annuale() && _to_date.year() == datadoc.year()) + continue; } if (senzacompetenzaIVA() && (data < _from_date || data > _to_date)) continue; @@ -275,9 +299,9 @@ const TVariant& TRiepilogoIVA_recordset::get(unsigned int column) const } TRiepilogoIVA_recordset::TRiepilogoIVA_recordset() : TRecordset(), _pos(0), _from_date(botime), _to_date(eotime), - _from_gruppo(0), _from_conto(0), _from_sottoconto(0L), - _to_gruppo(999), _to_conto(999), _to_sottoconto(999999L), - _freezed(false) +_from_gruppo(0), _from_conto(0), _from_sottoconto(0L), +_to_gruppo(999), _to_conto(999), _to_sottoconto(999999L), _freezed(false), _annuale(false) + { add_field(_alfafld, 101, 4, COD); add_field(_alfafld, 102, 50, DESC); diff --git a/src/cg/cglib05.h b/src/cg/cglib05.h index 6db91dcc9..2c80c89e7 100644 --- a/src/cg/cglib05.h +++ b/src/cg/cglib05.h @@ -32,6 +32,7 @@ class TRiepilogoIVA_recordset : public TRecordset long _to_sottoconto; TArray _info; bool _freezed; + bool _annuale; protected: virtual const TVariant& get_field(int num, const char* field) const; @@ -59,9 +60,11 @@ public: virtual bool set_senzacompetenzaIVA(bool on) { return true; } virtual bool set_competenzadiversaIVA(bool on) { return false; } virtual bool set_registrazioneIVAritardo(bool on) { return false; } - virtual bool senzacompetenzaIVA() { return true; } - virtual bool competenzadiversaIVA() { return false; } - virtual bool registrazioneIVAritardo() { return false; } + virtual bool set_annuale(bool on) { _annuale = on; return _annuale; } + virtual bool senzacompetenzaIVA() const { return true; } + virtual bool competenzadiversaIVA() const { return false; } + virtual bool registrazioneIVAritardo() const { return false; } + virtual bool annuale() const { return _annuale; } TRiepilogoIVA_recordset(); virtual ~TRiepilogoIVA_recordset() { }