diff --git a/cg/cg1600.cpp b/cg/cg1600.cpp index eff63cb59..8f04cd4c2 100755 --- a/cg/cg1600.cpp +++ b/cg/cg1600.cpp @@ -260,24 +260,25 @@ class CG1600_application : public TPrintapp bool conto_dettagliato; }; - bil_ivd* _bil; - TMask* _msk; - TTable* _tabesc; - TTable* _tabivd; - TLocalisamfile* _nditte; - TLocalisamfile* _comuni; - TLocalisamfile* _unloc; - TLocalisamfile* _anag; - TLocalisamfile* _pconti; - TLocalisamfile* _clifo; - TLocalisamfile* _saldi; - const char* _buff; - TSort* _sort; - Anni_es _anni_es; - Righe_sez_opp _sezopps; - TSaldi_list* _listasld; - TProgind* _prog; - TParagraph_string * _descr; + bil_ivd* _bil; + TMask* _msk; + TTable* _tabesc; + TTable* _tabivd; + TLocalisamfile* _nditte; + TLocalisamfile* _comuni; + TLocalisamfile* _unloc; + TLocalisamfile* _anag; + TLocalisamfile* _pconti; + TLocalisamfile* _clifo; + TLocalisamfile* _saldi; + const char* _buff; + TSort* _sort; + Anni_es* _anni_es; + Righe_sez_opp _sezopps; + TSaldi_list* _listasld; + TProgind* _prog; + TParagraph_string* _descr; + Saldo* _sld; TDate _data_fine_ese,_data_fine_ese_prec,_data_fine_raf,_data_fine_raf_prec; TDate _datastampa,_datalimite,_databilrafr,_datai,_datairaf; @@ -291,7 +292,6 @@ class CG1600_application : public TPrintapp TString _numr_da_stamp,_num_da_stamp,_numr_stamp,_num_stamp,_descr_sez; int _tipo_bilancio, _tipo_stampa; int _cont_let,_cont_numr,_cont_num,_cont_gcs,_num; - Saldo _sld; real _sale,_salerafr,_totale_ordine,_totale_economico; real _totale_ordine_raf,_totale_economico_raf; real _totale_numero,_totale_numr,_totale_lettera,_totale_sezione; @@ -324,7 +324,7 @@ public: bool menu (MENU_TAG m) { return TPrintapp::menu(m) ; } virtual bool user_create() ; virtual bool user_destroy(); - bool set_print(int); + bool set_print(int); virtual bool preprocess_page (int,int); virtual print_action postprocess_page (int,int); @@ -479,7 +479,7 @@ bool data_limite (TMask_field& f, KEY key) if (annoese != 0) { - a()._anni_es.aggiungi_anno(annoese, in, fin); + a()._anni_es->aggiungi_anno(annoese, in, fin); a()._data_fine_ese = fin; a()._data_ini_ese = in; @@ -558,7 +558,7 @@ bool data_bil_raff (TMask_field& f, KEY key) in = a()._inizioEs; } else - a()._anni_es.aggiungi_anno(annoese, in, fin); + a()._anni_es->aggiungi_anno(annoese, in, fin); TString instr = in.string(); if (dataraf != botime) @@ -599,7 +599,7 @@ bool data_bil_raff (TMask_field& f, KEY key) else if (annoraf != 0) { - a()._anni_es.aggiungi_anno(annoraf, in_raf, fin_raf); + a()._anni_es->aggiungi_anno(annoraf, in_raf, fin_raf); a()._data_fine_raf = fin_raf; a()._data_ini_raf = in_raf; @@ -641,7 +641,7 @@ bool anno_ese_raff (TMask_field& f, KEY key) { if (annoese != 0) { - if (annoraf > annoese) + if (annoraf >= annoese) { f.error_box("L' anno esercizio da raffrontare deve essere inferiore all' anno esercizio in corso"); return FALSE; @@ -779,7 +779,7 @@ bool data_inizio(TMask_field& f, KEY k) { if (anno != 0) { - a()._anni_es.aggiungi_anno(anno, in, fin); + a()._anni_es->aggiungi_anno(anno, in, fin); a()._data_ini_ese = in; a()._data_fine_ese = fin; a()._anno_esercizio = anno; @@ -837,7 +837,7 @@ bool data_fine(TMask_field& f, KEY k) { if (annoes != 0) { - a()._anni_es.aggiungi_anno(annoes, in, fin); + a()._anni_es->aggiungi_anno(annoes, in, fin); a()._data_ini_ese = in; a()._data_fine_ese = fin; @@ -1399,7 +1399,7 @@ void CG1600_application::crea_sort_piano_conti_verifica() real saldo,sld_prg_dare,sld_prg_avere,mov_dare,mov_avere; real saldo_conto,sld_prg_dare_conto,sld_prg_avere_conto,mov_dare_conto,mov_avere_conto; - _sld.set_annoes(_anno_esercizio); + _sld->set_annoes(_anno_esercizio); saldo_conto = ZERO; sld_prg_dare_conto = ZERO; @@ -1539,9 +1539,9 @@ void CG1600_application::crea_sort_piano_conti_verifica() else if (_tipo_stampa == 2) { - if (!_sld.ultima_immissione_verifica(_anno_esercizio,g,c,s,indbil)) + if (!_sld->ultima_immissione_verifica(_anno_esercizio,g,c,s,indbil)) continue; - app = _sld.saldoini(); + app = _sld->saldoini(); if (app < ZERO) { app = -app; @@ -1553,8 +1553,8 @@ void CG1600_application::crea_sort_piano_conti_verifica() sld_prg_dare = app; sld_prg_avere = ZERO; } - mov_dare = _sld.prgdare(); - mov_avere = _sld.prgavere(); + mov_dare = _sld->prgdare(); + mov_avere = _sld->prgavere(); saldo = sld_prg_dare-sld_prg_avere+mov_dare-mov_avere; } @@ -1667,9 +1667,9 @@ void CG1600_application::sottoc_clifo_verifica(int g,int c,int anno,char tipocf, else if (_tipo_stampa == 2) { - if (!_sld.ultima_immissione_bilancio(_anno_esercizio,g,c,s,indbil)) + if (!_sld->ultima_immissione_bilancio(_anno_esercizio,g,c,s,indbil)) continue; - app = _sld.saldoini(); + app = _sld->saldoini(); if (app < ZERO) { app = -app; @@ -1681,8 +1681,8 @@ void CG1600_application::sottoc_clifo_verifica(int g,int c,int anno,char tipocf, sld_prg_dare = app; sld_prg_avere = ZERO; } - mov_dare = _sld.prgdare(); - mov_avere = _sld.prgavere(); + mov_dare = _sld->prgdare(); + mov_avere = _sld->prgavere(); saldo = sld_prg_dare-sld_prg_avere+mov_dare-mov_avere; } @@ -1748,23 +1748,23 @@ bool CG1600_application::calcola_saldo(real& saldo, real& saldo_raf,int g,int c, bool esiste = FALSE; TString saldostr,saldo_rafstr; - _sld.set_annoes(_anno_esercizio); + _sld->set_annoes(_anno_esercizio); if (_tipo_bilancio == 1) { if (_tipo_stampa == 1) //bilancio per data limite { - esiste = _sld.data_limite_bilancio(_tipo_stampa,g,c,s,_datai,_datalimite,indbil,_stampa_mov_prov); - saldo = _sld.saldo(); + esiste = _sld->data_limite_bilancio(_tipo_stampa,g,c,s,_datai,_datalimite,indbil,_stampa_mov_prov); + saldo = _sld->saldo(); - if (!esiste && (!_sld.esiste_saldo() || !_sld.significativo())) + if (!esiste && (!_sld->esiste_saldo() || !_sld->significativo())) no_movimentato = TRUE; else if (!_stampamov) { if (saldo == ZERO) { - if (!_sld.esiste_saldo() || !_sld.significativo()) + if (!_sld->esiste_saldo() || !_sld->significativo()) no_movimentato = TRUE; else no_movimentato = FALSE; @@ -1782,9 +1782,9 @@ bool CG1600_application::calcola_saldo(real& saldo, real& saldo_raf,int g,int c, } else if (_tipo_stampa == 2) { - if (!_sld.ultima_immissione_bilancio(_anno_esercizio,g,c,s,indbil)) + if (!_sld->ultima_immissione_bilancio(_anno_esercizio,g,c,s,indbil)) { - if (!_sld.esiste_saldo() || !_sld.significativo()) + if (!_sld->esiste_saldo() || !_sld->significativo()) no_movimentato = TRUE; else no_movimentato = FALSE; @@ -1792,13 +1792,13 @@ bool CG1600_application::calcola_saldo(real& saldo, real& saldo_raf,int g,int c, else no_movimentato = FALSE; - saldo = _sld.saldo(); + saldo = _sld->saldo(); } saldostr = saldo.string(); if (_annoeserafr != 0 || _databilrafr != botime) { - _sld.set_annoes(_anno_esercizio_raf); + _sld->set_annoes(_anno_esercizio_raf); if (_databilrafr != _data_fine_raf) //(_tipo_stampa == 1) bilancio per data limite { @@ -1806,17 +1806,17 @@ bool CG1600_application::calcola_saldo(real& saldo, real& saldo_raf,int g,int c, TString16 datadep (_databilrafr.string()); TString16 datadep2 (_datairaf.string()); #endif - esiste = _sld.data_limite_bilancio(DataLimite,g,c,s,_datairaf,_databilrafr,indbil,_stampa_mov_prov); - saldo_raf = _sld.saldo(); + esiste = _sld->data_limite_bilancio(DataLimite,g,c,s,_datairaf,_databilrafr,indbil,_stampa_mov_prov); + saldo_raf = _sld->saldo(); - if (!esiste && (!_sld.esiste_saldo() || !_sld.significativo())) + if (!esiste && (!_sld->esiste_saldo() || !_sld->significativo())) no_movimentato_raf = TRUE; else if (!_stampamov) { if (saldo_raf == ZERO) { - if (!_sld.esiste_saldo() || !_sld.significativo()) + if (!_sld->esiste_saldo() || !_sld->significativo()) no_movimentato_raf = TRUE; else no_movimentato_raf = FALSE; @@ -1834,9 +1834,9 @@ bool CG1600_application::calcola_saldo(real& saldo, real& saldo_raf,int g,int c, } else if (_databilrafr == _data_fine_raf) //(_tipo_stampa == 2) { - if (!_sld.ultima_immissione_bilancio(_anno_esercizio_raf,g,c,s,indbil)) + if (!_sld->ultima_immissione_bilancio(_anno_esercizio_raf,g,c,s,indbil)) { - if (!_sld.esiste_saldo() || !_sld.significativo()) + if (!_sld->esiste_saldo() || !_sld->significativo()) no_movimentato_raf = TRUE; else no_movimentato_raf = FALSE; @@ -1844,7 +1844,7 @@ bool CG1600_application::calcola_saldo(real& saldo, real& saldo_raf,int g,int c, else no_movimentato_raf = FALSE; - saldo_raf = _sld.saldo(); + saldo_raf = _sld->saldo(); } saldo_rafstr = saldo_raf.string(); } @@ -2089,6 +2089,9 @@ void CG1600_application::stampa_totali() diff_prod.format("%c%c",'9','B'); ris_imp.format ("%c%c%8s%2s",'9','E',"","21"); + TString16 classe; + classe.format("%c%c%8s%2s", _sez_da_stamp,_let_da_stamp,(const char*)_numr_da_stamp,(const char*)_num_da_stamp); + _num = atoi(_num_tot); _numr = _numr_tot; _let = _let_tot; @@ -2120,11 +2123,7 @@ void CG1600_application::stampa_totali() } } if (_sez_stamp == '9') - { - TString16 classe; - - classe.format("%c%c%8s%2s", _sez_da_stamp,_let_da_stamp,(const char*)_numr_da_stamp,(const char*)_num_da_stamp); - + { if (classe > ris_imp && _risimp_fatto) { if (_num_tot == "20" || _num_tot == "21") @@ -2501,10 +2500,16 @@ void CG1600_application::stampa_totali() set_row (_i++,"@4gDifferenza tra valore e costi della produzione@86g%r", &_totale_economico); _diffprod_fatto = FALSE; } - if (_risimp_fatto) - { - set_row (_i,"@4gRisultato prima delle imposte"); - set_row (_i++,"@86g%r", &_totale_economico); + if (_risimp_fatto) + { + if (_let_da_stamp == 'E' && (_num_da_stamp == "20" || _num_da_stamp == "21")) + { + set_row (_i,"@4gTotale delle partite straordinarie"); + set_row (_i++,"@86g%r", &_totale_parziale); + set_row (_i,"@4gRisultato prima delle imposte"); + set_row (_i++,"@86g%r", &_totale_economico); + _risimp_fatto = FALSE; + } } } @@ -2535,6 +2540,10 @@ void CG1600_application::stampa_totali_con_raffronto() diff_prod.format("%c%c",'9','B'); ris_imp.format ("%c%c%8s%2s",'9','E',"","21"); + + TString16 classe; + classe.format("%c%c%8s%2s", _sez_da_stamp,_let_da_stamp,(const char*)_numr_da_stamp,(const char*)_num_da_stamp); + _num = atoi(_num_tot); _numr = _numr_tot; _let = _let_tot; @@ -2568,11 +2577,7 @@ void CG1600_application::stampa_totali_con_raffronto() } } if (_sez_stamp == '9') - { - TString16 classe; - - classe.format("%c%c%8s%2s", _sez_da_stamp,_let_da_stamp,(const char*)_numr_da_stamp,(const char*)_num_da_stamp); - + { if (classe > ris_imp && _risimp_fatto) { if (_num_tot == "20" || _num_tot == "21") @@ -3012,11 +3017,18 @@ void CG1600_application::stampa_totali_con_raffronto() set_row (_i++,"@4gDifferenza tra valore e costi della produzione@86g%r@112g%r", &_totale_economico,&_totale_economico_raf); _diffprod_fatto = FALSE; } - if (_risimp_fatto) - { - set_row (_i,"@4gRisultato prima delle imposte"); - set_row (_i,"@86g%r", &_totale_economico); - set_row (_i++,"@112g%r", &_totale_economico_raf); + if (_risimp_fatto) + { + if (_let_da_stamp == 'E' && (_num_da_stamp == "20" || _num_da_stamp == "21")) + { + set_row (_i,"@4gTotale delle partite straordinarie"); + set_row (_i,"@86g%r", &_totale_parziale); + set_row (_i++,"@112g%r", &_totale_parziale_raf); + set_row (_i,"@4gRisultato prima delle imposte"); + set_row (_i,"@86g%r", &_totale_economico); + set_row (_i++,"@112g%r", &_totale_economico_raf); + _risimp_fatto = FALSE; + } } } char app = ' '; @@ -3661,6 +3673,20 @@ bool CG1600_application::preprocess_stampa_scalare(int counter) saldostr = _sale.string(); saldo_rafstr = _salerafr.string(); + // Faccio passare solo i sottoconti o i conti non dettagliati (che non hanno sottoconti) + // perchè l' importo dei conti dettagliati non è altri che il totale degli importi di + // tutti i suoi sottoconti; dunque se li sommassi anche loro, sommerei l'importo due volte. + // Pero' devo ricordarmi di cambiare ugualmente segno ai conti che vanno dettagliati. + + if (g != 0 && c != 0 && s == 0 && conto_dettagliato) + if (_sez_da_stamp == '9') + { + _sale = -_sale; + if (_annoeserafr != 0 || _databilrafr != botime) + _salerafr = -_salerafr; + } + + if ((g != 0 && c != 0 && s != 0)||(g != 0 && c != 0 && s == 0 && !conto_dettagliato)) { // if (_sez_da_stamp == '5') @@ -4896,19 +4922,23 @@ void CG1600_application::init_sort() bool CG1600_application::user_create() { - _nditte = new TLocalisamfile (LF_NDITTE); - _comuni = new TLocalisamfile (LF_COMUNI); - _unloc = new TLocalisamfile (LF_UNLOC); - _anag = new TLocalisamfile (LF_ANAG); - _pconti = new TLocalisamfile (LF_PCON); - _clifo = new TLocalisamfile (LF_CLIFO); - _saldi = new TLocalisamfile (LF_SALDI); - _descr = new TParagraph_string ("",40); + _nditte = new TLocalisamfile (LF_NDITTE); + _comuni = new TLocalisamfile (LF_COMUNI); + _unloc = new TLocalisamfile (LF_UNLOC); + _anag = new TLocalisamfile (LF_ANAG); + _pconti = new TLocalisamfile (LF_PCON); + _clifo = new TLocalisamfile (LF_CLIFO); + _saldi = new TLocalisamfile (LF_SALDI); + _descr = new TParagraph_string ("",40); - _tabivd = new TTable (TAB_IVD); - _tabesc = new TTable (TAB_ESC); + _tabivd = new TTable (TAB_IVD); + _tabesc = new TTable (TAB_ESC); + + _anni_es = new Anni_es(); + _sld = new Saldo(); + + _msk = new TMask("cg1600a"); - _msk = new TMask("cg1600a"); return TRUE; } @@ -4926,6 +4956,9 @@ bool CG1600_application::user_destroy() delete _clifo; delete _saldi; delete _descr; + delete _anni_es; + delete _sld; + return TRUE; } diff --git a/cg/cg4400.cpp b/cg/cg4400.cpp index 4c90eaa98..28e19219b 100755 --- a/cg/cg4400.cpp +++ b/cg/cg4400.cpp @@ -1,8 +1,9 @@ // cg4400.cpp -// Stampa tabella registri +// Stampa registri IVA #include "cg4.h" #include "cg4400.h" #include "cg4400a.h" +#include "cg4400b.h" static TString256 TMP; @@ -10,11 +11,12 @@ inline CG4400_application& app() { return (CG4400_application&)main_app(); } bool CG4400_application::filter_func (const TRelation * r) { - TLocalisamfile & mov = r->lfile(LF_MOV); + TLocalisamfile& mov = r->lfile(LF_MOV); TString16 codreg = mov.get(MOV_REG); TDate datareg = mov.get_date(MOV_DATAREG); int annoiva = mov.get_int(MOV_ANNOIVA); - + bool regst = mov.get_bool(MOV_REGST); + if (codreg != (app()._codreg) || annoiva != (app()._annoes)) return FALSE; @@ -22,6 +24,10 @@ bool CG4400_application::filter_func (const TRelation * r) if ( (datareg < app()._data_da || datareg > app()._data_a ) || (!datareg.ok()) ) return FALSE; + if (app()._tipo_stampa == 2 || app()._tipo_stampa == 4) //stampa di bollato + if (regst) //il movimento e' gia' stato stampato in forma definitiva + return FALSE; + return TRUE; } @@ -45,14 +51,17 @@ HIDDEN int compare_fields(const TObject** o1, const TObject** o2) return strcmp(campo1, campo2); } -/* - bool CG4400_application::libro_giornale_iva_unico() - { - TConfig conf(CONFIG_DITTA); +bool CG4400_application::stampa_totali_finali() +{ + TConfig conf(CONFIG_DITTA); + return conf.get_bool("StTfFr"); +} - return conf.get("StLgiU") == "X"; - } - */ +bool CG4400_application::stampa_datareg() +{ + TConfig conf(CONFIG_STUDIO); + return conf.get_bool("NoDtRg"); +} bool CG4400_application::mask_select (TMask_field& f, KEY k) { @@ -114,6 +123,21 @@ bool CG4400_application::mask_firm_to (TMask_field& f, KEY k) return TRUE; } +bool CG4400_application::mask_tipo_stampa(TMask_field& f, KEY k) +{ + TMask& m = f.mask(); + + if (k == K_SPACE) + { + int tipo_stampa = m.get_int(TIPO_STAMPA); + if (tipo_stampa == 3) //stampa su libro unico + m.enable_page(1); + else + m.disable_page(1); + } + return TRUE; +} + bool CG4400_application::mask_mese (TMask_field& f, KEY k) { const short id = f.dlg(); @@ -123,17 +147,19 @@ bool CG4400_application::mask_mese (TMask_field& f, KEY k) if (id == FINO_A_MESE) mese = f.mask().get_int(FINO_A_MESE); //Per stampa su bollato - if (k == K_ENTER) - { - if (id == MESE) //Per stampa su libro unico - { - int umese = f.mask().get_int(ULTIMO_MESE); - if (mese != umese+1) - return f.warning_box ("Le stampe devono essere richieste mese per mese!\n" - "I mesi successivi a %s non sono ancora stati stampati.", itom(umese)); - } - } - if (k == K_TAB) + /* + if (k == K_ENTER) + { + if (id == MESE) //Per stampa su libro unico + { + int umese = f.mask().get_int(ULTIMO_MESE); + if (mese != umese+1) + return f.warning_box ("Le stampe devono essere richieste mese per mese!\n" + "I mesi successivi a %s non sono ancora stati stampati.", itom(umese)); + } + } + */ + if (k == K_SPACE) { if (id == MESE) if (mese == 12) @@ -156,6 +182,155 @@ bool CG4400_application::mask_mese (TMask_field& f, KEY k) return TRUE; } +bool CG4400_application::look_reg(long l, int anno, TString& codlib, int m, const char* cod, int* umese) +{ + TString16 y; + + y << anno << cod; + _tabreg->zero(); + _tabreg->put("CODTAB", y); + + if (_tabreg->read() == NOERR) + { + int tipo = _tabreg->get_int("I0"); + if (tipo == 1 || tipo == 2) + { + TString16 cod_lib_un = _tabreg->get("S6"); + TDate u_data = _tabreg->get_date("D3"); + TDate sca_vid = _tabreg->get_date("D0"); + *umese = u_data.month(); + if (_selected[l]) + { + if (codlib != cod_lib_un) + { + message_box("Ditta %ld: il codice libro unico del registro non e' uguale al codice libro unico indicato", _nditte->get_long("CODDITTA")); + return FALSE; + } + if (m < *umese) + { + message_box("Ditta %ld: il mese indicato e' inferiore al mese dell'ultima data di stampa del registro", _nditte->get_long("CODDITTA")); + return FALSE; + } + if (sca_vid.month() < m) + { + message_box("Ditta %ld: la data scadenza di vidimazione del registro non deve essere inferiore al mese indicato", _nditte->get_long("CODDITTA")); + return FALSE; + } + } + /* + if (*umese < m - 1) + { + app().TApplication::set_firm(__firm); + return error_box("Ditta %ld: Stampare i registri dei mesi precedenti", _nditte->get_long("CODDITTA")); + } + */ + return TRUE; + } + } + return FALSE; +} + +bool CG4400_application::look_regs(int anno, TString& codlib, int m, int* umese) +{ + int a, tipo; + TString16 codtab; + *umese = 13; + + for (_tabreg->first(); !_tabreg->eof(); _tabreg->next()) + { + tipo = _tabreg->get_int("I0"); + codtab = _tabreg->get("CODTAB"); + a = atoi(codtab.mid(0,4)); + if (a > anno) + { + // message_box("Non esistono registri IVA della Ditta %ld per l'anno %d", _nditte->get_long("CODDITTA"), anno); + // break; + return FALSE; + } + if (a == anno) + if ( tipo == 1 || tipo == 2 ) //registro iva + { + TString16 cod_lib_un = _tabreg->get("S6"); + TDate sca_vid = _tabreg->get_date("D0"); + TDate u_data = _tabreg->get_date("D3"); + if (codlib != cod_lib_un) + continue; + if (m < u_data.month()) + continue; + if (sca_vid.month() < m) + continue; + if (u_data.month() < m - 1) + { + app().TApplication::set_firm(__firm); + return error_box("Ditta %ld: Stampare i registri dei mesi precedenti", _nditte->get_long("CODDITTA")); + } + *umese = (*umese < u_data.month()) ? *umese : u_data.month(); + } + } + return TRUE; +} + +bool CG4400_application::mask_libun (TMask_field& f, KEY k) +{ + //TString16 cod(f.mask().get(CODICE_LIBRO_IVA)); + + //if ( (k == K_TAB && f.mask().is_running()) || (k == K_ENTER && cod.not_empty()) ) + if ( k == K_ENTER ) + { + TString16 cod(f.mask().get(CODICE_LIBRO_IVA)); + TString16 codlib(f.mask().get(CODICE_LIB_UN)); + int fino_a_mese = f.mask().get_int(MESE); + int anno = f.mask().get_int(ANNO); + bool ok = FALSE; + long l; + int last_mese = 13; + int mese; + + app().__firm = app().TApplication::get_firm(); + + for (l = 0l, app()._nditte->first(); !app()._nditte->eof(); l++, app()._nditte->next()) + { + if (!prefhndl->exist(app()._nditte->get_long("CODDITTA"))) + continue; + app().TApplication::set_firm(app()._nditte->get_long("CODDITTA")); + + if (cod.not_empty()) + { + ok = app().look_reg(l,anno,codlib,fino_a_mese,cod,&mese); + if ( app()._selected[l] && !ok) + { + f.message_box("Ditta %ld: il registro %s non soddisfa i parametri indicati",app()._nditte->get_long("CODDITTA"), (const char*)cod); + continue; + } + if (mese < fino_a_mese - 1) //indipendentemente se si tratta di una ditta selezionata oppure no + { + app().TApplication::set_firm(app().__firm); + return error_box("Ditta %ld: Stampare i registri dei mesi precedenti", app()._nditte->get_long("CODDITTA")); + } + } + else + { + ok = app().look_regs(anno,codlib,fino_a_mese,&mese); + + if ( app()._selected[l] && (!ok || mese == 13) ) + { + f.message_box("Ditta %ld: nessun registro soddisfa i parametri indicati", app()._nditte->get_long("CODDITTA")); + continue; + } + } + if (app()._selected[l]) + last_mese = (last_mese < mese) ? last_mese : mese; + } + app().TApplication::set_firm(app().__firm); + if (last_mese == 13) + return FALSE; + const char* me = ""; + me = format("%02d", last_mese); + f.mask().set(ULTIMO_MESE, me); + } + return TRUE; +} + bool CG4400_application::mask_cod (TMask_field& f, KEY k) { TTable TabLbu ("%LBU"); @@ -173,9 +348,9 @@ bool CG4400_application::mask_cod (TMask_field& f, KEY k) TabLbu.read(); if ( TabLbu.good() ) { - // f.mask().set(MESE,TabLbu.get_long("I0")+1); - f.mask().set(ULTIMO_MESE,TabLbu.get_long("I0")); + //f.mask().set(ULTIMO_MESE,TabLbu.get_long("I0")); f.mask().set(ULTIMA_PAGINA,TabLbu.get_long("I1")); + app()._codice_vidi = TabLbu.get("S4"); } } return TRUE; @@ -202,80 +377,10 @@ bool CG4400_application::mask_data (TMask_field& f, KEY k) return TRUE; } -/* - bool mask_fino_a_mese (TMask_field& f, KEY k) - { - if (k == K_ENTER) - { - TTable TabReg ("REG"); - TString16 codtab; - int giorni_del_mese; - TString codreg = f.mask().get(CODICE_LIBRO); - int tipo = f.mask().get_int(TIPO_STAMPA); - int anno = f.mask().get_int(ANNO); - - if ( (tipo == 1) || (tipo == 4) ) - { - int fino_a_mese = f.mask().get_int(FINO_A_MESE); - if (fino_a_mese == 12) - giorni_del_mese = 31; - else - { - TDate primo = format("01/%02d/%4d", fino_a_mese+1, anno); - --primo; - giorni_del_mese = primo.day(); - } - TDate datasup = format("%02d/%02d/%4d",giorni_del_mese,fino_a_mese,anno); - if (codreg != "") - { - TabReg.zero(); - codtab << anno << codreg; - TabReg.put ("CODTAB", codtab); - TabReg.read(); - if ( TabReg.good() ) - { - TDate data = TabReg.get_date("D3"); - if (datasup < data) - { - TString16 datas = format("%02d/%4d", data.month(), data.year()); - f.warning_box ("La data specificata non deve essere inferiore al %s (ultima data di stampa specificata sul registro)", (const char*)datas); - return FALSE; - } - } - } - if (tipo == 4) - { - TabReg.zero(); - TabReg.put ("CODTAB", anno); - TRectype r (TabReg.curr()); - TabReg.read(_isgteq); - for (; !TabReg.eof(); TabReg.next()) - { - if (TabReg.curr() != r) break; - - int tiporeg = TabReg.get_int("I0"); - if (tiporeg == 5) //libro giornale - { - TDate data = TabReg.get_date("D3"); - if (datasup > data) - { - TString16 datas = format("%02d/%4d", data.month(), data.year()); - f.warning_box ("La data specificata non deve essere superiore al %s (ultima data di stampa del libro giornale)", (const char*)datas); - return FALSE; - } - } - } - } - } - } - return TRUE; - } - */ - -const char * CG4400_application::descr_doc(const char * tipo) +const char * CG4400_application::descr_doc() { TTable tab_tpd("%TPD"); - const TString16 codtab(format("%-2s", tipo)); + TString codtab(format("%-2s",(const char*) _tipodoc)); tab_tpd.zero(); tab_tpd.put("CODTAB", codtab); @@ -290,7 +395,7 @@ const char * CG4400_application::descr_doc(const char * tipo) const char * CG4400_application::descr_iva(const char * cod) { TTable tab_iva("%IVA"); - const TString16 codtab(format ("%-4s", cod)); + TString codtab(format ("%-4s", cod)); tab_iva.zero(); tab_iva.put("CODTAB", codtab); @@ -302,12 +407,25 @@ const char * CG4400_application::descr_iva(const char * cod) return TMP; } -const char * CG4400_application::desc_attivita(const char * codatt) +const char * CG4400_application::tipo_attivita() +{ + TLocalisamfile attiv (LF_ATTIV); + + attiv.zero(); + attiv.put("CODDITTA", get_firm()); + attiv.put("CODATT", _codatt); + if (attiv.read() == NOERR) + TMP = attiv.get("TIPOATT"); + else TMP = ""; + return TMP; +} + +const char * CG4400_application::desc_attivita() { TTable attiv ("%AIS"); attiv.zero(); - attiv.put("CODTAB", codatt); + attiv.put("CODTAB", _codatt); if (attiv.read()==NOERR) TMP = attiv.get("S0"); else @@ -315,49 +433,37 @@ const char * CG4400_application::desc_attivita(const char * codatt) return TMP; } -const char * CG4400_application::ricerca_cf(char tipocf, long codcf) +TRectype& CG4400_application::ricerca_cf(char tipocf, long codcf) { _clifo->zero(); _clifo->put(CLI_TIPOCF, tipocf); _clifo->put(CLI_CODCF, codcf); - if (_clifo->read() == NOERR) - TMP = _clifo->get(CLI_RAGSOC); - else - TMP = ""; - return TMP; + _clifo->read(); + if (_clifo->bad()) + _clifo->zero(); + + return _clifo->curr(); } -const char * CG4400_application::ricerca_occ(const char * occ) +TRectype& CG4400_application::ricerca_occ(const char * occ) { TLocalisamfile occas (LF_OCCAS); - occas.zero(); occas.put(OCC_CFPI, occ); + occas.read(); + if (occas.bad()) + occas.zero(); - if (occas.read() == NOERR) - TMP = occas.get(OCC_RAGSOC); - else - TMP = ""; - return TMP; + return occas.curr(); } bool CG4400_application::user_create() { _nditte = new TLocalisamfile(LF_NDITTE); - _ditte = new TArray_sheet(-1, -1, 0, 0, "Selezione Ditte", - "@1|Cod.@5|Ragione Sociale@50"); - for (_nditte->first(); !_nditte->eof(); _nditte->next()) - { - TToken_string* d = new TToken_string(64); - d->add(" "); - d->add(_nditte->get("CODDITTA")); - d->add(_nditte->get("RAGSOC")); - _ditte->add(*d); - } - _n_ditte = _ditte->items(); - _com = new TLocalisamfile(LF_COMUNI); _anag = new TLocalisamfile(LF_ANAG); + _unloc = new TLocalisamfile(LF_UNLOC); + _attiv = new TLocalisamfile(LF_ATTIV); _tab = new TLocalisamfile(LF_TAB); _tabcom = new TLocalisamfile(LF_TABCOM); _tabreg = new TTable("REG"); @@ -366,17 +472,42 @@ bool CG4400_application::user_create() _tabinl = new TTable("%INL"); _tablim = new TTable("LIM"); _tabpim = new TTable("PIM"); - _tablia = new TTable("LIA"); + _tablia = new TTable("LIA"); + _tabpla = new TTable("PLA"); + _tabppa = new TTable("PPA"); + _tabvid = new TTable("VID"); _clifo = new TLocalisamfile(LF_CLIFO); _occas = new TLocalisamfile(LF_OCCAS); _rel = new TRelation (LF_MOV); + _rel->add(LF_CAUSALI,"CODCAUS=CODCAUS",1,LF_MOV); - _rel->add(LF_RMOVIVA,"NUMREG=NUMREG",1,LF_MOV); - _cur = new TCursor(_rel, "", 1); - + _rel->add(LF_RMOVIVA,"NUMREG=NUMREG",1,LF_MOV); + + _cur = new TCursor(_rel, "", 2); + + _ditte = new TArray_sheet(-1, -1, 0, 0, "Selezione Ditte", + "@1|Cod.@5|Ragione Sociale@50"); + + long firm = TApplication::get_firm(); + + for (_nditte->first(); !_nditte->eof(); _nditte->next()) + { + if (!prefhndl->exist(_nditte->get_long("CODDITTA"))) + continue; + TToken_string* d = new TToken_string(64); + d->add(" "); + d->add(_nditte->get("CODDITTA")); + d->add(_nditte->get("RAGSOC")); + _ditte->add(*d); + } + _n_ditte = _ditte->items(); + + TApplication::set_firm(firm); + add_cursor(_cur); add_file(LF_MOV); - add_file(LF_RMOVIVA); + add_file(LF_RMOVIVA); + return TRUE; } @@ -384,48 +515,176 @@ bool CG4400_application::user_destroy() { delete _ditte; delete _nditte; + delete _com; + delete _unloc; + delete _anag; + delete _attiv; delete _tab; delete _tabcom; + delete _tabreg; + delete _tabiva; + delete _tablbu; + delete _tabinl; + delete _tablim; + delete _tabpim; + delete _tablia; + delete _tabpla; + delete _tabppa; + delete _tabvid; + delete _clifo; + delete _occas; delete _cur; delete _rel; - delete _clifo; + return TRUE; } +/* + void CG4400_application::calcola_progressivi(real& r0, real& r1, real& r2, const char* codiva, const int tipocr) + { + TTable pim ("PIM"); + TString chiave; + int i, num=0; + + if (_tipo_stampa == 2) + num = _datareg.month(); + if ( (_tipo_stampa == 3) || (_tipo_stampa == 4) ) + num = _fino_a_mese; + + if (_frequiva == 'T') + for (i=3; isave_status(); + real impo, impos; + int tipodet, tipocr, tipoatt; + bool intra; + + //_cur->save_status(); + TLocalisamfile& rmoviva = _cur->file(LF_RMOVIVA); bool ok = _cur->is_first_match(LF_RMOVIVA); int nrec = 0; + TRecnotype nr = rmoviva.recno(); + while (ok) { nrec++; - TRectype iva (_cur->file(LF_RMOVIVA).curr()); + TRectype iva (rmoviva.curr()); tipodet = iva.get_int (RMI_TIPODET); tipocr = iva.get_int (RMI_TIPOCR); impo = iva.get_real(RMI_IMPONIBILE); impos = iva.get_real(RMI_IMPOSTA); codiva = iva.get(RMI_CODIVA); + intra = iva.get_bool(RMI_INTRA); + tipoatt = iva.get_int("TIPOATT"); - impop = imposp = 0.00; - _riga_rmi.add_riga(impo,impos,codiva,tipodet,tipocr,impop,imposp); + _riga_rmi.add_riga(impo,impos,ZERO,ZERO,codiva,tipodet,tipocr,intra,tipoatt); - if (_tipo_reg == 2) //registro acquisti + if (_tipo_stampa == 1) //stampa di prova { - if (_tipo_stampa != 3) //stampa definitiva - calcola_progressivi(impop,imposp,codiva,tipocr); - _iva_array.add_riga(impo,impos,codiva,tipodet,tipocr,impop,imposp); + if (_tipodoc == "FS") + { + real somma = -(impo + impos); + _tot_iva_array.add_riga(ZERO,ZERO,somma,ZERO,ZERO,ZERO,codiva); + } + else if (_tipodoc == "CR" || _tipodoc == "RF" || _tipodoc == "SC") + _tot_iva_array.add_riga(ZERO,ZERO,impo+impos,ZERO,ZERO,ZERO,codiva); + if (_tipodoc != "CR" && _tipodoc != "SC" && _tipodoc != "RF") + _tot_iva_array.add_riga(impo,impos,ZERO,ZERO,ZERO,ZERO,codiva); + + if (_tipo_reg == 2) //registro acquisti (non ha senso parlare di importi lordi) + _iva_array.add_riga(impo,impos,ZERO,ZERO,codiva,tipodet,0,TRUE); } - impop = imposp = 0.00; - if (_tipo_stampa != 3) - calcola_progressivi(impop,imposp,codiva,tipocr); - - _tot_iva_array.add_riga(impo,impos,codiva,_tipodoc,impop,imposp); - ok = _cur->next_match(LF_RMOVIVA); } - _cur->restore_status(); + //_cur->restore_status(); + rmoviva.readat(nr); return nrec; } @@ -481,7 +749,7 @@ int CG4400_application::setta_riga(int r, const TRigaiva& riga, real& tot1, set_row(r, "@5g%s",(const char*)descr); set_row(r, "@25g%r", &riga._imponibile); set_row(r, "@41g%r", &riga._imposta); - if (_tipo_stampa != 3) + if (_tipo_stampa != 1) { set_row(r, "@81g%r", &riga._imponibilep); set_row(r++, "@98g%r", &riga._impostap); @@ -499,101 +767,117 @@ bool CG4400_application::controlla_liquidazione() { TTable lim ("LIM"); TTable pim ("PIM"); - TTable lia ("LIA"); TString mesi_ric = ""; TString mesi_cal = ""; TString16 chiave = ""; TString16 ditta = ""; - int i; + int i, mese; ditta << get_firm(); - if (lim.empty()) - return yesno_box("Ditta %s : non esiste la tabella liquidazione iva mensile! Vuoi ugualmente continuare la stampa?", (const char*) ditta); + if (lim.empty()) + return yesno_box("Ditta %s: non esiste la tabella liquidazione iva mensile! Vuoi ugualmente continuare la stampa?", (const char*) ditta); if (pim.empty()) - return yesno_box("Ditta %s : non esiste la tabella progressivi iva mensile! Vuoi ugualmente continuare la stampa?", (const char*) ditta); + return yesno_box("Ditta %s: non esiste la tabella progressivi iva mensile! Vuoi ugualmente continuare la stampa?", (const char*) ditta); + + if (_tipo_stampa == 1) //stampa di prova + mese = _data_a.month(); + else + mese = _fino_a_mese; - chiave << _annoes; - lia.put("CODTAB", chiave); - if (lia.read() == NOERR) - _frequiva = lia.get("S7")[0]; - - if (_frequiva == 'T') //nella tabella LIM ho solo i mesi 3, 6, 9, 12 + if (_tipo_riepilogativo == ' ' || _tipo_riepilogativo == 'P') { - for (i=3; i<=_fino_a_mese; i+=3) + if (_frequiva == 'T') //nella tabella LIM ho solo i mesi 3, 6, 9, 12 { - chiave = ""; - chiave << _annoes << i; - lim.put("CODTAB", chiave); - if (lim.read() == NOERR) + for (i=3; i<=mese; i+=3) { - bool calcolato = lim.get_bool("B0"); - if (!calcolato) - - // return yesno_box("La liquidazione relativa al mese di %s deve essere ricalcolata. Vuoi ugualmente continuare la stampa?", itom(i) ); - mesi_ric << itom(i) << "\n"; + chiave = ""; + chiave << _annoes << i; + lim.put("CODTAB", chiave); + if (lim.read() == NOERR) + { + bool calcolato = lim.get_bool("B0"); + if (!calcolato) + mesi_ric << itom(i) << "\n"; + } + else + mesi_cal << itom(i) << "\n"; } - else - // return yesno_box("La liquidazione relativa al mese di %s non e' stata calcolata. Vuoi ugualmente continuare la stampa?", itom(i) ); - mesi_cal << itom(i) << "\n"; + } + if (_frequiva == 'M') + { + for (i=1 ; i<=mese; i++) + { + chiave = ""; + chiave << _annoes << i; + lim.put("CODTAB", chiave); + if (lim.read() == NOERR) + { + bool calcolato = lim.get_bool("B0"); + if (!calcolato) + mesi_ric << itom(i) << "\n"; + } + else + mesi_cal << itom(i) << "\n"; + } + } + if (mesi_ric.not_empty()) + { + _liquidazione = FALSE; + warning_box ("Ditta %s: deve essere ricalcolata la liquidazione relativa ai mesi di:\n %s ", (const char*)ditta, (const char *)mesi_ric); + return yesno_box("Vuoi ugualmente continuare la stampa?"); } - } - if (_frequiva == 'M') - { - for (i=1 ; i<=_fino_a_mese; i++) + if (mesi_cal.not_empty()) + { + _liquidazione = FALSE; + warning_box ("Ditta %s: la liquidazione relativa ai mesi di \n %s non e' stata ancora calcolata", (const char*)ditta, (const char *)mesi_cal); + return yesno_box("Vuoi ugualmente continuare la stampa?"); + } + } + else if (_tipo_riepilogativo == 'A') + if (_riep_liq) { chiave = ""; - chiave << _annoes << i; + chiave << _annoes << 13; lim.put("CODTAB", chiave); if (lim.read() == NOERR) { bool calcolato = lim.get_bool("B0"); if (!calcolato) - // return yesno_box("La liquidazione relativa al mese di %s deve essere ricalcolata. Vuoi ugualmente continuare la stampa?", itom(i) ); - mesi_ric << itom(i) << "\n"; + { + _liquidazione = FALSE; + return yesno_box("Ditta %s: non eseguito calcolo liquidazione. Vuoi ugualmente continuare la stampa?", (const char*)ditta); + } } - else - // return yesno_box("La liquidazione relativa al mese di %s non e' stata calcolata. Vuoi ugualmente continuare la stampa?", itom(i) ); - mesi_cal << itom(i) << "\n"; - } - } - - if (mesi_ric.not_empty()) - { - warning_box ("Ditta %s : deve essere ricalcolata la liquidazione relativa ai mesi di:\n %s ", (const char*)ditta, (const char *)mesi_ric); - return yesno_box("Vuoi ugualmente continuare la stampa?"); - } - if (mesi_cal.not_empty()) - { - warning_box ("Ditta %s : la liquidazione relativa ai mesi di \n %s non e' stata ancora calcolata", (const char*)ditta, (const char *)mesi_cal); - return yesno_box("Vuoi ugualmente continuare la stampa?"); - } + //else ? + } return TRUE; } -//controlla che i movimenti con data di registrazione compresa tra l'anno precedente e l'ultima data stampata siano tutti gia' stati stampati in forma definitiva*/ +//controlla che i movimenti con anno data di registrazione < dell'anno indicato a video siano stati gia' stampati in forma definitiva*/ +//questo controllo viene fatto solo per stampa di bollato (non su libro unico) bool CG4400_application::controlla_mov() { TLocalisamfile mov (LF_MOV); bool ok = TRUE; + bool first = TRUE; byte tipo; TString16 ditta = ""; - TDate udata; - TDate data = format("01/01/%4d", _annoes - 1); TRecnotype rec = _tabreg->recno(); + _stampa_mese = 0; for (mov.first(); !mov.eof(); mov.next()) { TString16 reg = mov.get(MOV_REG); - if (reg.empty()) continue; + if (reg.empty()) continue; //non e' un movimento iva TDate datareg = mov.get_date(MOV_DATAREG); if (_stampa_tutti_i_registri) - cerca_reg (reg, tipo, udata); - else udata = _data_da; - if ( (_stampa_tutti_i_registri && ((tipo == 1)||(tipo == 2))) - || ((!_stampa_tutti_i_registri)&&(reg == _codreg)) ) - if ( (datareg >= data) && (datareg <= udata) ) + cerca_reg (reg, &tipo); + if ( (_stampa_tutti_i_registri && (tipo == 1 || tipo == 2)) + || (!_stampa_tutti_i_registri && reg == _codreg) ) + { + bool stampato = mov.get_bool(MOV_REGST); + if ( datareg.year() < _annoes ) { - bool stampato = mov.get_bool(MOV_REGST); long numreg = mov.get_long(MOV_NUMREG); if (!stampato) { @@ -602,13 +886,49 @@ bool CG4400_application::controlla_mov() warning_box("Ditta %s : il movimento con numero di registrazione %ld non e' ancora stato stampato in forma definitiva!", (const char*)ditta, numreg); ok = FALSE; } - } + } + if ( datareg.year() == _annoes && first) + if (!stampato) + { + _stampa_mese = datareg.month(); + first = FALSE; + } + } } _tabreg->readat(rec); return ok; } -void CG4400_application::cerca_reg(const TString& c, byte& t, TDate& d) +bool CG4400_application::cerca_libro_gio(TString& datas) +{ + TString app(4); + app = format("%04d", _annoes); + + TRecnotype rec = _tabreg->recno(); + _tabreg->zero(); + _tabreg->put ("CODTAB", app); + TRectype r (_tabreg->curr()); + _tabreg->read(_isgteq); + for (; !_tabreg->eof(); _tabreg->next()) + { + if (_tabreg->curr() != r) break; + + int tiporeg = _tabreg->get_int("I0"); + if (tiporeg == 5) //libro giornale + { + TDate data = _tabreg->get_date("D3"); + if (_data_a > data) + { + datas = format("%02/%02d/%4d", data.day(), data.month(), data.year()); + return FALSE; + } + } + } + _tabreg->readat(rec); + return TRUE; +} + +void CG4400_application::cerca_reg(const TString& c, byte* t) { TString16 cod = ""; @@ -616,67 +936,9 @@ void CG4400_application::cerca_reg(const TString& c, byte& t, TDate& d) _tabreg->zero(); _tabreg->put("CODTAB", cod); if (_tabreg->read() == NOERR) - { - t = _tabreg->get_int ("I0"); - d = _tabreg->get_date("D3"); - } + *t = _tabreg->get_int ("I0"); } -/* - bool CG4400_application::controlla_mov() - { - bool ok = TRUE; - - if (_stampa_tutti_i_registri) - { - TRecnotype rec = _tabreg->recno();//la first l'ho gia' fatta - for (; !_tabreg->eof(); _tabreg->next()) - { - TString codtab = _tabreg->get("CODTAB"); - int anno = atoi(codtab.mid(0,4)); - if (anno != _annoes) break; - - TDate data_da = _tabreg->get_date("D3"); - TString16 codreg = codtab.mid(4,3); - leggi_movimenti(data_da, codreg, ok); - } - _tabreg->readat(rec); - } - else - leggi_movimenti(_data_da, _codreg, ok); - - return ok; - } - - void CG4400_application::leggi_movimenti(const TDate& d, const TString& cod, bool& ok) - { - TLocalisamfile mov (LF_MOV); - bool stampato; - long numreg; - TString codreg; - - TDate data = format("01/01/%4d", _annoes - 1); - mov.zero(); - TRectype a (mov.curr()); - mov.put(MOV_DATAREG, data); - a.put (MOV_DATAREG, d); - mov.read(_isgteq); - while (mov.curr() < a && !mov.eof()) - { - stampato = mov.get_bool(MOV_STAMPATO); - numreg = mov.get_long(MOV_NUMREG); - codreg = mov.get(MOV_REG); - if (codreg == cod) - if (!stampato) - { - warning_box("Il movimento con numero di registrazione %ld non e' ancora stato stampato in forma definitiva!", numreg); - ok = FALSE; - } - mov.next(); - } - } - */ - bool CG4400_application::ventilazione(const char* iva) { TTable tabiva ("%IVA"); @@ -699,44 +961,60 @@ int CG4400_application::stampa_prospetto() reset_print(); riga.fill('-'); - set_row(r, "%s", (const char *) riga); + set_row(r, "%s", (const char*)riga); r++; set_row(r, "Legenda Tipo Operazione: 1=operazione intracomunitaria 2=AF art.34 comma 3"); if (_auto_intraf) set_row(r, "@78g3=operazione intracomunitaria e AF art.34 comma 3"); r++; - set_row(++r, "Tipo documento@30gTotale documento"); - r+=2; - for (int j = 0; j < _doc_array.items(); j++) + + _stampa = stampa_totali_finali(); + if (_stampa) { - TTipodoc& doc = (TTipodoc&)_doc_array[j]; - rr = r+j; - set_row(rr, "%2s", (const char*) doc._tipodoc); - set_row(rr, "@3g%.25s", (const char*) doc._descrdoc); - set_row(rr, "@29g%r", &doc._totdoc); - } - _doc_array.destroy(); + set_row(++r, "Tipo documento@30gTotale documento"); + r+=2; + for (int j = 0; j < _doc_array.items(); j++) + { + TTipodoc& doc = (TTipodoc&)_doc_array[j]; + rr = r+j; + set_row(rr, "%2s", (const char*) doc._tipodoc); + set_row(rr, "@3g%.25s", (const char*) doc._descrdoc); + set_row(rr, "@29g%r", &doc._totdoc); + } + _doc_array.destroy(); + } if (rr > 0) rr++; else rr = r; - //if (_nrec > 0) //numero records di rmoviva - if (_esiste_riga_iva) + if (_stampa && _tipo_reg == 2) + if (_stampa_cred_pre && _mese_credito==0 && _credito > ZERO) + { + set_row (++rr, "** CREDITO INIZIO ANNO %r = credito iva anno precedente", &_credito); + rr++; + } + + if (_esiste_riga_iva && _stampa) { - if (_corrispettivi) + if (_tipo_reg == 1 && _corrispettivi) set_row(++rr, "@26g------------------ P E R I O D O -------------------"); else set_row(++rr, "@26g---------- P E R I O D O -----------"); - if (_tipo_stampa != 3) - set_row(rr,"@82g------ P R O G R E S S I V I ------"); + if (_tipo_stampa != 1) + { + if (_tipo_reg == 1 && _corrispettivi) + set_row(rr,"@84g----------- P R O G R E S S I V I --------------"); + else + set_row(rr,"@82g------ P R O G R E S S I V I ------"); + } rr++; set_row(rr, "Cod."); if (_tipo_reg == 2) { set_row(rr, "@36gA C Q U I S T I"); - if (_tipo_stampa != 3) + if (_tipo_stampa != 1) set_row(rr, "@92gA C Q U I S T I"); } if (_tipo_reg == 1) //un registro corrispettivi puo' solo essere un registro vendite @@ -744,249 +1022,455 @@ int CG4400_application::stampa_prospetto() set_row(rr, "@37gV E N D I T E"); if (_corrispettivi) set_row(rr, "@63gCORRISPETTIVI"); - if (_tipo_stampa != 3) - set_row(rr, "@93gV E N D I T E"); + if (_tipo_stampa != 1) + { + if (_corrispettivi) + set_row(rr, "@94gV E N D I T E@118gCORRISPETTIVI"); + else + set_row(rr, "@93gV E N D I T E"); + } } rr++; set_row(rr, "iva Descrizione@30gImponibile@49gImposta"); - if (_corrispettivi) + if (_tipo_reg == 1 && _corrispettivi) set_row(rr, "@63gImporti lordi"); - if (_tipo_stampa != 3) - set_row(rr++, "@86gImponibile@106gImposta"); + if (_tipo_stampa != 1) + { + if (_tipo_reg == 1 && _corrispettivi) + set_row(rr++, "@87gImponibile@107gImposta@118gImporti Lordi"); + else + set_row(rr++, "@86gImponibile@106gImposta"); + } else rr++; rr++; - } + } return rr; } //la stampa "tipi di indetraibilita'" viene fatta solo per gli acquisti -void CG4400_application::stampa_acquisti(int row) +int CG4400_application::stampa_acquisti(int row) { - if (_tipo_reg == 2) + real tot_imponib, tot_imposta, tot_imponibp, tot_impostap; + row+=2; + int tdetprec = -1; + int rw = row; + tot_imponib = tot_imposta = tot_imponibp = tot_impostap = 0.00; + + _iva_array.sort(compare_fields); + for (int s = 0; s < _iva_array.items(); s++) { - real tot_imponib, tot_imposta, tot_imponibp, tot_impostap; - row+=2; - int tdetprec = -1; - int rw = row; - tot_imponib = tot_imposta = tot_imponibp = tot_impostap = 0.00; - - _iva_array.sort(compare_fields); - for (int s = 0; s < _iva_array.items(); s++) + TRigaiva& riga = (TRigaiva&)_iva_array[s]; + switch (riga._tipodet) { - TRigaiva& riga = (TRigaiva&)_iva_array[s]; - switch (riga._tipodet) - { - case 1: if (riga._tipodet != tdetprec) - { - set_row(rw++, "----- Indetraibile su op.es. -----"); - set_row(rw, "Cod."); - rw++; - set_row(rw, "iva Descrizione@30gImponibile@49gImposta"); - if (_tipo_stampa != 3) - set_row(rw++, "@86gImponibile@106gImposta"); - else rw++; - rw++; - } - rw = setta_riga(rw, riga, tot_imponib, tot_imposta, tot_imponibp, tot_impostap); - tdetprec = riga._tipodet; - break; - case 3: if (tdetprec == 1) - { - set_row(++rw, "TOTALE@25g%r@41g%r", &tot_imponib, &tot_imposta); - if (_tipo_stampa != 3) - set_row(rw, "@81g%r@98g%r", &tot_imponibp, &tot_impostap); - tot_imponib = tot_imposta = tot_imponibp = tot_impostap = 0.00; - rw+=2; + case 1: if (riga._tipodet != tdetprec) + { + set_row(rw++, "----- Indetraibile su op.es. -----"); + set_row(rw, "Cod."); + rw++; + set_row(rw, "iva Descrizione@30gImponibile@49gImposta"); + if (_tipo_stampa != 1) + set_row(rw++, "@86gImponibile@106gImposta"); + else rw++; + rw++; + } + rw = setta_riga(rw, riga, tot_imponib, tot_imposta, tot_imponibp, tot_impostap); + tdetprec = riga._tipodet; + break; + case 3: if (tdetprec == 1) + { + set_row(++rw, "TOTALE@25g%r@41g%r", &tot_imponib, &tot_imposta); + if (_tipo_stampa != 1) + set_row(rw, "@81g%r@98g%r", &tot_imponibp, &tot_impostap); + tot_imponib = tot_imposta = tot_imponibp = tot_impostap = 0.00; + rw+=2; + } + if (riga._tipodet != tdetprec) + { + set_row(rw++, "----- Passaggi interni -----"); + set_row(rw, "Cod."); + rw++; + set_row(rw, "iva Descrizione@30gImponibile@49gImposta"); + if (_tipo_stampa != 1) + set_row(rw++, "@86gImponibile@106gImposta"); + else rw++; + rw++; } - if (riga._tipodet != tdetprec) - { - set_row(rw++, "----- Passaggi interni -----"); - set_row(rw, "Cod."); - rw++; - set_row(rw, "iva Descrizione@30gImponibile@49gImposta"); - if (_tipo_stampa != 3) - set_row(rw++, "@86gImponibile@106gImposta"); - else rw++; - rw++; - } - rw = setta_riga(rw, riga, tot_imponib, tot_imposta, tot_imponibp, tot_impostap); - tdetprec = riga._tipodet; - break; - case 9: if ( (tdetprec == 1) || (tdetprec == 3) ) - { - set_row(++rw, "TOTALE@25g%r@41g%r", &tot_imponib, &tot_imposta); - if (_tipo_stampa != 3) - set_row(rw, "@81g%r@98g%r", &tot_imponibp, &tot_impostap); - tot_imponib = tot_imposta = tot_imponibp = tot_impostap = 0.00; - rw+=2; + rw = setta_riga(rw, riga, tot_imponib, tot_imposta, tot_imponibp, tot_impostap); + tdetprec = riga._tipodet; + break; + case 9: if ( (tdetprec == 1) || (tdetprec == 3) ) + { + set_row(++rw, "TOTALE@25g%r@41g%r", &tot_imponib, &tot_imposta); + if (_tipo_stampa != 1) + set_row(rw, "@81g%r@98g%r", &tot_imponibp, &tot_impostap); + tot_imponib = tot_imposta = tot_imponibp = tot_impostap = 0.00; + rw+=2; + } + if (riga._tipodet != tdetprec) + { + set_row(rw++, "----- N.D. 9 - acquisti indeducibili per ART.19 -----"); + set_row(rw, "Cod."); + rw++; + set_row(rw, "iva Descrizione@30gImponibile@49gImposta"); + if (_tipo_stampa != 1) + set_row(rw++, "@86gImponibile@106gImposta"); + else rw++; + rw++; } - if (riga._tipodet != tdetprec) - { - set_row(rw++, "----- N.D. 9 - acquisti indeducibili per ART.19 -----"); - set_row(rw, "Cod."); - rw++; - set_row(rw, "iva Descrizione@30gImponibile@49gImposta"); - if (_tipo_stampa != 3) - set_row(rw++, "@86gImponibile@106gImposta"); - else rw++; - rw++; - } - rw = setta_riga(rw, riga, tot_imponib, tot_imposta, tot_imponibp, tot_impostap); - tdetprec = riga._tipodet; - break; - default: break; - } - } + rw = setta_riga(rw, riga, tot_imponib, tot_imposta, tot_imponibp, tot_impostap); + tdetprec = riga._tipodet; + break; + default: break; + } + } + if (_iva_array.items() > 0) if (tdetprec == 9) { set_row(++rw, "TOTALE@25g%r@41g%r", &tot_imponib, &tot_imposta); - if (_tipo_stampa != 3) + if (_tipo_stampa != 1) set_row(rw, "@81g%r@98g%r", &tot_imponibp, &tot_impostap); } - _iva_array.destroy(); - } + _iva_array.destroy(); + rw++; + return rw; } +/* + void CG4400_application::set_page_tot_reg() + { + TString16 codivaprec = ""; + int row=0, rr=0; + + rr = stampa_prospetto(); + + //if (_nrec > 0) //numero di records di rmoviva + if (_esiste_riga_iva && _stampa) + { + real tot_imponib, tot_imposta, tot_imponibp, tot_impostap, tot_lordo; + real dep_imponib, dep_imposta, dep_lordo; + tot_imponib = tot_imposta = tot_imponibp = tot_impostap = tot_lordo = ZERO; + dep_imponib = dep_imposta = dep_lordo = ZERO; + + _tot_iva_array.sort(compare_rows); //viene ordinato per codice iva + + for (int k = 0; k < _tot_iva_array.items(); k++) + { + TRiga& riga = (TRiga&)_tot_iva_array[k]; + //row = rr+k; + if (codivaprec == "") + codivaprec = riga._codiva; + if (codivaprec != riga._codiva) + { + set_row(rr, "%3s", (const char*)codivaprec); + TString descr = descr_iva(codivaprec); + set_row(rr, "@5g%s",(const char*)descr); + if (dep_imponib != ZERO) + set_row(rr, "@25g%r", &dep_imponib); + if (dep_imposta != ZERO) + set_row(rr, "@41g%r", &dep_imposta); + if (dep_lordo != ZERO) + set_row(rr, "@61g%r", &dep_lordo); + } + rr++; + codivaprec = riga._codiva; + dep_imponib = dep_imposta = dep_lordo = ZERO; + } + if (riga._tipodoc == "FS") + { + real somma = -(riga._imponibile + riga._imposta); + dep_lordo += somma; + } + else if (riga._tipodoc == "CR" || riga._tipodoc == "RF" || riga._tipodoc == "SC") + { + dep_lordo += riga._imponibile + riga._imposta; + tot_lordo += riga._imponibile + riga._imposta; + } + + if (riga._tipodoc != "CR" && riga._tipodoc != "SC" && riga._tipodoc == "RF") + { + dep_imponib += riga._imponibile; + dep_imposta += riga._imposta; + tot_imponib += riga._imponibile; + tot_imposta += riga._imposta; + } + + if (k == (_tot_iva_array.items()-1)) + { + set_row(rr, "%3s", (const char*)riga._codiva); + TString descr = descr_iva(riga._codiva); + set_row(rr, "@5g%s", (const char*)descr); + if (dep_imponib != ZERO) + set_row(rr, "@25g%r", &dep_imponib); + if (dep_imposta != ZERO) + set_row(rr, "@41g%r", &dep_imposta); + if (dep_lordo != ZERO) + set_row(rr, "@61g%r", &dep_lordo); + } + } + _tot_iva_array.destroy(); + rr++; + set_row(++rr, "TOTALE@25g%r@41g%r", &tot_imponib, &tot_imposta); + if (_corrispettivi) + if (tot_lordo != ZERO) + set_row(rr, "@61g%r", &tot_lordo); + + if (_tipo_reg == 2) rr = stampa_acquisti(rr); + + if (_tipo_reg == 2 && _tipo_stampa != 1) + stampa_plafonds(rr); + } + } + */ + void CG4400_application::set_page_tot_reg() { - TString16 codivaprec = ""; - int row=0, rr=0; + int rr=0; rr = stampa_prospetto(); //if (_nrec > 0) //numero di records di rmoviva - if (_esiste_riga_iva) + if (_esiste_riga_iva && _stampa) { - real tot_imponib, tot_imposta, tot_imponibp, tot_impostap, tot_lordo; - real dep_imponib, dep_imposta, dep_lordo; - tot_imponib = tot_imposta = tot_imponibp = tot_impostap = tot_lordo = ZERO; - dep_imponib = dep_imposta = dep_lordo = ZERO; + real tot_imponib, tot_imposta, tot_lordo, tot_imponibp, tot_impostap, tot_lordop; + tot_imponib = tot_imposta = tot_lordo = tot_imponibp = tot_impostap = tot_lordop = ZERO; - _tot_iva_array.sort(compare_rows); + _tot_iva_array.sort(compare_rows); //viene ordinato per codice iva for (int k = 0; k < _tot_iva_array.items(); k++) { TRiga& riga = (TRiga&)_tot_iva_array[k]; //row = rr+k; - if (codivaprec == "") - codivaprec = riga._codiva; - if (codivaprec != riga._codiva) - { - set_row(rr, "%3s", (const char*)codivaprec); - TString descr = descr_iva(codivaprec); - set_row(rr, "@5g%s", (const char*)descr); - if (dep_imponib != ZERO) - set_row(rr, "@25g%r", &dep_imponib); - if (dep_imposta != ZERO) - set_row(rr, "@41g%r", &dep_imposta); - if (dep_lordo != ZERO) - set_row(rr, "@61g%r", &dep_lordo); - if (_tipo_stampa != 3) - { + set_row(rr, "%3s", (const char*)riga._codiva); + TString80 descr = descr_iva(riga._codiva); + set_row(rr, "@5g%s",(const char*)descr); + if (riga._imponibile != ZERO) + set_row(rr, "@25g%r", &riga._imponibile); + if (riga._imposta != ZERO) + set_row(rr, "@41g%r", &riga._imposta); + if (_tipo_reg == 1 && _corrispettivi) + if (riga._implordo != ZERO) + set_row(rr, "@61g%r", &riga._implordo); + if (_tipo_stampa != 1) + { + if (riga._imponibilep != ZERO) set_row(rr, "@81g%r", &riga._imponibilep); - set_row(rr, "@98g%r", &riga._impostap); - } - rr++; - codivaprec = riga._codiva; - dep_imponib = dep_imposta = dep_lordo = ZERO; - } - if (_corrispettivi) - { - if (riga._tipodoc == "CR" || riga._tipodoc == "RF" || riga._tipodoc == "SC") - { - dep_lordo += riga._imponibile; - dep_imposta += riga._imposta; - tot_lordo += riga._imponibile; - tot_imposta += riga._imposta; - } - else if (riga._tipodoc == "CN" || riga._tipodoc == "RN" || riga._tipodoc == "SN" || riga._tipodoc != "FS") - { - dep_imponib += riga._imponibile; - dep_imposta += riga._imposta; - tot_imponib += riga._imponibile; - tot_imposta += riga._imposta; - } - if (riga._tipodoc == "FS") - { - real somma = riga._imponibile + riga._imposta; - if (ventilazione(riga._codiva)) //con ventilazione - { - dep_imponib += somma; - tot_imponib += somma; - somma = -somma; - dep_lordo += somma; - } - else //senza ventilazione - { - dep_imponib += riga._imponibile; - tot_imponib += riga._imponibile; - dep_imposta += riga._imposta; - tot_imposta += riga._imposta; - somma = -somma; - dep_lordo += somma; - } - tot_lordo += somma; - } + if (riga._impostap != ZERO) + set_row(rr, "@98g%r", &riga._impostap); + if (_tipo_reg == 1 && _corrispettivi) + if (riga._implordop != ZERO) + set_row(rr, "@115g%r", &riga._implordop); } - else //non e' un registro corrispettivo - { - //set_row(row, "@25g%r", &riga._imponibile); - //set_row(row, "@41g%r", &riga._imposta); - dep_imponib += riga._imponibile; - dep_imposta += riga._imposta; - tot_imponib += riga._imponibile; - tot_imposta += riga._imposta; - tot_imponibp += riga._imponibilep; - tot_impostap += riga._impostap; - } - if (k == (_tot_iva_array.items()-1)) - { - set_row(rr, "%3s", (const char*)riga._codiva); - TString descr = descr_iva(riga._codiva); - set_row(rr, "@5g%s", (const char*)descr); - if (dep_imponib != ZERO) - set_row(rr, "@25g%r", &dep_imponib); - if (dep_imposta != ZERO) - set_row(rr, "@41g%r", &dep_imposta); - if (dep_lordo != ZERO) - set_row(rr, "@61g%r", &dep_lordo); - if (_tipo_stampa != 3) - { - set_row(rr, "@81g%r", &riga._imponibilep); - set_row(rr, "@98g%r", &riga._impostap); - } - } - /* - if (_tipo_stampa != 3) - { - set_row(rr, "@81g%r", &riga._imponibilep); - set_row(rr, "@98g%r", &riga._impostap); - } - */ + rr++; + tot_imponib += riga._imponibile; + tot_imposta += riga._imposta; + tot_lordo += riga._implordo; + tot_imponibp+= riga._imponibilep; + tot_impostap+= riga._impostap; + tot_lordop += riga._implordop; } _tot_iva_array.destroy(); rr++; set_row(++rr, "TOTALE@25g%r@41g%r", &tot_imponib, &tot_imposta); - if (_corrispettivi) - if (tot_lordo != ZERO) - set_row(rr, "@61g%r", &tot_lordo); - if (_tipo_stampa != 3) + if (_tipo_reg == 1 && _corrispettivi) + set_row(rr, "@61g%r", &tot_lordo); + if (_tipo_stampa != 1) + { set_row(rr, "@81g%r@98g%r", &tot_imponibp, &tot_impostap); + if (_tipo_reg == 1 && _corrispettivi) + set_row(rr, "@115g%r", &tot_lordop); + } - stampa_acquisti(rr); + if (_tipo_reg == 2) rr = stampa_acquisti(rr); + + if (_tipo_reg == 2 && _tipo_stampa != 1) + stampa_plafonds(rr); } } +void CG4400_application::stampa_plafonds(int r) +{ + TTable pla ("PLA"); + TTable ppa ("PPA"); + TString80 chiave; + int num; + real r1, r2, r3; + + r1 = r2 = r3 = ZERO; + + if (_tipo_stampa == 3) + num = _fino_a_mese; + if ( _tipo_stampa == 2 || _tipo_stampa == 4 ) + num = _datareg.month(); + + // forza il tipoatt a 1 + char buf[10]; strcpy(buf,_codatt); + buf[strlen(buf) - 1] = '1'; + + chiave = ""; + chiave << _annoes << buf; + pla.put("CODTAB", chiave); + + if (pla.read() == NOERR) + { + r1 = pla.get_real("R1"); //totali esp. art.8 + r2 = pla.get_real("R2"); //totali esp. art.8 bis + r3 = pla.get_real("R3"); //totali esp. art 9 + } + + if (r1 > ZERO || r2 > ZERO || r3 > ZERO) + { + set_row(++r, "QUADRO RELATIVO ALLA DISPONIBILITA' E UTILIZZAZIONE MENSILE DEI PLAFONDS"); + r++; + TString mese(9); + mese = itom(num); + mese.right_just(); + set_row(++r, "%s", (const char*) mese); + r++; + } + else return; + + if (r1 > ZERO) + { + real r8 = ZERO; + r8 = stampa_valori_plafonds(r1, num, ppa); + if (r8 > ZERO) + { + real pri = ZERO; + real pre = ZERO; + chiave = ""; + chiave << _annoes << _codatt << "1" << num << "1"; + ppa.put("CODTAB", chiave); + if (ppa.read() == NOERR) + { + pri = ppa.get_real("R0"); + pre = ppa.get_real("R1"); + } + chiave = ""; + chiave << _annoes << _codatt << "2" << num << "1"; + ppa.put("CODTAB", chiave); + if (ppa.read() == NOERR) + { + pri += ppa.get_real("R0"); + pre += ppa.get_real("R1"); + } + real x = r8 - pri - pre; + set_row(r++, "ART. 8 1° comma lettere a-b Disponibile %r", &r8); + set_row(r++, "Utilizzato all'interno@33g%r", &pri); + set_row(r++, "Utilizzato per l'importazione@33g%r riporto %r", &pre, &x); + } + } + + if (r2 > ZERO) + { + real r8b = ZERO; + r8b = stampa_valori_plafonds(r2, num, ppa); + if (r8b > ZERO) + { + real pri = ZERO; + real pre = ZERO; + chiave = ""; + chiave << _annoes << _codatt << "1" << num << "2"; + ppa.put("CODTAB", chiave); + if (ppa.read() == NOERR) + { + pri = ppa.get_real("R0"); + pre = ppa.get_real("R1"); + } + chiave = ""; + chiave << _annoes << _codatt << "2" << num << "2"; + ppa.put("CODTAB", chiave); + if (ppa.read() == NOERR) + { + pri += ppa.get_real("R0"); + pre += ppa.get_real("R1"); + } + real x = r8b - pri - pre; + r++; + set_row(r++, "ART. 8 bis 1° comma Disponibile %r", &r8b); + set_row(r++, "Utilizzato all'interno@33g%r", &pri); + set_row(r++, "Utilizzato per l'importazione@33g%r riporto %r", &pre, &x); + } + } + + if (r3 > ZERO) + { + real r9 = ZERO; + r9 = stampa_valori_plafonds(r3, num, ppa); + if (r9 > ZERO) + { + real pri = ZERO; + real pre = ZERO; + chiave = ""; + chiave << _annoes << _codatt << "1" << num << "3"; + ppa.put("CODTAB", chiave); + if (ppa.read() == NOERR) + { + pri = ppa.get_real("R0"); + pre = ppa.get_real("R1"); + } + chiave = ""; + chiave << _annoes << _codatt << "2" << num << "3"; + ppa.put("CODTAB", chiave); + if (ppa.read() == NOERR) + { + pri += ppa.get_real("R0"); + pre += ppa.get_real("R1"); + } + real x = r9 - pri - pre; + r++; + set_row(r++, "ART. 8 bis 1° comma Disponibile %r", &r9); + set_row(r++, "Utilizzato all'interno@33g%r", &pri); + set_row(r++, "Utilizzato per l'importazione@33g%r riporto %r", &pre, &x); + } + } +} + +real CG4400_application::stampa_valori_plafonds(const real& r1, const int mese, TTable& ppa) +{ + real r, si8, se8; + TString80 chiave; + int i; + + r = r1; + si8 = se8 = ZERO; + if (mese > 1) + { + for (i=1; iget_long("CODDITTA"); TString16 codtab = ""; + TString16 cod_lib_un; + TDate sca_vid; _tipo_stampa = m.get_int(TIPO_STAMPA); - if (_tipo_stampa == 2) //stampa su libro unico di studio + if (_tipo_stampa == 3) //stampa su libro unico di studio _codreg = m.get(CODICE_LIBRO_IVA); - else if (_tipo_stampa == 3) //stampa di prova + else if (_tipo_stampa == 1) //stampa di prova _codreg = m.get(CODICE_LIBRO_PROVA); else _codreg = m.get(CODICE_LIBRO); @@ -1000,8 +1484,9 @@ bool CG4400_application::compila_reg(const TMask& m) anno = atoi(codtab.mid(0,4)); if (anno > _annoes) { - warning_box("Non esistono registri IVA della Ditta %ld per l'anno %d", - codditta, _annoes); + if (_tipo_stampa != 3) //per il libro unico e' gia' stato controllato + warning_box("Non esistono registri IVA della Ditta %ld per l'anno %d", + codditta, _annoes); return FALSE; } } @@ -1014,64 +1499,69 @@ bool CG4400_application::compila_reg(const TMask& m) _tabreg->put("CODTAB", codtab); if (_tabreg->read() == NOERR) { - _tipo_reg = _tabreg->get_int("I0"); - _pagine_stampate = _tabreg->get_int("I1"); - _corrispettivi = _tabreg->get_bool("B0"); - //_pagine_numerate = tab_reg.get_int("I2"); - //_stampa_ok = tab_reg.get_int("I7"); - //_nprog_da = tab_reg.get_long ("I6"); - //_tot_dare = tab_reg.get_real ("R1") - //_tot_avere = tab_reg.get_real ("R2"); - if (_tipo_stampa != 3) + _tipo_reg = _tabreg->get_int("I0"); + if (_tipo_reg == 1 || _tipo_reg == 2) //registro iva { - _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) + cod_lib_un = _tabreg->get("S6"); + sca_vid = _tabreg->get_date("D0"); + if (_tipo_stampa != 1) { - TString16 datas = format("%02d/%4d", _data_da.month(), _data_da.year()); - warning_box ("Ditta %ld : la data specificata deve essere superiore al %s (ultima data di stampa specificata sul registro)", codditta, (const char*)datas); - return FALSE; - } - _stampa_ind_ditta = _tabreg->get_bool ("B9"); - _codatt = _tabreg->get("S8"); - _attivita = desc_attivita(_codatt); - _desc_lib = _tabreg->get ("S0"); + _u_data = _tabreg->get_date ("D3"); + if (!_u_data.ok()) + _u_data = format("01/01/%4d", _annoes); + } + if ( _tipo_stampa == 2 || _tipo_stampa == 4 ) + { + if (_data_a < _u_data) + { + TString16 datas = format("%02d/%02d/%4d", _u_data.day(), _u_data.month(), _u_data.year()); + warning_box ("Ditta %ld: la data specificata non deve essere inferiore al %s (ultima data di stampa specificata sul registro)", codditta, (const char*)datas); + return FALSE; + } + if (cod_lib_un.not_empty()) + { + warning_box ("Ditta %ld: sul registro non deve essere indicato il codice del libro unico", codditta); + return FALSE; + } + if (sca_vid.month() < _fino_a_mese) + { + warning_box ("Ditta %ld: il mese della data scadenza vidimazione riportata sul registro non deve essere inferiore al mese indicato", codditta); + return FALSE; + } + if (_tipo_stampa == 4) //stampa con riferimenti al libro giornale + { + TString16 datas; + bool ok = cerca_libro_gio(datas); + if (!ok) + { + warning_box ("Ditta %ld: la data indicata non deve essere superiore al %s (ultima data di stampa del libro giornale)", codditta, (const char*)datas); + return FALSE; + } + } + } + _pagine_stampate = _tabreg->get_long("I1"); + _numini = _pagine_stampate; + _corrispettivi = _tabreg->get_bool("B0"); + _liquidazione = _tabreg->get_bool("B7"); + _riep_liq = _tabreg->get_bool("B6"); + _stampa_cred_pre = _tabreg->get_bool("B4"); + _stampa_ind_ditta = _tabreg->get_bool("B9"); + _stampa_ind_comp = _tabreg->get_bool("B5"); + _cod_un_loc = _tabreg->get_int ("I7"); + _mese_credito = _tabreg->get_int ("I8"); //campo nascosto sulla tabella dei registri: mese di stampa credito anno precedente + _mese_ultima_liq = _tabreg->get_int ("I4"); + _codatt = _tabreg->get("S8"); + _tipoatt = tipo_attivita(); + _attivita = desc_attivita(); + _desc_lib = _tabreg->get ("S0"); + } } - else + else if (_tipo_stampa != 3) { warning_box("Il registro IVA specificato non esiste nella \n Ditta %ld", codditta); return FALSE; } } - - if (_tipo_stampa == 4) - { - TString app(4); - _tabreg->zero(); - app = format("%04d", _annoes); - _tabreg->put ("CODTAB", app); - TRectype r (_tabreg->curr()); - _tabreg->read(_isgteq); - for (; !_tabreg->eof(); _tabreg->next()) - { - if (_tabreg->curr() != r) break; - - int tiporeg = _tabreg->get_int("I0"); - if (tiporeg == 5) //libro giornale - { - TDate data = _tabreg->get_date("D3"); - if (_data_a > data) - { - TString16 datas = format("%02d/%4d", data.month(), data.year()); - warning_box ("Ditta %ld : la data specificata non deve essere superiore al %s (ultima data di stampa del libro giornale)", codditta, (const char*)datas); - return FALSE; - } - } - } - } return TRUE; } @@ -1104,11 +1594,12 @@ bool CG4400_application::preprocess_print(int file, int counter) _tot_iva_array.destroy(); _doc_array.destroy(); _dataregp = ""; - _mov_empty = TRUE; _esiste_riga_iva = FALSE; - _primast = _u_stampata; _auto_intraf = FALSE; + _intesta_liq = FALSE; set_print_zero(); + if (_tipo_stampa == 3) + calcola_progressivi(); } return TRUE; } @@ -1118,8 +1609,11 @@ bool CG4400_application::preprocess_page(int file, int counter) if (file == LF_MOV) { if (counter) return TRUE; + reset_print(); - int rr = 0; + int rr = 0, riga = 0; + TString80 comune, prov, comcf, capcf, civcf; + TString80 viacf; TString ragsoc; TString tipo_op = ""; @@ -1128,34 +1622,57 @@ bool CG4400_application::preprocess_page(int file, int counter) _datareg = mov.get_date(MOV_DATAREG); + if (_tipo_stampa == 2 || _tipo_stampa == 4) + for (int m = _stampa_mese; m > 0 && m < _datareg.month(); m++) + { + if (!_st_liq[m]) + //if (stampo_liquidazione(m)) + { + _datareg = format("01/%02d/%4d", m, _annoes); //serve per la preprocess_header + _intesta_liq = TRUE; + TFilename t; + t.temp(); + send_message('L',t, m); + if (m > 1) printer().formfeed(); + merge_export_file(t,FALSE,TRUE); + _intesta_liq = FALSE; + _st_liq[m] = TRUE; + } + } + + _datareg = mov.get_date(MOV_DATAREG); _mov_empty = FALSE; - if ( (_datareg.month() != _dataregp.month()) && (_dataregp.ok()) ) + if ( _datareg.month() != _dataregp.month() && _dataregp.ok() ) { - if (_tipo_stampa == 2) - ++ _u_stampata; _auto_intraf = FALSE; printer().formfeed(); } _dataregp = _datareg; - TDate datadoc = mov.get_date(MOV_DATADOC); - long numreg = mov.get_long(MOV_NUMREG); - long protiva = mov.get_long(MOV_PROTIVA); - real totdoc = mov.get_real(MOV_TOTDOC); - TString numdoc = mov.get(MOV_NUMDOC); - char tipocf = mov.get(MOV_TIPO)[0]; - TString ocfpi = mov.get(MOV_OCFPI); - long codcf = mov.get_long(MOV_CODCF); - long numgio = mov.get_long(MOV_NUMGIO); - bool stampato = mov.get_bool(MOV_REGST); - bool intra = caus.get_bool(CAU_INTRACOM); //sul movimento - bool autof = caus.get_bool(CAU_AUTOFATT); - TString descrcau = caus.get(CAU_DESCR); + TDate datadoc = mov.get_date(MOV_DATADOC); + long numreg = mov.get_long(MOV_NUMREG); + long protiva = mov.get_long(MOV_PROTIVA); + long uprotiva = mov.get_long(MOV_UPROTIVA); + real totdoc = mov.get_real(MOV_TOTDOC); + TString16 numdoc = mov.get(MOV_NUMDOC); + char tipocf = mov.get(MOV_TIPO)[0]; + TString16 ocfpi = mov.get(MOV_OCFPI); + long codcf = mov.get_long(MOV_CODCF); + long numgio = mov.get_long(MOV_NUMGIO); + bool stampato = mov.get_bool(MOV_REGST); + TString16 codval = mov.get(MOV_CODVALI); + real corrval = mov.get_real(MOV_CORRVALUTA); + bool intra = caus.get_bool(CAU_INTRACOM); //da prendere sul movimento ? + bool autof = caus.get_bool(CAU_AUTOFATT); + TString80 descrcau = caus.get(CAU_DESCR); + + if (_cur->pos() == 0) + _uprotivap = uprotiva ? uprotiva : protiva; //aggiornamento di mov - if (_tipo_stampa != 3) + if (_tipo_stampa != 1) if (!stampato) { mov.put(MOV_REGST,TRUE); @@ -1172,34 +1689,75 @@ bool CG4400_application::preprocess_page(int file, int counter) else if (autof) tipo_op = "2"; - if ( (tipocf == 'C') || (tipocf == 'F') ) + if (codcf == 0l) + ragsoc = descrcau; + else { if (ocfpi.trim().empty()) - ragsoc = ricerca_cf(tipocf, codcf); + { + TRectype dep = ricerca_cf(tipocf, codcf); + ragsoc = dep.get (CLI_RAGSOC); + viacf = dep.get (CLI_INDCF); + civcf = dep.get (CLI_CIVCF); + capcf = dep.get (CLI_CAPCF); + comcf = dep.get (CLI_COMCF); + } else - ragsoc = ricerca_occ(ocfpi); + { + TRectype dep = ricerca_occ(ocfpi); + ragsoc = dep.get (OCC_RAGSOC); + viacf = dep.get (OCC_INDIR); + civcf = dep.get (OCC_CIV); + capcf = dep.get (OCC_CAP); + comcf = dep.get (OCC_COM); + } + TRectype com = look_comuni(comcf); + comune = com.get(COM_DENCOM); + prov = com.get(COM_PROVCOM); } - else ragsoc = descrcau; _tipodoc = mov.get(MOV_TIPODOC); - _descr_doc = descr_doc(_tipodoc); + _descr_doc = descr_doc(); TString app = datadoc.string(2, '/'); - _doc_array.add_riga(_tipodoc,_descr_doc,totdoc); + if (stampa_totali_finali()) + _doc_array.add_riga(_tipodoc,_descr_doc,totdoc); //setto le righe di stampa _r = 1; - set_row(_r, "%s", (const char*) _datareg.string(2, '/')); - set_row(_r, "@9g%5d", protiva); - set_row(_r, "@15g%s", (const char*) app); + if (_stampa_data_reg) + set_row(_r, "%s", (const char*) _datareg.string(2, '/')); + set_row(_r, "@9g%5d", protiva); + if (datadoc.ok()) + set_row(_r, "@15g%s", (const char*) app); set_row(_r, "@24g%s", (const char*) numdoc); set_row(_r, "@32g%ld", codcf); set_row(_r, "@39g%.28s",(const char*) ragsoc); set_row(_r, "@68g%s", (const char*) tipo_op); set_row(_r, "@70g%2s", (const char*) _tipodoc); - set_row(_r, "@72g%r", &totdoc); + if (_stampa_width == 132) + set_row(_r, "@72g%r", &totdoc); + else set_row(_r, "@78g%r", &totdoc); + + if (_tipo_stampa == 1) //in caso di stampa di prova + if (! (_tipo_reg == 1 && _corrispettivi)) //e se non si tratta di registro vendite corrispettivi + if (! (_cur->pos()==0)) //il primo movimento non va controllato + { + if (protiva != _uprotivap + 1) + { + set_row(_r+1, "@5g*** NUM.PROT.FUORI SEQUENZA"); + riga = _r+2; + } + _uprotivap = uprotiva ? uprotiva : protiva; + } - _nrec = riga_rmoviva(); + if (codcf != 0l && _stampa_ind_comp) + { + set_row (_r+1, "@39g%.24s %.3s",(const char *)viacf, (const char *)civcf); + set_row (_r+2, "@39g%s %.22s", (const char *)capcf, (const char *)comune); + riga = _r+3; + } + _nrec = riga_rmoviva(); if (_nrec > 0) { _esiste_riga_iva = TRUE; @@ -1207,25 +1765,82 @@ bool CG4400_application::preprocess_page(int file, int counter) { TRigaiva& riga = (TRigaiva&)_riga_rmi[j]; rr = _r+j; - set_row(rr, "@87g%r", &riga._imponibile); - set_row(rr, "@102g%4s",(const char*)riga._codiva); - if (_tipo_reg == 2) - set_row(rr, "@107g%d", riga._tipodet); - set_row(rr, "@108g%r", &riga._imposta); - set_row(rr, "@124g%d", riga._tipocr); + if (_stampa_width == 132) + { + set_row(rr, "@87g%r", &riga._imponibile); + set_row(rr, "@102g%4s",(const char*)riga._codiva); + if (_tipo_reg == 2) + set_row(rr, "@107g%d", riga._tipodet); + set_row(rr, "@108g%r", &riga._imposta); + set_row(rr, "@124g%d", riga._tipocr); + if (_tipoatt == "E") + set_row(rr, "@126g%d", riga._tipoatt); + if (_tipo_stampa == 4) //stampa con riferimento al libro giornale + set_row(rr, "@127g%4ld", numgio); + } + else //stampa a 198 + { + set_row(rr, "@93g%r", &riga._imponibile); + set_row(rr, "@109g%4s",(const char*)riga._codiva); + if (_tipo_reg == 2) + set_row(rr, "@114g%d", riga._tipodet); + set_row(rr, "@116g%r", &riga._imposta); + if (_tipoatt == "E") + set_row(rr, "@132g%d", riga._tipoatt); + set_row(rr, "@134g%d", riga._tipocr); + if (_tipo_stampa == 4) //stampa con riferimento al libro giornale + set_row(rr, "@136g%7ld", numgio); + } } _riga_rmi.destroy(); } + if (_tipo_stampa == 1) //stampa di prova + { + if (_stampa_width == 132) + { + set_row(_r, "@127g%4ld", numreg); + if (stampato) + set_row(_r, "@131g*"); //solo in stampa di prova! + } + else //198 + { + set_row(_r, "@136g%7ld", numreg); + if (stampato) + set_row(_r, "@144g*"); + } + } + if (_tipo_stampa == 4 && _stampa_width == 198) + { + TLocalisamfile rmoviva (LF_RMOVIVA); + rmoviva.zero(); + rmoviva.put(RMI_NUMREG,numreg); + TRectype rec(rmoviva.curr()); + rmoviva.read(_isgteq); + for ( ; !rmoviva.eof(); rmoviva.next()) + { + if (rmoviva.curr() != rec) break; + + int gruppo = rmoviva.get_int("GRUPPO"); + int conto = rmoviva.get_int("CONTO"); + long sottoc = rmoviva.get_long("SOTTOCONTO"); + TConto tc (gruppo,conto,sottoc); + TString80 descr = tc.descrizione(); + set_row(_r, "@144g%3d %3d %6d", gruppo, conto, sottoc); + set_row(_r, "@160g%s", (const char*) descr); + break; + } + } + + if (riga == 0) riga = ++rr; + + if (corrval != ZERO) + set_row(riga, "@30gCodice valuta %s Corrispettivo in valuta %r", (const char*) codval, &corrval); + //int tipocr = _cur->file(LF_RMOVIVA)->get_int(RMI_TIPOCR); //set_row(_r, "@124g%d", tipocr); - if (_tipo_stampa == 3) //stampa di prova - { - set_row(_r, "@125g%6d", numreg); - if (stampato) - set_row(_r, "@131g*"); - } - if (_tipo_stampa == 4) //stampa con riferimento al libro giornale - set_row(_r, "@125g%ld", numgio); + + //if (_tipo_stampa == 4) + // set_row(_r, "@125g%ld", numgio); } return TRUE; } @@ -1235,7 +1850,8 @@ void CG4400_application::aggiorna_reg() TString16 codtab; TTable Tabreg ("REG"); TTable TabInl ("%INL"); - long pag; + int mese; + //long pag; //long stampate; word ultimast = get_page_number(); @@ -1247,20 +1863,34 @@ void CG4400_application::aggiorna_reg() Tabreg.put("CODTAB", codtab); if (Tabreg.read() == NOERR) { + TDate d = Tabreg.get_date("D3"); //stampate = ultimast + 1; if (!_mov_empty) //cioe' se e' stata stampata almeno una pagina { - pag = _pagine_stampate + ultimast; - Tabreg.put("I1", pag); + TDate ultima_data = format("%02d/%02d/%4d", _datareg.last_day(_datareg.month(), _annoes), _datareg.month(), _annoes); + if (ultima_data > d) + Tabreg.put("D3", ultima_data); + //pag = _pagine_stampate + ultimast; + //Tabreg.put("I1", pag); } - Tabreg.put("D3", _data_a); + else if (_data_a > d) + Tabreg.put("D3", _data_a); + + Tabreg.put("I1", _pagine_stampate); + if (_tipo_reg == 2 && _stampa_cred_pre) + if (_mese_credito == 0 && _credito > ZERO) + if (_mov_empty) + Tabreg.put("I8", (long)_fino_a_mese); + else Tabreg.put("I8", _datareg.month()); + Tabreg.rewrite(); } - if (_tipo_stampa == 2) //stampa su libro unico - //sulla tabella %inl (indice libro unico) devo generare una riga per ogni registro stampato - if (!_mov_empty) + if (_tipo_stampa == 3) //stampa su libro unico + //sulla tabella %inl (indice libro unico) devo generare una riga per ogni registro stampato (ricordarsi che la stampa su libro unico deve avvenire mese per mese! + //inoltre non posso stampare due volte lo stesso mese perche' la stampa avviene a fine mese + if (!_mov_empty || _ok_vidi) //se ho stampato almeno un movimento oppure ho stampato la vidimazione { - bool trovato = FALSE; + bool trovato = FALSE; codtab = ""; codtab << _annoes << _codlib; TabInl.zero(); @@ -1274,12 +1904,13 @@ void CG4400_application::aggiorna_reg() { if (TabInl.curr() != rec) break; + mese = TabInl.get_int("I1"); trovato = TRUE; recprec = TabInl.curr(); + if (mese == _fino_a_mese) break; //cosi' mi posiziono su quel mese (altrimenti rischio di generare due righe per lo stesso mese e registro => la stampa di vidimazione mi sballa tutta!!! } - TString cod = ""; - if (trovato) + if (trovato && mese != _fino_a_mese) { TString16 cod_inl = recprec.get("CODTAB"); long numero_riga = atol(cod_inl.mid(7,6)) + 1; @@ -1288,29 +1919,39 @@ void CG4400_application::aggiorna_reg() nuovo = recprec; cod << cod_inl << num_riga; } - else + else if (mese != _fino_a_mese) { - TString16 num_riga ( format("%6d", 1L) ); + TString16 num_riga ( format("%6d", 0L) ); cod << codtab << num_riga; } - - long numini = _pagine_stampate + 1; + else + { + TString16 cod_inl = recprec.get("CODTAB"); + TString16 numero_riga = cod_inl.mid(7,6); + cod << codtab << numero_riga; + } + //long numini = _pagine_stampate + 1; nuovo.put("CODTAB", cod); nuovo.put("I0", (long)_annoes); - nuovo.put("I1", (long)_fino_a_mese); - nuovo.put("I2", (long)(_primast + 1)); - nuovo.put("I3", (long)(_primast + ultimast)); + nuovo.put("I1", (long)_fino_a_mese); // su libro unico ho un solo mese in gioco! + nuovo.put("I2", (long)(_primast + 1)); // numero iniziale pagina libro unico + //nuovo.put("I3", (long)(_primast + ultimast)); // numero finale pagina libro unico + nuovo.put("I3", (long)(_u_stampata)); // numero finale pagina libro unico nuovo.put("I4", get_firm()); nuovo.put("S0", _codreg); - nuovo.put("I5", (long)numini); - nuovo.put("I6", (long)(numini + ultimast - 1)); + nuovo.put("S1", _codice_vidi); + //nuovo.put("I5", (long)numini); //numero iniziale pagina registro utente + //nuovo.put("I6", (long)(numini + ultimast - 1)); //numero finale pagina registro utente + nuovo.put("I5", _numini + 1); + nuovo.put("I6", _pagine_stampate); - if (trovato) + if (mese == _fino_a_mese) TabInl.rewrite(nuovo); else TabInl.write(nuovo); - _u_stampata += ultimast; + //_u_stampata += ultimast; //ultima pagina stampata sul libro unico + aggiorna_lib(); } } @@ -1330,9 +1971,101 @@ void CG4400_application::aggiorna_lib() } } +bool CG4400_application::stampo_liquidazione(int mese) +{ + if (_liquidazione) + if ( (_frequiva == 'T' && (mese == 3 || mese == 6 || mese == 9 || mese == 12)) + || _frequiva != 'T' || (mese == 12 && _tipo_riepilogativo == 'A') ) + if ( (mese == 12 && _tipo_riepilogativo == 'A' && _mese_ultima_liq != 13) + || (mese != 12 && mese > _mese_ultima_liq) + || (mese == 12 && _tipo_riepilogativo != 'A' && mese > _mese_ultima_liq) ) + return TRUE; + + return FALSE; +} + +void CG4400_application::stampa_vidi() +{ + TTable TabInl ("%INL"); + TTable TabVid ("VID"); + TString16 codtab = ""; + TString16 codreg; + TString16 vid; + long ditta; + int mese; + _ok_vidi = FALSE; + TPrintrow row; + + printer().open(); + + codtab << _annoes << _codlib; + TabInl.zero(); + TabInl.put("CODTAB", codtab); + + TRectype rec (TabInl.curr()); + TabInl.read (_isgteq); + for (; !TabInl.eof(); TabInl.next()) + { + if (TabInl.curr() != rec) break; + ditta = TabInl.get_long("I4"); + codreg = TabInl.get("S0"); + if (ditta == get_firm() && codreg == _codreg) + { + if (!_ok_vidi) + { + ++_u_stampata; + ++_pagine_stampate; + _ok_vidi = TRUE; + } + mese = TabInl.get_int("I1"); + row.reset(); + row.put(format("%s", itom(mese)), 0); + row.put(format("%6ld", TabInl.get_long("I2")), 10); + row.put(format("%6ld", _u_stampata), 17); + row.put(format("%6ld", TabInl.get_long("I5")), 25); + row.put(format("%6ld", _pagine_stampate), 32); + vid = TabInl.get("S1"); + TabVid.zero(); + TabVid.put("CODTAB", vid); + if (TabVid.read() == NOERR) + { + row.put(format("%s", (const char*)TabVid.get("S0")), 39); + row.put(format("%7d",TabVid.get_long("I0")), 71); + row.put(format("%7d",TabVid.get_long("I1")), 79); + row.put(format("%7d",TabVid.get_long("I2")), 87); + TDate d(TabVid.get_long("D0")); + row.put(format("%s", (const char*)d.string()), 95); + row.put(format("%s", (const char*)TabVid.get("S1")), 106); + } + printer().print(row); + } + } + printer().close(); +} + print_action CG4400_application::postprocess_page (int file, int counter) { if (file == LF_MOV) + { + if (counter) //dopo aver fatto un REPEAT_PAGE (cioe' dopo aver stampato le righe settate in set_page_tot_reg()), in pratica a rottura di mese o alla fine + { + //if (_tipo_stampa != 1) aggiorna_reg(); // => l'aggiornamento viene fatto o a rottura di mese o alla fine + + reset_print(); + if (_tipo_stampa != 1) + //if (stampo_liquidazione(_datareg.month())) + { + _st_liq[_datareg.month()] = TRUE; + _intesta_liq = TRUE; + printer().formfeed(); + TFilename t; + t.temp(); + send_message('L',t, _datareg.month()); //stampa liquidazione + merge_export_file(t,FALSE,TRUE); + _intesta_liq = FALSE; + //if (_tipo_stampa != 1) aggiorna_reg(); + } + } if (!counter) { bool FINITO = FALSE; @@ -1343,10 +2076,12 @@ print_action CG4400_application::postprocess_page (int file, int counter) if ( FINITO ) { + if (_tipo_stampa == 2 || _tipo_stampa == 4) + calcola_progressivi(); set_page_tot_reg(); return REPEAT_PAGE; } - else //if ( (_tipo_stampa == 1) || (_tipo_stampa == 4) ) + else { TLocalisamfile& mov = _cur->file(LF_MOV); _cur->save_status(); @@ -1357,85 +2092,69 @@ print_action CG4400_application::postprocess_page (int file, int counter) if (_dataregs.month() != _dataregp.month()) { + if (_tipo_stampa == 2 || _tipo_stampa == 4) + calcola_progressivi(); set_page_tot_reg(); return REPEAT_PAGE; - } - } + } + } } + } return NEXT_PAGE; } -print_action CG4400_application::postprocess_print(int file, int counter) -{ - if (file == LF_MOV) - { - //aggiorna registri solo se non e' stampa di prova - if ( (_tipo_stampa != 3) && (!_stampa_tutti_i_registri) ) - aggiorna_reg(); - if (_stampa_tutti_i_registri) - //if (!_mov_empty ) - { - if (_tipo_stampa == 2) - ++ _u_stampata; - } - /* - if (_stampa_tutti_i_registri) - { - TString16 codtab; - int anno, tipo; - //vado avanti dal punto in cui sono - _tabreg->next(); - for (; !_tabreg->eof(); _tabreg->next()) - { - tipo = _tabreg->get_int("I0"); - if ( (tipo == 1) || (tipo == 2) ) //registro iva - { - codtab = _tabreg->get("CODTAB"); - anno = atoi(codtab.mid(0,4)); - break; - } - } - if ( (_tabreg->eof()) || (anno != _annoes) ) - { - if (_tipo_stampa == 2) //stampa su libro unico - aggiorna_lib(); - return NEXT_PAGE; - } - else - { - _tipo_reg = _tabreg->get_int("I0"); - _desc_lib = _tabreg->get("S0"); - _data_da = _tabreg->get_date("D3"); - _pagine_stampate = _tabreg->get_int("I1"); - _codreg = codtab.mid(4,3); - _primast = get_page_number(); - if (!_mov_empty ) - printer().formfeed(); - _cur->set_filterfunction(NULL); - _cur->set_filterfunction(filter_func); - _mov_empty = TRUE; - return REPEAT_PAGE; - } - } - */ - } - - return NEXT_PAGE; -} +/* + print_action CG4400_application::postprocess_print(int file, int counter) + { + if (file == LF_MOV) + { + if (_stampa_tutti_i_registri) + //if (!_mov_empty ) + { + if (_tipo_stampa == 3) + ++ _u_stampata; + } + } + return NEXT_PAGE; + } + */ bool CG4400_application::set_print(int n) { TMask m("cg4400a"); int giorni_del_mese; + bool ok; - // bool ok = set_ditte(m); - if (set_ditte(m)) + m.set_handler (TIPO_STAMPA, mask_tipo_stampa); + m.set_handler (A_CODICE, mask_firm_to); + m.set_handler (DA_DATA, mask_data); + m.set_handler (A_DATA, mask_data); + m.set_handler (MESE, mask_mese); + m.set_handler (FINO_A_MESE, mask_mese); + m.set_handler (CODICE_LIB_UN, mask_cod); + m.set_handler (CODICE_LIBRO_IVA, mask_libun); + m.set_handler (DLG_SELECT, mask_select); + m.set_handler (F_ANNULLA, mask_azzera); + + set_real_picture("###.###.###.###"); + + while (ok = set_ditte(m)) + { if (_selected.ones() > 0l) { _annoes = m.get_int(ANNO);//in realta' e' l'anno IVA !!! _tipo_stampa = m.get_int(TIPO_STAMPA); + _intesta_vidi = FALSE; + _stampa_width = m.get_int(STAMPA_WIDTH); + _stampa_len = m.get_int(STAMPA_LEN); + if (_stampa_width == 1) + _stampa_width = 132; + else _stampa_width = 198; + if (_stampa_len != 0) + printer().formlen(_stampa_len); + else printer().formlen(66); //Se stampa di prova l'utente indica data_da e data_a - if (_tipo_stampa == 3) + if (_tipo_stampa == 1) { _data_stampa = m.get(DATA_STAMPA); _data_da = m.get(DA_DATA); @@ -1444,124 +2163,348 @@ bool CG4400_application::set_print(int n) _data_da = format("01/01/%4d", _annoes); if (!_data_a.ok()) _data_a = format("31/12/%4d", _annoes); + TDate d(31,12,_annoes); + if (_data_a == d) + _tipo_riepilogativo = m.get(TIPO_RIEPILOGATIVO)[0]; + else _tipo_riepilogativo = ' '; printer().setdate(_data_stampa); } - // senno' data_da e' letta dal registro else //stampe definitive { - if ( (_tipo_stampa == 1) || (_tipo_stampa == 4) ) + if ( (_tipo_stampa == 2) || (_tipo_stampa == 4) ) + { _fino_a_mese = m.get_int(FINO_A_MESE); + _data_da = format("01/01/%4d", _annoes); //e non ultima data di stampa del registro (come invece verrebbe spontaneo di pensare) + } else //stampa su libro unico { _codlib = m.get(CODICE_LIB_UN); _fino_a_mese = m.get_int(MESE); _u_stampata = m.get_int(ULTIMA_PAGINA); + _rif_vid = m.get_bool(RIF_VID); + _primast = _u_stampata; + _data_da = format("01/%02d/%04d", _fino_a_mese, _annoes); //set_page_number(_u_stampata + 1); } if (_fino_a_mese == 12) + { giorni_del_mese = 31; + _tipo_riepilogativo = m.get(TIPO_RIEPILOGATIVO)[0]; + } else { + _tipo_riepilogativo = ' '; TDate primo = format("01/%02d/%4d", _fino_a_mese+1, _annoes); --primo; giorni_del_mese = primo.day(); } _data_a=format("%02d/%02d/%4d",giorni_del_mese,_fino_a_mese,_annoes); - // NB data_da viene letta nella compila_reg } - if (_tipo_stampa == 2) + _stampa_data_reg = stampa_datareg(); + if (_tipo_stampa == 3) compila_lib(); stampa_registri_IVA(m); } - else warning_box("Nessuna ditta selezionata!"); + else + { + warning_box("Nessuna ditta selezionata!"); + continue; + } + } return FALSE; - // return ok; } -void CG4400_application::stampa_registri_IVA(const TMask& m) +bool CG4400_application::stampa_registri_IVA(const TMask& m) { long l; - long firm = TApplication::get_firm(); + __firm = TApplication::get_firm(); bool ok = FALSE; - + for (l = 0l, _nditte->first(); !_nditte->eof(); l++, _nditte->next()) { if (_selected[l]) { - TApplication::set_firm(_nditte->get_long("CODDITTA")); - ok = compila_reg(m); // cerca il primo registro valido (nel caso di stampa tutti i registri), senno' legge i dati del registro specificato + bool msg = TRUE; + TApplication::set_firm(_nditte->get_long("CODDITTA")); + TString16 y; y << _annoes; + _tablia->zero(); + _tablia->put("CODTAB", y); + if (_tablia->read() == NOERR) + { + _frequiva = _tablia->get("S7")[0]; + _credito = _tablia->get_real("R0"); //credito iva anno precedente + } + else + { + warning_box("Ditta %ld: non esiste sulla tabella di liquidazione IVA annuale il record relativo all'anno %d", _nditte->get_long("CODDITTA"), _annoes); + continue; //passa alla ditta successiva, se selezionata + } + ok = compila_reg(m); if (!ok) continue; + if (_tipo_stampa == 2 || _tipo_stampa == 4) + if (!controlla_mov()) + { + TApplication::set_firm(__firm); + return fatal_box("Finire di stampare registri anno precedente"); + } if (!_stampa_tutti_i_registri) _cur->set_filterfunction(filter_func); //_frequiva = _nditte->get("FREQVIVA")[0]; - if (_tipo_stampa != 3) //stampa definitiva - ok = controlla_liquidazione() && controlla_mov(); - - if (!ok) continue; - - // send_message(); - if (!_stampa_tutti_i_registri) { + if (_liquidazione) + { + ok = controlla_liquidazione(); + if (!ok) continue; + } + for (int i=0; i < 12; i++) + _st_liq[i] = FALSE; + (*_cur) = 0L; const long item = _cur->items(); - if (item > 0) + if (item > 0) //cioe' se ci sono dei movimenti da stampare + { + if (_tipo_stampa == 2 || _tipo_stampa == 4) + { + TMask mb("cg4400b"); + mb.set(COD_LIB, _codreg); + const char* m = ""; + m = format("%02d", _stampa_mese); + mb.set(U_MESE, m); + mb.set(U_PAGINA, _pagine_stampate); + mb.set(U_DATA, _u_data.string()); + KEY tasto = mb.run(); + if (tasto != K_ENTER) continue; + } + if (_tipo_stampa != 1) + { + TFilename t; + t.temp(); + send_message('C',t, _fino_a_mese); + } print(); - if (_tipo_stampa != 3) aggiorna_reg(); - } - else - { - TString16 codtab; - int anno, tipo; - for (_tabreg->first(); !_tabreg->eof(); _tabreg->next()) - { - tipo = _tabreg->get_int("I0"); - codtab = _tabreg->get("CODTAB"); - anno = atoi(codtab.mid(0,4)); - if (anno > _annoes) - break; - if (anno == _annoes) - 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"); - 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("Ditta %ld : Il registro %s e' gia' stato stampato come bollato di %s", _nditte->get_long("CODDITTA"), (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(); - _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 == 2) - aggiorna_lib(); - } - } - - TApplication::set_firm(firm); +else +{ + _mov_empty = TRUE; + int limite; + //stampo la liquidazione per tutti i mesi fino a _fino_a_mese (in caso di stampa = 2/3/4) + if (_tipo_stampa == 2 || _tipo_stampa == 4) + limite = _stampa_mese; + if (_tipo_stampa == 3) + limite = _fino_a_mese; + printer().open(); + for (int m = limite; m > 0 && m <= _fino_a_mese; m++) + { + //if (stampo_liquidazione(m)) + { + _datareg = format("01/%02d/%4d", m, _annoes); //serve per la preprocess_header + _intesta_liq = TRUE; + TFilename t; + t.temp(); + send_message('L',t, m); + if (m > 1) printer().formfeed(); + merge_export_file(t,FALSE,TRUE); + _intesta_liq = FALSE; + } +} + printer().close(); +} +if (_tipo_stampa == 3 && _rif_vid) +{ + _intesta_vidi = TRUE; + stampa_vidi(); //stampa riferimenti vidimazione +} +} +else +{ + TString16 codtab, cod_lib_un; + int anno; + TDate sca_vid; + for (_tabreg->first(); !_tabreg->eof(); _tabreg->next()) + { + _tipo_reg = _tabreg->get_int("I0"); + codtab = _tabreg->get("CODTAB"); + anno = atoi(codtab.mid(0,4)); + if (anno > _annoes) + break; + if (anno == _annoes) + if ( _tipo_reg == 1 || _tipo_reg == 2 ) //registro iva + { + _codreg = codtab.mid(4,3); + cod_lib_un = _tabreg->get("S6"); + sca_vid = _tabreg->get_date("D0"); + if (_tipo_stampa != 1) + { + _u_data = _tabreg->get_date("D3"); + if (!_u_data.ok()) //e' la prima volta che stampo + _u_data = format("01/01/%4d", _annoes); + } + if (_tipo_stampa == 2 || _tipo_stampa == 4) + { + if (_data_a < _u_data) + { + message_box("Ditta %ld: Il registro %s e' gia' stato stampato come bollato di %s", _nditte->get_long("CODDITTA"), (const char*) _codreg, itom(_fino_a_mese)); + continue; + } + if (cod_lib_un.not_empty()) + continue; + if (sca_vid.month() < _fino_a_mese) + continue; + } + if (_tipo_stampa == 4) //stampa con riferimenti al libro giornale + { + long codditta = _nditte->get_long("CODDITTA"); + TString16 d; + TRecnotype rec = _tabreg->recno(); + bool trovato = cerca_libro_gio(d); + _tabreg->readat(rec); + if (!trovato) + continue; + } + if (_tipo_stampa == 3) //stampa su libro unico + { + if (cod_lib_un != _codlib) + continue; + if (_fino_a_mese < _u_data.month()) + continue; + if (sca_vid.month() < _fino_a_mese) + continue; + } + msg = FALSE; + _liquidazione = _tabreg->get_bool("B7"); + + if (_liquidazione) //per i registri "validi" eseguo il controllo liquidazione + { + ok = controlla_liquidazione(); + if (!ok) continue; + } + _riep_liq = _tabreg->get_bool("B6"); + _corrispettivi = _tabreg->get_bool("B0"); + _pagine_stampate = _tabreg->get_long("I1"); + _numini = _pagine_stampate; + _cod_un_loc = _tabreg->get_int("I7"); + _mese_ultima_liq = _tabreg->get_int("I4"); + _mese_credito = _tabreg->get_int("I8"); + _codatt = _tabreg->get("S8"); + _tipoatt = tipo_attivita(); + _attivita = desc_attivita(); + _desc_lib = _tabreg->get ("S0"); + _stampa_ind_ditta = _tabreg->get_bool ("B9"); + _stampa_ind_comp = _tabreg->get_bool ("B5"); + _stampa_cred_pre = _tabreg->get_bool ("B4"); + _cur->set_filterfunction(NULL); + _cur->set_filterfunction(filter_func); + + for (int i=0; i < 12; i++) + _st_liq[i] = FALSE; + // Vado a vedere se ci sono movimenti + (*_cur) = 0L; + const long items = _cur->items(); + if (items > 0) + { + if (_tipo_stampa == 2 || _tipo_stampa == 4) + { + TMask mb("cg4400b"); + mb.set(COD_LIB, _codreg); + const char* m = ""; + m = format("%02d", _stampa_mese); + mb.set(U_MESE, m); + mb.set(U_PAGINA, _pagine_stampate); + mb.set(U_DATA, _u_data.string()); + KEY tasto = mb.run(); + if (tasto != K_ENTER) continue; + } + if (_tipo_stampa != 1) + { + TFilename t; + t.temp(); + send_message('C',t, _fino_a_mese); + } + print(); + } + else + { + int limite; + _mov_empty = TRUE; + //stampo la liquidazione per tutti i mesi fino a _fino_a_mese (in caso di stampa = 2/3/4) + if (_tipo_stampa == 2 || _tipo_stampa == 4) + limite = _stampa_mese; + if (_tipo_stampa == 3) + limite = _fino_a_mese; + printer().open(); + for (int m = limite; m > 0 && m <= _fino_a_mese; m++) + { + //if (stampo_liquidazione(m)) + { + _datareg = format("01/%02d/%4d", m, _annoes); //serve per la preprocess_header + _intesta_liq = TRUE; + TFilename t; + t.temp(); + send_message('L',t, m); + if (m > 1) printer().formfeed(); + merge_export_file(t,FALSE,TRUE); + _intesta_liq = FALSE; + } + } + printer().close(); + //if (_tipo_stampa != 1) aggiorna_reg(); + } + if (_tipo_stampa == 3 && _rif_vid) + { + _intesta_vidi = TRUE; + stampa_vidi(); //stampa riferimenti vidimazione + } + } + } //for + if (msg) + message_box("Ditta %ld: Nessun registro soddisfa i parametri indicati", _nditte->get_long("CODDITTA")); +} +//if (_tipo_stampa == 3) +// aggiorna_lib(); +} +} +TApplication::set_firm(__firm); +return TRUE; } -//void CG4400_application::send_message() + +void CG4400_application::send_message(char tipo, const TFilename& nome, int mese) +{ + //const char* const app = "cg4a -2 -icon"; + const char* const app = "cg4a -2"; + TToken_string ss(10); + //int mese ; + + /* + if (tipo == 'L') + { + if (_tipo_stampa == 3) //stampa su libro unico + mese = _fino_a_mese; + if (_tipo_stampa == 2 || _tipo_stampa == 4) + mese = _datareg.month(); + } + else mese = _fino_a_mese; + */ + + ss.add(_annoes); + ss.add(mese); + ss.add(_nditte->get_long("CODDITTA")); + ss.add(tipo); + + //if (tipo == 'L') + //{ + ss.add(_data_stampa.string()); + ss.add(nome); + ss.add("x"); + //} + + TMessage liq ("cg4a -2", "RCL", ss); + liq.send(); + + TExternal_app pn(app); + pn.run(); +} bool CG4400_application::set_ditte(TMask& m) { @@ -1572,45 +2515,31 @@ bool CG4400_application::set_ditte(TMask& m) m.field(A_CODICE).set(""); m.field(TIPO_STAMPA).set("1"); - m.set_handler (A_CODICE, mask_firm_to); - m.set_handler (DA_DATA, mask_data); - m.set_handler (A_DATA, mask_data); - m.set_handler (MESE, mask_mese); - m.set_handler (FINO_A_MESE, mask_mese); - m.set_handler (CODICE_LIB_UN, mask_cod); - m.set_handler (DLG_SELECT, mask_select); - m.set_handler (F_ANNULLA, mask_azzera); - KEY tasto; - - _stampa_width = 132; - set_real_picture("###.###.###.###"); - tasto = m.run(); - // m.first_focus(tasto); - return tasto == K_ENTER; } -TRectype& look_comuni (const char * cod, TLocalisamfile *comuni) +TRectype& CG4400_application::look_comuni (const char * cod) { - comuni->zero(); - comuni->put(COM_COM, cod); - comuni->read(); - if (comuni->bad()) - comuni->zero(); + _com->zero(); + _com->put(COM_COM, cod); + _com->read(); + if (_com->bad()) + _com->zero(); - return comuni->curr(); + return _com->curr(); } void CG4400_application::get_dati_ditta() { TLocalisamfile nditte(LF_NDITTE); - TLocalisamfile anag(LF_ANAG); + TLocalisamfile anag(LF_ANAG); + TLocalisamfile unloc(LF_UNLOC); TString codanagr; TString tipoa; - + nditte.zero(); nditte.put(NDT_CODDITTA, get_firm()); nditte.read(); @@ -1633,25 +2562,43 @@ void CG4400_application::get_dati_ditta() _comunefis = anag.get(ANA_COMRF); if (_comunefis.empty()) - _comunefis = anag.get(ANA_COMRES); + _comunefis = anag.get(ANA_COMRES); - TRectype dep = look_comuni (_comunefis, _com); + TRectype dep = look_comuni (_comunefis); _comunefis = dep.get(COM_DENCOM); _provfis = dep.get(COM_PROVCOM); _cap = dep.get(COM_CAPCOM); if (_comunefis.empty()) { - _viafis = anag.get(ANA_INDRF); + _viafis = anag.get(ANA_INDRF); _viafis.rtrim(); _viafis << " " << anag.get (ANA_CIVRF); } else { - _viafis = anag.get(ANA_INDRES); + _viafis = anag.get(ANA_INDRES); _viafis.rtrim(); _viafis << " " << anag.get (ANA_CIVRES); - } + } + + if (_cod_un_loc) + { + unloc.zero(); + unloc.put(ULC_CODDITTA, get_firm()); + unloc.put(ULC_CODULC, _cod_un_loc); + unloc.read(); + if (unloc.read() == NOERR) + { + TRectype dep = look_comuni (unloc.get(ULC_COMULC)); + _comunefis = dep.get(COM_DENCOM); + _provfis = dep.get(COM_PROVCOM); + _cap = dep.get(COM_CAPCOM); + _viafis = unloc.get(ULC_INDULC); + _viafis.rtrim(); + _viafis << " " << unloc.get(ULC_CIVULC); + } + } } int CG4400_application::stampa_intestazione() @@ -1659,8 +2606,7 @@ int CG4400_application::stampa_intestazione() int r = 1; TString codice_ditta; TString riga(_stampa_width); - //TString riga(132); - + get_dati_ditta(); codice_ditta << get_firm(); @@ -1670,15 +2616,13 @@ int CG4400_application::stampa_intestazione() (const char*)_provfis); r++; //printer().setdate(_data); - if (_tipo_stampa == 3) - riga = "STAMPA DI PROVA Data @<"; - //else - // riga = "Data @<"; - riga.right_just(_stampa_width-6); - //riga.right_just(127); - riga.overwrite (format ("Partita iva %s Codice fiscale %s", (const char*)_paiva, (const char*)_cofi)); - set_header (r, "%s", (const char*) riga); - r++; + if (_tipo_stampa == 1) + { + riga = "REGISTRO DI PROVA Data @<"; + riga.right_just(_stampa_width-6); + } + riga.overwrite (format("Partita iva %s Codice fiscale %s", (const char*)_paiva, (const char*)_cofi)); + set_header (r, riga); return r; } @@ -1686,75 +2630,158 @@ int CG4400_application::stampa_intestazione() void CG4400_application::preprocess_header() { int r=1; - TString cor, nd1, nd2; + char cor, nd1, nd2; + char tipo = ' '; + char type = ' '; + int mese, anno; TString riga(_stampa_width); - TString data; + TString data(30); - 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.format("%s %s %d", (const char*)"mese di", itom(_data_da.month()), _annoes); + riga.fill('-'); + + if (_tipo_stampa != 3) + { + mese = _datareg.month(); + anno = _datareg.year(); + } + else + { + mese = _fino_a_mese; + anno = _annoes; + } + + data.format("%s %s %d", "mese di", itom(mese), anno); reset_header(); - if (_tipo_stampa != 3) + if (_tipo_stampa == 2 || _tipo_stampa == 4) + { if (_stampa_ind_ditta) r = stampa_intestazione(); + } + else //se stampa di prova o su libro unico l'intestazione della ditta va sempre stampata + r = stampa_intestazione(); - if (_tipo_stampa == 2) + if (_tipo_stampa == 3 && !_intesta_vidi) { - long num = _u_stampata + 1; - set_header(r++, "@94gProgr.Studio %ld@114gProgr.Utente @#", num); + ++_u_stampata; + ++_pagine_stampate; } - - set_header(r, "Registro IVA: %s %s %s Attivita\' %s %s", - (const char *) _codreg, (const char *) _desc_lib, - (const char *) data, (const char *) _codatt, - (const char *) _attivita); + + if (_tipo_stampa == 3) + //set_header(r, "@94gProgr.Studio %ld@114gProgr.Utente @#", _u_stampata); + set_header(r, "@94gProgr.Studio %ld@114gProgr.Utente %ld", _u_stampata, _pagine_stampate); + + if (_tipo_stampa != 1) aggiorna_reg(); //cosi' sono sicura che l'aggiornamento viene fatto ad ogni salto pagina (cioe' a rottura di mese) + r++; - riga.fill('-'); - set_header(r, riga); - r++; - if (_tipo_reg == 1) //registro vendite + + if (!_intesta_vidi) + set_header(r, "Registro IVA: %s %s %s Attivita\' %s %s", + (const char *) _codreg, (const char *) _desc_lib, + (const char *) data, (const char *) _codatt, + (const char *) _attivita); + else { - cor = "R"; - nd1 = ""; - nd2 = ""; - } - if (_tipo_reg == 2) - { - cor = "C"; - nd1 = "N"; - nd2 = "D"; + set_header(r++, "Registro IVA: %s %s", (const char *) _codreg, (const char *) _desc_lib); + set_header(r, "RIFERIMENTI VIDIMAZIONE"); } - if (_tipo_stampa == 3) //stampa di prova + + if (_intesta_liq) { - set_header(r,"@10gNum.@19gDocumento@68gT Tipo@103gCod %s@121g@124gT@128gNum", (const char*) nd1); r++; - set_header(r, "Data reg. prot.@17gData@25gNumero Codice Ragione sociale/descrizione@68gO Doc.@76gTotale doc.@91gImponibile Iva %s@112gImposta@124g%s@128gReg", (const char*) nd2, (const char*) cor); - r++; - } + set_header(r++, "CALCOLO LIQUIDAZIONE IVA"); + set_header(r++,riga); + TString title (80); + title << "Liquidazione IVA del periodo: "; + title << format(" %s %d", itom(mese), anno); + set_header(r++, "%s@102g Frequenza %s", (const char*) title, _frequiva == 'T' ? "T" : "M"); + set_header(r++,riga); + set_header(r,""); + } else { - set_header(r,"@10gNum.@19gDocumento@68gT Tipo@103gCod %s@121g@124gT", (const char*) nd1); + r++; + set_header(r, riga); + r++; + if (_tipo_reg == 1) //registro vendite + { + cor = 'R'; + nd1 = NULL; + nd2 = NULL; + } + if (_tipo_reg == 2) + { + cor = 'C'; + nd1 = 'N'; + nd2 = 'D'; + } + if (_tipoatt == "E") //attivita' mista + { + tipo = 'A'; + type = 'T'; + } + if (_stampa_data_reg && _stampa_width == 132) + set_header(r,"Data I/P"); + if (_tipo_stampa == 1) //stampa di prova (_intesta_vidi e' di sicuro FALSE) + { + if (_stampa_width == 132) + { + set_header(r,"@10gNum.@19gDocumento@68gT Tipo@76gIncassi/Pag.@103gCod %c@124gT %c@128gNum", nd1, tipo); + r++; + set_header(r, "Data reg. prot.@17gData@25gNumero Codice Ragione sociale/descrizione@68gO Doc.@76gTotale doc.@91gImponibile Iva %c@112gImposta@124g%c %c@128gReg", nd2, cor, type); + r++; + } + else //stampa a 198 + { + set_header(r,"Registrazione Documento@68gT Tipo@80gTot.Inc./Pag.@110gCod %c@132g%c T@139gNum.", nd1, tipo, cor); + r++; + set_header(r, "Data Protocollo Data@25gNumero Codice Ragione sociale/descrizione@68gO Documento@80gTot.Documento@99gImponibile Iva %c@124gImposta@132g%c %c@139gReg.", nd2, type, cor); + r++; + } + } +else if (!_intesta_vidi) +{ + if (_stampa_width == 132) + { + set_header(r,"@10gNum.@19gDocumento@68gT Tipo@76gIncassi/Pag.@103gCod %c@124gT %c", nd1, tipo); if (_tipo_stampa == 4) //stampa definitiva con rif. al libro giornale set_header(r, "@128gNum."); r++; - set_header(r, "Data reg. prot.@17gData@25gNumero Codice Ragione sociale/descrizione@68gO Doc.@76gTotale doc.@91gImponibile Iva %s@112gImposta@124g%s", - (const char*) nd2, (const char*) cor); + set_header(r, "Data reg. prot.@17gData@25gNumero Codice Ragione sociale/descrizione@68gO Doc.@76gTotale doc.@91gImponibile Iva %c@112gImposta@124g%c %c", + nd2, cor, type); if (_tipo_stampa == 4) set_header(r, "@128gop."); r++; - } - riga.fill('-'); + } + else //stampa a 198 + { + set_header(r,"Registrazione Documento@68gT Tipo@80gTot.Inc./Pag.@110gCod %c@132g%c T", nd1, tipo); + if (_tipo_stampa == 4) + set_header(r, "@139gNum."); + r++; + set_header(r, "Data Protocollo Data@25gNumero Codice Ragione sociale/descrizione@68gO Documento@80gTot.Documento@99gImponibile Iva %c@124gImposta@132g%c %c", nd2, type, cor); + if (_tipo_stampa == 4) + set_header(r, "@139gop. @144gCodice conto @160gDescrizione sottoconto"); + r++; + } +} +else if (_tipo_stampa == 3 && _intesta_vidi) +{ + TString tr(52); + tr.fill('-'); + set_header(r++,"@10gPagine studio Pagine utente ---------------- V I D I M A Z I O N E %s", (const char*)tr); + set_header(r++,"Mese@12gda@20ga@27gda@35ga Intestatario@71gN.fogli Pag.in. Pag.fin. Data Ufficio"); +} +if (_stampa_ind_comp && !_intesta_vidi) + set_header(r++, "@39gGeneralita'"); + set_header(r, riga); } +} int cg4400 (int argc, char * argv[]) -{ +{ CG4400_application a; a.run(argc, argv, "Stampa registri IVA"); return 0; diff --git a/cg/cg4400.h b/cg/cg4400.h index a2690c0d2..84a0b8917 100755 --- a/cg/cg4400.h +++ b/cg/cg4400.h @@ -1,104 +1,127 @@ -// -// cg4400.h -// -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "cglib03.h" - -const int TABREG = (int)TTable::name2log("REG"); - -class CG4400_application : public TPrintapp -{ - TCursor * _cur; - TRelation *_rel; - TLocalisamfile *_clifo, *_nditte, *_occas, *_tab, *_tabcom, *_com, *_anag; - TTable *_tabreg, *_tablbu, *_tabinl, *_tablim, *_tabpim, *_tablia, *_tabiva; - TRigaiva_array _iva_array, _riga_rmi; - TTipodoc_array _doc_array; - TRiga_array _tot_iva_array; - - TBit_array _selected; - TArray_sheet *_ditte; - - TRecnotype _nrec; - bool _mov_empty, _stampa_ind_ditta, _stampa_tutti_i_registri, _auto_intraf; - bool _corrispettivi, _esiste_riga_iva; - char _frequiva; - TDate _data_da, _data_a, _data_stampa, _dataregp, _dataregs, _datareg; - long _n_ditte, _u_stampata, _primast; - int _fino_a_mese, _tipo_reg, _tipo_stampa, _pagine_stampate; - int _annoes, _r, _stampa_width; // riga corrente di stampa - real _totale_doc; - TString _codreg, _desc_lib, _codatt, _attivita; - TString _tipodoc, _descr_doc, _codlib; - TString _cofi,_cap,_paiva,_ragsoc,_comunefis,_provfis,_viafis; - -protected: - const char* desc_attivita (const char * codatt); - const char* descr_doc (const char * tipo); - const char* descr_iva (const char * cod); - const char* ricerca_cf (char tipocf, long codcf); - const char* ricerca_occ(const char * occ); - int setta_riga (int, const TRigaiva&, real&, real&, real&, real&); - int riga_rmoviva(); - bool set_print(int); - bool set_ditte(TMask&); - bool compila_reg(const TMask&); - bool compila_lib(); - bool controlla_liquidazione(); - bool controlla_mov(); - bool ventilazione(const char*); - void cerca_reg(const TString&, byte&, TDate&); - //void leggi_movimenti(const TDate&, const TString&, bool&); - void stampa_registri_IVA(const TMask&); - void set_page_tot_reg(); - void aggiorna_reg(); - void aggiorna_lib(); - void calcola_progressivi(real&, real&, const char*, const int); - bool user_create(); - bool user_destroy(); - bool preprocess_page(int, int); - int stampa_intestazione(); - int stampa_prospetto(); - void get_dati_ditta(); - void stampa_acquisti(int); - bool preprocess_print(int, int); - print_action postprocess_print(int, int); - print_action postprocess_page (int, int); - void preprocess_header(); - - static bool filter_func (const TRelation * r); - - static bool mask_firm_to (TMask_field&, KEY); - static bool mask_cod (TMask_field&, KEY); - static bool mask_data (TMask_field&, KEY); - static bool mask_mese (TMask_field&, KEY); - static bool mask_fino_a_mese (TMask_field&, KEY); - static bool mask_select (TMask_field&, KEY); - static bool mask_azzera (TMask_field&, KEY); - -public: - - CG4400_application() : TPrintapp(), _ditte(NULL) {} - virtual ~CG4400_application() {} -}; - - - - +// +// cg4400.h +// +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "cglib03.h" + +const int TABREG = (int)TTable::name2log("REG"); + +class CG4400_application : public TPrintapp +{ + TCursor * _cur; + TRelation *_rel; + TLocalisamfile *_clifo, *_nditte, *_occas, *_tab, *_tabcom, *_com, *_anag, *_unloc, *_attiv; + TTable *_tabreg, *_tablbu, *_tabinl, *_tablim, *_tabpim, *_tablia, *_tabiva; + TTable *_tabpla, *_tabppa, *_tabvid; + TRigaiva_array _iva_array, _riga_rmi; + TTipodoc_array _doc_array; + TRiga_array _tot_iva_array; + + TBit_array _selected; + TArray_sheet *_ditte; + bool _st_liq[12]; + TRecnotype _nrec; + bool _mov_empty, _stampa_ind_ditta, _stampa_tutti_i_registri, _auto_intraf, _stampa; + bool _corrispettivi, _liquidazione, _riep_liq, _stampa_ind_comp, _esiste_riga_iva, _stampa_cred_pre; + bool _rif_vid, _intesta_vidi, _intesta_liq, _stampa_data_reg, _ok_vidi; + char _frequiva, _tipo_riepilogativo; + TDate _data_da, _data_a, _data_stampa, _dataregp, _dataregs, _datareg; + TDate _u_data; + long _n_ditte, _u_stampata, _primast, __firm, _uprotivap; + long _numini, _pagine_stampate; + int _fino_a_mese, _tipo_reg, _tipo_stampa, _cod_un_loc; + int _annoes, _r, _stampa_width, _mese_ultima_liq, _mese_credito; + int _stampa_len, _stampa_mese; + real _totale_doc, _credito; + TString _codreg, _desc_lib, _codatt, _attivita, _tipoatt; + TString _tipodoc, _descr_doc, _codlib, _codice_vidi; + TString _cofi,_cap,_paiva,_ragsoc,_comunefis,_provfis,_viafis; + +protected: + const char* desc_attivita (); + const char* tipo_attivita (); + const char* descr_doc (); + const char* descr_iva (const char *); + TRectype& ricerca_occ(const char*); + TRectype& ricerca_cf (char, long); + TRectype& look_comuni(const char*); + int setta_riga (int, const TRigaiva&, real&, real&, real&, real&); + int riga_rmoviva(); + bool set_print(int); + bool set_ditte(TMask&); + bool compila_reg(const TMask&); + bool compila_lib(); + bool controlla_liquidazione(); + bool controlla_mov(); + bool stampo_liquidazione(int); + bool ventilazione(const char*); + bool cerca_libro_gio(TString&); + bool look_reg (long, int, TString&, int, const char*, int*); + bool look_regs(int, TString&, int, int*); + bool stampa_totali_finali(); + bool stampa_datareg(); + bool stampa_registri_IVA(const TMask&); + void cerca_reg(const TString&, byte*); + void set_page_tot_reg(); + void send_message(char, const TFilename&,int); + void aggiorna_reg(); + void aggiorna_lib(); + void calcola_progressivi(); + bool user_create(); + bool user_destroy(); + bool preprocess_page(int, int); + int stampa_intestazione(); + int stampa_prospetto(); + void stampa_plafonds(int); + void get_dati_ditta(); + void stampa_vidi(); + int stampa_acquisti(int); + real stampa_valori_plafonds(const real&, const int, TTable&); + bool preprocess_print(int, int); + //print_action postprocess_print(int, int); + print_action postprocess_page (int, int); + void preprocess_header(); + + static bool filter_func (const TRelation * r); + + static bool mask_tipo_stampa (TMask_field&, KEY); + static bool mask_firm_to (TMask_field&, KEY); + static bool mask_cod (TMask_field&, KEY); + static bool mask_libun (TMask_field&, KEY); + static bool mask_data (TMask_field&, KEY); + static bool mask_mese (TMask_field&, KEY); + static bool mask_fino_a_mese (TMask_field&, KEY); + static bool mask_select (TMask_field&, KEY); + static bool mask_azzera (TMask_field&, KEY); + +public: + + CG4400_application() : TPrintapp(), _ditte(NULL) {} + virtual ~CG4400_application() {} +}; + + + + diff --git a/cg/cg4400a.h b/cg/cg4400a.h index a348a49b3..17a197327 100755 --- a/cg/cg4400a.h +++ b/cg/cg4400a.h @@ -1,27 +1,29 @@ -// cg4400a.h -// Maschera stampa tabella registri -#define TIPO_STAMPA 101 -#define DATA_STAMPA 102 -#define CODICE_LIBRO 103 -#define DA_DATA 104 -#define A_DATA 105 -#define FINO_A_MESE 106 -#define ULTIMA_PAGINA 107 -#define CODICE_LIBRO_IVA 108 -#define ULTIMO_MESE 109 -#define TIPO_RIEPILOGATIVO 110 -#define ANNO 111 -#define DA_CODICE 112 -#define A_CODICE 113 -#define F_SELECT 114 -#define F_ANNULLA 115 -#define F_VERIFICA 116 -#define CODICE_LIB_UN 117 -#define MESE 118 -#define CODICE_LIBRO_PROVA 119 -#define RIF_VID 120 - - - - - +// cg4400a.h +// Maschera stampa tabella registri +#define TIPO_STAMPA 101 +#define DATA_STAMPA 102 +#define CODICE_LIBRO 103 +#define DA_DATA 104 +#define A_DATA 105 +#define FINO_A_MESE 106 +#define ULTIMA_PAGINA 107 +#define CODICE_LIBRO_IVA 108 +#define ULTIMO_MESE 109 +#define TIPO_RIEPILOGATIVO 110 +#define ANNO 111 +#define DA_CODICE 112 +#define A_CODICE 113 +#define F_SELECT 114 +#define F_ANNULLA 115 +#define F_VERIFICA 116 +#define CODICE_LIB_UN 117 +#define MESE 118 +#define CODICE_LIBRO_PROVA 119 +#define RIF_VID 120 +#define STAMPA_WIDTH 121 +#define STAMPA_LEN 122 + + + + + diff --git a/cg/cg4400a.uml b/cg/cg4400a.uml index da55e9cde..06058a613 100755 --- a/cg/cg4400a.uml +++ b/cg/cg4400a.uml @@ -1,255 +1,270 @@ -// cg4400a.uml -// Stampa tabella registri - -#include "cg4400a.h" - -PAGE "Stampa registri IVA" -1 -1 56 18 - - -LISTBOX TIPO_STAMPA 1 48 -BEGIN - PROMPT 2 1 "Tipo " - HELP "Indicare il tipo di stampa da eseguire" - ITEM "3|Stampa di prova" - MESSAGE SHOW,3@|SHOW,CODICE_LIBRO_PROVA|SHOW,DATA_STAMPA|HIDE,1@|RESET,1@|HIDE,2@|RESET,2@ - ITEM "1|Libri bollati della ditta" - MESSAGE SHOW,1@|HIDE,CODICE_LIBRO_PROVA|RESET,CODICE_LIBRO_PROVA|HIDE,2@|RESET,2@|HIDE,3@|RESET,3@|HIDE,DATA_STAMPA - ITEM "2|Libri unici dello studio" - MESSAGE SHOW,2@|HIDE,1@|RESET,1@|HIDE,3@|RESET,3@|HIDE,DATA_STAMPA|HIDE,CODICE_LIBRO_PROVA|RESET,CODICE_LIBRO_PROVA - ITEM "4|Libri con riferimenti al libro giornale" - MESSAGE SHOW,1@|HIDE,CODICE_LIBRO_PROVA|RESET,CODICE_LIBRO_PROVA|HIDE,2@|RESET,2@|HIDE,3@|RESET,3@|HIDE,DATA_STAMPA -END - -GROUPBOX DLG_NULL 35 5 -BEGIN - PROMPT 20 2 "Scelta ditte" -END - -NUMBER DA_CODICE 5 -BEGIN - PROMPT 21 3 "Da codice " - HELP "Codice ditta di partenza per la selezione" - USE LF_NDITTE KEY 1 - CHECKTYPE NORMAL - INPUT CODDITTA DA_CODICE - DISPLAY "Codice" CODDITTA - DISPLAY "Ragione sociale@50" RAGSOC - OUTPUT DA_CODICE CODDITTA -END - -NUMBER A_CODICE 5 -BEGIN - PROMPT 21 4 "A codice " - HELP "Codice ditta di fine selezione" - COPY USE DA_CODICE - CHECKTYPE NORMAL - INPUT CODDITTA A_CODICE - COPY DISPLAY DA_CODICE - OUTPUT A_CODICE CODDITTA -END - -STRING F_SELECT 5 -BEGIN - PROMPT 21 5 "Scelte n. " - FLAGS "D" -END - -BUTTON DLG_SELECT 9 2 -BEGIN - PROMPT 42 3 "~Selezione" - HELP "Indicare le ditta da selezionare per la stampa" -END - -BUTTON F_ANNULLA 9 -BEGIN - PROMPT 42 5 "A~zzera" - HELP "Togliere la selezione alle ditte" - MESSAGE RESET,DA_CODICE|RESET,A_CODICE -END - -DATE DATA_STAMPA -BEGIN - PROMPT 28 7 "Data stampa " -<<<<<<< cg4400a.uml - FLAGS "A" - CHECKTYPE REQUIRED - WARNING "Inserire la data di stampa" -======= - HELP "Data in cui viene stampato il registro" - FLAG "AH" - GROUP 3 ->>>>>>> 1.14 -END - -NUMBER ANNO 4 -BEGIN - PROMPT 2 3 "Anno " - HELP "Anno di cui si vuole stampare il registro" - FLAGS "A" - WARNING "Inserire l'anno" - CHECKTYPE REQUIRED -END - -STRING CODICE_LIBRO 3 -BEGIN - PROMPT 2 7 "Codice libro " - HELP "Codice libro di cui si chiede la stampa; nel caso in cui non si indichi nessun codice verranno stampati tutti i libri delle ditte selezionate" - USE REG SELECT (I0<"3") && (S6=="") && (CODTAB[1,4]==#111) - INPUT CODTAB[1,4] ANNO - INPUT CODTAB[5,7] CODICE_LIBRO - DISPLAY "Anno " CODTAB[1,4] - DISPLAY "Codice " CODTAB[5,7] - DISPLAY "Descrizione @40" S0 - OUTPUT ANNO CODTAB[1,4] - OUTPUT CODICE_LIBRO CODTAB[5,7] - //CHECKTYPE NORMAL - FLAGS "UZ" - GROUP 1 -END - -STRING CODICE_LIBRO_PROVA 3 -BEGIN - PROMPT 2 7 "Codice libro " - HELP "Codice libro di cui si chiede la stampa; nel caso in cui non si indichi nessun codice verranno stampati tutti i libri delle ditte selezionate" - USE REG SELECT (I0<"3") && (CODTAB[1,4]==#111) - INPUT CODTAB[1,4] ANNO - INPUT CODTAB[5,7] CODICE_LIBRO_PROVA - DISPLAY "Anno " CODTAB[1,4] - DISPLAY "Codice " CODTAB[5,7] - DISPLAY "Descrizione @40" S0 - OUTPUT ANNO CODTAB[1,4] - OUTPUT CODICE_LIBRO_PROVA CODTAB[5,7] -<<<<<<< cg4400a.uml - FLAGS "UR" -======= - //CHECKTYPE NORMAL - FLAGS "UZ" - GROUP 1 ->>>>>>> 1.15 -END - -STRING CODICE_LIB_UN 3 -BEGIN - PROMPT 2 7 "Libro unico " - HELP "Codice del libro unico su cui deve essere effettuata la stampa" - USE %LBU SELECT CODTAB[1,4]==#111 - INPUT CODTAB[1,4] ANNO - INPUT CODTAB[5,7] CODICE_LIB_UN - DISPLAY "Anno " CODTAB[1,4] - DISPLAY "Codice " CODTAB[5,7] - DISPLAY "Descrizione @40" S0 - OUTPUT ANNO CODTAB[1,4] - OUTPUT CODICE_LIB_UN CODTAB[5,7] - FLAGS "UR" - CHECKTYPE REQUIRED - WARNING "Inserire il codice del libro unico" - GROUP 2 -END - -GROUPBOX DLG_NULL 52 3 -BEGIN - PROMPT 2 8 "Stampa movimenti" -END - -DATE DA_DATA -BEGIN - PROMPT 5 9 "Dalla data " - HELP "Data di partenza per la stampa del registro" - GROUP 3 -END - -DATE A_DATA -BEGIN - PROMPT 30 9 "Alla data " - HELP "Data di fine per la stampa del registro" - VALIDATE DATE_CMP_FUNC >= DA_DATA - WARNING "Inserire una data non inferiore alla data limite inferiore" - GROUP 3 -END - -LISTBOX FINO_A_MESE 10 -BEGIN - PROMPT 5 9 "Fino al mese " - HELP "Mese fino al quale eseguire la stampa" - FLAGS "M" - GROUP 1 -END - -LISTBOX MESE 10 -BEGIN - PROMPT 5 9 "Mese " - HELP "Mese di cui eseguire la stampa" - FLAGS "M" - GROUP 2 -END - -LISTBOX TIPO_RIEPILOGATIVO 11 -BEGIN - PROMPT 2 11 "Tipo riepilogativo " - HELP "Indicare il periodo di cui si vuole stampare il registro" - ITEM "P|Del periodo" - ITEM "A|Annuale" - GROUP 1 -END - -LISTBOX ULTIMO_MESE 10 -BEGIN - PROMPT 2 12 "Ultimo mese stampa su libro unico " - FLAGS "MD" - GROUP 2 -END - -NUMBER ULTIMA_PAGINA 4 -BEGIN -<<<<<<< cg4400a.uml - PROMPT 2 13 "Ultimo numero di pagina stampata libro unico " -======= - PROMPT 2 12 "Ultimo numero di pagina stampata libro unico " - HELP "Numero dell'ultima pagina del libro unico stampata" ->>>>>>> 1.14 - FLAGS "R" - GROUP 2 -END - -STRING CODICE_LIBRO_IVA 3 -BEGIN -<<<<<<< cg4400a.uml - PROMPT 2 14 "Eventuale codice libro IVA " - HELP "Se non viene indicato nessun cod. libro IVA, vengono stampati tutti i registri delle ditte selezionate" -======= - PROMPT 2 13 "Eventuale codice libro IVA " - HELP "Libro IVA da stampare. Vuoto = tutti" ->>>>>>> 1.14 - USE REG SELECT (I0<"3") && (S6=="") && (CODTAB[1,4]==#111) - INPUT CODTAB[1,4] ANNO - INPUT CODTAB[5,7] CODICE_LIBRO_IVA - DISPLAY "Anno " CODTAB[1,4] - DISPLAY "Codice " CODTAB[5,7] - DISPLAY "Descrizione @40" S0 - OUTPUT ANNO CODTAB[1,4] - OUTPUT CODICE_LIBRO_IVA CODTAB[5,7] - //CHECKTYPE NORMAL - FLAGS "UZ" - GROUP 2 -END - -BOOLEAN RIF_VID -BEGIN - PROMPT 2 15 "Stampa riferimenti vidimazione" - GROUP 2 -END - -BUTTON DLG_PRINT 10 2 -BEGIN - PROMPT -12 -1 "~Stampa" - MESSAGE EXIT,K_ENTER -END - -BUTTON DLG_QUIT 10 2 -BEGIN - PROMPT -22 -1 "" -END - -ENDPAGE - -ENDMASK +// cg4400a.uml +// Stampa tabella registri + +#include "cg4400a.h" + +PAGE "Stampa registri IVA" -1 -1 56 18 + +LISTBOX TIPO_STAMPA 1 48 +BEGIN + PROMPT 2 1 "Tipo " + HELP "Indicare il tipo di stampa da eseguire" + ITEM "1|Stampa di prova" + MESSAGE SHOW,3@|SHOW,CODICE_LIBRO_PROVA|SHOW,DATA_STAMPA|HIDE,1@|RESET,1@|HIDE,2@|RESET,2@|HIDE,4@|RESET,4@ + ITEM "2|Libri bollati della ditta" + MESSAGE SHOW,1@|HIDE,CODICE_LIBRO_PROVA|RESET,CODICE_LIBRO_PROVA|HIDE,2@|RESET,2@|HIDE,3@|RESET,3@|HIDE,DATA_STAMPA|HIDE,4@|RESET,4@ + ITEM "3|Libri unici dello studio" + MESSAGE SHOW,2@|HIDE,1@|RESET,1@|HIDE,3@|RESET,3@|HIDE,DATA_STAMPA|HIDE,CODICE_LIBRO_PROVA|RESET,CODICE_LIBRO_PROVA|HIDE,4@|RESET,4@ + ITEM "4|Libri con riferimenti al libro giornale" + MESSAGE SHOW,1@|HIDE,CODICE_LIBRO_PROVA|RESET,CODICE_LIBRO_PROVA|HIDE,2@|RESET,2@|HIDE,3@|RESET,3@|HIDE,DATA_STAMPA|HIDE,4@|RESET,4@ +END + +GROUPBOX DLG_NULL 35 5 +BEGIN + PROMPT 20 2 "Scelta ditte" +END + +NUMBER DA_CODICE 6 +BEGIN + PROMPT 21 3 "Da codice " + FLAGS "UR" + HELP "Codice ditta di inizio selezione" + USE LF_NDITTE KEY 1 + //CHECKTYPE NORMAL + INPUT CODDITTA DA_CODICE + DISPLAY "Codice" CODDITTA + DISPLAY "Ragione sociale@50" RAGSOC + OUTPUT DA_CODICE CODDITTA +END + +NUMBER A_CODICE 6 +BEGIN + PROMPT 21 4 "A codice " + FLAGS "UR" + HELP "Codice ditta di fine selezione" + COPY USE DA_CODICE + //CHECKTYPE NORMAL + INPUT CODDITTA A_CODICE + COPY DISPLAY DA_CODICE + OUTPUT A_CODICE CODDITTA +END + +STRING F_SELECT 6 +BEGIN + PROMPT 21 5 "Scelte n. " + FLAGS "DR" +END + +BUTTON DLG_SELECT 9 2 +BEGIN + PROMPT 42 3 "~Selezione" + HELP "Indicare le ditte da selezionare per la stampa" +END + +BUTTON F_ANNULLA 9 +BEGIN + PROMPT 42 5 "A~zzera" + HELP "Annullare la selezione delle ditte" + MESSAGE RESET,DA_CODICE|RESET,A_CODICE +END + +DATE DATA_STAMPA +BEGIN + PROMPT 28 7 "Data stampa " + FLAGS "A" + CHECKTYPE REQUIRED + WARNING "Inserire la data di stampa" +END + +NUMBER ANNO 4 +BEGIN + PROMPT 2 3 "Anno " + HELP "Anno di cui si vuole stampare il registro" + FLAGS "A" + WARNING "Inserire l'anno" + CHECKTYPE REQUIRED +END + +STRING CODICE_LIBRO 3 +BEGIN + PROMPT 2 7 "Codice libro " + HELP "Codice libro di cui si chiede la stampa; nel caso in cui non si indichi nessun codice verranno stampati tutti i libri delle ditte selezionate" + USE REG SELECT (I0<"3") && (S6=="") && (CODTAB[1,4]==#111) + INPUT CODTAB[1,4] ANNO + INPUT CODTAB[5,7] CODICE_LIBRO + DISPLAY "Anno " CODTAB[1,4] + DISPLAY "Codice " CODTAB[5,7] + DISPLAY "Descrizione @40" S0 + OUTPUT ANNO CODTAB[1,4] + OUTPUT CODICE_LIBRO CODTAB[5,7] + //CHECKTYPE NORMAL + FLAGS "UR" + GROUP 1 +END + +STRING CODICE_LIBRO_PROVA 3 +BEGIN + PROMPT 2 7 "Codice libro " + HELP "Codice libro di cui si chiede la stampa; nel caso in cui non si indichi nessun codice verranno stampati tutti i libri delle ditte selezionate" + USE REG SELECT (I0<"3") && (CODTAB[1,4]==#111) + INPUT CODTAB[1,4] ANNO + INPUT CODTAB[5,7] CODICE_LIBRO_PROVA + DISPLAY "Anno " CODTAB[1,4] + DISPLAY "Codice " CODTAB[5,7] + DISPLAY "Descrizione @40" S0 + OUTPUT ANNO CODTAB[1,4] + OUTPUT CODICE_LIBRO_PROVA CODTAB[5,7] + FLAGS "UR" +END + +STRING CODICE_LIB_UN 3 +BEGIN + PROMPT 2 7 "Libro unico " + HELP "Codice del libro unico su cui deve essere effettuata la stampa" + USE %LBU SELECT CODTAB[1,4]==#111 + INPUT CODTAB[1,4] ANNO + INPUT CODTAB[5,7] CODICE_LIB_UN + DISPLAY "Anno " CODTAB[1,4] + DISPLAY "Codice " CODTAB[5,7] + DISPLAY "Descrizione @40" S0 + OUTPUT ANNO CODTAB[1,4] + OUTPUT CODICE_LIB_UN CODTAB[5,7] + FLAGS "UR" + CHECKTYPE REQUIRED + WARNING "Inserire il codice del libro unico" + GROUP 2 +END + +GROUPBOX DLG_NULL 52 3 +BEGIN + PROMPT 2 8 "Stampa movimenti" +END + +DATE DA_DATA +BEGIN + PROMPT 3 9 "Dalla data " + HELP "Data di inizio stampa registro" + GROUP 3 +END + +DATE A_DATA +BEGIN + PROMPT 30 9 "Alla data " + HELP "Data di fine stampa registro" + VALIDATE DATE_CMP_FUNC >= DA_DATA + WARNING "Inserire una data non inferiore alla data limite inferiore" + GROUP 3 +END + +LISTBOX FINO_A_MESE 10 +BEGIN + PROMPT 4 9 "Fino al mese " + HELP "Mese fino al quale eseguire la stampa" + FLAGS "M" + GROUP 1 +END + +LISTBOX MESE 10 +BEGIN + PROMPT 4 9 "Mese " + HELP "Mese di cui eseguire la stampa" + FLAGS "M" + GROUP 2 +END + +LISTBOX TIPO_RIEPILOGATIVO 11 +BEGIN + PROMPT 2 11 "Tipo riepilogativo " + HELP "Indicare il tipo stampa di liquidazione sul registro" + ITEM "P|Del periodo" + ITEM "A|Annuale" + GROUP 4 +END + +GROUPBOX DLG_NULL 35 4 +BEGIN + PROMPT 2 12 "Formato pagina" +END + +LISTBOX STAMPA_WIDTH 4 +BEGIN + PROMPT 3 13 "Numero di colonne " + HELP "Numero di colonne per pagina del modulo di stampa." + ITEM "1|132" + ITEM "2|198" +END + +NUMBER STAMPA_LEN 3 +BEGIN + PROMPT 3 14 "Numero di righe " + HELP "Numero di righe per pagina del modulo di stampa. Se non specificato assume 66 righe" +END + +BUTTON DLG_PRINT 10 2 +BEGIN + PROMPT -12 -1 "~Stampa" + MESSAGE EXIT,K_ENTER +END + +BUTTON DLG_QUIT 10 2 +BEGIN + PROMPT -22 -1 "" +END + +ENDPAGE + +PAGE "Stampa registri IVA" -1 -1 56 18 + +NUMBER ULTIMA_PAGINA 4 +BEGIN + PROMPT 2 2 "Ultimo numero di pagina stampata libro unico " + HELP "Numero dell'ultima pagina del libro unico stampata" + FLAGS "R" + GROUP 2 +END + +STRING CODICE_LIBRO_IVA 3 +BEGIN + PROMPT 2 3 "Eventuale codice libro IVA " + HELP "Libro IVA da stampare. Vuoto = tutti" + USE REG SELECT (I0<"3") && (CODTAB[1,4]==#111) + INPUT CODTAB[1,4] ANNO + INPUT CODTAB[5,7] CODICE_LIBRO_IVA + DISPLAY "Anno " CODTAB[1,4] + DISPLAY "Codice " CODTAB[5,7] + DISPLAY "Descrizione @40" S0 + OUTPUT ANNO CODTAB[1,4] + OUTPUT CODICE_LIBRO_IVA CODTAB[5,7] + //CHECKTYPE NORMAL + FLAGS "UR" + GROUP 2 +END + +LISTBOX ULTIMO_MESE 10 +BEGIN + PROMPT 2 4 "Ultimo mese stampa su libro unico " + FLAGS "MD" + GROUP 2 +END + +BOOLEAN RIF_VID +BEGIN + PROMPT 2 5 "Stampa riferimenti vidimazione" + GROUP 4 +END + +BUTTON DLG_PRINT 10 2 +BEGIN + PROMPT -12 -1 "~Stampa" + MESSAGE EXIT,K_ENTER +END + +BUTTON DLG_QUIT 10 2 +BEGIN + PROMPT -22 -1 "" +END + +ENDPAGE + +ENDMASK +