From b2cce041ef568dd97a51d3045952f3231c3fcd03 Mon Sep 17 00:00:00 2001 From: luca Date: Tue, 19 Jul 2005 11:05:25 +0000 Subject: [PATCH] Patch level :2.2 nopatch Files correlati : Ricompilazione Demo : [ ] Commento :commit di sicurezza in fase avanzamento programma rendiconto (maschera completa) git-svn-id: svn://10.65.10.50/trunk@13279 c028cbd2-c16b-5b4b-a496-9718f37d4682 --- ca/ca3700.cpp | 209 +++++++++++++++++++++++++++++++++++++++++--------- ca/ca3700.h | 55 +++++++++---- ca/ca3700.uml | 44 ++++++----- 3 files changed, 234 insertions(+), 74 deletions(-) diff --git a/ca/ca3700.cpp b/ca/ca3700.cpp index e1330d481..c76364b36 100755 --- a/ca/ca3700.cpp +++ b/ca/ca3700.cpp @@ -8,6 +8,7 @@ #include "../cg/cglib01.h" #include "../ve/velib04.h" +#include "panapdc.h" #include "pconana.h" #include "movana.h" #include "rmovana.h" @@ -26,8 +27,11 @@ protected: bool on_field_event(TOperable_field& o, TField_event e, long jolly); const TString& get_report_class() const; bool test_compatible_report(); - void create_page2(); - int create_page2_sheet(int lf, int& y, short& dlg, bool required); + + bool esistono_riclassificazioni() const; + void create_sheet(); + int create_sheet_fields(int lf, int& y, short& dlg, bool required); + public: TPrint_rendiconto_ca_mask(); virtual ~TPrint_rendiconto_ca_mask() {} @@ -42,7 +46,7 @@ const TString& TPrint_rendiconto_ca_mask::get_report_class() const bool TPrint_rendiconto_ca_mask::test_compatible_report() { - TFilename lib = get_report_class(); + const TString& cls = get_report_class(); const TString& name = get(F_REPORT); bool ok = name.not_empty(); if (ok) @@ -52,14 +56,15 @@ bool TPrint_rendiconto_ca_mask::test_compatible_report() if (ok) { const TString& classe = rep.get_class(); - ok = classe == lib; + ok = classe == cls; } } if (!ok) { - set(F_REPORT, lib); - lib.ext("rep"); - ok = lib.custom_path(); + set(F_REPORT, cls); + TFilename path = cls; + path.ext("rep"); + ok = path.custom_path(); } return ok; } @@ -68,7 +73,6 @@ bool TPrint_rendiconto_ca_mask::on_field_event(TOperable_field& o, TField_event { switch (o.dlg()) { - break; case F_REPORT: if (e == fe_button) { @@ -84,15 +88,31 @@ bool TPrint_rendiconto_ca_mask::on_field_event(TOperable_field& o, TField_event if (e == fe_close) { if (!test_compatible_report()) - return error_box(TR("Impossibile trovare un report compatibile")); + return error_box("Impossibile trovare un report compatibile"); } break; - default: break; + case F_PRE1: + case F_PRE2: + case F_PRE3: + if ((e == fe_init || e == fe_modify) && o.active()) + { + const int k = o.dlg()-F_PRE1; + set(F_PAN1_INI + k, o.get(), 0x2); + disable(F_PAN1_INI + k); + disable(F_PANDES1_INI + k); + + set(F_PAN1_FIN + k, o.get(), 0x2); + disable(F_PAN1_FIN + k); + disable(F_PANDES1_FIN + k); + } + break; + default: + break; } return true; } -int TPrint_rendiconto_ca_mask::create_page2_sheet(int lf, int& y, short& dlg, bool required) +int TPrint_rendiconto_ca_mask::create_sheet_fields(int lf, int& y, short& dlg, bool required) { TSheet_field& sf = sfield(F_RIGHE); TMask& sm = sf.sheet_mask(); @@ -137,7 +157,7 @@ int TPrint_rendiconto_ca_mask::create_page2_sheet(int lf, int& y, short& dlg, bo return h; } -void TPrint_rendiconto_ca_mask::create_page2() +void TPrint_rendiconto_ca_mask::create_sheet() { TSheet_field& sf = sfield(F_RIGHE); TMask& sm = sf.sheet_mask(); @@ -157,27 +177,27 @@ void TPrint_rendiconto_ca_mask::create_page2() if (level == "CDC") // Crea centro di costo { if (fasinfo.parent() == LF_CDC) - create_page2_sheet(LF_FASI, y, dlg, fsc_req); + create_sheet_fields(LF_FASI, y, dlg, fsc_req); else { const bool cdc_req = ini.get_bool("CdcRequired"); - create_page2_sheet(LF_CDC, y, dlg, cdc_req); + create_sheet_fields(LF_CDC, y, dlg, cdc_req); } } else if (level == "CMS") // Crea commessa { if (fasinfo.parent() == LF_COMMESSE) - create_page2_sheet(LF_FASI, y, dlg, fsc_req); + create_sheet_fields(LF_FASI, y, dlg, fsc_req); else { const bool cms_req = ini.get_bool("CmsRequired"); - create_page2_sheet(LF_COMMESSE, y, dlg, cms_req); + create_sheet_fields(LF_COMMESSE, y, dlg, cms_req); } } } if (fasinfo.levels() > 0 && fasinfo.parent() <= 0) - create_page2_sheet(LF_FASI, y, dlg, fsc_req); + create_sheet_fields(LF_FASI, y, dlg, fsc_req); for (short id = S_CDC12+100; id >= S_CDC1+100; id--) { @@ -196,6 +216,11 @@ void TPrint_rendiconto_ca_mask::create_page2() } } +bool TPrint_rendiconto_ca_mask::esistono_riclassificazioni() const +{ + TLocalisamfile ric(LF_PANAPDC); + return ric.first() == NOERR; +} TPrint_rendiconto_ca_mask::TPrint_rendiconto_ca_mask() :TAutomask("ca3700") @@ -203,21 +228,85 @@ TPrint_rendiconto_ca_mask::TPrint_rendiconto_ca_mask() TConfig_anal cfg; const bool use_pdcc = cfg.get_bool("UsePdcc"); - const int logicnum = use_pdcc ? LF_PCON : LF_PCONANA; - const int nfields = ca_create_fields(*this, 0, logicnum, 2, 5, F_CDC1_INI, F_DES1_INI, 0x0, "#DACONTO"); - ca_create_fields(*this, 0, logicnum, 2, 11, F_CDC1_FIN, F_DES1_FIN, 0x0, "#ACONTO"); + const TMultilevel_code_info& pconana_info = ca_multilevel_code_info(LF_PCONANA); + const int pconana_levels = pconana_info.levels(); + + int pconana_prefix = cfg.get_int("PdcPrefix"); + if (pconana_prefix >= pconana_levels) + pconana_prefix = pconana_levels-1; - for (int i = 0; i < nfields; i++) - { - TMask_field& daconto = field(F_CDC1_INI + i); - daconto.set_group(1); - daconto.check_type(CHECK_NORMAL); - TMask_field& aconto = field(F_CDC1_FIN + i); - aconto.set_group(2); - aconto.check_type(CHECK_NORMAL); - } - // creazione dei campi della seconda pagina della maschera - create_page2(); + disable(F_PIANO); + set(F_PIANO, use_pdcc ? "C" : "A"); + + // Controllo se voglio (e posso) usare il conto analitico come prefisso di quello contabile + const int pref = cfg.get_int("PdcPrefix"); + if (use_pdcc && pref > 0) + { + const TMultilevel_code_info& info = ca_multilevel_code_info(LF_PCONANA); + const int levels = info.levels(); + if (levels >= 2 && pref < levels && esistono_riclassificazioni()) + { + enable(F_PIANO); + ca_create_fields(*this, 0, LF_PCONANA, 2, 4, F_PRE1, F_PREDES1, 0x0, PCONANA_CODCONTO); + + // Nascondi i campi che non fanno parte del prefisso + for (int i = 0; i < levels; i++) + { + if (i < pref) + { + field(F_PRE1 + i).check_type(CHECK_REQUIRED); + field(F_PRE1 + i).set_group(6); + field(F_PREDES1 + i).set_group(6); + } + else + { + field(F_PRE1 + i).hide(); + field(F_PREDES1 + i).hide(); + } + } + } + } + + for (int g = 5; g <= 6; g++) + { + const int logicnum = g == 5 ? LF_PCON : LF_PCONANA; + const short da_dlg = g == 5 ? F_PDC1_INI : F_PAN1_INI; + const short da_des = g == 5 ? F_PDCDES1_INI : F_PANDES1_INI; + const short a_dlg = g == 5 ? F_PDC1_FIN : F_PAN1_FIN; + const short a_des = g == 5 ? F_PDCDES1_FIN : F_PANDES1_FIN; + + const int nfields = ca_create_fields(*this, 0, logicnum, 2, 9, da_dlg, da_des, 0x0, PCONANA_CODCONTO); + ca_create_fields(*this, 0, logicnum, 2, 14, a_dlg, a_des, 0x0, PCONANA_CODCONTO); + + for (int i = 0; i < nfields; i++) + { + TMask_field& daconto = field(da_dlg + i); + daconto.set_group(1); + daconto.set_group(4); + daconto.set_group(g); + daconto.check_type(CHECK_NORMAL); + + field(da_des+i).set_group(4); + field(da_des+i).set_group(g); + + TMask_field& aconto = field(a_dlg + i); + aconto.set_group(2); + aconto.set_group(4); + aconto.set_group(g); + aconto.check_type(CHECK_NORMAL); + + field(a_des+i).set_group(4); + field(a_des+i).set_group(g); + } + } + + // creazione dei campi della seconda pagina della maschera (cdc/cms/fasi) + create_sheet(); + // setta gli handlers a tutti i campi generati della maschera;senza questa chiamata la on_field_event + // non puo' funzionare sui campi generati!!! + set_handlers(); + + //la terza pagina ha uno sheet standard e non necessita di metodi per la creazione } @@ -424,9 +513,51 @@ void TPrint_rendiconto_ca_recordset::salva_rmovana(const TRectype& rmovana, cons const char tipomov = movana.get_char(MOVANA_TIPOMOV); if (tipomov <= ' ' || tipomov == 'T') { - //scegli i campi da mettere - _tmp->curr().put("CONTO", rmovana.get(RMOVANA_CODCONTO)); //conto + //compila i campi da stampare + // il conto puo' essere analitico o contabile... + //se si usa il piano dei conti contabile ed è compilato l'archivio di collegamento PANAPDC + //si deve usare come conto il campo codconto del panapdc!!!... + TConfig_anal ini; + const bool use_pdc = ini.get_bool("UsePdcc"); + TLocalisamfile panapdc(LF_PANAPDC); + panapdc.setkey(2); + if (use_pdc && panapdc.first() == NOERR) + { + TRectype& rec_panapdc = panapdc.curr(); + + const int gruppo = atoi(rmovana.get(RMOVANA_CODCONTO).left(3)); + + const int conto = atoi(rmovana.get(RMOVANA_CODCONTO).mid(3,3)); + const long sottoconto = atol(rmovana.get(RMOVANA_CODCONTO).mid(6,6)); + + rec_panapdc.put(PANAPDC_GRUPPO, gruppo); + rec_panapdc.put(PANAPDC_CONTO, conto); + rec_panapdc.put(PANAPDC_SOTTOCONTO, sottoconto); + int err = panapdc.read(rec_panapdc, _isgteq); + //poichè non puo' avere la chiave 2 completa, visto che sta cercando l'ultimo elemento.. + //deve fare il confronto campo a campo dei gr/co/sottoc del record corrente con quelli + //estratti qualche riga sopra da rmovana + const int curr_gruppo = rec_panapdc.get_int(PANAPDC_GRUPPO); + if (gruppo - curr_gruppo == 0) + { + const int curr_conto = rec_panapdc.get_int(PANAPDC_CONTO); + if (conto - curr_conto == 0) + { + const long curr_sottoconto = rec_panapdc.get_long(PANAPDC_SOTTOCONTO); + if (sottoconto - curr_sottoconto == 0) + { + const TString80 codconto = rec_panapdc.get(PANAPDC_CODCONTO); + _tmp->curr().put("CONTO", codconto); + } + } + } + + } + else //...sennò si usa il normale piano dei conti analitico + _tmp->curr().put("CONTO", rmovana.get(RMOVANA_CODCONTO)); //conto + + //i movimenti possono essere normali o generati da documento... if (dadoc) //movimento generato da documento { _tmp->curr().put("CODNUM", movana.get(MOVANA_DCODNUM)); //codnum del documento che origina il movana @@ -728,10 +859,14 @@ void TPrint_rendiconto_ca_recordset::set_filter(const TPrint_rendiconto_ca_mask& _codfas = rel.curr().get(RMOVANA_CODFASE); } - for (int i = 0; msk.id2pos(F_CDC1_INI+i) > 0; i++) + const char tc = msk.get(F_PIANO)[0]; // Contabile o Analitico? + const short dlg_da = tc == 'C' ? F_PDC1_INI : F_PAN1_INI; + const short dlg_al = tc == 'C' ? F_PDC1_FIN : F_PAN1_FIN; + + for (int i = 0; msk.id2pos(dlg_da+i) > 0; i++) { - _daconto << msk.get(F_CDC1_INI+i); - _aconto << msk.get(F_CDC1_FIN+i); + _daconto << msk.get(dlg_da+i); + _aconto << msk.get(dlg_al+i); } _dadata = msk.get_date(F_DATAINI); @@ -740,7 +875,7 @@ void TPrint_rendiconto_ca_recordset::set_filter(const TPrint_rendiconto_ca_mask& //metodo per riempire il file crea_righe_rmovana(); - crea_righe_rdoc(msk); + //crea_righe_rdoc(msk); } diff --git a/ca/ca3700.h b/ca/ca3700.h index 1e2dd62b3..37e04e807 100755 --- a/ca/ca3700.h +++ b/ca/ca3700.h @@ -2,24 +2,47 @@ #define __CA3700_H //pagina 1 -#define F_CODDITTA 201 -#define F_RAGSOC 202 -#define F_DATASTAMPA 203 -#define F_ANNO 204 -#define F_REPORT 205 +#define F_CODDITTA 251 +#define F_RAGSOC 252 +#define F_DATASTAMPA 253 +#define F_ANNO 254 +#define F_REPORT 255 +#define F_DATAINI 256 +#define F_DATAFIN 257 -#define F_DATAINI 250 -#define F_DATAFIN 251 +//campi generati dai piani dei conti +#define F_PIANO 319 +#define F_PRE0 320 +#define F_PRE1 321 +#define F_PRE2 322 +#define F_PRE3 323 +#define F_PREDES1 325 +#define F_PREDES2 326 +#define F_PREDES3 327 -//campi generati dal pdc -#define F_CDC1_INI 206 -#define F_CDC4_INI 209 -#define F_CDC1_FIN 216 -#define F_CDC4_FIN 219 -#define F_DES1_INI 226 -#define F_DES4_INI 229 -#define F_DES1_FIN 236 -#define F_DES4_FIN 239 +#define F_PDC0_INI 330 +#define F_PDC1_INI 331 +#define F_PDC4_INI 334 +#define F_PDCDES1_INI 335 +#define F_PDCDES4_INI 338 + +#define F_PDC0_FIN 340 +#define F_PDC1_FIN 341 +#define F_PDC4_FIN 344 +#define F_PDCDES1_FIN 345 +#define F_PDCDES4_FIN 348 + +#define F_PAN0_INI 350 +#define F_PAN1_INI 351 +#define F_PAN4_INI 354 +#define F_PANDES1_INI 355 +#define F_PANDES4_INI 358 + +#define F_PAN0_FIN 360 +#define F_PAN1_FIN 361 +#define F_PAN4_FIN 364 +#define F_PANDES1_FIN 365 +#define F_PANDES4_FIN 368 //sheet di pagina 2 #define F_RIGHE 260 diff --git a/ca/ca3700.uml b/ca/ca3700.uml index 69d23c4ce..57cdf766d 100755 --- a/ca/ca3700.uml +++ b/ca/ca3700.uml @@ -44,13 +44,22 @@ END DATE F_DATASTAMPA BEGIN - PROMPT 1 2 "Data di stampa " + PROMPT 1 2 "Data stampa " FLAGS "A" END +LIST F_PIANO 1 12 +BEGIN + PROMPT 26 2 "Piano dei conti " + ITEM "A|Analitico" + MESSAGE HIDE,5@|SHOW,6@ + ITEM "C|Contabile" + MESSAGE HIDE,6@|SHOW,5@ +END + NUMBER F_ANNO 4 BEGIN - PROMPT 49 2 "Esercizio " + PROMPT 60 2 "Esercizio " USE ESC INPUT CODTAB F_ANNO DISPLAY "Codice Esercizio" CODTAB @@ -63,44 +72,37 @@ BEGIN ADD NONE END -GROUPBOX DLG_NULL 76 6 +GROUPBOX F_PRE0 76 6 BEGIN - PROMPT 1 4 "@bDa:" + PROMPT 1 3 "@bPrefisso del piano dei conti analitico:" + GROUP 6 END -GROUPBOX DLG_NULL 76 6 +GROUPBOX F_PDC0_INI 76 6 BEGIN - PROMPT 1 10 "@bA:" + PROMPT 1 8 "@bDa conto:" + GROUP 4 END -GROUPBOX DLG_NULL 76 4 +GROUPBOX F_PDC0_FIN 76 6 BEGIN - PROMPT 1 16 "@bOpzioni stampa" -END - -TEXT 96 -BEGIN - PROMPT 2 17 "Dalla data " -END - -TEXT 97 -BEGIN - PROMPT 40 17 "Alla data " + PROMPT 1 13 "@bA conto:" + GROUP 4 END DATE F_DATAINI BEGIN - PROMPT 26 17 "" + PROMPT 2 19 "Dalla data " END DATE F_DATAFIN BEGIN - PROMPT 62 17 "" + PROMPT 40 19 "Alla data " END STRING F_REPORT 256 64 BEGIN - PROMPT 2 18 "Report " + PROMPT 2 20 "Report " FLAGS "B" CHECKTYPE REQUIRED END