diff --git a/build/AgaLib.vcxproj b/build/AgaLib.vcxproj index 30a458a36..7ed602a3b 100644 --- a/build/AgaLib.vcxproj +++ b/build/AgaLib.vcxproj @@ -41,9 +41,9 @@ <_ProjectFileVersion>10.0.30319.1 ..\lib\ - ..\obj\$(SolutionName)\$(ProjectName)\ + ..\obj\common\$(ProjectName)\ ..\lib\ - ..\obj\$(SolutionName)\$(ProjectName)\ + ..\obj\common\$(ProjectName)\ $(ProjectName) $(ProjectName) @@ -216,6 +216,7 @@ + @@ -566,6 +567,7 @@ %(AdditionalIncludeDirectories) %(PreprocessorDefinitions) + %(AdditionalIncludeDirectories) %(PreprocessorDefinitions) diff --git a/build/AgaLib.vcxproj.filters b/build/AgaLib.vcxproj.filters index e7dd7b67e..958661ae8 100644 --- a/build/AgaLib.vcxproj.filters +++ b/build/AgaLib.vcxproj.filters @@ -526,6 +526,9 @@ Headers + + Headers + @@ -780,6 +783,9 @@ Sources + + Sources + diff --git a/build/Cb6.vcxproj b/build/Cb6.vcxproj index 97aebe8ea..16e37313a 100644 --- a/build/Cb6.vcxproj +++ b/build/Cb6.vcxproj @@ -40,14 +40,14 @@ <_ProjectFileVersion>10.0.30319.1 ..\exe\ - ..\obj\$(SolutionName)\$(ProjectName)\ + ..\obj\common\$(ProjectName)\ false true false false $(ProjectName) ..\exe\ - ..\obj\$(SolutionName)\$(ProjectName)\ + ..\obj\common\$(ProjectName)\ false false $(ProjectName) diff --git a/build/PATCHDEF.EXE b/build/PATCHDEF.EXE index a0d30711b..b4cf135fd 100644 Binary files a/build/PATCHDEF.EXE and b/build/PATCHDEF.EXE differ diff --git a/build/Uno.vcxproj b/build/Uno.vcxproj index a99d8dbad..05dfc3130 100644 --- a/build/Uno.vcxproj +++ b/build/Uno.vcxproj @@ -40,9 +40,9 @@ <_ProjectFileVersion>10.0.30319.1 ..\lib\ - ..\obj\$(SolutionName)\$(ProjectName)\ + ..\obj\common\$(ProjectName)\ ..\lib\ - ..\obj\$(SolutionName)\$(ProjectName)\ + ..\obj\common\$(ProjectName)\ $(ProjectName) $(ProjectName) diff --git a/build/agalib_alx.vcxproj b/build/agalib_alx.vcxproj index 611fe9b1e..e9099e982 100644 --- a/build/agalib_alx.vcxproj +++ b/build/agalib_alx.vcxproj @@ -48,11 +48,11 @@ <_ProjectFileVersion>10.0.30319.1 ..\exe\ - ..\obj\$(SolutionName)\$(ProjectName)\ + ..\obj\common\$(ProjectName)\ false false ..\exe\ - ..\obj\$(SolutionName)\$(ProjectName)\ + ..\obj\common\$(ProjectName)\ false false diff --git a/build/agalib_bagn.vcxproj b/build/agalib_bagn.vcxproj index cc9cb55d8..56f3d934f 100644 --- a/build/agalib_bagn.vcxproj +++ b/build/agalib_bagn.vcxproj @@ -43,11 +43,11 @@ <_ProjectFileVersion>10.0.30319.1 ..\exe\ - ..\obj\$(SolutionName)\$(ProjectName)\ + ..\obj\common\$(ProjectName)\ false false ..\exe\ - ..\obj\$(SolutionName)\$(ProjectName)\ + ..\obj\common\$(ProjectName)\ false false diff --git a/build/agalib_bagn.vcxproj.filters b/build/agalib_bagn.vcxproj.filters index a025edf29..7f6b0e818 100644 --- a/build/agalib_bagn.vcxproj.filters +++ b/build/agalib_bagn.vcxproj.filters @@ -74,14 +74,4 @@ Headers - - - Trr - - - - - Dir - - \ No newline at end of file diff --git a/build/agalib_rep.vcxproj b/build/agalib_rep.vcxproj index da726ba20..71d687c48 100644 --- a/build/agalib_rep.vcxproj +++ b/build/agalib_rep.vcxproj @@ -44,11 +44,11 @@ <_ProjectFileVersion>10.0.30319.1 ..\exe\ - ..\obj\$(SolutionName)\$(ProjectName)\ + ..\obj\common\$(ProjectName)\ false false ..\exe\ - ..\obj\$(SolutionName)\$(ProjectName)\ + ..\obj\common\$(ProjectName)\ false false diff --git a/build/ca.sln b/build/ca.sln index 739b3c757..9d58b18f6 100644 --- a/build/ca.sln +++ b/build/ca.sln @@ -51,6 +51,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cglib", "cglib.vcxproj", "{ EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "vedocext", "vedocext.vcxproj", "{0042619A-6B7C-4D3D-9CD9-9BDD8D200C15}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "lilib", "lilib.vcxproj", "{B61F0AD4-0CCE-4371-8E92-85A26CAF1A7C}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 @@ -105,6 +107,10 @@ Global {0042619A-6B7C-4D3D-9CD9-9BDD8D200C15}.Debug|Win32.Build.0 = Debug|Win32 {0042619A-6B7C-4D3D-9CD9-9BDD8D200C15}.Release|Win32.ActiveCfg = Release|Win32 {0042619A-6B7C-4D3D-9CD9-9BDD8D200C15}.Release|Win32.Build.0 = Release|Win32 + {B61F0AD4-0CCE-4371-8E92-85A26CAF1A7C}.Debug|Win32.ActiveCfg = Debug|Win32 + {B61F0AD4-0CCE-4371-8E92-85A26CAF1A7C}.Debug|Win32.Build.0 = Debug|Win32 + {B61F0AD4-0CCE-4371-8E92-85A26CAF1A7C}.Release|Win32.ActiveCfg = Release|Win32 + {B61F0AD4-0CCE-4371-8E92-85A26CAF1A7C}.Release|Win32.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/build/cglib.vcxproj b/build/cglib.vcxproj index f7e206f32..2f78637ec 100644 --- a/build/cglib.vcxproj +++ b/build/cglib.vcxproj @@ -42,9 +42,9 @@ <_ProjectFileVersion>10.0.30319.1 ..\lib\ - ..\obj\$(SolutionName)\$(ProjectName)\ + ..\obj\common\$(ProjectName)\ ..\lib\ - ..\obj\$(SolutionName)\$(ProjectName)\ + ..\obj\common\$(ProjectName)\ $(ProjectName) $(ProjectName) AllRules.ruleset diff --git a/build/fastrip.exe b/build/fastrip.exe index 8bc86e627..0a766454c 100644 Binary files a/build/fastrip.exe and b/build/fastrip.exe differ diff --git a/build/fp0.vcxproj b/build/fp0.vcxproj index 43596688e..d516e6f23 100644 --- a/build/fp0.vcxproj +++ b/build/fp0.vcxproj @@ -92,6 +92,7 @@ MachineX86 + false true diff --git a/build/fp1.vcxproj b/build/fp1.vcxproj index 283be2e26..474c948c3 100644 --- a/build/fp1.vcxproj +++ b/build/fp1.vcxproj @@ -92,6 +92,7 @@ MachineX86 + false true diff --git a/build/gfm.vcxproj b/build/gfm.vcxproj index 2d281319e..6e312ddfa 100644 --- a/build/gfm.vcxproj +++ b/build/gfm.vcxproj @@ -42,10 +42,10 @@ <_ProjectFileVersion>10.0.30319.1 ..\exe\ - ..\obj\$(SolutionName)\$(ProjectName)\ + ..\obj\common\$(ProjectName)\ true ..\exe\ - ..\obj\$(SolutionName)\$(ProjectName)\ + ..\obj\common\$(ProjectName)\ false $(ProjectName) false diff --git a/build/lilib.vcxproj b/build/lilib.vcxproj index 6658c27be..12dee11c6 100644 --- a/build/lilib.vcxproj +++ b/build/lilib.vcxproj @@ -42,10 +42,10 @@ <_ProjectFileVersion>10.0.30319.1 ..\lib\ - ..\obj\$(SolutionName)\$(ProjectName)\ + ..\obj\common\$(ProjectName)\ false ..\lib\ - ..\obj\$(SolutionName)\$(ProjectName)\ + ..\obj\common\$(ProjectName)\ false false false @@ -158,7 +158,6 @@ - diff --git a/build/pdflib_dll.vcxproj b/build/pdflib_dll.vcxproj index 4c656e159..e2e11d426 100644 --- a/build/pdflib_dll.vcxproj +++ b/build/pdflib_dll.vcxproj @@ -43,10 +43,10 @@ <_ProjectFileVersion>10.0.30319.1 ..\exe\ - ..\obj\$(SolutionName)\$(ProjectName)\ + ..\obj\common\$(ProjectName)\ true ..\exe\ - ..\obj\$(SolutionName)\$(ProjectName)\ + ..\obj\common\$(ProjectName)\ $(ProjectName) false false diff --git a/build/pdflibwrap.vcxproj b/build/pdflibwrap.vcxproj index b516580c1..84134f5da 100644 --- a/build/pdflibwrap.vcxproj +++ b/build/pdflibwrap.vcxproj @@ -40,9 +40,9 @@ <_ProjectFileVersion>10.0.30319.1 ..\lib\ - ..\obj\$(SolutionName)\$(ProjectName)\ + ..\obj\common\$(ProjectName)\ ..\lib\ - ..\obj\$(SolutionName)\$(ProjectName)\ + ..\obj\common\$(ProjectName)\ $(ProjectName) $(ProjectName) diff --git a/build/vedoc.vcxproj b/build/vedoc.vcxproj index 162e98e58..6121d748e 100644 --- a/build/vedoc.vcxproj +++ b/build/vedoc.vcxproj @@ -42,9 +42,9 @@ <_ProjectFileVersion>10.0.30319.1 ..\lib\ - ..\obj\$(SolutionName)\$(ProjectName)\ + ..\obj\common\$(ProjectName)\ ..\lib\ - ..\obj\$(SolutionName)\$(ProjectName)\ + ..\obj\common\$(ProjectName)\ $(ProjectName) $(ProjectName) AllRules.ruleset diff --git a/build/vedocext.vcxproj b/build/vedocext.vcxproj index d27d02848..dc229e2bb 100644 --- a/build/vedocext.vcxproj +++ b/build/vedocext.vcxproj @@ -43,9 +43,9 @@ <_ProjectFileVersion>10.0.30319.1 ..\lib\ - ..\obj\$(SolutionName)\$(ProjectName)\ + ..\obj\common\$(ProjectName)\ ..\lib\ - ..\obj\$(SolutionName)\$(ProjectName)\ + ..\obj\common\$(ProjectName)\ $(ProjectName) $(ProjectName) diff --git a/build/xi.vcxproj b/build/xi.vcxproj index 8a8667a8b..921fc47eb 100644 --- a/build/xi.vcxproj +++ b/build/xi.vcxproj @@ -42,10 +42,10 @@ <_ProjectFileVersion>10.0.30319.1 ..\exe\ - ..\obj\$(SolutionName)\$(ProjectName)\ + ..\obj\common\$(ProjectName)\ true ..\exe\ - ..\obj\$(SolutionName)\$(ProjectName)\ + ..\obj\common\$(ProjectName)\ false $(ProjectName) false diff --git a/build/xvaga.vcxproj b/build/xvaga.vcxproj index 5287f21c7..4acd78986 100644 --- a/build/xvaga.vcxproj +++ b/build/xvaga.vcxproj @@ -43,10 +43,10 @@ <_ProjectFileVersion>10.0.30319.1 ..\exe\ - ..\obj\$(SolutionName)\$(ProjectName)\ + ..\obj\common\$(ProjectName)\ false ..\exe\ - ..\obj\$(SolutionName)\$(ProjectName)\ + ..\obj\common\$(ProjectName)\ true $(ProjectName) false diff --git a/build/xvapp.vcxproj b/build/xvapp.vcxproj index 6ba9e33fe..9fbb6e666 100644 --- a/build/xvapp.vcxproj +++ b/build/xvapp.vcxproj @@ -42,9 +42,9 @@ <_ProjectFileVersion>10.0.30319.1 ..\lib\ - ..\obj\$(SolutionName)\$(ProjectName)\ + ..\obj\common\$(ProjectName)\ ..\lib\ - ..\obj\$(SolutionName)\$(ProjectName)\ + ..\obj\common\$(ProjectName)\ $(ProjectName) $(ProjectName) diff --git a/build/xvtdb.vcxproj b/build/xvtdb.vcxproj index a8fa3f6b8..9c133349a 100644 --- a/build/xvtdb.vcxproj +++ b/build/xvtdb.vcxproj @@ -44,10 +44,10 @@ <_ProjectFileVersion>10.0.30319.1 ..\exe\ - ..\obj\$(SolutionName)\$(ProjectName)\ + ..\obj\common\$(ProjectName)\ false ..\exe\ - ..\obj\$(SolutionName)\$(ProjectName)\ + ..\obj\common\$(ProjectName)\ true $(ProjectName) false diff --git a/cd/Setup.exe b/cd/Setup.exe index 07d92d59f..670d1ffd1 100644 Binary files a/cd/Setup.exe and b/cd/Setup.exe differ diff --git a/src/ba/ba0100.cpp b/src/ba/ba0100.cpp index a068cb241..da5291b49 100755 --- a/src/ba/ba0100.cpp +++ b/src/ba/ba0100.cpp @@ -1512,6 +1512,18 @@ bool TMenu_application::dongle_update_needed() const bool TMenu_application::user_create() { + TFilename dir; + + if (xvt_sys_get_env("TEMP", dir.get_buffer(), dir.size())) + if (!dexist(dir)) + return error_box(FR("La cartella temporanea %s definita dalla variabile d'ambiente TEMP non esiste."), (const char *)dir); + if (xvt_sys_get_env("TMP", dir.get_buffer(), dir.size())) + if (!dexist(dir)) + return error_box(FR("La cartella temporanea %s definita dalla variabile d'ambiente TMP non esiste."), (const char *)dir); + dir.cut(0); + dir.tempdir(); + if (!dexist(dir)) + return error_box(FR("La cartella temporanea %s definita in campo.ini non esiste."), (const char *)dir); disable_menu_item(M_FILE_PRINT); // Questa voce di menu non serve per ora disable_menu_item(M_FILE_PREVIEW); // Figuriamoci questa @@ -1575,7 +1587,7 @@ bool TMenu_application::user_create() _menu.read(menu); update_preferred_tree(); } - + return true; } diff --git a/src/ba/ba1100.cpp b/src/ba/ba1100.cpp index 6c503a8a1..d336756b7 100755 --- a/src/ba/ba1100.cpp +++ b/src/ba/ba1100.cpp @@ -13,11 +13,9 @@ #include "ba1100.h" #include "ba1103.h" -#include #include -#include +#include #include -#include #include #include @@ -35,59 +33,6 @@ #define Dir_file "dir.gen" #define Trc_file "trc.gen" -class TManutenzione_app : public TSkeleton_application -{ - TDir_sheet* _browse; - TArray _dirs; - TArray _recs; - TMask* _mask; - long _firm; - long _level; - long _history_firm; - TRec_sheet* _rec; - TLog_report* _log; - bool _print_log; - - bool _superprassi; - -protected: - virtual void main_loop(); - virtual bool create () ; - virtual bool destroy(); - void insert_riga(long, TToken_string&); - void edit_riga(long, TToken_string&); - void edit_riga(const TString&); - void delete_riga(long); - virtual bool extended_firm() const { return true; } - - bool set_converting(); - bool reset_converting(); - - bool try_to_recover(TSystemisamfile& f, int err); - void update(); - void update_dir(); - void convert_dir(); - virtual void print(); - virtual void do_print(TPrinter & p, TRec_sheet & r); - const char* dumpfilename(const FileDes& dep) const; - void load_des(); - void open_history(); - void put_history(const char* firm); - void close_history(); - void dump_trc(const char * dir, const bool des_too, const long modules); - void repair_file(int i); - void save_file(const char * file); - - void open_log(); - void write_log(const char* line, const int severity = 0); - void close_log(); - - bool moveable_file(int file) const; -public: - - TManutenzione_app(); -}; - HIDDEN bool browse_file_handler(TMask_field& f, KEY k) { if (k == K_F9) @@ -318,12 +263,12 @@ void TManutenzione_app::print() bool TManutenzione_app::create() // initvar e arrmask { - _firm = get_firm(); - TString sw(argc()>2 ? argv(2) : ""); // Posso fare le operazione avanzate solo se sono ammistratore // e NON mi trovo su di una installazione di tipo client - _superprassi = user() == ::dongle().administrator() && !::dongle().demo(); + + xvt_vobj_show(TASK_WIN); + _superprassi = user() == ::dongle().administrator() && !::dongle().demo(); if (_superprassi) { const int type = ini_get_int(CONFIG_INSTALL, "Main", "Type"); @@ -361,7 +306,8 @@ bool TManutenzione_app::create() // initvar e arrmask else if (!::dongle().demo() && !set_firm()) return false; - load_des(); + _firm = atol(prefix().name()); + load_des(); _mask = new TMask("ba1100a"); _browse = new TDir_sheet(TR("Manutenzione file di sistema"), _superprassi); @@ -384,6 +330,24 @@ bool TManutenzione_app::destroy() return TApplication::destroy(); } +void TManutenzione_app::show_log() +{ + if (db_log()) + { + if (admin()) + { + TLog_mask m; + + m.run(); + } + else + message_box(TR("Il log delle transazioni è visualizzabile dall'amministratore")); + } + else + message_box(TR("Il log delle transazioni è disattivato")); +} + + void TManutenzione_app::open_log() { _print_log = false; diff --git a/src/ba/ba1100.h b/src/ba/ba1100.h index ff79ff996..443cc783a 100755 --- a/src/ba/ba1100.h +++ b/src/ba/ba1100.h @@ -1,6 +1,10 @@ #ifndef __BA1100_H #define __BA1100_H +#ifndef __APPLICAT_H +#include +#endif + #ifndef __CONFIG_H #include #endif @@ -17,6 +21,14 @@ class TMask_field; #endif +#ifndef __PRINTER_H +#include +#endif + +#ifndef __REPUTILS_H +#include +#endif + #include "ba1100a.h" /////////////////////////////////////////////////////////// @@ -92,4 +104,62 @@ public: virtual ~TEdit_file() {} }; +class TManutenzione_app : public TSkeleton_application +{ + TDir_sheet* _browse; + TArray _dirs; + TArray _recs; + TMask* _mask; + long _firm; + long _level; + long _history_firm; + TRec_sheet* _rec; + TLog_report* _log; + bool _print_log; + + bool _superprassi; + +protected: + virtual void main_loop(); + virtual bool create(); + virtual bool destroy(); + void insert_riga(long, TToken_string&); + void edit_riga(long, TToken_string&); + void edit_riga(const TString&); + void delete_riga(long); + virtual bool extended_firm() const { return true; } + + bool set_converting(); + bool reset_converting(); + + bool try_to_recover(TSystemisamfile& f, int err); + void update(); + void update_dir(); + void convert_dir(); + virtual void print(); + virtual void do_print(TPrinter & p, TRec_sheet & r); + const char* dumpfilename(const FileDes& dep) const; + void load_des(); + void open_history(); + void put_history(const char* firm); + void close_history(); + void dump_trc(const char * dir, const bool des_too, const long modules); + void repair_file(int i); + void save_file(const char * file); + + virtual void show_log(); + + void open_log(); + void write_log(const char* line, const int severity = 0); + void close_log(); + + bool moveable_file(int file) const; +public: + long get_firm() const { return _firm; } + + TManutenzione_app(); +}; + +inline TManutenzione_app & app() { return (TManutenzione_app &)main_app(); } + #endif diff --git a/src/ba/ba1101.cpp b/src/ba/ba1101.cpp index f413898ce..82863f895 100755 --- a/src/ba/ba1101.cpp +++ b/src/ba/ba1101.cpp @@ -275,9 +275,17 @@ void TRec_sheet::edit() } f2.set_notify(key_notify); f2.set_append(FALSE); + int nkeys = _rec.keys(); - for (i = 0; i < nkeys; i++) f2.row(i) = _rec.keydef(i); + + for (i = 0; i < nkeys; i++) + f2.row(i) = _rec.keydef(i); f2.disable_cell(0, 1); + + const bool enable_save = (_dir.is_com() && app().get_firm() == 0) || + (_dir.is_firm() && app().get_firm() > 0); + + _mask->enable(DLG_SAVEREC, enable_save); while (true) { f1.force_update(0); // Non togliere, serve per fare l'update della descrizione quando si fa l'import!! diff --git a/src/ba/ba2900.cpp b/src/ba/ba2900.cpp index faffa4b7b..ab54b52bc 100644 --- a/src/ba/ba2900.cpp +++ b/src/ba/ba2900.cpp @@ -136,7 +136,7 @@ protected: bool dir_gen() const; bool trc_gen() const; bool export_manager(const TString generalErrors) const; - bool show_log(); + bool show_export_log(); void log(int severity, const char* msg); public: @@ -980,7 +980,7 @@ bool TMSSQLExport_app::export_manager(TString generalErrors) const return true; } -bool TMSSQLExport_app::show_log() +bool TMSSQLExport_app::show_export_log() { if (_log) { @@ -1089,7 +1089,7 @@ void TMSSQLExport_app::main_loop() } message_box("Migrazione effettuata correttamente!"); } while (loop); - show_log(); + show_export_log(); } else message_box("Fallita connessione"); diff --git a/src/ba/ba7100.cpp b/src/ba/ba7100.cpp index a166a511e..ffd601aa6 100755 --- a/src/ba/ba7100.cpp +++ b/src/ba/ba7100.cpp @@ -1742,6 +1742,7 @@ class TMailer : public TSkeleton_application bool _start_full_screen; protected: + virtual bool task_win_iconized() const { return !_start_full_screen && xvt_win_is_taskbar_visible(); } virtual bool create(); virtual void main_loop(); }; @@ -1767,7 +1768,7 @@ void TMailer::main_loop() WINDOW tray = xvt_trayicon_create(TASK_WIN, 9013, appname); // CampoServer.ico open_files(LF_USER, 0); - if (!_start_full_screen && xvt_win_is_taskbar_visible()) +/* if (!_start_full_screen && xvt_win_is_taskbar_visible()) { if (tray != NULL_WIN) { @@ -1778,7 +1779,7 @@ void TMailer::main_loop() if (xvt_rect_get_width(&rct_postman) >= xvt_rect_get_width(&rct_screen) - 64) xvt_vobj_set_visible(TASK_WIN, FALSE); } - } + } */ TMailer_mask mm; diff --git a/src/ba/batbiva.uml b/src/ba/batbiva.uml index ddaacf0b2..1b74f4c28 100755 --- a/src/ba/batbiva.uml +++ b/src/ba/batbiva.uml @@ -46,7 +46,7 @@ BEGIN WARNING "Manca la descrizione" END -LIST LST_TABIVA_S1 2 20 +LIST LST_TABIVA_S1 2 28 BEGIN PROMPT 2 2 "Tipo " FIELD S1 @@ -70,11 +70,15 @@ BEGIN MESSAGE CLEAR,FLD_TABIVA_R0|CLEAR,FLD_TABIVA_I0 MESSAGE ENABLE,FLD_TABIVA_I3|ENABLE,FLD_TABIVA_I4|SHOW,CHK_TABIVA_B5 MESSAGE ENABLE,FLD_TABIVA_S6 -END + ITEM "RC|Reverse Charge (vendite)" + MESSAGE CLEAR,FLD_TABIVA_R0|CLEAR,FLD_TABIVA_I0 + MESSAGE CLEAR,FLD_TABIVA_I3|CLEAR,FLD_TABIVA_I4|HIDE,CHK_TABIVA_B5 + MESSAGE ENABLE,FLD_TABIVA_S6 + END STRING FLD_TABIVA_S6 4 BEGIN - PROMPT 39 2 "C.IVA a cui ventilare " + PROMPT 44 2 "C.IVA a cui ventilare " FLAGS "U" FIELD S6 COPY USE FLD_TABIVA_CODTAB @@ -146,7 +150,7 @@ END BOOLEAN CHK_TABIVA_B5 BEGIN - PROMPT 30 5 "Escluso dal calcolo dei bolli sufatture esenti" + PROMPT 30 5 "Escluso dal calcolo dei bolli su fatture esenti" FIELD B5 END @@ -188,6 +192,8 @@ BEGIN INPUT FLD_TABIVA_I3 OUTPUT FLD_TABIVA_I3 ITEM " |Nessuno" + ITEM "14|Passaggi interni" + ITEM "16|Cessioni beni ammortizzabili" ITEM "20|Operazioni non imponibili (comma 1, artt.8, 8bis e 9)" ITEM "21|Operazioni non imponibili a seguito di dich. d'intento" ITEM "22|Altre operazioni non imponibili" @@ -201,6 +207,7 @@ BEGIN ITEM "36|Cessione di microprocessori" ITEM "37|Prestazioni comparto edile e settori connessi" ITEM "38|Operazioni settore energetico" + ITEM "39|Reverse charge altri casi" ITEM "B1|Ammontare op. es. escluse da nr. 1 a 9 e 11 art. 10" ITEM "B2|Ammontare op. es. di cui al nr. 11 art. 10" ITEM "B3|Ammontare op. es. di cui ai nr. 1 a 9 art. 10" diff --git a/src/ca/ca2100.cpp b/src/ca/ca2100.cpp index feb491c68..9ccc1082e 100755 --- a/src/ca/ca2100.cpp +++ b/src/ca/ca2100.cpp @@ -1025,7 +1025,7 @@ bool TMovanal_msk::row2imp(int r, TImporto& imp) const return !imp.is_zero(); } -const TToken_string& TMovanal_msk::rec2key(const TRectype& rec) const +const TToken_string& TMovanal_msk::rec2key(const TRectype& rec) const //qui { TToken_string& key = get_tmp_string(); key = get(F_TIPO); @@ -1127,7 +1127,6 @@ void TMovanal_msk::aggiorna_saldo_riga(int r) sld += TImporto('D', dare); } } - sld.normalize(); set(F_DARE, sld.sezione() == 'D' ? sld.valore() : ZERO); set(F_AVERE, sld.sezione() == 'A' ? sld.valore() : ZERO); diff --git a/src/ca/ca2300.cpp b/src/ca/ca2300.cpp index 027f480e4..58a8e3c89 100755 --- a/src/ca/ca2300.cpp +++ b/src/ca/ca2300.cpp @@ -50,11 +50,8 @@ bool TRic_saldi_msk::on_field_event(TOperable_field& o, TField_event e, long jol const long recset_items = recset.items(); TProgind pi(recset_items, "Ricerca movimenti che interessano l'esercizio selezionato...", true, true); - for (bool ok = recset.move_first(); ok; ok = recset.move_next()) + for (bool ok = recset.move_first(); pi.addstatus(1) && ok; ok = recset.move_next()) { - if (!pi.addstatus(1)) - break; - const TDate curr_date = recset.get(MOVANA_DATACOMP).as_date(); const TDate fcomp_date = recset.get(MOVANA_DATAFCOMP).as_date(); diff --git a/src/ca/ca3200.cpp b/src/ca/ca3200.cpp index 9aa08aa24..bbf85f9c5 100755 --- a/src/ca/ca3200.cpp +++ b/src/ca/ca3200.cpp @@ -2,6 +2,7 @@ #include #include #include +#include #include #include "../cg/cglib.h" @@ -24,89 +25,16 @@ class TPrint_mastrini_ca_mask : public TAnal_report_mask { protected: bool on_field_event(TOperable_field& o, TField_event e, long jolly); - const TString& get_report_class() const; - bool test_compatible_report(); public: TPrint_mastrini_ca_mask(); virtual ~TPrint_mastrini_ca_mask() {} }; -const TString& TPrint_mastrini_ca_mask::get_report_class() const -{ - TString& classe = get_tmp_string(); - classe = "ca3200a"; -// const int stp = get_int(F_TIPOCONTI); -// classe << (stp == 1 ? 'a' : 'b'); // tipo di report da usare in caso di report multipli - return classe; -} - -bool TPrint_mastrini_ca_mask::test_compatible_report() -{ - TFilename lib = get_report_class(); - const TString& name = get(F_REPORT); - bool ok = name.not_empty(); - if (ok) - { - TReport rep; - ok = rep.load(name); - if (ok) - { - const TString& classe = rep.get_class(); - ok = classe == lib; - } - } - if (!ok) - { - set(F_REPORT, lib); - lib.ext("rep"); - ok = lib.custom_path(); - } - return ok; -} - bool TPrint_mastrini_ca_mask::on_field_event(TOperable_field& o, TField_event e, long jolly) { switch (o.dlg()) { - case DLG_PRINT: - if (e == fe_button) - { - main_app().print(); - return false; - } - break; - case DLG_PREVIEW: - if (e == fe_button) - { - main_app().preview(); - return false; - } - break; - case F_TIPOCONTI: - if (e == fe_init || e == fe_modify) - { - test_compatible_report(); //in base al tipo di conti da stampare setta i report compatibili (solo nel caso di rep multipli) - } - break; - case F_REPORT: - if (e == fe_button) - { - const TString8 lib = get_report_class(); - TFilename path = o.get(); - if (select_custom_file(path, "rep", lib)) - { - path = path.name(); - path.ext(""); - o.set(path); - } - } else - if (e == fe_close) - { - if (!test_compatible_report()) - return error_box(TR("Impossibile trovare un report compatibile")); - } - break; case F_ANNO: if (e == fe_modify && !o.empty()) { @@ -180,7 +108,7 @@ protected: int _tipimov; TDate _dadata, _adata; long _danumreg, _anumreg; - TString _daconto, _aconto, _codcosto, _codcms, _codfas; + TString _daconto, _aconto, _codcosto, _codcms, _codfas, _contsep; protected: //da libreria virtual const TVariant& get(const char* column_name) const; @@ -288,7 +216,8 @@ void TPrint_mastrini_ca_recordset::set_custom_filter(TCursor& cur) const const TImporto& TPrint_mastrini_ca_recordset::saldo_iniziale(const char* conto) const { TAnal_bill bill(conto, _codcosto, _codcms, _codfas); - const TSaldanal& saldo = ca_saldo(bill, _dadata, _adata, _tipimov); + const TSaldanal& saldo = ca_saldo(bill, "", _dadata, _adata, _tipimov); // qui + return saldo._ini; } @@ -394,7 +323,8 @@ TPrint_mastrini_ca_alternative_recordset::TPrint_mastrini_ca_alternative_records const TImporto& TPrint_mastrini_ca_alternative_recordset::saldo_finale(const char* conto) const { TAnal_bill bill(conto, _codcosto, _codcms, _codfas); - const TSaldanal& saldo = ca_saldo(bill, _dadata, _adata, _tipimov); + const TSaldanal& saldo = ca_saldo(bill, "", _dadata, _adata, _tipimov); // qui + return saldo._fin; } @@ -470,7 +400,7 @@ void TPrint_mastrini_ca_alternative_recordset::set_filter(const TPrint_mastrini_ { TPconana_recordset pconana; - pconana.set_filter(' ', _daconto, _aconto, _codcosto, _codcms, _codfas, + pconana.set_filter(' ', _daconto, _aconto, _codcosto, _codcms, _codfas, _contsep, _dadata, _adata, _tipimov, _tipoconti==1, _tipoconti==2); const long pconana_items = pconana.items(); @@ -485,20 +415,26 @@ void TPrint_mastrini_ca_alternative_recordset::set_filter(const TPrint_mastrini_ a_rmovana.put(RMOVANA_DATACOMP, _adata); TString filtro; - if (_codcosto.not_empty()) + if (_codcosto.full()) filtro << "(" << RMOVANA_CODCCOSTO << "?=\"" << _codcosto << "*\")"; - if (_codcms.not_empty()) + if (_codcms.full()) { - if (filtro.not_empty()) + if (filtro.full()) filtro << "&&"; filtro << "(" << RMOVANA_CODCMS << "?=\"" << _codcms << "*\")"; } - if (_codfas.not_empty()) + if (_codfas.full()) { - if (filtro.not_empty()) + if (filtro.full()) filtro << "&&"; filtro << "(" << RMOVANA_CODFASE << "?=\"" << _codfas << "*\")"; } + if (_contsep.full()) + { + if (filtro.full()) + filtro << "&&"; + filtro << "(" << MOVANA_CONTSEP << "?=\"" << _contsep << "*\")"; + } //scandisce il piano dei conti.. for (bool pok = pconana.move_first(); pok; pok = pconana.move_next()) @@ -594,142 +530,137 @@ void TPrint_mastrini_ca_rep::set_filter(const TPrint_mastrini_ca_mask& msk, int //////////////////////////////////////////////////////// // APPLICAZIONE //////////////////////////////////////////////////////// -class TPrint_mastrini_ca : public TSkeleton_application +class TPrint_mastrini_ca : public TReport_application { TPrint_mastrini_ca_mask* _mask; + TPrint_mastrini_ca_rep * _rep; protected: virtual const char * extra_modules() const {return "cm";} //funziona anche con autorizzazione CM + virtual TReport & get_report(const TAutomask & m); + //virtual TTrec * get_dbase_recdesc(TReport & rep); + virtual TAutomask & get_mask(); + virtual void execute_print(TReport_book & book, TAutomask & mask, TReport & rep, export_type type = _export_printer); + virtual short output_id() const { return 0; } + virtual const char * output_name(const TReport & rep) const { return "listamov"; } + // @cmember Distruzione dei dati dell'utente + virtual bool user_destroy() { return true; } - void print_or_preview(const bool stampa); - virtual void print(); - virtual void preview(); - - virtual void main_loop(); +public: + TPrint_mastrini_ca() : _mask(nullptr), _rep(nullptr) {} + ~TPrint_mastrini_ca() {} }; -void TPrint_mastrini_ca::print() +TReport & TPrint_mastrini_ca::get_report(const TAutomask & m) { - print_or_preview(true); -} + if (_rep == nullptr) + _rep = new TPrint_mastrini_ca_rep; -void TPrint_mastrini_ca::preview() -{ - print_or_preview(false); -} + TString path = _mask->get(DLG_REPORT); -void TPrint_mastrini_ca::print_or_preview(const bool stampa) -{ - //report e book dei report - TReport_book book; - TString path = _mask->get(F_REPORT); if (path.empty()) - path = "ca3200a"; - TPrint_mastrini_ca_rep rep; - rep.load(path); + path = ((TPrint_mastrini_ca_mask *)_mask)->get_report_class(); + _rep->load(_mask->get(DLG_REPORT)); + return *_rep; +} +TAutomask & TPrint_mastrini_ca::get_mask() +{ + if (_mask == nullptr) + _mask = new TPrint_mastrini_ca_mask; + return *_mask; +} + + + +void TPrint_mastrini_ca::execute_print(TReport_book & book, TAutomask & mask, TReport & rep, export_type type) +{ TSheet_field& sheet = _mask->sfield(F_RIGHE); - TString video_string; //stringa che compare nella progind + TString msg; //stringa che compare nella progind + if (sheet.empty()) //se non ci sono righe sullo sheet (selezione su tutte le cms/cdc)... { if (_mask->get_bool(F_PERCONTO)) { - rep.set_filter(*_mask, -1); //fa la set filter sulla prima riga (che è quella usata) + ((TPrint_mastrini_ca_rep &)rep).set_filter((TPrint_mastrini_ca_mask &)mask, -1); book.add(rep); } else { - TToken_string& row = sheet.row(-1); //crea la prima riga dello sheet + TToken_string& row = sheet.row(-1); //crea la prima riga dello sheet - //stabilisce quale è il primo livello (tra CDC e CMS).. - const TMultilevel_code_info& liv1 = *ca_multilevel_code_info_by_index(0); - const int logic1 = liv1.logic(); + //stabilisce quale è il primo livello (tra CDC e CMS).. + const TMultilevel_code_info& liv1 = *ca_multilevel_code_info_by_index(0); + const int logic1 = liv1.logic(); - TAssoc_array codici_buoni; - TString query; - query << "USE RMOVANA KEY 2\n"; - query << "FROM CODCONTO=#DACONTO\n"; - query << "TO CODCONTO=#ACONTO"; - TISAM_recordset rmovana(query); - TString80 daconto, aconto; - for (int i = 0; _mask->id2pos(F_CDC1_INI+i) > 0; i++) - { - daconto << _mask->get(F_CDC1_INI+i); - aconto << _mask->get(F_CDC1_FIN+i); - } - rmovana.set_var("#DACONTO", daconto); - rmovana.set_var("#ACONTO", aconto); - const long items = rmovana.items(); - if (items > 0) - { - TProgind po(items, "Analisi righe movimento analitiche...", true, true); + TAssoc_array codici_buoni; + TString query; + query << "USE RMOVANA KEY 2\n"; + query << "FROM CODCONTO=#DACONTO\n"; + query << "TO CODCONTO=#ACONTO"; + TISAM_recordset rmovana(query); + TString80 daconto, aconto; + for (int i = 0; _mask->id2pos(F_CDC1_INI+i) > 0; i++) + { + daconto << _mask->get(F_CDC1_INI+i); + aconto << _mask->get(F_CDC1_FIN+i); + } + rmovana.set_var("#DACONTO", daconto); + rmovana.set_var("#ACONTO", aconto); + const long items = rmovana.items(); + if (items > 0) + { + TProgind po(items, "Analisi righe movimento analitiche...", true, true); - for (bool ok = rmovana.move_first(); ok; ok = rmovana.move_next()) - { - if (!po.addstatus(1)) - break; + for (bool ok = rmovana.move_first(); ok; ok = rmovana.move_next()) + { + if (!po.addstatus(1)) + break; - const TString& codice = rmovana.get(logic1 == LF_COMMESSE ? RMOVANA_CODCMS : RMOVANA_CODCCOSTO).as_string(); - codici_buoni.add(codice); - } - } + const TString& codice = rmovana.get(logic1 == LF_COMMESSE ? RMOVANA_CODCMS : RMOVANA_CODCCOSTO).as_string(); + codici_buoni.add(codice); + } + } - TISAM_recordset set(logic1 == LF_CDC ? "USE CDC" : "USE COMMESSE"); //..e di conseguenza scrive la use giusta + TISAM_recordset set(logic1 == LF_CDC ? "USE CDC" : "USE COMMESSE"); //..e di conseguenza scrive la use giusta - bool skip_closed = false; - if (logic1 == LF_COMMESSE) - skip_closed = !yesno_box(TR("E' stata richiesta la stampa di tutte le commesse:\n" - "Si desidera includere anche le commesse chiuse?")); + bool skip_closed = false; + if (logic1 == LF_COMMESSE) + skip_closed = !yesno_box(TR("E' stata richiesta la stampa di tutte le commesse:\n" + "Si desidera includere anche le commesse chiuse?")); - TProgind pi(set.items(), video_string, true, true); - for (bool sok = set.move_first(); sok; sok = set.move_next()) //fighissimo metodo per scandire un file in 1 riga! - { - if (!pi.addstatus(1)) - break; + TProgress_monitor pi(set.items(), msg, true); + for (bool sok = set.move_first(); pi.add_status() && sok; sok = set.move_next()) //fighissimo metodo per scandire un file in 1 riga! + { + if (skip_closed && set.get(COMMESSE_CHIUSA).as_bool()) + continue; - if (skip_closed && set.get(COMMESSE_CHIUSA).as_bool()) - continue; - - row = set.get(0u).as_string(); //prende il valore del primo campo del file (CDC o CMS code) - if (!codici_buoni.is_key(row)) - continue; + row = set.get_string(0u); //prende il valore del primo campo del file (CDC o CMS code) + if (!codici_buoni.is_key(row)) + continue; - //completa la stringa da visualizzare sulla progind - video_string.cut(0) << row << '\n' << set.get(1u); - pi.set_text(video_string); + //completa la stringa da visualizzare sulla progind + msg = row; + msg << '\n' << set.get(1u); + pi.set_text(msg); - for (int l = liv1.levels()-2; l >= 0; l--) //se la struttura è a più livelli costruisce la tokenstring - row.insert("|", liv1.total_len(l)); + for (int l = liv1.levels()-2; l >= 0; l--) //se la struttura è a più livelli costruisce la tokenstring + row.insert("|", liv1.total_len(l)); - rep.set_filter(*_mask, 0); //fa la set filter sulla prima riga (che è quella usata) - book.add(rep); - } - sheet.destroy(); //cancella le commesse aggiunte in automatico sullo sheet + ((TPrint_mastrini_ca_rep &)rep).set_filter((TPrint_mastrini_ca_mask &)mask, 0); //fa la set filter sulla prima riga (che è quella usata) + book.add(rep); + } + sheet.destroy(); //cancella le commesse aggiunte in automatico sullo sheet } } else { FOR_EACH_SHEET_ROW(sheet, r, row) { - rep.set_filter(*_mask, r); + ((TPrint_mastrini_ca_rep &)rep).set_filter((TPrint_mastrini_ca_mask &) mask, r); book.add(rep); } } - - if (stampa) - book.print(); //stampa il book dei report - else - book.preview(); //anteprima - -} - - -void TPrint_mastrini_ca::main_loop() -{ - _mask = new TPrint_mastrini_ca_mask; - _mask->run(); - delete _mask; - _mask = NULL; } int ca3200(int argc, char* argv[]) diff --git a/src/ca/ca3300.cpp b/src/ca/ca3300.cpp index 352367ed0..a20ac945d 100755 --- a/src/ca/ca3300.cpp +++ b/src/ca/ca3300.cpp @@ -1,6 +1,7 @@ #include #include #include +#include #include #include @@ -26,53 +27,26 @@ class TPrint_bilancio_ca_mask : public TAnal_report_mask { protected: virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly); - const TString& get_report_class() const; - bool test_compatible_report(); bool esistono_riclassificazioni() const; public: - TPrint_bilancio_ca_mask(); + const TString& get_report_class() const; + + TPrint_bilancio_ca_mask(); virtual ~TPrint_bilancio_ca_mask() {} }; const TString& TPrint_bilancio_ca_mask::get_report_class() const { - TString& lib = get_tmp_string(); - lib = "ca3300"; + TString& classe = get_tmp_string(); - const char bil = get(F_BILANCIO)[0]; // Verifica o sezioni Contrapposte - const char stp = get(F_TIPOSTAMPA)[0]; // Raffronto o No? - - if (bil == 'V') - lib << (stp == 'R' ? 'a' : 'b'); // Verifica + classe = TAnal_report_mask::get_report_class(); + classe.cut(5); + if (get(F_BILANCIO) == "V") // Verifica o sezioni Contrapposte + classe << (get(F_TIPOSTAMPA) == "R" ? 'a' : 'b'); // Verifica - Raffronto o No else - lib << (stp == 'R' ? 'c' : 'd'); // Sezioni contrapposte - return lib; -} - -bool TPrint_bilancio_ca_mask::test_compatible_report() -{ - const TString& cls = get_report_class(); - const TString& name = get(F_REPORT); - bool ok = name.full(); - if (ok && name != cls) - { - TReport rep; - ok = rep.load(name); - if (ok) - { - const TString& classe = rep.get_class(); - ok = classe == cls; - } - } - if (!ok) - { - set(F_REPORT, cls); - TFilename path = cls; - path.ext("rep"); - ok = path.custom_path(); - } - return ok; + classe << (get(F_TIPOSTAMPA) == "R" ? 'c' : 'd'); // Sezioni contrapposte - Raffronto o No + return classe; } bool TPrint_bilancio_ca_mask::esistono_riclassificazioni() const @@ -85,28 +59,13 @@ bool TPrint_bilancio_ca_mask::on_field_event(TOperable_field& o, TField_event e, { switch (o.dlg()) { - case DLG_PRINT: - if (e == fe_button) - { - main_app().print(); - return false; - } - break; - case DLG_PREVIEW: - if (e == fe_button) - { - main_app().preview(); - return false; - } - break; - case F_ANNO: case F_BILANCIO: case F_STAMPA: case F_TIPOSTAMPA: if (e == fe_modify || (e == fe_init && o.dlg() == F_ANNO)) { - test_compatible_report(); + set_report_class(); bool enable_from = false, enable_to = false; if (get_int(F_STAMPA) == 1) // Stampa per data limite @@ -153,24 +112,6 @@ bool TPrint_bilancio_ca_mask::on_field_event(TOperable_field& o, TField_event e, } } break; - case F_REPORT: - if (e == fe_button) - { - const TString8 lib = get_report_class(); - TFilename path = o.get(); - if (select_custom_file(path, "rep", lib)) - { - path = path.name(); - path.ext(""); - o.set(path); - } - } else - if (e == fe_close) - { - if (!test_compatible_report()) - return error_box("Impossibile trovare un report compatibile"); - } - break; case F_PRE1: case F_PRE2: case F_PRE3: @@ -291,7 +232,7 @@ protected: public: void set_filter(const TMask& msk, int row); - TReport_bilancio_verifica(const char* name); + TReport_bilancio_verifica() { } }; bool TReport_bilancio_verifica::set_recordset(const TString& /* sql */) @@ -372,14 +313,10 @@ void TReport_bilancio_verifica::set_filter(const TMask& m, int row) commessa = rel.curr().get(RMOVANA_CODCMS); fase = rel.curr().get(RMOVANA_CODFASE); + const TString & contsep = m.get(F_CONTSEP); TPconana_recordset* rset = (TPconana_recordset*)recordset(); if (rset != NULL) - rset->set_filter(tc, da_conto, a_conto, costo, commessa, fase, dal, al, tipimov, movimentati, nonnulli); -} - -TReport_bilancio_verifica::TReport_bilancio_verifica(const char* name) -{ - load(name); + rset->set_filter(tc, da_conto, a_conto, costo, commessa, fase, contsep, dal, al, tipimov, movimentati, nonnulli); } //////////////////////////////////////////////////////// @@ -418,7 +355,7 @@ class TRecordset_sezioni_contrapposte : public TRecordset TDate _da_data, _a_data; word _tipimov; bool _movimentati, _nonnulli; - TString _daconto, _aconto; + TString _daconto, _aconto, _contsep; TString4 _tipostampa; bool _print_ap; @@ -449,7 +386,7 @@ public: virtual const TVariant& get(unsigned int column) const { return NULL_VARIANT; } virtual const TVariant& get(const char* field) const; - void set_filter(char piano, const char* costo, const char* commessa, const char* fase, + void set_filter(char piano, const char* costo, const char* commessa, const char* fase, const char * contsep, const TDate& dal, const TDate& al, word tipimov, bool movimentati, bool nonnulli, bool print_ap, const TString& daconto, const TString& aconto); char tipo_piano() const { return _tipo_piano; } @@ -473,7 +410,7 @@ bool TRecordset_sezioni_contrapposte::move_to(TRecnotype pos) return _pos < items(); } -void TRecordset_sezioni_contrapposte::set_filter(char piano, const char* costo, const char* commessa, const char* fase, +void TRecordset_sezioni_contrapposte::set_filter(char piano, const char* costo, const char* commessa, const char* fase, const char * contsep, const TDate& dal, const TDate& al, word tipimov, bool movimentati, bool nonnulli, bool print_ap, const TString& daconto, const TString& aconto) { @@ -505,6 +442,7 @@ void TRecordset_sezioni_contrapposte::set_filter(char piano, const char* costo, _daconto = daconto; _aconto = aconto; + _contsep = contsep; } TArray& TRecordset_sezioni_contrapposte::conti(int indbil) @@ -536,7 +474,7 @@ void TRecordset_sezioni_contrapposte::add_conto(const TString& b, a.insert(sc, n); } -void TRecordset_sezioni_contrapposte::add_conto(int indbil, const TString& b) +void TRecordset_sezioni_contrapposte::add_conto(int indbil, const TString& b) // qui { if (indbil >= 1 && indbil <= 4) { @@ -646,8 +584,8 @@ void TRecordset_sezioni_contrapposte::add_conto(int indbil, const TString& b) bill.set_fase(c.blank() ? "~" : c); - const TSaldanal& wsp = ca_saldo(bill, _da_data, _a_data, _saldanal_preventivi); - const TSaldanal& wsc = ca_saldo(bill, _da_data, _a_data, _saldanal_consuntivo); + const TSaldanal& wsp = ca_saldo(bill, "", _da_data, _a_data, _saldanal_preventivi); // qui + const TSaldanal& wsc = ca_saldo(bill, "", _da_data, _a_data, _saldanal_consuntivo); sp += wsp; sc += wsc; @@ -675,7 +613,7 @@ void TRecordset_sezioni_contrapposte::add_conto(int indbil, const TString& b) c = code.get(); bill.set_fase(c.blank() ? "~" : c); - const TSaldanal& wsa = ca_saldo(bill, _da_data, _a_data, _tipimov); + const TSaldanal& wsa = ca_saldo(bill, "", _da_data, _a_data, _tipimov); // qui sa += wsa; } @@ -691,8 +629,8 @@ void TRecordset_sezioni_contrapposte::add_conto(int indbil, const TString& b) { if ((_tipimov & _saldanal_qualsiasi) == _saldanal_qualsiasi) // Bilancio a sezioni contrapposte di raffronto { - const TSaldanal sp = ca_saldo(bill, _da_data, _a_data, _saldanal_preventivi); - const TSaldanal sc = ca_saldo(bill, _da_data, _a_data, _saldanal_consuntivo); + const TSaldanal sp = ca_saldo(bill, "", _da_data, _a_data, _saldanal_preventivi);// qui + const TSaldanal sc = ca_saldo(bill, "", _da_data, _a_data, _saldanal_consuntivo); if (!sp._fin.is_zero() || !sc._fin.is_zero()) { @@ -704,7 +642,7 @@ void TRecordset_sezioni_contrapposte::add_conto(int indbil, const TString& b) } else { - const TSaldanal sa = ca_saldo(bill, _da_data, _a_data, _tipimov); + const TSaldanal sa = ca_saldo(bill, "", _da_data, _a_data, _tipimov); // qui if (!sa._fin.is_zero()) { @@ -771,6 +709,9 @@ void TRecordset_sezioni_contrapposte::requery() { // Crea recordset del piano dei conti appropriato TString query = "USE PCON"; + + if (_contsep.full()) + query << " SELECT (" << MOVANA_CONTSEP << "==" << _contsep << ")"; if (_tipo_piano == 'A') { query << "ANA"; @@ -979,6 +920,8 @@ const TVariant& TRecordset_sezioni_contrapposte::get(const char* field) const return get_tmp_var() = _filter.commessa(); if (fld == "#FASE") return get_tmp_var() = _filter.fase(); + if (fld == "#CONTSEP") + return get_tmp_var() = _contsep; if (fld == "#DATA_INIZIALE") return get_tmp_var() = _da_data; if (fld == "#DATA_FINALE") @@ -1035,7 +978,7 @@ protected: public: void set_filter(const TMask& msk, int row); - TReport_bilancio_sezioni_contrapposte(const char* name) { load(name); } + TReport_bilancio_sezioni_contrapposte() { } }; bool TReport_bilancio_sezioni_contrapposte::set_recordset(const TString& /* sql */) @@ -1109,7 +1052,9 @@ void TReport_bilancio_sezioni_contrapposte::set_filter(const TMask& m, int row) } TRecordset_sezioni_contrapposte* recset = new TRecordset_sezioni_contrapposte(tipo); - recset->set_filter(tipo, costo, commessa, fase, dal, al, tipimov, movimentati, nonnulli, print_ap, daconto, aconto); + const TString & contsep = m.get(F_CONTSEP); + + recset->set_filter(tipo, costo, commessa, fase, contsep, dal, al, tipimov, movimentati, nonnulli, print_ap, daconto, aconto); TAnal_report::set_recordset(recset); }; @@ -1117,9 +1062,10 @@ void TReport_bilancio_sezioni_contrapposte::set_filter(const TMask& m, int row) // APPLICAZIONE //////////////////////////////////////////////////////// -class TPrint_bilancio_ca : public TSkeleton_application +class TPrint_bilancio_ca : public TReport_application { - TPrint_bilancio_ca_mask* _mask; + TPrint_bilancio_ca_mask * _mask; + TArray _reps; protected: virtual const char * extra_modules() const {return "cm";} //funziona anche con autorizzazione CM @@ -1127,70 +1073,75 @@ protected: bool commessa_buona(const TRectype& cms, const TDate& dadata, const TDate& adata) const; bool buon_cdc(const TRectype& cdc, const TDate& dadata, const TDate& adata) const; void fill_sheet(int livello); - void bilancio_a_sezioni_contrapposte(const bool stampa); - void bilancio_di_verifica(const bool stampa); + void bilancio_a_sezioni_contrapposte(TReport & rep); + void bilancio_di_verifica(TReport & rep); + // @cmember ritorna la maschera + virtual TAutomask & get_mask(); + // @cmember Ritorna il report + virtual TReport & get_report(const TAutomask & m); + virtual void execute_print(TReport_book & book, TAutomask & mask, TReport & rep, export_type type = _export_printer); + virtual bool user_destroy(); - void print_or_preview(const bool stampa); - virtual void print(); - virtual void preview(); - - virtual void main_loop(); +public: + TPrint_bilancio_ca() : _mask(nullptr) {} + ~TPrint_bilancio_ca() {} }; -void TPrint_bilancio_ca::bilancio_a_sezioni_contrapposte(const bool stampa) +TReport & TPrint_bilancio_ca::get_report(const TAutomask & m) { - TReport_bilancio_sezioni_contrapposte rep(_mask->get(F_REPORT)); + TReport * r = nullptr; + if (m.get(F_BILANCIO) == "C") + { + if (_reps.objptr(0) == nullptr) + _reps.add(new TReport_bilancio_sezioni_contrapposte, 0); + r = (TReport_bilancio_sezioni_contrapposte *) _reps.objptr(0); + } + else + { + if (_reps.objptr(1) == nullptr) + _reps.add(new TReport_bilancio_verifica, 0); + r = (TReport_bilancio_verifica *)_reps.objptr(1); + } + TString path = _mask->get(DLG_REPORT); + + if (path.empty()) + path = ((TPrint_bilancio_ca_mask *)_mask)->get_report_class(); + r->load(path); + return *r; +} + +TAutomask & TPrint_bilancio_ca::get_mask() +{ + if (_mask == nullptr) + _mask = new TPrint_bilancio_ca_mask; + return *_mask; +} + +void TPrint_bilancio_ca::bilancio_a_sezioni_contrapposte(TReport & rep) +{ const int rows = _mask->sfield(F_RIGHE).items(); - TProgind* pi = rows > 1 ? new TProgind(rows, TR("Bilancio a sezioni contrapposte")) : NULL; - + TProgress_monitor pi(rows, TR("Bilancio a sezioni contrapposte")); TReport_book book; - for (int i = 0; i < rows; i++) + + for (int i = 0; pi.add_status() && i < rows; i++) { - if (pi && !pi->addstatus(1)) - break; - rep.set_filter(*_mask, i); + ((TReport_bilancio_sezioni_contrapposte &)rep).set_filter(*_mask, i); book.add(rep); } - if (pi) delete pi; - - if (stampa) - book.print(); //stampa il book dei report - else - book.preview(); //anteprima } -void TPrint_bilancio_ca::bilancio_di_verifica(const bool stampa) +void TPrint_bilancio_ca::bilancio_di_verifica(TReport & rep) { - TReport_bilancio_verifica rep(_mask->get(F_REPORT)); - const int rows = _mask->sfield(F_RIGHE).items(); - TProgind* pi = rows > 1 ? new TProgind(rows, TR("Bilancio di verifica")) : NULL; - + TProgress_monitor pi(rows, TR("Bilancio di verifica")); TReport_book book; - for (int i = 0; i < rows; i++) + + for (int i = 0; pi.add_status() && i < rows; i++) { - if (pi && !pi->addstatus(1)) - break; - rep.set_filter(*_mask, i); + ((TReport_bilancio_verifica &)rep).set_filter(*_mask, i); book.add(rep); } - if (pi) delete pi; - - if (stampa) - book.print(); //stampa il book dei report - else - book.preview(); //anteprima -} - -void TPrint_bilancio_ca::print() -{ - print_or_preview(true); -} - -void TPrint_bilancio_ca::preview() -{ - print_or_preview(false); } // Anche l'occhio vuole la sua parte @@ -1297,7 +1248,7 @@ void TPrint_bilancio_ca::fill_sheet(int livello) } } -void TPrint_bilancio_ca::print_or_preview(const bool stampa) +void TPrint_bilancio_ca::execute_print(TReport_book & book, TAutomask & mask, TReport & rep, export_type type) { TSheet_field& sf = _mask->sfield(F_RIGHE); @@ -1311,22 +1262,19 @@ void TPrint_bilancio_ca::print_or_preview(const bool stampa) } else fill_sheet(completa); - if (_mask->get(F_BILANCIO) == "C") - bilancio_a_sezioni_contrapposte(stampa); + bilancio_a_sezioni_contrapposte(rep); else - bilancio_di_verifica(stampa); + bilancio_di_verifica(rep); if (empty_sheet) sf.destroy(); } -void TPrint_bilancio_ca::main_loop() +bool TPrint_bilancio_ca::user_destroy() { - _mask = new TPrint_bilancio_ca_mask; - _mask->run(); - delete _mask; - _mask = NULL; + safe_delete(_mask); + return TReport_application::user_destroy(); } int ca3300(int argc, char* argv[]) diff --git a/src/ca/ca3700.cpp b/src/ca/ca3700.cpp index f15945c86..132680413 100755 --- a/src/ca/ca3700.cpp +++ b/src/ca/ca3700.cpp @@ -75,7 +75,7 @@ const TString& TPrint_rendiconto_ca_mask::get_report_class() const bool TPrint_rendiconto_ca_mask::test_compatible_report() { const TString& cls = get_report_class(); - const TString& name = get(F_REPORT); + const TString& name = get(DLG_REPORT); bool ok = name.not_empty(); if (ok) { @@ -89,7 +89,7 @@ bool TPrint_rendiconto_ca_mask::test_compatible_report() } if (!ok) { - set(F_REPORT, cls); + set(DLG_REPORT, cls); TFilename path = cls; path.ext("rep"); ok = path.custom_path(); @@ -144,7 +144,7 @@ bool TPrint_rendiconto_ca_mask::on_field_event(TOperable_field& o, TField_event }*/ } break; - case F_REPORT: + case DLG_REPORT: if (e == fe_button) { const TString8 lib = get_report_class(); @@ -563,7 +563,7 @@ real TPrint_rendiconto_ca_recordset::get_budget_batch(const TString& codcdc, con if (_riclassificato) tipo_movimento |= _saldanal_riclassify; //..ecco quindi il saldo.. - const TSaldanal& saldo = ca_saldo(zio, null_date, null_date, tipo_movimento); + const TSaldanal& saldo = ca_saldo(zio, "", null_date, null_date, tipo_movimento); // qui //..che deve essere normalizzato in base alla sua sezione ed all'indicatore di bilancio del conto TImporto imp = saldo._fin; switch (zio.indicatore_bilancio()) @@ -601,7 +601,7 @@ real TPrint_rendiconto_ca_recordset::get_budget_print(const TString& conto, char if (_riclassificato) tipo_movimento |= _saldanal_riclassify; //..ecco quindi il saldo.. - const TSaldanal& saldo = ca_saldo(zio, null_date, null_date, tipo_movimento); + const TSaldanal& saldo = ca_saldo(zio, "", null_date, null_date, tipo_movimento); // qui //..che deve essere normalizzato in base alla sua sezione ed all'indicatore di bilancio del conto TImporto imp = saldo._fin; switch (zio.indicatore_bilancio()) @@ -2378,7 +2378,7 @@ void TPrint_rendiconto_ca::export_rendiconto() TSheet_field& sheet = _msk->sfield(F_RIGHE); sheet.destroy(); TToken_string& row = sheet.row(-1); //crea la prima riga dello sheet - TString repname = _msk->get(F_REPORT); + TString repname = _msk->get(DLG_REPORT); if (repname.empty()) repname = "ca3700a"; @@ -2684,7 +2684,7 @@ void TPrint_rendiconto_ca::main_loop() //report e book dei report TReport_book book; - TString path = mask.get(F_REPORT); + TString path = mask.get(DLG_REPORT); if (path.empty()) path = "ca3700a"; TPrint_rendiconto_ca_rep rep; diff --git a/src/ca/ca3800.cpp b/src/ca/ca3800.cpp index ff008eceb..4de0add11 100755 --- a/src/ca/ca3800.cpp +++ b/src/ca/ca3800.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include "../cg/cglib.h" @@ -7,6 +7,7 @@ #include "ca3883a.h" #include "calib01.h" #include "calib02.h" +#include "commesse.h" #include "pconana.h" #include "cdc.h" #include "fasi.h" @@ -47,7 +48,7 @@ const TString& TPrint_bilancio_cms_mask::get_report_class() const bool TPrint_bilancio_cms_mask::test_compatible_report() { const TString& cls = get_report_class(); - const TString& name = get(F_REPORT); + const TString& name = get(DLG_REPORT); bool ok = name.not_empty(); if (ok) { @@ -61,7 +62,7 @@ bool TPrint_bilancio_cms_mask::test_compatible_report() } if (!ok) { - set(F_REPORT, cls); + set(DLG_REPORT, cls); TFilename path = cls; path.ext("rep"); ok = path.custom_path(); @@ -73,21 +74,7 @@ bool TPrint_bilancio_cms_mask::on_field_event(TOperable_field& o, TField_event e { switch (o.dlg()) { - case DLG_PRINT: - if (e == fe_button) - { - main_app().print(); - return false; - } - break; - case DLG_PREVIEW: - if (e == fe_button) - { - main_app().preview(); - return false; - } - break; - case F_REPORT: + case DLG_REPORT: if (e == fe_button) { const TString8 lib = get_report_class(); @@ -131,7 +118,6 @@ bool TPrint_bilancio_cms_mask::on_field_event(TOperable_field& o, TField_event e return TAnal_report_mask::on_field_event(o, e, jolly); } - TPrint_bilancio_cms_mask::TPrint_bilancio_cms_mask() :TAnal_report_mask("ca3800") { @@ -251,36 +237,35 @@ TPrint_bilancio_cms_rep::TPrint_bilancio_cms_rep(const char* rep_name, const TSt const bool intestazione_minima) :TCRPA_report(rep_name, prefix, depth, show_fasi, show_cdc, show_cms_descr, show_cms_date, sintetica, intestazione_minima) { - } //////////////////////////////////////////////////////// // APPLICAZIONE //////////////////////////////////////////////////////// -class TPrint_bilancio_cms : public TSkeleton_application +class TPrint_bilancio_cms : public TReport_application { - TPrint_bilancio_cms_mask* _mask; + TPrint_bilancio_cms_mask * _mask; + TReport * _rep; protected: void build_lista_fasi(TString_array & lista_fasi, const TString & fase); void build_lista_cdc(TString_array & lista_cdc, const TString & cdc); - void print_or_preview(const bool stampa); - virtual void print(); - virtual void preview(); + // @cmember Ritorna il report + virtual TReport & get_report(const TAutomask & m); + // @cmember ritorna la maschera + virtual TAutomask & get_mask(); + virtual void execute_print(TReport_book & book, TAutomask & mask, TReport & rep, export_type type = _export_printer); - virtual void main_loop(); +public: + virtual const char * title() const { return TR("Stampa bilancio di commessa"); } + virtual const char * output_name(const TReport & rep) const { return "bilcms"; } + virtual TTrec * get_dbase_recdesc(TReport & rep); + // @cmember Costruttore + TPrint_bilancio_cms() : _mask(nullptr), _rep(nullptr) { } + // @cmember Distruttore + virtual ~TPrint_bilancio_cms() { } }; -void TPrint_bilancio_cms::print() -{ - print_or_preview(true); -} - -void TPrint_bilancio_cms::preview() -{ - print_or_preview(false); -} - void TPrint_bilancio_cms::build_lista_fasi(TString_array & lista_fasi, const TString & fase) { TString query("USE FASI"); @@ -331,25 +316,14 @@ void TPrint_bilancio_cms::build_lista_cdc(TString_array & lista_cdc, const TStri } } -void TPrint_bilancio_cms::print_or_preview(const bool stampa) +void TPrint_bilancio_cms::execute_print(TReport_book & book, TAutomask & mask, TReport & rep, export_type type) { - //report e book dei report - TReport_book book; - - TString80 prefix; - for (short id = F_PRE1; id <= F_PRE3 && _mask->id2pos(id) > 0; id++) - prefix << _mask->get(id); - - const int depth = _mask->get_int(F_DEPTH); - TString path = _mask->get(F_REPORT); - const int tipostampa = _mask->get_int(F_TIPOSTAMPA); //fasi const bool dett_fasi = (tipostampa == 1) || (tipostampa == 3); const TString& fase = _mask->get(F_FASE); const bool group_fasi = tipostampa == 4; const bool show_fasi = dett_fasi && fase.empty(); - const bool sintetica = _mask->get_bool(F_STAMPA_SINTETICA); const bool intestazione_minima = _mask->get_bool(F_INTESTAZIONE_MINIMA); //cdc @@ -363,12 +337,6 @@ void TPrint_bilancio_cms::print_or_preview(const bool stampa) const bool show_cms_descr = _mask->get_bool(F_SHOW_CMS_DESCR); const bool show_cms_date = _mask->get_bool(F_SHOW_CMS_DATE); - if (path.empty()) - path = _mask->get_report_class(); - - //crea il report in base ai parametri (tipo report,struttura,profondita' di stampa) - TPrint_bilancio_cms_rep rep(path, prefix, depth, show_fasi, show_cdc, show_cms_descr, show_cms_date, sintetica, intestazione_minima); - //se e' una stampa di tipo fasi riassunte (crpa special edition) deve fare lo scanning di tutte le fasi.. //..singolarmente e stampare un report per ogni fase.Senno' stampa un solo report @@ -379,12 +347,8 @@ void TPrint_bilancio_cms::print_or_preview(const bool stampa) if (fase.blank() && cdc.blank()) { - rep.set_filter(*_mask); - book.add(rep); - if (stampa) - book.print(); - else - book.preview(); + ((TPrint_bilancio_cms_rep & ) rep).set_filter(*_mask); + book.add(rep, type); } else { @@ -401,8 +365,8 @@ void TPrint_bilancio_cms::print_or_preview(const bool stampa) { const TString& cdc = lista_cdc.row(j); - rep.set_filter(*_mask, fase, cdc); - book.add(rep); + ((TPrint_bilancio_cms_rep &)rep).set_filter(*_mask, fase, cdc); + book.add(rep, type); if (rep.page() > 0) { if (intestazione_minima) @@ -413,10 +377,6 @@ void TPrint_bilancio_cms::print_or_preview(const bool stampa) } } } - if (stampa) - book.print(); - else - book.preview(); } } } //if(group_fasi... @@ -434,8 +394,8 @@ void TPrint_bilancio_cms::print_or_preview(const bool stampa) { TString16 fase = lista_fasi.row(i); - rep.set_filter(*_mask, fase); - book.add(rep); + ((TPrint_bilancio_cms_rep &)rep).set_filter(*_mask, fase); + book.add(rep, type); if (rep.page() > 0) { if (intestazione_minima) @@ -445,13 +405,7 @@ void TPrint_bilancio_cms::print_or_preview(const bool stampa) } } } - if (stampa) - book.print(); - else - book.preview(); - } - } //if(group_fasi... else if (group_cdc || dett_cdc) @@ -465,8 +419,8 @@ void TPrint_bilancio_cms::print_or_preview(const bool stampa) { const TString& cdc = lista_cdc.row(j); - rep.set_filter(*_mask, fase, cdc); - book.add(rep); + ((TPrint_bilancio_cms_rep &)rep).set_filter(*_mask, fase, cdc); + book.add(rep, type); if (rep.page() > 0) { if (intestazione_minima) @@ -477,35 +431,115 @@ void TPrint_bilancio_cms::print_or_preview(const bool stampa) } } } - if (stampa) - book.print(); - else - book.preview(); } //if(group_cdc... else //...senno' stampa standard in un giro solo { - rep.set_filter(*_mask); - book.add(rep); - if (stampa) - book.print(); - else - book.preview(); + ((TPrint_bilancio_cms_rep &)rep).set_filter(*_mask); + book.add(rep, type); } } -void TPrint_bilancio_cms::main_loop() +TReport & TPrint_bilancio_cms::get_report(const TAutomask & m) { - _mask = new TPrint_bilancio_cms_mask; - _mask->run(); - delete _mask; - _mask = NULL; + + TString80 prefix; + + for (short id = F_PRE1; id <= F_PRE3 && m.id2pos(id) > 0; id++) + prefix << m.get(id); + + const int depth = m.get_int(F_DEPTH); + TString path = m.get(DLG_REPORT); + + const int tipostampa = m.get_int(F_TIPOSTAMPA); + //fasi + const bool dett_fasi = (tipostampa == 1) || (tipostampa == 3); + const TString& fase = m.get(F_FASE); + const bool group_fasi = tipostampa == 4; + const bool show_fasi = dett_fasi && fase.empty(); + const bool sintetica = m.get_bool(F_STAMPA_SINTETICA); + const bool intestazione_minima = m.get_bool(F_INTESTAZIONE_MINIMA); + + //cdc + const bool dett_cdc = (tipostampa == 2) || (tipostampa == 3); + const TString& cdc = m.get(F_CDC); + const bool group_cdc = tipostampa == 8; + const bool show_cdc = dett_cdc && cdc.empty(); + + + //descrizioni + const bool show_cms_descr = m.get_bool(F_SHOW_CMS_DESCR); + const bool show_cms_date = m.get_bool(F_SHOW_CMS_DATE); + + if (path.empty()) + path = ((TPrint_bilancio_cms_mask &)m).get_report_class(); + //crea il report in base ai parametri (tipo report,struttura,profondita' di stampa) + safe_delete(_rep); + _rep = new TPrint_bilancio_cms_rep(path, prefix, depth, show_fasi, show_cdc, show_cms_descr, show_cms_date, sintetica, intestazione_minima); + return *_rep; +} + +TAutomask & TPrint_bilancio_cms::get_mask() +{ + if (_mask == nullptr) + _mask = new TPrint_bilancio_cms_mask; + return *_mask; +} + +TTrec * TPrint_bilancio_cms::get_dbase_recdesc(TReport & rep) +{ + TTrec * desc = new TTrec; + TToken_string def; + TRectype cms(LF_COMMESSE); + TRectype fasi(LF_FASI); + TRectype cdc(LF_CDC); + TMask & m = get_mask(); + const int tipostampa = m.get_int(F_TIPOSTAMPA); + const bool show_cms_descr = _mask->get_bool(F_SHOW_CMS_DESCR); + const bool show_cms_date = _mask->get_bool(F_SHOW_CMS_DATE); + const bool dett_fasi = (tipostampa == 1) || (tipostampa == 3); + const bool dett_cdc = (tipostampa == 2) || (tipostampa == 3); + + desc->add_fielddef(cms.rec_des(), COMMESSE_CODCMS); + if (show_cms_descr) + desc->add_fielddef(cms.rec_des(), COMMESSE_DESCRIZ); + if (show_cms_date) + { + desc->add_fielddef("INIZIO", _datefld); + desc->add_fielddef("FINE", _datefld); + } + if (dett_fasi) + desc->add_fielddef(fasi.rec_des(), FASI_CODFASE); + if (dett_cdc) + desc->add_fielddef(cdc.rec_des(), CDC_CODCOSTO); + desc->add_fielddef("AVRIC", _realfld, 6, 2); + desc->add_fielddef("RICAVI", _realfld, 18, 2); + desc->add_fielddef("INCAR", _realfld, 18, 2); + desc->add_fielddef("CONSUL", _realfld, 18, 2); + desc->add_fielddef("ALTRI", _realfld, 18, 2); + desc->add_fielddef("MATER", _realfld, 18, 2); + desc->add_fielddef("INDIST", _realfld, 18, 2); + desc->add_fielddef("DIPEND", _realfld, 18, 2); + desc->add_fielddef("COSTI", _realfld, 18, 2); + desc->add_fielddef("DIFF", _realfld, 18, 2); + desc->add_fielddef("DIFFPERC", _realfld, 6, 2); + + TString keydef = COMMESSE_CODCMS; + + if (dett_fasi) + keydef << '+' << FASI_CODFASE; + if (dett_cdc) + keydef << '+' << CDC_CODCOSTO; + desc->add_keydef(keydef, true); + if (show_cms_descr) + desc->add_keydef(COMMESSE_DESCRIZ, true); + return desc; } int ca3800(int argc, char* argv[]) { TPrint_bilancio_cms a; - a.run(argc, argv, TR("Stampa bilancio di commessa")); + a.run(argc, argv, a.title()); return 0; } diff --git a/src/ca/ca3800.uml b/src/ca/ca3800.uml index 4bd00e7ad..8e084b427 100755 --- a/src/ca/ca3800.uml +++ b/src/ca/ca3800.uml @@ -1,9 +1,16 @@ #include "ca3883a.h" +#define ALL_EXPORT +#define CLASS_NAME "ca3800" + TOOLBAR "topbar" 0 0 0 2 #include ENDPAGE +TOOLBAR "bottombar" 0 -3 0 1 +#include +ENDPAGE + PAGE "Stampa bilancio commessa" 0 2 0 0 GROUPBOX DLG_NULL 76 5 @@ -71,18 +78,12 @@ END LISTBOX F_TIPOSTAMPA 1 30 BEGIN PROMPT 1 8 "Stampa " - ITEM "0|Normale" - MESSAGE CLEAR,F_FASE|CLEAR,F_CDC - ITEM "1|Dettaglia per Fase" - MESSAGE ENABLE,F_FASE|CLEAR,F_CDC - ITEM "2|Dettaglia per CdC" - MESSAGE CLEAR,F_FASE|ENABLE,F_CDC - ITEM "3|Dettaglia per Fase e CdC" - MESSAGE ENABLE,F_FASE|ENABLE,F_CDC - ITEM "4|Riassuntiva per Fase" - MESSAGE CLEAR,F_FASE|CLEAR,F_CDC - ITEM "8|Riassuntiva per CdC" - MESSAGE CLEAR,F_FASE|CLEAR,F_CDC + ITEM "0|Normale" MESSAGE CLEAR,F_FASE|CLEAR,F_CDC + ITEM "1|Dettaglia per Fase" MESSAGE ENABLE,F_FASE|CLEAR,F_CDC + ITEM "2|Dettaglia per CdC" MESSAGE CLEAR,F_FASE|ENABLE,F_CDC + ITEM "3|Dettaglia per Fase e CdC" MESSAGE ENABLE,F_FASE|ENABLE,F_CDC + ITEM "4|Riassuntiva per Fase" MESSAGE CLEAR,F_FASE|CLEAR,F_CDC + ITEM "8|Riassuntiva per CdC" MESSAGE CLEAR,F_FASE|CLEAR,F_CDC END BOOLEAN F_STAMPA_SINTETICA @@ -115,12 +116,9 @@ END LISTBOX F_TIPOSTIMA 1 30 BEGIN PROMPT 1 11 "Tipo di stima Costi\Ricavi" - ITEM "T|C prev.\R prev. (Tempo)" - MESSAGE SHOW,F_DETR_CONS|ENABLE,F_DETR_CONS|CLEAR,F_INCLUDE_DOCUMENTI - ITEM "C|C cons.\R prev." - MESSAGE SHOW,F_DETR_CONS|ENABLE,F_DETR_CONS|ENABLE,F_INCLUDE_DOCUMENTI - ITEM "R|C cons.\R cons." - MESSAGE CLEAR,F_DETR_CONS|HIDE,F_DETR_CONS|ENABLE,F_INCLUDE_DOCUMENTI + ITEM "T|C prev.\R prev. (Tempo)" MESSAGE SHOW,F_DETR_CONS|ENABLE,F_DETR_CONS|CLEAR,F_INCLUDE_DOCUMENTI + ITEM "C|C cons.\R prev." MESSAGE SHOW,F_DETR_CONS|ENABLE,F_DETR_CONS|ENABLE,F_INCLUDE_DOCUMENTI + ITEM "R|C cons.\R cons." MESSAGE CLEAR,F_DETR_CONS|HIDE,F_DETR_CONS|ENABLE,F_INCLUDE_DOCUMENTI END BOOLEAN F_DETR_CONS @@ -134,25 +132,39 @@ BEGIN GROUP 6 END +STRING F_CONTSEP 6 +BEGIN + PROMPT 1 19 "Cont.separata " + USE &NPENT + INPUT CODTAB F_CONTSEP + DISPLAY "Codice@6" CODTAB + DISPLAY "Descrizione@50" S0 + OUTPUT F_CONTSEP CODTAB + OUTPUT F_DESCONTSEP S0 + CHECKTYPE NORMAL + FIELD CONTSEP + MODULE NP +END + +STRING F_DESCONTSEP 50 48 +BEGIN + PROMPT 25 19 "" + USE &NPENT KEY 2 + INPUT S0 F_DESCONTSEP + DISPLAY "Descrizione@50" S0 + DISPLAY "Codice@6" CODTAB + COPY OUTPUT F_CONTSEP + CHECKTYPE SEARCH + MODULE NP +END + LISTBOX F_DEPTH 1 20 BEGIN - PROMPT 1 19 "Profondita' del piano dei conti da considerare " + PROMPT 1 20 "Profondita' del piano dei conti da considerare " ITEM "1|Gruppo" ITEM "2|Conto" END -STRING F_REPORT 256 64 -BEGIN - PROMPT 1 20 "Report " - FLAGS "B" -END - -STRING DLG_PROFILE 50 -BEGIN - PROMPT 1 -1 "Profilo " - PSELECT -END - ENDPAGE PAGE "Istruzioni" -1 -1 78 20 diff --git a/src/ca/ca3883.cpp b/src/ca/ca3883.cpp index efaa24902..f73e7671a 100755 --- a/src/ca/ca3883.cpp +++ b/src/ca/ca3883.cpp @@ -609,7 +609,13 @@ const TString& TPrint_saldana_recordset::crea_select(const int logicnum) } break; } + if (_contsep.full()) + { + TString clause = SALDANA_CONTSEP; + clause << "=\"" << _contsep << "\""; + ca_append_and(select, clause); + } return get_tmp_string() = select; } @@ -877,8 +883,8 @@ void TPrint_saldana_recordset::elabora_rmovana(TAssoc_array* cms, const TDate& d const TRectype& rec_commesse = cache().get(LF_COMMESSE, codcms); const int indice = ricava_sezione_di_stampa(rec_commesse, datainiesc, datafinesc); - //solo le righe con commessa buona (indice >= 0) vengono considerate - if (indice >= 0) + //solo le righe con commessa buona (indice >= 0) vengono considerate ed eventualmente i movimenti con un codice di contabilità separata specifico + if (indice >= 0 && (movana.get(MOVANA_CONTSEP) == _contsep)) { //ci sono filtri o raggruppamenti per fase o centro di costo? const TString& fase = rmovana.get(RMOVANA_CODFASE); @@ -969,11 +975,13 @@ void TPrint_saldana_recordset::elabora_rmovana(TAssoc_array* cms, const TDate& d rec_commesse.get_date(COMMESSE_PROROGA)); TRectype saldana(LF_SALDANA); + saldana.put(SALDANA_ANNO, _anno); saldana.put(SALDANA_CONTO, conto_anale); saldana.put(SALDANA_COSTO, cdc); saldana.put(SALDANA_COMMESSA, codcms); saldana.put(SALDANA_FASE, fase); + saldana.put(SALDANA_CONTSEP, _contsep); switch(tipomov) { @@ -1712,4 +1720,11 @@ void TPrint_saldana_recordset::set_filter(const TMask& msk, const char * curr_fa break; } */ } + + TEdit_field * csep = (TEdit_field *)msk.find_by_id(F_CONTSEP); + + if (csep != nullptr) + _contsep = csep->get(); + else + _contsep = ""; } diff --git a/src/ca/ca3883.h b/src/ca/ca3883.h index e8a4e370d..0d9b24e43 100755 --- a/src/ca/ca3883.h +++ b/src/ca/ca3883.h @@ -72,6 +72,7 @@ class TPrint_saldana_recordset : public TRecordset TDate _datacalcolo; TString16 _fase; TString80 _cdc; + TString16 _contsep; int _tipo; int _anno; @@ -140,7 +141,7 @@ protected: public: virtual void set_filter(const TMask& msk, const char * curr_fase = "", const char * curr_cdc =""); - TPrint_saldana_recordset(int tipo) : _tipo(tipo) { } + TPrint_saldana_recordset(int tipo, const char * curr_contsep = "") : _tipo(tipo), _contsep(curr_contsep) { } }; #endif diff --git a/src/ca/ca3883a.h b/src/ca/ca3883a.h index b597e9246..33ede49f1 100755 --- a/src/ca/ca3883a.h +++ b/src/ca/ca3883a.h @@ -5,7 +5,6 @@ #define F_RAGSOC 102 #define F_DATASTAMPA 103 #define F_ESERCIZIO 104 -#define F_REPORT 105 #define F_INIZIO_ES 106 #define F_FINE_ES 107 #define F_TIPOSTIMA 108 @@ -23,6 +22,9 @@ #define F_STAMPA_SINTETICA 119 #define F_INTESTAZIONE_MINIMA 120 +#define F_CONTSEP 122 +#define F_DESCONTSEP 123 + /* campi per la generazione automatica #define F_FASE1 112 #define F_FASE2 113 diff --git a/src/ca/calib01.cpp b/src/ca/calib01.cpp index da1d2b990..ed58b7906 100755 --- a/src/ca/calib01.cpp +++ b/src/ca/calib01.cpp @@ -2276,7 +2276,7 @@ const char * TAnal_mov::row_code(int row) const } return get_tmp_string() = code; } -void TAnal_mov::saldo_set_reset(const TRectype& row, bool reset) +void TAnal_mov::saldo_set_reset(const TRectype& row, const char * contsep, bool reset) { const int dec = TCurrency::get_firm_dec(); const TImporto imp_row(row.get_char(RMOVANA_SEZIONE), row.get_real(RMOVANA_IMPORTO)); @@ -2288,6 +2288,8 @@ void TAnal_mov::saldo_set_reset(const TRectype& row, bool reset) annies.add(esc_iniziale); const char tipomov = get_char(MOVANA_TIPOMOV); + if (*contsep != '\0' && tipomov != '\0') + int i = 1; // i movimenti analitici possono avere una data di scadenza come la mozzarella const TDate datacomp = get_date(MOVANA_DATACOMP); TDate datafcomp = get_date(MOVANA_DATAFCOMP); @@ -2315,12 +2317,14 @@ void TAnal_mov::saldo_set_reset(const TRectype& row, bool reset) } TToken_string key; + key.add(tipomov); key.add(esc_iniziale); key.add(row.get(RMOVANA_CODCCOSTO)); key.add(row.get(RMOVANA_CODCMS)); key.add(row.get(RMOVANA_CODFASE)); key.add(row.get(RMOVANA_CODCONTO)); + key.add(contsep); if (annies.items() > 1) //saldi spammati su piu' anni { @@ -2418,10 +2422,14 @@ void TAnal_mov::load_saldi(bool reset) } const TRecord_array& a = body(LF_RMOVANA); + TString contsep = get(MOVANA_CONTSEP); + for (int i = a.last_row(); i > 0; i--) { const TRectype& row = a[i]; - saldo_set_reset(row, reset); //aggiunge o toglie la riga corrente ai saldi in memoria + saldo_set_reset(row, "", reset); //aggiunge o toglie la riga corrente ai saldi in memoria + if (contsep.full()) + saldo_set_reset(row, contsep, reset); //aggiunge o toglie la riga corrente ai saldi in memoria con contabilità separata } } @@ -2469,6 +2477,7 @@ bool TAnal_mov::save_saldi(const int annoes) saldi.put(SALDANA_COMMESSA, key.get(3)); saldi.put(SALDANA_FASE, key.get(4)); saldi.put(SALDANA_CONTO, key.get(5)); + saldi.put(SALDANA_CONTSEP, key.get(6)); int err = saldi.read(_isequal, _lock); if (err != NOERR) @@ -2484,6 +2493,7 @@ bool TAnal_mov::save_saldi(const int annoes) saldi.put(SALDANA_COMMESSA, key.get(3)); saldi.put(SALDANA_FASE, key.get(4)); saldi.put(SALDANA_CONTO, key.get(5)); + saldi.put(SALDANA_CONTSEP, key.get(6)); err = saldi.write(); if (err != NOERR) cantwrite_box(saldi.name()); @@ -3068,7 +3078,7 @@ TObject* TCache_ripartizioni::key2obj(const char* key) TRectype & rec = (*rip)[i]; const TAnal_bill bill(rec); //calcola il saldo usando come parametri (cms/cdc/fsc/conto) quelli che trova sulla riga di ripartizione - const TSaldanal& s = ca_saldo(bill, _dal, _al, _saldanal_consuntivo); + const TSaldanal& s = ca_saldo(bill, "", _dal, _al, _saldanal_consuntivo); // qui //in base a C/R stabilisce quali saldi considerare e in quale sezione normalizzare real val; if (sezione_di_riferimento == 'R') //in Ricavi normalizza in Avere diff --git a/src/ca/calib01.h b/src/ca/calib01.h index 5a152cbdb..cd2b87f4a 100755 --- a/src/ca/calib01.h +++ b/src/ca/calib01.h @@ -188,7 +188,7 @@ class TAnal_mov : public TMultiple_rectype TAssoc_array _saldind; protected: - void saldo_set_reset(const TRectype& row, bool reset); + void saldo_set_reset(const TRectype& row, const char * contsep, bool reset); void load_saldi(bool reset); void kill_saldi() { _saldi.destroy(); } void update_saldi(bool kill); diff --git a/src/ca/calib02.cpp b/src/ca/calib02.cpp index c016c1933..348a4c6ab 100755 --- a/src/ca/calib02.cpp +++ b/src/ca/calib02.cpp @@ -163,7 +163,7 @@ const TVariant& TPconana_recordset::get(const char* field) const } ((TAnal_bill&)_bill).set_conto(get(PCONANA_CODCONTO).as_string()); - const TSaldanal& s = ca_saldo(_bill, _dal, _al, tipimov); + const TSaldanal& s = ca_saldo(_bill, "", _dal, _al, tipimov); //qui TVariant& var = get_tmp_var(); if (sub_field == "INI_DARE") @@ -250,12 +250,15 @@ bool TPconana_recordset::valid_record(const TRelation& rel) const conto = curr.get(PCONANA_CODCONTO); if (conto.len() <= _conto_minlen) return false; - } + if (_contsep.full() && _contsep != cache().get(LF_MOVANA, curr.get(RMOVANA_NUMREG), MOVANA_CONTSEP)) + return false; + } - if (_movimentati || _nonnulli) + + if (_movimentati || _nonnulli) { ((TAnal_bill&)_bill).set_conto(conto); - const TSaldanal& s = ca_saldo(_bill, _dal, _al, _tipimov); + const TSaldanal& s = ca_saldo(_bill, _contsep, _dal, _al, _tipimov); if (_movimentati && !s._movimentato) return false; if (_nonnulli && s._fin.is_zero()) @@ -324,7 +327,7 @@ void TPconana_recordset::set_tipo(char tipo) void TPconana_recordset::set_filter(char tipo, const char* da_conto, const char* a_conto, const char* costo, const char* commessa, const char* fase, - const TDate& dal, const TDate& al, + const char * contsep, const TDate& dal, const TDate& al, word tipimov, bool movimentati, bool nonnulli) { set_tipo(tipo); @@ -343,6 +346,7 @@ void TPconana_recordset::set_filter(char tipo, const char* da_conto, const char* _bill.set_costo(costo); _bill.set_commessa(commessa); _bill.set_fase(fase); + _contsep = contsep; } TPconana_recordset::TPconana_recordset(char tipo) : TISAM_recordset("USE PCONANA") @@ -771,7 +775,7 @@ protected: bool saldi(const TAnal_bill& bill, const TDate& dal, const TDate& al, word tipo, TSaldanal& s); public: - const TSaldanal& saldo(const TAnal_bill& bill, const TDate& dal, const TDate& al, word tipi = 0x1); + const TSaldanal& saldo(const TAnal_bill& bill, const char * contsep, const TDate& dal, const TDate& al, word tipi = 0x1); TSaldi_cache(); }; @@ -1108,7 +1112,7 @@ TObject* TSaldi_cache::key2obj(const char* key) return s; } -const TSaldanal& TSaldi_cache::saldo(const TAnal_bill& bill, const TDate& dal, const TDate& al, word tipi) +const TSaldanal& TSaldi_cache::saldo(const TAnal_bill& bill, const char * contsep, const TDate& dal, const TDate& al, word tipi) { TToken_string key; key.add(bill.conto(), 0); @@ -1118,6 +1122,7 @@ const TSaldanal& TSaldi_cache::saldo(const TAnal_bill& bill, const TDate& dal, c key.add(dal, 4); key.add(al, 5); key.add(tipi, 6); + key.add(contsep, 7); return *(const TSaldanal*)objptr(key); } @@ -1125,7 +1130,7 @@ const TSaldanal& TSaldi_cache::saldo(const TAnal_bill& bill, const TDate& dal, c TSaldi_cache::TSaldi_cache() : TCache(3881) // Numero primo { } -const TSaldanal& ca_saldo(const TAnal_bill& bill, const TDate& dal, const TDate& al, word tipi) +const TSaldanal& ca_saldo(const TAnal_bill& bill, const char * contsep, const TDate& dal, const TDate& al, word tipi) { static TSaldi_cache* cache = nullptr; @@ -1133,7 +1138,7 @@ const TSaldanal& ca_saldo(const TAnal_bill& bill, const TDate& dal, const TDate& SAFE_DELETE(cache); if (cache == nullptr) cache = new TSaldi_cache; - return cache->saldo(bill, dal, al, tipi); + return cache->saldo(bill, contsep, dal, al, tipi); } @@ -1247,6 +1252,22 @@ void TAnal_report_mask::create_sheet(short sheet_id) } } +const TString& TAnal_report_mask::get_report_class() const +{ + TReport_select * rs = (TReport_select *)efield(DLG_REPORT).browse(); + + return rs->get_report_class(); +} + +void TAnal_report_mask::set_report_class() const +{ + TReport_select * rs = (TReport_select *)efield(DLG_REPORT).browse(); + + if (rs != nullptr) + rs->set_report_class(get_report_class()); + +} + int TAnal_report_mask::get_row_bill(TSheet_field& sf, int r, TAnal_bill& bill) { int flag = 0; diff --git a/src/ca/calib02.h b/src/ca/calib02.h index 1e535312c..be866e681 100755 --- a/src/ca/calib02.h +++ b/src/ca/calib02.h @@ -91,7 +91,7 @@ public: /////////////////////////////////////////////////////// // Metodi sciolti ma decisivi /////////////////////////////////////////////////////// -const TSaldanal& ca_saldo(const TAnal_bill& bill, const TDate& dal, const TDate& al, word tipi = _saldanal_consuntivo); +const TSaldanal& ca_saldo(const TAnal_bill& bill, const char * contsep, const TDate& dal, const TDate& al, word tipi = _saldanal_consuntivo); TImporto ca_get_imp(const TRecordset& rs, const char* sez, const char* imp); @@ -103,7 +103,7 @@ class TPconana_recordset : public TISAM_recordset { char _tipo; word _tipimov; - TString _da_conto, _a_conto; + TString _da_conto, _a_conto, _contsep; int _conto_minlen; TAnal_bill _bill; TDate _dal, _al; @@ -124,7 +124,7 @@ public: void set_tipo(char tipo); void set_filter(char tipo, const char* da_conto, const char* a_conto, const char* costo, const char* commessa, const char* fase, - const TDate& dal, const TDate& al, + const char * contsep, const TDate& dal, const TDate& al, word tipimov, bool movimentati, bool nonnulli); TPconana_recordset(char tipo = ' '); }; @@ -165,10 +165,12 @@ class TAnal_report_mask : public TAutomask protected: void create_sheet(short sheet_id); int create_sheet_fields(short sheet_id, int lf, int& y, short& dlg); + virtual void set_report_class() const; virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly); public: + virtual const TString& get_report_class() const; int get_row_bill(TSheet_field& sf, int r, TAnal_bill& bill); int set_row_bill(TSheet_field& sf, int r, const TAnal_bill& bill); bool esistono_riclassificazioni() const; diff --git a/src/ca/f151.dir b/src/ca/f151.dir index 73d90d980..9cbcb5896 100755 --- a/src/ca/f151.dir +++ b/src/ca/f151.dir @@ -1,3 +1,3 @@ 151 0 -$saldana|0|0|189|0|Saldi contabilita' analitica||| +$saldana|0|0|195|0|Saldi contabilita' analitica||| diff --git a/src/ca/f151.trr b/src/ca/f151.trr index c6ee66297..a08ebb9df 100755 --- a/src/ca/f151.trr +++ b/src/ca/f151.trr @@ -1,10 +1,11 @@ 151 -17 +18 ANNO|9|4|0|Codice esercizio COSTO|1|20|0|Centro Di costo COMMESSA|1|20|0|Commessa FASE|1|10|0|Fase CONTO|1|20|0|Conto +CONTSEP|1|6|0|Contabilità separata SEZIONE|7|1|0|Sezione (Normale) SALDO|4|18|3|Saldo (Normale) SEZIONEP|7|1|0|Sezione (Preventivo) @@ -18,5 +19,5 @@ SALDOIV|4|18|3|Saldo Indiretto (Preventivo) SEZIONEIP|7|1|0|Sezione Indiretto (Variazione Preventivo) SALDOIP|4|18|3|Saldo Indiretto (Variazione Preventivo) 2 -ANNO+CONTO+COSTO+COMMESSA+FASE| -CONTO+ANNO+COSTO+COMMESSA+FASE| +ANNO+CONTO+COSTO+COMMESSA+FASE+CONTSEP| +CONTO+ANNO+COSTO+COMMESSA+FASE+CONTSEP|X diff --git a/src/ca/saldana.h b/src/ca/saldana.h index dd1d740f4..568944bcf 100755 --- a/src/ca/saldana.h +++ b/src/ca/saldana.h @@ -6,6 +6,7 @@ #define SALDANA_COMMESSA "COMMESSA" #define SALDANA_FASE "FASE" #define SALDANA_CONTO "CONTO" +#define SALDANA_CONTSEP "CONTSEP" #define SALDANA_SEZIONE "SEZIONE" #define SALDANA_SALDO "SALDO" diff --git a/src/ce/ce1300.cpp b/src/ce/ce1300.cpp index 6013eb60f..43bd53d71 100755 --- a/src/ce/ce1300.cpp +++ b/src/ce/ce1300.cpp @@ -230,9 +230,9 @@ bool TSelam_qmask::on_field_event(TOperable_field& o, TField_event e, long jolly const TRectype & ammce = cache().get(LF_AMMCE, key); if (!ammce.empty()) { - if (ammce.get_bool(AMMCE_FZPER) == TRUE) + if (ammce.get_bool(AMMCE_FZPER)) return error_box(TR("Sul cespite sono state forzate le Percentuali:\nprocedere dalla forzatura ammortamenti su cespite")); - if (ammce.get_bool(AMMCE_FZQUO) == TRUE) + if (ammce.get_bool(AMMCE_FZQUO)) return error_box(TR("Sul cespite sono state forzate le Quote:\nprocedere dalla forzatura ammortamenti su cespite")); } diff --git a/src/ce/ce2100.cpp b/src/ce/ce2100.cpp index 8e92d11f9..0f628d881 100755 --- a/src/ce/ce2100.cpp +++ b/src/ce/ce2100.cpp @@ -120,6 +120,7 @@ bool TCalcamm::calcola_ammortamenti() break; TCespite cespite(cur.curr()); + for (int tipo_sit = 1; tipo_sit <= 3; tipo_sit++) cespite.calc_amm(tipo_sit, data_limite, true); } diff --git a/src/ce/ce3900.cpp b/src/ce/ce3900.cpp index fafd6d453..30ef0d184 100755 --- a/src/ce/ce3900.cpp +++ b/src/ce/ce3900.cpp @@ -31,14 +31,15 @@ //////////////////////////////////////////////////////// class TStampa_sintetica_mask : public TAutomask { - bool _preview; +// bool _preview; bool _excel; protected: bool on_field_event(TOperable_field& o, TField_event e, long jolly); public: - bool preview() const { return _preview; } - bool excel() const { return _excel; } +// bool preview() const { return _preview; } + bool excel() const { return _excel; } + void set_excel(bool on) { _excel = on; } TStampa_sintetica_mask(); }; @@ -82,19 +83,19 @@ bool TStampa_sintetica_mask::on_field_event(TOperable_field& o, TField_event e, } } break; - case DLG_PRINT: +/* case DLG_PRINT: if (e == fe_button) { - _preview = false; - _excel = false; +// _preview = false; +// _excel = false; } break; case DLG_PREVIEW: if (e == fe_button) { - _preview = true; - _excel = false; - stop_run(K_ENTER); +// _preview = true; +// _excel = false; +// stop_run(K_ENTER); } break; case DLG_EXPORT_EXCEL: @@ -103,13 +104,13 @@ bool TStampa_sintetica_mask::on_field_event(TOperable_field& o, TField_event e, _excel = true; stop_run(K_ENTER); } - break; + break; */ default: break; } return ok; } -TStampa_sintetica_mask::TStampa_sintetica_mask() : TAutomask("ce3900"), _preview(false), _excel(false) +TStampa_sintetica_mask::TStampa_sintetica_mask() : TAutomask("ce3900"), _excel(false) //, _preview(false) { } @@ -201,10 +202,10 @@ void TStampa_sintetica_rep::set_filter(const TStampa_sintetica_mask& msk) const bool shimp = (!msk.excel()) && msk.get_bool(F_TOTIMP); const bool shloc = (!msk.excel()) && msk.get_bool(F_TOTLOC); - section('H', 2).show(shcat); section('H', 3).show(shimp); section('H', 4).show(shloc); section('F', 2).show(shcat); + section('H', 2).show(shcat); section('F', 3).show(shimp); section('F', 4).show(shloc); @@ -396,10 +397,12 @@ protected: void TStampa_sintetica::main_loop() { TStampa_sintetica_mask mask; + KEY k; // mask.set(F_CALCOLO, "X"); - while (mask.run() == K_ENTER) + while ((k = mask.run()) != K_QUIT) { + mask.set_excel(k == K_EXCEL); // Esecuzione calcolo globale if (mask.get_bool(F_CALCOLO)) { @@ -427,7 +430,7 @@ void TStampa_sintetica::main_loop() book.export_excel(out, false, true, true); } else - if (mask.preview()) + if (k == K_VISUALIZE) book.preview(); else book.print(); diff --git a/src/cg/cg0800a.uml b/src/cg/cg0800a.uml index 3043f0279..bb593e203 100644 --- a/src/cg/cg0800a.uml +++ b/src/cg/cg0800a.uml @@ -1,6 +1,7 @@ #include "cg0800a.h" TOOLBAR "topbar" 0 0 0 2 + BUTTON DLG_PRINT 2 2 BEGIN PROMPT 1 1 "Stampa" diff --git a/src/cg/cg2100.cpp b/src/cg/cg2100.cpp index 97cd86a06..4d3f2cbc2 100755 --- a/src/cg/cg2100.cpp +++ b/src/cg/cg2100.cpp @@ -59,7 +59,7 @@ public: TPrimanota_application::TPrimanota_application() : _rel(nullptr), _mode(0), _iva(nessuna_iva), _causale(nullptr), _giornale(nullptr), _lastreg(0), _last_dreg(TODAY), _last_dcom(TODAY), _automatico(nullptr), _swap_mask(false), _is_set_fpcheck(false), _f1_ini(false), _f1_liq(false), - _skip_giornale_check(false), _skip_bollato_check(false) + _skip_giornale_check(false), _skip_bollato_check(false), _pro_mask(nullptr) { memset(_msk, 0, sizeof(_msk)); } @@ -439,7 +439,7 @@ bool TPrimanota_application::read_caus(const char* cod, int year) } const char sezione = rcaus->get_char(RCA_SEZIONE); - const TImporto zero('D', ZERO); + TImporto zero('D', ZERO); const TString80 desc(causale().desc_agg(i)); if (nriga == 1) m->set(F_DESCR, desc); @@ -697,7 +697,7 @@ void TPrimanota_application::init_mask(TMask& m) _sal_dirty = false; // Azzero il flag di modifica del saldaconto fill_sheet(m); // Riempe righe contabili coi conti della causale m.hide(F_LINKDOC); - set_has_f1_db(&m); + has_f1_db(m); } void TPrimanota_application::init_query_mode(TMask& m) @@ -736,7 +736,7 @@ void TPrimanota_application::init_query_mode(TMask& m) m.set(F_CODCAUS, ini.get(MOV_CODCAUS)); m.send_key(K_SPACE, DLG_NEWREC); } - set_has_f1_db(&m); + has_f1_db(m); } @@ -1491,18 +1491,14 @@ void TPrimanota_application::check_saldi() void TPrimanota_application::write_fppro() { -#ifdef DBG - if (!ini_get_bool(CONFIG_INSTALL, "Main", "SkipFPPRO")) + if (main_app().has_module(FPAUT) && !ini_get_bool(CONFIG_INSTALL, "Main", "SkipFPPRO")) { -#endif // Controllo se la registrazione ha avuto effetto anche su FPPRO allora salvo riferimento sul mov if (save_fppro() > 0 && !save_dbmov()) message_box( "ATTENZIONE: non e' stato possibile salvare i riferimenti del documento in ingresso per questo movimento.\n" "Movimento registrato senza collegamento ai documenti in ingresso."); -#ifdef DBG } -#endif } bool TPrimanota_application::has_tot_doc(TToken_string& fppro_keys) @@ -1559,7 +1555,7 @@ void TPrimanota_application::set_movcoll(const long movcoll, const long numreg) } int TPrimanota_application::controlli_f1(const TMask& m) { - if (m.find_by_id(F_PROKEY) != nullptr && m.get(F_PROKEY).full() && has_f1_db((TMask*)&m) && fp_db().sq_is_connect() && check_causale(m.get(F_CODCAUS))) + if (iva_mask(m) && m.get(F_PROKEY).full() && has_f1_db(m) && fp_db().sq_is_connect() && check_causale(m.get(F_CODCAUS))) { TToken_string keys(m.get(F_PROKEY), ';'); const TDate dataoraric = fppro_db().set_keys(keys).get_dataorarioric(); @@ -1787,7 +1783,7 @@ void TPrimanota_application::clean_fppro() // Controlli: solo in mod modifica; che abbia fp-f1 (no F8); che non sono in salvataggio if (_mode != MODE_MOD - || !has_f1_db(&msk) + || !has_f1_db(msk) || last_key != K_DEL && last_key != K_SAVE && last_key != K_ELIMMAS && last_key != K_QUIT && !scollega()) return; @@ -1802,27 +1798,17 @@ void TPrimanota_application::clean_fppro() fp_db().sq_commit(); } -void TPrimanota_application::set_has_f1_db(TMask* m) +bool TPrimanota_application::has_f1() const { - if (m->find_by_id(F_DATAREG) != nullptr && !m->get(F_DATAREG).empty()) - { - if (TDate(m->get(F_DATAREG)) >= TDate(get_data_start_fatt())) - _isf1 = has_module(F1AUT) && !get_db_indirizzo().empty(); - else - _isf1 = false; - _is_set_fpcheck = true; - } - else if (!_is_set_fpcheck) - { - _isf1 = false; - _is_set_fpcheck = true; - } + return has_module(F1AUT) && get_db_indirizzo().full(); } -bool TPrimanota_application::has_f1_db(TMask* m) +bool TPrimanota_application::has_f1_db(const TMask & m) { - set_has_f1_db(m); - return _isf1; + const TDate datareg = m.get_date(F_DATAREG); + + _is_set_fpcheck = true; + return datareg.ok() && (datareg >= get_data_start_fatt()) && has_f1(); } bool TPrimanota_application::remove() @@ -2671,7 +2657,7 @@ int TPrimanota_application::save_fppro() TMask& msk = curr_mask(); // Provo a vedere se hanno l'FP: se c'è l'indirizzo controllo che non sia F8 se non c'è non hanno l'FP - if (!has_f1_db(&msk)) + if (!has_f1_db(msk)) return pro_nofp; // Anzitutto guardo la modalita' in cui sono @@ -2736,7 +2722,7 @@ int TPrimanota_application::save_fppro() items = fp_db().sq_items(); } - if(has_f1_db(&msk) && items != 1) + if(has_f1_db(msk) && items != 1) { const bool forza = noyes_box("Attenzione, al movimento non e' stato abbinato nessun documento elettronico.\n" "Per consentire una corretta archiviazione sostitutiva si consiglia di provvedere al controllo della registrazione e di procedere\n" @@ -2850,6 +2836,7 @@ bool TPrimanota_application::link_intra(const TMask& m, const char* action) const BOOLEAN bModify = xvt_str_same(action, "Modify"); + TFilename intrini; intrini.tempdir(); intrini.add("ActIntra.ini"); diff --git a/src/cg/cg2100t.uml b/src/cg/cg2100t.uml index ec4eb71cd..96590a6a6 100644 --- a/src/cg/cg2100t.uml +++ b/src/cg/cg2100t.uml @@ -13,12 +13,14 @@ BEGIN PROMPT 2 1 "Contabilizzaz." PICTURE TOOL_EXPORT MODULE F1 + MESSAGE EXIT,K_ENTER END BUTTON DLG_LINK 2 2 BEGIN PROMPT 3 1 "Collega in Prima nota" PICTURE TOOL_LINK + MESSAGE EXIT,K_ENTER END BUTTON DLG_QUIT 2 2 diff --git a/src/cg/cg2102.cpp b/src/cg/cg2102.cpp index d333ceab7..c85df071d 100755 --- a/src/cg/cg2102.cpp +++ b/src/cg/cg2102.cpp @@ -219,7 +219,10 @@ TSheet_field& TPrimanota_application::cgs() const void TPrimanota_application::set_cgs_imp(int n, const TImporto& imp) { TSheet_field& s = cgs(); - imp.add_to(s.row(n), 0); + TImporto i(imp); + + i.normalize(); + i.add_to(s.row(n), 0); s.force_update(n); } @@ -371,7 +374,7 @@ void TPrimanota_application::reset_sheet_row(TSheet_field& s, int n) s.destroy(n); // Remove line n } -int TPrimanota_application::set_cgs_row(int n, const TImporto& imp, +int TPrimanota_application::set_cgs_row(int n, TImporto& importo, const TBill& conto, const char* desc, char tipo, const char* cms, const char* fas) { @@ -380,7 +383,8 @@ int TPrimanota_application::set_cgs_row(int n, const TImporto& imp, TToken_string& row = cg.row(n); row.cut(0); - imp.add_to(row, 0); + importo.normalize(); + importo.add_to(row, 0); row.add(conto.string(0x3)); row.add(""); // Codice decrizione row.add(desc); // Descrizione aggiuntiva @@ -1536,7 +1540,7 @@ void TPrimanota_application::add2cg_row(TSheet_field& s, TToken_string & row, TS { const TBill conto(row, cid2index(IVA_TIPO), 0x1); const int pos = bill2pos(conto, cgrowtype_imponibile); // Riga in cui andra' l'imponibile - const TImporto imp = a.real2imp(d > 0 ? imp_det : imp_ind, tipod); // Imponibile + TImporto imp = a.real2imp(d > 0 ? imp_det : imp_ind, tipod); // Imponibile if (pos >= 0) // Se il conto esisteva anche prima ... { @@ -1761,7 +1765,7 @@ bool TPrimanota_application::iva_notify(TSheet_field& s, int r, KEY k) real pimponibile(pag.imponibile(inv)); pimponibile.round(pag.round(inv)); - if ((pimposta != imposta || pimponibile != imponibile) && (!a._f1_ini && (a._pro_mask == nullptr || !a._pro_mask->should_bring_back()))) + if ((pimposta != imposta || pimponibile != imponibile) && (!a._f1_ini && (a._pro_mask == nullptr || !a._pro_mask->da_riportare()))) a.set_scadenze(m); // Ricalcola rate } } @@ -2842,7 +2846,7 @@ void TPrimanota_application::add_cgs_tot(TMask& m) TImporto imp = real2imp(m.get_real(F_TOTALE), cgrowtype_totale); - set_cgs_row(riga_totale, imp.normalize(), nuovo, descr, cgrowtype_totale); + set_cgs_row(riga_totale, imp, nuovo, descr, cgrowtype_totale); } calcola_imp(); // Ricalcola totale IVA calcola_saldo(); // Ricalcola sbilanci @@ -3550,21 +3554,11 @@ HIDDEN void inventa_cambio_intra(TMask& m) { const TString& codval = m.get(F_VALUTAINTRA); - if (codval.not_empty() && TCurrency::get_firm_val() != codval) + if (codval.full() && TCurrency::get_firm_val() != codval) { - TTable cam("CAM"); + const TRectype & cam =cache().get("CAM", codval); - cam.put("CODTAB", codval); - const int err = cam.read(_isgteq); - bool yes = err != NOERR; - if (!yes) - { - TString16 v = cam.get("CODTAB"); - - v.cut(3).rtrim(); - yes = v != codval; - } - if (yes) + if (cam.full()) m.set(F_CAMBIOINTRA, cache().get("%VAL", codval, "S4")); } } @@ -3891,71 +3885,74 @@ bool TPrimanota_application::quadratura_handler(TMask_field& f, KEY key) return true; } -void TPrimanota_application::write_righe_iva_f1(TMask& cg_msk, const shared_ptr& msk) + +void TPrimanota_application::write_righe_iva_f1(TMask& cg_msk, const TPro_msk & msk) { TSheet_field& sf = cg_msk.sfield(F_SHEETIVA); - const vector& righe = msk->get_righeiva(); - int i = 0; + const TString_array& righe = msk.get_righeiva(); - for (auto it = righe.begin(); it != righe.end(); ++it) + FOR_EACH_ARRAY_ITEM( righe, r, obj) { - if(it->imponibile != 0 || it->imposta != 0) - { - TToken_string& row = sf.row(i); + TToken_string & riga = STRING_TOKEN(obj); + const real imponibile = riga.get_real(FPRI_IMPONIBILE); + const real imposta = riga.get_real(FPRI_IMPOSTA); - sf.notify(i, K_SPACE); - row.add(it->imponibile, cid2index(IVA_IMPONIBILE)); - row.add(it->imposta, cid2index(IVA_IMPOSTA)); - row.add(it->aliquota, cid2index(IVA_PERCIVA)); - row.add(it->natura, cid2index(IVA_NATURIVA)); - sf.notify(i, K_ENTER); - i++; + if(imponibile != ZERO || imposta != ZERO) + { + TToken_string& row = sf.row(r); + + sf.notify(r, K_SPACE); + sf.set_row_cell(IVA_IMPONIBILE, imponibile, r); + sf.set_row_cell(IVA_IMPOSTA, imposta, r); + sf.set_row_cell(IVA_PERCIVA, riga.get(FPRI_ALIQUOTA), r); + sf.set_row_cell(IVA_NATURIVA, riga.get(FPRI_NATURA), r); + sf.notify(r, K_ENTER); } } } -bool TPrimanota_application::write_scad_f1(const TMask& cg_msk, const shared_ptr& msk) +bool TPrimanota_application::write_scad_f1(const TMask& cg_msk, const TPro_msk & msk) { TSheet_field& sf = cg_msk.sfield(FS_RATESHEET); const int items = sf.items(); - const vector& righe = msk->get_scadenze(); - int i = 0; + const TString_array & righe = msk.get_scadenze(); - for (auto it = righe.begin(); it != righe.end(); ++it, ++i) + FOR_EACH_ARRAY_ITEM(righe, r, obj) { - TToken_string& row = app().pags().row(i); + TToken_string& row = app().pags().row(r); + TToken_string & riga = STRING_TOKEN(obj); - if(i >= items) - pag_notify(sf, i, K_CTRL+K_INS); - pag_notify(sf, i, K_SPACE); - row.add(it->data, cid2index(101)); - row.add(it->importo, cid2index(102)); - pag_notify(sf, i, K_ENTER); + if (r >= items) + pag_notify(sf, r, K_CTRL+K_INS); + pag_notify(sf, r, K_SPACE); + sf.set_row_cell(101, riga.get_date(FPSC_DATA), r); + sf.set_row_cell(102, riga.get_real(FPSC_IMPORTO), r); + pag_notify(sf, r, K_ENTER); } - return !righe.empty(); + return righe.items() > 0; } -void TPrimanota_application::write_clifo(TMask& cg_msk, const shared_ptr& msk) +void TPrimanota_application::write_clifo(TMask& cg_msk, const TPro_msk & msk) { bool ok = false; TLocalisamfile clifo(LF_CLIFO); - TToken_string keys(msk->get_fpprokeys(), ';'); - TString codforn = TFppro(keys).get_codforn(); + TToken_string keys(msk.get_fpprokeys(), ';'); + long codforn = TFppro(keys).get_codforn(); - if (codforn.empty()) - codforn = msk->get_codforn(); - if (codforn.empty()) + if (codforn == 0L) + codforn = msk.get_codforn(); + if (codforn == 0L) { clifo.setkey(5); clifo.put(CLI_TIPOCF, "F"); - clifo.put(CLI_PAIV, msk->get_piva()); + clifo.put(CLI_PAIV, msk.get_piva()); clifo.read(); - ok = clifo.get(CLI_PAIV) == msk->get_piva(); + ok = clifo.get(CLI_PAIV) == msk.get_piva(); if(!ok) { clifo.zero(); clifo.setkey(5); clifo.put(CLI_TIPOCF, "F"); - clifo.put(CLI_PAIV, msk->get_piva()); + clifo.put(CLI_PAIV, msk.get_piva()); clifo.put(CLI_STATOPAIV, "IT"); clifo.read(); } @@ -3967,8 +3964,8 @@ void TPrimanota_application::write_clifo(TMask& cg_msk, const shared_ptrget_piva(); - if (ok && (cg_msk.get(F_CODCLIFOR).empty() || cg_msk.get(F_CODCLIFOR) != codforn)) + ok = clifo.get(CLI_PAIV) == msk.get_piva(); + if (ok && (cg_msk.get_long(F_CODCLIFOR) == 0 || cg_msk.get_long(F_CODCLIFOR) != codforn)) { cg_msk.set(F_CODCLIFOR, clifo.get(CLI_CODCF)); cg_msk.set(F_RAGSOCCF, clifo.get(CLI_RAGSOC)); @@ -3976,20 +3973,21 @@ void TPrimanota_application::write_clifo(TMask& cg_msk, const shared_ptr& msk) +void TPrimanota_application::set_totale(TMask& cg_msk, TPro_msk & msk) { - real totale = msk->get_totdoc(); + real totale = msk.get_totdoc(); - if(totale == ZERO) + if (totale == ZERO) totale = app().calcola_imp(); - const real rit = msk->get_ritenute(); + const real rit = msk.get_ritenute(); if (rit != ZERO) { @@ -3997,18 +3995,19 @@ void TPrimanota_application::set_totale(TMask& cg_msk, const shared_ptris_doc_split()) - totale = msk->get_tot_imp_riva(); + else + if (msk.is_doc_split()) + totale = msk.get_tot_imp_riva(); cg_msk.set(F_TOTALE, totale); } -void TPrimanota_application::riporta_dati_f1(TMask& cg_msk, const shared_ptr& msk) +void TPrimanota_application::riporta_dati_f1(TMask& cg_msk, TPro_msk & msk) { - const bool bring = msk->should_bring_back(); + const bool bring = msk.da_riportare(); if (bring) { - if (msk->get_numdoc().full() && cg_msk.get(F_CODCLIFOR).empty()) + if (msk.get_numdoc() != 0L && cg_msk.get(F_CODCLIFOR).empty()) write_clifo(cg_msk, msk); write_righe_iva_f1(cg_msk, msk); set_totale(cg_msk, msk); @@ -4019,57 +4018,57 @@ void TPrimanota_application::riporta_dati_f1(TMask& cg_msk, const shared_ptrget_numdoc()); - cg_msk.set(F_NUMDOC, msk->get_numdoc().right(7)); + + cg_msk.set(F_NUMDOCEXT, format("%ld", msk.get_numdoc())); + cg_msk.set(F_NUMDOC, format("%-7ld", msk.get_numdoc())); } if (bring || cg_msk.get(F_DATADOC).empty()) - cg_msk.set(F_DATADOC, msk->get_datadoc()); + cg_msk.set(F_DATADOC, msk.get_datadoc()); } -void TPrimanota_application::insert_part_scad(TConfig& ini) +void TPrimanota_application::insert_part_scad(TConfig& ini) // che cazzo significa la partita 73/001 { - vector rif_doc; - int i = 0; - ini.set_paragraph("23"); + TArray rif_doc; + TString str = ini.get("NUMLINEA", "23", 0); // Carico nel vettore - while(true) + for (int i = 0; str.full(); str = ini.get("NUMLINEA", "23", ++i)) { TToken_string doc("", '|'); - TString str; str << ini.get("NUMLINEA", nullptr, i, "NULL"); - if (str != "NULL") - { - doc.add(str); - doc.add(ini.get("DOCRIF", nullptr, i, "NULL")); - doc.add(ini.get("DATADOCRIF", nullptr, i, "NULL")); - rif_doc.insert(rif_doc.end(), doc); - i++; - } - else - break; + doc.add(str); + doc.add(ini.get("DOCRIF", "23", i)); + doc.add(ini.get("DATADOCRIF", "23", i)); + rif_doc.add(doc); } // Agganciare alla partita del documento di riferimento - if(!rif_doc.empty()) + if(rif_doc.items() > 0) { is_f1() = true; TString query; query << "USE MOV\nSELECT (DATADOC==#DATADOC)"; TISAM_recordset rec(query); - rec.set_var("#DATADOC", TVariant(TDate(rif_doc[0].get(2)))); TString part; - do - { - if (rec.get(MOV_NUMDOC).as_string() == "73/001") - { - part = rec.get(MOV_PROTIVA).as_string(); - break; - } - } while (rec.move_next()); - num_doc_rif() = part; + FOR_EACH_ARRAY_ITEM(rif_doc, r, _obj) + { + if (part.blank()) + { + rec.set_var("#DATADOC", ((TToken_string&)rif_doc[0]).get_date(2)); + + for (bool ok = rec.move_first(); ok; ok = rec.move_next()) + { + if (rec.get_string(MOV_NUMDOC) == "73/001") + { + part = rec.get_string(MOV_PROTIVA); + break; + } + } while (rec.move_next()); + } + } + _num_doc_rif_partite = part; } } @@ -4080,9 +4079,10 @@ bool TPrimanota_application::fppro_mask(TMask_field& f, KEY key) if (!app().has_module(FPAUT) || key != K_SPACE && key != K_TAB || !check_causale(cg_msk.get(F_CODCAUS))) return true; - auto msk = std::make_shared(cg_msk); - - app()._pro_mask = msk; + TPro_msk * msk = app()._pro_mask; + + if (msk == nullptr) + app()._pro_mask = msk = new TPro_msk(cg_msk); const TString datadoc = cg_msk.get(F_DATADOC); @@ -4092,16 +4092,13 @@ bool TPrimanota_application::fppro_mask(TMask_field& f, KEY key) msk->field(F_DATESEARCH).show(); msk->set(F_DATESEARCH, datadoc); } - if (msk->load_fppro_mask(msk.get())) - { - msk->run(); - // Riporto dati FPPRO su maschera Prima Nota (solo se hai F1) - // Se non hai F1 collego senza riportarti i dati (solo le chiavi db) - riporta_dati_f1(cg_msk, msk); - cg_msk.set(F_PROKEY, msk->get_fpprokeys()); - is_collegato(cg_msk.field(F_COLFPPRO)); - cg_msk.set(F_ANNORIF, cg_msk.get(F_ANNOIVA)); - } + msk->run(); + // Riporto dati FPPRO su maschera Prima Nota (solo se hai F1) + // Se non hai F1 collego senza riportarti i dati (solo le chiavi db) + riporta_dati_f1(cg_msk, *msk); + cg_msk.set(F_PROKEY, msk->get_fpprokeys()); + is_collegato(cg_msk.field(F_COLFPPRO)); + cg_msk.set(F_ANNORIF, cg_msk.get(F_ANNOIVA)); return true; } @@ -4150,91 +4147,77 @@ bool TPrimanota_application::is_collegato(TMask_field& f) return has_prokey; } -bool TPro_msk::load_fppro_mask(TMask* msk, KEY k) +bool TPro_msk::load_fppro_mask(TMask & msk) { // Provo a vedere se hanno l'FP: se c'è l'indirizzo controllo che non sia F8 se non c'è non hanno l'FP - if (k != 32) - return false; if (!fp_db().sq_is_connect()) { message_box("Attenzione connessione al database non riuscita.\nImpossibile collegarsi ai documenti in entrata."); return false; } - const int forn = msk->get_int(F_CODCLIFORS); + const int forn = msk.get_int(F_CODCLIFORS); if (forn == 0) { - msk->set(F_ENABSEARCH, "X"); - abilita_piva(msk); + msk.set(F_ENABSEARCH, "X"); + abilita_piva(); //message_box("Inserire prima il fornitore"); //return false; } - const TString& codfisc = msk->get(F_COFIS); - const TString& stato_piva = msk->get(F_STATOPAIVS); - const TString& piva = msk->get(F_PIVAS); + const TString& codfisc = msk.get(F_COFIS); + const TString& stato_piva = msk.get(F_STATOPAIVS); + const TString& piva = msk.get(F_PIVAS); TString query; - TString date = ""; + TDate date; - if (msk->get_bool(F_ENABDATE)) - date = msk->get_date(F_DATESEARCH); - if(!msk->get_bool(F_ENABSEARCH)) - query = query_fppro(msk->get(F_CODCLIFORS), date); + if (msk.get_bool(F_ENABDATE)) + date = msk.get_date(F_DATESEARCH); + if(!msk.get_bool(F_ENABSEARCH)) + query = query_fppro(msk.get(F_CODCLIFORS), date); else query = query_fppro(stato_piva, piva, date); fp_db().sq_set_exec(query, false); - TSheet_field& sf = msk->sfield(F_SHEETFPPROS); + TSheet_field& sf = msk.sfield(F_SHEETFPPROS); + const bool show_all = msk.get_bool(F_SHOWALL); - sf.hide(); - if (sf.items() > 0) - sf.destroy(); + sf.reset(); while (fp_db().sq_next()) { - TString numreg = fp_db().sq_get("PZ_NUMREGCONT"); - const bool show_all = msk->get_bool(F_SHOWALL); + const long numreg = fp_db().sq_get_long("PZ_NUMREGCONT"); - if (numreg != "0" && !show_all) - continue; + if (show_all || numreg == 0L) + { + TToken_string keys(fp_db().sq_get("PZ_KEYPRGINVIO"), ';'); - TToken_string& row = sf.row(-1); - TToken_string keys(fp_db().sq_get("PZ_KEYPRGINVIO"), ';'); + keys.add(fp_db().sq_get("PZ_KEYHEADERFATT")); keys.add(fp_db().sq_get("PZ_KEYBODYFATT")); - keys.add(fp_db().sq_get("PZ_KEYHEADERFATT")); keys.add(fp_db().sq_get("PZ_KEYBODYFATT")); - row.add("", 0); - row.add(fp_db().sq_get("P7_TIPODOC")); - row.add(TDate(fp_db().sq_get_date("P1_DATAORARIC"))); - row.add(TDate(fp_db().sq_get_date("PZ_DATA"))); - row.add(fp_db().sq_get("PQ_IMPTOTDOC")); - row.add(fppro_db().set_keys(keys).get_ritenute()); - row.add(fp_db().sq_get("PZ_NUMERO")); - row.add(fp_db().sq_get("P2_ANADENOMIN")); - row.add(fp_db().sq_get("P2_FISCIVAPAESE")); - row.add(fp_db().sq_get("P2_FISCIVACOD")); - row.add(fp_db().sq_get("P2_CODFISCALE")); - row.add(fp_db().sq_get("PZ_TIPOPROT")); - row.add(fp_db().sq_get("PZ_NUMPROT")); - row.add(keys); + const int r = sf.set_row_cell(F_SELFPPROS, ""); + + sf.set_row_cell(F_TIPODOCS, fp_db().sq_get("P7_TIPODOC"), r); + sf.set_row_cell(F_DATAORARICS, fp_db().sq_get_date("P1_DATAORARIC"), r); + sf.set_row_cell(F_DATAS, fp_db().sq_get_date("PZ_DATA"), r); + sf.set_row_cell(F_IMPTOTDOCS, fp_db().sq_get("PQ_IMPTOTDOC"), r); + sf.set_row_cell(F_RITENUTE, fppro_db().set_keys(keys).get_ritenute(), r); + sf.set_row_cell(F_NUMEROS, fp_db().sq_get("PZ_NUMERO"), r); + sf.set_row_cell(F_RAGXML, fp_db().sq_get("P2_ANADENOMIN"), r); + sf.set_row_cell(F_FISCIVAPAESES, fp_db().sq_get("P2_FISCIVAPAESE"), r); + sf.set_row_cell(F_FISCIVACODS, fp_db().sq_get("P2_FISCIVACOD"), r); + sf.set_row_cell(F_CODFISCALES, fp_db().sq_get("P2_CODFISCALE"), r); + sf.set_row_cell(F_TIPOPROTS, fp_db().sq_get("PZ_TIPOPROT"), r); + sf.set_row_cell(F_PROGRESSS, fp_db().sq_get("PZ_NUMPROT"), r); + sf.set_row_cell(F_KEYFPPROS, keys, r); + } } sf.force_update(); - sf.show(); return true; } -bool TPro_msk::fppro_handler(TMask_field& f, KEY k) +bool TPro_msk::riporta(TMask_field& f) { TMask& msk = f.mask(); - - const bool load = load_fppro_mask(&msk, k); - return load; -} - -bool TPro_msk::riporta_handler(TMask_field& f, KEY k) -{ - if (k != 32) - return true; - TMask& msk = f.mask(); //if (msk.curr_page() != 3) //return true; bool ok = false; @@ -4242,16 +4225,10 @@ bool TPro_msk::riporta_handler(TMask_field& f, KEY k) FOR_EACH_SHEET_ROW(sf, nr, row) { - if(*row->get(0) == 'X') + if(row->get_bool(0)) { - //TProtocollo protocollo(TDate(row->get(2)).year(), row->get(9), row->get(10)); - app()._pro_mask->set_doc(row->get(cid2index(F_NUMEROS)), row->get(cid2index(F_DATAS)), - row->get(cid2index(F_IMPTOTDOCS)), row->get(cid2index(F_RITENUTE)), "", row->get(cid2index(F_KEYFPPROS)), - msk.get(F_CODCLIFORS), row->get(cid2index(F_FISCIVACODS))); - if (f.dlg() == DLG_OK) - app()._pro_mask->_riporta = true; - else - app()._pro_mask->_riporta = false; + app().pro_mask()->set_doc(sf, nr); + _riporta = f.dlg() == DLG_OK; ok = true; break; } @@ -4265,67 +4242,56 @@ bool TPro_msk::riporta_handler(TMask_field& f, KEY k) return true; } -bool TPro_msk::collega_handler(TMask_field& f, KEY k) -{ - return riporta_handler(f, k); -} - -bool TPro_msk::piva_handler(TMask_field& f, KEY k) -{ - TMask& msk = f.mask(); - bool ok = true; - - if(k == K_TAB && f.active() && f.focusdirty()) - { - ok = load_fppro_mask(&msk, K_SPACE); - } - return ok; -} - -bool TPro_msk::date_handler(TMask_field& f, KEY k) -{ - TMask& msk = f.mask(); - bool ok = true; - - if (k == K_TAB && f.active() && f.focusdirty()) - { - ok = load_fppro_mask(&msk, K_SPACE); - } - return ok; -} - void TPro_msk::fppro_selfatt() const { const TMask& mask = *this; TSheet_field& sf = mask.sfield(F_SHEETFPPROS); - sf.hide(); FOR_EACH_SHEET_ROW(sf, nr, row) - { - if (*row->get(0) == 'X') - row->add("", 0); - } + if (sf.get_bool_row_cell(nr, F_SELFPPROS)) + sf.set_row_cell(F_SELFPPROS, false, nr); sf.force_update(); - sf.show(); } bool TPro_msk::on_field_event(TOperable_field& o, TField_event e, long jolly) { + TMask & m = o.mask(); + switch (o.dlg()) { - case F_SELFPPROS: + case DLG_CONFIG: + if (e == fe_button) + load_fppro_mask(m); + break; + case DLG_OK: + if (e == fe_button) + riporta(o); + break; + case DLG_LINK: + if (e == fe_button) + riporta(o); + break; + case F_PIVAS: + if (e == fe_modify) + load_fppro_mask(m); + break; + case F_DATESEARCH: + if (e == fe_modify) + load_fppro_mask(m); + break; + case F_SELFPPROS: if (e == fe_modify) fppro_selfatt(); break; case F_SHOWALL: if (e == fe_modify) - load_fppro_mask(this, K_SPACE); + load_fppro_mask(m); break; case F_ENABSEARCH: if (e == fe_modify) { - abilita_piva(this); - load_fppro_mask(this); + abilita_piva(); + load_fppro_mask(m); } break; case F_ENABDATE: @@ -4333,7 +4299,7 @@ bool TPro_msk::on_field_event(TOperable_field& o, TField_event e, long jolly) { field(F_DATESEARCH).show(o.mask().get_bool(F_ENABDATE)); if (!o.mask().get_bool(F_ENABDATE)) - load_fppro_mask(this); + load_fppro_mask(m); } break; default: @@ -4344,9 +4310,11 @@ bool TPro_msk::on_field_event(TOperable_field& o, TField_event e, long jolly) bool TPro_msk::is_doc_split() { - for(riga_iva_s const& riga : _righe_iva) + FOR_EACH_ARRAY_ITEM(_righe_iva, r, obj) { - if (riga.esigibilita == 'S') + TToken_string & riga = STRING_TOKEN(obj); + + if (riga.get(FPRI_ESIGIBILITA) == "S") return true; } return false; @@ -4383,53 +4351,70 @@ void TPro_msk::set_scadenze(const char* fpprokeys) } } -void TPro_msk::set_doc(const char* numero, const char* datadoc, const char* totdoc, const char* ritenute, const char* protfppro, const char* fpprokeys, const char* codforn, const char* piva) +void TPro_msk::set_doc(TSheet_field & s, int nrow) + //long numero, TDate datadoc, real totdoc, real ritenute, const char* protfppro, const char* fpprokeys, long codforn, const char* piva) { - _numero = numero; - _datadoc = datadoc; - _totdoc = abs(totdoc); - _ritenute = ritenute; - _protfppro.sset(protfppro); + _numero = s.get_long_row_cell(nrow, F_NUMEROS); + _datadoc = s.get_date_row_cell(nrow, F_DATAS); + _totdoc = abs(s.get_real_row_cell(nrow, F_IMPTOTDOCS)); + _ritenute = s.get_real_row_cell(nrow, F_RITENUTE); + _protfppro.sset(""); + + const TString & fpprokeys = s.get_str_row_cell(nrow, F_KEYFPPROS); + _fpprokeys = fpprokeys; - _codforn = codforn; - _piva = piva; - set_righeiva(fpprokeys); - set_scadenze(fpprokeys); + set_righeiva(fpprokeys); + set_scadenze(fpprokeys); + _codforn = s.get_long_row_cell(nrow, F_CODCLIFORS); + _piva = s.get_str_row_cell(nrow, F_FISCIVACODS); + } real TPro_msk::get_tot_imp_riva() { - real tot = ZERO; + real tot; - for(riga_iva_s const& riga : _righe_iva) + FOR_EACH_ARRAY_ITEM(_righe_iva, r, obj) { - if (riga.imposta > ZERO) - tot += riga.imponibile; + TToken_string & riga = STRING_TOKEN(obj); + + tot += riga.get_real(FPRI_IMPONIBILE); } return tot; } void TPro_msk::add_rigaiva(const real& imponibile, const real& imposta, const real& aliquota, const TString4& natura, char esigib) { - _righe_iva.insert(_righe_iva.end(), { imponibile, imposta, aliquota, natura, esigib }); + TToken_string riga; + + riga.add(imponibile, FPRI_IMPONIBILE); + riga.add(imposta, FPRI_IMPOSTA); + riga.add(aliquota, FPRI_ALIQUOTA); + riga.add(natura, FPRI_NATURA); + riga.add(esigib, FPRI_ESIGIBILITA); + _righe_iva.add(riga); } void TPro_msk::add_scad(const TDate& date, const real& importo) { - _scadenze.insert(_scadenze.end(), { date, importo }); + TToken_string riga; + + riga.add(date, FPSC_DATA); + riga.add(importo, FPSC_IMPORTO); + _scadenze.add(riga); } -TString& TPro_msk::query_fppro(const TString& codforn, const TString& date) +TString& TPro_msk::query_fppro(const TString& codforn, const TDate& date) { return query_fppro(codforn, "", "", "", date, "", "", "", true, false); } -TString& TPro_msk::query_fppro(const TString& stato_piva, const TString& piva, const TString& date) +TString& TPro_msk::query_fppro(const TString& stato_piva, const TString& piva, const TDate& date) { return query_fppro("", stato_piva, piva, "", date, "", "", "", true, true); } -TString& TPro_msk::query_fppro(const TString& codforn, const TString& stato_piva, const TString& piva, const TString& where_str, const TString& date, const TString& keyprginvio, const TString& keyheaderfatt, const TString& keybodyfatt, bool order, bool piva_research) +TString& TPro_msk::query_fppro(const TString& codforn, const TString& stato_piva, const TString& piva, const TString& where_str, const TDate& date, const TString& keyprginvio, const TString& keyheaderfatt, const TString& keybodyfatt, bool order, bool piva_research) { TString id_fornitore; TString keys; @@ -4453,14 +4438,15 @@ TString& TPro_msk::query_fppro(const TString& codforn, const TString& stato_piva id_fornitore << " (PZ_CLIFOR = '" << codforn << "') "; } - static TString query; - query.cut(0) << query_string() << "WHERE "; + TString & query = query_string(); + + query << "WHERE "; if (!id_fornitore.empty()) { query << id_fornitore << " "; - if (!date.empty()) - query << " AND PZ_DATA = '" << TDate(date).date2ansi() << "' "; + if (date.ok()) + query << " AND PZ_DATA = '" << date.date2ansi() << "' "; if (order) query << "\nORDER BY P1_DATAORARIC ASC"; query << ";"; @@ -4472,9 +4458,9 @@ TString& TPro_msk::query_fppro(const TString& codforn, const TString& stato_piva query << " AND " << where_str; query << ";"; } - else if (!date.empty()) + else if (date.ok()) { - query << " PZ_DATA = '" << TDate(date).date2ansi() << "' "; + query << " PZ_DATA = '" << date.date2ansi() << "' "; if (order) query << "\nORDER BY P1_DATAORARIC ASC, PZ_TIPOPROT ASC, PZ_NUMPROT ASC"; query << ";"; @@ -4489,47 +4475,37 @@ TString& TPro_msk::query_fppro(const TString& codforn, const TString& stato_piva TString& TPro_msk::query_string() { - static TString query; + TString & query = get_tmp_string(512); - query.cut(0) << "SELECT PZ_CLIFOR, PZ_DATA, CAST(P1_DATAORARIC AS DATE) AS P1_DATAORARIC, P7_TIPODOC, PQ_IMPTOTDOC, PZ_NUMERO, PZ_NUMREGCONT, PZ_TIPOPROT, " << - "PZ_NUMPROT, P2_ANADENOMIN, P2_FISCIVAPAESE, P2_FISCIVACOD, P2_CODFISCALE, PZ_KEYPRGINVIO, PZ_KEYHEADERFATT, PZ_KEYBODYFATT\n" << - "FROM PAA0200F \nJOIN FPPRO00F\n" << " ON P2_KEYPRGINVIO = PZ_KEYPRGINVIO AND P2_KEYHEADERFATT = PZ_KEYHEADERFATT AND P2_KEYBODYFATT = PZ_KEYBODYFATT\n" << - "JOIN PAA0100F \nON P2_KEYPRGINVIO = P1_KEYPRGINVIO AND P2_KEYHEADERFATT = P1_KEYHEADERFATT AND P2_KEYBODYFATT = P1_KEYBODYFATT\n" << - "JOIN PAA2700F \nON P2_KEYPRGINVIO = PQ_KEYPRGINVIO AND P2_KEYHEADERFATT = PQ_KEYHEADERFATT AND P2_KEYBODYFATT = PQ_KEYBODYFATT\n" << - "JOIN PAA0700F \nON P7_KEYPRGINVIO = PQ_KEYPRGINVIO AND P7_KEYHEADERFATT = PQ_KEYHEADERFATT AND P7_KEYBODYFATT = PQ_KEYBODYFATT\n"; + query << "SELECT PZ_CLIFOR, PZ_DATA, CAST(P1_DATAORARIC AS DATE) AS P1_DATAORARIC, P7_TIPODOC, PQ_IMPTOTDOC, PZ_NUMERO, PZ_NUMREGCONT, PZ_TIPOPROT, " << + "PZ_NUMPROT, P2_ANADENOMIN, P2_FISCIVAPAESE, P2_FISCIVACOD, P2_CODFISCALE, PZ_KEYPRGINVIO, PZ_KEYHEADERFATT, PZ_KEYBODYFATT\n" << + "FROM PAA0200F \nJOIN FPPRO00F\n" << " ON P2_KEYPRGINVIO = PZ_KEYPRGINVIO AND P2_KEYHEADERFATT = PZ_KEYHEADERFATT AND P2_KEYBODYFATT = PZ_KEYBODYFATT\n" << + "JOIN PAA0100F \nON P2_KEYPRGINVIO = P1_KEYPRGINVIO AND P2_KEYHEADERFATT = P1_KEYHEADERFATT AND P2_KEYBODYFATT = P1_KEYBODYFATT\n" << + "JOIN PAA2700F \nON P2_KEYPRGINVIO = PQ_KEYPRGINVIO AND P2_KEYHEADERFATT = PQ_KEYHEADERFATT AND P2_KEYBODYFATT = PQ_KEYBODYFATT\n" << + "JOIN PAA0700F \nON P7_KEYPRGINVIO = PQ_KEYPRGINVIO AND P7_KEYHEADERFATT = PQ_KEYHEADERFATT AND P7_KEYBODYFATT = PQ_KEYBODYFATT\n"; return query; } -void TPro_msk::abilita_piva(TMask* msk) +void TPro_msk::abilita_piva() { - if (msk->get_bool(F_ENABSEARCH)) - { - msk->enable(F_PIVAS); - msk->enable(F_STATOPAIVS); - } - else - { - msk->enable(F_PIVAS, false); - msk->enable(F_STATOPAIVS, false); - } + const bool on = get_bool(F_ENABSEARCH); + + enable(F_PIVAS, on); + enable(F_STATOPAIVS, on); + enable(F_COFIS, on); } -TPro_msk::TPro_msk(TMask& cg_msk) : TAutomask("cg2100t"), _riporta(false), _codforn("") +TPro_msk::TPro_msk(TMask& cg_msk) : TAutomask("cg2100t"), _riporta(false), _codforn(0L), _numero(0L) { - TMask::set_handler(DLG_CONFIG, fppro_handler); - TMask::set_handler(DLG_OK, riporta_handler); - if (!app().has_module(F1AUT)) - field(DLG_OK).disable(); - TMask::set_handler(DLG_LINK, collega_handler); - TMask::set_handler(F_PIVAS, piva_handler); - TMask::set_handler(F_DATESEARCH, date_handler); - TMask::set(F_CODCLIFORS, cg_msk.get(F_CODCLIFOR)); - TMask::set(F_COFIS, cg_msk.get(F_COFI)); - TMask::set(F_STATOPAIVS, cg_msk.get(F_STATOPAIV)); - TMask::set(F_PIVAS, cg_msk.get(F_PIVA)); - TMask::set(F_RAGSOCS, cg_msk.get(F_RAGSOCCF)); + enable(DLG_OK, app().has_module(F1AUT)); + set(F_CODCLIFORS, cg_msk.get(F_CODCLIFOR)); + set(F_COFIS, cg_msk.get(F_COFI)); + set(F_STATOPAIVS, cg_msk.get(F_STATOPAIV)); + set(F_PIVAS, cg_msk.get(F_PIVA)); + set(F_RAGSOCS, cg_msk.get(F_RAGSOCCF)); set(F_DATESEARCH, TDate(TODAY)); - _righe_iva.clear(); + _righe_iva.destroy(); + _scadenze.destroy(); } bool& is_f1() @@ -4538,8 +4514,3 @@ bool& is_f1() return is_f1; } -TString& num_doc_rif() -{ - static TString num_doc_rif_partite = -1; - return num_doc_rif_partite; -} \ No newline at end of file diff --git a/src/cg/cg2102.h b/src/cg/cg2102.h index e9cc2cd3e..8e3c88aa9 100755 --- a/src/cg/cg2102.h +++ b/src/cg/cg2102.h @@ -27,15 +27,76 @@ #include #include "../f1/f1lib.h" -#include -#define K_ELIMMAS 0 // Key per eliminazione massima +#define K_ELIMMAS 0 // Key per eliminazione massima + +#define FPRI_IMPONIBILE 0 +#define FPRI_IMPOSTA 1 +#define FPRI_ALIQUOTA 2 +#define FPRI_NATURA 3 +#define FPRI_ESIGIBILITA 4 + +#define FPSC_DATA 0 +#define FPSC_IMPORTO 1 -class TPro_msk; class TDati_mov_auto; enum CGMaskType { _query = 0, _no_iva = 1, _iva = 2, _occas = 3}; +class TPro_msk : public TAutomask +{ + long _numero; + TDate _datadoc; + real _totdoc; + real _ritenute; + TProtocollo _protfppro; + TString _fpprokeys; + TString _piva; + long _codforn; + TString_array _righe_iva; + TString_array _scadenze; + bool _riporta; + + // Non permette la selezione multipla + void fppro_selfatt() const; + bool on_field_event(TOperable_field& o, TField_event e, long jolly) override; +public: + bool da_riportare() const { return _riporta; } + bool is_doc_split() ; + + void set_righeiva(const char* fpprokeys); + void set_scadenze(const char* fpprokeys); + void set_doc(TSheet_field & s, int nrow); + + const long get_numdoc() const { return _numero; } + const TDate & get_datadoc() const { return _datadoc; } + const real & get_totdoc() const { return _totdoc; } + const real & get_ritenute() const { return _ritenute; } + const TString & get_fpprokeys() const { return _fpprokeys; } + const long get_codforn() const { return _codforn; } + const TString & get_piva() const { return _piva; } + const TString_array& get_righeiva() const { return _righe_iva; } + const TProtocollo& get_protocollo() const { return _protfppro; } + const TString_array& get_scadenze() const { return _scadenze; } + real get_tot_imp_riva() ; + + void add_rigaiva(const real& imponibile, const real& imposta, const real& aliquota, const TString4& natura, char esigib); + void add_scad(const TDate& date, const real& importo); + + static TString& query_fppro(const TString& codforn, const TDate& date); + static TString& query_fppro(const TString& stato_piva, const TString& piva, const TDate& date); + static TString& query_fppro(const TString& codforn, const TString& stato_piva, const TString& piva, const TString& where_str, const TDate& date, const TString& keyprginvio, const TString& keyheaderfatt, const TString& keybodyfatt, bool order = true, bool piva_research = false); + static TString& query_string(); + + void abilita_piva(); + + // Carica documenti FPPRO sulla maschera + bool riporta(TMask_field& f); + bool load_fppro_mask(TMask & msk); + + TPro_msk(TMask& cg_msk); +}; + class TPrimanota_application : public TRelation_application { TMovimentoPN* _rel; // Relazione principale @@ -90,11 +151,12 @@ class TPrimanota_application : public TRelation_application TAssoc_array _colori; // Colori delle righe bool _isf1; - shared_ptr _pro_mask; + TPro_msk * _pro_mask; bool _is_set_fpcheck; int _last_date; bool _f1_ini; bool _f1_liq; + TString _num_doc_rif_partite; friend class TPro_msk; static bool showpartite_handler(TMask_field& f, KEY k); @@ -180,11 +242,11 @@ class TPrimanota_application : public TRelation_application // Gestione F1 - static void write_righe_iva_f1(TMask& cg_msk, const shared_ptr& msk); - static bool write_scad_f1(const TMask& cg_msk, const shared_ptr& msk); - static void write_clifo(TMask& cg_msk, const shared_ptr& msk); - static void set_totale(TMask& cg_msk, const shared_ptr& msk); - static void riporta_dati_f1(TMask& cg_msk, const shared_ptr& msk); + static void write_righe_iva_f1(TMask& cg_msk, const TPro_msk & msk); + static bool write_scad_f1(const TMask& cg_msk, const TPro_msk & msk); + static void write_clifo(TMask& cg_msk, const TPro_msk & msk); + static void set_totale(TMask& cg_msk, TPro_msk & msk); + static void riporta_dati_f1(TMask& cg_msk, TPro_msk & msk); void insert_part_scad(TConfig& ini); // Handlers per aggancio FPPRO // Bottone per maschera FPPRO @@ -222,9 +284,10 @@ protected: // TApplication static bool scollega(bool set = false); // Pulisce il mov e db dai firerimenti FPPRO (in MODE_MOD per edit/delete) void clean_fppro(); - // setta variabili prima del controllo has_f1_db - void set_has_f1_db(TMask* m); - bool has_f1_db(TMask* m); + // Ha f1 ? + bool has_f1() const; + // controlla il db + bool has_f1_db(const TMask & m); // Controlli prima di write e rewrite int controlli_f1(const TMask& m); @@ -320,8 +383,8 @@ protected: real calcola_imp() const; void add_cgs_tot(TMask& m); - int set_cgs_row(int n, const TImporto& importo, const TBill& conto, const char* desc, char tipo, - const char* cms = nullptr, const char* fas = nullptr); + int set_cgs_row(int n, TImporto& importo, const TBill& conto, const char* desc, char tipo, + const char* cms = nullptr, const char* fas = nullptr); void set_cgs_imp(int n, const TImporto& importo); bool add_cgs_imp(int n, const TImporto& importo); bool sub_cgs_imp(int n, const TImporto& importo); @@ -399,97 +462,18 @@ public: TString_array& pag_rows() { return _pag_rows; } TImporto get_cgs_imp(int n) const; + TPro_msk * pro_mask() const { return _pro_mask; } TImporto imposte_split_pay() const; + const TString & num_doc_rif() const { return _num_doc_rif_partite; } TPrimanota_application(); - virtual ~TPrimanota_application() { } -}; - -class TPro_msk : public TAutomask -{ -public: - struct riga_iva_s; - struct scadenza_s; -private: - TString _numero; - TDate _datadoc; - real _totdoc; - real _ritenute; - TProtocollo _protfppro; - TString _fpprokeys; - TString _piva; - TString _codforn; - vector _righe_iva; - vector _scadenze; - bool _riporta; - - // Handlers per aggancio FPPRO - // Bottone carica documenti in maschera FPPRO - static bool fppro_handler(TMask_field& f, KEY k); - // Bottone riporta doc FPPRO in testata Prima Nota - static bool riporta_handler(TMask_field& f, KEY k); - static bool collega_handler(TMask_field& f, KEY k); - static bool piva_handler(TMask_field& f, KEY k); - static bool date_handler(TMask_field& f, KEY k); - // Non permette la selezione multipla - void fppro_selfatt() const; - bool on_field_event(TOperable_field& o, TField_event e, long jolly) override; -public: - struct riga_iva_s - { - real imponibile; - real imposta; - real aliquota; - TString4 natura; - char esigibilita; - }; - struct scadenza_s - { - TDate data; - real importo; - }; - - bool should_bring_back() const { return _riporta; } - bool is_doc_split(); - - void set_righeiva(const char* fpprokeys); - void set_scadenze(const char* fpprokeys); - void set_doc(const char* numero, const char* datadoc, const char* totdoc, const char* ritenute, const char* protfppro, const char* fpprokeys, const char* codforn, const char* piva); - - TString get_numdoc() const { return _numero; } - TDate get_datadoc() const { return _datadoc; } - real get_totdoc() const { return _totdoc; } - real get_ritenute() const { return _ritenute; } - TString get_fpprokeys() const { return _fpprokeys; } - TString get_codforn() const { return _codforn; } - TString get_piva() const { return _piva; } - const vector& get_righeiva() const { return _righe_iva; } - TProtocollo& get_protocollo() { return _protfppro; } - vector& get_scadenze() { return _scadenze; } - real get_tot_imp_riva(); - - - void add_rigaiva(const real& imponibile, const real& imposta, const real& aliquota, const TString4& natura, char esigib); - void add_scad(const TDate& date, const real& importo); - - - static TString& query_fppro(const TString& codforn, const TString& date); - static TString& query_fppro(const TString& stato_piva, const TString& piva, const TString& date); - static TString& query_fppro(const TString& codforn, const TString& stato_piva, const TString& piva, const TString& where_str, const TString& date, const TString& keyprginvio, const TString& keyheaderfatt, const TString& keybodyfatt, bool order = true, bool piva_research = false); - static TString& query_string(); - - static void abilita_piva(TMask* msk); - - // Carica documenti FPPRO sulla maschera - static bool load_fppro_mask(TMask* msk, KEY k = 32); - - TPro_msk() = delete; - TPro_msk(TMask& cg_msk); + virtual ~TPrimanota_application() { safe_delete(_pro_mask); } }; bool& is_f1(); -TString& num_doc_rif(); + + #ifndef __EXTRA__ inline TPrimanota_application& app() diff --git a/src/cg/cg2104.cpp b/src/cg/cg2104.cpp index 1db3a0a1b..e2b265ea0 100755 --- a/src/cg/cg2104.cpp +++ b/src/cg/cg2104.cpp @@ -329,7 +329,7 @@ bool TPrimanota_application::codpag_handler(TMask_field& f, KEY key) TMask& m = f.mask(); TPrimanota_application& a = app(); const bool set_scad = a.is_fattura() && m.page_enabled(2); // E' attiva pagina 3 - if (key == K_ENTER && (!a._f1_ini && (a._pro_mask == nullptr || !a._pro_mask->should_bring_back()))) + if (key == K_ENTER && (!a._f1_ini && (a._pro_mask == nullptr || !a._pro_mask->da_riportare()))) { if (set_scad && f.empty()) { @@ -356,7 +356,7 @@ bool TPrimanota_application::codpag_handler(TMask_field& f, KEY key) } } - if (key == K_TAB && f.focusdirty() && m.insert_mode() && set_scad && (!a._f1_ini && (a._pro_mask == nullptr || !a._pro_mask->should_bring_back()))) + if (key == K_TAB && f.focusdirty() && m.insert_mode() && set_scad && (!a._f1_ini && (a._pro_mask == nullptr || !a._pro_mask->da_riportare()))) a.set_scadenze(m); return ok; @@ -1227,8 +1227,7 @@ bool TPrimanota_application::notify_edit_pagamento(TPartita& p, TRectype& new_pa // Aggiornamento contopartita const TImporto old_importo(controsez, old_pag.get_real(PAGSCA_IMPORTO)); TBill old_conto; old_conto.get(old_pag, true); - - const TImporto new_importo(controsez, new_pag.get_real(PAGSCA_IMPORTO)); + TImporto new_importo(controsez, new_pag.get_real(PAGSCA_IMPORTO)); if (old_importo != new_importo || old_conto != new_conto) { @@ -1298,7 +1297,7 @@ bool TPrimanota_application::notify_edit_pagamento(TPartita& p, TRectype& new_pa const real new_ritenute(new_pag.get(PAGSCA_RITENUTE)); if (old_ritenute != new_ritenute) { - const TImporto grow_ritenute(causale().sezione_ritfis(), new_ritenute - old_ritenute); + TImporto grow_ritenute(causale().sezione_ritfis(), new_ritenute - old_ritenute); const int riga = type2pos(cgrowtype_ritfis); if (riga < 0) @@ -1319,7 +1318,7 @@ bool TPrimanota_application::notify_edit_pagamento(TPartita& p, TRectype& new_pa const real new_ritsoc(new_pag.get(PAGSCA_RITSOC)); if (old_ritsoc != new_ritsoc) { - const TImporto grow_ritenute(causale().sezione_ritsoc(), new_ritsoc-old_ritsoc); + TImporto grow_ritenute(causale().sezione_ritsoc(), new_ritsoc-old_ritsoc); const int riga = type2pos(cgrowtype_ritsoc); if (riga < 0) diff --git a/src/cg/cg2105.cpp b/src/cg/cg2105.cpp index 7d10dc39d..34be2e796 100755 --- a/src/cg/cg2105.cpp +++ b/src/cg/cg2105.cpp @@ -920,12 +920,9 @@ bool TGame_mask::partite_notify(TSheet_field& partite, int r, KEY k) TToken_string& row = partite.row(r); const int anno = row.get_int(0); // Anno partita TNumero_partita num = row.get(); // Numero partita - if(is_f1()) - { - TNumero_partita prev = num; - if ((num = num_doc_rif()) == -1) - num = prev; - } + + if (is_f1() && app().num_doc_rif().full()) + num = app().num_doc_rif(); gm.set(P_ANNO, anno); // Aggiorna campi di ricerca gm.set(P_NUMERO, num); diff --git a/src/cg/cg2300.cpp b/src/cg/cg2300.cpp index f772a5f6c..dab8ffdc3 100644 --- a/src/cg/cg2300.cpp +++ b/src/cg/cg2300.cpp @@ -8,7 +8,6 @@ #include "mov.h" #include #include "rmov.h" -#include #include "pconti.h" #define INI_ANNO "riep_anno" @@ -23,18 +22,15 @@ class TCompetenze_mask : public TAutomask int s_conto; real importo; }; - std::vector _regs; - std::vector _conts; + + TString_array _regs; + const char* get_ini(bool dataini) const; bool on_field_event(TOperable_field& o, TField_event e, long jolly) override; - // Funzione becera di ordinamento del vettore _conts - void sort_conts(bool sort_by_imp = true); - static void swap_items(cont_contr_t* it, cont_contr_t* jt); - static bool is_minor_of(cont_contr_t* jt, cont_contr_t* it); - + static TString get_descr(int gruppo, int conto, int s_conto); void fill_contc(); void fill(); @@ -50,6 +46,44 @@ const char* TCompetenze_mask::get_ini(bool dataini) const return ini_get_string(CONFIG_DITTA, "cg", INI_MESE, ""); } + +static bool __sort_by_imp = false; + +static int sort_sheet(TSheet_field & s, int r1, int r2) +{ + int ret = 0; + + if (__sort_by_imp) + { + const real i1 = s.get_real_row_cell(r1, F_TOTCONTC); + const real i2 = s.get_real_row_cell(r2, F_TOTCONTC); + + if (i1 > i2) + ret = 1; + else + if (i2 > i1) + ret = -1; + } + else + { + ret = s.get_int_row_cell(r1, F_GRPCONTC) - s.get_int_row_cell(r2, F_GRPCONTC); + if (ret == 0) + ret = s.get_int_row_cell(r1, F_NUMCONTC) - s.get_int_row_cell(r2, F_NUMCONTC); + if (ret == 0) + { + const long s1 = s.get_long_row_cell(r1, F_SOTCONTC); + const real s2 = s.get_long_row_cell(r2, F_SOTCONTC); + + if (s1 > s2) + ret = 1; + else + if (s2 > s1) + ret = -1; + } + } + return ret; +} + bool TCompetenze_mask::on_field_event(TOperable_field& o, TField_event e, long jolly) { switch (o.dlg()) @@ -76,6 +110,16 @@ bool TCompetenze_mask::on_field_event(TOperable_field& o, TField_event e, long j case F_ANNO: if (e == fe_init) set(F_ANNO, get_ini(true)); break; + case F_ORDIN: + if (e == fe_init || e == fe_modify) + { + TSheet_field& sf = sfield(F_CONTC); + + __sort_by_imp = o.get_bool(); + sf.sort(sort_sheet); + sf.force_update(); + } + break; case F_MESE: if (e == fe_init) set(F_MESE, get_ini(false)); @@ -95,100 +139,66 @@ TString TCompetenze_mask::get_descr(int gruppo, int conto, int s_conto) return pcont.get(PCN_DESCR); } -bool TCompetenze_mask::is_minor_of(cont_contr_t* jt, cont_contr_t* it) -{ - return jt->gruppo < it->gruppo - || (jt->gruppo == it->gruppo && jt->conto < it->conto) - || (jt->gruppo == it->gruppo && jt->conto == it->conto - && jt->s_conto < it->s_conto); -} - -void TCompetenze_mask::swap_items(cont_contr_t* it, cont_contr_t* jt) -{ - const cont_contr_t appo = *it; - *it = *jt; - *jt = appo; -} - -void TCompetenze_mask::sort_conts(bool sort_by_imp) -{ - // Sopra 100 rischia di essere leggermente lento? - if (1 < _conts.size() && _conts.size() < 100) - for (auto it = _conts.begin(); it != _conts.end(); ++it) - for (auto jt = (it+1); jt != _conts.end(); ++jt) - if (sort_by_imp && jt->importo > it->importo || !sort_by_imp && is_minor_of(&(*jt), &(*it))) - swap_items(&(*it), &(*jt)); -} - void TCompetenze_mask::fill_contc() { TSheet_field& sf = sfield(F_CONTC); - TLocalisamfile rmovs(LF_RMOV); + TAssoc_array conti; + real tot; - sf.hide(); sf.reset(); - _conts.clear(); // Per ogni registrazione - for (int i = 0; i < (int)_regs.size(); ++i) + FOR_EACH_ARRAY_ITEM(_regs, i, obj) { - const int numreg = _regs[i]; - rmovs.zero(); - rmovs.put(RMV_NUMREG, numreg); - rmovs.put(RMV_NUMRIG, 0); - int riga = 0; - if (rmovs.read()) - { + const long numreg = atol(STRING_TOKEN(obj)); + const TMovimento_contabile mov(numreg); + const TCausale & caus = cached_causale(mov.get(MOV_CODCAUS)); + const int rows = mov.cg_rows(); + // Per ogni riga della registrazione - for (; rmovs.get_int(RMV_NUMREG) == numreg; rmovs.next()) + for (int r = mov.is_IVA() ? 2 : 1; r <= rows; r++) + { + const TRectype & rmov = mov.cg(r); + const int gruppo = rmov.get_int(RMV_GRUPPO); + const int numcontc = rmov.get_int(RMV_CONTO); + const int s_conto = rmov.get_int(RMV_SOTTOCONTO); + const TString& tipocc = rmov.get(RMV_TIPOC); + const real importo = rmov.get_real(RMV_IMPORTO); + TString key; + + key.format("%03d|%03d|%06d", gruppo, numcontc, s_conto); + + if (tipocc.blank()) // Solo se il tipo di conto di contr. e' un conto, cioe' vuoto { - const int gruppo = rmovs.get_int(RMV_GRUPPOC); - const int numcontc = rmovs.get_int(RMV_CONTOC); - const int s_conto = rmovs.get_int(RMV_SOTTOCONTOC); - const TString& tipocc = rmovs.get(RMV_TIPOCC); - const real importo(rmovs.get(RMV_IMPORTO)); + // Cerco se ho già la chiave + real * tot = (real *)conti.objptr(key); - if (tipocc.blank()) // Solo se il tipo di conto di contr. e' un conto, cioe' vuoto - { - // Cerco se ho già la chiave - auto it = _conts.begin(); - for (; it != _conts.end(); ++it) - { - if (it->gruppo == gruppo - && it->conto == numcontc - && it->s_conto == s_conto) - break; - } - - if (it != _conts.end()) - it->importo += importo; - else - _conts.insert(_conts.end(), { gruppo, numcontc, s_conto, importo }); - } + if (tot == nullptr) + conti.add(key, tot = new real); + *tot += importo; } } } - - sort_conts(get(F_ORDIN) == "X"); - - real tot; tot = 0; - for (auto it = _conts.begin(); it != _conts.end(); ++it) - { - const int gruppo = it->gruppo; - const int conto = it->conto; - const int s_conto = it->s_conto; + + FOR_EACH_ASSOC_OBJECT(conti, i, k, o1) + { + TToken_string key = k; + const int gruppo = key.get_int(0); + const int conto = key.get_int(0); + const int s_conto = key.get_long(2); const TString& descr = get_descr(gruppo, conto, s_conto); + const real importo = *(real *)o1; + int r = sf.set_row_cell(F_GRPCONTC, gruppo); - TToken_string& row = sf.row(-1); - row.add(gruppo); - row.add(conto); - row.add(s_conto); - row.add(descr); - row.add(it->importo); - tot += it->importo; + sf.set_row_cell(F_NUMCONTC, conto, r); + sf.set_row_cell(F_SOTCONTC, s_conto, r); + + sf.set_row_cell(F_DESCRCON, descr, r); + sf.set_row_cell(F_TOTCONTC, importo, r); + tot += importo; } - sf.force_update(); - sf.show(); + sf.sort(sort_sheet); + sf.force_update(); set(F_TOT, tot); } @@ -198,42 +208,42 @@ void TCompetenze_mask::fill() const int anno = get_int(F_ANNO); const int mese = get_int(F_MESE); TSheet_field& sf = sfield(F_MOVS); - TLocalisamfile movs(LF_MOV); + TRectype from(LF_MOV); + TRectype to(LF_MOV); + TDate data(1, mese, anno); + + from.put(MOV_DATAREG, data); + data.set_end_month(); + to.put(MOV_DATAREG, data); + + TCursor c(new TRelation(LF_MOV), "", 2, &from, &to); + const int items = c.items(); - sf.hide(); sf.reset(); - _regs.clear(); - movs.setkey(2); - - const TDate dataini(1, mese, anno); - TDate dataend(dataini); dataend.set_end_month(); - movs.put(MOV_DATAREG, dataini); - if (movs.read() != NOERR) + _regs.destroy(); + for (c = 0L; c.pos() < items; ++c) { - for (; movs.next() == NOERR && movs.get_date(MOV_DATAREG) <= dataend; ) + const TRectype & mov = c.curr(); + const int month_liq = mov.get_int(MOV_MESELIQ); + const TDate datareg(mov.get(MOV_DATAREG)); + const TDate datacomp(mov.get(MOV_DATACOMP)); + + if (month_liq != 0) { - const int month_liq = movs.get_int(MOV_MESELIQ); - const TDate datareg(movs.get(MOV_DATAREG)); - const TDate datacomp(movs.get(MOV_DATACOMP)); + _regs.add(mov.get(MOV_NUMREG)); - if (month_liq != 0) - { - _regs.insert(_regs.end(), movs.get_int(MOV_NUMREG)); + int r = sf.set_row_cell(F_NUMREG, mov.get(MOV_NUMREG)); - TToken_string& row = sf.row(-1); - row.add(movs.get(MOV_NUMREG)); - row.add(datareg); - row.add(movs.get(MOV_DATADOC)); - row.add(TCausale(movs.get(MOV_CODCAUS)).tipo_doc()); - row.add(month_liq); - row.add(movs.get(MOV_NUMDOC)); - row.add(movs.get(MOV_PROTIVA)); - row.add(movs.get(MOV_DESCR)); - } + sf.set_row_cell(F_DATAREG, mov.get_date(MOV_DATAREG), r); + sf.set_row_cell(F_DATADOC, mov.get_date(MOV_DATADOC), r); + sf.set_row_cell(F_CODCAUS, mov.get(MOV_CODCAUS), r); + sf.set_row_cell(F_MESELIQ, month_liq, r); + sf.set_row_cell(F_NUMDOC, mov.get(MOV_NUMDOC), r); + sf.set_row_cell(F_PROTIVA, mov.get(MOV_PROTIVA), r); + sf.set_row_cell(F_DESCR, mov.get(MOV_DESCR), r); } } sf.force_update(); - sf.show(); fill_contc(); } diff --git a/src/cg/cg2300a.uml b/src/cg/cg2300a.uml index a0ca4e472..76f127352 100644 --- a/src/cg/cg2300a.uml +++ b/src/cg/cg2300a.uml @@ -118,7 +118,7 @@ END NUMBER F_MESELIQ 2 BEGIN - PROMPT 1 5 "Causale " + PROMPT 1 5 "Mese Liq." FLAGS "D" END diff --git a/src/cg/cg3100.cpp b/src/cg/cg3100.cpp index 23e4e6d32..cd7e9449f 100755 --- a/src/cg/cg3100.cpp +++ b/src/cg/cg3100.cpp @@ -68,7 +68,8 @@ class TListaMov_application : public TPrintapp int _ricser; bool _settata_prima_riga, _causale_gia_stampata,_mov_di_sola_iva; int _cur1,_cur2,_cur2b,_cur3,_cur4,_decidi,/*_tipod,*/_controllo_mov_errati; - int _numero_riga, _alleg, _tiporegistro, _scelta_stampa, _nr, _n; + int _numero_riga, _alleg, _scelta_stampa, _nr, _n; + tiporeg _tiporegistro; int _provvis; liste _tipo_lista; word _flags; @@ -116,7 +117,6 @@ public: bool RicercaDoc(const char* cod) const; const TString& SimboloValuta (const char* cod) const; const TString& DescrDoc(const char* cod) const; - const TString& AttivitaRegistro(const char * cod, int anno) const; TListaMov_application(char tipost); virtual ~TListaMov_application() {} @@ -427,19 +427,6 @@ const TString& TListaMov_application::SimboloValuta(const char* cod) const const TString& TListaMov_application::DescrDoc(const char* tipo) const { return cache().get(TAB_TPD, tipo, "S0"); } -const TString& TListaMov_application::AttivitaRegistro(const char* cod, int anno) const -{ - TString8 key; key.format("%04d%-3s", anno, cod); - return cache().get("REG", key, "S8"); -} - -HIDDEN int tipo_registro(const char* cod, int anno) -{ - TString8 codtab; codtab.format("%4d%-3s", anno, cod); - const TString& tipo_reg = cache().get("REG", codtab, "I0"); - return atoi(tipo_reg); -} - static bool between(const TString& code, const TString& mini, const TString& maxi) { if (mini.full() && code < mini) @@ -508,11 +495,11 @@ bool TListaMov_application::filter_func_fatture (const TRelation* rel) const int ann_reg = mov.get_int(MOV_ANNOIVA); const TString4 cod_reg = mov.get(MOV_REG); - const int tipo_reg = tipo_registro(cod_reg, ann_reg); + const tiporeg tipo_reg = cached_registro(cod_reg, ann_reg).tipo_registro(); // Considera solo iva acquisti o vendite - if (tipo_reg != 1 && tipo_reg != 2) - return FALSE; + if (tipo_reg != vendita && tipo_reg != acquisto) + return false; if (app()._annoes > 0) //anno esercizio specificato nella maschera { @@ -563,8 +550,10 @@ bool TListaMov_application::filter_func (const TRelation * rel) { const TString& cod_reg = mov.get(MOV_REG); const int ann_reg = mov.get_int(MOV_ANNOIVA); - const int tipo_reg = tipo_registro(cod_reg, ann_reg); - if (tipo_reg == 1 || tipo_reg == 2) + const tiporeg tipo_reg = cached_registro(cod_reg, ann_reg).tipo_registro(); + + // Considera solo iva acquisti o vendite + if (tipo_reg != vendita && tipo_reg != acquisto) return false; } @@ -653,9 +642,10 @@ void TListaMov_application::stampa_errori_rmov() else set_row(_nr++, FR("@11gCodice C/F non presente in Anagrafica")); if (_registro.not_empty()) //se su mov e' indicato il codice registro { - TRegistro rg (_registro, _ae); - const int tiporeg = rg.tipo(); - if ((tiporeg == 1 && t != 'C') || (tiporeg == 2 && t != 'F')) + const TRegistro & reg = cached_registro(_registro, _ae); + const tiporeg tipo = reg.tipo_registro(); + + if ((tipo == vendita && t != 'C') || (tipo == acquisto && t != 'F')) set_row(_nr++, FR("@11gTipo C/F non compatibile con tipo registro")); } } @@ -742,14 +732,14 @@ void TListaMov_application::stampa_errori_iva(int* nr, const TRigaiva& riva) const int tipocr = riva._tipocr; if (tipodet == 1 || tipodet == 3 || tipodet == 5 || tipodet == 9) - if (_tiporegistro != 2) + if (_tiporegistro != acquisto) set_row(++(*nr), FR("@11gCodice di indetraibilita' errato")); - if (_tiporegistro == 1) + if (_tiporegistro == vendita) if (tipocr != 0 && tipocr != 1 && tipocr != 4 && tipocr != 9) set_row(++(*nr), FR("@11gTipo costo/ricavo non valido")); - if (_tiporegistro == 2) + if (_tiporegistro == acquisto) if (tipocr != 0 && tipocr != 1 && tipocr != 2 && tipocr != 3 && tipocr != 5 && tipocr != 8 && tipocr != 9) set_row(++(*nr), FR("@11gTipo costo/ricavo non valido")); } @@ -809,11 +799,11 @@ void TListaMov_application::set_page(int file, int count) TString16 reg = current_cursor()->curr(LF_MOV).get(MOV_REG); int anno = current_cursor()->curr(LF_MOV).get_int(MOV_ANNOIVA); char prov = current_cursor()->curr(LF_MOV).get_char(MOV_PROVVIS); - int tipo = tipo_registro(reg, anno); - + const tiporeg tipo = cached_registro(reg, anno).tipo_registro(); TEsercizi_contabili esc; + esc.date2esc(data); // qui verificare - if ( (tipo == 1) || (tipo == 2) ) + if ( (tipo == vendita) || (tipo == acquisto) ) { set_row (_n, FR("@103greg @3s"),FLD(LF_MOV,MOV_REG)); set_row (_n, FR("@111gpr @5n"),FLD(LF_MOV,MOV_PROTIVA)); @@ -887,7 +877,8 @@ bool TListaMov_application::preprocess_page(int file,int counter) _codcf = curmov.get_long(MOV_CODCF); _numero = curmov.get_long(MOV_NUMREG); _codval = curmov.get(MOV_CODVALI); - _tiporegistro = tipo_registro(_registro, _anno); + _tiporegistro = cached_registro(_registro, _anno).tipo_registro(); + _causale_gia_stampata = FALSE; TEsercizi_contabili esc; @@ -1014,11 +1005,9 @@ bool TListaMov_application::preprocess_page(int file,int counter) _descr_causale = caus.get(CAU_DESCR); _alleg_causale = caus.get_bool(CAU_ALLEG); _tipodocumento = caus.get(CAU_TIPODOC); - - _tiporegistro = tipo_registro (_registro, _anno); - - if ((_tiporegistro != 1)&&(_tiporegistro != 2))//se si tratta di un movimento di sola prima nota - return TRUE; + _tiporegistro = cached_registro(_registro, _anno).tipo_registro(); + if ((_tiporegistro != vendita) && (_tiporegistro != acquisto))//se si tratta di un movimento di sola prima nota + return true; } } else if (file == LF_RMOV) @@ -1065,10 +1054,10 @@ bool TListaMov_application::preprocess_page(int file,int counter) _numr = curmov.get_long(MOV_NUMREG); _tipo_elenco = curmov.get(MOV_TIPO); _codcf = curmov.get_long(MOV_CODCF); - const int tiporeg = tipo_registro (codreg, anno); - const TString8 attreg = AttivitaRegistro (codreg, anno); + const tiporeg tiporeg = cached_registro(codreg, anno).tipo_registro(); + const TString8 attreg = cached_registro(codreg, anno).attivita(); - if (tiporeg == 1 || tiporeg == 2)//se si tratta di un movimento iva + if (tiporeg == vendita || tiporeg == acquisto)//se si tratta di un movimento iva { _tipoatt = TipoAttivita(attreg, get_firm()); _tipo_elenco = curmov.get(MOV_TIPO); @@ -1897,18 +1886,18 @@ bool TListaMov_application::segnala_errori_iva() return true; } if (tipodet == 1 || tipodet == 3 || tipodet == 5 || tipodet == 9) - if (_tiporegistro != 2) + if (_tiporegistro != acquisto) { rmoviva.readat(nrec); return true; } - if (_tiporegistro == 1) + if (_tiporegistro == vendita) if (tipocr != 0 && tipocr != 1 && tipocr != 4 && tipocr != 9) { rmoviva.readat(nrec); return true; } - if (_tiporegistro == 2) + if (_tiporegistro == acquisto) if (tipocr != 0 && tipocr != 1 && tipocr != 2 && tipocr != 3 && tipocr != 5 && tipocr != 8 && tipocr != 9) { rmoviva.readat(nrec); diff --git a/src/cg/cg3300.cpp b/src/cg/cg3300.cpp index 36182580b..d57bc2739 100755 --- a/src/cg/cg3300.cpp +++ b/src/cg/cg3300.cpp @@ -25,6 +25,7 @@ #include "cg3.h" #include "cg3300.h" +#include "cglib.h" #include "cg3300a.h" #include "cg3300b.h" @@ -469,18 +470,19 @@ void TStampa_allegati::ricalcola(int anno_dic) { pi.addstatus(1); - const int tiporeg = reg.get_int("I0"); - if ((tiporeg != 2) && (tiporeg != 1)) + const tiporeg tipo = cached_registro(reg).tipo_registro(); + + if ((tipo != acquisto) && (tipo != vendita)) continue; - if (tiporeg == 1) + if (tiporeg == vendita) { - bool sosp = reg.get_bool ("B0"); - if (sosp) continue; - vendite = TRUE; + if (cached_registro(reg).sospeso()) + continue; + vendite = true; } else - vendite = FALSE; + vendite = false; tipodoc = cau.get (CAU_TIPODOC); if (corrispettivo (tipodoc)) diff --git a/src/cg/cg3700.cpp b/src/cg/cg3700.cpp index 7978e2593..721fed667 100755 --- a/src/cg/cg3700.cpp +++ b/src/cg/cg3700.cpp @@ -84,7 +84,6 @@ class TLista_fatture : public TPrintapp protected: long select_firm_range(long from, long to); - int tiporeg(const TString& ); static bool mix_handler(TMask_field&, KEY); static bool date_handler(TMask_field&, KEY); static bool to_ditt_handler(TMask_field&, KEY); @@ -117,12 +116,6 @@ public: inline TLista_fatture& app() { return (TLista_fatture&) main_app(); } -int TLista_fatture::tiporeg(const TString& reg) -{ - TString8 s; s.format("%4d%-3s",_date_from.year(),(const char*)reg); - return atoi(cache().get("REG", s, "I0")); -} - bool TLista_fatture::filter_func1(const TRelation *r) { TLista_fatture& a = app(); @@ -144,8 +137,8 @@ bool TLista_fatture::filter_func1(const TRelation *r) if (riv.get(RMI_TIPODET).blank() || percind.is_zero()) return false; - const int tiporeg = a.tiporeg(rg); - if (tiporeg != 2) + const tiporeg tipo = cached_registro(rg).tipo_registro(); + if (tipo != acquisto) return false; } else // Tipo costo/ricavo @@ -443,8 +436,9 @@ bool TLista_fatture::preprocess_page(int file, int counter) if (_tipo == intra) { TString4 codiva = rec.get(RMI_CODIVA); - const int tipomov = tiporeg(mov.get(MOV_REG)); - if (tipomov == 2 && tipodet == 9) + const tiporeg tipomov = cached_registro(mov.get(MOV_REG)).tipo_registro(); + + if (tipomov == acquisto && tipodet == 9) codiva = "~A19"; // Speciale per acquisti indeducibili art. 19 const bool is_key = _intra_items.is_key(codiva); // Esiste l'elemento ? // Se si' allora prendi quello, altrimenti prendine uno nuovo @@ -469,8 +463,10 @@ bool TLista_fatture::preprocess_page(int file, int counter) _tot_iva += iva; _tp_imp += imp; _tp_iva += iva; - const int tipomov = tiporeg(mov.get(MOV_REG)); - if (_tipo == indetraibile && tipomov == 2 && tipodet > 0) + + const tiporeg tipomov = cached_registro(mov.get(MOV_REG)).tipo_registro(); + + if (_tipo == indetraibile && tipomov == acquisto && tipodet > 0) { TString4 codiva = rec.get(RMI_CODIVA); _Iva_item * iva_row = (_Iva_item *) _indetr.objptr(codiva); diff --git a/src/cg/cg4100.cpp b/src/cg/cg4100.cpp index 7719a25b1..f39d92366 100755 --- a/src/cg/cg4100.cpp +++ b/src/cg/cg4100.cpp @@ -24,7 +24,7 @@ #include #include -#include "cglib02.h" +#include "cglib.h" struct therec { @@ -89,7 +89,7 @@ bool CG4100_App::sort_sal() sal.set_anno_es(year); sal.clear_saldi(year); long numreg = 0L; - tiposal tsal = normale; + tiposal tsal = saldo_normale; char provvis; TDate datareg; @@ -127,20 +127,11 @@ bool CG4100_App::sort_sal() mov.put(MOV_NUMREG, numreg); mov.read(); CHECK(mov.good(),"Archivi movimenti e righe inconsistenti"); + const TString& codcaus = mov.get(MOV_CODCAUS); - // Tipo saldo normale per default - tsal = normale; - const TString& codcaus = mov.get(MOV_CODCAUS); - const TRectype& causale = cache().get(LF_CAUSALI, codcaus); - if (!causale.empty()) - { - const char ac = causale.get_char(CAU_MOVAP); - if (ac == 'A') - tsal = apertura; else - if (ac == 'C') - tsal = chiusura; - } - + tsal = saldo_normale; // Tipo saldo normale per default + if(codcaus.full()) + tsal = cached_causale(codcaus, year).tipo_saldo(); scaricato = mov.get_bool(MOV_SCARCON); provvis = mov.get_char(MOV_PROVVIS); datareg = mov.get_date(MOV_DATAREG); diff --git a/src/cg/cg4300.cpp b/src/cg/cg4300.cpp index 79b104bf5..f3980cc42 100755 --- a/src/cg/cg4300.cpp +++ b/src/cg/cg4300.cpp @@ -208,7 +208,6 @@ bool TLiquidazione_app::user_create() _lam = new TTable("LAM"); _pla = new TTable("%PLA"); _reg = new TTable("REG"); - _iva = new TTable("%IVA"); _del = new TTable("%DEL"); _mov = &_cur->file(LF_MOV); @@ -225,7 +224,6 @@ bool TLiquidazione_app::user_create() _pum_r = &(_pum->curr()); _pam_r = &(_pam->curr()); _pom_r = &(_pom->curr()); - _iva_r = &(_iva->curr()); _del_r = &(_del->curr()); _lam_r = &(_lam->curr()); _pla_r = &(_pla->curr()); diff --git a/src/cg/cg4300.h b/src/cg/cg4300.h index a9b1f7207..642eee98b 100755 --- a/src/cg/cg4300.h +++ b/src/cg/cg4300.h @@ -338,7 +338,6 @@ class TLiquidazione_app : public TPrint_application TTable* _pla; TTable* _ppa; TTable* _reg; - TTable* _iva; TTable* _del; // a reference rectype per file/table @@ -346,7 +345,6 @@ class TLiquidazione_app : public TPrint_application TRectype* _rmoviva_r; TRectype* _pcon_1_r; TRectype* _pcon_2_r; - TRectype* _iva_r; TRectype* _pim_r; TRectype* _pis_r; TRectype* _prm_r; @@ -622,7 +620,7 @@ public: bool look_pla(const char* a, bool create = false); bool look_ppa(int m, const char* a, int t, bool create = false); bool look_del(int month, int type, bool create = false); - bool look_iva(const char* cod); +// bool look_iva(const char* cod); bool look_reg(const char* reg); const TRectype & get_lia(long ditta = 0l, bool create = false, int anno = 0); const int put_lia(const TRectype & lia, bool re = true); diff --git a/src/cg/cg4301.cpp b/src/cg/cg4301.cpp index 58c0db47c..8dbb5ec89 100755 --- a/src/cg/cg4301.cpp +++ b/src/cg/cg4301.cpp @@ -1450,7 +1450,7 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt, TAssoc_array & real nin_iva = ZERO; // imposta non incassati const TString4 codiva = _rmoviva->get(RMI_CODIVA); - TCodiceIVA civa(codiva); + const TCodiceIVA& civa = cached_codIVA(codiva); #ifdef DBG BREAK_DBG; @@ -1466,17 +1466,16 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt, TAssoc_array & continue; } - look_iva(codiva); // da eliminare esso per evitare un problema di non lettura _iva ve eliminato - const TString4 tipoiva = _iva->get("S1"); - const TString4 tipoes_v = _iva->get("S2"); - const TString4 tipoes_a = _iva->get("S9"); - const int tipoagr = _iva->get_int("I4"); // 2/9/2015 was S4 - const int tipoag = _iva->get_int("S5"); - const int tipopla = _iva->get_int("S3"); - int isrimbinfr = _iva->get_bool("B3"); // vale per calcolo rimborso se ES o NI - const real perciva = _iva->get_real("R0") / CENTO; - int ivarimb = !_iva->get_bool("B4"); // non escluso calcolo rimb. per al. media - const bool den_prorata = _iva->get_bool("B7"); // denominatore prorata nel caso di calcolo pro rata con numeratore e denominatore + const TString4 tipoiva = civa.tipo(); + const TString4 tipoes_v = civa.IVA11_vendite(); + const TString4 tipoes_a = civa.IVA11_acquisti(); + const int tipoagr = civa.tipo_IVA_agricola(); // 2/9/2015 was S4 + const int tipoag = civa.tipo_agenzie_viaggio(); + const int tipopla = civa.tipo_plafond(); + int isrimbinfr = civa.codice_rimborso_infrannuale(); // vale per calcolo rimborso se ES o NI + const real perciva = civa.moltiplicatore_percentuale(); + int ivarimb = !civa.escluso_dal_rimborso(); // non escluso calcolo rimb. per al. media + const bool den_prorata = civa.tipo_IVA_agricola(); // denominatore prorata nel caso di calcolo pro rata con numeratore e denominatore const TString4 tipocr_s = _rmoviva->get(RMI_TIPOCR); const int tipocr = atoi(tipocr_s); @@ -1559,7 +1558,7 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt, TAssoc_array & sezfat = tipomov == vendita ? 'D' : 'A'; - if (is_detr_diff == 1 || civa.tipo() == "NS") + if (is_detr_diff == 1 || civa.iva_non_soggetta()) continue; if (bIsMovDiff && tm == tm_fattura) { @@ -2221,8 +2220,10 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt, TAssoc_array & if (_pcon_1_r->get_int(PCN_INDBIL) == 4) if (_cur->is_first_match(-AGR_PCON2)) // Esiste il sottoconto ? { - if (look_iva(_pcon_2_r->get(PCN_IVACOMP))) - ivacomp = _iva->get("CODTAB"); // Ecco il codice IVA di compensazione + const TCodiceIVA & civa = cached_codIVA(_pcon_2_r->get(PCN_IVACOMP)); + + if (civa.ok()) + ivacomp = civa.codice(); // Ecco il codice IVA di compensazione } look_pia(month, codatt, codiva, ivacomp, true); // Crea il record in tabella se non esiste real pia_imp = _pia->get_real("R0") + agr_imp; // Aggiorna... @@ -2727,11 +2728,10 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt, TAssoc_array & if (_pim->get_bool("B4")) { // ricalcola l'imposta a partire dal codice IVA - look_iva(*_pim_codiva); - real old_iva = _pim->get_real("R1"); - real perc = _iva->get_real("R0"); + const TCodiceIVA & civa = cached_codIVA(*_pim_codiva); + const real old_iva = _pim->get_real("R1"); + real new_iva = _pim->get_real("R0") * civa.moltiplicatore_percentuale(); - real new_iva = _pim->get_real("R0") * perc / CENTO; round_al_centesimo(new_iva); if (new_iva != old_iva) @@ -2759,10 +2759,9 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt, TAssoc_array & if (_pia->get_bool("B0")) { // calcola l'imposta a partire dal codice IVA di compensazione - look_iva(*_pia_codcom); - real perc = _iva->get_real("R0"); - - real iva = _pia->get_real("R0") * perc / CENTO; + const TCodiceIVA & civa = cached_codIVA(*_pia_codcom); + real iva = _pia->get_real("R0") * civa.moltiplicatore_percentuale(); + round_al_centesimo(iva); agr_detIA += iva; _pia->put("R1",iva); @@ -2994,12 +2993,14 @@ void TLiquidazione_app::iva11_set_arr_phase_1(const TString& codatt) if (is_split_payment(_mov->curr())) imposta = ZERO; - const TString4 codiva = _iva->get("CODTAB"); - const TString4 tipoiva = _iva->get("S1"); - const real ali = _iva->get_real("R0"); - const TString4 tipoes_v = _iva->get("S2"); - const TString4 tipoes_a = _iva->get("S9"); - const int tipoagr = _iva->get_int("I4"); // 2/9/2015 was S4 + + const TCodiceIVA & civa = cached_codIVA(_rmoviva->get(RMI_CODIVA)); + const TString4 codiva = civa.codice(); + const TString4 tipoiva = civa.tipo(); + const real ali = civa.percentuale(); + const TString4 tipoes_v = civa.IVA11_vendite(); + const TString4 tipoes_a = civa.IVA11_acquisti(); + const int tipoagr = civa.tipo_IVA_agricola(); // 2/9/2015 was S4 const TRectype& rcs = _cur->curr(LF_CAUSALI); const bool autofattura = rcs.get_bool("AUTOFATT"); const bool valintra = rcs.get_bool("VALINTRA"); @@ -3379,14 +3380,17 @@ void TLiquidazione_app::iva11_set_arr_phase_2(const TString& codatt) // Must consider current activity too... codiva = *_pim_codiva; reg = *_pim_codreg; - look_iva(codiva); look_reg(reg); // posiziona la tabella registri e quella IVA - tiva = _iva->get("S1"); // tipo IVA - tpla = _iva->get("S3"); // tipo gestione plafond - tagr = _iva->get_int("I4"); // tipo gestione regime agricolo 2/9/2015 was S4 - tvia = _iva->get("S5"); // tipo gestione ag. viaggio - v11 = _iva->get("S2"); // n.ro riga vendite per mod. IVA11 - a11 = _iva->get("S9"); // n.ro riga acquisti per mod. IVA11 - aliq = _iva->get_real("R0"); // aliquota + + const TCodiceIVA & civa = cached_codIVA(codiva); + + look_reg(reg); // posiziona la tabella registri e quella IVA + tiva = civa.tipo(); // tipo IVA + tpla = civa.tipo_plafond(); // tipo gestione plafond + tagr = civa.tipo_IVA_agricola(); // tipo gestione regime agricolo 2/9/2015 was S4 + tvia = civa.tipo_agenzie_viaggio(); // tipo gestione ag. viaggio + v11 = civa.IVA11_vendite(); // n.ro riga vendite per mod. IVA11 + a11 = civa.IVA11_acquisti(); // n.ro riga acquisti per mod. IVA11 + aliq = civa.percentuale(); // aliquota treg = (tiporeg)_reg->get_long("I0"); const bool is_vendita = treg == vendita; const bool is_acquisto = treg == acquisto; @@ -3484,7 +3488,7 @@ void TLiquidazione_app::iva11_set_arr_phase_2(const TString& codatt) _CorrItem& ca = (_CorrItem&) corr_ann[codiva]; ca._totale += lor; if (!is_present) - ca._aliquota = _iva->get_real("R0"); // Se e' nuovo setta l'aliquota + ca._aliquota = civa.percentuale(); // Se e' nuovo setta l'aliquota } tt = _pim->get("S0"); @@ -4541,8 +4545,10 @@ void TLiquidazione_app::recalc_annual(const char* att, bool & first) const int tipocr = atoi(*_pim_tipocr); codiva = *_pim_codiva; reg = *_pim_codreg; - look_iva(codiva); look_reg(reg); - tiva = _iva->get("S1"); + const TCodiceIVA & civa = cached_codIVA(codiva); + + look_reg(reg); + tiva = civa.tipo(); const TRegistro & reg = cached_registro(_reg->curr()); const tipo_sospensione simp = reg.sospensione(); @@ -4573,7 +4579,7 @@ void TLiquidazione_app::recalc_annual(const char* att, bool & first) _CorrItem& ca = (_CorrItem&)corr_ann[codiva]; ca._totale += _pim->get_real("R3"); if (!is_key) // se non c'e' lo aggiunge - ca._aliquota = _iva->get_real("R0") / CENTO; // Se è nuovo setta l'aliquota + ca._aliquota = civa.moltiplicatore_percentuale(); // Se è nuovo setta l'aliquota } if (tipoatt == 1) volaff1 += imp_ifs; diff --git a/src/cg/cg4302.cpp b/src/cg/cg4302.cpp index 28c47c8ba..1e45fa0c8 100755 --- a/src/cg/cg4302.cpp +++ b/src/cg/cg4302.cpp @@ -583,6 +583,7 @@ bool TLiquidazione_app::look_reg(const char* reg) return rt; } +/* bool TLiquidazione_app::look_iva(const char* cod) { bool rt = true; @@ -603,6 +604,7 @@ bool TLiquidazione_app::look_iva(const char* cod) return rt; } +*/ bool TLiquidazione_app::look_ppa(int month, const char* codatt, int type, bool create) { @@ -981,8 +983,10 @@ real TLiquidazione_app::aliquota_agvia() { real r; const TString& codagv = ini_get_string(CONFIG_STUDIO, "cg", "CodAgv"); - if (codagv.full() && look_iva(codagv)) // Controlla se è vuoto! CM600475 - r = _iva->get_real("R0"); + const TCodiceIVA & civa = cached_codIVA(codagv); + + if (civa.ok()) // Controlla se è vuoto! CM600475 + r = civa.percentuale(); return r; } diff --git a/src/cg/cg4303.cpp b/src/cg/cg4303.cpp index d521bc851..0fb74019b 100755 --- a/src/cg/cg4303.cpp +++ b/src/cg/cg4303.cpp @@ -95,10 +95,13 @@ void TLiquidazione_app::recalc_corrispettivi(int month, const char* codatt) vaf += imponibile; _pam->put("R1", vaf); _pam->rewrite(); + // Aggiorna il totale IVA periodica CD1_1 - if (month == 13 && look_iva(ci->_codiva)) + const TCodiceIVA & civa = cached_codIVA(ci->_codiva); + + if (month == 13 && civa.ok()) { - if (_iva->get("S10").not_empty()) // Solo CD1_1 ha senso coi corrispettivi... + if (civa.tipo_comunicazione_attive().full()) // Solo CD1_1 ha senso coi corrispettivi... { _pum->curr().add("R14", imponibile); // CD1_1 _pum->rewrite(); @@ -142,12 +145,11 @@ void TLiquidazione_app::recalc_ventilation(int month, const char* codatt) int tipocr = atoi(*_pim_tipocr); int mese = atoi(*_pim_mese); int tipodet = atoi(*_pim_tipodet); - look_iva(*_pim_codiva); + const TCodiceIVA & civa = cached_codIVA(*_pim_codiva); // base di riparto solo se non esente, non soggetto, non imponibile - TString16 tipoiva(_iva->get("S1")); + TString16 tipoiva(civa.tipo()); TString16 reg = *_pim_codreg; - /* * caso particolare SENSU Vladimiro (1995) #MI3001 * questi vengono pero' conteggiati nel totale @@ -161,18 +163,15 @@ void TLiquidazione_app::recalc_ventilation(int month, const char* codatt) if (tipocr == 1 && (mese == m) && att == (const char*)(*_pim_codatt)) { - if (tipoiva != "NS" && tipoiva != "NI" && tipoiva != "ES") + if (civa.iva_da_ventilare()) { real lurd = _pim->get_real("R0"); lurd += _pim->get_real("R1"); - real perc = _iva->get_real("R0"); - TString other = _iva->get("S6"); - if (!other.empty()) - { - // ventila a un altro codice - look_iva(other); - perc = _iva->get_real("R0"); - } + real perc = civa.percentuale(); + TString other = civa.iva_a_cui_ventilare(); + + if (other.full()) + perc = cached_codIVA(other).percentuale(); // ventila a un altro codice add_ventilation(perc / CENTO, lurd, *_pim_codiva, other); } } @@ -341,9 +340,11 @@ void TLiquidazione_app::recalc_ventilation(int month, const char* codatt) _pam->rewrite(); // Aggiorna il totale IVA periodica CD1_1 - if (month == 13 && look_iva(vv->_codiva)) + const TCodiceIVA & civa = cached_codIVA(vv->_codiva); + + if (month == 13 && civa.ok()) { - if (_iva->get("S10").not_empty()) // Solo CD1_1 ha senso coi corrispettivi + if (civa.get("S10").full()) // Solo CD1_1 ha senso coi corrispettivi { _pum->curr().add("R14", imponibile); // CD1_1 _pum->rewrite(); @@ -364,9 +365,10 @@ void TLiquidazione_app::recalc_ventilation(int month, const char* codatt) // viene amorosamente messo a quanto il codice IVA prevede if (!was) { - look_iva(vv->_codiva); + const TCodiceIVA & civa = cached_codIVA((vv->_codiva)); + _pim->put("I1", (long)vendita); - if (!_iva->get_bool("B4")) + if (!civa.escluso_dal_rimborso()) _pim->put("B3", "X"); } _pim->rewrite(); @@ -533,8 +535,8 @@ _DescrItem* TLiquidazione_app::recalc_rimborso(int month, const char* codatts, if (!_pim->get_bool("B3")) continue; // Se il tipo di codice e' NS non va considerato nella sommatoria del tot. acquisti - look_iva(codiva); - const bool non_sogg = _iva->get("S1") == "NS"; + const TCodiceIVA & civa = cached_codIVA(codiva); + const bool non_sogg = civa.iva_non_soggetta(); if (!is_mens) // Trimestrali { @@ -565,7 +567,7 @@ _DescrItem* TLiquidazione_app::recalc_rimborso(int month, const char* codatts, ca._totale += _pim->get_real("R3"); if (!is_key) // se non c'e' lo aggiunge { - ca._aliquota = _iva->get_real("R0")/CENTO; // Se e' nuovo setta l'aliquota + ca._aliquota = civa.moltiplicatore_percentuale(); // Se e' nuovo setta l'aliquota corr_ann.add(codiva,ca); } } diff --git a/src/cg/cg4304.cpp b/src/cg/cg4304.cpp index 802b36f0a..fe6386e0d 100755 --- a/src/cg/cg4304.cpp +++ b/src/cg/cg4304.cpp @@ -286,7 +286,7 @@ void TLiquidazione_app::describe_ventilation(int month, const char* codatt) continue; look_reg(*_pim_codreg); - look_iva(*_pim_codiva); + const TCodiceIVA & civa = cached_codIVA(*_pim_codiva); int tipocr = atoi(*_pim_tipocr); int tipodet = atoi(*_pim_tipodet); @@ -295,7 +295,7 @@ void TLiquidazione_app::describe_ventilation(int month, const char* codatt) real imponibile = _pim->get_real("R0"); real imposta = _pim->get_real("R1"); tiporeg tipomov = (tiporeg)_reg->get_long("I0"); - TString4 tipoiva = _iva->get("S1"); + TString4 tipoiva = civa.tipo(); if (_year != *_pim_anno || (month == 13 && mese < 13)) continue; @@ -564,28 +564,19 @@ void TLiquidazione_app::describe_pims(int month, const char* codatt, const bool continue; TString4 codiva = codtab.mid(16,4); codiva.trim(); - if (!look_iva(codiva)) + const TCodiceIVA & civa = cached_codIVA(codiva); + + if (!civa.ok()) continue; tiporeg tipomov = (tiporeg)_reg->get_int("I0"); bool corrisp = _reg->get_bool("B0"); - const TString4 tipoiva = _iva->get("S1"); + const TString4 tipoiva = civa.tipo(); const TString4 other = tab->get("S4"); TToken_string s1(tab->get("S1"), '!'); // Imponibile/iva fatture in ritardo real rit_imp(s1.get(0)); real rit_iva(s1.get(1)); - /* Perchè _pim invece di tab ? 17-10-2012 - diffimp = _pim->get_real("R26"); - diffiva = _pim->get_real("R27"); - diffincimp = _pim->get_real("R28"); - diffinciva = _pim->get_real("R29"); - - diffimp_acq = _pim->get_real("R30"); - diffiva_acq = _pim->get_real("R31"); - diffincimp_acq = _pim->get_real("R32"); - diffinciva_acq = _pim->get_real("R33"); */ - diffimp = tab->get_real("R26"); diffiva = tab->get_real("R27"); diffincimp = tab->get_real("R28"); @@ -603,10 +594,10 @@ void TLiquidazione_app::describe_pims(int month, const char* codatt, const bool issosp |= (sosp_imp != nessuna_sospensione); // Setta il flag di presenza registri in sospensione (qualsiasi tipo: sospensione_normale, vol_affari, liquidazione) // ACHTUNG! Corrispettivi da ventileer possono ventilare ad un altro codiva; in tal caso si scrive quello if (corrisp && other.full()) - { - look_iva(other); codiva = other; - } + + const TCodiceIVA & civa1 = cached_codIVA(codiva); // codice IVA aggiornato per eventuale ventilazione + // se e' corrispettivo da ventilare non scrivo un cannolo ripieno visto che e' stato ventilato if (tipomov == vendita && tipoiva == "VE" && !describe_pis) continue; @@ -713,7 +704,7 @@ void TLiquidazione_app::describe_pims(int month, const char* codatt, const bool ca._totale_vf += tab->get_real(tipoiva == "VE" ? "R2" : "R3"); if (!is_key) // se non c'e' lo aggiunge { - ca._aliquota = _iva->get_real("R0")/CENTO; // Se e' nuovo setta l'aliquota + ca._aliquota = civa.moltiplicatore_percentuale(); // Se e' nuovo setta l'aliquota corr_ann.add(codiva,ca); } // vedi corrispettivi veri e falsi @@ -1804,8 +1795,9 @@ void TLiquidazione_app::set_pim(_DescrItem& d) rw++; else { - look_iva(d._s1); - d._s2 = _iva->get("S0"); + const TCodiceIVA & civa = cached_codIVA(d._s1); + + d._s2 = civa.get("S0"); if (d._s2.len() > 19) d._s2.cut(19); } @@ -2934,8 +2926,9 @@ void TLiquidazione_app::set_ventila(_DescrItem& d) for(i = 0; i < d._arr.items(); i++) { _vDesc& vd = (_vDesc&)d._arr[i]; - look_iva(vd._codiva); - s0 = _iva->get("S0"); s0.cut(23); + const TCodiceIVA & civa = cached_codIVA(vd._codiva); + + s0 = civa.descrizione(); s0.cut(23); set_row(row+i,"@8g%5s@17g%-23s@41g%r@68g%r@89g%r", (const char*)vd._codiva, @@ -3065,13 +3058,15 @@ void TLiquidazione_app::set_regagr(_DescrItem& d) _DescrItem& di = (_DescrItem&) agr_array[i]; if (di._flags != PROGAGR) continue; - look_iva(di._s0); - des = _iva->get("S0"); des.cut(25); - al = _iva->get_real("R0"); + + const TCodiceIVA & civa = cached_codIVA(di._s0); + + des = civa.descrizione(); des.cut(25); + al = civa.percentuale(); set_row(r,"%4s %-25s@48g%s %%", (const char*) di._s0, (const char*) des, al.string("#@,@@")); set_row(r,"@56g%r@75g%4s",&di._r0, (const char*)di._s1); - look_iva(di._s1); - al = _iva->get_real("R0"); + const TCodiceIVA & civa1 = cached_codIVA(di._s1); + al = civa1.percentuale(); set_row(r++,"@92g%s %%@100g%r", al.string("#@,@@"), &di._r1); t1 += di._r0; t2 += di._r1; diff --git a/src/cg/cg5300.cpp b/src/cg/cg5300.cpp index eebb3d5a0..69d0a004a 100755 --- a/src/cg/cg5300.cpp +++ b/src/cg/cg5300.cpp @@ -450,7 +450,7 @@ int TParaliq_app::read(TMask& m) TCursor cur(&relpla, "", 1, &pla, &pla); const TRecnotype items = cur.items(); - sf.destroy(); + sf.reset(); if (items == 0) init_array(sf); // Carica tutti i codici attività else diff --git a/src/cg/cg7600.cpp b/src/cg/cg7600.cpp index 6ee35f88c..2f5a3206a 100644 --- a/src/cg/cg7600.cpp +++ b/src/cg/cg7600.cpp @@ -112,6 +112,8 @@ void TQuadro_VE_recordset::load() { const TRectype & pimr = pim.cursor()->curr(); TString8 codiva(codtab.mid(16,4)); codiva.trim(); + if (codiva == "274") + int i = 1; const TRectype & ivar = cache().get("%IVA", codiva); const TString8 aliquota = ivar.get("R0"); const TString4 tipo_aliquota = ivar.get("S1"); @@ -160,6 +162,16 @@ void TQuadro_VE_recordset::load() add_value(STRING_TOKEN(imposta.objptr(aliquota)), iva); } } + else + { + const int tipocr = atoi(codtab.mid(15, 1)); // tipo costo_ricavo + + if (tipocr == 4) + { + if (int_tipo_iva11_ven == acq_ind_pass_int || int_tipo_iva11_ven == cess_amm) + add_value("VE40.1", imp); + } + } break; case acq_simp: break; @@ -185,12 +197,12 @@ void TQuadro_VE_recordset::load() break; case acq_ind_pass_int: // passaggi interni if (vendite) - add_value("VE40.1", iva); + add_value("VE40.1", imp); break; case acq_ind_art_19: // indetr. art. 19 break; case cess_amm: // cessioni amministrative - add_value("VE40.1", iva); + add_value("VE40.1", imp); break; case vend_rimborso: // vendite valide per rimborso break; @@ -251,24 +263,28 @@ void TQuadro_VE_recordset::load() } } + /* 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(); + TString8 cod(exp.get(FIELD_NAME(LF_RMOVIVA, RMI_CODIVA)).as_string()); + const TCodiceIVA & codiva = cached_codIVA(cod); + const TString & aliquota = codiva.aliquota(); + const TRectype & mov = cache().get(LF_MOV, exp.get(FIELD_NAME(LF_RMOVIVA, RMI_NUMREG)).as_int()); - 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); - } - } + if (aliquota.full()) + { + const real imp = exp.get(FIELD_NAME(LF_RMOVIVA, RMI_IMPONIBILE)).as_real(); + real iva = exp.get(FIELD_NAME(LF_RMOVIVA, RMI_IMPOSTA)).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); @@ -305,6 +321,7 @@ void TQuadro_VE_recordset::load() } } + query = "USE LIM\n FROM CODTAB=="; query << year() << "13\nTO CODTAB==" << year() << "13"; diff --git a/src/cg/cg7700.cpp b/src/cg/cg7700.cpp index 23519d24a..7d63d1d26 100644 --- a/src/cg/cg7700.cpp +++ b/src/cg/cg7700.cpp @@ -286,9 +286,9 @@ void TQuadro_VF_recordset::load() } if (non_soggetto) { - if (tipo_iva11_acq == "15A" || int_tipo_iva11_acq == 15) + if (int_tipo_iva11_acq == 15) { - if (tipo_iva11_acq == "15A") + if (tipo_iva11_acq == "15B") add_value("VF17.2", imp); add_value("VF17.1", imp); } diff --git a/src/cg/cglib.h b/src/cg/cglib.h index 2f91baa76..9768a2cfe 100644 --- a/src/cg/cglib.h +++ b/src/cg/cglib.h @@ -108,30 +108,9 @@ class TProgind; static const char * __date_field_name[] = { MOV_DATAREG, MOV_DATACOMP, MOV_DATACOMPCR }; - -enum TipoIVA -{ - iva_errata = -1, - nessuna_iva = 0, - iva_vendite = 1, - iva_acquisti = 2, - libro_giornale = 5, - iva_generica = 9 -}; - -enum tipo_movimento -{ - tm_nessuno = 0, - tm_fattura = 1, - tm_nota_credito = 2, - tm_pagamento = 3, - tm_insoluto = 5, - tm_pagamento_insoluto = 6 -}; - - -enum cgrowtypes -{ +typedef enum { iva_errata = -1, nessuna_iva = 0, iva_vendite = 1, iva_acquisti = 2, libro_giornale = 5, iva_generica = 9 } TipoIVA; +typedef enum { tm_nessuno = 0, tm_fattura = 1, tm_nota_credito = 2, tm_pagamento = 3, tm_insoluto = 5, tm_pagamento_insoluto = 6 } tipo_movimento; +typedef enum { cgrowtype_contabile = ' ', // riga contabile cgrowtype_totale = 'T', // Totale documento cgrowtype_abbattivo = 'A', // Abbuoni attivi @@ -149,47 +128,12 @@ enum cgrowtypes cgrowtype_imponibile = 'I', // Imponibile/contropartita saldaconto cgrowtype_clisplit = '1', // Cliente per scissione pagamenti art.17-ter DPR 633/72 cgrowtype_spese = 'G' // Spese del saladaconto -}; - -enum tipo_sospensione -{ - nessuna_sospensione, - sospensione_normale, - vol_affari, - liquidazione -}; - -enum tipobil -{ - DataLimite = 1, - UltimaImmissione -}; - -enum tiposal -{ - saldo_normale, - saldo_apertura, - saldo_chiusura -}; - -enum TTipo_data -{ - Registrazione, - Competenza, - CostiRicavi -}; - -enum tiporeg -{ - vendita = 1, - acquisto = 2, - riepilogativo = 3, - incassi = 4, - giornale = 5, - sociale = 6, - cespiti = 7, - giornale_magazzino = 9 -}; +} cgrowtypes; +typedef enum { nessuna_sospensione, sospensione_normale, vol_affari, liquidazione } tipo_sospensione; +typedef enum { DataLimite = 1, UltimaImmissione} tipobil; +typedef enum { saldo_normale, saldo_apertura, saldo_chiusura} tiposal; +typedef enum { Registrazione, Competenza, CostiRicavi } TTipo_data; +typedef enum { vendita = 1, acquisto = 2, riepilogativo = 3, incassi = 4, giornale = 5, sociale = 6, cespiti = 7, giornale_magazzino = 9 } tiporeg; inline bool check_mov(const int tipomovprovv, const TString & provvis) { diff --git a/src/cg/cglib01.h b/src/cg/cglib01.h index d57323cd1..53f70b81d 100755 --- a/src/cg/cglib01.h +++ b/src/cg/cglib01.h @@ -172,6 +172,7 @@ public: // TObject real imposta(const real& imponibile, int ndec = AUTO_DECIMALS, const char * codval = "") const; // Calcola l'imposta sull'imponibile l'imposta e la ritorna real scorpora(real& imponibile, int ndec = AUTO_DECIMALS, const char * codval = "") const; // Scorpora dall'imponibile l'imposta e la ritorna real lordo(const real& imponibile, int ndec = AUTO_DECIMALS, const char * codval = "") const; // Calcola il lordo dell'imponibile l'imposta e la ritorna + real imponibile(const real& imposta, int ndec = AUTO_DECIMALS, const char * codval = "") const; // Calcola l'imponibile dell'imposta e lo ritorna // bool reverse_charge() const; // bool reverse_charge_pubb() const; diff --git a/src/cg/cgpim.cpp b/src/cg/cgpim.cpp index d2b34d449..26532936e 100755 --- a/src/cg/cgpim.cpp +++ b/src/cg/cgpim.cpp @@ -31,11 +31,11 @@ bool classify_pim(const TRectype& pimr, real& imp, real& iva, tiporec& t, bool t switch(tocheck) { - case acq_norm: + case acq_norm: //found = tipomov == 2 && tipoiva != "NS"; found = tipomov == 2; found &= (tipodet == 0 /* || tipodet == 1 || tipodet == 3 || - tipodet == 5 || tipodet == 9 */); + tipodet == 5 || tipodet == 9 */); if (found) { if (tipost) //stampa @@ -57,7 +57,7 @@ bool classify_pim(const TRectype& pimr, real& imp, real& iva, tiporec& t, bool t break; case vend_norm: //found = tipomov == 1 /* && corrisp == 1 */ && tipoiva != "NS"; - found = tipomov == 1 /* && corrisp == 1 */; + found = tipomov == 1 /* && corrisp == 1 */; if (found) { imp = pimr.get_real("R0"); diff --git a/src/cm/cm1100.cpp b/src/cm/cm1100.cpp index 1ceafa2b6..e44b97df4 100755 --- a/src/cm/cm1100.cpp +++ b/src/cm/cm1100.cpp @@ -10,7 +10,7 @@ #include #include "..\cg\cgsaldac.h" -#include "..\cg\cg2103.h" +#include "..\cg\cglib.h" #include "..\ve\velib.h" #include "cm1100a.h" diff --git a/src/crpa/crpa0.cpp b/src/crpa/crpa0.cpp index c40cda5b5..623adbdb0 100755 --- a/src/crpa/crpa0.cpp +++ b/src/crpa/crpa0.cpp @@ -11,7 +11,7 @@ #include "../ce/collces.h" #include "../ve/velib.h" -#include "../cg/cg2103.h" +#include "../cg/cglib.h" #include "../ca/movana.h" #include "../ca/rmovana.h" diff --git a/src/db/db0500.cpp b/src/db/db0500.cpp index 6104e7033..bfbdfd8a2 100755 --- a/src/db/db0500.cpp +++ b/src/db/db0500.cpp @@ -972,7 +972,7 @@ private: protected: virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly); - bool test_row(const TToken_string& row); + bool test_row(int nrow); void load_um(); static void sheetrighe_get(TSheet_field &fld_righe, int item); @@ -1071,12 +1071,13 @@ void TDistinta_mask::load_um() } -bool TDistinta_mask::test_row(const TToken_string& row) +bool TDistinta_mask::test_row(int nrow) { + TSheet_field& sheet = sfield(F_SHEET); const TCodice_articolo father = get(F_CODICE); - - TCodice_articolo code; row.get(1, code); + TCodice_articolo code = sheet.get_str_row_cell(nrow, F_CODART); bool ok = code != father; + if (ok && _tree.find_node(father) > 0) { TToken_string path; _tree.curr_id(path); @@ -1088,12 +1089,9 @@ bool TDistinta_mask::test_row(const TToken_string& row) "in quanto la distinta risulterebbe ciclica."), (const char*)code); // Se e' una lavorazione - if (get(F_TIPO)[0] == 'L') - { - ok = row[0] == 'L' && _tree.is_lav(code); - if (!ok) - error_box(FR("Il codice '%s' non e' una lavorazione"), (const char*)code); - } + if ((get(F_TIPO) == "L") && + !(sheet.get_str_row_cell(nrow, F_TIPOCOMP) == "L" && _tree.is_lav(code))) + return error_box(FR("Il codice '%s' non e' una lavorazione"), (const char*)code); return ok; } @@ -1170,41 +1168,47 @@ bool TDistinta_mask::on_unitsheet_event(TOperable_field& o, TField_event e, long bool TDistinta_mask::on_distsheet_event(TOperable_field& o, TField_event e, long jolly) { const short id = o.dlg(); + switch (id) { case F_SHEET: - if (e == se_notify_add || e == se_notify_modify || e == fe_close) + if (e == se_notify_add || e == se_notify_modify || e == fe_close) { - TSheet_field& sheet = (TSheet_field&)o; - const int nrig = int(jolly); - TToken_string& row = sheet.row(nrig); + + switch(e) { case se_notify_add: - row.add("A", F_TIPOCOMP-FIRST_FIELD); // Forza il listbox ad articolo - row.add("", F_EXPR-FIRST_FIELD); // Forza la quantita' ad 1 - row.add(nrig+1, F_SORT0-FIRST_FIELD); // Inizializza numero riga - sheet.select(nrig); + { + TSheet_field& sheet = (TSheet_field&)o; + const int nrig = int(jolly); + + sheet.set_row_cell(F_TIPOCOMP, "A", nrig); // Forza il listbox ad articolo + sheet.set_row_cell(F_EXPR, 1, nrig); // Forza la quantita' ad 1 + sheet.set_row_cell(F_SORT0, nrig + 1, nrig); // Inizializza numero riga + sheet.select(nrig); + sheet.force_update(nrig); + } break; case se_notify_modify: - return test_row(row); + return test_row(int(jolly)); + break; case fe_close: { + TSheet_field& sheet = (TSheet_field&)o; + const int nrig = int(jolly); TString80 code; - TString80 code1; + for (int n = sheet.items()-1; n >= 0; n--) { - const TToken_string& row = sheet.row(n); - row.get(F_CODART-FIRST_FIELD, code); - if (!code.blank()) + code = sheet.get_str_row_cell(n, F_CODART); + if (code.full()) { - if (!test_row(row)) + if (!test_row(nrig)) return false; for (int m = n - 1; m >= 0; m--) { - const TToken_string& row = sheet.row(m); - row.get(F_CODART-FIRST_FIELD, code1); - if (code == code1) + if (code == sheet.get_str_row_cell(m, F_CODART)) { int k = noyesall_box("Il codice %s e' ripetuto alla riga %d,\ncontinuare ugualmente ?", (const char *) code, n + 1); if (k == K_NO) @@ -1219,7 +1223,7 @@ bool TDistinta_mask::on_distsheet_event(TOperable_field& o, TField_event e, long sheet.destroy(n); } } - if (sheet.items() == 0) + if (((TSheet_field&)o).items() == 0) message_box(TR("E' necessario inserire almeno una riga nella distinta")); break; default: diff --git a/src/db/db0500b.uml b/src/db/db0500b.uml index 093d820b2..2b02867c7 100755 --- a/src/db/db0500b.uml +++ b/src/db/db0500b.uml @@ -246,13 +246,13 @@ LIST F_TIPOCOMP 1 12 BEGIN PROMPT 2 1 "Tipo " ITEM "A|Articolo" - MESSAGE SHOW,11@|HIDE,12@|HIDE,13@|HIDE,14@|ENABLE,F_UMEXPR|ENABLE,11@|DISABLE,12@|DISABLE,13@|DISABLE,14@ + MESSAGE SHOW,11@|HIDE,12@|HIDE,13@|HIDE,14@|ENABLE,F_UMEXPR|ENABLE,11@|CLEAR,12@|CLEAR,13@|CLEAR,14@ ITEM "L|Lavorazione" - MESSAGE HIDE,11@|SHOW,12@|HIDE,13@|HIDE,14@|DISABLE,F_UMEXPR|DISABLE,11@|ENABLE,12@|DISABLE,13@|DISABLE,14@ + MESSAGE HIDE,11@|SHOW,12@|HIDE,13@|HIDE,14@|CLEAR,F_UMEXPR|CLEAR,11@|ENABLE,12@|CLEAR,13@|CLEAR,14@ ITEM "D|Distinta" - MESSAGE HIDE,11@|HIDE,12@|SHOW,13@|HIDE,14@|ENABLE,F_UMEXPR|DISABLE,11@|DISABLE,12@|ENABLE,13@|DISABLE,14@ + MESSAGE HIDE,11@|HIDE,12@|SHOW,13@|HIDE,14@|ENABLE,F_UMEXPR|CLEAR,11@|CLEAR,12@|ENABLE,13@|CLEAR,14@ ITEM "V|Variabile" - MESSAGE HIDE,11@|HIDE,12@|HIDE,13@|SHOW,14@|CLEAR,F_UMEXPR|DISABLE,11@|DISABLE,12@|DISABLE,13@|ENABLE,14@ + MESSAGE HIDE,11@|HIDE,12@|HIDE,13@|SHOW,14@|CLEAR,F_UMEXPR|CLEAR,11@|CLEAR,12@|CLEAR,13@|ENABLE,14@ FIELD TIPO END @@ -282,8 +282,8 @@ BEGIN OUTPUT F_CODLAV CODTAB OUTPUT F_DESLAV S0 CHECKTYPE REQUIRED - FIELD CODCOMP - FLAGS "UHD" + FIELD CODCOMP + FLAGS "UHD" GROUP 12 END @@ -297,7 +297,7 @@ BEGIN OUTPUT F_CODDIS CODDIST OUTPUT F_DESDIS DESCR CHECKTYPE REQUIRED - FIELD CODCOMP + FIELD CODCOMP FLAGS "UHD" GROUP 13 END diff --git a/src/db/db1100.cpp b/src/db/db1100.cpp index 31cf11395..30c8a5dfc 100755 --- a/src/db/db1100.cpp +++ b/src/db/db1100.cpp @@ -11,7 +11,7 @@ #include #include -#include "../cg/cglib01.h" +#include "../cg/cglib.h" #include "../mg/mglib.h" #include "../ve/velib.h" #include "dblib.h" diff --git a/src/db/db1300.cpp b/src/db/db1300.cpp index 64dc7af85..2f9214c51 100755 --- a/src/db/db1300.cpp +++ b/src/db/db1300.cpp @@ -454,7 +454,7 @@ int TImplosion_mask::find_roots(const char* articolo, TAssoc_array& roots) const TAssoc_array ass[2]; int c = 0; // Array dei children = 0; fathers = 1 - ass[c].add(articolo, NULL); + ass[c].add(articolo); const char* cap = FR("Livello %d - Articoli %ld"); TString caption; caption.format(cap, 0, 0L); @@ -478,7 +478,7 @@ int TImplosion_mask::find_roots(const char* articolo, TAssoc_array& roots) const for (cur = 0L; cur.pos() < cur.items(); ++cur) { const TString& father = cur.curr().get("CODDIST"); - ass[!c].add(father, NULL); + ass[!c].add(father); } cur.freeze(FALSE); } @@ -559,7 +559,7 @@ void TImplosion_mask::implode_slow() key << row->get(); key.rtrim(); } - _xmas.add(key, NULL); + _xmas.add(key); } } @@ -623,7 +623,7 @@ void TImplosion_mask::implode_medium() key = articolo; if (livello.not_empty()) key << '|' << livello; - _xmas.add(key, NULL); + _xmas.add(key); TAssoc_array roots; const long items = find_roots(articolo, roots); diff --git a/src/db/dbtblav.h b/src/db/dbtblav.h index 59ecc28ad..c4c769a92 100755 --- a/src/db/dbtblav.h +++ b/src/db/dbtblav.h @@ -1,25 +1,25 @@ -#define F_CODICE 101 -#define F_DESCR 102 -#define F_COSUNIT 103 -#define F_UNMIS 104 -#define F_STAMPA 105 -#define F_UMDESC 106 -#define F_CODICEART 107 -#define F_SEARCHART 108 -#define F_SHEET 109 -#define F_NUMPERS 110 -#define F_PRODUTTIV 111 -#define F_UNTEMPO 112 -#define F_DESUNTEMPO 113 -#define F_UNMIS2 114 -#define F_LINEESTD 115 -#define F_PERCMIN 116 -#define F_PRODNRIL 117 +#define F_CODICE 201 +#define F_DESCR 202 +#define F_COSUNIT 203 +#define F_UNMIS 204 +#define F_STAMPA 205 +#define F_UMDESC 206 +#define F_CODICEART 207 +#define F_SEARCHART 208 +#define F_SHEET 209 +#define F_NUMPERS 210 +#define F_PRODUTTIV 211 +#define F_UNTEMPO 212 +#define F_DESUNTEMPO 213 +#define F_UNMIS2 214 +#define F_LINEESTD 215 +#define F_PERCMIN 216 +#define F_PRODNRIL 217 -#define F_CODLIN 101 -#define F_DESCRLIN 102 -#define F_CODIMP 103 -#define F_LNUMPERS 104 -#define F_LPRODUTTIV 105 +#define F_CODLIN 101 +#define F_DESCRLIN 102 +#define F_CODIMP 103 +#define F_LNUMPERS 104 +#define F_LPRODUTTIV 105 #define F_DESCRIMP 120 diff --git a/src/ef/ef0100.cpp b/src/ef/ef0100.cpp index 3e70dde8d..563425b55 100755 --- a/src/ef/ef0100.cpp +++ b/src/ef/ef0100.cpp @@ -524,6 +524,23 @@ bool TEffetti_mask::on_field_event(TOperable_field& o, TField_event e, long joll if (e == fe_modify) sfield(F_SHEET_RIGHE).set_focusdirty(); break; + case F_IBAN_STATO: + if (mode() == MODE_MOD && e == fe_init) + { + TRelation * rel = app().get_relation(); + + if (rel != nullptr) + { + TRectype & rec = rel->lfile().curr(); + + if (rec.get(EFF_IBAN).empty()) + { + set(F_CODABI, rec.get(EFF_CODABI)); + set(F_CODCAB, rec.get(EFF_CODCAB)); + return true; + } + } + } case F_SHEET_RIGHE: return on_sheet_event(o, e, jolly); default: diff --git a/src/f1/f1lib.cpp b/src/f1/f1lib.cpp index 55a2ae491..776245c5b 100644 --- a/src/f1/f1lib.cpp +++ b/src/f1/f1lib.cpp @@ -20,20 +20,14 @@ TFppro& fppro_db() return *fppro; } -bool TFppro::sql_inj(const TString& str) -{ - TString appo; appo << str; - appo.upper(); - return appo.contains("--") || appo.contains("SELECT") || appo.contains("DELETE") || appo.contains("DROP"); -} - -bool TFppro::sql_inj(const keys_s& keys) +bool TFppro::sql_inj(TToken_string& keys) { TToken_string str("", ';'); - str.add(keys.prginvio); - str.add(keys.headerfatt); - str.add(keys.bodyfatt); - return sql_inj(str); + + str.add(keys.get(0)); + str.add(keys.get(1)); + str.add(keys.get(2)); + return str.contains("--") || str.contains("SELECT") || str.contains("DELETE") || str.contains("DROP"); } bool TFppro::check_reg(TToken_string& keys, int numreg) @@ -44,68 +38,74 @@ bool TFppro::check_reg(TToken_string& keys, int numreg) bool TFppro::guess_the_doc(const TLocalisamfile& mov) { // Prendo il fornitore del mov per controllare la p.iva - TLocalisamfile clifo(LF_CLIFO); - clifo.put(CLI_TIPOCF, "F"); - const TString& codforn = mov.get(MOV_CODCF); - clifo.put(CLI_CODCF, codforn); - clifo.read(); - TString cli_statopiva, cli_piva; - cli_statopiva << clifo.get(CLI_STATOPAIV); - cli_piva << clifo.get(CLI_PAIV); + TCli_for forn = cached_clifor('F', mov.get_long(MOV_CODCF)); + + const TString4 statopiva(forn.get(CLI_STATOPAIV)); + const real tot = mov.get_real(MOV_TOTDOC) + mov.get_real(MOV_RITFIS) + mov.get_real(MOV_RITSOC); TString numdoc = mov.get(MOV_NUMDOCEXT); + if (numdoc.empty()) numdoc = mov.get(MOV_NUMDOC); // Controllo datadoc - numdoc - totdoc - p.iva + TString query; - query << "SELECT PQ_KEYPRGINVIO AS KEYPRGINVIO, PQ_KEYHEADERFATT AS KEYHEADERFATT, PQ_KEYBODYFATT AS KEYBODYFATT, P7_DATA AS DATA,\n" << - "\tP7_NUMERO AS NUMDOC, PQ_IMPTOTDOC AS IMPTOTDOC, P2_FISCIVAPAESE AS STATOPIVA, P2_FISCIVACOD AS PIVA FROM PAA2700F\n" << - "JOIN PAA0700F ON PQ_KEYPRGINVIO = P7_KEYPRGINVIO AND PQ_KEYHEADERFATT = P7_KEYHEADERFATT AND PQ_KEYBODYFATT = P7_KEYBODYFATT\n" << - "JOIN PAA0200F ON PQ_KEYPRGINVIO = P2_KEYPRGINVIO AND PQ_KEYHEADERFATT = P2_KEYHEADERFATT AND PQ_KEYBODYFATT = P2_KEYBODYFATT\n" << - "WHERE P7_DATA = '" << mov.get_date(MOV_DATADOC).date2ansi() << "' AND \n" << - "(P7_NUMERO = '" << numdoc << "' OR P7_NUMERO LIKE '%" << numdoc << "%') AND \n" << - (cli_statopiva.full() ? TString("P2_FISCIVAPAESE = '") << cli_statopiva << "' AND " : "") << - "P2_FISCIVACOD = '" << cli_piva << "' AND \n" << "PQ_IMPTOTDOC = " << tot; + + query << "SELECT PQ_KEYPRGINVIO AS KEYPRGINVIO, PQ_KEYHEADERFATT AS KEYHEADERFATT, PQ_KEYBODYFATT AS KEYBODYFATT, P7_DATA AS DATA,\n" << + "\tP7_NUMERO AS NUMDOC, PQ_IMPTOTDOC AS IMPTOTDOC, P2_FISCIVAPAESE AS STATOPIVA, P2_FISCIVACOD AS PIVA FROM PAA2700F\n" << + "JOIN PAA0700F ON PQ_KEYPRGINVIO = P7_KEYPRGINVIO AND PQ_KEYHEADERFATT = P7_KEYHEADERFATT AND PQ_KEYBODYFATT = P7_KEYBODYFATT\n" << + "JOIN PAA0200F ON PQ_KEYPRGINVIO = P2_KEYPRGINVIO AND PQ_KEYHEADERFATT = P2_KEYHEADERFATT AND PQ_KEYBODYFATT = P2_KEYBODYFATT\n" << + "WHERE P7_DATA = '" << mov.get_date(MOV_DATADOC).date2ansi() << "' AND \n" << + "(P7_NUMERO = '" << numdoc << "' OR P7_NUMERO LIKE '%" << numdoc << "%') \n"; + if (statopiva.full()) + query << "' AND \n" << "P2_FISCIVAPAESE = '" << statopiva; + query << "' AND \n" << "P2_FISCIVACOD = '" << forn.get(CLI_PAIV); + if (forn.gruppo_IVA()) + query << "' AND \n" "P2_COCAZZO = '" << forn.get(CLI_COFI); // cazzo; + query << "PQ_IMPTOTDOC = " << tot; if (_db->sq_set_exec(query) && _db->sq_items() == 1) { - _keys = { _db->sq_get("KEYPRGINVIO"), _db->sq_get("KEYHEADERFATT"), _db->sq_get("KEYBODYFATT") }; + _keys = _db->sq_get("KEYPRGINVIO"); + _keys.add(_db->sq_get("KEYHEADERFATT")); + _keys.add(_db->sq_get("KEYBODYFATT")); return true; } - return false; } -const char* TFppro::get_keys_fppro() const +const char* TFppro::get_keys_fppro() { - static TString keys; - keys.cut(0) << _keys.prginvio << ";" << _keys.headerfatt << ";" << _keys.bodyfatt; - return (const char*)keys; + TString& keys = get_tmp_string(64); + + keys.cut(0) << _keys.get(0) << ";" << _keys.get(1) << ";" << _keys.get(2); + return keys; } -int TFppro::get_numreg() +long TFppro::get_numreg() { if (!_is_set) { if (set_query()) - return _db->sq_get_int("PZ_NUMREGCONT"); + return _db->sq_get_long("PZ_NUMREGCONT"); return -1; } - return _db->sq_get_int("PZ_NUMREGCONT"); + return _db->sq_get_long("PZ_NUMREGCONT"); } -int TFppro::get_numreg(TToken_string& keys) +long TFppro::get_numreg(TToken_string& keys) { set_keys(keys); return get_numreg(); } -TString TFppro::get_codforn() const +long TFppro::get_codforn() { TString query; + query << "SELECT PZ_CLIFOR FROM FPPRO00F\n" << where_str(); _db->sq_set_exec(query); - return _db->sq_get("PZ_CLIFOR"); + return _db->sq_get_long("PZ_CLIFOR"); } TDate TFppro::get_datareg() @@ -127,12 +127,13 @@ TDate TFppro::get_datareg(TToken_string& keys) return TDate(); } -real TFppro::get_ritenute() const +real TFppro::get_ritenute() { - real imp = ZERO; + real imp; TString query; + query << "SELECT P7_IMPORTORIT AS IMPORTO FROM PAA0700F\n" << - "WHERE P7_KEYPRGINVIO = '" << _keys.prginvio << "' AND P7_KEYHEADERFATT = '" << _keys.headerfatt << "' AND P7_KEYBODYFATT = '" << _keys.bodyfatt << "'"; + "WHERE P7_KEYPRGINVIO = '" << _keys.get(0) << "' AND P7_KEYHEADERFATT = '" << _keys.get(1) << "' AND P7_KEYBODYFATT = '" << _keys.get(2) << "'"; _db->sq_set_exec(query, false); for(bool ok = _db->sq_next(); ok; ok = _db->sq_next()) imp += _db->sq_get_real("IMPORTO"); @@ -140,49 +141,48 @@ real TFppro::get_ritenute() const } TFppro& TFppro::set_keys(TToken_string& keys) -{ - if (keys.items() == 3) - { - const keys_s k = { keys.get(0), keys.get(1), keys.get(2) }; - return set_keys(k); - } - _is_set = false; - _keys_setted = false; - return *this; -} - -TFppro& TFppro::set_keys(const keys_s& keys) { if (sql_inj(keys)) { TString msg; msg << "Database error: Possibile SQL INJECTION:\n" << keys; - //throw std::exception(msg); +; error_box(msg); _last_error.cut(0) << msg; } - else if (!keys.prginvio.empty() && !keys.headerfatt.empty() && !keys.bodyfatt.empty()) - { - _keys = keys; - _keys_setted = true; - } else { - _last_error.cut(0) << "Chiavi settate non valide:\n" << keys; - _keys_setted = false; + TString prginvio = keys.get(0); + TString headerfatt = keys.get(1); + TString bodyfatt = keys.get(2); + + if (prginvio.full() && headerfatt.full() && bodyfatt.full()) + { + _keys = keys; + _keys_setted = true; + } + else + { + _last_error = "Chiavi settate non valide:\n"; + _last_error << keys; + _keys_setted = false; + } } _is_set = false; return *this; } -bool TFppro::associa_mov(const int numreg) const +bool TFppro::associa_mov(const long numreg) { bool ok; TLocalisamfile mov(LF_MOV); + mov.put(MOV_NUMREG, numreg); - if ((ok = mov.read() == NOERR)) + ok = mov.read() == NOERR; + if (ok) { mov.put(MOV_KEYFPPRO, get_keys_fppro()); - if ((ok = mov.rewrite() == NOERR)) // Scrivo sul movimento il riferimento al fppro + ok = mov.rewrite() == NOERR; + if (ok) // Scrivo sul movimento il riferimento al fppro { TString query; query << "UPDATE FPPRO00F \nSET " << @@ -199,7 +199,7 @@ bool TFppro::associa_mov(const int numreg) const return ok; } -const char* TFppro::get_tipoprot() const +const char* TFppro::get_tipoprot() { TString query; @@ -208,80 +208,88 @@ const char* TFppro::get_tipoprot() const return _db->sq_get("TIPOPROT"); } -const char* TFppro::get_numprot() const +const char* TFppro::get_numprot() { TString query; - static TString num; + query << "SELECT PZ_NUMPROT AS NUMPROT FROM FPPRO00F\r\n" << where_str(); _db->sq_set_exec(query); - return num.cut(0) = _db->sq_get("NUMPROT"); + + return _db->sq_get("NUMPROT"); } -const char* TFppro::get_annoprot() const +const char* TFppro::get_annoprot() { TString query; - static TString anno; + query << "SELECT PZ_ANNOPROT AS ANNOPROT FROM FPPRO00F\r\n" << where_str(); _db->sq_set_exec(query); - return anno.cut(0) = _db->sq_get("ANNOPROT"); + return _db->sq_get("ANNOPROT"); } -const char* TFppro::get_dataoraric() const +const char * TFppro::get_dataoraric() { TString query; - static TString data; - query << "SELECT PZ_DATAORARIC AS DATAORARIC FROM FPPRO00F\r\n" << where_str(); + TString & data = get_tmp_string(16); + + query << "SELECT PZ_DATAORARIC AS DATAORARIC FROM FPPRO00F\r\n" << where_str(); _db->sq_set_exec(query); - return data.cut(0) << _db->sq_get_date("DATAORARIC").date2ansi(); + data << _db->sq_get_date("DATAORARIC").date2ansi(); + return data; } -const char* TFppro::get_tipodoc() const +const char* TFppro::get_tipodoc() { TString query; - static TString tipodoc; + query << "SELECT PZ_TIPODOC AS TIPODOC FROM FPPRO00F\r\n" << where_str(); _db->sq_set_exec(query); - return tipodoc.cut(0) << _db->sq_get("TIPODOC"); + return _db->sq_get("TIPODOC"); } -const char* TFppro::get_numdoc() const +const char* TFppro::get_numdoc() { TString query; - static TString numdoc; + query << "SELECT PZ_NUMERO AS NUMDOC FROM FPPRO00F\r\n" << where_str(); _db->sq_set_exec(query); - return numdoc.cut(0) << _db->sq_get("NUMDOC"); + return _db->sq_get("NUMDOC"); } TDate TFppro::get_data_first_doc() const { TString query; + query << "SELECT min(a.DATA) AS DATA \nFROM( \n\tSELECT P7_DATA as DATA \n" << "\tFROM PAA0700F \n\tUNION \n\tSELECT P7_DATA as DATA \n\tFROM PAF0700F \n) a"; _db->sq_set_exec(query); return _db->sq_get_date("DATA"); } -TDate TFppro::get_dataorarioric() const +TDate TFppro::get_dataorarioric() { TString query; + query << "SELECT P1_DATAORARIC \nFROM PAA0100F \n" << - "WHERE P1_KEYPRGINVIO = '" << _keys.prginvio << "' AND P1_KEYHEADERFATT = '" << _keys.headerfatt << "' AND P1_KEYBODYFATT = '" << _keys.bodyfatt << "'"; + "WHERE P1_KEYPRGINVIO = '" << _keys.get(0) << "' AND P1_KEYHEADERFATT = '" << _keys.get(1) << "' AND P1_KEYBODYFATT = '" << _keys.get(2) << "'"; _db->sq_set_exec(query); return _db->sq_get_date("P1_DATAORARIC"); } -int TFppro::get_numregcont() const +long TFppro::get_numregcont() { TString query; + query << "SELECT PZ_NUMREGCONT FROM FPPRO00F\n" << where_str(); _db->sq_set_exec(query); - return _db->sq_get_int("PZ_NUMREGCONT"); + return _db->sq_get_long("PZ_NUMREGCONT"); } TString TFppro::get_last_error(bool clear) { - TString l(_last_error); + TString & l = get_tmp_string(128); + + l = _last_error; if(clear) _last_error.cut(0); return l; @@ -297,14 +305,14 @@ bool TFppro::set_query() return _is_set = false; } -const char* TFppro::where_str() const +const char* TFppro::where_str() { static TString str; - str.cut(0) << " WHERE PZ_KEYPRGINVIO = '" << _keys.prginvio << "' AND PZ_KEYHEADERFATT = '" << _keys.headerfatt << "' AND PZ_KEYBODYFATT = '" << _keys.bodyfatt << "'"; + str.cut(0) << " WHERE PZ_KEYPRGINVIO = '" << _keys.get(0) << "' AND PZ_KEYHEADERFATT = '" << _keys.get(1) << "' AND PZ_KEYBODYFATT = '" << _keys.get(2) << "'"; return str; } -TFppro::TFppro() : _keys({ "\0", "\0", "\0" }), _keys_setted(false), _is_set(false) +TFppro::TFppro() : _keys("", ';'), _keys_setted(false), _is_set(false) { _db = new SSimple_query(); const bool ok = set_connection(*_db); @@ -324,11 +332,12 @@ prot_s TProtocollo::get_prot() TString& TProtocollo::prot_in(const int year, const char* tipoprot, const char* progres) { - static TString protocollo; + TString & protocollo = get_tmp_string(128); TString tipo(tipoprot); + if (tipo.empty()) tipo << "no_prot"; - protocollo.cut(0) << year << "-" << tipo << "/" << progres; + protocollo << year << "-" << tipo << "/" << progres; return protocollo; } @@ -363,29 +372,21 @@ const char* get_ini_codcaus() return ini_get_string(FILE_CONFIG, FILE_SECTION, F1_CAUS); } -const char* get_codcaus(const char * tipodoc, const char* codcf) +const char* get_codcaus(const char * tipodoc, long codcf) { - TLocalisamfile cfven(LF_CFVEN); - cfven.put(CFV_TIPOCF, "F"); - cfven.put(CFV_CODCF, codcf); - const char* codcaus = ""; - const char* codcausnc = ""; + TCli_for f = cached_clifor('F', codcf); const bool nc = TString(tipodoc) == "TD04"; - if (cfven.read() == NOERR) - { - codcaus = cfven.get(CFV_CODCAUS); - codcausnc = cfven.get(CFV_CODCAUSNC); - } - if (nc) { - if (!TString(codcausnc).empty()) - return codcausnc; + const TString & codcaus = f.vendite().get(CFV_CODCAUSNC); + if (codcaus.full()) + return codcaus; } else { - if (!TString(codcaus).empty()) + const TString & codcaus = f.vendite().get(CFV_CODCAUS); + if (codcaus.full()) return codcaus; } return get_ini_codcaus(); @@ -444,74 +445,42 @@ bool check_causale(const TString& cod_caus, bool acq) bool check_causale(const TString& cod_caus, const TString& tipo_doc, bool acq) { - const TCausale& caus = cached_causale(cod_caus); + const TCausale& c = cached_causale(cod_caus); if(tipo_doc == "FA" || tipo_doc == "BD" || tipo_doc == "AF" || tipo_doc == "FF") - return caus.tipo_doc() == tipo_doc; + return c.tipo_doc() == tipo_doc; if (tipo_doc == "NC" || tipo_doc == "ND") { bool nota; bool nota_iva = false; - if ((nota = caus.tipo_doc() == tipo_doc)) + + if ((nota = c.tipo_doc() == tipo_doc)) { if (acq) - nota_iva = caus.reg().tipo() == iva_acquisti; + nota_iva = c.reg().tipo() == iva_acquisti; else - nota_iva = caus.reg().tipo() == iva_vendite; + nota_iva = c.reg().tipo() == iva_vendite; } return nota && nota_iva; } - return false; } -bool check_caus_has_rit(const TString& cod_caus, bool rit) +bool check_caus_has_rit(const TString& cod_caus, int year) { - TLocalisamfile causali(LF_CAUSALI); - causali.put(CAU_CODCAUS, cod_caus); - causali.read(); - return *causali.get(CAU_M770) != '\0'; + const TCausale & c = cached_causale(cod_caus, year); + + return c.causale_770().full(); } void run_cont_ini(bool liq) { - static TString run_string; -#ifdef DBG - run_string.cut(0) << "cg2 -0 -i" << F1_INIREGCONT << "*" << ".ini" << " -f1" << (liq? " -liq" : " ") << " /u" << user(); -#else - run_string.cut(0) << "cg2 -0 -i" << TFilename().tempdir() << "\\" << F1_INIREGCONT << "*" << ".ini" << " -f1" << (liq ? " -liq" : " ") << " /u" << user(); -#endif - TExternal_app(run_string).run(); + TString cmd; + + cmd.cut(0) << "cg2 -0 -i" << TFilename().temp("cg2CONTAB", "ini") << " -f1" << (liq ? " -liq" : " ") << " /u" << user(); + + TExternal_app app(cmd); + + app.run(); } - -void TF1_log::log(int severity, const char* msg) -{ - if (_log == nullptr) - { - _log = new TLog_report("Stato contabilizzazione:"); - // Tento l'eliminazione del file - std::remove("f1_cg.log"); - } - - static TString txt; - txt.cut(0) << msg; - _log->log(severity, txt); - // Scrivo anche su file - std::filebuf fb; - fb.open("f1_cg.log", std::ios::out | std::ios::app); - std::ostream os(&fb); - os << txt << std::endl; - fb.close(); -} - -bool TF1_log::show_log() -{ - if (_log) - { - _log->preview(); - delete _log; - _log = nullptr; - } - return true; -} \ No newline at end of file diff --git a/src/f1/f1lib.h b/src/f1/f1lib.h index 420a73779..fcc6cff2b 100644 --- a/src/f1/f1lib.h +++ b/src/f1/f1lib.h @@ -8,7 +8,6 @@ #define FILE_CONFIG CONFIG_DITTA #define FILE_SECTION "f1" #define F1_CAUS "caus" -#define F1_INIREGCONT "cg2CONTAB" #define LOG_MSG 0 #define LOG_WARN 1 #define LOG_ERR 2 @@ -39,61 +38,44 @@ typedef struct _prot_s */ class TFppro : public TObject { - struct keys_s - { - TString prginvio; - TString headerfatt; - TString bodyfatt; - - operator const char*() const - { - static TToken_string a("", ';'); - a.add(prginvio); - a.add(headerfatt); - a.add(bodyfatt); - return a; - } - } _keys; - + TToken_string _keys; SSimple_query* _db; bool _keys_setted; bool _is_set; // Query is setted TString _fppro_query; TString _last_error; - static bool sql_inj(const TString& str); - static bool sql_inj(const keys_s& keys); + bool sql_inj(TToken_string& keys); public: - const char* where_str() const; + const char* where_str(); bool check_reg(TToken_string& keys, int numreg); // Se un mov. registrato non e' collegato all'FPPRO cerco di capire qual'e` bool guess_the_doc(const TLocalisamfile& mov); // Getters - const char* get_keys_fppro() const; - int get_numreg(); - int get_numreg(TToken_string& keys); - TString get_codforn() const; + const char* get_keys_fppro(); + long get_numreg(); + long get_numreg(TToken_string& keys); + long get_codforn(); TDate get_datareg(); TDate get_datareg(TToken_string& keys); - real get_ritenute() const; + real get_ritenute(); TDate get_data_first_doc() const; - TDate get_dataorarioric() const; - int get_numregcont() const; + TDate get_dataorarioric(); + long get_numregcont(); TString get_last_error(bool clear = true); // Setters bool set_query(); TFppro& set_keys(TToken_string& keys); - TFppro& set_keys(const keys_s& keys); - bool associa_mov(int numreg) const; - const char* get_tipoprot() const; - const char* get_numprot() const; - const char* get_annoprot() const; - const char* get_dataoraric() const; - const char* get_tipodoc() const; - const char* get_numdoc() const; + bool associa_mov(long numreg); + const char* get_tipoprot(); + const char* get_numprot(); + const char* get_annoprot(); + const char* get_dataoraric(); + const char* get_tipodoc(); + const char* get_numdoc(); TFppro(); TFppro(TToken_string& keys) : TFppro() { set_keys(keys); } @@ -125,19 +107,17 @@ public: }; -class TF1_log : TObject +class TF1_log : public TLog_report { - TLog_report* _log; public: - TF1_log() : _log(nullptr){} - void log(int severity, const char* msg); - bool show_log(); + TF1_log() : TLog_report("Stato contabilizzazione:") {} + bool show_log() { export_text("f1_cg.log", false); return preview(); } }; TFppro& fppro_db(); const char* get_ini_codcaus(); -const char* get_codcaus(const char * tipodoc, const char* codcf); +const char* get_codcaus(const char * tipodoc, long codcf); bool get_endatareg(); TString get_datainireg(); TString get_dataendreg(); @@ -153,7 +133,7 @@ void set_periodprec(bool flag); bool check_causale(const TString& cod_caus, bool acq = true); // Controlla se il "cod_caus" ha come "tipo_doc" FA o NC (di acquisto) bool check_causale(const TString& cod_caus, const TString& tipo_doc, bool acq = true); -bool check_caus_has_rit(const TString& cod_caus, bool rit); +bool check_caus_has_rit(const TString& cod_caus, int year = 0); void run_cont_ini(bool liq); #endif // _F1LIB_H_ diff --git a/src/f9/f9lib02.cpp b/src/f9/f9lib02.cpp index 0914762af..9c0640655 100644 --- a/src/f9/f9lib02.cpp +++ b/src/f9/f9lib02.cpp @@ -593,7 +593,9 @@ bool TF9Prospetto_integr::operator()(const char* numreg_acq, const char* numreg_ _items = _prosp_rs->items(); if (_items == 0) { - FILE* log = fopen("TF9Prospetto_integr_error.txt", "a"); + FILE* log; + + fopen_s(&log, "TF9Prospetto_integr_error.txt", "a"); if (!_prosp_rs->last_exec()) { if (log != nullptr) diff --git a/src/fp/Rappresentazione_tabellare_del_tracciato_FatturaPA_versione_1.2.1.xls b/src/fp/Rappresentazione_tabellare_del_tracciato_FatturaPA_versione_1.2.1.xls index 94d225528..990e3f18b 100644 Binary files a/src/fp/Rappresentazione_tabellare_del_tracciato_FatturaPA_versione_1.2.1.xls and b/src/fp/Rappresentazione_tabellare_del_tracciato_FatturaPA_versione_1.2.1.xls differ diff --git a/src/fp/fp0300.cpp b/src/fp/fp0300.cpp index 21075375a..5fe421f7f 100644 --- a/src/fp/fp0300.cpp +++ b/src/fp/fp0300.cpp @@ -104,10 +104,7 @@ void TPA_mask::load_all_fields() set(F_DATAEND, ini_get_string(CONFIG_DITTA, "fp", "dataend")); const TToken_string s_accepted_docs(ini_get_string(CONFIG_DITTA, "fp", "accepted_docs"), ';'); - // - auto& sheet = sfield(F_DOCUMENTI_TIPO); - sheet.hide(); - + TSheet_field& sheet = sfield(F_DOCUMENTI_TIPO); TFP_selected_docs selected_docs; if (selected_docs.has_selected_docs()) @@ -212,7 +209,7 @@ void TPA_mask::fill() continue; bool sent = false; - if (chiave_paf(doc, hfatt, bfatt)) + if (chiave_paf_doc(doc, hfatt, bfatt)) { if (paf0100f.search(nullptr, hfatt, bfatt) && paf0100f.sq_get("P1_GESTIONE") != " " && paf0100f.sq_get("P1_ERRINT") != "*") { @@ -307,7 +304,7 @@ void TPA_mask::set_pronto() static TString campo_hfatt, campo_bfatt, query; TDocumento doc('D', riga->get_int(xvtil_cid2index(S_ANNO)), riga->get(xvtil_cid2index(S_CODNUM)), riga->get_long(xvtil_cid2index(S_NDOC))); - if (chiave_paf(doc, campo_hfatt, campo_bfatt)) + if (chiave_paf_doc(doc, campo_hfatt, campo_bfatt)) { // Come prima cosa controllo che effettivamente la chiave di questo doc sia in giro per il mondo query.cut(0) << "UPDATE PAF0100F SET P1_GESTIONE = 'P' WHERE P1_KEYHEADERFATT = '" << campo_hfatt << "' AND P1_KEYBODYFATT = '" << campo_bfatt << "'"; @@ -345,7 +342,7 @@ void TPA_mask::connect_keys() TDocumento doc('D', riga->get_int(xvtil_cid2index(S_ANNO)), riga->get(xvtil_cid2index(S_CODNUM)), riga->get_long(xvtil_cid2index(S_NDOC))); static TString campo_hfatt, campo_bfatt, query; - if (chiave_paf(doc, campo_hfatt, campo_bfatt)) + if (chiave_paf_doc(doc, campo_hfatt, campo_bfatt)) { // Come prima cosa controllo che effettivamente la chiave di questo doc sia in giro per il mondo query.cut(0) << "SELECT * FROM PAF0100F WHERE P1_KEYHEADERFATT = '" << campo_hfatt << "' AND P1_KEYBODYFATT = '" << campo_bfatt << "'"; @@ -687,7 +684,7 @@ void TPA_mask::set_err_paf() TString hfatt, bfatt; TPaf_record paf0100f("PAF0100F"); - if (fdoc.read() == NOERR && chiave_paf(fdoc.curr(), hfatt, bfatt) && paf0100f.search(nullptr, hfatt, bfatt)) + if (fdoc.read() == NOERR && chiave_paf_doc(fdoc.curr(), hfatt, bfatt) && paf0100f.search(nullptr, hfatt, bfatt)) { static TString query; query.cut(0) << diff --git a/src/fp/fp0400.cpp b/src/fp/fp0400.cpp index dd90e67fc..de91a77d4 100644 --- a/src/fp/fp0400.cpp +++ b/src/fp/fp0400.cpp @@ -17,6 +17,7 @@ #define FILTER_ALL "A" #define FILTER_CONT "C" #define PARA_FP "fp" +#define F1_INIREGCONT "regcont" enum { @@ -669,7 +670,7 @@ int TPassive_mask::prepara_contab() const { TString prokeys = row->get(sf.cid2index(S_PROKEY)); TToken_string keys(prokeys, ';'); - const TString codcaus(get_codcaus(row->get(cid2index(S_TIPODOCSDI)), row->get(cid2index(S_FORNITORE)))); + const TString codcaus(get_codcaus(row->get(cid2index(S_TIPODOCSDI)), row->get_long(cid2index(S_FORNITORE)))); TString tipodoc(row->get(sf.cid2index(S_TIPODOCSDI))); if (tipodoc == "TD01" && !check_causale(codcaus, "FA", true)) @@ -868,7 +869,7 @@ int TPassive_mask::check_err() const { if (row->starts_with("X")) { - TString codcaus(get_codcaus(row->get(cid2index(S_TIPODOCSDI)), row->get(cid2index(S_FORNITORE)))); + TString codcaus(get_codcaus(row->get(cid2index(S_TIPODOCSDI)), row->get_long(cid2index(S_FORNITORE)))); if (codcaus.empty()) return no_codcaus; if (TString(row->get(cid2index(S_FORNITORE))).empty()) diff --git a/src/fp/fp0700.cpp b/src/fp/fp0700.cpp index 82f2c8513..8768083f7 100644 --- a/src/fp/fp0700.cpp +++ b/src/fp/fp0700.cpp @@ -13,21 +13,16 @@ #include "fp0700a.h" #include "fp0100a.h" -///////////////////////////////////////////////////////////////////////////////////// -// Globals -///////////////////////////////////////////////////////////////////////////////////// - -#define LEN_HFATT 20 -#define LEN_BFATT 50 - ///////////////////////////////////////////////////////////////////////////////////// // TPAR_mask ///////////////////////////////////////////////////////////////////////////////////// class TPAR_mask : public TAutomask { + TAssoc_array _causali; + protected: - enum {_codnum, _tipodoc, _dastato, _astato, _tiposdi}; + enum { _codnum, _tipodoc, _dastato, _astato, _tiposdi }; void set_filter_changed(); void set_pronto(); @@ -50,35 +45,29 @@ protected: bool _enable_chiave_fixer; public: - TPAR_mask() : TAutomask("fp0700a"), _filter_changed(true), _enable_chiave_fixer(false) - { - disable(DLG_OK); - disable(DLG_SAVEREC); - disable(DLG_FINDREC); - load_all_fields(); - const TDate data_inizio = get_date_start_new_fatt(); - - } - void save_all_fields() const; + const TAssoc_array & causali() const { return _causali; } + void save_all_fields(); + TPAR_mask(); + virtual ~TPAR_mask() {} }; -void TPAR_mask::save_all_fields() const +TPAR_mask *__mask = nullptr; + +void TPAR_mask::save_all_fields() { + TSheet_field & scaus = sfield(F_CAUSALI_TIPO); + // Salvo le impostazioni ini_set_string(CONFIG_DITTA, "fp", "dataini", get(F_DATAINI)); ini_set_string(CONFIG_DITTA, "fp", "dataend", get(F_DATAEND)); - + ini_set_string(CONFIG_DITTA, "fp", "TIPO_SDI", get(F_TIPO_SDI)); // Salvo lo sheet - TFP_selected_docs selected_docs; - selected_docs.save_sheet(sfield(F_CAUSALI_TIPO)); - - // Salvo le impostazioni -/* - set_esp_pri_empty(get_bool(F_SETDEFCOD)); - set_send_all_rifs(get_bool(F_SENDALLRIFS)); - set_esp_est(get_bool(F_SETCODEST)); - set_esp_est_cod(get(F_VALCODEST)); -*/ - + _causali.destroy(); + FOR_EACH_SHEET_ROW_LOOP(scaus, r) + { + const TString & codcaus = scaus.get_str_row_cell(r, S_COD_CAUS); + ini_set_string(CONFIG_DITTA, "fp", "CAUSALE", codcaus, r); + _causali.add(codcaus); + } } void TPAR_mask::force_reload_sheet() @@ -97,117 +86,71 @@ void TPAR_mask::load_all_fields() set(F_DATAEND, ini_get_string(CONFIG_DITTA, "fp", "dataend")); const TToken_string s_accepted_docs(ini_get_string(CONFIG_DITTA, "fp", "accepted_docs"), ';'); - // - TSheet_field& sheet = sfield(F_CAUSALI_TIPO); + TSheet_field& scaus = sfield(F_CAUSALI_TIPO); - TFP_selected_regs selected_regs; - - if (selected_regs.has_selected_regs()) + for (int i = 0;; i++) { - // Super nuova gestione super avanzata! - selected_regs.fill_sheet(sheet); + TString16 caus = ini_get_string(CONFIG_DITTA, "fp", "CAUSALE", "", i); + + if (caus.full()) + scaus.set_row_cell(S_COD_CAUS, caus); + else + break; } - else if(s_accepted_docs.full()) - { - // Nuova gestione avanzata! - FOR_EACH_STR_TOKEN(s_accepted_docs, tok) - { - TToken_string& row = sheet.row(-1); - row.add(tok); - row.add(TTipo_documento(TToken_string(tok).get(1)).tipo_doc_sdi()); - } - } - else - { - // Vecchia gestione ): - const TString& codnum = ini_get_string(CONFIG_DITTA, "fp", "codnum"); - TToken_string tipidocs(ini_get_string(CONFIG_DITTA, "fp", "tipodocs")); - FOR_EACH_STR_TOKEN(tipidocs, tok) - { - TToken_string& row = sheet.row(-1); - row.add(codnum); - row.add(tok); - // Considero 1 e 9 come stati default? - row.add(1); - row.add(9); - row.add(TTipo_documento(tok).tipo_doc_sdi()); - } - } - sheet.force_update(); - sheet.show(); + scaus.force_update(); + set(F_TIPO_SDI, ini_get_string(CONFIG_DITTA, "fp", "TIPO_SDI")); +} - /* DA FARE - set(F_SETDEFCOD, get_esp_pri_empty()); - set(F_SENDALLRIFS, get_send_all_rifs()); - set(F_SETCODEST, get_esp_est()); - set(F_VALCODEST, get_esp_est_cod()); - */ +bool caus_filter(const TRelation* r) +{ + return __mask->causali().is_key(r->lfile().get(MOV_CODCAUS)); } void TPAR_mask::fill() { - // Salvo subito su file le impostazioni di esportazione, in fplib accedo ai file - save_all_fields(); - - TSheet_field& docs = sfield(F_DOCS); - TString_array& sht = docs.rows_array(); - docs.hide(); - - sht.destroy(); - const TDate dal = get(F_DATAINI); const TDate al = get(F_DATAEND); - TString filter_selected = get(F_DOCSEL); + TString filter_selected = get(F_REGSEL); + // Record di controllo per eventuali elaborazioni precedenti + TString hfatt, bfatt; + TPaf_record paf0100f("PAF0100F"); + TSheet_field& regs = sfield(F_REGS); + TString query; enable(DLG_OK, filter_selected.empty() || filter_selected == "E"); enable(DLG_SAVEREC, (is_f8() && filter_selected == "X") || filter_selected == "D"); enable(DLG_FINDREC, filter_selected == "D"); enable(DLG_PRINT, _enable_chiave_fixer && filter_selected.empty()); - // Record di controllo per eventuali elaborazioni precedenti - TString hfatt(LEN_HFATT), bfatt(LEN_BFATT); - TPaf_record paf0100f("PAF0100F"); - - TString query; - - query << "USE 33 KEY 3 \n" << - "SELECT 33.TIPOCF==\"C\" \n" << - "JOIN 20 INTO TIPOCF==TIPOCF CODCF==CODCF \n" << - "JOIN 17 TO 33 INTO TIPOCF==TIPOCF CODCF==CODCF \n" << - "JOIN %TIP TO 33 ALIAS 400 INTO CODTAB==TIPODOC \n" << - "FROM DATADOC=#DADATADOC \n" << - "TO DATADOC=#ADATADOC"; + query << "USE " << LF_MOV << " KEY 3 SELECT (BETWEEN(" << MOV_DATAREG << "," + << dal.date2ansi() << ',' << al.date2ansi() << "))&&(REG!=\"\")" + << "\nFROM " << MOV_TIPO << "=C\nTO " << MOV_TIPO "=C"; TISAM_recordset rec(query); - - rec.set_var("#DADATADOC", dal); - rec.set_var("#ADATADOC", al); + + rec.set_filterfunction(caus_filter); TProgress_monitor pi(rec.items(), nullptr); bool first, show, ask = !((show = (first = true))); int fat_no_cod = 0; + const TString16 tipodocsdi = get(F_TIPO_SDI); + const TDate data_inizio = get_date_start_new_fatt(); // Disabilito la colonna del codice ufficio - docs.enable_column(cid2index(S_UFFICIO), false); - const TDate data_inizio = get_date_start_new_fatt(); + regs.enable_column(cid2index(S_UFFICIO), false); + regs.reset(); for (bool okc = rec.move_first(); okc; okc = rec.move_next()) { if (!pi.add_status()) break; - const TRectype& doc = rec.cursor()->curr(); - const TTipo_documento& td = cached_tipodoc(doc.get(DOC_TIPODOC)); - - // Controllo che la numerazione sia tra quelle giuste - - // Controllo che il tipo documento sia OK - if(!check_doc_filter(doc)) - continue; - + const TRectype& mov = rec.cursor()->curr(); + const TCli_for & cli = cached_clifor(mov.get_char(MOV_TIPO), mov.get_long(MOV_CODCF)); bool sent = false; - if (chiave_paf(doc, hfatt, bfatt)) + + if (chiave_paf_mov(mov, tipodocsdi, hfatt, bfatt)) { if (paf0100f.search(nullptr, hfatt, bfatt) && paf0100f.sq_get("P1_GESTIONE") != " " && paf0100f.sq_get("P1_ERRINT") != "*") { @@ -219,26 +162,17 @@ void TPAR_mask::fill() continue; } - TToken_string& row = docs.row(-1); - row = sent ? " " : "X"; - row.add(rec.get(DOC_ANNO).as_int(), 1); - row.add(rec.get(DOC_CODNUM).as_string()); - row.add(rec.get(DOC_TIPODOC).as_string()); + int r = regs.set_row_cell(S_SELECTED, sent); - TString tipodoc = rec.get(DOC_TIPODOCSDI).as_string(); - - if (tipodoc.blank()) - tipodoc = td.tipo_doc_sdi(); - if (today 0) warning_box("Sono state trovate una o piĂ¹ fatture senza codice destinatario nĂ© pec"); @@ -289,7 +220,7 @@ void TPAR_mask::set_filter_changed() void TPAR_mask::set_pronto() { - TString_array& sht = sfield(F_DOCS).rows_array(); + TString_array& sht = sfield(F_REGS).rows_array(); TProgress_monitor pi(sht.items(), "Esportazione Fatture"); FOR_EACH_ARRAY_ROW(sht, r, riga) { @@ -302,7 +233,7 @@ void TPAR_mask::set_pronto() static TString campo_hfatt, campo_bfatt, query; TDocumento doc('D', riga->get_int(xvtil_cid2index(S_ANNO)), EMPTY_STRING, riga->get_long(xvtil_cid2index(S_NUMREG))); - if (chiave_paf(doc, campo_hfatt, campo_bfatt)) + if (chiave_paf_doc(doc, campo_hfatt, campo_bfatt)) { // Come prima cosa controllo che effettivamente la chiave di questo doc sia in giro per il mondo query.cut(0) << "UPDATE PAF0100F SET P1_GESTIONE = 'P' WHERE P1_KEYHEADERFATT = '" << campo_hfatt << "' AND P1_KEYBODYFATT = '" << campo_bfatt << "'"; @@ -317,7 +248,7 @@ void TPAR_mask::set_pronto() void TPAR_mask::connect_keys() { - TString_array& sht = sfield(F_DOCS).rows_array(); + TString_array& sht = sfield(F_REGS).rows_array(); TLog_report legno("Allineamento chiavi documento"); // Non sto a fare 8000 variabili, oggi mi sento a corto di Byte static TString msg_log; @@ -340,7 +271,7 @@ void TPAR_mask::connect_keys() TDocumento doc('D', riga->get_int(xvtil_cid2index(S_ANNO)), EMPTY_STRING, riga->get_long(xvtil_cid2index(S_NUMREG))); static TString campo_hfatt, campo_bfatt, query; - if (chiave_paf(doc, campo_hfatt, campo_bfatt)) + if (chiave_paf_doc(doc, campo_hfatt, campo_bfatt)) { // Come prima cosa controllo che effettivamente la chiave di questo doc sia in giro per il mondo query.cut(0) << "SELECT * FROM PAF0100F WHERE P1_KEYHEADERFATT = '" << campo_hfatt << "' AND P1_KEYBODYFATT = '" << campo_bfatt << "'"; @@ -440,7 +371,7 @@ void TPAR_mask::export_paf() { int ndocs = 0; TLocalisamfile doc(LF_DOC); - TString_array& sht = sfield(F_DOCS).rows_array(); + TString_array& sht = sfield(F_REGS).rows_array(); TDoc_fp elab; //elab.set_cache_insert(true); @@ -454,8 +385,8 @@ void TPAR_mask::export_paf() if (riga->starts_with("X")) { - const int anno = riga->get_int(sfield(F_DOCS).cid2index(S_ANNO)); - const long nreg = riga->get_long(sfield(F_DOCS).cid2index(S_NUMREG)); + const int anno = riga->get_int(sfield(F_REGS).cid2index(S_ANNO)); + const long nreg = riga->get_long(sfield(F_REGS).cid2index(S_NUMREG)); const TDoc_key key(anno, EMPTY_STRING, nreg); //da fare // Verifico che il codice sdi nello sheet sia lo stesso sulla testata del documento in caso contrario lo aggiorno @@ -502,7 +433,7 @@ bool TPAR_mask::on_field_event(TOperable_field& o, TField_event e, long jolly) case F_DATAEND: if (e == fe_init) o.set(TDate(TODAY)); - case F_DOCS: + case F_REGS: if (e == se_query_add || e == se_query_del) return false; break; @@ -513,24 +444,19 @@ bool TPAR_mask::on_field_event(TOperable_field& o, TField_event e, long jolly) case DLG_USER: if (e == fe_button && jolly > 0) { - TSheet_field& docs = sfield(F_DOCS); - TToken_string& row = docs.row(docs.selected()); - TRectype doc(LF_DOC); - doc.put(DOC_PROVV, 'D'); - doc.put(DOC_ANNO, row.get(1)); - doc.put(DOC_CODNUM, row.get(2)); - doc.put(DOC_TIPODOC, row.get(3)); - doc.put(DOC_NDOC, row.get(5)); - if (doc.edit(LF_DOC, "", "ve0")) // Perchè prima andava senza dovergli mettere nulla? - fill(); + TSheet_field& regs = sfield(F_REGS); + TToken_string& row = regs.row(regs.selected()); + // Salvo subito su file le impostazioni di esportazione, in fplib accedo ai file + save_all_fields(); + fill(); } break; case DLG_ALL: { if (e == fe_button) { - TSheet_field& docs = sfield(F_DOCS); - TString_array& sht = docs.rows_array(); + TSheet_field& regs = sfield(F_REGS); + TString_array& sht = regs.rows_array(); const int items = sht.items(); if (items > 0) @@ -538,7 +464,7 @@ bool TPAR_mask::on_field_event(TOperable_field& o, TField_event e, long jolly) const TString4 select = *(sht.row(0).get(0)) == 'X' ? "" : "X"; for (int i = 0; i < items; i++) sht.row(i).add(select, 0); - docs.force_update(); + regs.force_update(); } } } @@ -580,7 +506,7 @@ void TPAR_mask::next_page(int p) { if ((ok = _filter_changed = check_full_fields())) { - TSheet_field& sf = sfield(F_DOCS); + save_all_fields(); fill(); _filter_changed = false; } @@ -605,7 +531,7 @@ bool TPAR_mask::on_key(const KEY key) bool TPAR_mask::check_not_empty() { - TSheet_field& sheet = sfield(F_DOCS); + TSheet_field& sheet = sfield(F_REGS); TString msg; if (sheet.empty()) @@ -637,8 +563,10 @@ bool TPAR_mask::check_doc_filter(const TDocumentoEsteso& d) const const TString& tipodoc = d.get(DOC_TIPODOC); const char stato = d.stato(); const TTipo_documento& td = cached_tipodoc(d.get(DOC_TIPODOC)); + TSheet_field & scaus = sfield(F_CAUSALI_TIPO); + // Mi precarico la tabella dei documenti scelti - FOR_EACH_SHEET_ROW(sfield(F_CAUSALI_TIPO), nr, row) + FOR_EACH_SHEET_ROW(scaus, nr, row) { if (codnum.compare(row->get(_codnum)) == 0 && // Codice numerazione tipodoc.compare(row->get(_tipodoc)) == 0 && // Tipo documento @@ -653,78 +581,78 @@ bool TPAR_mask::check_doc_filter(const TDocumentoEsteso& d) const void TPAR_mask::set_err_paf() { // Vado a riportare sui paf l'errore - TSheet_field& sfld = sfield(F_DOCS); - TString_array& sht = sfld.rows_array(); - TLocalisamfile fdoc(LF_DOC); - if (!sht.empty()) + TSheet_field& sfld = sfield(F_REGS); + TProgress_monitor pi(sfld.items(), "Cambio stato fatture"); + const TString tipodocsdi = get(F_TIPO_SDI); + + FOR_EACH_SHEET_ROW_LOOP(sfld, r) { - TProgress_monitor pi(sht.items(), "Cambio stato fatture"); + if (!pi.add_status()) + break; - FOR_EACH_ARRAY_ROW(sht, r, riga) + if (sfld.get_bool_row_cell(r, S_SELECTED)) { - if (!pi.add_status()) - break; + // Ricontrollo che la fattura sia presente in Campo prima di cambiare stato + long nreg = sfld.get_long_row_cell(r, S_NUMREG); + const TRectype & mov = cache().get(LF_MOV, nreg); + TString hfatt, bfatt; + TPaf_record paf0100f("PAF0100F"); - if (riga->starts_with("X")) + if (chiave_paf_mov(mov, tipodocsdi, hfatt, bfatt) && paf0100f.search(nullptr, hfatt, bfatt)) { - const int anno = riga->get_int(sfield(F_DOCS).cid2index(S_ANNO)); - const long nreg = riga->get_long(sfield(F_DOCS).cid2index(S_NUMREG)); - const TDoc_key key(anno, EMPTY_STRING, nreg); - // Ricontrollo che la fattura sia presente in Campo prima di cambiare stato - fdoc.zero(); - fdoc.put(DOC_PROVV, key.provv()); - fdoc.put(DOC_ANNO, key.anno()); - fdoc.put(DOC_CODNUM, key.codnum()); - fdoc.put(DOC_NDOC, key.ndoc()); - - TString hfatt, bfatt; - TPaf_record paf0100f("PAF0100F"); - if (fdoc.read() == NOERR && chiave_paf(fdoc.curr(), hfatt, bfatt) && paf0100f.search(nullptr, hfatt, bfatt)) + TString query; + query << + "UPDATE PAF0100F SET P1_GESTIONE = 'E', P1_KEYPRGINVIO = 'DELETED' WHERE P1_KEYHEADERFATT = '" << hfatt << "' AND P1_KEYBODYFATT = '" << bfatt << "';\n" << + "UPDATE PAF0200F SET P2_GESTIONE = 'E', P2_KEYPRGINVIO = 'DELETED' WHERE P2_KEYHEADERFATT = '" << hfatt << "' AND P2_KEYBODYFATT = '" << bfatt << "';\n" << + "UPDATE PAF0400F SET P4_GESTIONE = 'E', P4_KEYPRGINVIO = 'DELETED' WHERE P4_KEYHEADERFATT = '" << hfatt << "' AND P4_KEYBODYFATT = '" << bfatt << "';\n" << + "UPDATE PAF0700F SET P7_GESTIONE = 'E', P7_KEYPRGINVIO = 'DELETED' WHERE P7_KEYHEADERFATT = '" << hfatt << "' AND P7_KEYBODYFATT = '" << bfatt << "';\n" << + "UPDATE PAF0800F SET P8_GESTIONE = 'E', P8_KEYPRGINVIO = 'DELETED' WHERE P8_KEYHEADERFATT = '" << hfatt << "' AND P8_KEYBODYFATT = '" << bfatt << "';\n" << + "UPDATE PAF1000F SET P0_GESTIONE = 'E', P0_KEYPRGINVIO = 'DELETED' WHERE P0_KEYHEADERFATT = '" << hfatt << "' AND P0_KEYBODYFATT = '" << bfatt << "';\n" << + "UPDATE PAF1100F SET PA_GESTIONE = 'E', PA_KEYPRGINVIO = 'DELETED' WHERE PA_KEYHEADERFATT = '" << hfatt << "' AND PA_KEYBODYFATT = '" << bfatt << "';\n" << + "UPDATE PAF1200F SET PB_GESTIONE = 'E', PB_KEYPRGINVIO = 'DELETED' WHERE PB_KEYHEADERFATT = '" << hfatt << "' AND PB_KEYBODYFATT = '" << bfatt << "';\n" << + "UPDATE PAF1600F SET PF_GESTIONE = 'E', PF_KEYPRGINVIO = 'DELETED' WHERE PF_KEYHEADERFATT = '" << hfatt << "' AND PF_KEYBODYFATT = '" << bfatt << "';\n" << + "UPDATE PAF1700F SET PG_GESTIONE = 'E', PG_KEYPRGINVIO = 'DELETED' WHERE PG_KEYHEADERFATT = '" << hfatt << "' AND PG_KEYBODYFATT = '" << bfatt << "';\n" << + "UPDATE PAF1800F SET PI_GESTIONE = 'E', PI_KEYPRGINVIO = 'DELETED' WHERE PI_KEYHEADERFATT = '" << hfatt << "' AND PI_KEYBODYFATT = '" << bfatt << "';\n" << + "UPDATE PAF1900F SET PY_GESTIONE = 'E', PY_KEYPRGINVIO = 'DELETED' WHERE PY_KEYHEADERFATT = '" << hfatt << "' AND PY_KEYBODYFATT = '" << bfatt << "';\n" << + "UPDATE PAF2000F SET PJ_GESTIONE = 'E', PJ_KEYPRGINVIO = 'DELETED' WHERE PJ_KEYHEADERFATT = '" << hfatt << "' AND PJ_KEYBODYFATT = '" << bfatt << "';\n" << + "UPDATE PAF2100F SET PK_GESTIONE = 'E', PK_KEYPRGINVIO = 'DELETED' WHERE PK_KEYHEADERFATT = '" << hfatt << "' AND PK_KEYBODYFATT = '" << bfatt << "';\n" << + "UPDATE PAF2200F SET PL_GESTIONE = 'E', PL_KEYPRGINVIO = 'DELETED' WHERE PL_KEYHEADERFATT = '" << hfatt << "' AND PL_KEYBODYFATT = '" << bfatt << "';\n" << + "UPDATE PAF2400F SET PN_GESTIONE = 'E', PN_KEYPRGINVIO = 'DELETED' WHERE PN_KEYHEADERFATT = '" << hfatt << "' AND PN_KEYBODYFATT = '" << bfatt << "';\n" << + "UPDATE PAF2500F SET PO_GESTIONE = 'E', PO_KEYPRGINVIO = 'DELETED' WHERE PO_KEYHEADERFATT = '" << hfatt << "' AND PO_KEYBODYFATT = '" << bfatt << "';\n" << + "UPDATE PAF2600F SET PP_GESTIONE = 'E', PP_KEYPRGINVIO = 'DELETED' WHERE PP_KEYHEADERFATT = '" << hfatt << "' AND PP_KEYBODYFATT = '" << bfatt << "';\n" << + "UPDATE PAF2700F SET PQ_GESTIONE = 'E', PQ_KEYPRGINVIO = 'DELETED' WHERE PQ_KEYHEADERFATT = '" << hfatt << "' AND PQ_KEYBODYFATT = '" << bfatt << "';\n" << + "UPDATE PAF3000F SET PT_GESTIONE = 'E', PT_KEYPRGINVIO = 'DELETED' WHERE PT_KEYHEADERFATT = '" << hfatt << "' AND PT_KEYBODYFATT = '" << bfatt << "';\n" << + "UPDATE PAF3200F SET PU_GESTIONE = 'E', PU_KEYPRGINVIO = 'DELETED' WHERE PU_KEYHEADERFATT = '" << hfatt << "' AND PU_KEYBODYFATT = '" << bfatt << "';\n" << + // PAFW3 non ha il flag di gestione + "UPDATE PAFW300F SET PW_KEYPRGINVIO = 'DELETED' WHERE PW_KEYHEADERFATT = '" << hfatt << "' AND PW_KEYBODYFATT = '" << bfatt << "';\n"; + if(!fp_db().sq_set_exec(query)) { - static TString query; - query.cut(0) << - "UPDATE PAF0100F SET P1_GESTIONE = 'E', P1_KEYPRGINVIO = 'DELETED' WHERE P1_KEYHEADERFATT = '" << hfatt << "' AND P1_KEYBODYFATT = '" << bfatt << "';\n" << - "UPDATE PAF0200F SET P2_GESTIONE = 'E', P2_KEYPRGINVIO = 'DELETED' WHERE P2_KEYHEADERFATT = '" << hfatt << "' AND P2_KEYBODYFATT = '" << bfatt << "';\n" << - "UPDATE PAF0400F SET P4_GESTIONE = 'E', P4_KEYPRGINVIO = 'DELETED' WHERE P4_KEYHEADERFATT = '" << hfatt << "' AND P4_KEYBODYFATT = '" << bfatt << "';\n" << - "UPDATE PAF0700F SET P7_GESTIONE = 'E', P7_KEYPRGINVIO = 'DELETED' WHERE P7_KEYHEADERFATT = '" << hfatt << "' AND P7_KEYBODYFATT = '" << bfatt << "';\n" << - "UPDATE PAF0800F SET P8_GESTIONE = 'E', P8_KEYPRGINVIO = 'DELETED' WHERE P8_KEYHEADERFATT = '" << hfatt << "' AND P8_KEYBODYFATT = '" << bfatt << "';\n" << - "UPDATE PAF1000F SET P0_GESTIONE = 'E', P0_KEYPRGINVIO = 'DELETED' WHERE P0_KEYHEADERFATT = '" << hfatt << "' AND P0_KEYBODYFATT = '" << bfatt << "';\n" << - "UPDATE PAF1100F SET PA_GESTIONE = 'E', PA_KEYPRGINVIO = 'DELETED' WHERE PA_KEYHEADERFATT = '" << hfatt << "' AND PA_KEYBODYFATT = '" << bfatt << "';\n" << - "UPDATE PAF1200F SET PB_GESTIONE = 'E', PB_KEYPRGINVIO = 'DELETED' WHERE PB_KEYHEADERFATT = '" << hfatt << "' AND PB_KEYBODYFATT = '" << bfatt << "';\n" << - "UPDATE PAF1600F SET PF_GESTIONE = 'E', PF_KEYPRGINVIO = 'DELETED' WHERE PF_KEYHEADERFATT = '" << hfatt << "' AND PF_KEYBODYFATT = '" << bfatt << "';\n" << - "UPDATE PAF1700F SET PG_GESTIONE = 'E', PG_KEYPRGINVIO = 'DELETED' WHERE PG_KEYHEADERFATT = '" << hfatt << "' AND PG_KEYBODYFATT = '" << bfatt << "';\n" << - "UPDATE PAF1800F SET PI_GESTIONE = 'E', PI_KEYPRGINVIO = 'DELETED' WHERE PI_KEYHEADERFATT = '" << hfatt << "' AND PI_KEYBODYFATT = '" << bfatt << "';\n" << - "UPDATE PAF1900F SET PY_GESTIONE = 'E', PY_KEYPRGINVIO = 'DELETED' WHERE PY_KEYHEADERFATT = '" << hfatt << "' AND PY_KEYBODYFATT = '" << bfatt << "';\n" << - "UPDATE PAF2000F SET PJ_GESTIONE = 'E', PJ_KEYPRGINVIO = 'DELETED' WHERE PJ_KEYHEADERFATT = '" << hfatt << "' AND PJ_KEYBODYFATT = '" << bfatt << "';\n" << - "UPDATE PAF2100F SET PK_GESTIONE = 'E', PK_KEYPRGINVIO = 'DELETED' WHERE PK_KEYHEADERFATT = '" << hfatt << "' AND PK_KEYBODYFATT = '" << bfatt << "';\n" << - "UPDATE PAF2200F SET PL_GESTIONE = 'E', PL_KEYPRGINVIO = 'DELETED' WHERE PL_KEYHEADERFATT = '" << hfatt << "' AND PL_KEYBODYFATT = '" << bfatt << "';\n" << - "UPDATE PAF2400F SET PN_GESTIONE = 'E', PN_KEYPRGINVIO = 'DELETED' WHERE PN_KEYHEADERFATT = '" << hfatt << "' AND PN_KEYBODYFATT = '" << bfatt << "';\n" << - "UPDATE PAF2500F SET PO_GESTIONE = 'E', PO_KEYPRGINVIO = 'DELETED' WHERE PO_KEYHEADERFATT = '" << hfatt << "' AND PO_KEYBODYFATT = '" << bfatt << "';\n" << - "UPDATE PAF2600F SET PP_GESTIONE = 'E', PP_KEYPRGINVIO = 'DELETED' WHERE PP_KEYHEADERFATT = '" << hfatt << "' AND PP_KEYBODYFATT = '" << bfatt << "';\n" << - "UPDATE PAF2700F SET PQ_GESTIONE = 'E', PQ_KEYPRGINVIO = 'DELETED' WHERE PQ_KEYHEADERFATT = '" << hfatt << "' AND PQ_KEYBODYFATT = '" << bfatt << "';\n" << - "UPDATE PAF3000F SET PT_GESTIONE = 'E', PT_KEYPRGINVIO = 'DELETED' WHERE PT_KEYHEADERFATT = '" << hfatt << "' AND PT_KEYBODYFATT = '" << bfatt << "';\n" << - "UPDATE PAF3200F SET PU_GESTIONE = 'E', PU_KEYPRGINVIO = 'DELETED' WHERE PU_KEYHEADERFATT = '" << hfatt << "' AND PU_KEYBODYFATT = '" << bfatt << "';\n" << - // PAFW3 non ha il flag di gestione - "UPDATE PAFW300F SET PW_KEYPRGINVIO = 'DELETED' WHERE PW_KEYHEADERFATT = '" << hfatt << "' AND PW_KEYBODYFATT = '" << bfatt << "';\n"; - if(!fp_db().sq_set_exec(query)) - { - TString err = "Impossibile salvare la fattura "; err << anno << " " << " " << nreg << "\nVerrĂ  saltata."; - error_box(err); - } - - } - else - { - TString err = "Impossibile trovare la fattura "; err << anno << " " << " " << nreg << "\nVerrĂ  saltata."; + TString err = "Impossibile salvare la regolarizzazione "; err << nreg << "\nVerrĂ  saltata."; error_box(err); } + + } + else + { + TString err = "Impossibile trovare la fattura "; err << nreg << "\nVerrĂ  saltata."; + error_box(err); } } - fp_db().sq_commit(); } + fp_db().sq_commit(); force_reload_sheet(); } +TPAR_mask::TPAR_mask() : TAutomask("fp0700a"), _filter_changed(true), _enable_chiave_fixer(false) +{ + disable(DLG_OK); + disable(DLG_SAVEREC); + disable(DLG_FINDREC); + load_all_fields(); + const TDate data_inizio = get_date_start_new_fatt(); + __mask = this; + +} ///////////////////////////////////////////////////////////////////////////////////// // TReg2Paf diff --git a/src/fp/fp0700a.h b/src/fp/fp0700a.h index 1c984fd81..f8790865c 100644 --- a/src/fp/fp0700a.h +++ b/src/fp/fp0700a.h @@ -1,11 +1,11 @@ #define F_DATAINI 401 #define F_DATAEND 402 -#define F_DOCSEL 403 +#define F_REGSEL 403 #define F_CAUSALI_TIPO 404 #define F_TIPO_SDI 405 -#define F_DOCS 406 +#define F_REGS 406 #define START_MASK F_DATAINI -#define END_MASK F_DOCS +#define END_MASK F_REGS #define S_COD_CAUS 101 diff --git a/src/fp/fp0700a.uml b/src/fp/fp0700a.uml index c9a7da494..523d5a0fd 100644 --- a/src/fp/fp0700a.uml +++ b/src/fp/fp0700a.uml @@ -62,11 +62,14 @@ BEGIN CHECKTYPE REQUIRED END -RADIOBUTTON F_DOCSEL 7 80 +RADIOBUTTON F_REGSEL 7 80 BEGIN - PROMPT 1 3 "Documenti da visualizzare" - ITEM "P|Provvisori" - ITEM "D|Definitivi" + PROMPT 1 3 "Registrazioni da visualizzare" + ITEM "|Da inviare" + ITEM "X|XML Generato" + ITEM "N|Notificato" + ITEM "E|In errore" + ITEM "D|Diag." FLAGS "Z" END @@ -97,7 +100,7 @@ END ENDPAGE PAGE "Elenco Regolarizzazioni" 0 2 0 0 -SPREADSHEET F_DOCS +SPREADSHEET F_REGS BEGIN PROMPT 0 2 "" ITEM "@1" diff --git a/src/fp/fplib.h b/src/fp/fplib.h index 60aa701ae..7e8e1ffec 100644 --- a/src/fp/fplib.h +++ b/src/fp/fplib.h @@ -35,8 +35,9 @@ TString& complete_num_fp(const TCodice_numerazione& codnum, const int numdoc); // Genera la chiave per i paf -bool chiave_paf(const TDocumento& doc, TString& hfatt, TString& bfatt); -bool chiave_paf(const TRectype& doc, TString& hfatt, TString& bfatt); +bool chiave_paf_mov(const TRectype& mov, const TString & tipodoc, TString& hfatt, TString& bfatt); +bool chiave_paf_doc(const TDocumento& doc, TString& hfatt, TString& bfatt); +bool chiave_paf_doc(const TRectype& doc, TString& hfatt, TString& bfatt); // Ritorna cod sdi, pec o vuoto. Chiama get_coddest() TString get_dest_sdi(char tipocf, long codcf, const TString& cod_ind_sped); // Valorizza codice sdi e pec in base alle configurazioni del monitor @@ -421,9 +422,8 @@ inline TFP_custom_cache& cached_custom_fp() return *carmelo; } -class TFP_expression : public TObject +class TFP_expression : public TObject // ma perchè non derivano da expre documento cazzone ? se sono più espressioni prima si separa la token string { -private: enum TFP_operator { error, eq, neq, gt, ls, gteq, lseq, and, or }; // Etrattori @@ -445,8 +445,8 @@ public: static bool check_condition(const TString& cond, TRiga_documento& rdoc); static bool check_condition(const TString& cond, TDocumento& doc) { return check_condition(cond, doc[1]); } - TFP_expression() = default; - virtual ~TFP_expression() = default; + TFP_expression() {}; + virtual ~TFP_expression() {}; }; // Gestione PAF diff --git a/src/fp/fplib01.cpp b/src/fp/fplib01.cpp index 47c20068c..283ed0005 100644 --- a/src/fp/fplib01.cpp +++ b/src/fp/fplib01.cpp @@ -159,7 +159,27 @@ TString& complete_num_fp(const TCodice_numerazione& codnum, const int numdoc) */ // Crea la coppia di chiavi per il db PAF a partire da un documento vero e proprio -bool chiave_paf(const TDocumento& doc, TString& hfatt, TString& bfatt) +bool chiave_paf_mov(const TRectype& mov, const TString & tipodoc, TString& hfatt, TString& bfatt) +{ + TCli_for cli(mov.get_char(MOV_TIPO), mov.get_long(MOV_CODCF)); + hfatt.cut(0); + if (cli.is_occasionale()) + hfatt << "O" << mov.get(MOV_OCFPI); + else + hfatt << cli.tipo() << cli.codice(); + CHECK(hfatt.full(), "Destinatario fattura P.A. non valido"); + //20180101_TD01_123456712345671234567 + + TString numdoc = mov.get(MOV_NUMDOC); + + numdoc.lpad(mov.length(DOC_NDOC), '0'); + bfatt = mov.get_date(MOV_DATAREG).date2ansi(); + bfatt << '_' << tipodoc << '_' << numdoc; + return hfatt.full() && bfatt.full(); +} + + +bool chiave_paf_doc(const TDocumento& doc, TString& hfatt, TString& bfatt) { hfatt.cut(0); if (doc.clifor().is_occasionale()) @@ -174,10 +194,10 @@ bool chiave_paf(const TDocumento& doc, TString& hfatt, TString& bfatt) } // Crea la coppia di chiavi per il db PAF a partire da un semplice record di testata documento -bool chiave_paf(const TRectype& doc, TString& hfatt, TString& bfatt) +bool chiave_paf_doc(const TRectype& doc, TString& hfatt, TString& bfatt) { const TDocumento d(doc); - chiave_paf(d, hfatt, bfatt); + chiave_paf_doc(d, hfatt, bfatt); return hfatt.full(); } @@ -1015,7 +1035,7 @@ bool TDoc_fp::initialize(TDocumentoEsteso& doc) // Paese del documento _paese = "IT"; _has_bolla = false; - if (!chiave_paf(doc, _hfatt, _bfatt)) + if (!chiave_paf_doc(doc, _hfatt, _bfatt)) return false; // Preparo il log log(-1, _bfatt); @@ -1838,36 +1858,34 @@ bool TDoc_fp::doc_to_paf(TDocumentoEsteso& doc) rifs.trim(); if (rifs == "0") rifs.cut(0); - int pos = rifs.find(" - "); - int len = rifs.len(); - long numlinea = 0; - if (len > 0 && pos < 0) - pos = len; + int len = rifs.len(); - for(; pos >= 0;) - { - TToken_string rif(rifs.left(pos), ' '); + if (len > 0) + { + rifs.replace(" - ", "|"); - // // - reset(paf1600f); - temp = rif.get(); - paf1600f.set("PF_NUMDDDT", temp); - temp = rif.get(); + long numlinea = 0; + TToken_string elab_rifs(rifs); - TDate dataddt(atoi(temp.left(2)), atoi(temp.mid(3,2)),atoi( temp.right(2))); - - paf1600f.set("PF_DATADDT", dataddt); - paf1600f.set("PF_GESTIONE", "D"); - paf1600f.set("PF_RIFNUMLINEA", numlinea++); - ok &= insert(paf1600f); - rifs.ltrim(pos + 3); - pos = rifs.find(" - "); - len = rifs.len(); - if (len > 0 && pos < 0) - pos = len; - // - } + FOR_EACH_STR_TOKEN(elab_rifs, str) + { + TToken_string rif(str, ' '); + + // // + reset(paf1600f); + temp = rif.get(); + paf1600f.set("PF_NUMDDDT", temp); + temp = rif.get(); + + TDate dataddt(atoi(temp.left(2)), atoi(temp.mid(3, 2)), atoi(temp.right(2))); + + paf1600f.set("PF_DATADDT", dataddt); + paf1600f.set("PF_GESTIONE", "D"); + paf1600f.set("PF_RIFNUMLINEA", numlinea++); + ok &= insert(paf1600f); // + } + } } FOR_EACH_PHYSICAL_FPRDOC(doc, r, rdoc) { diff --git a/src/fp/fplib03.cpp b/src/fp/fplib03.cpp index 0f034a169..ee0150491 100644 --- a/src/fp/fplib03.cpp +++ b/src/fp/fplib03.cpp @@ -91,7 +91,7 @@ bool TFp_mail_sender::send(const TString& msg) TPaf_record paf0100f("PAF0100F"); TString query; - if (chiave_paf(fdoc, hfatt, bfatt) && paf0100f.search(nullptr, hfatt, bfatt)) + if (chiave_paf_doc(fdoc, hfatt, bfatt) && paf0100f.search(nullptr, hfatt, bfatt)) { query << "UPDATE PAF0100F SET P1_ERRINT = 'S' WHERE P1_KEYHEADERFATT = '" << hfatt << "' AND P1_KEYBODYFATT = '" << bfatt << "'"; fp_db().sq_set_exec(query); diff --git a/src/fp/fplib05.cpp b/src/fp/fplib05.cpp index 3874dd69d..5a73e01ad 100644 --- a/src/fp/fplib05.cpp +++ b/src/fp/fplib05.cpp @@ -477,7 +477,8 @@ void TFP_expression::split_condition(const TString& cond, TString& cond_sx, TStr } } -// Questa funzione potrebbe diventare standard per TRectype +// Questa funzione potrebbe diventare standard per TRectype. Ma vai a cagare i variant sono da eliminare + TVariant& TFP_expression::get_value(const TRectype& rec, const TString& campo) { TVariant& ret = get_tmp_var(); diff --git a/src/gfm/median.c b/src/gfm/median.c index 6cf7d88ed..9fbd519fb 100755 --- a/src/gfm/median.c +++ b/src/gfm/median.c @@ -73,7 +73,7 @@ int n; tmpa[i] = pSrc[i]; /* sort pointers */ - qsort((void *)tmpa,n,sizeof(DEC *), _SortInc); + qsort((void *)tmpa,n,sizeof(DEC *), (int (__cdecl *)(void)) _SortInc); if (n%2) _MacDCopy(pDst, tmpa[(n-1)/2]); diff --git a/src/gv/gvlib.cpp b/src/gv/gvlib.cpp index 8eceda97c..318f39cf3 100755 --- a/src/gv/gvlib.cpp +++ b/src/gv/gvlib.cpp @@ -5,7 +5,6 @@ #include "../cg/cglib.h" - /////////////////////////////////////////////////////////// // TRigheF24_set /////////////////////////////////////////////////////////// diff --git a/src/ha/ha1300.cpp b/src/ha/ha1300.cpp index 97d52d481..7e1c67a38 100755 --- a/src/ha/ha1300.cpp +++ b/src/ha/ha1300.cpp @@ -5,7 +5,7 @@ #include #include "../cg/cg2101.h" -#include "../cg/cg2103.h" +#include "../cg/cglib.h" #include "../cg/cgsaldac.h" #include "../mg/movmag.h" #include "../mg/rmovmag.h" diff --git a/src/ha/hacnv300.cpp b/src/ha/hacnv300.cpp index eed031101..934a24f47 100755 --- a/src/ha/hacnv300.cpp +++ b/src/ha/hacnv300.cpp @@ -12,7 +12,7 @@ #include #include "../cg/cglib01.h" -#include "../cg/cg2103.h" +#include "../cg/cglib.h" #include "../cg/cgsaldac.h" #include "../cg/cgpagame.h" diff --git a/src/ic/ic0100f.rep b/src/ic/ic0100f.rep index d9aa99419..d671d9cd9 100644 --- a/src/ic/ic0100f.rep +++ b/src/ic/ic0100f.rep @@ -395,7 +395,9 @@ THEN #F1.203 +! - USE IVADIFF SELECT (BETWEEN(DATAREG,#DAL,#AL))(TIPOIVA==#TIPOIVA)(TIPODIFF==#TIPODIFF)((CHIUSA=#CHIUSA)||(#CHIUSA="T")) + USE IVADIFF KEY 4 SELECT (BETWEEN(DATAREGP;#DAL;#AL))(TIPOIVA==#TIPOIVA)(TIPODIFF==#TIPODIFF)((CHIUSA=#CHIUSA)||(#CHIUSA="T")) +FROM DATAREG=#DAL +TO DATAREG=#AL JOIN MOV INTO NUMREG==NUMREG JOIN CLIFO TO MOV INTO TIPOCF==TIPO CODCF==CODCF \ No newline at end of file diff --git a/src/ic/ic0200.cpp b/src/ic/ic0200.cpp index d6719f489..ce81e5f86 100644 --- a/src/ic/ic0200.cpp +++ b/src/ic/ic0200.cpp @@ -20,7 +20,7 @@ public: void TICpag_print::main_loop() { - TMask m("ic0100a"); + TMask m("ic0200a"); while (m.run() == K_ENTER) { TICpag_report r("ic0200p"); diff --git a/src/ic/ic0200p.rep b/src/ic/ic0200p.rep index e911580c4..649ed8684 100644 --- a/src/ic/ic0200p.rep +++ b/src/ic/ic0200p.rep @@ -1,71 +1,71 @@ - + -
-
+