diff --git a/build/dncrypt.exe b/build/dncrypt.exe deleted file mode 100644 index 97fc1adfd..000000000 Binary files a/build/dncrypt.exe and /dev/null differ diff --git a/src/ba/ba4200b.uml b/src/ba/ba4200b.uml index e4f94c0fb..80898082b 100755 --- a/src/ba/ba4200b.uml +++ b/src/ba/ba4200b.uml @@ -909,8 +909,7 @@ BEGIN OUTPUT LST_AF4_EVECC ITEM " |Nessuno" ITEM "1|Vittime di richieste di natura estorsiva" - ITEM "3|Residenti a Lampedusa e Linosa nel 2011" - ITEM "8|Altri eventi eccezionali" + ITEM "5|Contribuenti colpiti da altri eventi eccezionali" END BOOLEAN FLD_AF4_RFDIVERSA diff --git a/src/ba/ba4200c.uml b/src/ba/ba4200c.uml index c9a97422d..70a4645db 100755 --- a/src/ba/ba4200c.uml +++ b/src/ba/ba4200c.uml @@ -1025,8 +1025,7 @@ BEGIN OUTPUT LST_AG5_EVECC ITEM " |Nessuno" ITEM "1|Vittime di richieste di natura estorsiva" - ITEM "3|Residenti a Lampedusa e Linosa nel 2011" - ITEM "6|Altri eventi eccezionali" + ITEM "5|Contribuenti colpiti da altri eventi eccezionali" END BOOLEAN CHK_AG5_RFDSL diff --git a/src/cg/cg0.cpp b/src/cg/cg0.cpp index aa85505bf..5ac704161 100755 --- a/src/cg/cg0.cpp +++ b/src/cg/cg0.cpp @@ -12,8 +12,9 @@ int main(int argc, char** argv) case 3: cg0400(argc,argv); break; // Progressivi IVA case 4: cg0500(argc,argv); break; // Causali contabili case 5: cg0600(argc,argv); break; // Tabelle contabili - case 6: cg0700(argc,argv); break; // Clienti/Fornitori occasionali - default: cg0100(argc,argv); break; // Piano dei conti + case 6: cg0700(argc, argv); break; // Clienti/Fornitori occasionali + case 7: cg0800(argc, argv); break; // Stampa progressivi IVA avanzata + default: cg0100(argc,argv); break; // Piano dei conti } return 0; } diff --git a/src/cg/cg0.h b/src/cg/cg0.h index 67ab82fe7..79ba4ce5d 100755 --- a/src/cg/cg0.h +++ b/src/cg/cg0.h @@ -8,6 +8,7 @@ int cg0400(int argc, char* argv[]); int cg0500(int argc, char* argv[]); int cg0600(int argc, char* argv[]); int cg0700(int argc, char* argv[]); +int cg0800(int argc, char* argv[]); #endif // __CG0_H diff --git a/src/cg/cg0800.cpp b/src/cg/cg0800.cpp new file mode 100644 index 000000000..7aebf1db4 --- /dev/null +++ b/src/cg/cg0800.cpp @@ -0,0 +1,107 @@ +#include +#include +#include +#include + +#include "cglib05.h" +#include "cg0800a.h" + +/////////////////////////////////////////////////////////// +// TRiepilogoIVA_mask +/////////////////////////////////////////////////////////// + +class TRiepilogoIVA_mask : public TAutomask +{ +protected: + virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly); + +public: + TRiepilogoIVA_mask() : TAutomask("cg0800a") { } +}; + +bool TRiepilogoIVA_mask::on_field_event(TOperable_field& o, TField_event e, long jolly) +{ + TRiepilogoIVA_mask & m = (TRiepilogoIVA_mask &) o.mask(); + + switch (o.dlg()) + { + case F_DAMESE: + if (e == fe_modify || e == fe_close) + { + if (atoi(o.get()) > m.get_int(F_AMESE)) + m.set(F_AMESE, o.get()); + } + break; + case F_AMESE: + if (e == fe_modify || e == fe_close) + { + if (atoi(o.get()) < m.get_int(F_DAMESE)) + o.set(m.get(F_DAMESE)); + } + break; + default: + break; + } + return true; +} + +/////////////////////////////////////////////////////////// +// TRiepilogoIVA_app +/////////////////////////////////////////////////////////// + +class TRiepilogoIVA_app : public TSkeleton_application +{ +protected: + virtual void main_loop(); +}; + +void TRiepilogoIVA_app::main_loop() +{ + TRiepilogoIVA_mask m; + + while (m.run() != K_QUIT) + { + TRiepilogoIVA_report rep; + TFilename repname = m.get(F_REPORT); + TRiepilogoIVA_recordset * recset = new TRiepilogoIVA_recordset; + + if (repname.blank()) + repname = "cg0800a"; + + rep.load(repname); + if (recset != NULL) + { + const int anno = m.get_int(F_ANNO); + int damese = m.get_int(F_DAMESE); + int amese = m.get_int(F_AMESE); + + if (damese == 13) + { + damese = 1; + amese = 12; + } + + const TDate da(1, damese, anno); + TDate a(1, amese, anno); + + a.set_end_month(); + recset->freeze(); + recset->set_from(da); + recset->set_to(a); + recset->set_var("#ANNO", m.get_long(F_ANNO), true); + recset->set_var("#DAMESE", m.get_long(F_DAMESE), true); + recset->set_var("#AMESE", m.get_long(F_AMESE), true); + recset->unfreeze(); + rep.set_recordset(recset); + + rep.print_or_preview(); + } + } +} + +int cg0800(int argc, char* argv[]) +{ + TRiepilogoIVA_app app; + app.run(argc, argv, TR("Stampa progressivi IVA avanzata")); + return 0; +} diff --git a/src/cg/cg0800a.rep b/src/cg/cg0800a.rep new file mode 100644 index 000000000..c4b1dcb78 --- /dev/null +++ b/src/cg/cg0800a.rep @@ -0,0 +1,144 @@ + + + Riepilogo progressivi IVA + +
+ + #SYSTEM.DATE + + + #SYSTEM.RAGSOC + + + #SYSTEM.RAGSOC + + + #PAGE + + + #PAGE + + + + + + + #ANNO + + + + + + + #DAMESE + +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • + + + + + + + + #AMESE + +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • + + + + + + + + + + + + + + + + + + + + + +
  • +
    +
    +
    + + COD + + + DESC + + + IMPVEN + #THIS @ +#F1.102 +! + + + IVAVEN + #THIS @ +#F1.103 +! + + + IMPCORR + #THIS @ +#F1.104 +! + + + IVACORR + #THIS @ +#F1.105 +! + + + IMPACQ + #THIS @ +#F1.106 +! + + + IVAACQ + #THIS @ +#F1.107 +! + +
    +
    +
    + + + DESC + + + + + + + +
    + USE 25 KEY 1 SELECT BETWEEN(23.DATAREG;#FROMDATE;#TODATE) \nJOIN 23 INTO NUMREG==NUMREG"; + \ No newline at end of file diff --git a/src/cg/cg0800a.uml b/src/cg/cg0800a.uml new file mode 100644 index 000000000..cf3252366 --- /dev/null +++ b/src/cg/cg0800a.uml @@ -0,0 +1,87 @@ +#include "cg0800a.h" + +TOOLBAR "topbar" 0 0 0 2 +BUTTON DLG_PRINT 2 2 +BEGIN + PROMPT 1 1 "Stampa" + PICTURE BMP_PRINT +END + +BUTTON DLG_SETPRINT 2 2 +BEGIN + PROMPT 1 1 "Imposta" + PICTURE BMP_SETPRINT +END + +BUTTON DLG_EDIT 2 2 +BEGIN + PROMPT 1 1 "~Edit" + PICTURE BMP_EDIT +END + +#include + +ENDPAGE + +PAGE "Stampa Riepilogo IVA" -1 -1 62 5 + +GROUPBOX DLG_NULL 74 3 +BEGIN + PROMPT 1 0 "" +END + +NUMBER F_CODDITTA 5 +BEGIN + PROMPT 2 1 "Ditta " + FLAGS "FRD" + USE LF_NDITTE KEY 1 + INPUT CODDITTA F_CODDITTA + OUTPUT F_RAGSOC RAGSOC + CHECKTYPE REQUIRED +END + +STRING F_RAGSOC 50 +BEGIN + PROMPT 15 1 "Ragione " + FLAGS "D" +END + +NUMBER F_ANNO 4 +BEGIN + PROMPT 2 3 "Anno " + FLAGS "AP" + CHECKTYPE REQUIRED +END + +LIST F_DAMESE 20 +BEGIN + PROMPT 2 5 "Da mese " + ITEM "13|13a liquid." + FLAGS "MP" + MESSAGE COPY,F_AMESE +END + +LIST F_AMESE 20 +BEGIN + PROMPT 2 7 " A mese " + ITEM "13|13a liquid." + FLAGS "MP" + WARINIG "Il mese di inizio non può essere successico al mese di fine" + VALIDATE F_DAMESE<=F_AMESE +END + +STRING F_REPORT 256 50 +BEGIN + PROMPT 2 -3 "Tipo di stampa " + RSELECT "cg0800a" + CHECKTYPE NORMAL +END + +STRING DLG_PROFILE 256 50 +BEGIN + PROMPT 2 -1 "Profilo " + PSELECT +END +ENDPAGE + +ENDMASK diff --git a/src/cg/cg3200.h b/src/cg/cg3200.h index bcc8b2640..ef2e02878 100755 --- a/src/cg/cg3200.h +++ b/src/cg/cg3200.h @@ -57,5 +57,6 @@ #define F_RAGSOC 505 #define F_SCELTE 506 #define F_DATASTAMPA 507 +#define F_DATA_LIQ 508 #endif // __CG3200_H diff --git a/src/cg/cg4.cpp b/src/cg/cg4.cpp index 5e7960f13..986d9b7e3 100755 --- a/src/cg/cg4.cpp +++ b/src/cg/cg4.cpp @@ -4,7 +4,7 @@ int main(int argc,char** argv) { - const int n = argc > 1 ? argv[1][1]-'0' : 0; + const int n = argc > 1 ? abs(atoi(argv[1])) : 0; switch (n) { case 1: cg4200(argc,argv); break; // Copia archivi @@ -13,10 +13,11 @@ int main(int argc,char** argv) case 4: cg4500(argc,argv); break; // Apertura nuovo esercizio case 5: cg4600(argc,argv); break; // Chiusura /Apertura case 6: cg4700(argc,argv); break; // Gestione acconti - //case 7: cg4800(argc,argv); break; // Creazione versamenti per acconto + case 7: cg4800(argc,argv); break; // Creazione versamenti per acconto case 8: cg4900(argc,argv); break; // Visualizzazione liquidazione acconti - case 9: cg4a00(argc,argv); break; // Gestione Autotrasportatori - default: cg4100(argc,argv); break; // Ricalcolo saldi + case 9: cg4a00(argc, argv); break; // Gestione Autotrasportatori + case 10: cg4b00(argc, argv); break; // Stampa progressivi IVA per competenza + default: cg4100(argc,argv); break; // Ricalcolo saldi } return 0; } diff --git a/src/cg/cg4.h b/src/cg/cg4.h index f277a3781..1686734db 100755 --- a/src/cg/cg4.h +++ b/src/cg/cg4.h @@ -11,6 +11,7 @@ int cg4700(int argc, char* argv[]); int cg4800(int argc, char* argv[]); int cg4900(int argc, char* argv[]); int cg4a00(int argc, char* argv[]); +int cg4b00(int argc, char* argv[]); #endif // __CG4_H diff --git a/src/cg/cg4300.cpp b/src/cg/cg4300.cpp index c0e493dac..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); } @@ -891,13 +905,21 @@ bool TLiquidazione_app::set_liquidazione() if (k == K_ENTER) { // handlers have set everything - _month = _what == trimestre ? m.get_int(CG43_LST_TRIM) : - m.get_int(CG43_LST_MESE); + _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 8e9b9c95e..896f345c9 100755 --- a/src/cg/cg4301.cpp +++ b/src/cg/cg4301.cpp @@ -1157,7 +1157,7 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt, TAssoc_array & #ifdef DBG long nr = _mov->get_long(MOV_NUMREG); - if (nr == 18489 || nr == 27710) + if (nr == 17146) int i = 1; #endif @@ -1184,6 +1184,7 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt, TAssoc_array & if (date.year() != year_int) // Controlla anno di appartenenza, altrimenti is_date_ok potrebbe non funzionare continue; } + const TRectype& rcs = _cur->curr(LF_CAUSALI); const TDate datareg = _mov->get_date(MOV_DATAREG); const TDate datadoc = _mov->get_date(MOV_DATADOC); @@ -1547,7 +1548,9 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt, TAssoc_array & const int tp = clifo.get_int(CLI_ALLEG); #ifdef DBG - if (nr == 25722 || nr == 27710) + long nr = _mov->get_long(MOV_NUMREG); + + if (nr >= 35363 && nr <= 35368) int i = 1; #endif @@ -2025,7 +2028,7 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt, TAssoc_array & real imponibile = is_detraibile == 0 ? impon_det : impon_ind; real imposta = is_detraibile == 0? impos_det : impos_ind; const TDate datareg = _mov->get_date(MOV_DATAREG); - const bool ok = (is_month_ok(month, datareg.month()) || month == 13) && (atoi(_year) == datareg.year()); + const bool ok = (is_month_ok(month, liqmonth == 0 ? datareg.month() : liqmonth) || month == 13) && (atoi(_year) == datareg.year()); if (civa.senza_imposta() && !ok) continue; 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 b07692b47..bdeb83383 100755 --- a/src/cg/cg4304.cpp +++ b/src/cg/cg4304.cpp @@ -1439,6 +1439,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); } @@ -1500,6 +1503,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/cg4400.cpp b/src/cg/cg4400.cpp index 70b6ed5b6..453a440ff 100755 --- a/src/cg/cg4400.cpp +++ b/src/cg/cg4400.cpp @@ -457,7 +457,14 @@ bool TStampa_registri_app::mask_mese (TMask_field& f, KEY k) 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 (mese == 20) + mese = 12; + if (mese == 12) + m.show(TIPO_RIEPILOGATIVO); + else m.hide(TIPO_RIEPILOGATIVO); + } if (id == MESE) { if (mese == 12) @@ -470,13 +477,10 @@ bool TStampa_registri_app::mask_mese (TMask_field& f, KEY k) m.hide (TIPO_RIEPILOGATIVO); m.hide (RIF_VID); } + mese = m.get_int(FINO_A_MESE); //Per stampa su bollato + if (mese == 20) + mese = 12; } - 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()) { @@ -601,6 +605,11 @@ bool TStampa_registri_app::mask_libun (TMask_field& f, KEY k) const TString& cod = f.mask().get(CODICE_LIBRO_IVA); int fino_a_mese = f.mask().get_int(MESE); + + if (fino_a_mese == 12) + f.mask().show(TIPO_RIEPILOGATIVO); + else f.mask().hide(TIPO_RIEPILOGATIVO); + int anno = f.mask().get_int(ANNO); bool ok = false; int last_mese = 13; @@ -1633,8 +1642,10 @@ void TStampa_registri_app::set_page_tot_reg() } // for } if (printed) + { flush(); fine_mese(); + } if (_stampa_plafonds) stampa_plafonds(rr); } @@ -2116,7 +2127,7 @@ bool TStampa_registri_app::print_IVAxCassa(int da_month, int a_month) return false; // Ho stampato qualcosa? } - int flags = 0x0; + int flags = 0x06; FOR_EACH_ARRAY_ITEM(_riga_prospettoXcassa, r, obj) { const TRiga& ri = *(const TRiga*)obj; @@ -3753,9 +3764,14 @@ bool TStampa_registri_app::set_print(int n) } else //stampe definitive { + _fino_a_mese = m.get_int(FINO_A_MESE); + _stampa_acconto = (_fino_a_mese == 20); + + if (_stampa_acconto) + _fino_a_mese = 12; if (_tipo_stampa == bollato || _tipo_stampa == rif_giornale) { - _fino_a_mese = m.get_int(FINO_A_MESE); + _data_da = TDate(1, 1, _annoIVA); // Meglio cosi' } else //stampa su libro unico @@ -3771,6 +3787,12 @@ bool TStampa_registri_app::set_print(int n) int giorni_del_mese = 31; if (_fino_a_mese == 12) { + TInteressi_IVA_table i; i.read(_annoIVA, _fino_a_mese); + + giorni_del_mese = i.get_int("I0"); + if (giorni_del_mese == 0) + giorni_del_mese = 20; + if (!_stampa_acconto) giorni_del_mese = 31; _tipo_riepilogativo = m.get(TIPO_RIEPILOGATIVO)[0]; } diff --git a/src/cg/cg4400.h b/src/cg/cg4400.h index 7af7659c2..032e045fb 100755 --- a/src/cg/cg4400.h +++ b/src/cg/cg4400.h @@ -57,6 +57,7 @@ class TStampa_registri_app : public TPrintapp long _u_stampata, _primast, __firm, _uprotivap, _ditta; long _numini, _pagine_stampate; int _fino_a_mese, _cod_un_loc; + bool _stampa_acconto; int _annoIVA, _r, _stampa_width, _mese_ultima_liq, _mese_credito; int _stampa_len, _stampa_mese, _size_header; real _totale_doc, _credito; @@ -120,7 +121,7 @@ public: bool ricalcola(int); bool stampa_riepilogo(int); void stampa_prospetto_riepilogo(tiporeg, const TString&, const TString&, const bool); - void stampa_progressivi(TRiga_array&, TRigaiva_array&, tiporeg, const bool); + void stampa_progressivi(TRiga_array&, TRigaiva_array&, tiporeg, const int); void set_choice_limits(TMask&); void build_ditte_sheet(int flags); tiporeg cerca_reg(const TString&); 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/cg4800.cpp b/src/cg/cg4800.cpp index 311378ddc..fe4b74238 100755 --- a/src/cg/cg4800.cpp +++ b/src/cg/cg4800.cpp @@ -104,10 +104,8 @@ bool VersAcc_app::create() TDate oggi(TODAY); _year = oggi.year(); - begin_wait(); build_nomiditte(); build_ditte_sheet(); - end_wait(); dispatch_e_menu(BAR_ITEM_ID(1)); diff --git a/src/cg/cg4b00.cpp b/src/cg/cg4b00.cpp new file mode 100644 index 000000000..d8ee42f44 --- /dev/null +++ b/src/cg/cg4b00.cpp @@ -0,0 +1,157 @@ +#include +#include +#include +#include + +#include "cglib05.h" +#include "cg4b00a.h" + +/////////////////////////////////////////////////////////// +// TRiepilogoIVA_mask +/////////////////////////////////////////////////////////// + +class TRiepilogoIVA_mask : public TAutomask +{ +protected: + virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly); + +public: + TRiepilogoIVA_mask() : TAutomask("cg4b00a") { } +}; + +bool TRiepilogoIVA_mask::on_field_event(TOperable_field& o, TField_event e, long jolly) +{ + TRiepilogoIVA_mask & m = (TRiepilogoIVA_mask &)o.mask(); + + switch (o.dlg()) + { + case F_DADATA: + if (e == fe_modify || e == fe_close) + { + if (TDate(o.get()) > m.get_date(F_ADATA)) + m.set(F_ADATA, o.get()); + } + break; + case F_ADATA: + if (e == fe_modify || e == fe_close) + { + if (TDate(o.get()) < m.get_date(F_DADATA)) + o.set(m.get(F_DADATA)); + } + case F_DASOTTOC: + if (e == fe_modify || e == fe_close) + { + TString da; da.format("%03d%03d%06ld", m.get_int(F_DAGRUPPO), m.get_int(F_DACONTO), m.get_long(F_DASOTTOC)); + TString a; a.format("%03d%03d%06ld", m.get_int(F_AGRUPPO), m.get_int(F_ACONTO), m.get_long(F_ASOTTOC)); + + if (da > a) + { + m.set(F_AGRUPPO, da.left(3)); + m.set(F_ACONTO, da.mid(3, 3)); + m.set(F_ASOTTOC, da.right(6), 0x3); + } + } + break; + case F_ASOTTOC: + if (e == fe_modify || e == fe_close) + { + TString da; da.format("%03d%03d%06ld", m.get_int(F_DAGRUPPO), m.get_int(F_DACONTO), m.get_long(F_DASOTTOC)); + TString a; a.format("%03d%03d%06ld", m.get_int(F_AGRUPPO), m.get_int(F_ACONTO), m.get_long(F_ASOTTOC)); + + if (da > a) + { + m.set(F_AGRUPPO, da.left(3)); + m.set(F_ACONTO, da.mid(3, 3)); + m.set(F_ASOTTOC, da.right(6), 0x3); + } + } + + default: + break; + } + return true; +} + +/////////////////////////////////////////////////////////// +// TRiepilogoIVAcompetenza_recordset +/////////////////////////////////////////////////////////// + +class TRiepilogoIVAcompetenza_recordset : public TRiepilogoIVA_recordset +{ + bool _senzacompetenza; + bool _competenzadiversa; + bool _registrazioneritardo; + +public: + virtual bool set_senzacompetenzaIVA(bool on) { _senzacompetenza = on; return on; } + virtual bool set_competenzadiversaIVA(bool on) { _competenzadiversa = on; return on; } + virtual bool set_registrazioneIVAritardo(bool on) { return _registrazioneritardo = on; return on; } + virtual bool senzacompetenzaIVA() { return _senzacompetenza; } + virtual bool competenzadiversaIVA() { return _competenzadiversa; } + virtual bool registrazioneIVAritardo() { return _registrazioneritardo; } + + TRiepilogoIVAcompetenza_recordset() {} + virtual ~TRiepilogoIVAcompetenza_recordset() { } +}; + +/////////////////////////////////////////////////////////// +// TRiepilogoIVA_app +/////////////////////////////////////////////////////////// + +class TRiepilogoIVA_app : public TSkeleton_application +{ +protected: + virtual void main_loop(); +}; + +void TRiepilogoIVA_app::main_loop() +{ + TRiepilogoIVA_mask m; + + while (m.run() != K_QUIT) + { + TRiepilogoIVA_report rep; + TFilename repname = m.get(F_REPORT); + TRiepilogoIVAcompetenza_recordset *recset = new TRiepilogoIVAcompetenza_recordset; + + if (repname.blank()) + repname = "cg4b00a"; + rep.load(repname); + if (recset != NULL) + { + recset->freeze(); + recset->set_senzacompetenzaIVA(m.get_bool(F_NOCOMP)); + recset->set_competenzadiversaIVA(m.get_bool(F_COMPDIV)); + 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_from_conto(m.get_long(F_DAGRUPPO), m.get_long(F_DACONTO), m.get_long(F_DASOTTOC)); + if (m.get_long(F_DAGRUPPO) != 0) + recset->set_to_conto(m.get_long(F_AGRUPPO), m.get_long(F_ACONTO), m.get_long(F_ASOTTOC)); + recset->set_var("#NOCOMP", m.get_bool(F_NOCOMP), true); + recset->set_var("#COMPDIV", m.get_bool(F_COMPDIV), true); + recset->set_var("#REGRIT", m.get_bool(F_REGRIT), true); + recset->set_var("#TODATE", m.get_date(F_ADATA), true); + recset->set_var("#FROMDATE", m.get_date(F_DADATA), true); + recset->set_var("#TODATE", m.get_date(F_ADATA), true); + recset->set_var("#DAGRUPPO", m.get_long(F_DAGRUPPO), true); + recset->set_var("#DACONTO", m.get_long(F_DACONTO), true); + recset->set_var("#DASOTTOCONTO", m.get_long(F_DASOTTOC), true); + recset->set_var("#AGRUPPO", m.get_long(F_AGRUPPO), true); + recset->set_var("#ACONTO", m.get_long(F_ACONTO), true); + recset->set_var("#ASOTTOCONTO", m.get_long(F_ASOTTOC), true); + recset->unfreeze(); + rep.set_recordset(recset); + + rep.print_or_preview(); + } + } +} + +int cg4b00(int argc, char* argv[]) +{ + TRiepilogoIVA_app app; + app.run(argc, argv, TR("Stampa progressivi IVA per competenza")); + return 0; +} diff --git a/src/cg/cg4b00a.h b/src/cg/cg4b00a.h new file mode 100644 index 000000000..192a7a71b --- /dev/null +++ b/src/cg/cg4b00a.h @@ -0,0 +1,19 @@ +#define F_CODDITTA 101 +#define F_RAGSOC 102 +#define F_DADATA 103 +#define F_ADATA 104 +#define F_DAGRUPPO 105 +#define F_DACONTO 106 +#define F_DASOTTOC 107 +#define F_AGRUPPO 108 +#define F_ACONTO 109 +#define F_ASOTTOC 110 +#define F_DADESCR 111 +#define F_ADESCR 112 +#define F_NOCOMP 113 +#define F_COMPDIV 114 +#define F_REGRIT 115 + +#define F_REPORT 200 +#define F_PROFILO 201 + diff --git a/src/cg/cg4b00a.rep b/src/cg/cg4b00a.rep new file mode 100644 index 000000000..38d79b0be --- /dev/null +++ b/src/cg/cg4b00a.rep @@ -0,0 +1,151 @@ + + + Riepilogo progressivi IVA per competenza + +
    + + #SYSTEM.DATE + + + #SYSTEM.RAGSOC + + + #SYSTEM.RAGSOC + + + #PAGE + + + #PAGE + + + + + + + #FROMDATE + + + + + + + #TODATE + + + + + + + #COMPIVA + +
  • +
  • +
  • + + + + + + + + #DAGRUPPO + + + + #DACONTO + + + + #DASOTTOCONTO + + + + + + + #AGRUPPO + + + + #ACONTO + + + + #ASOTTOCONTO + + + + + + + + + + + + + + + + + + + + +
  • +
    +
    +
    + + COD + + + DESC + + + IMPVEN + #THIS @ +#F1.102 +! + + + IVAVEN + #THIS @ +#F1.103 +! + + + IMPCORR + #THIS @ +#F1.104 +! + + + IVACORR + #THIS @ +#F1.105 +! + + + IMPACQ + #THIS @ +#F1.106 +! + + + IVAACQ + #THIS @ +#F1.107 +! + +
    +
    +
    + + + DESC + + + + + + + +
    + USE 25 KEY 1 SELECT BETWEEN(23.DATAREG;#FROMDATE;#TODATE) \nJOIN 23 INTO NUMREG==NUMREG"; + \ No newline at end of file diff --git a/src/cg/cg4b00a.uml b/src/cg/cg4b00a.uml new file mode 100644 index 000000000..e267cdf68 --- /dev/null +++ b/src/cg/cg4b00a.uml @@ -0,0 +1,209 @@ +#include "cg4b00a.h" + +TOOLBAR "topbar" 0 0 0 2 +BUTTON DLG_PRINT 2 2 +BEGIN + PROMPT 1 1 "Stampa" + PICTURE BMP_PRINT +END + +BUTTON DLG_SETPRINT 2 2 +BEGIN + PROMPT 1 1 "Imposta" + PICTURE BMP_SETPRINT +END + +BUTTON DLG_EDIT 2 2 +BEGIN + PROMPT 1 1 "~Edit" + PICTURE BMP_EDIT +END + +#include + +ENDPAGE + +PAGE "Stampa" -1 -1 62 5 + +GROUPBOX DLG_NULL 74 3 +BEGIN + PROMPT 1 0 "" +END + +NUMBER F_CODDITTA 5 +BEGIN + PROMPT 2 1 "Ditta " + FLAGS "FRD" + USE LF_NDITTE KEY 1 + INPUT CODDITTA F_CODDITTA + OUTPUT F_RAGSOC RAGSOC + CHECKTYPE REQUIRED +END + +STRING F_RAGSOC 50 +BEGIN + PROMPT 15 1 "Ragione " + FLAGS "D" +END + +DATE F_DADATA +BEGIN + PROMPT 2 3 "Da: data " +END + +DATE F_ADATA +BEGIN + PROMPT 2 5 " A: data " + WARINIG "La data di inizio non può essere successico alla data di fine" + VALIDATE DATE_CMP_FUNC >= F_>ADATA +END + +NUMBER F_DAGRUPPO 3 +BEGIN + PROMPT 2 7 "Da: Gruppo " + USE LF_PCON KEY 1 SELECT (CONTO="") + INPUT GRUPPO F_DAGRUPPO + DISPLAY "Gruppo" GRUPPO + DISPLAY "Descrizione@50" DESCR + OUTPUT F_DAGRUPPO GRUPPO + CHECKTYPE NORMAL +END + +NUMBER F_DACONTO 3 +BEGIN + PROMPT 23 7 "Conto " + USE LF_PCON KEY 1 SELECT (SOTTOCONTO="") + INPUT GRUPPO F_DAGRUPPO + INPUT CONTO F_DACONTO + DISPLAY "Gruppo" GRUPPO + DISPLAY "Conto" CONTO + DISPLAY "Descrizione@50" DESCR + OUTPUT F_DACONTO CONTO + OUTPUT F_DAGRUPPO GRUPPO + CHECKTYPE NORMAL +END + +NUMBER F_DASOTTOC 6 +BEGIN + PROMPT 36 7 "Sottoconto " + USE LF_PCON + INPUT GRUPPO F_DAGRUPPO + INPUT CONTO F_DACONTO + INPUT SOTTOCONTO F_DASOTTOC + DISPLAY "Gruppo" GRUPPO + DISPLAY "Conto" CONTO + DISPLAY "Sottoconto" SOTTOCONTO + DISPLAY "Descrizione@50" DESCR + OUTPUT F_DASOTTOC SOTTOCONTO + OUTPUT F_DAGRUPPO GRUPPO + OUTPUT F_DACONTO CONTO + OUTPUT F_DADESCR DESCR + CHECKTYPE NORMAL +END + +STRING F_DADESCR 50 +BEGIN + PROMPT 14 9 "" + USE LF_PCON KEY 2 + INPUT DESCR F_DADESCR + DISPLAY "Descrizione@50" DESCR + DISPLAY "Gruppo" GRUPPO + DISPLAY "Conto" CONTO + DISPLAY "Sottoconto" SOTTOCONTO + OUTPUT F_DASOTTOC SOTTOCONTO + OUTPUT F_DACONTO CONTO + OUTPUT F_DAGRUPPO GRUPPO + OUTPUT F_DADESCR DESCR + CHECKTYPE NORMAL +END + +NUMBER F_AGRUPPO 3 +BEGIN + PROMPT 2 11 " A: Gruppo " + USE LF_PCON KEY 1 SELECT (CONTO="") + INPUT GRUPPO F_AGRUPPO + DISPLAY "Gruppo" GRUPPO + DISPLAY "Descrizione@50" DESCR + OUTPUT F_AGRUPPO GRUPPO + CHECKTYPE NORMAL +END + +NUMBER F_ACONTO 3 +BEGIN + PROMPT 23 11 "Conto " + USE LF_PCON KEY 1 SELECT (SOTTOCONTO="") + INPUT GRUPPO F_AGRUPPO + INPUT CONTO F_ACONTO + DISPLAY "Gruppo" GRUPPO + DISPLAY "Conto" CONTO + DISPLAY "Descrizione@50" DESCR + OUTPUT F_ACONTO CONTO + OUTPUT F_AGRUPPO GRUPPO + CHECKTYPE NORMAL +END + +NUMBER F_ASOTTOC 6 +BEGIN + PROMPT 36 11 "Sottoconto " + USE LF_PCON + INPUT GRUPPO F_AGRUPPO + INPUT CONTO F_ACONTO + INPUT SOTTOCONTO F_ASOTTOC + DISPLAY "Gruppo" GRUPPO + DISPLAY "Conto" CONTO + DISPLAY "Sottoconto" SOTTOCONTO + DISPLAY "Descrizione@50" DESCR + OUTPUT F_ASOTTOC SOTTOCONTO + OUTPUT F_AGRUPPO GRUPPO + OUTPUT F_ACONTO CONTO + OUTPUT F_ADESCR DESCR + CHECKTYPE NORMAL +END + +STRING F_ADESCR 50 +BEGIN + PROMPT 14 13 "" + USE LF_PCON KEY 2 + INPUT DESCR F_ADESCR + DISPLAY "Descrizione@50" DESCR + DISPLAY "Gruppo" GRUPPO + DISPLAY "Conto" CONTO + DISPLAY "Sottoconto" SOTTOCONTO + OUTPUT F_ASOTTOC SOTTOCONTO + OUTPUT F_ACONTO CONTO + OUTPUT F_AGRUPPO GRUPPO + OUTPUT F_ADESCR DESCR + CHECKTYPE NORMAL +END + +BOOLEAN F_NOCOMP +BEGIN + PROMPT 2 15 "Movimenti senza competenza diversa" +END + +BOOLEAN F_COMPDIV +BEGIN + PROMPT 2 17 "Movimenti con competenza nel periodo" +END + +BOOLEAN F_REGRIT +BEGIN + PROMPT 2 19 "Movimenti registrati in ritardo" +END + +STRING F_REPORT 256 50 +BEGIN + PROMPT 2 -3 "Tipo di stampa " + RSELECT "cg4b00a" + CHECKTYPE NORMAL +END + +STRING DLG_PROFILE 256 50 +BEGIN + PROMPT 2 -1 "Profilo " + PSELECT +END + +ENDPAGE + +ENDMASK diff --git a/src/cg/cglib01.h b/src/cg/cglib01.h index 5249fed3f..db16308fe 100755 --- a/src/cg/cglib01.h +++ b/src/cg/cglib01.h @@ -168,6 +168,8 @@ public: // TObject bool reverse_charge() const; int regime_speciale() const { return get_int("I5");} + const TString& natura() const { return get("S12"); } + TCodiceIVA(const char* codice = NULL); TCodiceIVA(const TRectype & rec) : TRectype(rec) {} TCodiceIVA(const TCodiceIVA & iva) : TRectype(iva) {} diff --git a/src/cg/cglib03.cpp b/src/cg/cglib03.cpp index c11cd7fa6..1b66bfc17 100755 --- a/src/cg/cglib03.cpp +++ b/src/cg/cglib03.cpp @@ -280,6 +280,16 @@ TInteressi_IVA_table::~TInteressi_IVA_table() { } +int TInteressi_IVA_table::giorno_acc() const +{ + int d = get_int("I0"); + + if (d == 0) + d = 20; + return d; +} + + int TInteressi_IVA_table::read(int anno, int mese) { TString8 k; k.format("%04d%02d",anno,mese); diff --git a/src/cg/cglib03.h b/src/cg/cglib03.h index cd00b88ca..1104c9b35 100755 --- a/src/cg/cglib03.h +++ b/src/cg/cglib03.h @@ -33,6 +33,7 @@ public: int read(int anno, int mese); //int status() { return _ver->status();} real get(int what); + int giorno_acc() const; TInteressi_IVA_table(); virtual ~TInteressi_IVA_table(); }; diff --git a/src/cg/cglib05.cpp b/src/cg/cglib05.cpp new file mode 100644 index 000000000..8e249deab --- /dev/null +++ b/src/cg/cglib05.cpp @@ -0,0 +1,291 @@ +#include "cglib05.h" +/////////////////////////////////////////////////////////// +// TRiepilogoIVA_recordset +/////////////////////////////////////////////////////////// + +class TRiepilogoIVA_record : public TObject +{ + TString4 _cod; + TArray _values; + + real & get_val(int index); + TRiepilogoIVA_record & copy(const TRiepilogoIVA_record & r); + +public: + virtual TObject* dup() const { return new TRiepilogoIVA_record(*this); } + const TString & cod() const { return _cod; } + real & impacq() { return get_val(0); } + real & ivaacq() { return get_val(1); } + real & impcorr() { return get_val(2); } + real & ivacorr() { return get_val(3); } + real & impven() { return get_val(4); } + real & ivaven() { return get_val(5); } + TRiepilogoIVA_record& operator= (const TRiepilogoIVA_record & rec) { return copy(rec);} + + TRiepilogoIVA_record(const TRiepilogoIVA_record & rec) { copy(rec); } + + TRiepilogoIVA_record(const char * cod) : _cod(cod) {} +}; + +TRiepilogoIVA_record & TRiepilogoIVA_record::copy(const TRiepilogoIVA_record & r) +{ + _cod = r._cod; + _values = r._values; + return *this; +} + +real & TRiepilogoIVA_record::get_val(int index) +{ + real * val = (real *)_values.objptr(index); + if (val == NULL) + _values.add(val = new real, index); + return *val; +} + +void TRiepilogoIVA_recordset::requery() +{ + if (_freezed) + return; + TString wrk = query_text(); + TString query; + 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 meseliq_fieldname; meseliq_fieldname << LF_MOV << "." << MOV_MESELIQ; + + int p = wrk.find("FROMDATE"); + + if (p > 0) + query << wrk.left(p) << _from_date.string(); + wrk.ltrim(p + 8); + p = wrk.find("TODATE"); + + if (p > 0) + { + query << wrk.left(p); + if (senzacompetenzaIVA() && !competenzadiversaIVA() && !registrazioneIVAritardo()) + query << _to_date.string(); + else + { + TDate to(_to_date); + + to.set_day(31); + to.set_month(12); + if (_to_date.month() == 12) + to.addyear(1); + query << to.string(); + } + query << wrk.mid(p + 6); + } + + TISAM_recordset recset(query); + + for (bool ok = recset.move_first(); ok; ok = recset.move_next()) + { + TString cod = recset.get(RMI_CODIVA).as_string(); + TRiepilogoIVA_record * rec = (TRiepilogoIVA_record *)work_array.objptr(cod); + long gruppo = recset.get(RMI_GRUPPO).as_int(); + long conto = recset.get(RMI_CONTO).as_int(); + long sottoconto = recset.get(RMI_SOTTOCONTO).as_int(); + + if (((gruppo >= _from_gruppo) && (gruppo <= _to_gruppo)) && + ((conto >= _from_conto) && (conto <= _to_conto)) && + ((sottoconto >= _from_sottoconto) && (conto <= _to_sottoconto))) + { + TRegistro codreg(recset.get(reg_fieldname).as_string()); + + TipoIVA t = codreg.iva(); + + // filtro competenza + TDate data = recset.get(datareg_fieldname).as_date(); + + if (competenzadiversaIVA()) + { + const int meseliq = recset.get(meseliq_fieldname).as_int(); + + if (meseliq != 0) + { + data.set_month(meseliq); + data.set_end_month(); + if (data < _from_date || data > _to_date) + continue; + } + } + if (registrazioneIVAritardo()) + { + TDate datacomp = recset.get(datacomp_fieldname).as_date(); + } + if (senzacompetenzaIVA() && (data < _from_date || data > _to_date)) + continue; + + if (rec == NULL) + work_array.add(cod, rec = new TRiepilogoIVA_record(cod)); + if (t == iva_acquisti) + { + real & r = rec->impacq(); + r += recset.get(RMI_IMPONIBILE).as_real(); + real & r1 = rec->ivaacq(); + r1 += recset.get(RMI_IMPOSTA).as_real(); + } + else + if (t == iva_vendite) + { + if (codreg.corrispettivi()) + { + real & r = rec->impcorr(); + r += recset.get(RMI_IMPONIBILE).as_real(); + real & r1 = rec->ivacorr(); + r1 += recset.get(RMI_IMPOSTA).as_real(); + } + else + { + real & r = rec->impven(); + r += recset.get(RMI_IMPONIBILE).as_real(); + real & r1 = rec->ivaven(); + r1 += recset.get(RMI_IMPOSTA).as_real(); + } + } + } + } + + TString_array keys; + + work_array.get_keys(keys); + _rows.destroy(); + FOR_EACH_ARRAY_ITEM(keys, i, obj) + { + TString & key = (TString &) *obj; + TRiepilogoIVA_record & row = (TRiepilogoIVA_record &) work_array.find(key); + + _rows.add(row); + } +} + +bool TRiepilogoIVA_recordset::move_to(TRecnotype pos) +{ + bool ok = (pos >= 0) && (pos < items()); + + if (_pos < 0) + pos = 0; + else + if (_pos >= items()) + _pos = items() - 1; + else + _pos = pos; + return ok; +} +const TString& TRiepilogoIVA_recordset::query_text() const +{ + TString & query = get_tmp_string(); + + query << "USE " << LF_RMOVIVA << " KEY 1 SELECT BETWEEN(" << LF_MOV << "." << MOV_DATAREG << ";" << '"' << "FROMDATE" << '"' << ";" << '"' << "TODATE" << '"' << ") \nJOIN " << LF_MOV << " INTO NUMREG==NUMREG"; +// query << "USE " << LF_RMOVIVA << " KEY 1 SELECT BETWEEN(" << LF_MOV << "." << MOV_DATAREG << ";FROMDATE;TODATE) \nJOIN " << LF_MOV << " INTO NUMREG==NUMREG"; + return query; +} + +const TVariant& TRiepilogoIVA_recordset::get_field(int num, const char* field) const +{ + if (*field != '#') + { + TVariant & val = get_tmp_var(); + TRiepilogoIVA_record & row = (TRiepilogoIVA_record &) _rows[_pos]; + + if (xvt_str_compare_ignoring_case(field, IVAVEN) == 0) + int i = 1; + if (xvt_str_compare_ignoring_case(field, COD) == 0) + { + val = row.cod(); + return val; + } + else + if (xvt_str_compare_ignoring_case(field, DESC) == 0) + { + TCodiceIVA c(row.cod()); + + val = c.descrizione(); + return val; + } + else + if (xvt_str_compare_ignoring_case(field, IMPACQ) == 0) + { + val = row.impacq(); + return val; + } + else + if (xvt_str_compare_ignoring_case(field, IVAACQ) == 0) + { + val = row.ivaacq(); + return val; + } + else + if (xvt_str_compare_ignoring_case(field, IMPCORR) == 0) + { + val = row.impcorr(); + return val; + } + else + if (xvt_str_compare_ignoring_case(field, IVACORR) == 0) + { + val = row.ivacorr(); + return val; + } + else + if (xvt_str_compare_ignoring_case(field, IMPVEN) == 0) + { + val = row.impven(); + return val; + } + else + if (xvt_str_compare_ignoring_case(field, IVAVEN) == 0) + { + val = row.ivaven(); + return val; + } + } + return NULL_VARIANT; +} + +void TRiepilogoIVA_recordset::add_field(TFieldtypes tipo, short id, int width, const char* name) +{ + TRecordset_column_info* i = new TRecordset_column_info; + + TString& n = i->_name; + + if (name && *name) + n = name; + i->_type = tipo; + i->_pos = id; + i->_width = width; + + _info.add(i); +} + +const TVariant& TRiepilogoIVA_recordset::get(unsigned int column) const +{ + TVariant & v = get_tmp_var(); + if (_pos >= 0 && _pos < items() && column >= 0 && column < columns()) + { + const TRecordset_column_info& info = column_info(column); + + v = get_field(0, info._name); + } + + return v; +} + +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) +{ + add_field(_alfafld, 101, 4, COD); + add_field(_alfafld, 102, 50, DESC); + add_field(_realfld, 103, 18, IMPACQ); + add_field(_realfld, 104, 18, IVAACQ); + add_field(_realfld, 105, 18, IMPCORR); + add_field(_realfld, 106, 18, IVACORR); + add_field(_realfld, 107, 18, IMPVEN); + add_field(_realfld, 108, 18, IVAVEN); +} + diff --git a/src/cg/cglib05.h b/src/cg/cglib05.h new file mode 100644 index 000000000..6db91dcc9 --- /dev/null +++ b/src/cg/cglib05.h @@ -0,0 +1,83 @@ +#include + +#include "cglib01.h" +#include "mov.h" +#include "rmoviva.h" +#include "../ba/ba8500.h" + +/////////////////////////////////////////////////////////// +// TRiepilogoIVA_recordset +/////////////////////////////////////////////////////////// + +#define COD "COD" +#define DESC "DESC" +#define IMPACQ "IMPACQ" +#define IVAACQ "IVAACQ" +#define IMPCORR "IMPCORR" +#define IVACORR "IVACORR" +#define IMPVEN "IMPVEN" +#define IVAVEN "IVAVEN" + +class TRiepilogoIVA_recordset : public TRecordset +{ + TArray _rows; + long _pos; + TDate _from_date; + TDate _to_date; + long _from_gruppo; + long _from_conto; + long _from_sottoconto; + long _to_gruppo; + long _to_conto; + long _to_sottoconto; + TArray _info; + bool _freezed; + +protected: + virtual const TVariant& get_field(int num, const char* field) const; + void TRiepilogoIVA_recordset::add_field(TFieldtypes tipo, short id, int width, const char* name); + +public: + virtual TRecnotype items() const { return _rows.items(); } + virtual bool move_to(TRecnotype pos); + virtual TRecnotype current_row() const { return _pos; } + virtual void requery(); + virtual const TString& query_text() const; + virtual unsigned int columns() const { return _info.items(); } + virtual const TRecordset_column_info& column_info(unsigned int column) const { return (const TRecordset_column_info&)_info[column]; } + void freeze(bool on = true) { _freezed = on; } + void unfreeze() { freeze(false); } + // const TString& col2name(unsigned int column) const; + virtual const TVariant& get(unsigned int column) const; + + + TDate set_from(const TDate& from) { return _from_date = from; } + TDate set_to(const TDate& to) { return _to_date = to; } + void set_from_conto(int gruppo, int conto, long sottoconto) { _from_gruppo = gruppo; _from_conto = conto; _from_sottoconto = sottoconto; } + void set_to_conto(int gruppo, int conto, long sottoconto) { _to_gruppo = gruppo; _to_conto = conto; _to_sottoconto = sottoconto; } + + 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; } + + TRiepilogoIVA_recordset(); + virtual ~TRiepilogoIVA_recordset() { } +}; + +/////////////////////////////////////////////////////////// +// TRiepilogoIVA_report +/////////////////////////////////////////////////////////// + +class TRiepilogoIVA_report : public TReport +{ + +protected: + virtual bool use_mask() { return false; } + +public: + virtual bool set_recordset(TRecordset * set) { return TReport::set_recordset(set); } + +}; diff --git a/src/cg/cgmenu.men b/src/cg/cgmenu.men index 1b909ab12..1b809cf91 100755 --- a/src/cg/cgmenu.men +++ b/src/cg/cgmenu.men @@ -114,6 +114,8 @@ Item_09 = "Gestione F24", Item_10 = "Operazioni annuali", [CGMENU_029] Item_11 = "IVA per cassa / differita", Item_12 = "Gestione autotrasportatori", "cg4 -9", "F" +Item_13 = "Stampa progressivi avanzata", "cg0 -7", "F" +Item_13 = "Stampa progressivi IVA per competenza", "cg4 -10", "F" [CGMENU_011] Caption = "Tabelle ministeriali" diff --git a/src/fp/fp0300.cpp b/src/fp/fp0300.cpp index 90e6a6856..7cb9b0b89 100644 --- a/src/fp/fp0300.cpp +++ b/src/fp/fp0300.cpp @@ -39,7 +39,6 @@ protected: void set_err_paf(); void fill(); void init(); - bool is_fattura(const TRectype& doc) const; void load_all_fields(); @@ -56,16 +55,6 @@ public: void save_all_fields() const; }; -bool TPA_mask::is_fattura(const TRectype& doc) const -{ - const TTipo_documento& td = cached_tipodoc(doc.get(DOC_TIPODOC)); - if (!td.is_fattura()) // Tengo per buone solo le fatture e le note di credito - return false; - - const TCodice_numerazione& cn = cached_numerazione(doc.get(DOC_CODNUM)); - return cn.tipo() == 2 && !cn.get_bool("B10"); // Controlla se fattura provvisioria esclusa da P.A. -} - void TPA_mask::save_all_fields() const { ini_set_string(CONFIG_DITTA, "fp", "dataini", get(F_DATAINI)); @@ -132,27 +121,6 @@ void TPA_mask::load_all_fields() set(F_VALCODEST, fp_settings().get_esp_est_cod()); } -TString& add_filter(const TString& field, const TString& from, const TString& to) -{ - TString& query = get_tmp_string(); - const TString qf = field.find('.') < 0 ? field : field.sub(field.find('.') + 1); - - if (from.full() && to.full()) - { - query << "&&(BETWEEN(" << field << ", #DA" << qf << ", #A" << qf << "))"; - } - else if (from.full()) - { - query << "&&(" << field << ">=#DA" << qf << ")"; - } - else if (to.full()) - { - query << "&&(" << field << "<=#A" << qf << ")"; - } - - return query; -} - void TPA_mask::fill() { // Salvo subito su file le impostazioni di esportazione, in fplib accedo ai file diff --git a/src/fp/fplib.h b/src/fp/fplib.h index 581519ece..9ff0a711b 100644 --- a/src/fp/fplib.h +++ b/src/fp/fplib.h @@ -15,10 +15,6 @@ #define SQL_FLD "sql/" -#ifndef CARATTERI_SPECIALI -#define CARATTERI_SPECIALI "àèéìòù°" -#endif - // Ritorna la connessione al DB paf secondo i parametri impostati nel programma di configurazione SSimple_query& fp_db(); // Controlla il livello di patch installato e aggiorna le tabelle se necessario diff --git a/src/fp/fplib01.cpp b/src/fp/fplib01.cpp index e9c92e9fa..0203cd52d 100644 --- a/src/fp/fplib01.cpp +++ b/src/fp/fplib01.cpp @@ -198,24 +198,7 @@ inline const TString& no_special(char a) TString& r = get_tmp_string().cut(0); switch(a) { - case 'à': - r << "a''"; - break; - case 'è': - case 'é': - r << "e''"; - break; - case 'ì': - r << "i''"; - break; - case 'ò': - r << "o''"; - break; - case 'ù': - r << "u''"; - break; case '\'': - r << "''"; break; default: r << a; diff --git a/src/include/tsdb.cpp b/src/include/tsdb.cpp index 806994eee..2e2bab015 100644 --- a/src/include/tsdb.cpp +++ b/src/include/tsdb.cpp @@ -10,4 +10,23 @@ const TDate SSimple_query::sq_get_date(const char * field) { const TDate app(_rec.get_date(field)); return app; -} \ No newline at end of file +} + +TString SSimple_query::sq_get(const char* field, bool rtrim) +{ + TString fld = _rec.get(field); + if (rtrim) + fld.rtrim(); + + return fld; +} + +TString SSimple_query::sq_get(string field, bool rtrim) +{ + return sq_get(field.c_str(), rtrim); +} + +TString SSimple_query::sq_get(TString& field, bool rtrim) +{ + return sq_get(static_cast(field), rtrim); +} diff --git a/src/include/tsdb.h b/src/include/tsdb.h index 6d1d8eba4..1586f8242 100644 --- a/src/include/tsdb.h +++ b/src/include/tsdb.h @@ -166,11 +166,11 @@ public: /**< Ritorna il valore nel campo (field) in formato (SADateTime), Campo non gestisce le ore */ //SADateTime sqGetDateTime(const char* field) { get_short(field); } /**< Ritorna il valore nel campo (field) passato come (const char *) in formato (const char *) */ - const char* sq_get(const char* field) { return _rec.get(field); } + TString sq_get(const char* field, bool rtrim = true); /**< Ritorna il valore nel campo (field) passato come (string) in formato (const char *) */ - const char* sq_get(string field) { return _rec.get(field.c_str()); } + TString sq_get(string field, bool rtrim = true); /**< Ritorna il valore nel campo (field) passato come (TString) in formato (const char *) */ - const char* sq_get(TString& field) { return _rec.get(static_cast(field)); } + TString sq_get(TString& field, bool rtrim = true); /**< Ritorna il valore nel campo (field) in formato (char) */ const char sq_get_char(const char* field) { return _rec.get_char(field); } /**< Ritorna la posizione attuale */ @@ -181,7 +181,8 @@ public: const long sq_get_code_error(bool erase = true) { return _rec.get_code_error(erase); } /**< Ritorno l'ultima stringa di errore segnalato in formato (const char *) */ const char* sq_get_string_error(bool erase = true) { return _rec.get_string_error(erase); } - //char * getCharPointer(const char * field) { return const_cast(static_cast(recset.Field(field).asString())); } + /**< Ritorno l'ultima stringa di errore segnalato in formato (const char *) */ + const char* sq_get_text_error(bool erase = true) { return _rec.get_text_error(erase); } }; #endif \ No newline at end of file diff --git a/src/m770/777200.cpp b/src/m770/777200.cpp index 6bca745c2..cda47c749 100755 --- a/src/m770/777200.cpp +++ b/src/m770/777200.cpp @@ -565,7 +565,10 @@ bool TTrasferimentoCU::append_record_b() rec.set(16, numtel); const TRectype& rec_anagr = cache().get(LF_ANAG, TString(rec_nditte.get("TIPOA")) << "|" << rec_nditte.get("CODANAGR")); - rec.set(17, rec_anagr.get_int("EVECC")); + const int evecc = rec_anagr.get_int("EVECC"); + + if (evecc == 1 || evecc == 5) + rec.set(17, evecc); const TAnagrafica rapp(LF_ANAG, 'F', rec_nditte.get_long(NDT_RAPPR)); if (rapp.ok()) @@ -664,6 +667,8 @@ bool TTrasferimentoCU::append_record_d(const TRectype& qla, TLog_report& log) rec.np_put("DA001010", _codatt_dic); // rec.np_put("DA001011", "1"); // Codice Sede ??? + if (perc.codice_fiscale() == "BRTTMS98M18832Z") + int i = 1; rec.np_put("DA002001", perc.codice_fiscale()); if (perc.fisica()) { @@ -684,7 +689,10 @@ bool TTrasferimentoCU::append_record_d(const TRectype& qla, TLog_report& log) const TRectype& anag = cache().get_rec(LF_ANAG, qla.get("TIPOA"), qla.get("CODANAGR")); rec.np_put("DA002008", anag.get(ANA_CATPAR)); - rec.np_put("DA002009", anag.get_long(ANA_EVECC)); + const TString4 evecc = anag.get("EVECC"); + + if (evecc == "1" || evecc == "5") + rec.np_put("DA002009", evecc); long int da2010 = anag.get_long(ANA_ESCPRECOMP); // Tolla 2017: Aggiunto questo controllo in quanto noi non gestiamo nessuno dei quadri che richiedono il valore 2 if(da2010 == 2) da2010 = 0; @@ -791,7 +799,7 @@ bool TTrasferimentoCU::append_record_h(const TRectype& qla, int modulo, TLog_rep const TString4 causale = qla.get("CAUSALE"); rec.np_put("AU001001", causale); - if (causale >= "G" && causale <= "I") + if ((causale >= "G" && causale <= "I")&& (qla.get_long("ANNO") < 2019L)) rec.np_put("AU001002", qla.get_long("ANNO")); // Potrebbe essere anche l'anno precedente // rec.np_put("AU001003", ""); @@ -807,9 +815,9 @@ bool TTrasferimentoCU::append_record_h(const TRectype& qla, int modulo, TLog_rep long codice = atol(cache().get("%CA7", codcaus, "I1")); // 1, 2, 5, 6, 7 real altre_somme = qla.get_real("SOMME"); - if (altre_somme > -0.02 && altre_somme < 0.02) - { - altre_somme = ZERO; + if (altre_somme > -0.02 && altre_somme < 0.02) + { + altre_somme = ZERO; } if (altre_somme.is_zero() && codice == 7) { @@ -818,8 +826,10 @@ bool TTrasferimentoCU::append_record_h(const TRectype& qla, int modulo, TLog_rep } if (!altre_somme.is_zero()) { - if (codice <= 0) codice = 7; // Regime minimi - rec.np_put("AU001006", codice); // 1, 2, 5, 6, 7 + if (codice <= 0) codice = 7; // Regime minimi + if (codice == 2) + message_box("Anagrafica %c &ld : Il codice 2 somme non soggette è stato eliminato", tipoanag, codanagr); + rec.np_put("AU001006", codice); // 1, 5, 6, 7 rec.np_put("AU001007", altre_somme); } rec.np_put("AU001008", imponibile); // 004 - 005 - 007 @@ -920,7 +930,7 @@ bool TTrasferimentoCU::split(const char* path) { TRecordCU rec; rec.tipo_record('A'); // Compila record di testata A - rec.set(3, "CUR18"); // Codice fornitura 2018 + rec.set(3, "CUR19"); // Codice fornitura 2019 rec.set(4, 1); // Tipo fornitore: 01=Soggetto che invia la propria dichiarazione; 10=CAF rec.set(5, _codfis_int.full() ? _codfis_int : cod_fis_dic()); // Codice fiscale del fornitore outfile << rec; // Scrive record testata @@ -1147,12 +1157,12 @@ void TCU_app::main_loop() void TCU_app::isUpdated() { TRelation anagr(LF_ANAG); - TCursor c(&anagr); +/* TCursor c(&anagr); long int items = c.items(); TProgress_monitor p(items, "Aggiornamento valori per CU"); bool trovato = false; - // Eseguo questo controllo per verificare la presenza EVECC == 8 - for(c=0; c.pos() < items && !trovato; ++c) + Eseguo questo controllo per verificare la presenza EVECC == 8 + /*for(c=0; c.pos() < items && !trovato; ++c) { TRectype r = c.curr(); if(r.get_int("EVECC") == 8) @@ -1171,7 +1181,7 @@ void TCU_app::isUpdated() r.write_rewrite(anagr.lfile()); } } - } + } */ } int m777200(int argc, char* argv[]) diff --git a/src/m770/777200.h b/src/m770/777200.h index 88f23141d..66aea1476 100644 --- a/src/m770/777200.h +++ b/src/m770/777200.h @@ -6,10 +6,10 @@ #endif // Nota che sono stati definiti anche in 777lib -#define THIS_YEAR "2018" -#define THIS_YEARN 2018 -#define LAST_YEAR "2017" -#define LAST_YEARN 2017 +#define THIS_YEAR "2019" +#define THIS_YEARN 2019 +#define LAST_YEAR "2018" +#define LAST_YEARN 2018 class TRecordCU; diff --git a/src/m770/777lib.h b/src/m770/777lib.h index a5e23d56d..175fea6f1 100644 --- a/src/m770/777lib.h +++ b/src/m770/777lib.h @@ -9,10 +9,10 @@ #define CF_PRODUTTORE get_iva_sirio(); // Nota che sono anche definiti in 777200.h -#define THIS_YEAR "2018" -#define THIS_YEARN 2018 -#define LAST_YEAR "2017" -#define LAST_YEARN 2017 +#define THIS_YEAR "2019" +#define THIS_YEARN 2019 +#define LAST_YEAR "2018" +#define LAST_YEARN 2018 enum { CODE_SIZE = 8, FIELD_SIZE = 16, BLOCK_SIZE = 24, HEADER_SIZE = 89, USEABLE_SIZE = 1800, TOTAL_SIZE = 1900 }; diff --git a/src/m770/77tbca7.uml b/src/m770/77tbca7.uml index 72edb2f5b..c33474fbe 100755 --- a/src/m770/77tbca7.uml +++ b/src/m770/77tbca7.uml @@ -335,7 +335,6 @@ BEGIN INPUT F_IC ITEM " | " ITEM "1|Somme che non hanno concorso a formare il reddito imponibile (90% dell’ammontare erogato), relativo ai compensi percepiti dai docenti e dai ricercatori in base a quanto stabilito dal D.L. 29 novembre 2008, n. 185 convertito, con modificazioni dalla L. n. 2 del 28 gennaio 2009. Vanno altresì inseriti i relativi rimborsi spese" - ITEM "2|Somme che non hanno concorso a formare il reddito imponibile (rispettivamente l’80% dell’ammontare erogato per le lavoratrici ed il 70% per i lavoratori) per i lavoratori appartenenti alle categorie individuate con Decreto del Ministro dell’Economia e delle Finanze del 3 giugno 2011 in possesso dei requisiti previsti e che hanno richiesto di fruire del beneficio fiscale previsto dall’art. 3 della L. 30 dicembre 2010, n. 238" ITEM "5|Nel caso di somme corrisposte che non hanno concorso a formare il reddito imponibile (50% dell'ammontare erogato), relative ai compensi percepiti dai soggetti che hanno avviato un'attività di lavoro autonomo di impresa, in base a quanto stabilito dall'articolo 16 del D.lgs. n. 147 del 2015 modificato dalla legge n. 232 dell'11 dicembre 2016" ITEM "6|Nel caso di assegni di servizio civile di cui all'art.16 del D.lgs. n. 40 del 2017 per i quali la norma ha previsto la loro esenzione" ITEM "7|Erogazione di altri redditi non soggetti a ritenuta ovvero esenti" diff --git a/src/m770/Allegato A Specifiche Tecniche 770 2018.pdf b/src/m770/Allegato A Specifiche Tecniche 770 2018.pdf new file mode 100644 index 000000000..3a467d67b Binary files /dev/null and b/src/m770/Allegato A Specifiche Tecniche 770 2018.pdf differ diff --git a/src/m770/CU 2019.pdf b/src/m770/CU 2019.pdf new file mode 100644 index 000000000..e7a4610b4 Binary files /dev/null and b/src/m770/CU 2019.pdf differ diff --git a/src/ve/velib.h b/src/ve/velib.h index ca862b4a4..d7bec761c 100755 --- a/src/ve/velib.h +++ b/src/ve/velib.h @@ -149,9 +149,13 @@ public: const TString& cms() const { return get("S1").mid(40, 20); } const TString& fase() const { return get("S1").mid(60); } const int codtrib() const { return get_int("S10"); } + const TRectype& rec_caus_770() const; const int caus_770() const { return get_int("I6"); } const int quadro_770() const { return get_int("S12"); } const int quadroLA_770() const { return get_int("S14"); } + const TString& cassa_previdenziale() const { return get("S13").left(4); } + bool sogg_a_rit() const { return get_bool("B0"); } + bool spe_cal_rit() const { return get_bool("B1"); } TSpesa_prest(const char* codice = NULL, char tipo = 'S'); TSpesa_prest(const TRectype& rec); diff --git a/src/ve/velib01.cpp b/src/ve/velib01.cpp index d6822df47..2a7b4bfd4 100755 --- a/src/ve/velib01.cpp +++ b/src/ve/velib01.cpp @@ -229,6 +229,13 @@ char TSpesa_prest::genere() const return RIGA_ATTREZZATURE; return ' '; } + +const TRectype& TSpesa_prest::rec_caus_770() const +{ + static TString caus770; caus770.cut(0); caus770.format("%02d", caus_770()); + return cache().get("%CA7", caus770); +} + int TSpesa_prest::read(const char* codice) { const TString8 cod = get("COD"); diff --git a/src/ve/vetbspp.uml b/src/ve/vetbspp.uml index c235a410e..ef1f34d2e 100755 --- a/src/ve/vetbspp.uml +++ b/src/ve/vetbspp.uml @@ -492,7 +492,7 @@ END BOOLEAN SPP_CALCRIT BEGIN - PROMPT 60 18 "Spesa rientrante nel calcolo ritenuta " + PROMPT 2 19 "Spesa rientrante nel calcolo ritenuta " FLAGS "D" FIELD B1 GROUP 4 diff --git a/src/xvtdb/xvtdb.cpp b/src/xvtdb/xvtdb.cpp index 46302ccb0..885548f15 100644 --- a/src/xvtdb/xvtdb.cpp +++ b/src/xvtdb/xvtdb.cpp @@ -25,8 +25,9 @@ TXvt_recordset::TXvt_recordset() : _freezed(false) } catch (SAException &x) { - _codeError = x.ErrNativeCode(); - _GET_ERROR(x.ErrMessage(), _stringError); + _code_error = x.ErrNativeCode(); + _GET_ERROR(x.ErrMessage(), _string_error); + _GET_ERROR(x.ErrText(), _string_error_full_text); } } @@ -56,8 +57,9 @@ TXvt_recordset::TXvt_recordset(const char* db, const char* user, const char* pas } catch (SAException &x) { - _codeError = x.ErrNativeCode(); - _GET_ERROR(x.ErrMessage(), _stringError); + _code_error = x.ErrNativeCode(); + _GET_ERROR(x.ErrMessage(), _string_error); + _GET_ERROR(x.ErrText(), _string_error_full_text); } } } @@ -106,8 +108,8 @@ int TXvt_recordset::connect(const char* db, const char* user, const char* pass, SAClient_t dbDriver = (SAClient_t)tipoDb; if (dbAddress.IsEmpty() || usr.IsEmpty()) { - _codeError = NOT_INITIALIZED; - _stringError = NOT_INITIALIZEDS; + _code_error = NOT_INITIALIZED; + _string_error = NOT_INITIALIZEDS; } else { @@ -121,17 +123,18 @@ int TXvt_recordset::connect(const char* db, const char* user, const char* pass, } catch (SAException &x) { - _codeError = x.ErrNativeCode(); - _GET_ERROR(x.ErrMessage(), _stringError); + _code_error = x.ErrNativeCode(); + _GET_ERROR(x.ErrMessage(), _string_error); + _GET_ERROR(x.ErrText(), _string_error_full_text); } } } else { - _codeError = NOT_INITIALIZED; - _stringError = NOT_INITIALIZEDS; + _code_error = NOT_INITIALIZED; + _string_error = NOT_INITIALIZEDS; } - return _codeError; + return _code_error; } void TXvt_recordset::disconnect() @@ -142,8 +145,9 @@ void TXvt_recordset::disconnect() } catch(SAException &x) { - _codeError = x.ErrNativeCode(); - _GET_ERROR(x.ErrMessage(), _stringError); + _code_error = x.ErrNativeCode(); + _GET_ERROR(x.ErrMessage(), _string_error); + _GET_ERROR(x.ErrText(), _string_error_full_text); } } @@ -160,8 +164,9 @@ bool TXvt_recordset::commit(bool autoRoll) { rollback(); } - _codeError = x.ErrNativeCode(); - _GET_ERROR(x.ErrMessage(), _stringError); + _code_error = x.ErrNativeCode(); + _GET_ERROR(x.ErrMessage(), _string_error); + _GET_ERROR(x.ErrText(), _string_error_full_text); return false; } return true; @@ -176,8 +181,9 @@ bool TXvt_recordset::rollback() } catch (SAException &x) { - _codeError = x.ErrNativeCode(); - _GET_ERROR(x.ErrMessage(), _stringError); + _code_error = x.ErrNativeCode(); + _GET_ERROR(x.ErrMessage(), _string_error); + _GET_ERROR(x.ErrText(), _string_error_full_text); return false; } return true; @@ -295,8 +301,9 @@ bool TXvt_recordset::set(const char* query) } catch (SAException &x) { - _codeError = x.ErrNativeCode(); - _GET_ERROR(x.ErrMessage(), _stringError); + _code_error = x.ErrNativeCode(); + _GET_ERROR(x.ErrMessage(), _string_error); + _GET_ERROR(x.ErrText(), _string_error_full_text); return false; } return true; @@ -316,8 +323,9 @@ bool TXvt_recordset::exec(bool autoF) } catch (SAException &x) { - _codeError = x.ErrNativeCode(); - _GET_ERROR(x.ErrMessage(), _stringError); + _code_error = x.ErrNativeCode(); + _GET_ERROR(x.ErrMessage(), _string_error); + _GET_ERROR(x.ErrText(), _string_error_full_text); ok = false; } return ok; @@ -343,8 +351,9 @@ bool TXvt_recordset::next() } catch (SAException &x) { - _codeError = x.ErrNativeCode(); - _GET_ERROR(x.ErrMessage(), _stringError); + _code_error = x.ErrNativeCode(); + _GET_ERROR(x.ErrMessage(), _string_error); + _GET_ERROR(x.ErrText(), _string_error_full_text); } return fetched; } @@ -362,8 +371,9 @@ bool TXvt_recordset::prev() } catch (SAException &x) { - _codeError = x.ErrNativeCode(); - _GET_ERROR(x.ErrMessage(), _stringError); + _code_error = x.ErrNativeCode(); + _GET_ERROR(x.ErrMessage(), _string_error); + _GET_ERROR(x.ErrText(), _string_error_full_text); } return fetched; } @@ -381,8 +391,9 @@ bool TXvt_recordset::first() } catch (SAException &x) { - _codeError = x.ErrNativeCode(); - _GET_ERROR(x.ErrMessage(), _stringError); + _code_error = x.ErrNativeCode(); + _GET_ERROR(x.ErrMessage(), _string_error); + _GET_ERROR(x.ErrText(), _string_error_full_text); } return fetched; } @@ -408,8 +419,9 @@ bool TXvt_recordset::last() } catch (SAException &x) { - _codeError = x.ErrNativeCode(); - _GET_ERROR(x.ErrMessage(), _stringError); + _code_error = x.ErrNativeCode(); + _GET_ERROR(x.ErrMessage(), _string_error); + _GET_ERROR(x.ErrText(), _string_error_full_text); } return fetched; } @@ -452,8 +464,9 @@ int TXvt_recordset::get_int(const char* field) } catch (SAException &x) { - _codeError = x.ErrNativeCode(); - _GET_ERROR(x.ErrMessage(), _stringError); + _code_error = x.ErrNativeCode(); + _GET_ERROR(x.ErrMessage(), _string_error); + _GET_ERROR(x.ErrText(), _string_error_full_text); return -1; } } @@ -466,9 +479,9 @@ short TXvt_recordset::get_short(const char* field) } catch (SAException &x) { - _codeError = x.ErrNativeCode(); - _GET_ERROR(x.ErrMessage(), _stringError); - + _code_error = x.ErrNativeCode(); + _GET_ERROR(x.ErrMessage(), _string_error); + _GET_ERROR(x.ErrText(), _string_error_full_text); return -1; } } @@ -481,9 +494,9 @@ long TXvt_recordset::get_long(const char* field) } catch (SAException &x) { - _codeError = x.ErrNativeCode(); - _GET_ERROR(x.ErrMessage(), _stringError); - + _code_error = x.ErrNativeCode(); + _GET_ERROR(x.ErrMessage(), _string_error); + _GET_ERROR(x.ErrText(), _string_error_full_text); return -1; } } @@ -496,8 +509,9 @@ double TXvt_recordset::get_double(const char* field) } catch (SAException &x) { - _codeError = x.ErrNativeCode(); - _GET_ERROR(x.ErrMessage(), _stringError); + _code_error = x.ErrNativeCode(); + _GET_ERROR(x.ErrMessage(), _string_error); + _GET_ERROR(x.ErrText(), _string_error_full_text); return -1; } } @@ -510,8 +524,9 @@ bool TXvt_recordset::get_bool(const char* field) } catch (SAException &x) { - _codeError = x.ErrNativeCode(); - _GET_ERROR(x.ErrMessage(), _stringError); + _code_error = x.ErrNativeCode(); + _GET_ERROR(x.ErrMessage(), _string_error); + _GET_ERROR(x.ErrText(), _string_error_full_text); return false; } } @@ -532,8 +547,9 @@ const char* TXvt_recordset::get_date(const char * field) } catch (SAException &x) { - _codeError = x.ErrNativeCode(); - _GET_ERROR(x.ErrMessage(), _stringError); + _code_error = x.ErrNativeCode(); + _GET_ERROR(x.ErrMessage(), _string_error); + _GET_ERROR(x.ErrText(), _string_error_full_text); return NULL; } } @@ -546,8 +562,9 @@ const char* TXvt_recordset::get(const char* field) } catch (SAException &x) { - _codeError = x.ErrNativeCode(); - _GET_ERROR(x.ErrMessage(), _stringError); + _code_error = x.ErrNativeCode(); + _GET_ERROR(x.ErrMessage(), _string_error); + _GET_ERROR(x.ErrText(), _string_error_full_text); return ""; } } @@ -560,17 +577,18 @@ char TXvt_recordset::get_char(const char* field) } catch (SAException &x) { - _codeError = x.ErrNativeCode(); - _GET_ERROR(x.ErrMessage(), _stringError); + _code_error = x.ErrNativeCode(); + _GET_ERROR(x.ErrMessage(), _string_error); + _GET_ERROR(x.ErrText(), _string_error_full_text); return '\0'; } } long TXvt_recordset::get_code_error(bool erase) { - long app = _codeError; + long app = _code_error; if (erase) - _codeError = NOERR; + _code_error = NOERR; return app; } @@ -581,16 +599,30 @@ const char* TXvt_recordset::get_string_error(bool erase) if (app != nullptr) delete app; - _CPY_STR(_stringError, app); + _CPY_STR(_string_error, app); if (erase) - _stringError = ""; + _string_error = ""; + return app; +} + +const char* TXvt_recordset::get_text_error(bool erase) +{ + static char* app; + + if (app != nullptr) + delete app; + + _CPY_STR(_string_error_full_text, app); + + if (erase) + _string_error_full_text = ""; return app; } const bool TXvt_recordset::setErrorFreezed() { - _codeError = ERROR_FREEZED; - _stringError = ERROR_FREEZEDS; + _code_error = ERROR_FREEZED; + _string_error = _string_error_full_text = ERROR_FREEZEDS; return false; } diff --git a/src/xvtdb/xvtdb.h b/src/xvtdb/xvtdb.h index fac20c5af..f9fcdfe2b 100644 --- a/src/xvtdb/xvtdb.h +++ b/src/xvtdb/xvtdb.h @@ -74,9 +74,11 @@ protected: /**< Query */ const char* _query; /**< Ultima stringa con codice di errore ricevuto */ - char* _stringError; + char* _string_error; + /**< Ultima stringa con codice di errore ricevuto full text */ + char* _string_error_full_text; /**< Ultimo codice di errore ricevuto */ - long _codeError; + long _code_error; /**< Numero record corrente */ long _recno; /**< Indica se l'oggetto è bloccato, in tal caso non si possono fare set/exec */ @@ -202,6 +204,8 @@ public: long get_code_error(bool erase = true); /**< Ritorno l'ultima stringa di errore segnalato in formato (const char *) */ const char* get_string_error(bool erase = true); + /**< Ritorno l'ultima stringa di errore (full text) segnalato in formato (const char *) */ + const char* get_text_error(bool erase = true); //char * getCharPointer(const char * field) { return const_cast(static_cast(recset.Field(field).asString())); } // Utilities