From 43817827af3f878c0e8e82c2a8060ca5cb6785d0 Mon Sep 17 00:00:00 2001 From: nik Date: Wed, 2 Nov 1994 09:58:32 +0000 Subject: [PATCH] Bilanci : compattate ragioni sociali Stampa piano dei conti : correzioni varie Visualizzazione saldi : disabilitato speadsheet Mastrini sistemati vari errori non segnalati e compattate descrizioni git-svn-id: svn://10.65.10.50/trunk@509 c028cbd2-c16b-5b4b-a496-9718f37d4682 --- cg/cg1100.cpp | 2387 ++++++++++++++++++++++++------------------------ cg/cg1100.h | 22 +- cg/cg1100a.uml | 132 +-- cg/cg1500.cpp | 36 +- cg/cg1500.h | 82 +- cg/cg1500a.uml | 4 + cg/cg1600.cpp | 437 ++++++--- cg/cg1600.h | 56 +- cg/cg1600a.uml | 346 +++---- cg/cg3200.cpp | 263 ++++-- cg/cg3200.h | 83 +- cg/cg4400.cpp | 60 +- cg/cg5200.cpp | 22 +- cg/cg5200.h | 22 +- cg/cg5200a.uml | 42 + cg/conto.cpp | 19 +- cg/conto.h | 164 ++-- 17 files changed, 2286 insertions(+), 1891 deletions(-) diff --git a/cg/cg1100.cpp b/cg/cg1100.cpp index 7074319a7..9dadd2940 100755 --- a/cg/cg1100.cpp +++ b/cg/cg1100.cpp @@ -1,1180 +1,1207 @@ -// cg1100.cpp -// Stampa piano dei conti - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include "cg1.h" -#include "cg1100.h" - -const char * TAB_ANABIL = "%IVD"; -const char * TAB_IVD = "%IVD"; - -const int CODTABLEN = 15; - -enum stampe { - completa=1, - con_IV_direttiva, - senza_IV_direttiva, - completa_bil, - con_ana_bil, - senza_ana_bil - }; - -extern char __tmp [MAXSTR]; -static TFixed_string tmp(__tmp, MAXSTR); - -class CG1100_application : public TPrintapp -{ - struct bil_ivd - { - char sez; - char let; - char numr[5]; - char num[4]; - char gruppo[4]; - char conto[4]; - char sottoc[8]; - char descr[52]; - char sez_opp; - char let_opp; - char numr_opp[5]; - int num_opp; - }; - - bil_ivd* _bil; - TTable _tab; // tabella codici IV direttiva - TTable _tab_anabil ; // tabella codici analisi di bilancio - TRectype* _rec; - TSort* _sort; - TRelation* _rel; - TMask* _msk; - TParagraph_string * _descr; - const char* _buf; - stampe _tipo_stampa; - bool _salto_pag,_resetta_righe_stampa; - int _old_gruppo; - int _pcont_reclen,_i; - int _cur_c1, _cur_c2; - TString _clivd, _clivdo; - char _sez_da_stamp,_sez_stamp,_let_da_stamp,_let_stamp; - TString _numr_da_stamp,_numr_stamp; - int _gruppo,_conto,_num_da_stamp,_num_stamp,_g_prec,_c_prec; - long _sottoc,_s_prec; - TString _classe_da_stampare,_classe_stampata; - bool _conto_classificato,_sottoc_classificato,_stampa_riga_vuota; - bool _prima_volta; - -public: - - virtual void user_destroy() ; - virtual void user_create() ; - - virtual void set_page (int,int); - virtual bool preprocess_print (int,int); - virtual bool preprocess_page (int,int); - virtual print_action postprocess_page (int,int); - virtual void postclose_print (); - - virtual bool set_print(int); - - void intesta (stampe); - - - bool elabora_riga(); // decide se fare salto pagina o no - void scegli_cur(); - void set_completa (); - void set_con_IV (); - void set_senza_IV (); - void set_con_ana (); - void set_senza_ana (); - void init_sort(); - const char* descrizione_numero(char, char, int, int); - void setta_righe_descr(TParagraph_string*); - const char * decodifica_codanabil (const char * ); - int leggo_sottoc(int,int,long); - void riempi_record(char,char,const TString&,int,int,int,long,const TString&,char,char,const TString&,int); - void set_bil_key(bil_ivd* b, char sezione, char lettera, - const char* numero_romano, int numero, - int gruppo = 0, int conto = 0, long sottoconto = 0L); - void set_bil_val(bil_ivd* b, const char* descr,char sez_opp,char let_opp, - const char* numr_opp,int num_opp); - - const char * decodifica_IV_dir (const char * sezivd, - const char * lettivd = "", - int numrivd = 0, int numivd = 0); - - void process_link(int id, const char* txt); - - CG1100_application() : _tab (TAB_IVD), _tab_anabil (TAB_ANABIL), _clivd(8), - _clivdo(8) {} -}; - -void CG1100_application::process_link(int id, const char* txt) -{ - TString ss = "1|"; ss << txt; - TMessage fs(cmd2name("cg0","-0"), MSG_LN, ss); - TMailbox m; - m.send(fs); - TExternal_app cg0("cg0 -0"); - if (cg0.run()) beep(); -} - -void CG1100_application::init_sort() -{ - _bil = new bil_ivd; - _sort = new TSort (sizeof(bil_ivd)); - - _sort -> addsortkey ((char*)&(_bil->sez) - (char*)&(_bil->sez),1); - _sort -> addsortkey ((char*)&(_bil->let) - (char*)&(_bil->sez),1); - _sort -> addsortkey ((char*)&(_bil->numr) - (char*)&(_bil->sez),4); - _sort -> addsortkey ((char*)&(_bil->num) - (char*)&(_bil->sez),2); - _sort -> addsortkey ((char*)&(_bil->gruppo) - (char*)&(_bil->sez),3); - _sort -> addsortkey ((char*)&(_bil->conto) - (char*)&(_bil->sez),3); - _sort -> addsortkey ((char*)&(_bil->sottoc) - (char*)&(_bil->sez),6); - _sort->init(); -} - -void CG1100_application::set_bil_key(bil_ivd* b, char sezione, char lettera, - const char* numero_romano, int numero, - int gruppo, int conto,long sottoconto) -{ - b->sez = sezione; - b->let = lettera; - strcpy(b->numr, numero_romano); - sprintf(b->num , "%2d", numero); - sprintf(b->gruppo , "%3d", gruppo); - sprintf(b->conto , "%3d", conto); - sprintf(b->sottoc , "%6ld", sottoconto); -} - -void CG1100_application::set_bil_val(bil_ivd* b, const char* descr, - char sez_opp,char let_opp, - const char* numr_opp,int num_opp) -{ - strcpy(b->descr, descr); - b->sez_opp = sez_opp; - b->let_opp = let_opp; - strcpy(b->numr_opp, numr_opp); - b->num_opp = num_opp; -} - -void CG1100_application::riempi_record(char sez,char let,const TString& numr, - int numero,int g,int c,long s, - const TString& descr,char sez_opp, - char let_opp,const TString& numr_opp, - int num_opp) -{ - set_bil_key(_bil, sez, let, numr, numero, g, c, s); - set_bil_val(_bil, descr, sez_opp, let_opp, numr_opp, num_opp); - _sort->sort ((const char*) _bil); -} - -void CG1100_application::postclose_print() -{ - if (_tipo_stampa == con_IV_direttiva) - delete _sort; -} - -print_action CG1100_application::postprocess_page(int file,int counter) -{ - switch (_tipo_stampa) - { - case completa: - case senza_IV_direttiva: - case senza_ana_bil: - break; - case con_IV_direttiva: - case con_ana_bil: - { - //const char * buf; - struct bil_ivd* bil = (struct bil_ivd*) _buf; - - if (_sez_da_stamp != _sez_stamp) - { - if (_sez_da_stamp == '5' || _sez_da_stamp == '9') - { - reset_print(); - _i = 1; - set_con_IV(); - _resetta_righe_stampa = FALSE; - } - else - _resetta_righe_stampa = TRUE; - } - else - _resetta_righe_stampa = TRUE; - - _sez_stamp = _sez_da_stamp; - _let_stamp = _let_da_stamp; - _numr_stamp = _numr_da_stamp; - _num_stamp = _num_da_stamp; - _classe_stampata.format("%c%c%s%2d",_sez_stamp,_let_stamp,(const char*)_numr_stamp,_num_stamp); - - - - if ( (_buf = _sort->retrieve()) != NULL) - { - bil = (struct bil_ivd*) _buf; - _sez_da_stamp = bil->sez; - _let_da_stamp = bil->let; - _numr_da_stamp = bil->numr; - _numr_da_stamp.ltrim(); - _num_da_stamp = atoi(bil->num); - _gruppo = atoi(bil->gruppo); - _conto = atoi(bil->conto); - _sottoc = atol(bil->sottoc); - _classe_da_stampare.format("%c%c%s%2d",_sez_da_stamp,_let_da_stamp,(const char*)_numr_da_stamp,_num_da_stamp); - - set_auto_ff(FALSE); - - return REPEAT_PAGE; - } - break; - } - default: - break; - - } - return NEXT_PAGE; -} - -void CG1100_application::set_page(int file,int counter) -{ - //const char* buf; - - intesta (_tipo_stampa); - switch (_tipo_stampa) - { - case con_IV_direttiva: - { - if (_resetta_righe_stampa) - { - reset_print(); - _i = 1; - } - - if (_sez_da_stamp != _sez_stamp) - { - if (_sez_da_stamp=='1' || _sez_da_stamp=='2') - set_con_IV (); - if (_sez_da_stamp == '5' || _sez_da_stamp == '9') - { - set_row (_i,"%s",""); - set_auto_ff(TRUE); - } - } - else - if (_buf != NULL) - set_con_IV(); - } - break; - case con_ana_bil: - set_con_ana(); - break; - case senza_IV_direttiva: - set_senza_IV(); - break; - case senza_ana_bil: - set_senza_ana(); - break; -default: - break; -} -} - -////////////////////////////////////////////////////////////// -// Crea sort se necessario e seleziona il cursore opportuno -////////////////////////////////////////////////////////////// -void CG1100_application::scegli_cur() -{ - switch (_tipo_stampa) - { - case completa: - select_cursor (_cur_c1); - break; - case con_IV_direttiva: - { - char sez_conto,let_conto; - TString numr_conto; - int num_conto; - bool classe_conto = FALSE; - - init_sort(); - - select_cursor (_cur_c1); - - TCursor * cursor = current_cursor(); - TRectype & rec = cursor->curr(); - - long last = cursor->items(); - - for ( *cursor = 0; cursor->pos() < last; ++(*cursor) ) - { - int g = rec.get_int(PCN_GRUPPO); - int c = rec.get_int(PCN_CONTO); - long s = rec.get_int(PCN_SOTTOCONTO); - - if (g != 0 && c == 0 && s == 0) continue; - - char sez = rec.get_char(PCN_SEZIVD); - char let = rec.get_char(PCN_LETTIVD); - TString numr = rec.get (PCN_NUMRIVD); - int num = rec.get_int (PCN_NUMIVD); - TString descr = rec.get (PCN_DESCR); - char sez_opp = rec.get_char(PCN_SEZIVDOPP); - char let_opp = rec.get_char(PCN_LETTIVDOPP); - TString numr_opp = rec.get (PCN_NUMRIVDOPP); - int num_opp = rec.get_int (PCN_NUMIVDOPP); - - if ((g != 0) && (c != 0) && (s == 0)) - { - if (sez != '0') - { - sez_conto = sez; - - if (let != '\0') - let_conto = let; - else - if ((sez == '1')||(sez == '2')) - let_conto = 'Z'; - else - let_conto = let; - - numr_conto = numr; - num_conto = num; - classe_conto = TRUE; - riempi_record(sez_conto,let_conto,numr_conto,num_conto,g,c,s,descr,sez_opp,let_opp,numr_opp,num_opp); - } - else - classe_conto = FALSE; - } - - if ((g != 0) && (c != 0) && (s != 0)) - { - if (classe_conto) - riempi_record(sez_conto,let_conto,numr_conto,num_conto,g,c,s,descr,sez_opp,let_opp,numr_opp,num_opp); - else - { - if (sez != '0') - { - if (let == '\0') - if ((sez == '1')||(sez == '2')) - let = 'Z'; - - riempi_record(sez,let,numr,num,g,c,s,descr,sez_opp,let_opp,numr_opp,num_opp); - } - } - } - } - - _sort->endsort(); - delete _bil; - select_cursor (_cur_c2); - - break; - } - - case senza_IV_direttiva: - select_cursor (_cur_c1); - break; - - case con_ana_bil: - { - TRecfield codcbl (*_rec, PCN_CODCBL); - - _sort->addsortkey (codcbl); - _sort->init(); - - select_cursor (_cur_c1); - - TCursor * cursor = current_cursor(); - TRectype & rec = cursor->curr(); - - long last = cursor->items(); - TString c1(12); - - for ( *cursor = 0; cursor->pos() < last; ++(*cursor) ) - { - if (rec.get(PCN_CONTO).not_empty() && rec.get(PCN_SOTTOCONTO).empty()) - c1 = rec.get(PCN_CODCBL); - else - if (rec.get(PCN_SOTTOCONTO).not_empty() && rec.get(PCN_CODCBL).empty()) - rec.put(PCN_CODCBL, c1); - if (rec.get(PCN_CODCBL).not_empty() ) - _sort->sort (rec.string()); - } - - _sort->endsort(); - select_cursor (_cur_c2); - break; - } - case senza_ana_bil: - select_cursor (_cur_c1); - break; - default: - break; - } -} - -bool CG1100_application::preprocess_print (int file,int counter) -{ - //scegli_cur(); - switch (_tipo_stampa) - { - case con_IV_direttiva: - case con_ana_bil: - { - struct bil_ivd* bil = (struct bil_ivd*) _buf; - - if ((_buf = _sort->retrieve()) != NULL) - { - bil = (struct bil_ivd*) _buf; - _sez_da_stamp = bil->sez; - _let_da_stamp = bil->let; - _numr_da_stamp = bil->numr; - _numr_da_stamp.ltrim(); - _num_da_stamp = atoi(bil->num); - _gruppo = atoi(bil->gruppo); - _conto = atoi(bil->conto); - _sottoc = atol(bil->sottoc); - _classe_da_stampare.format("%c%c%s%2d",_sez_da_stamp,_let_da_stamp,(const char*)_numr_da_stamp,_num_da_stamp); - - return TRUE; - } - else - return FALSE; - } - break; -default: - break; -} - return TRUE; -} - -void CG1100_application::set_con_IV() -{ - struct bil_ivd* bil = (struct bil_ivd*) _buf; - - TString descrizione,descr; - char sez_opp,let_opp; - int num_opp,numr_opp; - bool stampa_classe = TRUE; - int numr = atoi(_numr_da_stamp); - TString numrom = itor(numr); - - sez_opp = bil->sez_opp; - let_opp = bil->let_opp; - numr_opp = atoi(bil->numr_opp); - TString numrom_opp = itor(numr_opp); - num_opp = bil->num_opp; - - descrizione = descrizione_numero(_sez_da_stamp,_let_da_stamp,numr,_num_da_stamp); - descr = bil->descr; - - //Se la classe prelevata dal record corrente del sort e' diversa dalla classe - //prelevata dal record precedente, allora stampo la nuova classe con i relativi - //sottoconti. In caso contrario continuo a stampare solo i sottoconti. - - if (_classe_da_stampare != _classe_stampata) - { - if (_sez_da_stamp != _sez_stamp) - { - if ((_sez_da_stamp == '1')&&(_let_da_stamp == 'Z')) - { - char app = ' '; - set_row (_i++,"@0g%c", app); - set_row (_i++,"@0gCONTI D' ORDINE ATTIVI"); - set_row (_i++,"@0g%c", app); - stampa_classe = FALSE; - } - else - if ((_sez_da_stamp == '1')&&(_let_da_stamp != 'Z')) - { - char app = ' '; - set_row (_i++,"@0g%c", app); - set_row (_i++,"@0gATTIVO"); - set_row (_i++,"@0g%c", app); - } - - if ((_sez_da_stamp == '2')&&(_let_da_stamp == 'Z')) - { - char app = ' '; - set_row(_i++,"@0g%c", app); - set_row (_i++,"@0gCONTI D' ORDINE PASSIVI"); - set_row(_i++,"@0g%c", app); - stampa_classe = FALSE; - } - else - if ((_sez_da_stamp == '2')&&(_let_da_stamp != 'Z')) - { - char app = ' '; - set_row(_i++,"@0g%c", app); - set_row (_i++,"@0gPASSIVO"); - set_row(_i++,"@0g%c", app); - } - - if (_sez_da_stamp == '5') - { - char app = ' '; - set_row(_i++,"@0g%c", app); - set_row (_i++,"@0gCONTI D' ORDINE"); - set_row(_i++,"@0g%c", app); - stampa_classe = FALSE; - } - - if (_sez_da_stamp == '9') - { - char app = ' '; - set_row(_i++,"@0g%c", app); - set_row (_i++,"@0gCONTO ECONOMICO"); - set_row(_i++,"@0g%c", app); - } - } - else - if ((_let_da_stamp!=_let_stamp)&&(_sez_da_stamp==_sez_stamp)) - { - if ((_sez_da_stamp == '1')&&(_let_da_stamp == 'Z')) - { - char app = ' '; - set_row (_i++,"@0g%c", app); - set_row (_i++,"@0gCONTI D' ORDINE ATTIVI"); - set_row (_i++,"@0g%c", app); - stampa_classe = FALSE; - } - if ((_sez_da_stamp == '2')&&(_let_da_stamp == 'Z')) - { - char app = ' '; - set_row(_i++,"@0g%c", app); - set_row (_i++,"@0gCONTI D' ORDINE PASSIVI"); - set_row(_i++,"@0g%c", app); - stampa_classe = FALSE; - } - } - - if (stampa_classe) - { - if ((_sez_da_stamp=='1')||(_sez_da_stamp=='2')||(_sez_da_stamp== '9')) - { - if (_let_da_stamp != ' ') - set_row(_i,"@0g%c", _let_da_stamp); - - if (_numr_da_stamp != "") - set_row(_i,"@2g%8s", (const char*) numrom); - - if (_num_da_stamp != 0) - set_row(_i,"@11g%2d", _num_da_stamp); - - *_descr = (const char*) descrizione; - setta_righe_descr(_descr); - } - } - } - set_row (_i,"@58g%3d", _gruppo); - set_row (_i,"@62g%3d", _conto); - if (_sottoc != 0) - set_row (_i,"@66g%6ld", _sottoc); - set_row (_i,"@73g%.40s", (const char*) descr); - - if (sez_opp != '0') - { - set_row (_i,"@116g%c", sez_opp); - - if (let_opp != '\0') - set_row (_i,"@118g%c", let_opp); - - if (numr_opp != 0) - set_row (_i,"@120g%8s", (const char*) numrom_opp); - - if (num_opp != 0) - set_row (_i++,"@129g%2d", num_opp); - } - else - _i++; -} - -void CG1100_application::setta_righe_descr(TParagraph_string* str) -{ - const char* r; - - while ((r = str->get()) != NULL) - { - set_row (_i,"@14g%s",r); - _i++; - } -} - -void CG1100_application::set_senza_IV() -{ - int i; - - TRectype & rec = current_cursor()->curr(); - - int gruppo = rec.get_int (PCN_GRUPPO); - int conto = rec.get_int (PCN_CONTO); - long sottoc = rec.get_long(PCN_SOTTOCONTO); - - reset_print (); - i = 1; - - if (_prima_volta) - { - _g_prec = gruppo; - _c_prec = conto; - _prima_volta = FALSE; - } - - if (sottoc == 0L) // Se si tratta di un conto - { - if (gruppo != _g_prec) - _stampa_riga_vuota = TRUE; - } - else - { - if (gruppo != _g_prec || conto != _c_prec) - _stampa_riga_vuota = TRUE; - } - - if (_stampa_riga_vuota) - { - char app = ' '; - set_row (i++,"@0g%c", app); - _stampa_riga_vuota = FALSE; - } - - set_row (i, "$[r]@pn$[n] $[r]@pn$[n] $[r]@pn$[n]", - FLD(LF_PCON, PCN_GRUPPO, "###"), FLD(LF_PCON,PCN_CONTO, "###"), - FLD(LF_PCON, PCN_SOTTOCONTO, "######")); - - - set_row (i, "@16g@50s", FLD(LF_PCON,PCN_DESCR) ); - - set_row (i, "@87g@pn", FLD(LF_PCON, PCN_INDBIL, "##") ); - set_row (i, "@92g@1s", FLD(LF_PCON, PCN_TMCF) ); - set_row (i, "@99g@f", FLD(LF_PCON, PCN_STSOTTBIL) ); - set_row (i, "@107g@f", FLD(LF_PCON, PCN_COMPENS) ); - set_row (i, "@114g@1n", FLD(LF_PCON, PCN_TIPOSPRIC) ); - set_row (i, "@120g@1s", FLD(LF_PCON, PCN_SEZSALDI) ); -} - -void CG1100_application::set_con_ana() -{ - // gruppo, conto e sottoconto - int g,c; - long s; - char tmcf; - int TipoSpric, IndBil; - - reset_row (1); - - g = _rec->get_int (PCN_GRUPPO); - c = _rec->get_int (PCN_CONTO); - s = _rec->get_long (PCN_SOTTOCONTO); - tmcf = _rec->get(PCN_TMCF)[0]; - TipoSpric = _rec->get_int(PCN_TIPOSPRIC); - IndBil = _rec->get_int(PCN_INDBIL); - - TString cod(_rec->get(PCN_CODCBL)); - - set_row (1, "%-10s", (const char *) cod); - - set_row (1, "@15g%-40s", "") ; /* TBI */ - set_row (1, "@60g$[r]%3d$[n] $[r]%3d$[n] $[r]%6ld$[n]", g, c, s); - TParagraph_string s1(_rec->get (PCN_DESCR), 30); - - set_row (1, "@78g%-30s", s1.get()); - - const char * s2 = s1.get(); - - if (s2) - { - reset_row(2); - set_row (2, "@78g%-30s", s2); - } -} - -void CG1100_application::set_senza_ana() -{ - - reset_row (1); - - set_row (1, "$[r]@pn$[n] $[r]@pn$[n] $[r]@pn$[n]", - FLD(LF_PCON, PCN_GRUPPO, "###"), FLD(LF_PCON,PCN_CONTO, "###"), - FLD(LF_PCON, PCN_SOTTOCONTO, "######")); - - set_row (1, "@16g@50s", FLD(LF_PCON,PCN_DESCR) ); - - set_row (1, "@69g@1s", FLD(LF_PCON, PCN_SEZIVD) ); - set_row (1, "@71g@1s", FLD(LF_PCON, PCN_LETTIVD) ); - set_row (1, "@73g#-8t", &_clivd); - set_row (1, "@82g@pn", FLD(LF_PCON, PCN_NUMIVD, "@@") ); - - set_row (1, "@87g@pn", FLD(LF_PCON, PCN_INDBIL, "##") ); - set_row (1, "@92g@1s", FLD(LF_PCON, PCN_TMCF) ); - set_row (1, "@99g@f", FLD(LF_PCON, PCN_STSOTTBIL) ); - set_row (1, "@107g@f", FLD(LF_PCON, PCN_COMPENS) ); - set_row (1, "@114g@1n", FLD(LF_PCON, PCN_TIPOSPRIC) ); - set_row (1, "@120g@1s", FLD(LF_PCON, PCN_SEZSALDI) ); -} - - -void CG1100_application::set_completa() -{ - TRectype & rec = current_cursor()->curr(); - char sezione; - int i; - - int gruppo = rec.get_int (PCN_GRUPPO); - int conto = rec.get_int (PCN_CONTO); - long sottoc = rec.get_long(PCN_SOTTOCONTO); - sezione = rec.get_char(PCN_SEZIVD); - TString desc = rec.get(PCN_DESCR); - - if (_prima_volta) - { - _s_prec = 0; - _prima_volta = FALSE; - } - - if (sottoc != 0l && _s_prec != 0l) - i = 1; - else - { - i = 1; - char app = ' '; - set_row (i++,"@0g%c", app); - } - - reset_print (); - - set_row (i, "$[r]@pn$[n] $[r]@pn$[n] $[r]@pn$[n]", - FLD(LF_PCON, PCN_GRUPPO, "###"), FLD(LF_PCON,PCN_CONTO, "###"), - FLD(LF_PCON, PCN_SOTTOCONTO, "######")); - - - // set_row (1, "@16g@50s", FLD(LF_PCON,PCN_DESCR) ); - set_row (i, "@16g%.40s", (const char*) desc); - - if (sezione != '0' && sezione != '9') - set_row (i, "@58g@1s", FLD(LF_PCON, PCN_SEZIVD) ); - set_row (i, "@60g@1s", FLD(LF_PCON, PCN_LETTIVD) ); - set_row (i, "@62g#-8t", &_clivd ); - set_row (i, "@71g@pn", FLD(LF_PCON, PCN_NUMIVD, "@@") ); - - if (conto != 0 && sottoc == 0l) - { - set_row (i, "@76g@pn", FLD(LF_PCON, PCN_INDBIL, "##") ); - set_row (i, "@82g@1s", FLD(LF_PCON, PCN_TMCF) ); - set_row (i, "@89g@f", FLD(LF_PCON, PCN_STSOTTBIL) ); - set_row (i, "@98g@f", FLD(LF_PCON, PCN_COMPENS) ); - } - if (sottoc != 0l) - { - set_row (i, "@104g@1n", FLD(LF_PCON, PCN_RICSER) ); - set_row (i, "@109g@1n", FLD(LF_PCON, PCN_TIPOSPRIC) ); - set_row (i, "@115g@1s", FLD(LF_PCON, PCN_SEZSALDI) ); - } - _s_prec = sottoc; -} - -bool CG1100_application::elabora_riga() -{ - TRectype& curr_rec = *_rec; - - switch (_tipo_stampa) - { - case completa: - case senza_IV_direttiva: - curr_rec = current_cursor()->curr(); - break; - case senza_ana_bil: - { - curr_rec = current_cursor()->curr(); - int conto = curr_rec.get_int(PCN_CONTO); - long sottoc = curr_rec.get_long(PCN_SOTTOCONTO); - if (conto != 0) - { - // se e' un sottoconto stampo sotttab in 127 - if (sottoc != 0) - { - set_row (1, "@127g@f", FLD(LF_PCON, PCN_STSOTTAB)); - set_row (1, "@117g "); - } - else - // se e' un conto stampo sotttab in 124 - { - set_row (1, "@117g@f", FLD(LF_PCON, PCN_STSOTTAB)); - set_row (1, "@127g "); - } - } - break; - } - case con_ana_bil: - case con_IV_direttiva: - curr_rec = *_rec; - break; - default: - break; - } - - // Gestione salto pagina - if (_tipo_stampa == con_ana_bil) // || _tipo_stampa == con_IV_direttiva) - return FALSE; - - int new_gruppo = curr_rec.get_int(PCN_GRUPPO); - - if (_salto_pag && new_gruppo != _old_gruppo) - { - const bool salta = _old_gruppo > 0; - _old_gruppo = new_gruppo; - return salta; - } - return FALSE; -} - -int CG1100_application::leggo_sottoc(int gruppo,int conto,long sottoc) -{ - TLocalisamfile pconti (LF_PCON,FALSE); - char sez; - int gr,co; - int esito = 0; - bool esiste_conto_classificato = FALSE; - bool esiste_conto_non_classificato = FALSE; - - pconti.zero(); - pconti.put(PCN_GRUPPO, gruppo); - pconti.put(PCN_CONTO, conto); - pconti.put(PCN_SOTTOCONTO, sottoc); - - for (pconti.read(); !pconti.eof() ;pconti.next()) - { - gr = pconti.get_int (PCN_GRUPPO); - co = pconti.get_int (PCN_CONTO); - - if (gruppo != gr || conto != co) break; - - sez = pconti.get_char(PCN_SEZIVD); - - if (sez != '0') - esiste_conto_classificato = TRUE; - - if (sez == '0') - esiste_conto_non_classificato = TRUE; - } - - if (esiste_conto_classificato && esiste_conto_non_classificato) - esito = 1; - - return esito; -} - -bool CG1100_application::preprocess_page(int file,int counter) -{ - static int c1 = 0; - static TString16 a1; - char sez; - - if (_tipo_stampa == completa) - set_completa(); - - if (_tipo_stampa == senza_IV_direttiva) - { - if (file == LF_PCON) - { - TRectype & rec = current_cursor()->curr(); - int gruppo = rec.get_int (PCN_GRUPPO); - int conto = rec.get_int (PCN_CONTO); - long sottoc = rec.get_long(PCN_SOTTOCONTO); - - force_setpage(); - - if (conto == 0) return FALSE; //Scarto i gruppi - - if (sottoc == 0L) // Se si tratta di un conto - { - sez = rec.get_char(PCN_SEZIVD); - - if (sez == '0') - { - _conto_classificato = FALSE; - _sottoc_classificato = 2; - } - else - { - _conto_classificato = TRUE; - return FALSE; - } - } - else // Se si tratta di un sottoconto - { - if (!_conto_classificato) - { - if (_sottoc_classificato == 2) - _sottoc_classificato = leggo_sottoc(gruppo,conto,sottoc); - - if (_sottoc_classificato == 0) - return FALSE; - else - if (_sottoc_classificato == 1) - { - char sezione = rec.get_char(PCN_SEZIVD); - - if (sezione != '0') - return FALSE; - } - } - else - return FALSE; - } - _g_prec = gruppo; - _c_prec = conto; - } - } - if (_tipo_stampa == senza_ana_bil) - { - TRectype & rec = current_cursor()->curr(); - - if (rec.get_int(PCN_CONTO) == 0) return FALSE; - if (rec.get_long(PCN_SOTTOCONTO) == 0L) - a1 = rec.get(PCN_CODCBL); - else - if (rec.get(PCN_CODCBL).empty()) - rec.put(PCN_CODCBL, a1); - if (rec.get(PCN_CODCBL).not_empty()) return FALSE; - } - if (elabora_riga()) - printer().formfeed(); - - const int c3 = atoi(_rec->get(PCN_NUMRIVD)); - const int o3 = atoi(_rec->get(PCN_NUMRIVDOPP)); - - _clivd = itor(c3); - _clivdo = itor(o3); - - return TRUE; -} - -bool CG1100_application::set_print(int) -{ - KEY tasto; - - _old_gruppo = 0; - tasto = _msk->run(); - - if (tasto == K_ENTER) - { - _tipo_stampa = (stampe)_msk->get_int(F_SCELTA_STAMPA); - _salto_pag = _msk->get_bool (F_SALTO_PAGINA); - - // scegli_cur(); - enable_link("Collegamento Piano dei conti : ", 'r'); - set_multiple_link(TRUE); - - _sez_stamp = ' '; - _let_stamp = ' '; - _numr_stamp = ""; - _num_stamp = 0; - _classe_stampata = ""; - - if (_tipo_stampa == senza_IV_direttiva) - { - _conto_classificato = TRUE; - _sottoc_classificato = 0; - _stampa_riga_vuota = FALSE; - _prima_volta = TRUE; - } - - scegli_cur(); - _resetta_righe_stampa = TRUE; - - return TRUE; - } - return FALSE; -} - -void CG1100_application::intesta (stampe tipo) -{ - int soh = 1; // riga d'inizio dell'intestazione - const long firm = get_firm(); - - reset_header (); - TLocalisamfile ditte(LF_NDITTE); - ditte.zero(); - ditte.put(NDT_CODDITTA, firm); - ditte.read(); - if (ditte.bad()) ditte.zero(); - - TString s(132); - s = ditte.get(NDT_RAGSOC); - - set_header (soh++, "Ditta : %ld %s@110gData : @< Pag. @#", firm, (const char *) s); - - - set_header (soh,"@0gPIANO DEI CONTI"); - - switch (tipo) - { - case completa: - set_header (soh++, "@20gStampa completa per IV direttiva"); - s.fill('-'); - set_header (soh++, (const char *) s); - set_header (soh++, "Conto @59gSez. Classe@75gTipo@86gDettaglio@104gT@107gSpesa@118gDet.alleg.bil."); - set_header (soh++, "Sottoconto @16gDescrizione@61gIV dir.@75gConto@81gC/F@86gBilancio@97gComp.@104gA@107gRicavo@114gSez@118gSot.con * Mov."); - break; - - case con_IV_direttiva: - set_header (soh++, "@20gStampa conti riclassificati per IV direttiva"); - s.fill('_'); - set_header (soh++, (const char *) s); - set_header (soh++, "@58gCodici Piano@116gSez. e Classe"); - set_header (soh++, "Classe@14gDescrizione@58gdei Conti @73gDescrizione@116gclasse opposta"); - - break; - - case senza_IV_direttiva: - set_header (soh++, "@20gStampa conti non collegati per IV direttiva"); - s.fill('_'); - set_header (soh++, (const char *) s); - set_header (soh++, "Conto@85gTipo@96gDettaglio@112gSpesa @123gDet.bil."); - set_header (soh++, "Sottoconto @16gDescrizione@85gConto @91gC/F @96gBilancio @106gComp. @112gRicavo @119gSez"); - break; - - case con_ana_bil: - - s.fill('_'); - set_header (soh++, (const char *) s); - set_header (soh++, "Codice @61gCodici Piano@113gDett.alleg.Bilancio"); - set_header (soh++, "Tabella@16gDescrizione@60gdei Conti @78gDescrizione @113gSot.con. * Moviment."); - - break; - - case senza_ana_bil: - s.fill('_'); - set_header (soh++, (const char *) s); - set_header (soh++, "Conto @67gSez. Classe@85gTipo@96gDettaglio@112gSpesa @123gDet.bil."); - set_header (soh++, "Sottoconto @16gDescrizione@68gIV dir. @85gConto @91gC/F @96gBilancio @106gComp. @112gRicavo @119gSez"); - break; - - default: - break; - } - - set_header (soh++,(const char*)s); - set_header (soh, ""); - -} - -const char* CG1100_application::descrizione_numero(char sezione, char lettera, int numr, int numero) -{ - TTable tabivd(TAB_IVD); - TString dep,dep2; - - tabivd.zero(); - if (numr == 0 && numero == 0) - dep = format("%c%c",sezione,lettera); - else - if (numero == 0) - { - if (numr != 0) - dep = format("%1c%1c%04d",sezione, lettera, numr); - else - dep = format("%c%c ",sezione,lettera); - } - else - { - if (numr != 0) - dep = format("%1c%1c%04d%02d",sezione, lettera, numr,numero); - else - dep = format("%c%c %02d",sezione,lettera,numero); - } - - tabivd.put("CODTAB", dep); - tabivd.read(); - dep2 = tabivd.get("CODTAB"); - if (dep == dep2) - tmp = tabivd.get("S0"); - else - tmp = ""; - return (__tmp); -} - -const char * CG1100_application::decodifica_IV_dir (const char * sezivd, const char * lettivd, int numrivd, int numivd) -{ - TString dep (CODTABLEN); - - _tab.curr().zero(); - dep.format("%1s%1s", sezivd, lettivd); - if (numivd != 0) - { - dep << format("%04d", numrivd); - dep << format("%02d", numivd); - } - else - if (numrivd != 0) - dep << format("%04d", numrivd); - - _tab.curr().put("CODTAB", (const char*)dep); - _tab.read(); - if (_tab.bad()) _tab.curr().zero(); - return _tab.curr().get ("S0"); -} - -const char * CG1100_application::decodifica_codanabil (const char * codpcab) -{ - // TString dep (CODTABLEN); - // non sara' un tabella ma un file - _tab_anabil.curr().zero(); - - _tab_anabil.curr().put("CODTAB", (const char*) codpcab); - _tab_anabil.read(); - if (_tab_anabil.bad()) _tab_anabil.curr().zero(); - return _tab_anabil.curr().get ("S0"); -} - -void CG1100_application::user_create() -{ - _rel = new TRelation (LF_PCON); - _msk = new TMask ("cg1100a") ; - - TCursor *cursor = new TCursor (_rel); - - _cur_c1 = add_cursor (cursor); - - _rec = new TRectype (cursor->curr()); - - _pcont_reclen = _rec->len(); - _sort = new TSort(_pcont_reclen); - - _cur_c2 = add_cursor (NULL); - - add_file(LF_PCON); - _descr = new TParagraph_string ("",40); - - _tipo_stampa = completa; - _salto_pag = FALSE; - -} - -void CG1100_application::user_destroy() -{ - delete _msk; - delete _rel; - delete _rec; - delete _descr; -} - -int cg1100(int argc, char* argv[]) -{ - CG1100_application a; - a.run(argc, argv, "Stampa Piano dei Conti"); - return 0; -} +// cg1100.cpp +// Stampa piano dei conti + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include "cg1.h" +#include "cg1100.h" + +const char * TAB_ANABIL = "%IVD"; +const char * TAB_IVD = "%IVD"; + +const int CODTABLEN = 15; + +enum stampe { + completa=1, + con_IV_direttiva, + senza_IV_direttiva, + completa_bil, + con_ana_bil, + senza_ana_bil + }; + +extern char __tmp [MAXSTR]; +static TFixed_string tmp(__tmp, MAXSTR); + +class CG1100_application : public TPrintapp +{ + struct bil_ivd + { + char sez; + char let; + char numr[5]; + char num[4]; + char gruppo[4]; + char conto[4]; + char sottoc[8]; + char descr[52]; + char sez_opp; + char let_opp; + char numr_opp[5]; + int num_opp; + }; + + bil_ivd* _bil; + TTable _tab; // tabella codici IV direttiva + TTable _tab_anabil ; // tabella codici analisi di bilancio + TRectype* _rec; + TSort* _sort; + TRelation* _rel; + TMask* _msk; + TParagraph_string * _descr; + const char* _buf; + stampe _tipo_stampa; + bool _salto_pag,_resetta_righe_stampa; + int _old_gruppo; + int _pcont_reclen,_i; + int _cur_c1, _cur_c2; + TString _clivd, _clivdo; + char _sez_da_stamp,_sez_stamp,_let_da_stamp,_let_stamp; + TString _numr_da_stamp,_numr_stamp; + int _gruppo,_conto,_num_da_stamp,_num_stamp,_g_prec,_c_prec; + long _sottoc,_s_prec; + TString _classe_da_stampare,_classe_stampata; + bool _conto_classificato,_sottoc_classificato,_stampa_riga_vuota; + bool _prima_volta; + TDate _data_stampa; + +public: + + virtual void user_destroy() ; + virtual void user_create() ; + + virtual void set_page (int,int); + virtual bool preprocess_print (int,int); + virtual bool preprocess_page (int,int); + virtual print_action postprocess_page (int,int); + virtual void postclose_print (); + + virtual bool set_print(int); + + void intesta (stampe); + + + bool elabora_riga(); // decide se fare salto pagina o no + void scegli_cur(); + void set_completa (); + void set_con_IV (); + void set_senza_IV (); + void set_con_ana (); + void set_senza_ana (); + void init_sort(); + const char* descrizione_numero(char, char, int, int); + void setta_righe_descr(TParagraph_string*); + const char * decodifica_codanabil (const char * ); + int leggo_sottoc(int,int,long); + void riempi_record(char,char,const TString&,int,int,int,long,const TString&,char,char,const TString&,int); + void set_bil_key(bil_ivd* b, char sezione, char lettera, + const char* numero_romano, int numero, + int gruppo = 0, int conto = 0, long sottoconto = 0L); + void set_bil_val(bil_ivd* b, const char* descr,char sez_opp,char let_opp, + const char* numr_opp,int num_opp); + + const char * decodifica_IV_dir (const char * sezivd, + const char * lettivd = "", + int numrivd = 0, int numivd = 0); + + void process_link(int id, const char* txt); + + CG1100_application() : _tab (TAB_IVD), _tab_anabil (TAB_ANABIL), _clivd(8), + _clivdo(8) {} +}; + +void CG1100_application::process_link(int id, const char* txt) +{ + TString ss = "1|"; ss << txt; + TMessage fs(cmd2name("cg0","-0"), MSG_LN, ss); + TMailbox m; + m.send(fs); + TExternal_app cg0("cg0 -0"); + if (cg0.run()) beep(); +} + +void CG1100_application::init_sort() +{ + _bil = new bil_ivd; + _sort = new TSort (sizeof(bil_ivd)); + + _sort -> addsortkey ((char*)&(_bil->sez) - (char*)&(_bil->sez),1); + _sort -> addsortkey ((char*)&(_bil->let) - (char*)&(_bil->sez),1); + _sort -> addsortkey ((char*)&(_bil->numr) - (char*)&(_bil->sez),4); + _sort -> addsortkey ((char*)&(_bil->num) - (char*)&(_bil->sez),2); + _sort -> addsortkey ((char*)&(_bil->gruppo) - (char*)&(_bil->sez),3); + _sort -> addsortkey ((char*)&(_bil->conto) - (char*)&(_bil->sez),3); + _sort -> addsortkey ((char*)&(_bil->sottoc) - (char*)&(_bil->sez),6); + _sort->init(); +} + +void CG1100_application::set_bil_key(bil_ivd* b, char sezione, char lettera, + const char* numero_romano, int numero, + int gruppo, int conto,long sottoconto) +{ + b->sez = sezione; + b->let = lettera; + strcpy(b->numr, numero_romano); + sprintf(b->num , "%2d", numero); + sprintf(b->gruppo , "%3d", gruppo); + sprintf(b->conto , "%3d", conto); + sprintf(b->sottoc , "%6ld", sottoconto); +} + +void CG1100_application::set_bil_val(bil_ivd* b, const char* descr, + char sez_opp,char let_opp, + const char* numr_opp,int num_opp) +{ + strcpy(b->descr, descr); + b->sez_opp = sez_opp; + b->let_opp = let_opp; + strcpy(b->numr_opp, numr_opp); + b->num_opp = num_opp; +} + +void CG1100_application::riempi_record(char sez,char let,const TString& numr, + int numero,int g,int c,long s, + const TString& descr,char sez_opp, + char let_opp,const TString& numr_opp, + int num_opp) +{ + set_bil_key(_bil, sez, let, numr, numero, g, c, s); + set_bil_val(_bil, descr, sez_opp, let_opp, numr_opp, num_opp); + _sort->sort ((const char*) _bil); +} + +void CG1100_application::postclose_print() +{ + if (_tipo_stampa == con_IV_direttiva) + delete _sort; +} + +print_action CG1100_application::postprocess_page(int file,int counter) +{ + switch (_tipo_stampa) + { + case completa: + case senza_IV_direttiva: + case senza_ana_bil: + break; + case con_IV_direttiva: + case con_ana_bil: + { + //const char * buf; + struct bil_ivd* bil = (struct bil_ivd*) _buf; +/* + if (_sez_da_stamp != _sez_stamp) + { + if (_sez_da_stamp == '5' || _sez_da_stamp == '9') + { + reset_print(); + _i = 1; + set_con_IV(); + _resetta_righe_stampa = FALSE; + } + else + _resetta_righe_stampa = TRUE; + } + else + _resetta_righe_stampa = TRUE; +*/ + _sez_stamp = _sez_da_stamp; + _let_stamp = _let_da_stamp; + _numr_stamp = _numr_da_stamp; + _num_stamp = _num_da_stamp; + _classe_stampata.format("%c%c%s%2d",_sez_stamp,_let_stamp,(const char*)_numr_stamp,_num_stamp); + + + + if ( (_buf = _sort->retrieve()) != NULL) + { + bil = (struct bil_ivd*) _buf; + _sez_da_stamp = bil->sez; + _let_da_stamp = bil->let; + _numr_da_stamp = bil->numr; + _numr_da_stamp.ltrim(); + _num_da_stamp = atoi(bil->num); + _gruppo = atoi(bil->gruppo); + _conto = atoi(bil->conto); + _sottoc = atol(bil->sottoc); + _classe_da_stampare.format("%c%c%s%2d",_sez_da_stamp,_let_da_stamp,(const char*)_numr_da_stamp,_num_da_stamp); + + //set_auto_ff(FALSE); + + return REPEAT_PAGE; + } + break; + } + default: + break; + + } + return NEXT_PAGE; +} + +void CG1100_application::set_page(int file,int counter) +{ + //const char* buf; + + intesta (_tipo_stampa); + switch (_tipo_stampa) + { + case con_IV_direttiva: + { +// if (_resetta_righe_stampa) +// { + reset_print(); + _i = 1; +// } + + if (_sez_da_stamp != _sez_stamp) +// { +// if (_sez_da_stamp=='1' || _sez_da_stamp=='2') + set_con_IV (); +// if (_sez_da_stamp == '5' || _sez_da_stamp == '9') +// { +// set_row (_i,"%s",""); +// set_auto_ff(TRUE); +// } +// } + else + if (_buf != NULL) + set_con_IV(); + } + break; + case con_ana_bil: + set_con_ana(); + break; + case senza_IV_direttiva: + set_senza_IV(); + break; + case senza_ana_bil: + set_senza_ana(); + break; + default: + break; + } +} + +////////////////////////////////////////////////////////////// +// Crea sort se necessario e seleziona il cursore opportuno +////////////////////////////////////////////////////////////// +void CG1100_application::scegli_cur() +{ + switch (_tipo_stampa) + { + case completa: + select_cursor (_cur_c1); + break; + case con_IV_direttiva: + { + char sez_conto,let_conto; + TString numr_conto; + int num_conto; + bool classe_conto = FALSE; + + init_sort(); + + select_cursor (_cur_c1); + + TCursor * cursor = current_cursor(); + TRectype & rec = cursor->curr(); + + long last = cursor->items(); + + for ( *cursor = 0; cursor->pos() < last; ++(*cursor) ) + { + int g = rec.get_int(PCN_GRUPPO); + int c = rec.get_int(PCN_CONTO); + long s = rec.get_int(PCN_SOTTOCONTO); + + if (g != 0 && c == 0 && s == 0) continue; + + char sez = rec.get_char(PCN_SEZIVD); + char let = rec.get_char(PCN_LETTIVD); + TString numr = rec.get (PCN_NUMRIVD); + int num = rec.get_int (PCN_NUMIVD); + TString descr = rec.get (PCN_DESCR); + char sez_opp = rec.get_char(PCN_SEZIVDOPP); + char let_opp = rec.get_char(PCN_LETTIVDOPP); + TString numr_opp = rec.get (PCN_NUMRIVDOPP); + int num_opp = rec.get_int (PCN_NUMIVDOPP); + + if ((g != 0) && (c != 0) && (s == 0)) + { + if (sez != '0') + { + sez_conto = sez; + + if (let != '\0') + let_conto = let; + else + if ((sez == '1')||(sez == '2')) + let_conto = 'Z'; + else + let_conto = let; + + numr_conto = numr; + num_conto = num; + classe_conto = TRUE; + riempi_record(sez_conto,let_conto,numr_conto,num_conto,g,c,s,descr,sez_opp,let_opp,numr_opp,num_opp); + } + else + classe_conto = FALSE; + } + + if ((g != 0) && (c != 0) && (s != 0)) + { + if (classe_conto) + riempi_record(sez_conto,let_conto,numr_conto,num_conto,g,c,s,descr,sez_opp,let_opp,numr_opp,num_opp); + else + { + if (sez != '0') + { + if (let == '\0') + if ((sez == '1')||(sez == '2')) + let = 'Z'; + + riempi_record(sez,let,numr,num,g,c,s,descr,sez_opp,let_opp,numr_opp,num_opp); + } + } + } + } + + _sort->endsort(); + delete _bil; + select_cursor (_cur_c2); + + break; + } + + case senza_IV_direttiva: + select_cursor (_cur_c1); + break; + + case con_ana_bil: + { + TRecfield codcbl (*_rec, PCN_CODCBL); + + _sort->addsortkey (codcbl); + _sort->init(); + + select_cursor (_cur_c1); + + TCursor * cursor = current_cursor(); + TRectype & rec = cursor->curr(); + + long last = cursor->items(); + TString c1(12); + + for ( *cursor = 0; cursor->pos() < last; ++(*cursor) ) + { + if (rec.get(PCN_CONTO).not_empty() && rec.get(PCN_SOTTOCONTO).empty()) + c1 = rec.get(PCN_CODCBL); + else + if (rec.get(PCN_SOTTOCONTO).not_empty() && rec.get(PCN_CODCBL).empty()) + rec.put(PCN_CODCBL, c1); + if (rec.get(PCN_CODCBL).not_empty() ) + _sort->sort (rec.string()); + } + + _sort->endsort(); + select_cursor (_cur_c2); + break; + } + case senza_ana_bil: + select_cursor (_cur_c1); + break; + default: + break; + } +} + +bool CG1100_application::preprocess_print (int file,int counter) +{ +//scegli_cur(); + switch (_tipo_stampa) + { + case con_IV_direttiva: + case con_ana_bil: + { + struct bil_ivd* bil = (struct bil_ivd*) _buf; + + if ((_buf = _sort->retrieve()) != NULL) + { + bil = (struct bil_ivd*) _buf; + _sez_da_stamp = bil->sez; + _let_da_stamp = bil->let; + _numr_da_stamp = bil->numr; + _numr_da_stamp.ltrim(); + _num_da_stamp = atoi(bil->num); + _gruppo = atoi(bil->gruppo); + _conto = atoi(bil->conto); + _sottoc = atol(bil->sottoc); + _classe_da_stampare.format("%c%c%s%2d",_sez_da_stamp,_let_da_stamp,(const char*)_numr_da_stamp,_num_da_stamp); + + return TRUE; + } + else + return FALSE; + } + break; + default: + break; + } + return TRUE; +} + +void CG1100_application::set_con_IV() +{ + struct bil_ivd* bil = (struct bil_ivd*) _buf; + + TString descrizione,descr; + char sez_opp,let_opp; + int num_opp,numr_opp; + bool stampa_classe = TRUE; + int numr = atoi(_numr_da_stamp); + TString numrom = itor(numr); + + sez_opp = bil->sez_opp; + let_opp = bil->let_opp; + numr_opp = atoi(bil->numr_opp); + TString numrom_opp = itor(numr_opp); + num_opp = bil->num_opp; + + descrizione = descrizione_numero(_sez_da_stamp,_let_da_stamp,numr,_num_da_stamp); + descr = bil->descr; + + //Se la classe prelevata dal record corrente del sort e' diversa dalla classe + //prelevata dal record precedente, allora stampo la nuova classe con i relativi + //sottoconti. In caso contrario continuo a stampare solo i sottoconti. + + if (_classe_da_stampare != _classe_stampata) + { + if (_sez_da_stamp != _sez_stamp) + { + if ((_sez_da_stamp == '1')&&(_let_da_stamp == 'Z')) + { + char app = ' '; + set_row (_i++,"@0g%c", app); + set_row (_i++,"@0gCONTI D' ORDINE ATTIVI"); + set_row (_i++,"@0g%c", app); + stampa_classe = FALSE; + } + else + if ((_sez_da_stamp == '1')&&(_let_da_stamp != 'Z')) + { + char app = ' '; + set_row (_i++,"@0g%c", app); + set_row (_i++,"@0gATTIVO"); + set_row (_i++,"@0g%c", app); + } + + if ((_sez_da_stamp == '2')&&(_let_da_stamp == 'Z')) + { + char app = ' '; + set_row(_i++,"@0g%c", app); + set_row (_i++,"@0gCONTI D' ORDINE PASSIVI"); + set_row(_i++,"@0g%c", app); + stampa_classe = FALSE; + } + else + if ((_sez_da_stamp == '2')&&(_let_da_stamp != 'Z')) + { + char app = ' '; + set_row(_i++,"@0g%c", app); + set_row (_i++,"@0gPASSIVO"); + set_row(_i++,"@0g%c", app); + } + + if (_sez_da_stamp == '5') + { + char app = ' '; + set_row(_i++,"@0g%c", app); + set_row (_i++,"@0gCONTI D' ORDINE"); + set_row(_i++,"@0g%c", app); + stampa_classe = FALSE; + } + + if (_sez_da_stamp == '9') + { + char app = ' '; + set_row(_i++,"@0g%c", app); + set_row (_i++,"@0gCONTO ECONOMICO"); + set_row(_i++,"@0g%c", app); + } + } + else + if ((_let_da_stamp!=_let_stamp)&&(_sez_da_stamp==_sez_stamp)) + { + if ((_sez_da_stamp == '1')&&(_let_da_stamp == 'Z')) + { + char app = ' '; + set_row (_i++,"@0g%c", app); + set_row (_i++,"@0gCONTI D' ORDINE ATTIVI"); + set_row (_i++,"@0g%c", app); + stampa_classe = FALSE; + } + if ((_sez_da_stamp == '2')&&(_let_da_stamp == 'Z')) + { + char app = ' '; + set_row(_i++,"@0g%c", app); + set_row (_i++,"@0gCONTI D' ORDINE PASSIVI"); + set_row(_i++,"@0g%c", app); + stampa_classe = FALSE; + } + } + + if (stampa_classe) + { + if ((_sez_da_stamp=='1')||(_sez_da_stamp=='2')||(_sez_da_stamp== '9')) + { + char app = ' '; + set_row (_i++,"@0g%c", app); + if (_let_da_stamp != ' ') + set_row(_i,"@0g%c", _let_da_stamp); + + if (_numr_da_stamp != "") + set_row(_i,"@2g%8s", (const char*) numrom); + + if (_num_da_stamp != 0) + set_row(_i,"@11g%2d", _num_da_stamp); + + *_descr = (const char*) descrizione; + setta_righe_descr(_descr); + } + } + } + set_row (_i,"@58g%3d", _gruppo); + set_row (_i,"@62g%3d", _conto); + if (_sottoc != 0) + set_row (_i,"@66g%6ld", _sottoc); + set_row (_i,"@73g%.40s", (const char*) descr); + + if (sez_opp != '0') + { + set_row (_i,"@116g%c", sez_opp); + + if (let_opp != '\0') + set_row (_i,"@118g%c", let_opp); + + if (numr_opp != 0) + set_row (_i,"@120g%8s", (const char*) numrom_opp); + + if (num_opp != 0) + set_row (_i++,"@129g%2d", num_opp); + } + else + _i++; +} + +void CG1100_application::setta_righe_descr(TParagraph_string* str) +{ + const char* r; + + while ((r = str->get()) != NULL) + { + set_row (_i,"@14g%s",r); + _i++; + } + _i--; +} + +void CG1100_application::set_senza_IV() +{ + int i; + + TRectype & rec = current_cursor()->curr(); + + int gruppo = rec.get_int (PCN_GRUPPO); + int conto = rec.get_int (PCN_CONTO); + long sottoc = rec.get_long(PCN_SOTTOCONTO); + + reset_print (); + i = 1; + + if (_prima_volta) + { + _g_prec = gruppo; + _c_prec = conto; + _prima_volta = FALSE; + } + + if (sottoc == 0L) // Se si tratta di un conto + { + if (gruppo != _g_prec) + _stampa_riga_vuota = TRUE; + } + else + { + if (gruppo != _g_prec || conto != _c_prec) + _stampa_riga_vuota = TRUE; + } + + if (_stampa_riga_vuota) + { + char app = ' '; + set_row (i++,"@0g%c", app); + _stampa_riga_vuota = FALSE; + } + + set_row (i, "$[r]@pn$[n] $[r]@pn$[n] $[r]@pn$[n]", + FLD(LF_PCON, PCN_GRUPPO, "###"), FLD(LF_PCON,PCN_CONTO, "###"), + FLD(LF_PCON, PCN_SOTTOCONTO, "######")); + + + set_row (i, "@16g@50s", FLD(LF_PCON,PCN_DESCR) ); + + if (conto != 0 && sottoc == 0l) + { + set_row (i, "@76g@pn", FLD(LF_PCON, PCN_INDBIL, "##") ); + set_row (i, "@82g@1s", FLD(LF_PCON, PCN_TMCF) ); + set_row (i, "@89g@f", FLD(LF_PCON, PCN_STSOTTBIL) ); + set_row (i, "@98g@f", FLD(LF_PCON, PCN_COMPENS) ); + set_row (i, "@121g@f", FLD(LF_PCON, PCN_STSOTTAB) ); + } + if (sottoc != 0l) + { + set_row (i, "@104g@1n", FLD(LF_PCON, PCN_RICSER) ); + set_row (i, "@109g@1n", FLD(LF_PCON, PCN_TIPOSPRIC) ); + set_row (i, "@115g@1s", FLD(LF_PCON, PCN_SEZSALDI) ); + set_row (i, "@129g@f", FLD(LF_PCON, PCN_STSOTTAB) ); + } +} + +void CG1100_application::set_con_ana() +{ + // gruppo, conto e sottoconto + int g,c; + long s; + char tmcf; + int TipoSpric, IndBil; + + reset_row (1); + + g = _rec->get_int (PCN_GRUPPO); + c = _rec->get_int (PCN_CONTO); + s = _rec->get_long (PCN_SOTTOCONTO); + tmcf = _rec->get(PCN_TMCF)[0]; + TipoSpric = _rec->get_int(PCN_TIPOSPRIC); + IndBil = _rec->get_int(PCN_INDBIL); + + TString cod(_rec->get(PCN_CODCBL)); + + set_row (1, "%-10s", (const char *) cod); + + set_row (1, "@15g%-40s", "") ; /* TBI */ + set_row (1, "@60g$[r]%3d$[n] $[r]%3d$[n] $[r]%6ld$[n]", g, c, s); + TParagraph_string s1(_rec->get (PCN_DESCR), 30); + + set_row (1, "@78g%-30s", s1.get()); + + const char * s2 = s1.get(); + + if (s2) + { + reset_row(2); + set_row (2, "@78g%-30s", s2); + } +} + +void CG1100_application::set_senza_ana() +{ + + reset_row (1); + + set_row (1, "$[r]@pn$[n] $[r]@pn$[n] $[r]@pn$[n]", + FLD(LF_PCON, PCN_GRUPPO, "###"), FLD(LF_PCON,PCN_CONTO, "###"), + FLD(LF_PCON, PCN_SOTTOCONTO, "######")); + + set_row (1, "@16g@50s", FLD(LF_PCON,PCN_DESCR) ); + + set_row (1, "@69g@1s", FLD(LF_PCON, PCN_SEZIVD) ); + set_row (1, "@71g@1s", FLD(LF_PCON, PCN_LETTIVD) ); + set_row (1, "@73g#-8t", &_clivd); + set_row (1, "@82g@pn", FLD(LF_PCON, PCN_NUMIVD, "@@") ); + + set_row (1, "@87g@pn", FLD(LF_PCON, PCN_INDBIL, "##") ); + set_row (1, "@92g@1s", FLD(LF_PCON, PCN_TMCF) ); + set_row (1, "@99g@f", FLD(LF_PCON, PCN_STSOTTBIL) ); + set_row (1, "@107g@f", FLD(LF_PCON, PCN_COMPENS) ); + set_row (1, "@114g@1n", FLD(LF_PCON, PCN_TIPOSPRIC) ); + set_row (1, "@120g@1s", FLD(LF_PCON, PCN_SEZSALDI) ); +} + + +void CG1100_application::set_completa() +{ + TRectype & rec = current_cursor()->curr(); + char sezione; + int i; + + int gruppo = rec.get_int (PCN_GRUPPO); + int conto = rec.get_int (PCN_CONTO); + long sottoc = rec.get_long(PCN_SOTTOCONTO); + sezione = rec.get_char(PCN_SEZIVD); + TString desc = rec.get(PCN_DESCR); + + if (_prima_volta) + { + _s_prec = 0; + _prima_volta = FALSE; + } + + if (sottoc != 0l && _s_prec != 0l) + i = 1; + else + { + i = 1; + char app = ' '; + set_row (i++,"@0g%c", app); + } + + reset_print (); + + set_row (i, "$[r]@pn$[n] $[r]@pn$[n] $[r]@pn$[n]", + FLD(LF_PCON, PCN_GRUPPO, "###"), FLD(LF_PCON,PCN_CONTO, "###"), + FLD(LF_PCON, PCN_SOTTOCONTO, "######")); + + +// set_row (1, "@16g@50s", FLD(LF_PCON,PCN_DESCR) ); + set_row (i, "@16g%.40s", (const char*) desc); + + if (sezione != '0' && sezione != '9') + set_row (i, "@58g@1s", FLD(LF_PCON, PCN_SEZIVD) ); + set_row (i, "@60g@1s", FLD(LF_PCON, PCN_LETTIVD) ); + set_row (i, "@62g#-8t", &_clivd ); + set_row (i, "@71g@pn", FLD(LF_PCON, PCN_NUMIVD, "@@") ); + + if (conto != 0 && sottoc == 0l) + { + set_row (i, "@76g@pn", FLD(LF_PCON, PCN_INDBIL, "##") ); + set_row (i, "@82g@1s", FLD(LF_PCON, PCN_TMCF) ); + set_row (i, "@89g@f", FLD(LF_PCON, PCN_STSOTTBIL) ); + set_row (i, "@98g@f", FLD(LF_PCON, PCN_COMPENS) ); + set_row (i, "@121g@f", FLD(LF_PCON, PCN_STSOTTAB) ); + } + if (sottoc != 0l) + { + set_row (i, "@104g@1n", FLD(LF_PCON, PCN_RICSER) ); + set_row (i, "@109g@1n", FLD(LF_PCON, PCN_TIPOSPRIC) ); + set_row (i, "@115g@1s", FLD(LF_PCON, PCN_SEZSALDI) ); + set_row (i, "@129g@f", FLD(LF_PCON, PCN_STSOTTAB) ); + } + _s_prec = sottoc; +} + +bool CG1100_application::elabora_riga() +{ + TRectype& curr_rec = *_rec; + + switch (_tipo_stampa) + { + case completa: + case senza_IV_direttiva: + curr_rec = current_cursor()->curr(); + break; + case senza_ana_bil: + { + curr_rec = current_cursor()->curr(); + int conto = curr_rec.get_int(PCN_CONTO); + long sottoc = curr_rec.get_long(PCN_SOTTOCONTO); + if (conto != 0) + { + // se e' un sottoconto stampo sotttab in 127 + if (sottoc != 0) + { + set_row (1, "@127g@f", FLD(LF_PCON, PCN_STSOTTAB)); + set_row (1, "@117g "); + } + else + // se e' un conto stampo sotttab in 124 + { + set_row (1, "@117g@f", FLD(LF_PCON, PCN_STSOTTAB)); + set_row (1, "@127g "); + } + } + break; + } + case con_ana_bil: + case con_IV_direttiva: + curr_rec = *_rec; + break; + default: + break; + } + + // Gestione salto pagina + if (_tipo_stampa == con_ana_bil) // || _tipo_stampa == con_IV_direttiva) + return FALSE; + + int new_gruppo = curr_rec.get_int(PCN_GRUPPO); + + if (_salto_pag && new_gruppo != _old_gruppo) + { + const bool salta = _old_gruppo > 0; + _old_gruppo = new_gruppo; + return salta; + } + return FALSE; +} + +int CG1100_application::leggo_sottoc(int gruppo,int conto,long sottoc) +{ + TLocalisamfile pconti (LF_PCON,FALSE); + char sez; + int gr,co; + int esito = 0; + bool esiste_conto_classificato = FALSE; + bool esiste_conto_non_classificato = FALSE; + + pconti.zero(); + pconti.put(PCN_GRUPPO, gruppo); + pconti.put(PCN_CONTO, conto); + pconti.put(PCN_SOTTOCONTO, sottoc); + + for (pconti.read(); !pconti.eof() ;pconti.next()) + { + gr = pconti.get_int (PCN_GRUPPO); + co = pconti.get_int (PCN_CONTO); + + if (gruppo != gr || conto != co) break; + + sez = pconti.get_char(PCN_SEZIVD); + + if (sez != '0') + esiste_conto_classificato = TRUE; + + if (sez == '0') + esiste_conto_non_classificato = TRUE; + } + + if (!esiste_conto_classificato && esiste_conto_non_classificato) + esito = 0; + + if (esiste_conto_classificato && esiste_conto_non_classificato) + esito = 1; + + if (esiste_conto_classificato && !esiste_conto_non_classificato) + esito = 2; + + return esito; +} + +bool CG1100_application::preprocess_page(int file,int counter) +{ + static int c1 = 0; + static TString16 a1; + char sez; + + if (_tipo_stampa == completa) + set_completa(); + + if (_tipo_stampa == senza_IV_direttiva) + { + if (file == LF_PCON) + { + TRectype & rec = current_cursor()->curr(); + int gruppo = rec.get_int (PCN_GRUPPO); + int conto = rec.get_int (PCN_CONTO); + long sottoc = rec.get_long(PCN_SOTTOCONTO); + + force_setpage(); + + if (conto == 0) return FALSE; //Scarto i gruppi + + if (sottoc == 0L) // Se si tratta di un conto + { + sez = rec.get_char(PCN_SEZIVD); + + if (sez == '0') + { + _sottoc_classificato = leggo_sottoc(gruppo,conto,sottoc); + if (_sottoc_classificato == 0) + _conto_classificato = TRUE; + else + if (_sottoc_classificato == 1) + { + _conto_classificato = FALSE; + return FALSE; + } + else + if (_sottoc_classificato == 2) + { + _conto_classificato = TRUE; + return FALSE; + } + } + else + { + _conto_classificato = TRUE; + return FALSE; + } + } + else // Se si tratta di un sottoconto + { + if (!_conto_classificato) + { + char sezione = rec.get_char(PCN_SEZIVD); + + if (sezione != '0') + return FALSE; + } + else + return FALSE; + } + _g_prec = gruppo; + _c_prec = conto; + } + } + if (_tipo_stampa == senza_ana_bil) + { + TRectype & rec = current_cursor()->curr(); + + if (rec.get_int(PCN_CONTO) == 0) return FALSE; + if (rec.get_long(PCN_SOTTOCONTO) == 0L) + a1 = rec.get(PCN_CODCBL); + else + if (rec.get(PCN_CODCBL).empty()) + rec.put(PCN_CODCBL, a1); + if (rec.get(PCN_CODCBL).not_empty()) return FALSE; + } + if (elabora_riga()) + printer().formfeed(); + + const int c3 = atoi(_rec->get(PCN_NUMRIVD)); + const int o3 = atoi(_rec->get(PCN_NUMRIVDOPP)); + + _clivd = itor(c3); + _clivdo = itor(o3); + + return TRUE; +} + +bool CG1100_application::set_print(int) +{ + KEY tasto; + + _old_gruppo = 0; + tasto = _msk->run(); + + if (tasto == K_ENTER) + { + _tipo_stampa = (stampe)_msk->get_int(F_SCELTA_STAMPA); + _salto_pag = _msk->get_bool (F_SALTO_PAGINA); + _data_stampa = _msk->get (F_DATA_STAMPA); + + // scegli_cur(); + enable_link("Collegamento Piano dei conti : ", 'r'); + set_multiple_link(TRUE); + + _sez_stamp = ' '; + _let_stamp = ' '; + _numr_stamp = ""; + _num_stamp = 0; + _classe_stampata = ""; + + if (_tipo_stampa == senza_IV_direttiva) + { + _conto_classificato = TRUE; + _sottoc_classificato = 0; + _stampa_riga_vuota = FALSE; + _prima_volta = TRUE; + } + + scegli_cur(); + _resetta_righe_stampa = TRUE; + + return TRUE; + } + return FALSE; +} + +void CG1100_application::intesta (stampe tipo) +{ + int soh = 1; // riga d'inizio dell'intestazione + const long firm = get_firm(); + + reset_header (); + TLocalisamfile ditte(LF_NDITTE); + ditte.zero(); + ditte.put(NDT_CODDITTA, firm); + ditte.read(); + if (ditte.bad()) ditte.zero(); + + TString s(132); + s = ditte.get(NDT_RAGSOC); + TString data = _data_stampa.string(); + + set_header (soh++, "Ditta : %ld %s@110gData@115g%s Pag. @#", firm, (const char *) s, (const char*) data); + + + set_header (soh,"@0gPIANO DEI CONTI"); + + switch (tipo) + { + case completa: + set_header (soh++, "@20gStampa completa per IV direttiva"); + s.fill('-'); + set_header (soh++, (const char *) s); + set_header (soh++, "Conto @59gSez. Classe@75gTipo@86gDettaglio@104gT@107gSpesa@118gDet.alleg.bil."); + set_header (soh++, "Sottoconto @16gDescrizione@61gIV dir.@75gConto@81gC/F@86gBilancio@97gComp.@104gA@107gRicavo@114gSez@118gSot.con * Mov."); + break; + + case con_IV_direttiva: + set_header (soh++, "@20gStampa conti riclassificati per IV direttiva"); + s.fill('_'); + set_header (soh++, (const char *) s); + set_header (soh++, "@58gCodici Piano@116gSez. e Classe"); + set_header (soh++, "Classe@14gDescrizione@58gdei Conti @73gDescrizione@116gdi segno opposto"); + + break; + + case senza_IV_direttiva: + set_header (soh++, "@20gStampa conti non collegati per IV direttiva"); + s.fill('_'); + set_header (soh++, (const char *) s); + set_header (soh++, "Conto @75gTipo@86gDettaglio@104gT@107gSpesa@118gDet.alleg.bil."); + set_header (soh++, "Sottoconto @16gDescrizione@75gConto@81gC/F@86gBilancio@97gComp.@104gA@107gRicavo@114gSez@118gSot.con * Mov."); + break; + + case con_ana_bil: + + s.fill('_'); + set_header (soh++, (const char *) s); + set_header (soh++, "Codice @61gCodici Piano@113gDett.alleg.Bilancio"); + set_header (soh++, "Tabella@16gDescrizione@60gdei Conti @78gDescrizione @113gSot.con. * Moviment."); + + break; + + case senza_ana_bil: + s.fill('_'); + set_header (soh++, (const char *) s); + set_header (soh++, "Conto @67gSez. Classe@85gTipo@96gDettaglio@112gSpesa @123gDet.bil."); + set_header (soh++, "Sottoconto @16gDescrizione@68gIV dir. @85gConto @91gC/F @96gBilancio @106gComp. @112gRicavo @119gSez"); + break; + + default: + break; + } + + set_header (soh++,(const char*)s); + set_header (soh, ""); + +} + +const char* CG1100_application::descrizione_numero(char sezione, char lettera, int numr, int numero) +{ + TTable tabivd(TAB_IVD); + TString dep,dep2; + + tabivd.zero(); + if (numr == 0 && numero == 0) + dep = format("%c%c",sezione,lettera); + else + if (numero == 0) + { + if (numr != 0) + dep = format("%1c%1c%04d",sezione, lettera, numr); + else + dep = format("%c%c ",sezione,lettera); + } + else + { + if (numr != 0) + dep = format("%1c%1c%04d%02d",sezione, lettera, numr,numero); + else + dep = format("%c%c %02d",sezione,lettera,numero); + } + + tabivd.put("CODTAB", dep); + tabivd.read(); + dep2 = tabivd.get("CODTAB"); + if (dep == dep2) + tmp = tabivd.get("S0"); + else + tmp = ""; + return (__tmp); +} + +const char * CG1100_application::decodifica_IV_dir (const char * sezivd, const char * lettivd, int numrivd, int numivd) +{ + TString dep (CODTABLEN); + + _tab.curr().zero(); + dep.format("%1s%1s", sezivd, lettivd); + if (numivd != 0) + { + dep << format("%04d", numrivd); + dep << format("%02d", numivd); + } + else + if (numrivd != 0) + dep << format("%04d", numrivd); + + _tab.curr().put("CODTAB", (const char*)dep); + _tab.read(); + if (_tab.bad()) _tab.curr().zero(); + return _tab.curr().get ("S0"); +} + +const char * CG1100_application::decodifica_codanabil (const char * codpcab) +{ + // TString dep (CODTABLEN); + // non sara' un tabella ma un file + _tab_anabil.curr().zero(); + + _tab_anabil.curr().put("CODTAB", (const char*) codpcab); + _tab_anabil.read(); + if (_tab_anabil.bad()) _tab_anabil.curr().zero(); + return _tab_anabil.curr().get ("S0"); +} + +void CG1100_application::user_create() +{ + _rel = new TRelation (LF_PCON); + _msk = new TMask ("cg1100a") ; + + TCursor *cursor = new TCursor (_rel); + + _cur_c1 = add_cursor (cursor); + + _rec = new TRectype (cursor->curr()); + + _pcont_reclen = _rec->len(); + _sort = new TSort(_pcont_reclen); + + _cur_c2 = add_cursor (NULL); + + add_file(LF_PCON); + _descr = new TParagraph_string ("",40); + + _tipo_stampa = completa; + _salto_pag = FALSE; + +} + +void CG1100_application::user_destroy() +{ + delete _msk; + delete _rel; + delete _rec; + delete _descr; +} + +int cg1100(int argc, char* argv[]) +{ + CG1100_application a; + a.run(argc, argv, "Stampa Piano dei Conti"); + return 0; +} diff --git a/cg/cg1100.h b/cg/cg1100.h index 97351e980..e3a536149 100755 --- a/cg/cg1100.h +++ b/cg/cg1100.h @@ -1,11 +1,11 @@ -#ifndef __CG1100_H -#define __CG1100_H - -#define F_DATA_STAMPA 100 -#define F_SCELTA_STAMPA 101 -#define F_SALTO_PAGINA 102 -#define F_CODDITTA 103 -#define F_RAGSOC 104 - -#endif - +#ifndef __CG1100_H +#define __CG1100_H + +#define F_DATA_STAMPA 100 +#define F_SCELTA_STAMPA 101 +#define F_SALTO_PAGINA 102 +#define F_CODDITTA 103 +#define F_RAGSOC 104 + +#endif + diff --git a/cg/cg1100a.uml b/cg/cg1100a.uml index 6170cfe42..6e106d412 100755 --- a/cg/cg1100a.uml +++ b/cg/cg1100a.uml @@ -1,66 +1,66 @@ -#include "cg1100.h" - -PAGE "" -1 -1 70 18 - -NUMBER F_CODDITTA 5 -BEGIN - PROMPT 2 1 "Ditta " - FLAGS "FRD" - USE LF_NDITTE KEY 1 - CHECKTYPE REQUIRED - INPUT CODDITTA F_CODDITTA - DISPLAY "Codice" CODDITTA - DISPLAY "Ragione sociale @50" RAGSOC - OUTPUT F_CODDITTA CODDITTA - OUTPUT F_RAGSOC RAGSOC -END - -STRING F_RAGSOC 50 -BEGIN - PROMPT 2 2 "Ragione sociale " - FLAGS "D" -END - -DATE F_DATA_STAMPA -BEGIN - PROMPT 2 4 "Data di stampa " - FLAGS "A" -END - -RADIOBUTTON F_SCELTA_STAMPA 47 -BEGIN - PROMPT 2 6 "Tipo di stampa " - HELP "Scegliere il tipo di stampa desiderata" - ITEM "1|Completa per IV direttiva" - ITEM "2|Conti riclassificati per IV direttiva" - ITEM "3|Conti non collegati per IV direttiva" - ITEM "4|Completa per analisi di bilancio" - ITEM "5|Conti riclassificati per analisi di bilancio" - ITEM "6|Conti non collegati per analisi di bilancio" -END - -BOOLEAN F_SALTO_PAGINA -BEGIN - PROMPT 3 14 "Salto pagina per cambio gruppo " - HELP "Indicare se si desidera un salto pagina ogni volta che cambia il gruppo" -END - -BUTTON DLG_OK 9 2 -BEGIN - PROMPT -12 -1 "" -END - -BUTTON DLG_QUIT 9 2 -BEGIN - PROMPT -22 -1 "" -END - -ENDPAGE - -ENDMASK - - - - - - +#include "cg1100.h" + +PAGE "" -1 -1 70 18 + +NUMBER F_CODDITTA 5 +BEGIN + PROMPT 2 1 "Ditta " + FLAGS "FRD" + USE LF_NDITTE KEY 1 + CHECKTYPE REQUIRED + INPUT CODDITTA F_CODDITTA + DISPLAY "Codice" CODDITTA + DISPLAY "Ragione sociale @50" RAGSOC + OUTPUT F_CODDITTA CODDITTA + OUTPUT F_RAGSOC RAGSOC +END + +STRING F_RAGSOC 50 +BEGIN + PROMPT 2 2 "Ragione sociale " + FLAGS "D" +END + +DATE F_DATA_STAMPA +BEGIN + PROMPT 2 4 "Data di stampa " + FLAGS "A" +END + +RADIOBUTTON F_SCELTA_STAMPA 47 +BEGIN + PROMPT 2 6 "Tipo di stampa " + HELP "Scegliere il tipo di stampa desiderata" + ITEM "1|Completa per IV direttiva" + ITEM "2|Conti riclassificati per IV direttiva" + ITEM "3|Conti non collegati per IV direttiva" + ITEM "4|Completa per analisi di bilancio" + ITEM "5|Conti riclassificati per analisi di bilancio" + ITEM "6|Conti non collegati per analisi di bilancio" +END + +BOOLEAN F_SALTO_PAGINA +BEGIN + PROMPT 3 14 "Salto pagina per cambio gruppo " + HELP "Indicare se si desidera un salto pagina ogni volta che cambia il gruppo" +END + +BUTTON DLG_OK 9 2 +BEGIN + PROMPT -12 -1 "" +END + +BUTTON DLG_QUIT 9 2 +BEGIN + PROMPT -22 -1 "" +END + +ENDPAGE + +ENDMASK + + + + + + diff --git a/cg/cg1500.cpp b/cg/cg1500.cpp index 5dcd470b9..1f2708366 100755 --- a/cg/cg1500.cpp +++ b/cg/cg1500.cpp @@ -1736,7 +1736,7 @@ void CG1500_application::crea_sort_clifo() int g=0, c=0; long codcf=0l; TString80 ragsoc; - char tipocf,tipocfp; + char tipocf,tipocfp,tipoa; real saldo_finale, saldo_conto, saldo_iniziale, saldodare, saldoavere, movdare, movavere; real mov_conto_dare, mov_conto_avere, prg_conto_dare, prg_conto_avere; @@ -1767,6 +1767,16 @@ void CG1500_application::crea_sort_clifo() codcf = _cur->curr().get_long(CLI_CODCF); tipocf = _cur->curr().get(CLI_TIPOCF)[0]; ragsoc = _cur->curr().get(CLI_RAGSOC); + tipoa = _cur->curr().get_char(CLI_TIPOAPER); + if (tipoa == 'F') //persona fisica + { + TString80 cognome, nome; + cognome = ragsoc.mid(0,30); + nome = ragsoc.mid(30,20); + cognome.trim(); nome.trim(); + ragsoc = cognome; + ragsoc << " " << nome; + } if (tipocf == 'C') gccf = _clienti; @@ -2843,6 +2853,7 @@ TDate CG1500_application::UltimaData(int g, int c, long s, int anno) return uldata; } +//Non ho potuto usare quella di TConto!!! Chiedere a me! const char* CG1500_application::DescrizioneConto(int g, int c, long s, char tipocf) { @@ -2851,6 +2862,8 @@ const char* CG1500_application::DescrizioneConto(int g, int c, long s, TMP = tc.descrizione(); return TMP; */ + TFixed_string ragsoc(&__tmp_string[256], 50); + const char* desc = NULL; TLocalisamfile pconti(LF_PCON,FALSE); TLocalisamfile clifo (LF_CLIFO); @@ -2869,9 +2882,24 @@ const char* CG1500_application::DescrizioneConto(int g, int c, long s, clifo.zero(); clifo.put(CLI_CODCF, s); clifo.put(CLI_TIPOCF,tipocf); - clifo.read(); - if (clifo.good()) - TMP = clifo.get(CLI_RAGSOC); + if (clifo.read() == NOERR) + { + char tipoa = clifo.get_char("TIPOAPER"); + if (tipoa == 'F') //persona fisica + { + TString80 cognome, nome; + ragsoc = clifo.get("RAGSOC"); + cognome = ragsoc.mid(0,30); + nome = ragsoc.mid(30,20); + cognome.trim(); nome.trim(); + ragsoc = cognome; + ragsoc << " " << nome; + desc = ragsoc; + } + else + desc = clifo.get("RAGSOC"); + TMP = desc; + } else TMP = ""; } diff --git a/cg/cg1500.h b/cg/cg1500.h index 42b221dd6..dee3da8a0 100755 --- a/cg/cg1500.h +++ b/cg/cg1500.h @@ -1,41 +1,41 @@ -#ifndef __CG1500_H -#define __CG1500_H - -#define F_CODDITTA 101 -#define F_DATASTAMPA 102 -#define F_RAGSOC 104 -#define F_BILANCIO 105 -#define F_ANNO 106 -#define F_STAMPA 107 -#define F_STAMPA1 108 -#define F_DATALIM 109 -#define F_TOTALI 110 -#define F_CODICI 111 -#define F_SALDO 112 -#define F_VERIFICA 113 -#define F_STAMPAV 114 -#define F_DATADA 115 -#define F_DATAA 116 -#define F_SITUAZIONE 118 -#define F_STAMPAC 119 -#define F_ORDINAMENTO 120 -#define F_MODULO 121 -#define F_STAMPAMPROV 122 - -#endif // __CG1500_H - - - - - - - - - - - - - - - - +#ifndef __CG1500_H +#define __CG1500_H + +#define F_CODDITTA 101 +#define F_DATASTAMPA 102 +#define F_RAGSOC 104 +#define F_BILANCIO 105 +#define F_ANNO 106 +#define F_STAMPA 107 +#define F_STAMPA1 108 +#define F_DATALIM 109 +#define F_TOTALI 110 +#define F_CODICI 111 +#define F_SALDO 112 +#define F_VERIFICA 113 +#define F_STAMPAV 114 +#define F_DATADA 115 +#define F_DATAA 116 +#define F_SITUAZIONE 118 +#define F_STAMPAC 119 +#define F_ORDINAMENTO 120 +#define F_MODULO 121 +#define F_STAMPAMPROV 122 + +#endif // __CG1500_H + + + + + + + + + + + + + + + + diff --git a/cg/cg1500a.uml b/cg/cg1500a.uml index 52c4b8c28..924f840d0 100755 --- a/cg/cg1500a.uml +++ b/cg/cg1500a.uml @@ -36,6 +36,9 @@ BEGIN DISPLAY "Data inizio esercizio" D0 DISPLAY "Data fine esercizio" D1 OUTPUT F_ANNO CODTAB + //CHECKTYPE NORMAL + //MESSAGE HIDE,98|HIDE,99|SHOW,96|SHOW,97 //se il campo e' vuoto manda questi messaggi + //MESSAGE EMPTY HIDE,96|HIDE,97|SHOW,98|SHOW,99 //se invece e' pieno manda questi FLAGS "RZ" END @@ -75,6 +78,7 @@ END RADIOBUTTON F_STAMPA1 28 BEGIN PROMPT 40 5 "Tipo stampa " + //FLAGS "G" HELP "Indicare il tipo di stampa" ITEM "1|Per date limite" MESSAGE SHOW,F_VERIFICA|SHOW,F_MODULO diff --git a/cg/cg1600.cpp b/cg/cg1600.cpp index ac1e282f5..886931513 100755 --- a/cg/cg1600.cpp +++ b/cg/cg1600.cpp @@ -275,13 +275,15 @@ class CG1600_application : public TPrintapp Anni_es _anni_es; Righe_sez_opp _sezopps; TSaldi_list* _listasld; - TProgind* _prog; + TProgind* _prog; + TParagraph_string * _descr; TDate _data_fine_ese,_data_fine_ese_prec,_data_fine_raf,_data_fine_raf_prec; TDate _datastampa,_datalimite,_databilrafr,_datai,_datairaf; TDate _dataini,_datafine,_data_ini_ese,_data_ini_raf; int _annoese,_annoeserafr,_anno_esercizio,_anno_esercizio_raf; bool _competenza,_intera_struttura,_stampamov,_stampacod,_stampa_modulo; + bool _sbilancio_patr_gia_stampato,_attivo_o_passivo; bool _stampa_mov_prov,_diffprod_fatto,_risimp_fatto; TString _classe_stampata, _classe_da_stampare,_numr_tot,_num_tot,_numr; char _sez_da_stamp,_let_da_stamp,_sez_stamp,_let_stamp,_sez_tot,_let_tot,_let,_sez_saldo,_sez,_tot_sez_saldo; @@ -340,6 +342,8 @@ public: void crea_sort_tabella(); void crea_sort_piano_conti_scalare(); void crea_sort_piano_conti_verifica(); + void setta_righe_descr(TParagraph_string*,const TString&,const TString&); + void setta_righe_descr_verifica(TParagraph_string*,const TString&,const TString&); void scrivi_record(const TString&,const TString&,const TString&,int,int,int,long,const real&,const real&,const real&,const real&,const real&,const real&,char,bool conto_dettagliato = TRUE); void riempi_record(const TString&,const TString&,const TString&,int,int,int,long,const real&,const real&,const real&,const real&,const real&,const real&,char,bool conto_dettagliato = TRUE); const char* descrizione_sezione(char); @@ -2013,7 +2017,9 @@ if (tasto == K_ENTER) _statopatr_no_stamp = TRUE; _diffprod_fatto = TRUE; _risimp_fatto = TRUE; - _sbilancio_ordine = FALSE; + _sbilancio_ordine = FALSE; + _sbilancio_patr_gia_stampato = FALSE; + _attivo_o_passivo = FALSE; _sez_stamp = ' '; _let_stamp = ' '; @@ -2094,7 +2100,10 @@ void CG1600_application::stampa_totali() _let_tot = ' '; _sez_tot = ' '; } - + + if ((_sez_stamp == '1' || _sez_stamp == '2') && _let_stamp != 'Z') + _attivo_o_passivo = TRUE; + if (_num_da_stamp!=_num_tot) { if (_let_stamp != 'Z') @@ -2301,15 +2310,20 @@ void CG1600_application::stampa_totali() set_row (_i,"@0gTOTALE CONTI D' ORDINE PASSIVI"); set_row (_i++,"@86g%r", &_totale_ordine_passivo); _i++; - real totale = _totale_ordine_attivo - _totale_ordine_passivo; - if (totale != ZERO) + + if (!_attivo_o_passivo) { - set_row (_i++,"@0gSALDO CONTI D' ORDINE"); - set_row (_i,"@0gSBILANCIO"); - set_row (_i++,"@86g%r", &totale); + real totale = _totale_ordine_attivo - _totale_ordine_passivo; + if (totale != ZERO) + { + set_row (_i++,"@0gSALDO CONTI D' ORDINE"); + set_row (_i,"@0gSBILANCIO"); + set_row (_i++,"@86g%r", &totale); + } + _totale_ordine_attivo = ZERO; + _totale_ordine_passivo = ZERO; + _sbilancio_ordine = TRUE; } - _totale_ordine_attivo = ZERO; - _totale_ordine_passivo = ZERO; gia_stampato_conto_ord = TRUE; } } @@ -2390,57 +2404,84 @@ void CG1600_application::stampa_totali() } if (!gia_stampato_conto_ord) - { + { + if (_sez_stamp == '2') + { + if (!_sbilancio_patr_gia_stampato) + { + _totale_patrimoniale = _totale_attivita - _totale_passivita; + if (_totale_patrimoniale != ZERO) + { + char app = ' '; + set_row (_i++,"@0g%c", app); + set_row (_i++,"@0gSALDO STATO PATRIMONIALE"); + set_row (_i,"@0gSBILANCIO (ATTIVO - PASSIVO)"); + //_totale_patrimoniale = _totale_attivita - _totale_passivita; + set_row (_i++,"@86g%r", &_totale_patrimoniale); + _totale_patrimoniale = ZERO; + } + _sbilancio_patr_gia_stampato = TRUE; + } + } if ((_sez_stamp == '1')&&(_let_stamp == 'Z')) { char app = ' '; set_row (_i++,"@0g%c", app); set_row (_i,"@0gTOTALE CONTI D' ORDINE ATTIVI"); set_row (_i++,"@86g%r", &_totale_ordine_attivo); - // _totale_ordine_attivo = ZERO; + // _totale_ordine_attivo = ZERO; } - if ((_sez_stamp == '2')&&(_let_stamp == 'Z')) { char app = ' '; set_row (_i++,"@0g%c", app); set_row (_i,"@0gTOTALE CONTI D' ORDINE PASSIVI"); set_row (_i++,"@86g%r", &_totale_ordine_passivo); - _i++; - real totale = _totale_ordine_attivo - _totale_ordine_passivo; - if (totale != ZERO) - { - set_row (_i++,"@0g%c", app); - set_row (_i++,"@0gSALDO CONTI D' ORDINE"); - set_row (_i,"@0gSBILANCIO"); - set_row (_i++,"@86g%r", &totale); - _sbilancio_ordine = TRUE; + _i++; + if (!_sbilancio_ordine) + { + real totale = _totale_ordine_attivo - _totale_ordine_passivo; + if (totale != ZERO) + { + set_row (_i++,"@0g%c", app); + set_row (_i++,"@0gSALDO CONTI D' ORDINE"); + set_row (_i,"@0gSBILANCIO"); + set_row (_i++,"@86g%r", &totale); + _sbilancio_ordine = TRUE; + } + _totale_ordine_passivo = ZERO; + _totale_ordine_attivo = ZERO; } - _totale_ordine_passivo = ZERO; - _totale_ordine_attivo = ZERO; } } if (_sez_stamp == '2') - { + { char app = ' '; - _totale_patrimoniale = _totale_attivita - _totale_passivita; - real totale = _totale_ordine_attivo - _totale_ordine_passivo; - if (totale != ZERO && !_sbilancio_ordine) - { - set_row (_i++,"@0g%c", app); - set_row (_i++,"@0gSALDO CONTI D' ORDINE"); - set_row (_i,"@0gSBILANCIO"); - set_row (_i++,"@86g%r", &totale); - } - if (_totale_patrimoniale != ZERO) + + if (!_sbilancio_patr_gia_stampato) { - set_row (_i++,"@0g%c", app); - set_row (_i++,"@0gSALDO STATO PATRIMONIALE"); - set_row (_i,"@0gSBILANCIO (ATTIVO - PASSIVO)"); - //_totale_patrimoniale = _totale_attivita - _totale_passivita; - set_row (_i++,"@86g%r", &_totale_patrimoniale); - _totale_patrimoniale = ZERO; + _totale_patrimoniale = _totale_attivita - _totale_passivita; + if (_totale_patrimoniale != ZERO) + { + set_row (_i++,"@0g%c", app); + set_row (_i++,"@0gSALDO STATO PATRIMONIALE"); + set_row (_i,"@0gSBILANCIO (ATTIVO - PASSIVO)"); + //_totale_patrimoniale = _totale_attivita - _totale_passivita; + set_row (_i++,"@86g%r", &_totale_patrimoniale); + _totale_patrimoniale = ZERO; + } + } + if (!_sbilancio_ordine) + { + real totale = _totale_ordine_attivo - _totale_ordine_passivo; + if (totale != ZERO && !_sbilancio_ordine) + { + set_row (_i++,"@0g%c", app); + set_row (_i++,"@0gSALDO CONTI D' ORDINE"); + set_row (_i,"@0gSBILANCIO"); + set_row (_i++,"@86g%r", &totale); + } } } if (_sez_stamp == '5') @@ -2505,7 +2546,10 @@ void CG1600_application::stampa_totali_con_raffronto() _let_tot = ' '; _sez_tot = ' '; } - + + if ((_sez_stamp == '1' || _sez_stamp == '2') && _let_stamp != 'Z') + _attivo_o_passivo = TRUE; + if (_num_da_stamp!=_num_tot) { @@ -2737,21 +2781,26 @@ void CG1600_application::stampa_totali_con_raffronto() set_row (_i,"@0gTOTALE CONTI D' ORDINE PASSIVI"); set_row (_i,"@86g%r", &_totale_ordine_passivo); set_row (_i++,"@112g%r", &_totale_ordine_passivo_raf); - _i++; - real totale = _totale_ordine_attivo - _totale_ordine_passivo; - real tot_raf = _totale_ordine_attivo_raf - _totale_ordine_passivo_raf; - if (totale != ZERO || tot_raf != ZERO) - { - set_row (_i++,"@0gSALDO CONTI D' ORDINE"); - set_row (_i,"@0gSBILANCIO"); - set_row (_i,"@86g%r", &totale); - set_row (_i++,"@112g%r", &tot_raf); - } - _totale_ordine_attivo = ZERO; - _totale_ordine_attivo_raf = ZERO; - _totale_ordine_passivo = ZERO; - _totale_ordine_passivo_raf = ZERO; + _i++; gia_stampato_conto_ord = TRUE; + if (!_attivo_o_passivo) + { + real totale = _totale_ordine_attivo - _totale_ordine_passivo; + real tot_raf = _totale_ordine_attivo_raf - _totale_ordine_passivo_raf; + if (totale != ZERO || tot_raf != ZERO) + { + set_row (_i++,"@0gSALDO CONTI D' ORDINE"); + set_row (_i,"@0gSBILANCIO"); + set_row (_i,"@86g%r", &totale); + set_row (_i++,"@112g%r", &tot_raf); + } + _totale_ordine_attivo = ZERO; + _totale_ordine_attivo_raf = ZERO; + _totale_ordine_passivo = ZERO; + _totale_ordine_passivo_raf = ZERO; + _sbilancio_ordine = TRUE; + _sbilancio_patr_gia_stampato = TRUE; //Se passa di qui non ci sono ne attivi ne passivo + } } } _cont_gcs = 0; @@ -2846,7 +2895,29 @@ void CG1600_application::stampa_totali_con_raffronto() } if (!gia_stampato_conto_ord) - { + { + if (_sez_stamp == '2') + { + if (!_sbilancio_patr_gia_stampato) + { + _totale_patrimoniale = _totale_attivita - _totale_passivita; + _totale_patrim_raf = _totale_attiv_raf - _totale_passiv_raf; + if (_totale_patrimoniale != ZERO || _totale_patrim_raf != ZERO) + { + char app = ' '; + set_row (_i++,"@0g%c", app); + set_row (_i++,"@0gSALDO STATO PATRIMONIALE"); + set_row (_i,"@0gSBILANCIO (ATTIVO - PASSIVO)"); + //_totale_patrimoniale = _totale_attivita - _totale_passivita; + //_totale_patrim_raf = _totale_attiv_raf - _totale_passiv_raf; + set_row (_i,"@86g%r", &_totale_patrimoniale); + set_row (_i++,"@112g%r", &_totale_patrim_raf); + _totale_patrimoniale = 0; + _totale_patrim_raf = 0; + } + _sbilancio_patr_gia_stampato = TRUE; + } + } if ((_sez_stamp == '1')&&(_let_stamp == 'Z')) { char app = ' '; @@ -2865,52 +2936,62 @@ void CG1600_application::stampa_totali_con_raffronto() set_row (_i,"@0gTOTALE CONTI D' ORDINE PASSIVI"); set_row (_i,"@86g%r", &_totale_ordine_passivo); set_row (_i++,"@112g%r", &_totale_ordine_passivo_raf); - _i++; - real totale = _totale_ordine_attivo - _totale_ordine_passivo; - real tot_raf = _totale_ordine_attivo_raf - _totale_ordine_passivo_raf; - if (totale != ZERO || tot_raf != ZERO) - { - set_row (_i++,"@0g%c", app); - set_row (_i++,"@0gSALDO CONTI D' ORDINE"); - set_row (_i,"@0gSBILANCIO"); - set_row (_i,"@86g%r", &totale); - set_row (_i++,"@112g%r", &tot_raf); - _sbilancio_ordine = TRUE; + _i++; + if (!_sbilancio_ordine) + { + real totale = _totale_ordine_attivo - _totale_ordine_passivo; + real tot_raf = _totale_ordine_attivo_raf - _totale_ordine_passivo_raf; + if (totale != ZERO || tot_raf != ZERO) + { + set_row (_i++,"@0g%c", app); + set_row (_i++,"@0gSALDO CONTI D' ORDINE"); + set_row (_i,"@0gSBILANCIO"); + set_row (_i,"@86g%r", &totale); + set_row (_i++,"@112g%r", &tot_raf); + _sbilancio_ordine = TRUE; + } + _totale_ordine_attivo = ZERO; + _totale_ordine_attivo_raf = ZERO; + _totale_ordine_passivo = ZERO; + _totale_ordine_passivo_raf = ZERO; + _sbilancio_ordine = TRUE; } - _totale_ordine_attivo = ZERO; - _totale_ordine_attivo_raf = ZERO; - _totale_ordine_passivo = ZERO; - _totale_ordine_passivo_raf = ZERO; } } if (_sez_stamp == '2') { - char app = ' '; - _totale_patrimoniale = _totale_attivita - _totale_passivita; - _totale_patrim_raf = _totale_attiv_raf - _totale_passiv_raf; - real totale = _totale_ordine_attivo - _totale_ordine_passivo; - real tot_raf = _totale_ordine_attivo_raf - _totale_ordine_passivo_raf; - if ((totale != ZERO || tot_raf != ZERO) && !_sbilancio_ordine) - { - set_row (_i++,"@0g%c", app); - set_row (_i++,"@0gSALDO CONTI D' ORDINE"); - set_row (_i,"@0gSBILANCIO"); - set_row (_i,"@86g%r", &totale); - set_row (_i++,"@112g%r", &tot_raf); + char app = ' '; + if (!_sbilancio_patr_gia_stampato) + { + _totale_patrimoniale = _totale_attivita - _totale_passivita; + _totale_patrim_raf = _totale_attiv_raf - _totale_passiv_raf; + if (_totale_patrimoniale != ZERO || _totale_patrim_raf != ZERO) + { + set_row (_i++,"@0g%c", app); + set_row (_i++,"@0gSALDO STATO PATRIMONIALE"); + set_row (_i,"@0gSBILANCIO (ATTIVO - PASSIVO)"); + //_totale_patrimoniale = _totale_attivita - _totale_passivita; + //_totale_patrim_raf = _totale_attiv_raf - _totale_passiv_raf; + set_row (_i,"@86g%r", &_totale_patrimoniale); + set_row (_i++,"@112g%r", &_totale_patrim_raf); + _totale_patrimoniale = 0; + _totale_patrim_raf = 0; + } } - if (_totale_patrimoniale != ZERO || _totale_patrim_raf != ZERO) + if (!_sbilancio_ordine) { - set_row (_i++,"@0g%c", app); - set_row (_i++,"@0gSALDO STATO PATRIMONIALE"); - set_row (_i,"@0gSBILANCIO (ATTIVO - PASSIVO)"); - //_totale_patrimoniale = _totale_attivita - _totale_passivita; - //_totale_patrim_raf = _totale_attiv_raf - _totale_passiv_raf; - set_row (_i,"@86g%r", &_totale_patrimoniale); - set_row (_i++,"@112g%r", &_totale_patrim_raf); - _totale_patrimoniale = 0; - _totale_patrim_raf = 0; - } + real totale = _totale_ordine_attivo - _totale_ordine_passivo; + real tot_raf = _totale_ordine_attivo_raf - _totale_ordine_passivo_raf; + if ((totale != ZERO || tot_raf != ZERO) && !_sbilancio_ordine) + { + set_row (_i++,"@0g%c", app); + set_row (_i++,"@0gSALDO CONTI D' ORDINE"); + set_row (_i,"@0gSBILANCIO"); + set_row (_i,"@86g%r", &totale); + set_row (_i++,"@112g%r", &tot_raf); + } + } } if (_sez_stamp == '5') { @@ -3951,8 +4032,15 @@ void CG1600_application::setta_righe(const char * titolo) long sottoc; TString numrom,numr; TString descr_let,descr_numr,descr_num,descr_sottoc,descr_classe; - bool stampa_classe = TRUE; + bool stampa_classe = TRUE; + TString lettera1 = "@1g)@3g%s"; + TString lettera2 = "@3g%s"; + TString numr1 = "@12g-@14g%s"; + TString numr2 = "@14g%s"; + TString num = "@15g)@18g%s"; + TString num2 = "@18g%s"; + _descr->set_width(40); sezione = bil->sez; lettera = bil->let; numr = bil->numr; @@ -3964,7 +4052,6 @@ void CG1600_application::setta_righe(const char * titolo) gruppo = atoi(bil->gruppo); conto = atoi(bil->conto); sottoc = atoi(bil->sottoc); - _descr_sez = descrizione_sezione(sezione); descr_let = descrizione_lettera(sezione,lettera); descr_numr = descrizione_numeroromano(sezione,lettera,numeror); descr_num = descrizione_numero(sezione,lettera,numeror,numero); @@ -4028,18 +4115,24 @@ void CG1600_application::setta_righe(const char * titolo) } if (lettera != ' ') { - set_row(_i,"@0g%c", bil->let); - set_row(_i++,"@1g)@3g%s", (const char*) descr_let); + set_row(_i,"@0g%c", bil->let); + *_descr = (const char*) descr_let; + setta_righe_descr(_descr,lettera1,lettera2); + //set_row(_i++,"@1g)@3g%s", (const char*) descr_let); } if (numrom != "") { set_row(_i,"@3g%8s", (const char*) numrom); - set_row(_i++,"@12g-@14g%s", (const char*) descr_numr); + *_descr = (const char*) descr_numr; + setta_righe_descr(_descr,numr1,numr2); + //set_row(_i++,"@12g-@14g%s", (const char*) descr_numr); } if (numero != 0) { set_row(_i,"@13g%s", bil->num); - set_row(_i++,"@15g)@18g%s", (const char*) descr_num); + *_descr = (const char*) descr_num; + setta_righe_descr(_descr,num,num2); + //set_row(_i++,"@15g)@18g%s", (const char*) descr_num); } } } @@ -4067,8 +4160,10 @@ void CG1600_application::setta_righe(const char * titolo) { if ((_sez_da_stamp=='1')||(_sez_da_stamp=='2')||(_sez_da_stamp=='9')) { - set_row(_i,"@0g%c", bil->let); - set_row(_i++,"@1g)@3g%s", (const char*) descr_let); + set_row(_i,"@0g%c", bil->let); + *_descr = (const char*) descr_let; + setta_righe_descr(_descr,lettera1,lettera2); + //set_row(_i++,"@1g)@3g%s", (const char*) descr_let); //_cont_let += 1; if (!_intera_struttura || (_intera_struttura && bil->gruppo[0] != 'Z')) { @@ -4080,12 +4175,16 @@ void CG1600_application::setta_righe(const char * titolo) if (numrom != "") { set_row(_i,"@3g%8s", (const char*) numrom); - set_row(_i++,"@12g-@14g%s", (const char*) descr_numr); + *_descr = (const char*) descr_numr; + setta_righe_descr(_descr,numr1,numr2); + //set_row(_i++,"@12g-@14g%s", (const char*) descr_numr); } if (numero != 0) { set_row(_i,"@13g%s", bil->num); - set_row(_i++,"@15g)@18g%s", (const char*) descr_num); + *_descr = (const char*) descr_num; + setta_righe_descr(_descr,num,num2); + //set_row(_i++,"@15g)@18g%s", (const char*) descr_num); } } } @@ -4096,7 +4195,9 @@ void CG1600_application::setta_righe(const char * titolo) if ((_sez_da_stamp=='1')||(_sez_da_stamp=='2')||(_sez_da_stamp=='9')) { set_row(_i,"@3g%8s", (const char*) numrom); - set_row(_i++,"@12g-@14g%s", (const char*) descr_numr); + *_descr = (const char*) descr_numr; + setta_righe_descr(_descr,numr1,numr2); + //set_row(_i++,"@12g-@14g%s", (const char*) descr_numr); //_cont_numr += 1; //_cont_numr = 1; if (!_intera_struttura || (_intera_struttura && bil->gruppo[0] != 'Z')) @@ -4108,7 +4209,9 @@ void CG1600_application::setta_righe(const char * titolo) if (numero != 0) { set_row(_i,"@13g%s", bil->num); - set_row(_i++,"@15g)@18g%s", (const char*) descr_num); + *_descr = (const char*) descr_num; + setta_righe_descr(_descr,num,num2); + //set_row(_i++,"@15g)@18g%s", (const char*) descr_num); } } } @@ -4118,7 +4221,9 @@ void CG1600_application::setta_righe(const char * titolo) if ((_sez_da_stamp=='1')||(_sez_da_stamp=='2')||(_sez_da_stamp=='9')) { set_row(_i,"@13g%s", bil->num); - set_row(_i++,"@15g)@18g%s", (const char*) descr_num); + *_descr = (const char*) descr_num; + setta_righe_descr(_descr,num,num2); + //set_row(_i++,"@15g)@18g%s", (const char*) descr_num); //_cont_num += 1; if (!_intera_struttura || (_intera_struttura && bil->gruppo[0] != 'Z')) _cont_gcs = 0; @@ -4175,7 +4280,15 @@ void CG1600_application::setta_righe_verifica() long sottoc; TString numrom,numr; TString descr_let,descr_numr,descr_num,descr_sottoc,descr_classe; + TString lettera1 = "@1g)@3g%s"; + TString lettera2 = "@3g%s"; + TString numr1 = "@8g)@10g%s"; + TString numr2 = "@10g%s"; + TString num = "@2g)@4g%s"; + TString num2 = "@4g%s"; + _descr->set_width(35); + sezione = bil->sez; lettera = bil->let; numr = bil->numr; @@ -4187,12 +4300,19 @@ void CG1600_application::setta_righe_verifica() conto = atoi(bil->conto); sottoc = atoi(bil->sottoc); tmcf = bil->tipocf; - _descr_sez = descrizione_sezione(sezione); descr_let = descrizione_lettera(sezione,lettera); descr_numr = descrizione_numeroromano(sezione,lettera,numeror); descr_num = descrizione_numero(sezione,lettera,numeror,numero); - if ((tmcf == 'C') || (tmcf == 'F')) - descr_sottoc = descr_sottoc_clifo(tmcf,sottoc); + if ((tmcf == 'C') || (tmcf == 'F')) + { + if (gruppo != 0 && conto != 0 && sottoc != 0) + { + TConto tc (gruppo,conto,sottoc,tmcf); + descr_sottoc = tc.descrizione(); + } + else + descr_sottoc = descrizione_sottoconto(gruppo,conto,sottoc); + } else descr_sottoc = descrizione_sottoconto(gruppo,conto,sottoc); @@ -4219,20 +4339,26 @@ void CG1600_application::setta_righe_verifica() if (lettera != '\0') { set_row(_i,"@0g%c", bil->let); - set_row(_i,"@1g)@3g%s", (const char*) descr_let); - set_row (_i++,"@48g!@81g!@114g!"); + *_descr = (const char*) descr_let; + setta_righe_descr_verifica(_descr,lettera1,lettera2); + //set_row(_i,"@1g)@3g%s", (const char*) descr_let); + //set_row (_i++,"@48g!@81g!@114g!"); } if (numrom != "") { set_row(_i,"@0g%8s", (const char*) numrom); - set_row(_i,"@8g)@10g%s", (const char*) descr_numr); - set_row (_i++,"@48g!@81g!@114g!"); + *_descr = (const char*) descr_numr; + setta_righe_descr_verifica(_descr,numr1,numr2); + //set_row(_i,"@8g)@10g%s", (const char*) descr_numr); + //set_row (_i++,"@48g!@81g!@114g!"); } if (numero != 0) { set_row(_i,"@0g%s", bil->num); - set_row(_i,"@2g)@4g%s", (const char*) descr_num); - set_row (_i++,"@48g!@81g!@114g!"); + *_descr = (const char*) descr_num; + setta_righe_descr_verifica(_descr,num,num2); + //set_row(_i,"@2g)@4g%s", (const char*) descr_num); + //set_row (_i++,"@48g!@81g!@114g!"); } } } @@ -4248,8 +4374,10 @@ void CG1600_application::setta_righe_verifica() if (_let_da_stamp != 'Z') { set_row(_i,"@0g%c", bil->let); - set_row(_i,"@1g)@3g%s", (const char*) descr_let); - set_row (_i++,"@48g!@81g!@114g!"); + *_descr = (const char*) descr_let; + setta_righe_descr_verifica(_descr,lettera1,lettera2); + //set_row(_i,"@1g)@3g%s", (const char*) descr_let); + //set_row (_i++,"@48g!@81g!@114g!"); //_cont_let += 1; if (!_intera_struttura || (_intera_struttura && bil->gruppo[0] != 'Z')) { @@ -4261,14 +4389,18 @@ void CG1600_application::setta_righe_verifica() if (numrom != "") { set_row(_i,"@0g%8s", (const char*) numrom); - set_row(_i,"@8g)@10g%s", (const char*) descr_numr); - set_row (_i++,"@48g!@81g!@114g!"); + *_descr = (const char*) descr_numr; + setta_righe_descr_verifica(_descr,numr1,numr2); + //set_row(_i,"@8g)@10g%s", (const char*) descr_numr); + //set_row (_i++,"@48g!@81g!@114g!"); } if (numero != 0) { set_row(_i,"@0g%s", bil->num); - set_row(_i,"@2g)@4g%s", (const char*) descr_num); - set_row (_i++,"@48g!@81g!@114g!"); + *_descr = (const char*) descr_num; + setta_righe_descr_verifica(_descr,num,num2); + //set_row(_i,"@2g)@4g%s", (const char*) descr_num); + //set_row (_i++,"@48g!@81g!@114g!"); } } } @@ -4284,8 +4416,10 @@ void CG1600_application::setta_righe_verifica() if (_let_da_stamp != 'Z') { set_row(_i,"@0g%8s", (const char*) numrom); - set_row(_i,"@8g)@10g%s", (const char*) descr_numr); - set_row (_i++,"@48g!@81g!@114g!"); + *_descr = (const char*) descr_numr; + setta_righe_descr_verifica(_descr,numr1,numr2); + //set_row(_i,"@8g)@10g%s", (const char*) descr_numr); + //set_row (_i++,"@48g!@81g!@114g!"); //_cont_numr += 1; //_cont_numr = 1; if (!_intera_struttura || (_intera_struttura && bil->gruppo[0] != 'Z')) @@ -4297,8 +4431,10 @@ void CG1600_application::setta_righe_verifica() if (numero != 0) { set_row(_i,"@0g%s", bil->num); - set_row(_i,"@2g)@4g%s", (const char*) descr_num); - set_row (_i++,"@48g!@81g!@114g!"); + *_descr = (const char*) descr_num; + setta_righe_descr_verifica(_descr,num,num2); + //set_row(_i,"@2g)@4g%s", (const char*) descr_num); + //set_row (_i++,"@48g!@81g!@114g!"); } } } @@ -4314,8 +4450,10 @@ void CG1600_application::setta_righe_verifica() if (_let_da_stamp != 'Z') { set_row(_i,"@0g%s", bil->num); - set_row(_i,"@2g)@4g%s", (const char*) descr_num); - set_row (_i++,"@48g!@81g!@114g!"); + *_descr = (const char*) descr_num; + setta_righe_descr_verifica(_descr,num,num2); + //set_row(_i,"@2g)@4g%s", (const char*) descr_num); + //set_row (_i++,"@48g!@81g!@114g!"); _cont_num += 1; _cont_gcs = 0; } @@ -4402,6 +4540,43 @@ void CG1600_application::setta_righe_verifica() } } } +} + +void CG1600_application::setta_righe_descr(TParagraph_string* str,const TString& formato,const TString& formato2) +{ + const char* r; + int i = 1; + + while ((r = str->get()) != NULL) + { + if (i == 1) + set_row (_i,formato, r); + else + if (i > 1) + set_row (_i,formato2,r); + _i++; + i++; + } +} + +void CG1600_application::setta_righe_descr_verifica(TParagraph_string* str,const TString& formato,const TString& formato2) +{ + const char* r; + int i = 1; + + while ((r = str->get()) != NULL) + { + if (i == 1) + set_row (_i,formato, r); + else + if (i > 1) + set_row (_i,formato2,r); + + set_row (_i,"@48g!@81g!@114g!"); + + _i++; + i++; + } } const char* CG1600_application::descrizione_sezione(char sezione) @@ -4727,6 +4902,7 @@ void CG1600_application::user_create() _anag = new TLocalisamfile (LF_ANAG); _pconti = new TLocalisamfile (LF_PCON); _clifo = new TLocalisamfile (LF_CLIFO); + _descr = new TParagraph_string ("",40); _tabivd = new TTable (TAB_IVD); _tabesc = new TTable (TAB_ESC); @@ -4745,7 +4921,8 @@ void CG1600_application::user_destroy() delete _unloc; delete _anag; delete _pconti; - delete _clifo; + delete _clifo; + delete _descr; } int cg1600 (int argc, char* argv[]) diff --git a/cg/cg1600.h b/cg/cg1600.h index 7374e465b..ee95be7ab 100755 --- a/cg/cg1600.h +++ b/cg/cg1600.h @@ -1,28 +1,28 @@ -#ifndef __CG1600_H -#define __CG1600_H - -#define TAB_ESC "ESC" -#define TAB_IVD "%IVD" - -#define F_CODDITTA 101 -#define F_RAGSOC 102 -#define F_DATASTAMPA 103 -#define F_TIPOBIL 104 -#define F_TIPOSTAMPA 105 -#define F_TIPOSTAMPA1 106 -#define F_DATALIM 107 -#define F_DATABILRAF 108 -#define F_STAMPAINT 109 -#define F_STAMPACOD 110 -#define F_STAMPAMOV 111 -#define F_COMPETENZA 112 -#define F_STAMPAMODULO 113 -#define F_DATAINI 114 -#define F_DATAFINE 115 -#define F_ANNOESE 116 -#define F_ANNORAFFR 117 -#define F_STAMPAMOVPROV 118 - -#endif // __CG1600_H - - +#ifndef __CG1600_H +#define __CG1600_H + +#define TAB_ESC "ESC" +#define TAB_IVD "%IVD" + +#define F_CODDITTA 101 +#define F_RAGSOC 102 +#define F_DATASTAMPA 103 +#define F_TIPOBIL 104 +#define F_TIPOSTAMPA 105 +#define F_TIPOSTAMPA1 106 +#define F_DATALIM 107 +#define F_DATABILRAF 108 +#define F_STAMPAINT 109 +#define F_STAMPACOD 110 +#define F_STAMPAMOV 111 +#define F_COMPETENZA 112 +#define F_STAMPAMODULO 113 +#define F_DATAINI 114 +#define F_DATAFINE 115 +#define F_ANNOESE 116 +#define F_ANNORAFFR 117 +#define F_STAMPAMOVPROV 118 + +#endif // __CG1600_H + + diff --git a/cg/cg1600a.uml b/cg/cg1600a.uml index 8a21e6ea3..dedfac2bb 100755 --- a/cg/cg1600a.uml +++ b/cg/cg1600a.uml @@ -1,173 +1,173 @@ -#include "cg1600.h" - -PAGE "" -1 -1 78 20 - -NUMBER F_CODDITTA 5 -BEGIN - PROMPT 4 1 "Ditta " - FLAGS "FRD" - USE LF_NDITTE KEY 1 - CHECKTYPE REQUIRED - INPUT CODDITTA F_CODDITTA - DISPLAY "Codice" CODDITTA - DISPLAY "Ragione sociale @50" RAGSOC - OUTPUT F_CODDITTA CODDITTA - OUTPUT F_RAGSOC RAGSOC -END - -STRING F_RAGSOC 50 -BEGIN - PROMPT 4 2 "Ragione sociale " - FLAGS "D" -END - -NUMBER F_ANNOESE 4 -BEGIN - PROMPT 4 5 "Anno esercizio " - USE ESC - INPUT CODTAB F_ANNOESE - DISPLAY "Anno" CODTAB - DISPLAY "Data inizio esercizio" D0 - DISPLAY "Data fine esercizio" D1 - OUTPUT F_ANNOESE CODTAB - FLAGS "RZ" - CHECKTYPE NORMAL -END - -NUMBER F_ANNORAFFR 4 -BEGIN - PROMPT 36 5 "Anno esercizio da raffrontare " - COPY USE F_ANNOESE - INPUT CODTAB F_ANNORAFFR - COPY DISPLAY F_ANNOESE - OUTPUT F_ANNORAFFR CODTAB - FLAGS "RZ" - CHECKTYPE NORMAL -END - -LIST F_TIPOBIL 22 -BEGIN - PROMPT 4 6 "Tipo bilancio " - ITEM "1|Bilancio scalare" - MESSAGE HIDE,F_TIPOSTAMPA1|RESET,F_TIPOSTAMPA1|SHOW,F_TIPOSTAMPA|K_SPACE,F_TIPOSTAMPA - MESSAGE SHOW,F_ANNORAFFR|SHOW,F_DATABILRAF - ITEM "2|Bilancio di verifica" - MESSAGE HIDE,F_TIPOSTAMPA|RESET,F_TIPOSTAMPA|SHOW,F_TIPOSTAMPA1|K_SPACE,F_TIPOSTAMPA1 - MESSAGE HIDE,F_ANNORAFFR|HIDE,F_DATABILRAF -END - -LIST F_TIPOSTAMPA 23 -BEGIN - PROMPT 4 7 "Tipo stampa " - ITEM "1|Per data limite" - MESSAGE HIDE,F_STAMPAMODULO|HIDE,F_DATAINI|HIDE,F_DATAFINE - MESSAGE RESET,F_STAMPAMODULO|RESET,F_DATAINI|RESET,F_DATAFINE - MESSAGE SHOW,F_DATALIM|SHOW,F_STAMPAINT|SHOW,F_STAMPAMOV - ITEM "2|All'ultima immissione" - MESSAGE HIDE,F_DATALIM|HIDE,F_STAMPAMODULO|HIDE,F_DATAINI|HIDE,F_DATAFINE - MESSAGE RESET,F_STAMPAMODULO|RESET,F_DATAINI|RESET,F_DATALIM|RESET,F_DATAFINE| - MESSAGE SHOW,F_STAMPAINT|SHOW,F_STAMPACOD|SHOW,F_STAMPAMOV -END - -LIST F_TIPOSTAMPA1 23 -BEGIN - PROMPT 4 7 "Tipo stampa1 " - ITEM "1|Per data " - MESSAGE HIDE,F_DATALIM - MESSAGE RESET,F_DATALIM - MESSAGE SHOW,F_STAMPAINT|SHOW,F_STAMPACOD|SHOW,F_STAMPAMOV - MESSAGE SHOW,F_DATAINI|SHOW,F_DATAFINE|SHOW,F_STAMPAMODULO - ITEM "2|All'ultima immissione" - MESSAGE HIDE,F_DATALIM|HIDE,F_DATAINI|HIDE,F_DATAFINE - MESSAGE RESET,F_DATAINI|RESET,F_DATALIM|RESET,F_DATAFINE - MESSAGE SHOW,F_STAMPAINT|SHOW,F_STAMPACOD|SHOW,F_STAMPAMOV|SHOW,F_STAMPAMODULO - MESSAGE COPY,F_TIPOSTAMPA -END - -DATE F_DATASTAMPA -BEGIN - PROMPT 4 4 "Data stampa " - FLAGS "A" -END - -TEXT 96 -BEGIN - PROMPT 4 9 "Dalla data competenza " -END - -TEXT 97 -BEGIN - PROMPT 40 9 "Alla data competenza " -END - -TEXT 98 -BEGIN - PROMPT 4 9 "Dalla data operazione " -END - -TEXT 99 -BEGIN - PROMPT 40 9 "Alla data operazione " -END -DATE F_DATALIM -BEGIN - PROMPT 4 9 "Data limite " -// VALIDATE NOT_EMPTY_FUNC -END - -DATE F_DATABILRAF -BEGIN - PROMPT 36 9 "Data bil. da raffrontare " -// VALIDATE NOT_EMPTY_FUNC -END - -DATE F_DATAINI -BEGIN - PROMPT 26 9 "" -// VALIDATE NOT_EMPTY_FUNC -END - -DATE F_DATAFINE -BEGIN - PROMPT 62 9 "" -// VALIDATE NOT_EMPTY_FUNC -END - -BOOLEAN F_STAMPAINT -BEGIN - PROMPT 4 11 "Stampa intera struttura" -END - -BOOLEAN F_STAMPACOD -BEGIN - PROMPT 41 11 "Non stampare cod. conti" -END - -BOOLEAN F_STAMPAMOV -BEGIN - PROMPT 4 12 "Non stampare mov. con saldo a 0" -END - -BOOLEAN F_STAMPAMOVPROV -BEGIN - PROMPT 41 12 "Stampa movimenti provvisori" -END - -BOOLEAN F_STAMPAMODULO -BEGIN - PROMPT 4 13 "Stampa su modulo stretto" -END - -BUTTON DLG_OK 9 2 -BEGIN - PROMPT -12 -1 "" -END - -BUTTON DLG_QUIT 9 2 -BEGIN - PROMPT -22 -1 "" -END - -ENDPAGE - -ENDMASK +#include "cg1600.h" + +PAGE "" -1 -1 78 20 + +NUMBER F_CODDITTA 5 +BEGIN + PROMPT 4 1 "Ditta " + FLAGS "FRD" + USE LF_NDITTE KEY 1 + CHECKTYPE REQUIRED + INPUT CODDITTA F_CODDITTA + DISPLAY "Codice" CODDITTA + DISPLAY "Ragione sociale @50" RAGSOC + OUTPUT F_CODDITTA CODDITTA + OUTPUT F_RAGSOC RAGSOC +END + +STRING F_RAGSOC 50 +BEGIN + PROMPT 4 2 "Ragione sociale " + FLAGS "D" +END + +NUMBER F_ANNOESE 4 +BEGIN + PROMPT 4 5 "Anno esercizio " + USE ESC + INPUT CODTAB F_ANNOESE + DISPLAY "Anno" CODTAB + DISPLAY "Data inizio esercizio" D0 + DISPLAY "Data fine esercizio" D1 + OUTPUT F_ANNOESE CODTAB + FLAGS "RZ" + CHECKTYPE NORMAL +END + +NUMBER F_ANNORAFFR 4 +BEGIN + PROMPT 36 5 "Anno esercizio da raffrontare " + COPY USE F_ANNOESE + INPUT CODTAB F_ANNORAFFR + COPY DISPLAY F_ANNOESE + OUTPUT F_ANNORAFFR CODTAB + FLAGS "RZ" + CHECKTYPE NORMAL +END + +LIST F_TIPOBIL 22 +BEGIN + PROMPT 4 6 "Tipo bilancio " + ITEM "1|Bilancio scalare" + MESSAGE HIDE,F_TIPOSTAMPA1|RESET,F_TIPOSTAMPA1|SHOW,F_TIPOSTAMPA|K_SPACE,F_TIPOSTAMPA + MESSAGE SHOW,F_ANNORAFFR|SHOW,F_DATABILRAF + ITEM "2|Bilancio di verifica" + MESSAGE HIDE,F_TIPOSTAMPA|RESET,F_TIPOSTAMPA|SHOW,F_TIPOSTAMPA1|K_SPACE,F_TIPOSTAMPA1 + MESSAGE HIDE,F_ANNORAFFR|HIDE,F_DATABILRAF +END + +LIST F_TIPOSTAMPA 23 +BEGIN + PROMPT 4 7 "Tipo stampa " + ITEM "1|Per data limite" + MESSAGE HIDE,F_STAMPAMODULO|HIDE,F_DATAINI|HIDE,F_DATAFINE + MESSAGE RESET,F_STAMPAMODULO|RESET,F_DATAINI|RESET,F_DATAFINE + MESSAGE SHOW,F_DATALIM|SHOW,F_STAMPAINT|SHOW,F_STAMPAMOV + ITEM "2|All'ultima immissione" + MESSAGE HIDE,F_DATALIM|HIDE,F_STAMPAMODULO|HIDE,F_DATAINI|HIDE,F_DATAFINE + MESSAGE RESET,F_STAMPAMODULO|RESET,F_DATAINI|RESET,F_DATALIM|RESET,F_DATAFINE| + MESSAGE SHOW,F_STAMPAINT|SHOW,F_STAMPACOD|SHOW,F_STAMPAMOV +END + +LIST F_TIPOSTAMPA1 23 +BEGIN + PROMPT 4 7 "Tipo stampa1 " + ITEM "1|Per data " + MESSAGE HIDE,F_DATALIM + MESSAGE RESET,F_DATALIM + MESSAGE SHOW,F_STAMPAINT|SHOW,F_STAMPACOD|SHOW,F_STAMPAMOV + MESSAGE SHOW,F_DATAINI|SHOW,F_DATAFINE|SHOW,F_STAMPAMODULO + ITEM "2|All'ultima immissione" + MESSAGE HIDE,F_DATALIM|HIDE,F_DATAINI|HIDE,F_DATAFINE + MESSAGE RESET,F_DATAINI|RESET,F_DATALIM|RESET,F_DATAFINE + MESSAGE SHOW,F_STAMPAINT|SHOW,F_STAMPACOD|SHOW,F_STAMPAMOV|SHOW,F_STAMPAMODULO + MESSAGE COPY,F_TIPOSTAMPA +END + +DATE F_DATASTAMPA +BEGIN + PROMPT 4 4 "Data stampa " + FLAGS "A" +END + +TEXT 96 +BEGIN + PROMPT 4 9 "Dalla data competenza " +END + +TEXT 97 +BEGIN + PROMPT 40 9 "Alla data competenza " +END + +TEXT 98 +BEGIN + PROMPT 4 9 "Dalla data operazione " +END + +TEXT 99 +BEGIN + PROMPT 40 9 "Alla data operazione " +END +DATE F_DATALIM +BEGIN + PROMPT 4 9 "Data limite " +// VALIDATE NOT_EMPTY_FUNC +END + +DATE F_DATABILRAF +BEGIN + PROMPT 36 9 "Data bil. da raffrontare " +// VALIDATE NOT_EMPTY_FUNC +END + +DATE F_DATAINI +BEGIN + PROMPT 26 9 "" +// VALIDATE NOT_EMPTY_FUNC +END + +DATE F_DATAFINE +BEGIN + PROMPT 62 9 "" +// VALIDATE NOT_EMPTY_FUNC +END + +BOOLEAN F_STAMPAINT +BEGIN + PROMPT 4 11 "Stampa intera struttura" +END + +BOOLEAN F_STAMPACOD +BEGIN + PROMPT 41 11 "Non stampare cod. conti" +END + +BOOLEAN F_STAMPAMOV +BEGIN + PROMPT 4 12 "Non stampare mov. con saldo a 0" +END + +BOOLEAN F_STAMPAMOVPROV +BEGIN + PROMPT 41 12 "Stampa movimenti provvisori" +END + +BOOLEAN F_STAMPAMODULO +BEGIN + PROMPT 4 13 "Stampa su modulo stretto" +END + +BUTTON DLG_OK 9 2 +BEGIN + PROMPT -12 -1 "" +END + +BUTTON DLG_QUIT 9 2 +BEGIN + PROMPT -22 -1 "" +END + +ENDPAGE + +ENDMASK diff --git a/cg/cg3200.cpp b/cg/cg3200.cpp index f12e05d07..87553e188 100755 --- a/cg/cg3200.cpp +++ b/cg/cg3200.cpp @@ -47,7 +47,7 @@ class CG3200_application : public TPrintapp TDate _data_ini,_data_fine,_data_finese,_data_finesesucc,_ultima_data_reg; TDate _datareg,_datadoc,_data_inizioese,_datareg_stampa; int _cur1,_gruppo,_conto,_numcarat,_stampanum,_numivd; - int _numrig,_natdoc,_tipo,_tipostampa,_g_prec,_c_prec; + int _numrig,_natdoc,_tipo,_tipostampa,_g_prec,_c_prec,_numrivd_int; real _progredare,_progreavere,_totprogre_dare_al,_totprogre_avere_al; real _totprogre_dare,_totprogre_avere,_importo; real _riporto_dare,_riporto_avere,_riporto_parziale_dare,_riporto_parziale_avere; @@ -57,9 +57,8 @@ class CG3200_application : public TPrintapp TString _ragsoc,_indulc,_civulc,_capulc,_com,_prov,_comulc; long _codice_ditta,_s_prec; TString _tipodoc,_codcaus,_descrcaus,_descrdociva,_regiva; - TString16 _lettivd; - int _sezivd; - TString _descrizione,_sezione,_numdoc,_descrizionemov,_numrivd; + char _sezivd,_lettivd; + TString _descrizione,_sezione,_numdoc,_descrizionemov,_numrivd,_descr; TString _dataregs, _datadocs,_gruppocontr,_contocontr,_sottocontocontr; bool _stampaprogre,_stampatotiva,_stampatot,_prima_volta,_stampa_mov_prov; @@ -104,12 +103,14 @@ public: void fai_stampa198(); void stampa_totali132(); void stampa_totali198(); - void stampa_totaliiva(); + void stampa_totaliiva(); + void ricerca_classe_IV(bool scelta); void data_fine_esercizio(int); const char* descrizione_gruppo(); const char* descrizione_conto(); const char* descrizione_gruppo_clifo(); - const char* descrizione_conto_clifo(); + const char* descrizione_conto_clifo(); + const char* descrizione_classe(char,char,int,int); bool almeno_un_record(); void ricerca_dati_ditta(); void conto(); @@ -328,13 +329,13 @@ void CG3200_application::saldi_zero() long sottoc = atol(rmov.get(RMV_SOTTOCONTO)); if ((gruppo == _gruppo)&&(conto == _conto)&&(sottoc == _sottoc)) - { + { if (sezione == 'D') saldo_dare += importo; else if (sezione == 'A') saldo_avere += importo; - } - else break; + } + else break; rmov.next(); } rmov.readat(record); @@ -855,11 +856,15 @@ void CG3200_application::ricerca_regiva() } bool CG3200_application::preprocess_print(int file, int counter) -{ - _g_prec = 0; - _c_prec = 0; - _s_prec = 0; - return TRUE; +{ + if (file == LF_SALDI) + { + _g_prec = 0; + _c_prec = 0; + _s_prec = 0; + } + + return TRUE; } bool CG3200_application::set_print(int) @@ -1119,8 +1124,8 @@ void CG3200_application::crea_intestazione() set_header (6, (const char *) sep); set_header (7,"Operazione@19gDocumento@117gContro"); set_header (8,"Data"); - if (_stampanum < 3) - set_header (8,"@11gnumero"); + if (_stampanum < 3) + set_header (8,"@11gnumero"); set_header (8,"@19gData@30gNumero@38gCod.Causale@61gDescrizione@90gDare@106gAvere@117gPartita"); sep.fill('-'); set_header (9, (const char *) sep); @@ -1130,10 +1135,10 @@ void CG3200_application::crea_intestazione() sep1.fill('-'); //Stampa 198 - (sep1(198)) set_header (6,"@1g%s", (const char *) sep1); set_header (7,"Operazione@19gData@30gNumero@172gContro@185gReg@193gNumero"); - set_header (8,"Data"); - if (_stampanum < 3) - set_header (8,"@11gnumero"); - set_header (8,"@19gDocumento@38gCod.Causale@68gDescrizione@108gDare@124gAvere@136gSaldo progress.@154gSaldo movim.@172gPartita@185gIva@189gProtocollo"); + set_header (8,"Data"); + if (_stampanum < 3) + set_header (8,"@11gnumero"); + set_header (8,"@19gDocumento@38gCod.Causale@68gDescrizione@108gDare@124gAvere@136gSaldo progress.@154gSaldo movim.@172gPartita@185gIva@189gProtocollo"); sep1.fill('-'); set_header (9,"@1g%s", (const char *) sep1); } @@ -1373,35 +1378,35 @@ void CG3200_application::calcola_progressivi() progavere_prec = saldo; } } - else - { + } + } // FOR //Se il saldo dell'esercizio attuale non e' diverso da zero, allora il saldo // finale dell'esercizio precedente devo calcolarmelo tenendo conto dell'indbil - - if ((_indbil == 1) || (_indbil == 2) || (_indbil == 5)) - { - const TRecnotype pos = saldi.recno(); - saldo = _sld.saldofin_esprec(_anno_corrente,_gruppo,_conto,_sottoc); - saldi.readat(pos); + + if (_annomsk != 0 && saldo == ZERO) + { + if ((_indbil == 1) || (_indbil == 2) || (_indbil == 5)) + { + const TRecnotype pos = saldi.recno(); + saldo = _sld.saldofin_esprec(_anno_corrente,_gruppo,_conto,_sottoc); + saldi.readat(pos); - if (saldo> ZERO) - { - progredare_eseprec = saldo;// + pdarescap + pdarep; - progdare_prec = saldo; + if (saldo> ZERO) + { + progredare_eseprec = saldo;// + pdarescap + pdarep; + progdare_prec = saldo; // progreavere_eseprec = paverescap + paverep; - } - else if (saldo < ZERO) - { - // progredare_eseprec = pdarescap + pdarep; - saldo = -saldo; - progreavere_eseprec = saldo;// + paverescap + paverep; - progavere_prec = saldo; - } - } } + else if (saldo < ZERO) + { + // progredare_eseprec = pdarescap + pdarep; + saldo = -saldo; + progreavere_eseprec = saldo;// + paverescap + paverep; + progavere_prec = saldo; + } } - } // FOR + } // saldi->readat(rec); @@ -1461,7 +1466,8 @@ void CG3200_application::ricerca_clifo() TString ragsoc,paiv,cofi,indcf,capcf,ptel,tel,statocf,comcf,dencom,provcom,dep; TLocalisamfile clifo(LF_CLIFO); TLocalisamfile pconti(LF_PCON); - TString16 dataini,datafine; + TString16 dataini,datafine; + TString descriz,descriz2; int numrivd; clifo.setkey(1); @@ -1471,8 +1477,9 @@ void CG3200_application::ricerca_clifo() clifo.read(); if (clifo.bad()) clifo.zero(); - - ragsoc = clifo.get(CLI_RAGSOC); + TConto tc (_gruppo,_conto,_sottoc,_tmcf); + + ragsoc = tc.descrizione(); paiv = clifo.get(CLI_PAIV); cofi = clifo.get(CLI_COFI); indcf = clifo.get(CLI_INDCF); @@ -1494,33 +1501,45 @@ void CG3200_application::ricerca_clifo() pconti.zero(); pconti.put(PCN_GRUPPO, _gruppo); pconti.put(PCN_CONTO, _conto); - pconti.put(PCN_SOTTOCONTO, _sottoc); + //pconti.put(PCN_SOTTOCONTO, _sottoc); pconti.read(); //_sezivd = pconti.get_char(PCN_SEZIVD); - _sezivd = pconti.get_int(PCN_SEZIVD); - _lettivd = pconti.get(PCN_LETTIVD); + _sezivd = pconti.get_char(PCN_SEZIVD); + _lettivd = pconti.get_char(PCN_LETTIVD); numrivd = pconti.get_int(PCN_NUMRIVD); _numrivd = itor(numrivd); _numivd = pconti.get_int(PCN_NUMIVD); - _tabivd->curr().zero(); - //dep.format ("%c%c%04d%2d",_sezivd,_lettivd,numrivd,_numivd); - dep.format ("%d%s%04d%2d", _sezivd, (const char *) _lettivd,numrivd,_numivd); - _tabivd->curr().put("CODTAB", (const char*) dep); - _tabivd->read(); - if (_tabivd->bad()) - _tabivd->zero(); - TString descriz = _tabivd->curr().get("S0"); + descriz = descrizione_classe(_sezivd,_lettivd,numrivd,_numivd); + + if (_numivd != 0) //Ora devo stampare la descrizione del livello della + { //classe immediatamente precedente a quello appena + if (_numrivd != "") //stampato + descriz2 = descrizione_classe(_sezivd,_lettivd,_numrivd_int,0); + else + descriz2 = descrizione_classe(_sezivd,_lettivd,0,0); + } + else + if (_numrivd != "") + descriz2 = descrizione_classe(_sezivd,_lettivd,0,0); + else + descriz2 = ""; set_header(3,"@27g%-30s",(const char*) descrizione_gruppo()); set_header(3,"@59g%-30s",(const char*) descrizione_conto()); set_header(3, "@91g%-30s",(const char*) ragsoc); - set_header(4, "Classe@8g%s", (const char*) _lettivd); + set_header(4, "Classe@8g%c", _lettivd); set_header(4, "@10g%-8s", (const char*) _numrivd); if (_numivd != 0) set_header(4, "@19g%2d", _numivd); - set_header(4,"@23g%-50s",(const char*) descriz); - + if (descriz2 != "") + { + set_header(4,"@23g%-50s",(const char*) descriz2); + set_header(4,"@80g%-50s",(const char*) descriz); + } + else + set_header(4,"@23g%-50s",(const char*) descriz); + dataini = _data_ini.string(); datafine = _data_fine.string(); @@ -1531,15 +1550,15 @@ void CG3200_application::ricerca_clifo() } else { - set_header (5, "Periodo di competenza@23g%s", (const char*) dataini); - set_header (5, "@35g%s", (const char*) datafine); + set_header (5, "Comp. da@9g%s", (const char*) dataini); + set_header (5, "@20ga@22g%s", (const char*) datafine); } - set_header (5, "@34g%-11s",(const char*) paiv); - set_header (5, "@46g%-16s",(const char*) cofi); - set_header (5, "@63g%-25s",(const char*) indcf); - set_header (5, "@89g%-5s",(const char*) capcf); - set_header (5, "@95g%-30s",(const char*) dencom); + set_header (5, "@33gP.I.@37g%-11s",(const char*) paiv); + set_header (5, "@49gCF@52g%-16s",(const char*) cofi); + set_header (5, "@69g%-25s",(const char*) indcf); + set_header (5, "@95g%-5s",(const char*) capcf); + set_header (5, "@101g%-24s",(const char*) dencom); set_header (5,"@126g%-5s",(const char*) provcom); if (_numcarat == 2) @@ -1551,47 +1570,67 @@ void CG3200_application::ricerca_clifo() // Se la ricerca selezionata sulla maschera e' per gruppo, conto, sottoconto // ricerca i corrispondenti su PCON, con relativa IV direttiva CEE - -void CG3200_application::ricerca_gruppo() -{ - TString80 descr,descriz,dep; - int numrivd; - TString dataini,datafine; - TLocalisamfile pconti(LF_PCON); +void CG3200_application::ricerca_classe_IV(bool scelta) +{ + TLocalisamfile pconti(LF_PCON); + pconti.setkey(1); pconti.zero(); pconti.put(PCN_GRUPPO, _gruppo); - pconti.put(PCN_CONTO, _conto); - pconti.put(PCN_SOTTOCONTO, _sottoc); + pconti.put(PCN_CONTO, _conto); + if (scelta) + pconti.put(PCN_SOTTOCONTO, _sottoc); pconti.read(); //_sezivd = pconti.get_char(PCN_SEZIVD); - _sezivd = pconti.get_int(PCN_SEZIVD); - _lettivd = pconti.get(PCN_LETTIVD); - numrivd = pconti.get_int(PCN_NUMRIVD); - _numrivd = itor(numrivd); - _numivd = pconti.get_int(PCN_NUMIVD); - descr = pconti.get(PCN_DESCR); - - _tabivd->zero(); - //dep.format ("%c%c%04d%2d",_sezivd,_lettivd, numrivd,_numivd); - dep.format ("%d%s%04d%2d",_sezivd,(const char *) _lettivd, numrivd,_numivd); - _tabivd->put("CODTAB", (const char*) dep); - _tabivd->read(); - if (_tabivd->bad()) - _tabivd->zero(); - descriz = _tabivd->get("S0"); + _sezivd = pconti.get_char(PCN_SEZIVD); + _lettivd = pconti.get_char(PCN_LETTIVD); + _numrivd_int = pconti.get_int (PCN_NUMRIVD); + _numrivd = itor(_numrivd_int); + _numivd = pconti.get_int (PCN_NUMIVD); + _descr = pconti.get (PCN_DESCR); +} + +void CG3200_application::ricerca_gruppo() +{ + TString80 descr,descriz,descriz2,dep; + TString dataini,datafine; + + ricerca_classe_IV (TRUE); //Esiste a livello di sottoconto + + if (_sezivd == '0') //Non esiste a livello di sottoconto + ricerca_classe_IV (FALSE); //Allora la cerco a livello di conto + + descriz = descrizione_classe(_sezivd,_lettivd,_numrivd_int,_numivd); + if (_numivd != 0) //Ora devo stampare la descrizione del livello della + { //classe immediatamente precedente a quello appena + if (_numrivd != "") //stampato + descriz2 = descrizione_classe(_sezivd,_lettivd,_numrivd_int,0); + else + descriz2 = descrizione_classe(_sezivd,_lettivd,0,0); + } + else + if (_numrivd != "") + descriz2 = descrizione_classe(_sezivd,_lettivd,0,0); + else + descriz2 = ""; set_header(3,"@27g%-30s",(const char*) descrizione_gruppo()); set_header(3,"@59g%-30s",(const char*) descrizione_conto()); - set_header(3,"@91g%-30s",(const char*) descr); - set_header(4, "@0gClasse@12g%s",(const char*) _lettivd); + set_header(3,"@91g%-30s",(const char*) _descr); + set_header(4, "@0gClasse@12g%c", _lettivd); set_header(4, "@14g%-8s",(const char*) _numrivd); if (_numivd != 0) - set_header(4, "@23g%d", _numivd); - set_header(4,"@27g%-50s",(const char*) descriz); - + set_header(4, "@23g%d", _numivd); + if (descriz2 != "") + { + set_header(4,"@27g%-50s",(const char*) descriz2); + set_header(4,"@80g%-50s",(const char*) descriz); + } + else + set_header(4,"@27g%-50s",(const char*) descriz); + dataini = _data_ini.string(); datafine = _data_fine.string(); @@ -1607,6 +1646,40 @@ void CG3200_application::ricerca_gruppo() } } +const char* CG3200_application::descrizione_classe(char sezione, char lettera, int numr, int numero) +{ + TTable tabivd(TAB_IVD); + TString dep,dep2; + + tabivd.zero(); + if (numr == 0 && numero == 0) + dep = format("%c%c",sezione,lettera); + else + if (numero == 0) + { + if (numr != 0) + dep = format("%1c%1c%04d",sezione, lettera, numr); + else + dep = format("%c%c ",sezione,lettera); + } + else + { + if (numr != 0) + dep = format("%1c%1c%04d%02d",sezione, lettera, numr,numero); + else + dep = format("%c%c %02d",sezione,lettera,numero); + } + + tabivd.put("CODTAB", dep); + tabivd.read(); + dep2 = tabivd.get("CODTAB"); + if (dep == dep2) + tmp = tabivd.get("S0"); + else + tmp = ""; + return (tmp); +} + //Ricerca la descrizione relativa al gruppo da stampare const char* CG3200_application::descrizione_gruppo() diff --git a/cg/cg3200.h b/cg/cg3200.h index c10c4c8c5..636622b41 100755 --- a/cg/cg3200.h +++ b/cg/cg3200.h @@ -1,41 +1,42 @@ -#ifndef __CG3200_H -#define __CG3200_H - -#define TAB_IVD "%IVD" -#define TAB_TPD "%TPD" -#define TAB_REG "REG" -#define TAB_ESC "ESC" - -#define F_CODDITTA 101 -#define F_RAGSOC 102 -#define F_TIPOCF 103 -#define F_GRUPPOINI 104 -#define F_GRUPPOFINE 105 -#define F_CONTOINI 106 -#define F_CONTOFINE 107 -#define F_SOTTOCINI_CONTO 108 -#define F_SOTTOCFINE_CONTO 109 -#define F_SOTTOCINI_CLIENTE 110 -#define F_SOTTOCFINE_CLIENTE 111 -#define F_SOTTOCINI_FORN 112 -#define F_SOTTOCFINE_FORN 113 -#define F_DESCRINI_CONTO 114 -#define F_DESCRFINE_CONTO 115 -#define F_DESCRINI_CLIENTE 116 -#define F_DESCRFINE_CLIENTE 117 -#define F_DESCRINI_FORN 118 -#define F_DESCRFINE_FORN 119 -#define F_DATAINI 120 -#define F_DATAFINE 121 -#define F_STAMPANUM 122 -#define F_STAMPAPROGRE 123 -#define F_STAMPATOTIVA 124 -#define F_TIPOSTAMPA 125 -#define F_STAMPAMOVPROV 126 -#define F_MEMORIZZA 127 -#define F_NUMCARAT 128 -#define F_NUMMAST 129 -#define F_ANNO 130 -#define F_FORMATO 131 - -#endif // __CG3200_H +#ifndef __CG3200_H +#define __CG3200_H + +#define TAB_IVD "%IVD" +#define TAB_TPD "%TPD" +#define TAB_REG "REG" +#define TAB_ESC "ESC" + +#define F_CODDITTA 101 +#define F_RAGSOC 102 +#define F_TIPOCF 103 +#define F_GRUPPOINI 104 +#define F_GRUPPOFINE 105 +#define F_CONTOINI 106 +#define F_CONTOFINE 107 +#define F_SOTTOCINI_CONTO 108 +#define F_SOTTOCFINE_CONTO 109 +#define F_SOTTOCINI_CLIENTE 110 +#define F_SOTTOCFINE_CLIENTE 111 +#define F_SOTTOCINI_FORN 112 +#define F_SOTTOCFINE_FORN 113 +#define F_DESCRINI_CONTO 114 +#define F_DESCRFINE_CONTO 115 +#define F_DESCRINI_CLIENTE 116 +#define F_DESCRFINE_CLIENTE 117 +#define F_DESCRINI_FORN 118 +#define F_DESCRFINE_FORN 119 +#define F_DATAINI 120 +#define F_DATAFINE 121 +#define F_STAMPANUM 122 +#define F_STAMPAPROGRE 123 +#define F_STAMPATOTIVA 124 +#define F_TIPOSTAMPA 125 +#define F_STAMPAMOVPROV 126 +#define F_MEMORIZZA 127 +#define F_NUMCARAT 128 +#define F_NUMMAST 129 +#define F_ANNO 130 +#define F_FORMATO 131 + +#endif // __CG3200_H + diff --git a/cg/cg4400.cpp b/cg/cg4400.cpp index c2355968a..b08c012cd 100755 --- a/cg/cg4400.cpp +++ b/cg/cg4400.cpp @@ -617,6 +617,7 @@ bool CG4400_application::controlla_mov() for (mov.first(); !mov.eof(); mov.next()) { TString16 reg = mov.get(MOV_REG); + if (reg.empty()) continue; TDate datareg = mov.get_date(MOV_DATAREG); if (_stampa_tutti_i_registri) cerca_reg (reg, tipo, udata); @@ -1053,7 +1054,11 @@ bool CG4400_application::compila_reg(const TMask& m) //_tot_dare = tab_reg.get_real ("R1") //_tot_avere = tab_reg.get_real ("R2"); if (_tipo_stampa != 3) - _data_da = _tabreg->get_date ("D3"); + { + _data_da = _tabreg->get_date ("D3"); + if (!_data_da.ok()) + _data_da = format("01/01/%4d", _annoes); + } if ( _tipo_stampa == 1 || _tipo_stampa == 4 ) if ( _data_a <= _data_da) { @@ -1061,10 +1066,10 @@ bool CG4400_application::compila_reg(const TMask& m) warning_box ("La data specificata deve essere superiore al %s (ultima data di stampa specificata sul registro)", (const char*)datas); return FALSE; } - //_stampa_intesta = _tabreg->get_bool ("B9"); - _codatt = _tabreg->get("S8"); - _attivita = desc_attivita(_codatt); - _desc_lib = _tabreg->get ("S0"); + _stampa_ind_ditta = _tabreg->get_bool ("B9"); + _codatt = _tabreg->get("S8"); + _attivita = desc_attivita(_codatt); + _desc_lib = _tabreg->get ("S0"); } else { @@ -1498,7 +1503,7 @@ bool CG4400_application::set_print(int n) giorni_del_mese = primo.day(); } _data_a=format("%02d/%02d/%4d",giorni_del_mese,_fino_a_mese,_annoes); - // NB data_da viene letta nella preprocess_page + // NB data_da viene letta nella compila_reg } if (_tipo_stampa == 2) compila_lib(); @@ -1553,28 +1558,32 @@ void CG4400_application::stampa_registri_IVA(const TMask& m) if ( tipo == 1 || tipo == 2 ) //registro iva { _tipo_reg = _tabreg->get_int("I0"); + _codreg = codtab.mid(4,3); _corrispettivi = _tabreg->get_bool("B0"); if (_tipo_stampa != 3) - _data_da = _tabreg->get_date("D3"); - _pagine_stampate = _tabreg->get_int("I1"); - _codreg = codtab.mid(4,3); - _codatt = _tabreg->get("S8"); - _attivita = desc_attivita(_codatt); - _desc_lib = _tabreg->get ("S0"); + { + _data_da = _tabreg->get_date("D3"); + if (!_data_da.ok()) //e' la prima volta che stampo + _data_da = format("01/01/%4d", _annoes); + } + if (_tipo_stampa == 1 || _tipo_stampa == 4) + if (_data_a <= _data_da) + warning_box("Il registro %s e' gia' stato stampato come bollato di %s", (const char*) _codreg, itom(_fino_a_mese)); + _pagine_stampate = _tabreg->get_int("I1"); + _codatt = _tabreg->get("S8"); + _attivita = desc_attivita(_codatt); + _desc_lib = _tabreg->get ("S0"); + _stampa_ind_ditta = _tabreg->get_bool ("B9"); //_primast = get_page_number(); - //if (!_mov_empty ) - // printer().formfeed(); _cur->set_filterfunction(NULL); _cur->set_filterfunction(filter_func); // Vado a vedere se ci sono movimenti (*_cur) = 0L; const long items = _cur->items(); if (items > 0) - { //set_page_number(_u_stampata + 1); print(); - if (_tipo_stampa != 3) aggiorna_reg(); - } + if (_tipo_stampa != 3) aggiorna_reg(); } } } @@ -1714,29 +1723,26 @@ void CG4400_application::preprocess_header() TString riga(_stampa_width); TString data; - //if (_tipo_stampa != 3) //cioe' si tratta di una stampa definitiva - //{ if ( (_tipo_stampa == 1) || (_tipo_stampa == 4) ) data.format("%s %s %d", (const char*)"mese di", itom(_datareg.month()), _datareg.year()); else if (_tipo_stampa == 2) data.format("%s %s %d", (const char*)"mese di", itom(_fino_a_mese), _annoes); - //} -else //stampa di prova - //data = _data_da.string(); - data.format("%s %s %d", (const char*)"mese di", itom(_data_da.month()), _annoes); + else //stampa di prova + data.format("%s %s %d", (const char*)"mese di", itom(_data_da.month()), _annoes); reset_header(); - if (_tipo_stampa == 2) - { + if (_tipo_stampa != 3) if (_stampa_ind_ditta) r = stampa_intestazione(); + + if (_tipo_stampa == 2) + { long num = _u_stampata + 1; set_header(r++, "@94gProgr.Studio %ld@114gProgr.Utente @#", num); } - else - r = stampa_intestazione(); + set_header(r, "Registro IVA: %s %s %s Attivita\' %s %s", (const char *) _codreg, (const char *) _desc_lib, (const char *) data, (const char *) _codatt, diff --git a/cg/cg5200.cpp b/cg/cg5200.cpp index eb5076412..773292d52 100755 --- a/cg/cg5200.cpp +++ b/cg/cg5200.cpp @@ -130,6 +130,7 @@ public: void add_r(int,int,real&,real&,real&,char,real&,real&, real&,real&,TDate&,long,real&,real&,real&); void compilasheet(); + void disable_all(); bool fai_filtro(); TMask* main_mask() const {return _msk;} TSheet_field& ss() const { return (TSheet_field&)_msk->field(F_SHEET_SALDI);} @@ -267,7 +268,19 @@ bool sottoc_handler(TMask_field& f, KEY key) clifo.setkey(1); if (clifo.read(_isequal, _nolock) == NOERR) { - TString rs = clifo.get(CLI_RAGSOC); + TString rs = clifo.get(CLI_RAGSOC); + char tipoa = clifo.get_char("TIPOAPER"); + + if (tipoa == 'F') + { + TString80 cognome, nome; + cognome = rs.mid(0,30); + nome = rs.mid(30,20); + cognome.trim(); nome.trim(); + + rs = cognome; + rs << " " << nome; + } f.mask().set(F_DESCR_CLIENTE, rs); f.mask().set(F_DESCR_FORN, rs); f.mask().stop_run(K_AUTO_ENTER); @@ -304,6 +317,7 @@ bool CG5200_application::user_create() _msk->set_handler(F_SOTTOCONTO, sottoc_handler); _msk->set_handler(F_SOTTOC_CLIENTE, sottoc_handler); _msk->set_handler(F_SOTTOC_FORN, sottoc_handler); + disable_all(); _pcon = new TLocalisamfile(LF_PCON); _clifo = new TLocalisamfile(LF_CLIFO); _rel = new TRelation(LF_PCON); @@ -314,6 +328,12 @@ bool CG5200_application::user_create() return TRUE; } +void CG5200_application::disable_all() +{ + for (int i = 0; i < 17; i++) + ss().enable_column(i,FALSE); +} + bool CG5200_application::user_destroy() { delete _msk; diff --git a/cg/cg5200.h b/cg/cg5200.h index 84c459698..6655ced05 100755 --- a/cg/cg5200.h +++ b/cg/cg5200.h @@ -1,11 +1,11 @@ -#define F_ANNO 101 -#define F_TIPOCF 102 -#define F_GRUPPO 103 -#define F_CONTO 104 -#define F_SOTTOCONTO 105 -#define F_DESCR_CONTO 106 -#define F_SOTTOC_CLIENTE 107 -#define F_DESCR_CLIENTE 108 -#define F_SOTTOC_FORN 109 -#define F_DESCR_FORN 110 -#define F_SHEET_SALDI 111 +#define F_ANNO 101 +#define F_TIPOCF 102 +#define F_GRUPPO 103 +#define F_CONTO 104 +#define F_SOTTOCONTO 105 +#define F_DESCR_CONTO 106 +#define F_SOTTOC_CLIENTE 107 +#define F_DESCR_CLIENTE 108 +#define F_SOTTOC_FORN 109 +#define F_DESCR_FORN 110 +#define F_SHEET_SALDI 111 diff --git a/cg/cg5200a.uml b/cg/cg5200a.uml index 6e492fd4f..116a71ca1 100755 --- a/cg/cg5200a.uml +++ b/cg/cg5200a.uml @@ -47,6 +47,7 @@ BEGIN DISPLAY "Gruppo" GRUPPO DISPLAY "Descrizione@50" DESCR OUTPUT F_GRUPPO GRUPPO + //OUTPUT F_DESCR_CONTO DESCR FLAGS "R" END @@ -64,9 +65,15 @@ BEGIN OUTPUT F_CONTO CONTO OUTPUT F_GRUPPO GRUPPO OUTPUT F_TIPOCF TMCF + //OUTPUT F_DESCR_CLIENTE DESCR + //OUTPUT F_DESCR_FORN DESCR + //OUTPUT F_DESCR_CONTO DESCR + FLAGS "R" CHECKTYPE NORMAL WARNING "Conto inesistente o mancante" + //MESSAGE DIRTY,F_SOTTOCONTO|DIRTY,F_SOTTOC_CLIENTE|DIRTY,F_SOTTOC_FORN + //MESSAGE DIRTY,F_DESCR_CONTO|DIRTY,F_DESCR_CLIENTE|DIRTY,F_DESCR_FORN END NUMBER F_SOTTOCONTO 6 @@ -85,8 +92,15 @@ BEGIN OUTPUT F_SOTTOCONTO SOTTOCONTO OUTPUT F_GRUPPO GRUPPO OUTPUT F_CONTO CONTO + //OUTPUT F_DESCR_CONTO DESCR + //OUTPUT F_DESCR_CLIENTE DESCR + //OUTPUT F_DESCR_FORN DESCR + //CHECKTYPE NORMAL + //MESSAGE COPY,F_SOTTOC_FORN //li gestisco da programma senno' fanno casino + //MESSAGE COPY,F_SOTTOC_CLIENTE FLAGS "R" CHECKTYPE NORMAL + //VALIDATE AUTOEXIT_FUNC 3 F_GRUPPO F_CONTO F_SOTTOCONTO GROUP 1 WARNING "Conto inesistente" END @@ -95,6 +109,7 @@ NUMBER F_SOTTOC_CLIENTE 6 BEGIN PROMPT 54 3 "Cliente " USE LF_CLIFO +//FIELD LF_CLIFO->CODCF INPUT TIPOCF "C" INPUT CODCF F_SOTTOC_CLIENTE DISPLAY "Codice" CODCF @@ -102,10 +117,14 @@ BEGIN DISPLAY "Gruppo" GRUPPO DISPLAY "Conto" CONTO OUTPUT F_SOTTOC_CLIENTE CODCF +//OUTPUT F_DESCR_CONTO RAGSOC +//OUTPUT F_DESCR_CLIENTE RAGSOC +//OUTPUT F_DESCR_FORN RAGSOC FLAGS "R" CHECKTYPE NORMAL KEY 1 WARNING "Cliente inesistente" + //VALIDATE AUTOEXIT_FUNC 3 F_GRUPPO F_CONTO F_SOTTOC_CLIENTE GROUP 2 END @@ -120,10 +139,15 @@ BEGIN DISPLAY "Gruppo" GRUPPO DISPLAY "Conto" CONTO OUTPUT F_SOTTOC_FORN CODCF +// OUTPUT F_DESCR_FORN RAGSOC +// OUTPUT F_DESCR_CONTO RAGSOC +// OUTPUT F_DESCR_CLIENTE RAGSOC FLAGS "R" CHECKTYPE NORMAL +// serve per l' autopremimento KEY 1 WARNING "Fornitore inesistente" + //VALIDATE AUTOEXIT_FUNC 3 F_GRUPPO F_CONTO F_SOTTOC_FORN GROUP 3 END @@ -320,6 +344,24 @@ BEGIN PROMPT -22 -1 "" END +/* +BUTTON DLG_OK 9 2 +BEGIN + PROMPT -13 -1 "" +END + +BUTTON DLG_CANCEL 9 2 +BEGIN + PROMPT -23 -1 "" +END + +BUTTON DLG_NULL 9 2 +BEGIN + PROMPT -33 -1 "Azzera" + MESSAGE RESET,1@ +END +*/ + ENDPAGE ENDMASK diff --git a/cg/conto.cpp b/cg/conto.cpp index cb597f874..63190ce19 100755 --- a/cg/conto.cpp +++ b/cg/conto.cpp @@ -110,6 +110,7 @@ const char* TBill::describe() { int err = NOERR; const char* desc = NULL; + TFixed_string ragsoc(&__tmp_string[256], 50); if ((_tipo != 'C' && _tipo != 'F') || _sottoconto == 0L) { @@ -136,7 +137,23 @@ const char* TBill::describe() err = clifo.read(); if (err == NOERR) { - desc = clifo.get("RAGSOC"); + char tipoa = clifo.get_char("TIPOAPER"); + + if (tipoa == 'F') + { + TString80 cognome, nome; + ragsoc = clifo.get("RAGSOC"); + cognome = ragsoc.mid(0,30); + nome = ragsoc.mid(30,20); + cognome.trim(); nome.trim(); + + ragsoc = cognome; + ragsoc << " " << nome; + + desc = ragsoc; + } + else + desc = clifo.get("RAGSOC"); if (_conto == 0) { _gruppo = clifo.get_int("GRUPPO"); diff --git a/cg/conto.h b/cg/conto.h index e120db055..9c34ee62e 100755 --- a/cg/conto.h +++ b/cg/conto.h @@ -1,82 +1,82 @@ -#ifndef __CONTO_H -#define __CONTO_H - -#ifndef __STRINGS_H -#include -#endif - -#ifndef __REAL_H -#include -#endif - -class TBill : public TSortable -{ - char _tipo; // ' ' = Conto, 'C' = Cliente, 'F' = 'Fornitore' - int _gruppo, _conto; - long _sottoconto; // Sottoconto, codice cliente o fornitore - TString80 _descrizione; // Vuota fino alla chiamata di describe - int _tipo_cr; // Tipo costo/ricavo - -protected: - virtual int compare(const TSortable& s) const; - virtual const char* class_name() const { return "Conto"; } - const char* describe(); - - const TBill& copy(const TBill& b); - -public: - TBill(int g = 0, int c = 0, long s = 0L, char t = ' ', const char* d = NULL, int r = -1) - : _tipo(t), _gruppo(g), _conto(c), _sottoconto(s), _descrizione(d), _tipo_cr(r) {} - - TBill(TToken_string& tgcsd, int from, int mode = 0); - TBill(const TBill& b) { copy(b); } - virtual ~TBill() {} - - const TBill& set(int g = 0, int c = 0, long s = 0L, char t = ' ', - const char* d = NULL, int r = -1); - const TBill& add_to(TToken_string& ts, int from, int mode = 0); - const TBill& operator=(const TBill& b) { return copy(b); } - - virtual bool ok() const; // Gruppo, Conto e Sottoconto non nulli - bool empty() const { return _gruppo==0 && _conto==0 && _sottoconto == 0; } - - char tipo() const { return _tipo; } - int gruppo() const { return _gruppo; } - int conto() const { return _conto; } - long sottoconto() const { return _sottoconto; } - - const TString& descrizione(); - int tipo_cr(); - void tipo_cr(int tcr) { _tipo_cr = tcr; } - - int tipo_att(); - bool read(TRectype& r); - - const char* string(int mode = 0); -}; - - -enum TIndbil { ib_null, ib_attivita, ib_passivita, ib_costi, ib_ricavi, ib_conti_ordine }; - -class TConto : public TBill -{ - real _dare, _avere, _darepro, _averepro, _saldo; - -public: - TConto(int g = 0, int c = 0, long s = 0L, char t = ' ', const char* d = NULL) - : TBill(g, c, s, t, d) {} - TConto (TToken_string& tgcsd, int from, int mode = 0) - : TBill(tgcsd, from, mode) {}; - - real& dare() { return _dare; } - real& avere() { return _avere; } - real& darepro() { return _darepro; } - real& averepro() { return _averepro; } - real& saldo() { return _saldo; } -}; - -#endif - - - - +#ifndef __CONTO_H +#define __CONTO_H + +#ifndef __STRINGS_H +#include +#endif + +#ifndef __REAL_H +#include +#endif + +class TBill : public TSortable +{ + char _tipo; // ' ' = Conto, 'C' = Cliente, 'F' = 'Fornitore' + int _gruppo, _conto; + long _sottoconto; // Sottoconto, codice cliente o fornitore + TString80 _descrizione; // Vuota fino alla chiamata di describe + int _tipo_cr; // Tipo costo/ricavo + +protected: + virtual int compare(const TSortable& s) const; + virtual const char* class_name() const { return "Conto"; } + const char* describe(); + + const TBill& copy(const TBill& b); + +public: + TBill(int g = 0, int c = 0, long s = 0L, char t = ' ', const char* d = NULL, int r = -1) + : _tipo(t), _gruppo(g), _conto(c), _sottoconto(s), _descrizione(d), _tipo_cr(r) { set(g,c,s,t,d,r);} + + TBill(TToken_string& tgcsd, int from, int mode = 0); + TBill(const TBill& b) { copy(b); } + virtual ~TBill() {} + + const TBill& set(int g = 0, int c = 0, long s = 0L, char t = ' ', + const char* d = NULL, int r = -1); + const TBill& add_to(TToken_string& ts, int from, int mode = 0); + const TBill& operator=(const TBill& b) { return copy(b); } + + virtual bool ok() const; // Gruppo, Conto e Sottoconto non nulli + bool empty() const { return _gruppo==0 && _conto==0 && _sottoconto == 0; } + + char tipo() const { return _tipo; } + int gruppo() const { return _gruppo; } + int conto() const { return _conto; } + long sottoconto() const { return _sottoconto; } + + const TString& descrizione(); + int tipo_cr(); + void tipo_cr(int tcr) { _tipo_cr = tcr; } + + int tipo_att(); + bool read(TRectype& r); + + const char* string(int mode = 0); +}; + + +enum TIndbil { ib_null, ib_attivita, ib_passivita, ib_costi, ib_ricavi, ib_conti_ordine }; + +class TConto : public TBill +{ + real _dare, _avere, _darepro, _averepro, _saldo; + +public: + TConto(int g = 0, int c = 0, long s = 0L, char t = ' ', const char* d = NULL) + : TBill(g, c, s, t, d) {} + TConto (TToken_string& tgcsd, int from, int mode = 0) + : TBill(tgcsd, from, mode) {}; + + real& dare() { return _dare; } + real& avere() { return _avere; } + real& darepro() { return _darepro; } + real& averepro() { return _averepro; } + real& saldo() { return _saldo; } +}; + +#endif + + + +