diff --git a/build/Cg2.vcxproj b/build/Cg2.vcxproj index 423b6b38b..16a8598dc 100644 --- a/build/Cg2.vcxproj +++ b/build/Cg2.vcxproj @@ -118,7 +118,6 @@ _DEBUG;WIN32;__LONGDOUBLE__;_WINDOWS;__LONGDOUBLE__;%(PreprocessorDefinitions) false MultiThreadedDebug - Level3 true EditAndContinue @@ -311,6 +310,9 @@ {2d38a763-3d74-4338-9362-b891784ec90e} + + {41f4c25f-6bd2-4fc9-a0d3-a68cd1c9e4fc} + {c575788b-0be4-4f68-b9c9-3c204ec04e07} diff --git a/build/cg.sln b/build/cg.sln index af3730030..87f0cb8cc 100644 --- a/build/cg.sln +++ b/build/cg.sln @@ -9,6 +9,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Cg1", "Cg1.vcxproj", "{9B42 EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Cg2", "Cg2.vcxproj", "{9304E774-E631-495D-A29D-774222BBF8C9}" ProjectSection(ProjectDependencies) = postProject + {41F4C25F-6BD2-4FC9-A0D3-A68CD1C9E4FC} = {41F4C25F-6BD2-4FC9-A0D3-A68CD1C9E4FC} {C575788B-0BE4-4F68-B9C9-3C204EC04E07} = {C575788B-0BE4-4F68-B9C9-3C204EC04E07} EndProjectSection EndProject @@ -28,6 +29,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AgaLib", "AgaLib.vcxproj", EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "fplib", "fplib.vcxproj", "{C575788B-0BE4-4F68-B9C9-3C204EC04E07}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "f1lib", "f1lib.vcxproj", "{41F4C25F-6BD2-4FC9-A0D3-A68CD1C9E4FC}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 @@ -78,6 +81,10 @@ Global {C575788B-0BE4-4F68-B9C9-3C204EC04E07}.Debug|Win32.Build.0 = Debug|Win32 {C575788B-0BE4-4F68-B9C9-3C204EC04E07}.Release|Win32.ActiveCfg = Release|Win32 {C575788B-0BE4-4F68-B9C9-3C204EC04E07}.Release|Win32.Build.0 = Release|Win32 + {41F4C25F-6BD2-4FC9-A0D3-A68CD1C9E4FC}.Debug|Win32.ActiveCfg = Debug|Win32 + {41F4C25F-6BD2-4FC9-A0D3-A68CD1C9E4FC}.Debug|Win32.Build.0 = Debug|Win32 + {41F4C25F-6BD2-4FC9-A0D3-A68CD1C9E4FC}.Release|Win32.ActiveCfg = Release|Win32 + {41F4C25F-6BD2-4FC9-A0D3-A68CD1C9E4FC}.Release|Win32.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/build/f1lib.vcxproj b/build/f1lib.vcxproj new file mode 100644 index 000000000..fa7086b48 --- /dev/null +++ b/build/f1lib.vcxproj @@ -0,0 +1,173 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + {41F4C25F-6BD2-4FC9-A0D3-A68CD1C9E4FC} + fp + 10.0.17763.0 + + + + StaticLibrary + false + v141 + + + StaticLibrary + false + v141 + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + ..\lib\ + ..\obj\$(SolutionName)\$(ProjectName)\ + false + ..\lib\ + ..\obj\$(SolutionName)\$(ProjectName)\ + false + false + false + .lib + .lib + + + + _DEBUG;%(PreprocessorDefinitions) + true + true + Win32 + .\..\debug/fplib.tlb + + + + + Disabled + ..\src\f1\;..\src\xvtdb\;..\src\cg;..\src\include;..\src\xvaga;%(AdditionalIncludeDirectories) + _DEBUG;WIN32;_WINDOWS;__LONGDOUBLE__;%(PreprocessorDefinitions) + false + MultiThreadedDebug + $(IntDir)$(TargetName).pch + $(IntDir) + $(IntDir) + $(IntDir)$(TargetName).pdb + Level3 + true + ProgramDatabase + true + + + _DEBUG;%(PreprocessorDefinitions) + 0x0410 + ..\wx28X\include;%(AdditionalIncludeDirectories) + + + wsock32.lib;%(AdditionalDependencies) + $(OutDir)$(TargetName)$(TargetExt) + true + %(IgnoreSpecificDefaultLibraries) + true + $(TargetDir)$(TargetName).pdb + Windows + false + + + MachineX86 + NotSet + + + true + .\..\debug/fplib.bsc + + + + + NDEBUG;%(PreprocessorDefinitions) + true + true + Win32 + .\..\release/fplib.tlb + + + + + MaxSpeed + ..\src\xvtdb\;..\src\cg;..\src\include;..\src\xvaga;%(AdditionalIncludeDirectories) + NDEBUG;WIN32;_WINDOWS;%(PreprocessorDefinitions) + true + MultiThreaded + true + false + Level3 + true + + + NDEBUG;%(PreprocessorDefinitions) + 0x0410 + ..\wx28X\include;%(AdditionalIncludeDirectories) + + + wsock32.lib;%(AdditionalDependencies) + true + %(IgnoreSpecificDefaultLibraries) + Windows + + + MachineX86 + 12.0 + false + $(OutDir)$(TargetName)$(TargetExt) + $(TargetDir)$(TargetName).pdb + + + true + .\..\release/fplib.bsc + + + + + Document + true + + + Document + true + + + + + {2d38a763-3d74-4338-9362-b891784ec90e} + + + + + + + + + + + + + \ No newline at end of file diff --git a/build/f1lib.vcxproj.filters b/build/f1lib.vcxproj.filters new file mode 100644 index 000000000..c61d72f6b --- /dev/null +++ b/build/f1lib.vcxproj.filters @@ -0,0 +1,21 @@ + + + + + {afbf9839-55d1-46a9-9d8a-45e41e3d3d11} + + + {1ca586f9-1511-48e9-89db-65f13a861684} + + + + + Sources + + + + + Headers + + + \ No newline at end of file diff --git a/build/f1lib.vcxproj.user b/build/f1lib.vcxproj.user new file mode 100644 index 000000000..be2507870 --- /dev/null +++ b/build/f1lib.vcxproj.user @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/build/fp.sln b/build/fp.sln index 8a1c85d07..5b54d3fea 100644 --- a/build/fp.sln +++ b/build/fp.sln @@ -21,6 +21,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "fp1", "fp1.vcxproj", "{A539 {7BF6939E-DFCD-49ED-B0A8-EDB68DDCE6D5} = {7BF6939E-DFCD-49ED-B0A8-EDB68DDCE6D5} EndProjectSection EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "f1lib", "f1lib.vcxproj", "{41F4C25F-6BD2-4FC9-A0D3-A68CD1C9E4FC}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 @@ -47,6 +49,10 @@ Global {A539BCC1-D08F-4D78-A8EA-65560F4A60CD}.Debug|Win32.Build.0 = Debug|Win32 {A539BCC1-D08F-4D78-A8EA-65560F4A60CD}.Release|Win32.ActiveCfg = Release|Win32 {A539BCC1-D08F-4D78-A8EA-65560F4A60CD}.Release|Win32.Build.0 = Release|Win32 + {41F4C25F-6BD2-4FC9-A0D3-A68CD1C9E4FC}.Debug|Win32.ActiveCfg = Debug|Win32 + {41F4C25F-6BD2-4FC9-A0D3-A68CD1C9E4FC}.Debug|Win32.Build.0 = Debug|Win32 + {41F4C25F-6BD2-4FC9-A0D3-A68CD1C9E4FC}.Release|Win32.ActiveCfg = Release|Win32 + {41F4C25F-6BD2-4FC9-A0D3-A68CD1C9E4FC}.Release|Win32.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/build/fp0.vcxproj b/build/fp0.vcxproj index 8857b770d..8aa5ec0fe 100644 --- a/build/fp0.vcxproj +++ b/build/fp0.vcxproj @@ -176,6 +176,9 @@ {2d38a763-3d74-4338-9362-b891784ec90e} + + {41f4c25f-6bd2-4fc9-a0d3-a68cd1c9e4fc} + {a1ce9743-a597-4f92-b55a-345a366c9e55} diff --git a/build/fp0.vcxproj.user b/build/fp0.vcxproj.user index be5d31880..6495d1c7c 100644 --- a/build/fp0.vcxproj.user +++ b/build/fp0.vcxproj.user @@ -1,7 +1,7 @@  - -2 /uADMIN + -3 /uADMIN $(TargetDir) WindowsLocalDebugger diff --git a/cd/test/cg0790.txt b/cd/test/cg0790.txt new file mode 100644 index 000000000..505e4e508 --- /dev/null +++ b/cd/test/cg0790.txt @@ -0,0 +1,11 @@ +cg2100c.msk +cg2.exe +cg2fppro.msk + +Tolta esportazione protocollo ingresso su movimento (verra' fatto con l'F9) +Aggiunto flag se registrazione collegata a FPPRO +Corretta eliminazione massiva movimenti +Cambiata modalita' modifica: non permetteva di salvare a prescindere dalle modifiche (mantenuto comunque il controllo preventivo) +Aggiunto controllo per apertura automatica maschera FPPRO: +Si apriva da sola quando eseguivo dal monitor delle fat. passive +Dati documento salvati internamente e non su maschera per passaggio da maschera FPPRO a maschera cg diff --git a/cd/test/cg0790a.ini b/cd/test/cg0790a.ini new file mode 100644 index 000000000..2807ad729 --- /dev/null +++ b/cd/test/cg0790a.ini @@ -0,0 +1,96 @@ +[Main] +Demo=0 + +[cg2] +Edit_23 = cg2 -0 +File(102) = cg2.exe|X +File(105) = cg2100c.msk|X +File(115) = cg2fppro.msk|X +Patch = 0790 +Versione = 21511200 + +[cg99] +Kill(0) = bastntb.rep|x +Kill(1) = bastvet.msk|x +Kill(2) = bastpdb.msk|x +Kill(3) = bastmsp.msk|x +Kill(4) = batbarb.msk|x +Kill(5) = bastndo.rep|x +Kill(6) = bastesc.msk|x +Kill(7) = batbvet.msk|x +Kill(8) = bastzon.msk|x +Kill(9) = bastcve.rep|x +Kill(10) = batbivd.msk|x +Kill(11) = batbtit.msk|x +Kill(12) = bastnot.msk|x +Kill(13) = bastcco.msk|x +Kill(14) = batbcco.msk|x +Kill(15) = bastscc.msk|x +Kill(16) = batbleg.msk|x +Kill(17) = batblia.msk|x +Kill(18) = bastpor.msk|x +Kill(19) = batbcam.msk|x +Kill(20) = batbind.msk|x +Kill(21) = bastcco.rep|x +Kill(22) = batbntb.msk|x +Kill(23) = bastpor.rep|x +Kill(24) = bastcve.msk|x +Kill(25) = batbesc.msk|x +Kill(26) = bastleg.msk|x +Kill(27) = bastmsp.rep|x +Kill(28) = batbcfi.msk|x +Kill(29) = bastarb.rep|x +Kill(30) = batbins.msk|x +Kill(31) = batblia.msk|x +Kill(32) = batbscc.msk|x +Kill(33) = bastivd.msk|x +Kill(34) = batbnot.msk|x +Kill(35) = bastreg.rep|x +Kill(36) = bastnot.rep|x +Kill(37) = batbpdb.msk|x +Kill(38) = cgtbcon.msk|x +Kill(39) = bastver.rep|x +Kill(40) = bastcfi.msk|x +Kill(41) = bastntb.msk|x +Kill(42) = bastpdb.rep|x +Kill(43) = bastesc.rep|x +Kill(44) = bastdpn.rep|x +Kill(45) = bastarb.msk|x +Kill(46) = bastreg.msk|x +Kill(47) = batbinl.msk|x +Kill(48) = bastivd.rep|x +Kill(49) = bastndo.msk|x +Kill(50) = batbdel.msk|x +Kill(51) = batbmsp.msk|x +Kill(52) = batbreg.msk|x +Kill(53) = bastvet.rep|x +Kill(54) = batblbu.msk|x +Kill(55) = bastcam.msk|x +Kill(56) = bastdpn.msk|x +Kill(57) = batbzon.msk|x +Kill(58) = bastscc.rep|x +Kill(59) = batbdpn.msk|x +Kill(60) = batbver.msk|x +Kill(61) = bastleg.rep|x +Kill(62) = bastzon.rep|x +Kill(63) = batbcve.msk|x +Kill(64) = bastcfi.rep|x +Kill(65) = bastver.msk|x +Kill(66) = batbndo.msk|x +Kill(67) = batbtra.msk|x +Kill(68) = bastcam.rep|x +Kill(69) = batbpor.msk|x + +[cg] +Data = 16-05-2019 +Descrizione = Contabilita' Generale +Dischi = 1 +Moduli = ba +OEM = +Patch = 790 +PostProcess = bainst -0 CG +PreProcess = +Prezzo(1) = +Prezzo(2) = +Versione = 21511200 + diff --git a/cd/test/cg0790a1.zip b/cd/test/cg0790a1.zip new file mode 100644 index 000000000..3834564e6 Binary files /dev/null and b/cd/test/cg0790a1.zip differ diff --git a/cd/test/fp0788.txt b/cd/test/fp0788.txt new file mode 100644 index 000000000..a7f53763d --- /dev/null +++ b/cd/test/fp0788.txt @@ -0,0 +1,3 @@ +fp0.exe + +Sistemato calcolo importo riga per chi non espone gli sconti in fattura \ No newline at end of file diff --git a/cd/test/fp0788a.ini b/cd/test/fp0788a.ini new file mode 100644 index 000000000..33cf0c7f1 --- /dev/null +++ b/cd/test/fp0788a.ini @@ -0,0 +1,19 @@ +[Main] +Demo=0 + +[fp1] +File(0) = fp0.exe|X +Patch = 0788 +Versione = 21511200 + +[fp] +Data = 13-05-2019 +Descrizione = Fattura Elettronica +Dischi = 1 +Moduli = cg,ve +OEM = +Patch = 788 +PostProcess = +PreProcess = +Versione = 21511200 + diff --git a/cd/test/fp0788a1.zip b/cd/test/fp0788a1.zip new file mode 100644 index 000000000..2b1cc2f2c Binary files /dev/null and b/cd/test/fp0788a1.zip differ diff --git a/cd/test/fp0790.txt b/cd/test/fp0790.txt new file mode 100644 index 000000000..3f2dd8d20 --- /dev/null +++ b/cd/test/fp0790.txt @@ -0,0 +1,15 @@ +fp0.exe +fp0400a.msk + +Aggiunta contabilizzazione automatica da fp fatt. passive con protocollo ini +Corretta comportamento bottoni toolbar (abilita/disabilita) +Aggiunto range data per fatture contabilizzate +Aggiunto controllo se fornitore e' sospeso non lo propongo +Aggiunte causali di default per contabilizzazione +Salvate date e causali default su config. ditta +Rifatta maschera per separare meglio parte fp da f1 +Aggiunti controlli sui bottoni +Aggiustati filtri elenco fatture +Aggiunta possibilita' di aprire registrazione da elenco fatture contabilizzate +Aggiunto log per stato contabilizzazione (salvate/annullate) +Corretta esportazione importi negativi diff --git a/cd/test/fp0790a.ini b/cd/test/fp0790a.ini new file mode 100644 index 000000000..af2e23e34 --- /dev/null +++ b/cd/test/fp0790a.ini @@ -0,0 +1,20 @@ +[Main] +Demo=0 + +[fp1] +File(0) = fp0.exe|X +File(4) = fp0400a.msk|X +Patch = 0790 +Versione = 21511200 + +[fp] +Data = 17-05-2019 +Descrizione = Fattura Elettronica +Dischi = 1 +Moduli = cg,ve +OEM = +Patch = 790 +PostProcess = +PreProcess = +Versione = 21511200 + diff --git a/cd/test/fp0790a1.zip b/cd/test/fp0790a1.zip new file mode 100644 index 000000000..50ceb8ccd Binary files /dev/null and b/cd/test/fp0790a1.zip differ diff --git a/cd/test/sy0790.txt b/cd/test/sy0790.txt new file mode 100644 index 000000000..646e5b9ff --- /dev/null +++ b/cd/test/sy0790.txt @@ -0,0 +1,4 @@ +ba0.exe +campo.aut + +Aggiunti nuovi moduli f1, f9 diff --git a/cd/test/sy0790a.ini b/cd/test/sy0790a.ini new file mode 100644 index 000000000..4d8b4d205 --- /dev/null +++ b/cd/test/sy0790a.ini @@ -0,0 +1,22 @@ +[Main] +Demo=0 + +[sy1] +File(0) = ba0.exe|X +File(36) = campo.aut|X +Patch = 0790 +Versione = 21511200 + +[sy] +Data = 17-05-2019 +Descrizione = Sistema +Dischi = 1 +Moduli = +OEM = +Patch = 790 +PostProcess = +PreProcess = +Prezzo(1) = +Prezzo(2) = +Versione = 21511200 + diff --git a/cd/test/sy0790a1.zip b/cd/test/sy0790a1.zip new file mode 100644 index 000000000..f7915fc49 Binary files /dev/null and b/cd/test/sy0790a1.zip differ diff --git a/src/cg/cg2100.cpp b/src/cg/cg2100.cpp index f1291272d..2b401e498 100755 --- a/src/cg/cg2100.cpp +++ b/src/cg/cg2100.cpp @@ -123,9 +123,11 @@ TMask* TPrimanota_application::load_mask(int n) ism.set_handler(309, sheet_clifo_handler); ism.set_handler(CG_RATEO, sheet_rateo_handler); ism.set_handler(CG_RISCONTO, sheet_risconto_handler); - if (!is_fp(m)) + if (!has_f1_db(m)) { m->hide(F_PROTFPPRO); + if (m->find_by_id(F_COLFPPRO) != NULL) + m->hide(F_COLFPPRO); if(m->find_by_id(DLG_LINK) != NULL) m->disable(DLG_LINK); } @@ -1051,7 +1053,12 @@ void TPrimanota_application::init_modify_mode(TMask& m) m.enable(F_BOLLARAGCLI, causale().tipo_doc() == "BD"); } if(m.find_by_id(F_PROTFPPRO) != NULL && !m.field(F_PROTFPPRO).hidden()) + { m.set(F_PROTFPPRO, mov.get(MOV_PROGFPPRO)); + m.set(F_COLFPPRO, mov.get(MOV_KEYFPPRO).empty() ? " " : "X"); + } + + } // Controlla sulla causale se il segno del totale documento (ritsoc=false) @@ -1572,8 +1579,8 @@ void TPrimanota_application::clean_fppro() // Controlli: solo in mod modifica; che abbia fp (no F8); che non sono in salvataggio if (_mode != MODE_MOD - || !is_fp(&msk) - || last_key != K_DEL && last_key != K_SAVE) + || !has_f1_db(&msk) + || last_key != K_DEL && last_key != K_SAVE && last_key != K_ELIMMAS) return; const TString& numreg = msk.get(F_NUMREG); @@ -1587,12 +1594,12 @@ void TPrimanota_application::clean_fppro() fp_db().sq_commit(); } -bool TPrimanota_application::is_fp(TMask* m) +bool TPrimanota_application::has_f1_db(TMask* m) { static bool is_set_fpcheck = false; if (!is_set_fpcheck) { - _isfp = has_module(FPAUT) && !fp_settings().get_db_indirizzo().empty() && !fp_settings().is_f8(); + _isfp = has_module(F1AUT) && !fp_settings().get_db_indirizzo().empty() && !fp_settings().is_f8(); is_set_fpcheck = true; } return _isfp; @@ -2348,7 +2355,7 @@ int TPrimanota_application::save_fppro() const KEY last = msk.last_key(); // Provo a vedere se hanno l'FP: se c'è l'indirizzo controllo che non sia F8 se non c'è non hanno l'FP - if (!is_fp(&msk)) + if (!has_f1_db(&msk)) return pro_nofp; if (!fp_db().sq_is_connect()) { @@ -2372,8 +2379,6 @@ int TPrimanota_application::save_fppro() { message_box(TString("Attenzione!") << " E' stato modificato un movimento già collegato a un documento in ingresso."); clean_fppro(); // Pulisco db - msk.set(F_PROKEY, ""); - msk.set(F_PROTFPPRO, ""); save_dbmov(); // Svuoto riferimento doc ingresso sul mov } } @@ -2382,7 +2387,7 @@ int TPrimanota_application::save_fppro() } // Controllo che sto registrando un documento FA Fattura di Acquisto o NC Acquisto - if (!TPro_msk::check_causale(msk.get(F_CODCAUS))) + if (!check_causale(msk.get(F_CODCAUS))) return pro_notsaved; if (last != K_SAVE) { // Se sto uscendo avvertimento di non salvataggio e salto message_box("La registrazione del movimento non verrà salvata sul database."); diff --git a/src/cg/cg2100.h b/src/cg/cg2100.h index 9c9fb80d2..3389e89b5 100755 --- a/src/cg/cg2100.h +++ b/src/cg/cg2100.h @@ -22,6 +22,7 @@ #define F_PROTFPPRO 230 #define F_RITFATT 231 #define F_PROKEY 232 +#define F_COLFPPRO 233 #define F_CLIFO 128 #define F_CODCLIFOR 151 diff --git a/src/cg/cg2100c.uml b/src/cg/cg2100c.uml index e0930e3d0..88f5e2200 100755 --- a/src/cg/cg2100c.uml +++ b/src/cg/cg2100c.uml @@ -609,9 +609,16 @@ BEGIN DRIVENBY F_VALUTAINTRA END +BOOLEAN F_COLFPPRO +BEGIN + PROMPT 1 18 "Registrazione collegata a FPPRO" + FLAGS "D" +END + STRING F_PROTFPPRO 18 BEGIN - PROMPT 1 18 "Codice Protocollo FPPRO " + PROMPT 1 19 "Codice Protocollo FPPRO " + FIELD PROGFPPRO FLAGS "D" END @@ -619,6 +626,7 @@ STRING F_PROKEY 80 BEGIN PROMPT 1 18 "db key" HELP "Chiave database" + FIELD KEYFPPRO FLAGS "H" END diff --git a/src/cg/cg2102.cpp b/src/cg/cg2102.cpp index 194a829a7..ae7d5a85d 100755 --- a/src/cg/cg2102.cpp +++ b/src/cg/cg2102.cpp @@ -20,6 +20,7 @@ #include #include #include "../fp/fplib.h" +#include "../f1/f1lib.h" /////////////////////////////////////////////////////////// // Funzioni di decodifica/calcolo @@ -2261,15 +2262,15 @@ bool TPrimanota_application::caus_query_handler(TMask_field& f, KEY key) void TPrimanota_application::check_fppro_fields(TMask& m) { - if (app().is_fp(&m)) + if (app().has_f1_db(&m)) { - if (!TPro_msk::check_causale(m.get(F_CODCAUS)) && m.find_by_id(F_PROTFPPRO) != NULL) + if (!check_causale(m.get(F_CODCAUS)) && m.find_by_id(F_PROTFPPRO) != NULL) { m.hide(F_PROTFPPRO); m.disable(DLG_LINK); } else - if (TPro_msk::check_causale(m.get(F_CODCAUS)) && m.find_by_id(F_PROTFPPRO) != NULL && m.field(F_PROTFPPRO).hidden()) + if (check_causale(m.get(F_CODCAUS)) && m.find_by_id(F_PROTFPPRO) != NULL && m.field(F_PROTFPPRO).hidden()) { m.show(F_PROTFPPRO); m.enable(DLG_LINK); @@ -3006,7 +3007,8 @@ bool TPrimanota_application::clifo_handler(TMask_field& f, KEY key) const bool ic = ixc->active() && (alleg < 5 || alleg == 7) && paiv.full() && !m.get_bool(F_LIQDIFF); ixc->set(ic ? "X" : ""); } - fppro_mask(f, key); + if(m.get(F_PROKEY).empty()) + fppro_mask(f, key); } } @@ -3846,28 +3848,37 @@ bool TPrimanota_application::quadratura_handler(TMask_field& f, KEY key) bool TPrimanota_application::fppro_mask(TMask_field& f, KEY key) { TMask& cg_msk = f.mask(); - if (!app().get_isfp() || key != K_SPACE && key != K_TAB || !TPro_msk::check_causale(f.mask().get(F_CODCAUS))) + if (!app().get_isfp() || key != K_SPACE && key != K_TAB || !check_causale(f.mask().get(F_CODCAUS))) return true; auto msk = std::make_shared(cg_msk); + app()._pro_mask = msk; - //load_list(msk, key); - //if(load_fppro_mask(msk)) if (msk->load_fppro_mask(msk.get())) { msk->run(); // Riporto dati FPPRO su maschera Prima Nota - cg_msk.set(F_NUMDOCEXT, msk->get(F_NUMEROI)); - cg_msk.set(F_NUMDOC, TString(msk->get(F_NUMEROI)).right(7)); - cg_msk.set(F_DATADOC, msk->get(F_DATAI)); - cg_msk.set(F_TOTALE, msk->get(F_TOTDOCI)); - cg_msk.set(F_PROTFPPRO, msk->get(F_PROTFPPROI)); - cg_msk.set(F_PROKEY, msk->get(F_FPPROKEYSI)); + cg_msk.set(F_NUMDOCEXT, msk->get_numdoc()); + cg_msk.set(F_NUMDOC, msk->get_numdoc().right(7)); + cg_msk.set(F_DATADOC, msk->get_datadoc()); + cg_msk.set(F_TOTALE, msk->get_totdoc()); + //cg_msk.set(F_PROTFPPRO, msk->get_protocollo()); + 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; } +bool TPrimanota_application::is_collegato(TMask_field& f) +{ + TMask& cg_msk = f.mask(); + const bool has_prokey = !cg_msk.get(F_PROKEY).empty(); + f.set(has_prokey ? "X" : " "); + return has_prokey; +} + bool TPro_msk::load_fppro_mask(TMask* msk, KEY k) { // Provo a vedere se hanno l'FP: se c'è l'indirizzo controllo che non sia F8 se non c'è non hanno l'FP @@ -3955,12 +3966,8 @@ bool TPro_msk::fppro_ok_handler(TMask_field& f, KEY k) { if(!loaded && *row->get(0) == 'X') { - msk.set(F_NUMEROI, row->get(5)); - msk.set(F_DATAI, row->get(3)); - msk.set(F_TOTDOCI, row->get(4)); - TString protocollo; protocollo << TDate(row->get(2)).year() << "-" << row->get(9) << "/" << row->get(10); - msk.set(F_PROTFPPROI, protocollo); - msk.set(F_FPPROKEYSI, row->get(11)); + //TProtocollo protocollo(TDate(row->get(2)).year(), row->get(9), row->get(10)); + app()._pro_mask->set_doc(row->get(5), row->get(3), row->get(4), "", row->get(11)); loaded = true; ok = true; break; @@ -3997,21 +4004,6 @@ bool TPro_msk::date_handler(TMask_field& f, KEY k) return ok; } -bool TPro_msk::check_causale(const TString& cod_caus) -{ - bool nc = false; - bool nc_acq = false; - bool fa = false; - TCausale caus(cod_caus); - - if ((nc = caus.tipo_doc() == "NC")) - nc_acq = caus.reg().tipo() == TIPO_REG_ACQ; - - fa = caus.tipo_doc() == "FA"; - - return fa || nc && nc_acq; -} - void TPro_msk::fppro_selfatt() const { const TMask& mask = *this; @@ -4059,6 +4051,15 @@ bool TPro_msk::on_field_event(TOperable_field& o, TField_event e, long jolly) return true; } +void TPro_msk::set_doc(const char* numero, const char* datadoc, const char* totdoc, const char* protfppro, const char* fpprokeys) +{ + _numero = numero; + _datadoc = datadoc; + _totdoc = totdoc; + _protfppro.sset(protfppro); + _fpprokeys = fpprokeys; +} + TString& TPro_msk::query_fppro(const TString& keyprginvio, const TString& keyheaderfatt, const TString& keybodyfatt, const TString& where_str) { @@ -4142,7 +4143,7 @@ void TPro_msk::abilita_piva(TMask* msk) } } -TPro_msk::TPro_msk(TMask& cg_msk) : TAutomask("cg2fppro"), _parent_mask(cg_msk) +TPro_msk::TPro_msk(TMask& cg_msk) : TAutomask("cg2fppro") { TMask::set_handler(DLG_CONFIG, fppro_handler); TMask::set_handler(DLG_LINK, fppro_ok_handler); diff --git a/src/cg/cg2102.h b/src/cg/cg2102.h index 598f032fb..d4539eaa5 100755 --- a/src/cg/cg2102.h +++ b/src/cg/cg2102.h @@ -34,8 +34,10 @@ #endif #include +#include "../f1/f1lib.h" -#define TIPO_REG_ACQ 2 +#define TIPO_REG_ACQ 2 +#define K_ELIMMAS 0 // Key per eliminazione massima class TPro_msk; class TDati_mov_auto; @@ -96,6 +98,8 @@ class TPrimanota_application : public TRelation_application TAssoc_array _colori; // Colori delle righe bool _isfp; + shared_ptr _pro_mask; + friend class TPro_msk; static bool showpartite_handler(TMask_field& f, KEY k); static bool speserimb_handler(TMask_field& f, KEY k); @@ -180,6 +184,7 @@ class TPrimanota_application : public TRelation_application // Handlers per aggancio FPPRO // Bottone per maschera FPPRO static bool fppro_mask(TMask_field& f, KEY key); + static bool is_collegato(TMask_field& f); static void fppromask_set_handl(TMask* msk); static void load_list(TMask* msk, KEY k); @@ -204,7 +209,7 @@ protected: // TApplication bool save_dbmov() const; // Pulisce il mov e db dai firerimenti FPPRO (in MODE_MOD per edit/delete) void clean_fppro(); - bool is_fp(TMask* m); + bool has_f1_db(TMask* m); virtual bool save(bool check_dirty); bool get_mask_swap_file(TFilename& name) const; @@ -376,7 +381,12 @@ public: class TPro_msk : public TAutomask { - TMask& _parent_mask; + TString _numero; + TDate _datadoc; + real _totdoc; + TProtocollo _protfppro; + TString _fpprokeys; + // Handlers per aggancio FPPRO // Bottone carica documenti in maschera FPPRO static bool fppro_handler(TMask_field& f, KEY k); @@ -388,6 +398,15 @@ class TPro_msk : public TAutomask void fppro_selfatt() const; bool on_field_event(TOperable_field& o, TField_event e, long jolly) override; public: + + void set_doc(const char* numero, const char* datadoc, const char* totdoc, const char* protfppro, const char* fpprokeys); + + TString get_numdoc() const { return _numero; } + TDate get_datadoc() const { return _datadoc; } + real get_totdoc() const { return _totdoc; } + TProtocollo& get_protocollo() { return _protfppro; } + TString get_fpprokeys() const { return _fpprokeys; } + static TString& query_fppro(const TString& keyprginvio, const TString& keyheaderfatt, const TString& keybodyfatt, const TString& where_str); static TString& query_fppro(const TString& codforn, const TString& date); static TString& query_fppro(const TString& stato_piva, const TString& piva, const TString& date); @@ -396,7 +415,6 @@ public: //bool is_fp(); // Carica documenti FPPRO sulla maschera static bool load_fppro_mask(TMask* msk, KEY k = 32); - static bool check_causale(const TString& cod_caus); TPro_msk() = delete; TPro_msk(TMask& cg_msk); }; diff --git a/src/f1/f1lib.cpp b/src/f1/f1lib.cpp new file mode 100644 index 000000000..ab26cb2a9 --- /dev/null +++ b/src/f1/f1lib.cpp @@ -0,0 +1,180 @@ +#include "f1lib.h" +#include "config.h" +#include "modaut.h" +#include "cg2103.h" +#include "cg2102.h" +#include "execp.h" +#include "cfven.h" +#include "../fp/fp0400a.h" +#include "reputils.h" + +TString& TProtocollo::prot_in(const int year, const char* tipoprot, const char* progres) +{ + static TString protocollo; + TString tipo(tipoprot); + if (tipo.empty()) + tipo << "no_prot"; + protocollo.cut(0) << year << "-" << tipo << "/" << progres; + return protocollo; +} + +void TProtocollo::set(const TProtocollo prot) +{ + _year = prot._year; + _tipoprot = prot._tipoprot; + _progres = prot._progres; +} + +void TProtocollo::sset(const char* prot) +{ + TToken_string tok(prot, '-'); + _year = tok.get_int(); + TToken_string p(tok.get(), '/'); + _tipoprot = p.get(); + _progres = p.get(); +} + +TString& TProtocollo::get_prot() const +{ + return prot_in(_year, _tipoprot, _progres); +} + +void set_ini_codcaus(const TString& codcaus, const bool nc) +{ + ini_set_string(FILE_CONFIG, FILE_SECTION, nc? F1_CAUSNC : F1_CAUSFA, codcaus); +} + +const char* get_ini_codcaus(const bool nc) +{ + return ini_get_string(FILE_CONFIG, FILE_SECTION, nc ? F1_CAUSNC : F1_CAUSFA); +} + +const char* get_codcaus(const char * tipodoc, const char* codcf) +{ + TLocalisamfile cfven(LF_CFVEN); + cfven.put(CFV_TIPOCF, "F"); + cfven.put(CFV_CODCF, codcf); + const char* codcaus = ""; + const char* codcausnc = ""; + 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; + } + else + { + if (!TString(codcaus).empty()) + return codcaus; + } + return get_ini_codcaus(nc); +} + +bool get_endatareg() +{ + return ini_get_bool(FILE_CONFIG, FILE_SECTION, "endatareg"); +} + +TString get_datainireg() +{ + return ini_get_string(FILE_CONFIG, FILE_SECTION, "datainireg"); +} + +TString get_dataendreg() +{ + return ini_get_string(FILE_CONFIG, FILE_SECTION, "dataendreg"); +} + +void set_endatareg(bool enable) +{ + ini_set_bool(FILE_CONFIG, FILE_SECTION, "endatareg", enable); +} + +void set_datainireg(const TString& date) +{ + ini_set_string(FILE_CONFIG, FILE_SECTION, "datainireg", date); +} + +void set_dataendreg(const TString& date) +{ + ini_set_string(FILE_CONFIG, FILE_SECTION, "dataendreg", date); +} + +bool check_causale(const TString& cod_caus) +{ + return check_causale(cod_caus, "FA") || check_causale(cod_caus, "NC"); +} + +bool check_causale(const TString& cod_caus, const TString& tipo_doc) +{ + TCausale caus(cod_caus); + + if(tipo_doc == "FA") + return caus.tipo_doc() == "FA"; + + if (tipo_doc == "NC") + { + bool nc; + bool nc_acq = false; + if ((nc = caus.tipo_doc() == "NC")) + nc_acq = caus.reg().tipo() == iva_acquisti; + return nc && nc_acq; + } + return false; +} + +void run_cont_ini() +{ + static TString run_string; +#ifdef DBG + run_string.cut(0) << "cg2 -0 -i" << F1_INIREGCONT << "*" << ".ini" << " /u" << user(); +#else + run_string.cut(0) << "cg2 -0 -i" << TFilename().tempdir() << "\\" << F1_INIREGCONT << "*" << ".ini" << " /u" << user(); +#endif + TExternal_app(run_string).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); + if (severity == LOG_MSG) + txt << "[message] : "; + else if(severity == LOG_WARN) + txt << "[warning] : "; + else if (severity == LOG_ERR) + txt << "[error] : "; + txt << 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 = NULL; + } + return true; +} \ No newline at end of file diff --git a/src/f1/f1lib.h b/src/f1/f1lib.h new file mode 100644 index 000000000..dd522c63a --- /dev/null +++ b/src/f1/f1lib.h @@ -0,0 +1,73 @@ +#ifndef _F1LIBH_ +#define _F1LIBH_ + +#include "strings.h" +#include "config.h" +#include "report.h" +#include "reputils.h" + +#define FILE_CONFIG CONFIG_DITTA +#define FILE_SECTION "f1" +#define F1_CAUSFA "causfa" +#define F1_CAUSNC "causnc" +#define F1_INIREGCONT "cg2CONTAB" +#define LOG_MSG 0 +#define LOG_WARN 1 +#define LOG_ERR 2 + +enum err_cont +{ + no_codcaus = -1, + no_selected = -2, + is_already_cont = -3, + is_ready = 0 +}; + +class TProtocollo : TObject +{ + int _year{}; + TString _tipoprot; + TString _progres; + +public: + TProtocollo() = default; + TProtocollo(const int year, const char* tipoprot, const char* progres): _year(year), _tipoprot(tipoprot), _progres(progres) { } + + void set(TProtocollo prot); + void sset(const char* prot); + TString& get_prot() const; + int get_year() const { return _year; } + TString& get_tipoprot() { return _tipoprot; } + TString& get_progres() { return _progres; } + + static TString& prot_in(int year, const char* tipoprot, const char* progres); + + operator const char*() const { return static_cast(get_prot()); } + +}; + +class TF1_log : TObject +{ + TLog_report* _log; +public: + TF1_log() : _log(nullptr){} + void log(int severity, const char* msg); + bool show_log(); +}; + +void set_ini_codcaus(const TString& codcaus, bool nc = false); +const char* get_ini_codcaus(bool nc = false); +const char* get_codcaus(const char * tipodoc, const char* codcf); +bool get_endatareg(); +TString get_datainireg(); +TString get_dataendreg(); +void set_endatareg(bool enable); +void set_datainireg(const TString& date); +void set_dataendreg(const TString& date); +// Controlla se il "cod_caus" e' per Fatture d'acquisto o Note Credito d'Acquisto +bool check_causale(const TString& cod_caus); +// 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); +void run_cont_ini(); + +#endif \ No newline at end of file diff --git a/src/fp/fp0400.cpp b/src/fp/fp0400.cpp index d0c2bffb8..f77b2a55c 100644 --- a/src/fp/fp0400.cpp +++ b/src/fp/fp0400.cpp @@ -1,18 +1,19 @@ -///////////////////////////////////////////////////////////////////////////////////// -// TPassive_mask -///////////////////////////////////////////////////////////////////////////////////// - #include "defmask.h" #include "automask.h" #include "applicat.h" -#include #include "tsdb.h" #include "fp0400a.h" #include "fplib.h" -#include "sheet.h" #include "execp.h" #include "dongle.h" #include +#include "../f1/f1lib.h" +#include "mov.h" + +#define FILTER_NOASS "" +#define FILTER_ASS "E" +#define FILTER_ALL "A" +#define FILTER_CONT "C" enum { @@ -26,11 +27,18 @@ enum }; enum { filtri = 0, elenco_fe = 1, elenco_err = 2 }; // Enum per bottoni toolbar (numero pagina in cui mi trovo) +///////////////////////////////////////////////////////////////////////////////////// +// TPassive_mask +///////////////////////////////////////////////////////////////////////////////////// + class TPassive_mask : public TAutomask { + TLog_report* _log; + bool _f1; + protected: bool _filter_changed; - TFilename tmp_dir; + TFilename _tmp_dir; struct TForn_err { int forn_code; @@ -43,17 +51,29 @@ protected: void select_all(int sheet_field); // Tasto nuovo: apre nuovo fornitore valorizzando già i dati dalla fattura - void new_forn(); + void new_forn(); // Tasto aggiorna: aggiorna cliente che non corrisponde. - void aggiorna_forn(); - void salva_for() const; - void clean_cg0(const TString& filename) const; - void run_cg0(const TString& filename) const; + void aggiorna_forn(); + void salva_for() const; + void clean_ini(const TString& filename) const; + void run_cg0(const TString& filename) const; + void elenco_prots_sel(TString& string) const; + // Gestione F1 + int prepara_contab() const; + void log_contab(); + void contabilizza(); + TDate load_data() const; + // Handlers + static bool causfa_handler(TMask_field& f, KEY k); + static bool causnc_handler(TMask_field& f, KEY k); + + void fattsel(int dlg, TField_event& e); bool on_field_event(TOperable_field& o, TField_event e, long jolly) override; + void check_buttons(int p); void next_page(int p) override; // Elenco dei protocolli selezionati - void elenco_prots_sel(TString& string) const; + void fill(); static int find_fornitore(TLocalisamfile& clifo); static void add_row_err_forn(int forn_code, TSheet_field& sf_err, TString& denom); @@ -61,16 +81,11 @@ protected: // Aggiunge i protocolli che sono già presenti per le fatture nel db alla tabellina per il filtro void aggiungi_prot() const; void init(); - void load_all_fields(); public: - void save_all_fields() const; + TString& get_fattsel() const; - TPassive_mask() : TAutomask("fp0400a"), _filter_changed(true) - { - tmp_dir = tmp_dir.tempdir(); - load_all_fields(); - } + TPassive_mask(bool f1); }; void TPassive_mask::set_filter_changed() @@ -80,7 +95,8 @@ void TPassive_mask::set_filter_changed() void TPassive_mask::next_page(int p) { - //if(true) + check_buttons(p); + if (_filter_changed && p != 1000) { fill(); @@ -97,10 +113,24 @@ void TPassive_mask::fill() TString prots_query; TLocalisamfile clifo(LF_CLIFO); - const TDate dal = get(F_DATAINI); - const TDate al = get(F_DATAEND); - const TString& ordin = get(F_FATTORD); - const TString& verso_ord = get(F_VERSOORD); + TDate dal; + TDate al; + const TString& filter_elab = get_fattsel(); + const TDate reg_dal(get(F_DATAINI)); + const TDate reg_al(get(F_DATAEND)); + const TString& ordin = get(F_FATTORD); + const TString& verso_ord = get(F_VERSOORD); + + if(get_fattsel() == FILTER_CONT) + { + dal = "20010101"; + al = TDate(TODAY); + } + else + { + dal = get(F_DATAINI); + al = get(F_DATAEND); + } sf.hide(); sf.destroy(); @@ -171,15 +201,19 @@ void TPassive_mask::aggiungi_riga(TLocalisamfile& clifo, TSheet_field& sf, TShee const TString& paa_piva = fp_db().sq_get("P_IVA"); const TString& paa_codpaese = fp_db().sq_get("COD_PAESE"); const TString& paa_codsdi = fp_db().sq_get("COD_SDI"); - const TString& prot = fp_db().sq_get("TIPO_PROT"); const TDate& dataregcont = fp_db().sq_get_date("DATAREGCONT"); - const TString& filter_elab = get(F_FATTSEL); + const TString& filter_elab = get_fattsel(); + const bool is_contab = dataregcont != TDate("20010101"); clifo.zero(); clifo.put(CLI_TIPOCF, 'F'); const int forn_code = find_fornitore(clifo); - if( filter_elab.blank() && forn_code != 0 || filter_elab == "E" && forn_code == 0 || filter_elab == "A") + const bool data_range = dataregcont >= TDate(get(F_DATAINIREG)) && dataregcont <= TDate(get(F_DATAENDREG)); + if( filter_elab.blank() && forn_code != 0 // Filtro sui non associati + || filter_elab == FILTER_ASS && forn_code == 0 && !is_contab // Filtro sui associati e non contab. + || filter_elab == FILTER_CONT && forn_code == 0 && is_contab && data_range // Filtro solo contabilizzati e data + || filter_elab == FILTER_ALL) // Tutte { TToken_string& row = sf.row(-1); if (denom.blank()) { @@ -228,7 +262,7 @@ void TPassive_mask::aggiungi_riga(TLocalisamfile& clifo, TSheet_field& sf, TShee row.add(fp_db().sq_get("ATTACHMENT") != "0" ? "" : "X"); row.add(paa_codsdi.blank() ? fp_db().sq_get("PEC") : paa_codsdi); row.add(denom); - row.add(fp_db().sq_get("ANNO_PROT") << (prot.empty() ? "" : "-") << prot << "/" << fp_db().sq_get("NUM_PROT") << (prot.empty() ? " (no prot.)" : "")); + row.add(TProtocollo(fp_db().sq_get_int("ANNO_PROT"), fp_db().sq_get("TIPO_PROT"), fp_db().sq_get("NUM_PROT"))); TString key_prot; key_prot << fp_db().sq_get("KEYPROG") << ";" << fp_db().sq_get("KEYHEAD") << ";" << fp_db().sq_get("KEYFATT"); row.add(key_prot); } @@ -283,13 +317,28 @@ void TPassive_mask::add_row_err_forn(const int forn_code, TSheet_field& sf_err, } } +TString& TPassive_mask::get_fattsel() const +{ + static TString fattsel; + fattsel.cut(0); + if (get_bool(F_FORNOTASS)) + return fattsel; + if (get_bool(F_FORASS)) + return fattsel << FILTER_ASS; + if (get_bool(F_FORALL)) + return fattsel << FILTER_ALL; + if (get_bool(F_CONTABIL)) + return fattsel << FILTER_CONT; + return fattsel; +} + int TPassive_mask::find_fornitore(TLocalisamfile& clifo) { - TString paa_codfisc = fp_db().sq_get("COD_FISC"); - const TString paa_piva = fp_db().sq_get("P_IVA"); - TString paa_codpaese = fp_db().sq_get("COD_PAESE"); - const TString fppro_tipocf = fp_db().sq_get("TIPO_CF"); - TString fppro_codcf = fp_db().sq_get("COD_CLIFOR"); + TString paa_codfisc = fp_db().sq_get("COD_FISC"); + const TString paa_piva = fp_db().sq_get("P_IVA"); + TString paa_codpaese = fp_db().sq_get("COD_PAESE"); + const TString fppro_tipocf = fp_db().sq_get("TIPO_CF"); + TString fppro_codcf = fp_db().sq_get("COD_CLIFOR"); // Cerco se il fornitore è presente in Campo int found_clifo = -1; @@ -338,6 +387,23 @@ int TPassive_mask::find_fornitore(TLocalisamfile& clifo) clifo.put(CLI_COFI, paa_codfisc); clifo.read() == NOERR ? found_clifo = 4 : found_clifo = -14; // Se il cod fisc corrisponde setto a 2 } + + // Se lo trovo controllo che non abbia il flag di sospeso se no ricerco ancora + bool noerr = true; + if (found_clifo == 2) + { + while (clifo.get_bool(CLI_SOSPESO) && noerr && clifo.get(CLI_PAIV) == paa_piva) + noerr = clifo.next() == NOERR; + if (clifo.get_bool(CLI_SOSPESO) || !noerr || clifo.get(CLI_PAIV) != paa_piva) + found_clifo = -5; + } + else if (found_clifo == 4) + { + while (clifo.get_bool(CLI_SOSPESO) && noerr && clifo.get(CLI_COFI) == paa_codfisc) + noerr = clifo.next() == NOERR; + if (clifo.get_bool(CLI_SOSPESO) || !noerr || clifo.get(CLI_COFI) != paa_codfisc) + found_clifo = -14; + } return found_clifo; } @@ -347,11 +413,45 @@ void TPassive_mask::init() aggiungi_prot(); } -void TPassive_mask::load_all_fields() +bool TPassive_mask::causfa_handler(TMask_field& f, KEY k) { + if (k == K_TAB && f.focusdirty()) + { + TMask& msk = f.mask(); + const TString& codcaus = msk.get(F_CAUSFA); + if (!check_causale(codcaus, "FA")) + { + warning_box("Impossibile selezionare questa causale registrazione.\nPrego inserire una causale di Fattura Acquisti"); + msk.field(F_CAUSFA).set(""); + msk.field(F_DESCAUSFA).set(""); + set_ini_codcaus(""); + return false; + } + set_ini_codcaus(codcaus); + } + return true; } -void TPassive_mask::select_all(int sheet_field) +bool TPassive_mask::causnc_handler(TMask_field& f, KEY k) +{ + if (k == K_TAB && f.focusdirty()) + { + TMask& msk = f.mask(); + const TString& codcaus = msk.get(F_CAUSNC); + if (!check_causale(codcaus, "NC")) + { + warning_box("Impossibile selezionare questa causale registrazione.\nPrego inserire una causale di Nota Credito Acquisti."); + msk.field(F_CAUSNC).set(""); + msk.field(F_DESCAUSNC).set(""); + set_ini_codcaus("", true); + return false; + } + set_ini_codcaus(codcaus, true); + } + return true; +} + +void TPassive_mask::select_all(const int sheet_field) { TSheet_field& docs = sfield(sheet_field); TString_array& sht = docs.rows_array(); @@ -370,7 +470,6 @@ void TPassive_mask::salva_for() const { if(fp_db().sq_is_connect()) { - TString q_update; // Query per update TSheet_field& sf = sfield(F_DOCS); TLocalisamfile clifo(LF_CLIFO); // Leggo in Campo per controllare che il codice cliente non sia errato @@ -379,7 +478,7 @@ void TPassive_mask::salva_for() const if (row->starts_with("X") && strcmp(clifo.get(CLI_CODCF), "17") == 0) bool simo = true; TString cod_forn = row->get(sf.cid2index(S_FORNITORE)); - if(row->starts_with("X") && cod_forn != "") + if(row->starts_with("X") && !cod_forn.empty()) { clifo.zero(); clifo.setkey(1); @@ -387,11 +486,11 @@ void TPassive_mask::salva_for() const clifo.put(CLI_CODCF, cod_forn); if(clifo.read() == NOERR) { - q_update = ""; + TString q_update = ""; TToken_string key(row->get(sf.cid2index(S_PROKEY)), ';'); - TString clifo_cofi = clifo.get(CLI_COFI); - TString clifo_paiv = clifo.get(CLI_PAIV); - if (clifo_cofi != "" && strcmp(row->get(sf.cid2index(S_CODFISC)), clifo_cofi) == 0 || clifo_paiv != "" && strcmp(row->get(sf.cid2index(S_PARIVA)), clifo_paiv) == 0) + const TString& clifo_cofi = clifo.get(CLI_COFI); + const TString& clifo_paiv = clifo.get(CLI_PAIV); + if (!clifo_cofi.empty() && strcmp(row->get(sf.cid2index(S_CODFISC)), clifo_cofi) == 0 || !clifo_paiv.empty() && strcmp(row->get(sf.cid2index(S_PARIVA)), clifo_paiv) == 0) { q_update << "UPDATE FPPRO00F SET PZ_TIPOCF = 'F', PZ_CLIFOR = '" << row->get(sf.cid2index(S_FORNITORE)) << "' WHERE PZ_KEYPRGINVIO = '" << key.get(0) << "' AND PZ_KEYHEADERFATT = '" << key.get(1) << "' AND PZ_KEYBODYFATT = '" << key.get(2) << "'"; fp_db().sq_set_exec(q_update, false); @@ -407,25 +506,188 @@ void TPassive_mask::salva_for() const } } -void TPassive_mask::clean_cg0(const TString& filename) const +void TPassive_mask::clean_ini(const TString& filename) const { static TString remove_string; - remove_string.cut(0) << tmp_dir << "\\" << filename << "*.*"; +#ifdef DBG + remove_string.cut(0) << filename << "*.ini"; +#else + remove_string.cut(0) << _tmp_dir << "\\" << filename << "*.*"; +#endif remove_files(remove_string, false); } void TPassive_mask::run_cg0(const TString& filename) const { static TString run_string; - run_string.cut(0) << "cg0 -1 -i" << tmp_dir << "\\" << filename << "*" << ".ini" << " /u" << user(); + run_string.cut(0) << "cg0 -1 -i" << _tmp_dir << "\\" << filename << "*" << ".ini" << " /u" << user(); TExternal_app(run_string).run(); } +int TPassive_mask::prepara_contab() const +{ + int n_sel = 0; + TSheet_field& sf = sfield(F_DOCS); + sf.hide(); + + clean_ini(F1_INIREGCONT); + + FOR_EACH_SHEET_ROW(sf, n, row) { + if (row->starts_with("X")) + { + if(!TString(row->get(sf.cid2index(S_NUMREGCONT))).empty()) + return n+1000; + TString codcaus(get_codcaus(row->get(2), row->get(10))); + if (codcaus.empty()) + return no_codcaus; + + n_sel++; + TString num; num.format("%04d", n); + TFilename newf_ini; +#ifndef DBG + newf_ini.tempdir() << "\\" << F1_INIREGCONT << num << ".ini"; +#else + newf_ini << F1_INIREGCONT << num << ".ini"; +#endif + TConfig contab_ini(newf_ini, "Transaction"); + + contab_ini.set("Action", "INSERT"); + + contab_ini.set_paragraph(LF_MOV); // [23] + contab_ini.set("CODCAUS", codcaus); + contab_ini.set("CODCF", row->get(sf.cid2index(S_FORNITORE))); + contab_ini.set("DATACOMP", TDate(TODAY)); + contab_ini.set("DATADOC", row->get(sf.cid2index(S_DATADOC))); + contab_ini.set("NUMDOCEXT", row->get(sf.cid2index(S_NDOC))); + contab_ini.set("NUMDOC", TString(row->get(sf.cid2index(S_NDOC))).right(7)); + contab_ini.set("TOTDOC", abs(real(row->get(sf.cid2index(S_TOTDOC)))).string()); + contab_ini.set("KEYFPPRO", row->get(sf.cid2index(S_PROKEY))); + + row->add("", 0); + } + } + + sf.force_update(); + sf.show(); + + if (n_sel == 0) + return no_selected; + + return is_ready; +} + +void TPassive_mask::log_contab() +{ + TFilename cg_ini; + TString msg; + TF1_log log; + std::vector doc_saved, doc_canceled; + FOR_EACH_SHEET_ROW(sfield(F_DOCS), n, row) + { + TString num; num.format("%04d", n); +#ifdef DBG + cg_ini = TString(F1_INIREGCONT) << num << ".ini"; +#else + cg_ini = TFilename().tempdir() << "\\" << TString(F1_INIREGCONT) << num << ".ini"; +#endif + if(cg_ini.exist()) + { + TConfig config(cg_ini, "Transaction"); + TString numdoc; + if (config.get("Result") == "OK") + { + numdoc = config.get("NUMDOC", "23"); + doc_saved.insert(doc_saved.end(), numdoc); + } + else if(config.get("Result") == "CANCEL") + { + numdoc = config.get("NUMDOC", "23"); + doc_canceled.insert(doc_canceled.end(), numdoc); + } + } + } + const int elem_save = doc_saved.size(); + const int elem_canc = doc_canceled.size(); + if (elem_save > 0) + { + if (elem_save == 1) + msg << "Il documento n. '" << doc_saved[0] << "' e' stata registrato."; + else + msg << "Sono stati registrati " << elem_save << " documenti."; + if (elem_save > 1) + for (int i = 0; i < elem_save; i++) + msg << "\n - Documento n. '" << doc_saved[i] << "'"; + log.log(LOG_MSG, msg); + } + if (elem_canc > 0) + { + msg.cut(0); + if (elem_canc == 1) + msg << "La registrazione del documento n. '" << doc_canceled[0] << "' e' stata annullata."; + else + msg << "Sono state annullate " << elem_canc << " registrazioni."; + if (elem_canc > 1) + for (int i = 0; i < elem_canc; i++) + msg << "\n - Documento n. '" << doc_canceled[i] << "'"; + log.log(LOG_WARN, msg); + } + if (elem_save > 0 || elem_canc > 0) + log.show_log(); +} + +void TPassive_mask::contabilizza() +{ + const int stato = prepara_contab(); + + switch(stato) + { + case is_ready: + run_cont_ini(); // Eseguo gli ini + log_contab(); // Mostro stato contabilizzate/annullate + clean_ini(F1_INIREGCONT); + fill(); // Ricarico sheet per togliere quelli contabilizzati + break; + case no_codcaus: + message_box("Attenzione, il fornitore non ha associato nessun codice causale predefinito.\nPrego selezionare un codice causale per la contabilizzazione."); + next_page(1000); + break; + case no_selected: + message_box("Selezionare almeno un documento."); + break; + default: break; + } + if(stato >= 1000) + { + TSheet_field& sf = sfield(F_DOCS); + TToken_string& row = sf.row(stato - 1000); + + const TString ndoc = row.get_int(sf.cid2index(S_NDOC)); + const TDate datadoc = row.get(sf.cid2index(S_DATADOC)); + const int nreg = row.get_int(sf.cid2index(S_NUMREGCONT)); + + TString msg; + msg << "Attenzione il doc " << ndoc << " del " << datadoc << " e' gia' stato registrato con numero reg. " << nreg; + warning_box(msg); + fill(); + } +} + +TDate TPassive_mask::load_data() const +{ + TString date; date << ini_get_string(CONFIG_DITTA, "fp", "dataini_fp04"); + TDate start_date(TODAY); + if(!date.empty()) + start_date = date; + else + start_date.set_day(1); + return start_date; +} + void TPassive_mask::new_forn() { TSheet_field& sf = sfield(F_ERR); static const TString newf = "fpnewf"; - clean_cg0(newf); + clean_ini(newf); FOR_EACH_SHEET_ROW(sf, nr, row) { const TString denom = row->get(sf.cid2index(S_RAGSERR)); @@ -478,7 +740,7 @@ void TPassive_mask::aggiorna_forn() { TSheet_field& sf = sfield(F_ERR); static const TString newf = "fpaggf"; - clean_cg0(newf); + clean_ini(newf); FOR_EACH_SHEET_ROW(sf, nr, row) { const TString denom = row->get(sf.cid2index(S_RAGSERR)); @@ -526,6 +788,28 @@ void TPassive_mask::aggiorna_forn() } +void TPassive_mask::fattsel(const int dlg, TField_event& e) +{ + if (e == fe_init) + { + set(F_FORNOTASS, "X"); + set(F_FORASS, ""); + set(F_FORALL, ""); + set(F_CONTABIL, ""); + } + else + { + set(F_FORNOTASS, dlg == F_FORNOTASS ? "X" : ""); + set(F_FORASS, dlg == F_FORASS ? "X" : ""); + set(F_FORALL, dlg == F_FORALL ? "X" : ""); + set(F_CONTABIL, dlg == F_CONTABIL ? "X" : ""); + } + field(F_DATAINI).enable(!get_bool(F_CONTABIL)); + field(F_DATAEND).enable(!get_bool(F_CONTABIL)); + field(F_DATAINIREG).enable(get_bool(F_CONTABIL)); + field(F_DATAENDREG).enable(get_bool(F_CONTABIL)); +} + bool TPassive_mask::on_field_event(TOperable_field& o, TField_event e, long jolly) { switch (o.dlg()) @@ -538,6 +822,20 @@ bool TPassive_mask::on_field_event(TOperable_field& o, TField_event e, long joll if(e == fe_init) init(); break; + case F_DOCS: + if (e == se_query_modify) + break; + case DLG_USER: + if (e == fe_button && jolly > 0 && get_fattsel() == FILTER_CONT) + { + TSheet_field& sf = sfield(F_DOCS); + TToken_string& row = sf.row(sf.selected()); + TRectype mov(LF_MOV); + mov.put(MOV_NUMREG, row.get(sf.cid2index(S_NUMREGCONT))); + if (mov.edit()) + fill(); + } + break; case DLG_ALL: if (e == fe_button) switch (curr_page()) @@ -570,15 +868,13 @@ bool TPassive_mask::on_field_event(TOperable_field& o, TField_event e, long joll if (curr_page() == elenco_err) aggiorna_forn(); break; + case DLG_EXPORT: + if (e == fe_button && curr_page() == elenco_fe) + contabilizza(); + break; case F_DATAINI: - if (e == fe_init) - { - TDate inizio_mese = TDate(TODAY); inizio_mese.set_day(1); - o.set(inizio_mese); - //o.set(ini_get_string(CONFIG_DITTA, "fp", "LastXML", "01-01-2019")); - } - //else if (e == fe_close) - // ini_set_string(CONFIG_DITTA, "fp", "LastXML", o.get()); + if (e == fe_init) + o.set(load_data()); break; case F_DATAEND: if (e == fe_init) @@ -586,6 +882,9 @@ bool TPassive_mask::on_field_event(TOperable_field& o, TField_event e, long joll break; default: break; } + if (o.dlg() >= F_FORNOTASS && o.dlg() <= F_CONTABIL) + if (e == fe_modify || e == fe_init) + fattsel(o.dlg(), e); if ((e == fe_modify || e >= se_enter) && jolly == 0) if (o.dlg() >= START_MASK && o.dlg() <= END_MASK || o.dlg() == F_PROT) set_filter_changed(); @@ -593,6 +892,32 @@ bool TPassive_mask::on_field_event(TOperable_field& o, TField_event e, long joll return true; } +void TPassive_mask::check_buttons(const int p) +{ + const TString& fattsel = get_fattsel(); + const bool err_forn = fattsel.empty() || fattsel == FILTER_ALL; + + field(DLG_EXPORT).enable((curr_page() + p == 1 || p == 1001) && _f1 && fattsel != FILTER_CONT); + field(DLG_SAVEREC).enable((curr_page() + p == 1 || p == 1001) && (fattsel.empty() || fattsel == FILTER_ASS)); + if (p >= 1000) + { + field(DLG_NEWREC).enable(p == 1002 && err_forn); + field(DLG_RECALC).enable(p == 1002 && err_forn); + } + else + { + field(DLG_NEWREC).enable((curr_page() + p == 2 || curr_page() + p == 3) && err_forn); + field(DLG_RECALC).enable((curr_page() + p == 2 || curr_page() + p == 3) && err_forn); + } +} + +TPassive_mask::TPassive_mask(bool f1) : TAutomask("fp0400a"), _f1(f1), _filter_changed(true) +{ + _tmp_dir = _tmp_dir.tempdir(); + TMask::set_handler(F_CAUSFA, causfa_handler); + TMask::set_handler(F_CAUSNC, causnc_handler); +} + ///////////////////////////////////////////////////////////////////////////////////// // TPassive_app @@ -600,18 +925,63 @@ bool TPassive_mask::on_field_event(TOperable_field& o, TField_event e, long joll class TPassive_app : public TSkeleton_application { + void load_mask(const TPassive_mask& mask) const; + bool check_f1() const; + void save_field(const TPassive_mask& mask); + public: void main_loop() override; TPassive_app() = default; }; +void TPassive_app::load_mask(const TPassive_mask& mask) const +{ + if (check_f1()) + { + mask.field(F_CAUSFA).set(get_ini_codcaus()); + mask.field(F_CAUSNC).set(get_ini_codcaus(true)); + mask.field(F_DATAINIREG).enable(mask.get_fattsel() == FILTER_CONT); + mask.field(F_DATAINIREG).set(get_datainireg()); + if(mask.field(F_DATAINIREG).get().empty()) + { + TDate start(TODAY); + start.set_day(1); + mask.field(F_DATAINIREG).set(start); + } + mask.field(F_DATAENDREG).enable(mask.get_fattsel() == FILTER_CONT); + mask.field(F_DATAENDREG).set(TDate(TODAY)); + } + else + { + mask.field(F_GROUPCON).hide(); + mask.field(F_GROUPCAU).hide(); + } +} + +bool TPassive_app::check_f1() const +{ + return has_module(F1AUT); +} + +void TPassive_app::save_field(const TPassive_mask& mask) +{ + if (check_f1()) + { + set_ini_codcaus(mask.get(F_CAUSFA)); + set_datainireg(mask.get(F_DATAINIREG)); + } + ini_set_string(CONFIG_DITTA, "fp", "dataini_fp04", mask.get(F_DATAINI)); +} + void TPassive_app::main_loop() { - TPassive_mask mask; + TPassive_mask mask(check_f1()); + load_mask(mask); while(mask.run() == K_ENTER) { } + save_field(mask); } int fp0400(int argc, char * argv[]) diff --git a/src/fp/fp0400a.h b/src/fp/fp0400a.h index b6033d319..a1f5de1f0 100644 --- a/src/fp/fp0400a.h +++ b/src/fp/fp0400a.h @@ -1,15 +1,26 @@ #define START_MASK 501 -#define F_DATAINI 501 -#define F_DATAEND 502 -#define F_SAVEFOR 503 -#define F_FATTSEL 504 -#define F_FATTORD 505 -#define F_VERSOORD 506 +#define F_FORNOTASS 501 +#define F_FORASS 502 +#define F_FORALL 503 +#define F_CONTABIL 504 +#define F_DATAINI 505 +#define F_DATAEND 506 +#define F_DATAINIREG 507 +#define F_DATAENDREG 508 +#define F_FATTORD 510 +#define F_VERSOORD 511 +#define F_CAUSFA 512 +#define F_DESCAUSFA 513 +#define F_CAUSNC 514 +#define F_DESCAUSNC 515 +#define F_GROUPCON 516 +#define F_GROUPCAU 517 #define END_MASK 599 #define F_PROT 401 + #define S_SELCODPROT 101 #define S_CODPROT 102 diff --git a/src/fp/fp0400a.uml b/src/fp/fp0400a.uml index b5bfc0412..c13b38b1f 100644 --- a/src/fp/fp0400a.uml +++ b/src/fp/fp0400a.uml @@ -28,38 +28,82 @@ BEGIN PICTURE BMP_RECALC END +BUTTON DLG_EXPORT 10 2 +BEGIN + PROMPT 4 1 "Contabilizzaz." + PICTURE TOOL_EXPORT +END + #include ENDPAGE PAGE "Fatture Passive" 0 2 0 0 +GROUPBOX DLG_NULL 30 7 +BEGIN + PROMPT 0 1 "@BFornitori" +END + +BOOLEAN F_FORNOTASS +BEGIN + PROMPT 1 2 "Non Associati" +END + +BOOLEAN F_FORASS +BEGIN + PROMPT 1 3 "Associati" +END + +BOOLEAN F_FORALL +BEGIN + PROMPT 1 4 "Tutti" +END + DATE F_DATAINI BEGIN - PROMPT 1 1 "Data iniziale" + PROMPT 1 5 "Data iniziale" CHECKTYPE REQUIRED END DATE F_DATAEND BEGIN - PROMPT 50 1 "Data finale " + PROMPT 1 6 "Data finale " VALIDATE DATE_CMP_FUNC >= F_DATAINI WARNING "La data finale non può essere minore della data iniziale" CHECKTYPE REQUIRED END -RADIOBUTTON F_FATTSEL 3 80 +GROUPBOX F_GROUPCON 30 5 BEGIN - PROMPT 1 2 "Fatture da visualizzare" - ITEM "|Non elaborate" - ITEM "E|Elaborate" - ITEM "A|Tutte" - FLAGS "Z" + PROMPT 0 10 "@BContabilita'" +END + +BOOLEAN F_CONTABIL +BEGIN + PROMPT 1 11 "Contabilizzate" + MODULE F1 +END + +DATE F_DATAINIREG +BEGIN + PROMPT 1 12 "Data iniziale" + CHECKTYPE REQUIRED + MODULE F1 +END + +DATE F_DATAENDREG +BEGIN + PROMPT 1 13 "Data finale " + VALIDATE DATE_CMP_FUNC >= F_DATAINIREG + WARNING "La data finale non può essere minore della data iniziale" + CHECKTYPE REQUIRED + MODULE F1 END RADIOBUTTON F_FATTORD 20 20 BEGIN - PROMPT 1 5 "Ordinamento fatture per " + PROMPT 31 1 "Ordinamento fatture per " ITEM "|Data Ricezione" ITEM "D|Data Documento" FLAGS "" @@ -67,19 +111,108 @@ END RADIOBUTTON F_VERSOORD 20 20 BEGIN - PROMPT 25 5 "Ordinamento:" + PROMPT 52 1 "Ordinamento:" ITEM "|Decrescente" ITEM "C|Crescente" FLAGS "" END -SPREADSHEET F_PROT 25 10 +SPREADSHEET F_PROT 25 4 BEGIN - PROMPT 1 10 "Selezionare o aggiungere un filtro sul Tipo Progressivo" + PROMPT 31 5 "Selezionare o aggiungere un filtro sul Tipo Progressivo" ITEM "@1" ITEM "Codice\nProtocol.@12" END +GROUPBOX F_GROUPCAU 59 7 +BEGIN + PROMPT 31 10 "@BSelezionare Causale per Registrazione Contabile:" +END + +STRING F_CAUSFA 3 +BEGIN + PROMPT 32 11 "Causale per Fattura Acquisti (FA) " + FLAGS "UZ" + FIELD CODCAUS + USE LF_CAUSALI + INPUT CODCAUS F_CAUSFA + DISPLAY "Codice" CODCAUS + DISPLAY "Descrizione@50" DESCR + DISPLAY "Tipo" TIPODOC + DISPLAY "Registro" REG + DISPLAY "SC" TIPOMOV + DISPLAY "CA" MOVIND + DISPLAY "CE" COLLCESP + DISPLAY "770" M770 + OUTPUT F_CAUSFA CODCAUS + OUTPUT F_DESCAUSFA DESCR + ADD RUN cg0 -4 + CHECKTYPE NORMAL + WARNING "Causale assente" + MODULE F1 +END + +STRING F_DESCAUSFA 50 +BEGIN + PROMPT 32 12 "" + USE LF_CAUSALI KEY 2 + CHECKTYPE NORMAL + INPUT DESCR F_DESCAUSFA + DISPLAY "Descrizione@50" DESCR + DISPLAY "Codice" CODCAUS + DISPLAY "Tipo" TIPODOC + DISPLAY "Registro" REG + DISPLAY "SC" TIPOMOV + DISPLAY "CA" MOVIND + DISPLAY "CE" COLLCESP + DISPLAY "770" M770 + COPY OUTPUT F_CAUSFA + ADD RUN cg0 -4 + MODULE F1 +END + +STRING F_CAUSNC 3 +BEGIN + PROMPT 32 13 "Causale per Nota Credito Acquisti [TD04]" + FLAGS "UZ" + FIELD CODCAUS + USE LF_CAUSALI + INPUT CODCAUS F_CAUSNC + DISPLAY "Codice" CODCAUS + DISPLAY "Descrizione@50" DESCR + DISPLAY "Tipo" TIPODOC + DISPLAY "Registro" REG + DISPLAY "SC" TIPOMOV + DISPLAY "CA" MOVIND + DISPLAY "CE" COLLCESP + DISPLAY "770" M770 + OUTPUT F_CAUSNC CODCAUS + OUTPUT F_DESCAUSNC DESCR + ADD RUN cg0 -4 + CHECKTYPE NORMAL + WARNING "Causale assente" + MODULE F1 +END + +STRING F_DESCAUSNC 50 +BEGIN + PROMPT 32 14 "" + USE LF_CAUSALI KEY 2 + CHECKTYPE NORMAL + INPUT DESCR F_DESCAUSNC + DISPLAY "Descrizione@50" DESCR + DISPLAY "Codice" CODCAUS + DISPLAY "Tipo" TIPODOC + DISPLAY "Registro" REG + DISPLAY "SC" TIPOMOV + DISPLAY "CA" MOVIND + DISPLAY "CE" COLLCESP + DISPLAY "770" M770 + COPY OUTPUT F_CAUSNC + ADD RUN cg0 -4 + MODULE F1 +END + ENDPAGE PAGE "Elenco Fatture" 0 2 0 0 diff --git a/src/include/utility.cpp b/src/include/utility.cpp index 55c86b33e..215043f7b 100755 --- a/src/include/utility.cpp +++ b/src/include/utility.cpp @@ -615,7 +615,7 @@ static bool is_sirio_station(const char* hostname) "SPOCK", // Alessandro ? "ARCHIMEDE", // Alessandro "SIRIOCOMP", - "NBK_SPALACINO_ACERW10", // Simone + "NBK_SPALACINO_A", // Simone NULL }; for (int i = 0; ranger[i]; i++)