From 3d1e6dbc6488c80e8c16f926b63dcc80bf42550b Mon Sep 17 00:00:00 2001 From: bonazzi Date: Wed, 17 Jan 2018 18:26:53 +0000 Subject: [PATCH] Patch level : 12.0 500 Files correlati : cg1.exe cg1300n.msk cgmenu.men Programma di riallineamento tipo conto cliente/fornitore su causali e movimenti git-svn-id: svn://10.65.10.50/branches/R_10_00@24272 c028cbd2-c16b-5b4b-a496-9718f37d4682 --- src/cg/cg1300n.uml | 6 +- src/cg/cg1314.cpp | 223 ++++++++++++++++++++++++++------------------- src/cg/cg1314.h | 9 +- 3 files changed, 138 insertions(+), 100 deletions(-) diff --git a/src/cg/cg1300n.uml b/src/cg/cg1300n.uml index cfd983856..3f71d6f9c 100644 --- a/src/cg/cg1300n.uml +++ b/src/cg/cg1300n.uml @@ -34,18 +34,18 @@ END STRING F_RAGSOC 50 BEGIN - PROMPT 2 6 "Ragione sociale " + PROMPT 2 4 "Ragione sociale " FLAGS "D" END BOOLEAN F_UPDCAUS BEGIN - PROMPT 2 8 "Aggiorno le causali" + PROMPT 2 6 "Aggiorno le causali" END BOOLEAN F_UPDMOV BEGIN - PROMPT 2 10 "Aggiorno i movimenti" + PROMPT 2 8 "Aggiorno i movimenti" END ENDPAGE diff --git a/src/cg/cg1314.cpp b/src/cg/cg1314.cpp index ce8e0ea70..3cc6699d8 100644 --- a/src/cg/cg1314.cpp +++ b/src/cg/cg1314.cpp @@ -4,6 +4,7 @@ #include #include +#include #include #include #include @@ -12,8 +13,6 @@ #include #include -#include -#include #include "cg1314.h" #include "cg1300n.h" #include "cglib01.h" @@ -25,110 +24,144 @@ bool TAgg_tcontoCF::create() return TSkeleton_application::create(); } +void TAgg_tcontoCF::update_causali(TRectype & pcon, TLog_report & log) +{ + TString use("USE "); use << LF_RCAUSALI; + TISAM_recordset rcaus(use); + TLocalisamfile & frcaus = rcaus.cursor()->relation()->lfile(); + + for (bool ok = rcaus.move_first(); ok; ok = rcaus.move_next()) + { + const int gruppo = rcaus.get(RCA_GRUPPO).as_int(); + const int conto = rcaus.get(RCA_CONTO).as_int(); + const TString4 tipocf = rcaus.get(RCA_TIPOCF).as_string(); + TBill tc(gruppo, conto, 0L); + + tc.read(pcon); + + const TString4 tipocf_pcon = pcon.get(PCN_TMCF); + + if (tipocf != tipocf_pcon) + { + frcaus.put(RCA_TIPOCF, tipocf_pcon); + frcaus.rewrite(); + TString msg("Causale "); + + msg << rcaus.get(RCA_CODCAUS).as_string(); + msg << " Riga " << rcaus.get(RCA_NRIGA).as_int(); + msg << " impostato tipo conto (" << tipocf_pcon << ")"; + log.log(0, msg); + } + } + +} +void TAgg_tcontoCF::update_movimenti(TRectype & pcon, TLog_report & log) +{ + TString use("USE "); use << LF_RMOV; + TISAM_recordset rmov(use); + TLocalisamfile & frmov = rmov.cursor()->relation()->lfile(); + + for (bool ok = rmov.move_first(); ok; ok = rmov.move_next()) + { + const int gruppo = rmov.get(RMV_GRUPPO).as_int(); + const int conto = rmov.get(RMV_CONTO).as_int(); + const TString4 tipocf = rmov.get(RMV_TIPOC).as_string(); + TBill tc(gruppo, conto, 0L); + + tc.read(pcon); + + const TString4 tipocf_pcon = pcon.get(PCN_TMCF); + + if (tipocf != tipocf_pcon) + { + frmov.put(RMV_TIPOC, tipocf_pcon); + frmov.rewrite(); + TString msg("Movimento "); + + msg << rmov.get(RMV_NUMREG).as_int(); + msg << " Riga " << rmov.get(RMV_NUMRIG).as_int(); + msg << " impostato tipo conto (" << tipocf_pcon << ")"; + log.log(0, msg); + } + } +} + +void TAgg_tcontoCF::update_movimenti_IVA(TRectype & pcon, TLog_report & log) +{ + TString use("USE "); use << LF_RMOVIVA; + TISAM_recordset rmoviva(use); + TLocalisamfile & frmoviva = rmoviva.cursor()->relation()->lfile(); + + for (bool ok = rmoviva.move_first(); ok; ok = rmoviva.move_next()) + { + const int gruppo = rmoviva.get(RMI_GRUPPO).as_int(); + const int conto = rmoviva.get(RMI_CONTO).as_int(); + const TString4 tipocf = rmoviva.get(RMI_TIPOC).as_string(); + TBill tc(gruppo, conto, 0L); + + tc.read(pcon); + + const TString4 tipocf_pcon = pcon.get(PCN_TMCF); + + if (tipocf != tipocf_pcon) + { + frmoviva.put(RMI_TIPOC, tipocf_pcon); + frmoviva.rewrite(); + TString msg("Movimento "); + + msg << rmoviva.get(RMI_NUMREG).as_int(); + msg << " Riga IVA " << rmoviva.get(RMI_NUMRIG).as_int(); + msg << " impostato tipo conto (" << tipocf_pcon << ")"; + log.log(0, msg); + } + } +} void TAgg_tcontoCF::main_loop() { TMask m("cg1300n"); const TString16 arg = argv(3); const bool force = arg.starts_with("-f"); + TRectype pcon(LF_PCON); + TLog_report log; - if (force || m.run() == K_ENTER) + if (force) { - bool update_caus = force|| m.get_bool(F_UPDCAUS); - bool update_mov = force || m.get_bool(F_UPDMOV); - TRectype pcon(LF_PCON); - TLog_report log; - - if (update_caus) + const int ditta = get_firm(); + TString use("USE "); use << LF_NDITTE; + TISAM_recordset d(use); + + for (bool ok = d.move_first(); ok; ok = d.move_next()) { - TString use("USE "); use << LF_RCAUSALI; - TISAM_recordset rcaus(use); - TLocalisamfile & frcaus = rcaus.cursor()->relation()->lfile(); + set_firm(d.get(NDT_CODDITTA).as_int()); - for (bool ok = rcaus.move_first(); ok; ok = rcaus.move_next()) - { - const int gruppo = rcaus.get(RCA_GRUPPO).as_int(); - const int conto = rcaus.get(RCA_CONTO).as_int(); - const TString4 tipocf = rcaus.get(RCA_TIPOCF).as_string(); - TBill tc (gruppo,conto,0L); + TString msg("Ditta "); - tc.read(pcon); - - const TString4 tipocf_pcon = pcon.get(PCN_TMCF); - - if (tipocf != tipocf_pcon) - { - frcaus.put(RCA_TIPOCF, tipocf_pcon); - frcaus.rewrite(); - TString msg ("Causale "); - - msg << rcaus.get(RCA_CODCAUS).as_string(); - msg << " Riga " << rcaus.get(RCA_NRIGA).as_int(); - msg << " impostato tipo conto (" << tipocf_pcon << ")"; - log.log(0, msg); - } - } + msg << get_firm(); + log.log(0, msg); + log.log(0, ""); + update_causali(pcon, log); + update_movimenti(pcon, log); + update_movimenti_IVA(pcon, log); + log.log(0, ""); } - if (update_mov) // CONTABILITA' - { - TString use("USE "); use << LF_RMOV; - TISAM_recordset rmov(use); - TLocalisamfile & frmov = rmov.cursor()->relation()->lfile(); - - for (bool ok = rmov.move_first(); ok; ok = rmov.move_next()) - { - const int gruppo = rmov.get(RMV_GRUPPO).as_int(); - const int conto = rmov.get(RMV_CONTO).as_int(); - const TString4 tipocf = rmov.get(RMV_TIPOC).as_string(); - TBill tc (gruppo,conto,0L); - - tc.read(pcon); - - const TString4 tipocf_pcon = pcon.get(PCN_TMCF); - - if (tipocf != tipocf_pcon) - { - frmov.put(RMV_TIPOC, tipocf_pcon); - frmov.rewrite(); - TString msg ("Movimento "); - - msg << rmov.get(RMV_NUMREG).as_int(); - msg << " Riga " << rmov.get(RMV_NUMRIG).as_int(); - msg << " impostato tipo conto (" << tipocf_pcon << ")"; - log.log(0, msg); - } - } - } - if (update_mov) // IVA - { - TString use("USE "); use << LF_RMOVIVA; - TISAM_recordset rmoviva(use); - TLocalisamfile & frmoviva = rmoviva.cursor()->relation()->lfile(); - - for (bool ok = rmoviva.move_first(); ok; ok = rmoviva.move_next()) - { - const int gruppo = rmoviva.get(RMI_GRUPPO).as_int(); - const int conto = rmoviva.get(RMI_CONTO).as_int(); - const TString4 tipocf = rmoviva.get(RMI_TIPOC).as_string(); - TBill tc (gruppo,conto,0L); - - tc.read(pcon); - - const TString4 tipocf_pcon = pcon.get(PCN_TMCF); - - if (tipocf != tipocf_pcon) - { - frmoviva.put(RMI_TIPOC, tipocf_pcon); - frmoviva.rewrite(); - TString msg ("Movimento "); - - msg << rmoviva.get(RMI_NUMREG).as_int(); - msg << " Riga IVA" << rmoviva.get(RMI_NUMRIG).as_int(); - msg << " impostato tipo conto (" << tipocf_pcon << ")"; - log.log(0, msg); - } - } - } - log.print_or_preview(); + set_firm(ditta); } + else + { + if (m.run() == K_ENTER) + { + bool update_caus = m.get_bool(F_UPDCAUS); + bool update_mov = m.get_bool(F_UPDMOV); + + if (update_caus) + update_causali(pcon, log); + if (update_mov) // CONTABILITA' + { + update_movimenti(pcon, log); + update_movimenti_IVA(pcon, log); + } + } + } + log.print_or_preview(); } diff --git a/src/cg/cg1314.h b/src/cg/cg1314.h index 7db797570..95ccc6623 100644 --- a/src/cg/cg1314.h +++ b/src/cg/cg1314.h @@ -1,8 +1,13 @@ -#include +#include +#include +#include class TAgg_tcontoCF : public TSkeleton_application { - + void update_causali(TRectype & pcon, TLog_report & log); + void update_movimenti(TRectype & pcon, TLog_report & log); + void update_movimenti_IVA(TRectype & pcon, TLog_report & log); + public: virtual bool create(); virtual void main_loop();