diff --git a/cg/cg4400.cpp b/cg/cg4400.cpp index 5a01d9c70..4833bf3f0 100755 --- a/cg/cg4400.cpp +++ b/cg/cg4400.cpp @@ -5,9 +5,11 @@ #include "cg4400a.h" #include "cg4400b.h" -inline TReg_print& app() { return (TReg_print&)main_app(); } +static TString256 TMP; -bool TReg_print::filter_func (const TRelation * r) +inline CG4400_application& app() { return (CG4400_application&)main_app(); } + +bool CG4400_application::filter_func (const TRelation * r) { TLocalisamfile& mov = r->lfile(LF_MOV); TString16 codreg = mov.get(MOV_REG); @@ -41,8 +43,8 @@ HIDDEN int compare_rows(const TObject** o1, const TObject** o2) HIDDEN int compare_fields(const TObject** o1, const TObject** o2) { - const TRigaiva* r1 = (const TRigaiva*)*o1; - const TRigaiva* r2 = (const TRigaiva*)*o2; + TRigaiva* r1 = (TRigaiva*)*o1; + TRigaiva* r2 = (TRigaiva*)*o2; TString16 campo1; TString16 campo2; @@ -51,19 +53,19 @@ HIDDEN int compare_fields(const TObject** o1, const TObject** o2) return strcmp(campo1, campo2); } -bool TReg_print::stampa_totali_finali() +bool CG4400_application::stampa_totali_finali() { TConfig conf(CONFIG_DITTA); return conf.get_bool("StTfFr"); } -bool TReg_print::stampa_datareg() +bool CG4400_application::stampa_datareg() { TConfig conf(CONFIG_STUDIO); return conf.get_bool("NoDtRg"); } -bool TReg_print::mask_select (TMask_field& f, KEY k) +bool CG4400_application::mask_select (TMask_field& f, KEY k) { if (k == K_SPACE) { @@ -79,7 +81,7 @@ bool TReg_print::mask_select (TMask_field& f, KEY k) return TRUE; } -bool TReg_print::mask_azzera (TMask_field& f, KEY k) +bool CG4400_application::mask_azzera (TMask_field& f, KEY k) { if (k == K_SPACE) { @@ -93,7 +95,7 @@ bool TReg_print::mask_azzera (TMask_field& f, KEY k) } /* - bool TReg_print::mask_firm_to (TMask_field& f, KEY k) + bool CG4400_application::mask_firm_to (TMask_field& f, KEY k) { if (k == K_TAB && f.focusdirty()) { @@ -121,7 +123,7 @@ bool TReg_print::mask_azzera (TMask_field& f, KEY k) } */ -bool TReg_print::mask_tipo_stampa(TMask_field& f, KEY k) +bool CG4400_application::mask_tipo_stampa(TMask_field& f, KEY k) { TMask& m = f.mask(); @@ -136,15 +138,8 @@ bool TReg_print::mask_tipo_stampa(TMask_field& f, KEY k) return TRUE; } -bool TReg_print::mask_mese (TMask_field& f, KEY k) -{ - const short id = f.dlg(); - int mese; - if (id == MESE) //Per stampa su libro unico - mese = f.mask().get_int(MESE); - if (id == FINO_A_MESE) - mese = f.mask().get_int(FINO_A_MESE); //Per stampa su bollato - +bool CG4400_application::mask_mese (TMask_field& f, KEY k) +{ /* if (k == K_ENTER) { @@ -159,6 +154,12 @@ bool TReg_print::mask_mese (TMask_field& f, KEY k) */ if (k == K_SPACE) { + const short id = f.dlg(); + int mese; + if (id == MESE) //Per stampa su libro unico + mese = f.mask().get_int(MESE); + if (id == FINO_A_MESE) + mese = f.mask().get_int(FINO_A_MESE); //Per stampa su bollato if (id == MESE) if (mese == 12) { @@ -180,7 +181,7 @@ bool TReg_print::mask_mese (TMask_field& f, KEY k) return TRUE; } -bool TReg_print::look_reg(int i, int anno, TString& codlib, int m, const char* cod, int* umese, long ditta) +bool CG4400_application::look_reg(int i, int anno, TString& codlib, int m, const char* cod, int* umese, long ditta) { TString16 y; @@ -222,10 +223,11 @@ bool TReg_print::look_reg(int i, int anno, TString& codlib, int m, const char* c return FALSE; } -bool TReg_print::look_regs(int anno, TString& codlib, int m, int* umese, long ditta) +bool CG4400_application::look_regs(int anno, TString& codlib, int m, int* umese, long ditta) { int a, tipo; TString16 codtab; + bool ok = FALSE; *umese = 13; for (_tabreg->first(); !_tabreg->eof(); _tabreg->next()) @@ -234,7 +236,8 @@ bool TReg_print::look_regs(int anno, TString& codlib, int m, int* umese, long di codtab = _tabreg->get("CODTAB"); a = atoi(codtab.mid(0,4)); if (a > anno) - return FALSE; + //return FALSE; + break; if (a == anno) if ( tipo == 1 || tipo == 2 ) //registro iva { @@ -257,21 +260,29 @@ bool TReg_print::look_regs(int anno, TString& codlib, int m, int* umese, long di app().set_firm(__firm); return error_box("Ditta %ld: Stampare i registri dei mesi precedenti", ditta); } + ok = TRUE; } } - return TRUE; + return ok; } -bool TReg_print::mask_libun (TMask_field& f, KEY k) -{ - if ( k == K_ENTER ) +bool CG4400_application::mask_libun (TMask_field& f, KEY k) +{ + static bool can_print = TRUE; + + if (!can_print) return FALSE; + + if (k == K_ENTER) return can_print; + + if (k==K_TAB && f.mask().is_running()) { 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; + bool ok = FALSE; + can_print = TRUE; int last_mese = 13; int mese = 0; @@ -289,18 +300,24 @@ bool TReg_print::mask_libun (TMask_field& f, KEY k) if (!ok) { if (app()._selected[i]) f.message_box("Ditta %ld: il registro %s non soddisfa i parametri indicati", ditta, (const char*)cod); - continue; + if (app()._selected.last_one() == i) + { + can_print = FALSE; + break; + } + else + continue; } if (mese != 0 && mese < fino_a_mese - 1) //indipendentemente se si tratta di una ditta selezionata oppure no { app().set_firm(app().__firm); + can_print = FALSE; return error_box("Ditta %ld: Stampare i registri dei mesi precedenti", ditta); } } else { ok = app().look_regs(anno,codlib,fino_a_mese,&mese,ditta); - //if ( app()._selected[i] && (!ok || mese == 13) ) if ( app()._selected[i] && !ok ) { f.message_box("Ditta %ld: nessun registro soddisfa i parametri indicati", ditta); @@ -323,7 +340,7 @@ bool TReg_print::mask_libun (TMask_field& f, KEY k) return TRUE; } -bool TReg_print::mask_cod (TMask_field& f, KEY k) +bool CG4400_application::mask_cod (TMask_field& f, KEY k) { TTable TabLbu ("%LBU"); TString codtab; @@ -356,7 +373,7 @@ bool TReg_print::mask_cod (TMask_field& f, KEY k) return TRUE; } -bool TReg_print::mask_data (TMask_field& f, KEY k) +bool CG4400_application::mask_data (TMask_field& f, KEY k) { if (k == K_TAB && f.mask().is_running()) { @@ -379,7 +396,7 @@ bool TReg_print::mask_data (TMask_field& f, KEY k) return TRUE; } -const char * TReg_print::descr_doc() +const char * CG4400_application::descr_doc() { TTable tab_tpd("%TPD"); TString codtab(format("%-2s",(const char*) _tipodoc)); @@ -394,7 +411,7 @@ const char * TReg_print::descr_doc() return TMP; } -const char * TReg_print::descr_iva(const char * cod) +const char * CG4400_application::descr_iva(const char * cod) { TTable tab_iva("%IVA"); TString codtab(format ("%-4s", cod)); @@ -409,7 +426,7 @@ const char * TReg_print::descr_iva(const char * cod) return TMP; } -const char * TReg_print::tipo_attivita() +const char * CG4400_application::tipo_attivita() { TLocalisamfile attiv (LF_ATTIV); @@ -422,7 +439,7 @@ const char * TReg_print::tipo_attivita() return TMP; } -const char * TReg_print::desc_attivita() +const char * CG4400_application::desc_attivita() { TTable attiv ("%AIS"); @@ -435,7 +452,7 @@ const char * TReg_print::desc_attivita() return TMP; } -TRectype& TReg_print::ricerca_cf(char tipocf, long codcf) +TRectype& CG4400_application::ricerca_cf(char tipocf, long codcf) { _clifo->zero(); _clifo->put(CLI_TIPOCF, tipocf); @@ -447,7 +464,7 @@ TRectype& TReg_print::ricerca_cf(char tipocf, long codcf) return _clifo->curr(); } -TRectype& TReg_print::ricerca_occ(const char * occ) +TRectype& CG4400_application::ricerca_occ(const char * occ) { TLocalisamfile occas (LF_OCCAS); occas.zero(); @@ -459,7 +476,7 @@ TRectype& TReg_print::ricerca_occ(const char * occ) return occas.curr(); } -bool TReg_print::year_handler(TMask_field& f, KEY key) +bool CG4400_application::year_handler(TMask_field& f, KEY key) { if (key == K_TAB && f.focusdirty()) { @@ -472,7 +489,7 @@ bool TReg_print::year_handler(TMask_field& f, KEY key) return TRUE; } -void TReg_print::build_ditte_sheet() +void CG4400_application::build_ditte_sheet() { // build sheet _ditte->destroy(); @@ -493,7 +510,7 @@ void TReg_print::build_ditte_sheet() // --------------------------- handlers per selezione ditte -bool TReg_print::to_ditt_handler(TMask_field& f, KEY key) +bool CG4400_application::to_ditt_handler(TMask_field& f, KEY key) { TMask& m = f.mask(); if (key == K_F9) @@ -509,7 +526,7 @@ bool TReg_print::to_ditt_handler(TMask_field& f, KEY key) return TRUE; } -bool TReg_print::fr_ditt_handler(TMask_field& f, KEY key) +bool CG4400_application::fr_ditt_handler(TMask_field& f, KEY key) { TMask& m = f.mask(); if (key == K_F9) @@ -525,7 +542,7 @@ bool TReg_print::fr_ditt_handler(TMask_field& f, KEY key) return TRUE; } -bool TReg_print::to_butt_handler(TMask_field& f, KEY key) +bool CG4400_application::to_butt_handler(TMask_field& f, KEY key) { if (key == K_SPACE) { @@ -542,7 +559,7 @@ bool TReg_print::to_butt_handler(TMask_field& f, KEY key) return TRUE; } -bool TReg_print::fr_butt_handler(TMask_field& f, KEY key) +bool CG4400_application::fr_butt_handler(TMask_field& f, KEY key) { if (key == K_SPACE) { @@ -559,30 +576,24 @@ bool TReg_print::fr_butt_handler(TMask_field& f, KEY key) return TRUE; } -void TReg_print::set_choice_limits(TMask& m) +void CG4400_application::set_choice_limits(TMask& m) { long first = -1l, last = -1l; for (int i = 0; i < _ditte->items(); i++) { if (_selected[i]) { - const long dit = _ditte->row(i).get_long(1); + long dit = _ditte->row(i).get_long(1); if (first == -1l) first = dit; if (last < dit) last = dit; } } - if (first != -1) - { - m.set(DA_CODICE, first); - app().set_firm(first); - } - if (last != -1) - m.set(A_CODICE, last); - + if (first != -1) m.field(DA_CODICE).set(format("%ld",first)); + if (last != -1) m.field(A_CODICE).set(format("%ld",last)); m.set(F_SELECT, _selected.ones()); } -long TReg_print::select_firm_range(long from, long to) +long CG4400_application::select_firm_range(long from, long to) { if (to == 0l) to = 99999L; for (int i = 0; i < _ditte->items(); i++) @@ -610,7 +621,7 @@ long TReg_print::select_firm_range(long from, long to) return _selected.ones(); } -void TReg_print::build_nomiditte(TProgind* pnd) +void CG4400_application::build_nomiditte(TProgind* pnd) { _nomiditte.destroy(); // ricostruire _nomiditte e rifare build_ditte_sheet @@ -623,6 +634,7 @@ void TReg_print::build_nomiditte(TProgind* pnd) if (good) { // check no parametri liquidazione + //TApplication::set_firm(dt.get_long("CODDITTA")); if (!look_lia(dt.get_long("CODDITTA"))) good = FALSE; } _n_ditte++; @@ -635,14 +647,14 @@ void TReg_print::build_nomiditte(TProgind* pnd) _nomiditte.add(d); } if (pnd) pnd->addstatus(1); - TApplication::set_firm(__firm); + //TApplication::set_firm(__firm); } -bool TReg_print::user_create() +bool CG4400_application::user_create() { TProgind* pnd = NULL; - pnd = new TProgind (3,"Preparazione archivi\nPrego attendere", + pnd = new TProgind (2,"Preparazione archivi\nPrego attendere", FALSE, TRUE, 30); _com = new TLocalisamfile(LF_COMUNI); @@ -651,10 +663,10 @@ bool TReg_print::user_create() _attiv = new TLocalisamfile(LF_ATTIV); _tab = new TLocalisamfile(LF_TAB); _tabcom = new TLocalisamfile(LF_TABCOM); + _indlib = new TLocalisamfile(LF_INDLIB); _tabreg = new TTable("REG"); _tabiva = new TTable("%IVA"); _tablbu = new TTable("%LBU"); - _tabinl = new TTable("%INL"); _tablim = new TTable("LIM"); _tabpim = new TTable("PIM"); _tablia = new TTable("%LIA"); @@ -682,36 +694,37 @@ bool TReg_print::user_create() TDate oggi(TODAY); _annoes = oggi.year(); - + build_nomiditte(pnd); build_ditte_sheet(); - if (pnd) pnd->addstatus(1); + //if (pnd) pnd->addstatus(1); add_cursor(_cur); add_file(LF_MOV); add_file(LF_RMOVIVA); + printer().footerlen(5); //set_real_picture(REAL_PICTURE); delete pnd; return TRUE; } -bool TReg_print::user_destroy() +bool CG4400_application::user_destroy() { delete _ditte; delete _nditte; delete _com; delete _unloc; delete _anag; - delete _attiv; + delete _attiv; + delete _indlib; delete _tab; delete _tabcom; delete _tabreg; delete _tabiva; delete _tablbu; - delete _tabinl; delete _tablim; delete _tabpim; delete _tablia; @@ -726,7 +739,7 @@ bool TReg_print::user_destroy() return TRUE; } -void TReg_print::calcola_progressivi() +void CG4400_application::calcola_progressivi() { TTable pim ("PIM"); TString80 chiave; @@ -743,6 +756,7 @@ void TReg_print::calcola_progressivi() // num = num - (num%3); chiave = ""; + //_codatt e' gia' Z perche' lo leggo dal registro chiave << _annoes << _codatt; pim.zero(); pim.put ("CODTAB", chiave); @@ -837,7 +851,7 @@ void TReg_print::calcola_progressivi() } } -int TReg_print::riga_rmoviva() +int CG4400_application::riga_rmoviva() { TString codiva; real impo, impos; @@ -887,8 +901,8 @@ int TReg_print::riga_rmoviva() return nrec; } -int TReg_print::setta_riga(int r, const TRigaiva& riga, real& tot1, - real& tot2, real& tot3, real& tot4) +int CG4400_application::setta_riga(int r, const TRigaiva& riga, real& tot1, + real& tot2, real& tot3, real& tot4) { set_row(r, "%4s", (const char*)riga._codiva); TString descr = descr_iva(riga._codiva); @@ -909,7 +923,7 @@ int TReg_print::setta_riga(int r, const TRigaiva& riga, real& tot1, return r; } -bool TReg_print::controlla_liquidazione() +bool CG4400_application::controlla_liquidazione() { TTable lim ("LIM"); TTable pim ("PIM"); @@ -937,7 +951,8 @@ bool TReg_print::controlla_liquidazione() for (i=3; i<=mese; i+=3) { chiave = ""; - chiave << _annoes << i; + TString16 m (format("%02d", i)); + chiave << _annoes << m; lim.put("CODTAB", chiave); if (lim.read() != NOERR) { @@ -951,7 +966,8 @@ bool TReg_print::controlla_liquidazione() for (i=1 ; i<=mese; i++) { chiave = ""; - chiave << _annoes << i; + TString16 m (format("%02d", i)); + chiave << _annoes << m; lim.put("CODTAB", chiave); if (lim.read() != NOERR) { @@ -980,7 +996,7 @@ bool TReg_print::controlla_liquidazione() //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 TReg_print::controlla_mov() +bool CG4400_application::controlla_mov() { TLocalisamfile mov (LF_MOV); bool ok = TRUE; @@ -1010,7 +1026,7 @@ bool TReg_print::controlla_mov() return ok; } -bool TReg_print::cerca_libro_gio(TString& datas) +bool CG4400_application::cerca_libro_gio(TString& datas) { TString app(4); app = format("%04d", _annoes); @@ -1039,7 +1055,7 @@ bool TReg_print::cerca_libro_gio(TString& datas) return TRUE; } -void TReg_print::cerca_reg(const TString& c, byte* t) +void CG4400_application::cerca_reg(const TString& c, byte* t) { TString16 cod = ""; @@ -1050,7 +1066,7 @@ void TReg_print::cerca_reg(const TString& c, byte* t) *t = _tabreg->get_int ("I0"); } -bool TReg_print::ventilazione(const char* iva) +bool CG4400_application::ventilazione(const char* iva) { TTable tabiva ("%IVA"); TString16 chiave = ""; @@ -1065,7 +1081,7 @@ bool TReg_print::ventilazione(const char* iva) return FALSE; } -int TReg_print::stampa_prospetto() +int CG4400_application::stampa_prospetto() { TString riga(_stampa_width); int r=1, rr=0; @@ -1161,7 +1177,7 @@ int TReg_print::stampa_prospetto() } //la stampa "tipi di indetraibilita'" viene fatta solo per gli acquisti -int TReg_print::stampa_acquisti(int row) +int CG4400_application::stampa_acquisti(int row) { real tot_imponib, tot_imposta, tot_imponibp, tot_impostap; row+=2; @@ -1249,7 +1265,7 @@ int TReg_print::stampa_acquisti(int row) } /* - void TReg_print::set_page_tot_reg() + void CG4400_application::set_page_tot_reg() { TString16 codivaprec = ""; int row=0, rr=0; @@ -1335,7 +1351,7 @@ int TReg_print::stampa_acquisti(int row) } */ -void TReg_print::set_page_tot_reg() +void CG4400_application::set_page_tot_reg() { int rr=0; @@ -1398,7 +1414,7 @@ void TReg_print::set_page_tot_reg() stampa_plafonds(rr); } -void TReg_print::stampa_plafonds(int r) +void CG4400_application::stampa_plafonds(int r) { TTable pla ("%PLA"); TTable ppa ("PPA"); @@ -1413,11 +1429,16 @@ void TReg_print::stampa_plafonds(int r) if ( _tipo_stampa == 2 || _tipo_stampa == 4 ) num = _datareg.month(); + TString16 nm (format("%02d", num)); + // forza il tipoatt a 1 //char buf[10]; strcpy(buf,_codatt); //buf[strlen(buf) - 1] = '1'; - chiave = format("%5ld", get_firm()); + chiave = ""; + //chiave << _annoes << buf; + + chiave.format("%05ld", get_firm()); chiave << _annoes; chiave << _codatt << "1"; pla.put("CODTAB", chiave); @@ -1445,13 +1466,13 @@ void TReg_print::stampa_plafonds(int r) if (r1 > ZERO) { real r8 = ZERO; - r8 = stampa_valori_plafonds(r1, num, ppa, " 1"); + r8 = stampa_valori_plafonds(r1, num, ppa, "1"); if (r8 > ZERO) { real pri = ZERO; real pre = ZERO; chiave = ""; - chiave << _annoes << _codatt << "1" << num << " 1"; + chiave << _annoes << _codatt << "1" << nm << "1"; ppa.put("CODTAB", chiave); if (ppa.read() == NOERR) { @@ -1459,7 +1480,7 @@ void TReg_print::stampa_plafonds(int r) pre = ppa.get_real("R1"); } chiave = ""; - chiave << _annoes << _codatt << "2" << num << " 1"; + chiave << _annoes << _codatt << "2" << nm << "1"; ppa.put("CODTAB", chiave); if (ppa.read() == NOERR) { @@ -1476,13 +1497,13 @@ void TReg_print::stampa_plafonds(int r) if (r2 > ZERO) { real r8b = ZERO; - r8b = stampa_valori_plafonds(r2, num, ppa, " 2"); + r8b = stampa_valori_plafonds(r2, num, ppa, "2"); if (r8b > ZERO) { real pri = ZERO; real pre = ZERO; - chiave = ""; - chiave << _annoes << _codatt << "1" << num << " 2"; + chiave = ""; + chiave << _annoes << _codatt << "1" << nm << "2"; ppa.put("CODTAB", chiave); if (ppa.read() == NOERR) { @@ -1490,7 +1511,7 @@ void TReg_print::stampa_plafonds(int r) pre = ppa.get_real("R1"); } chiave = ""; - chiave << _annoes << _codatt << "2" << num << " 2"; + chiave << _annoes << _codatt << "2" << nm << "2"; ppa.put("CODTAB", chiave); if (ppa.read() == NOERR) { @@ -1508,13 +1529,13 @@ void TReg_print::stampa_plafonds(int r) if (r3 > ZERO) { real r9 = ZERO; - r9 = stampa_valori_plafonds(r3, num, ppa, " 3"); + r9 = stampa_valori_plafonds(r3, num, ppa, "3"); if (r9 > ZERO) { real pri = ZERO; real pre = ZERO; chiave = ""; - chiave << _annoes << _codatt << "1" << num << " 3"; + chiave << _annoes << _codatt << "1" << nm << "3"; ppa.put("CODTAB", chiave); if (ppa.read() == NOERR) { @@ -1522,8 +1543,8 @@ void TReg_print::stampa_plafonds(int r) pre = ppa.get_real("R1"); } chiave = ""; - chiave << _annoes << _codatt << "2" << num << " 3"; - ppa.put("CODTAB", chiave); + chiave << _annoes << _codatt << "2" << nm << "3"; + ppa.put("CODTAB", chiave); if (ppa.read() == NOERR) { pri += ppa.get_real("R0"); @@ -1538,7 +1559,7 @@ void TReg_print::stampa_plafonds(int r) } } -real TReg_print::stampa_valori_plafonds(const real& r1, const int mese, TTable& ppa, const char* tipo) +real CG4400_application::stampa_valori_plafonds(const real& r1, const int mese, TTable& ppa, const char* tipo) { real r, si8, se8; TString80 chiave; @@ -1551,7 +1572,8 @@ real TReg_print::stampa_valori_plafonds(const real& r1, const int mese, TTable& for (i=1; i la stampa di vidimazione mi sballa tutta!!! } - TString cod = ""; if (trovato && mese != _fino_a_mese) { - TString16 cod_inl = recprec.get("CODTAB"); - long numero_riga = atol(cod_inl.mid(7,6)) + 1; - TString16 num_riga (format("%6d", numero_riga)); - cod_inl = cod_inl.mid(0,7); - nuovo = recprec; - cod << cod_inl << num_riga; + long numero_riga = recprec.get_long("NUMREG") + 1; + nuovo = recprec; + nuovo.put("NUMREG", numero_riga); } - else if (mese != _fino_a_mese) + else if (trovato) nuovo = rec; + else //trovato e' rimasto FALSE { - TString16 num_riga ( format("%6d", 0L) ); - cod << codtab << num_riga; - } - else - { - TString16 cod_inl = recprec.get("CODTAB"); - TString16 numero_riga = cod_inl.mid(7,6); - cod << codtab << numero_riga; + nuovo = rec; + nuovo.put("NUMREG", 1L); } - nuovo.put("CODTAB", cod); - nuovo.put("I0", (long)_annoes); - 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)(_u_stampata)); // numero finale pagina libro unico - nuovo.put("I4", get_firm()); - nuovo.put("S0", _codreg); - nuovo.put("S1", _codice_vidi); - nuovo.put("I5", (long)(_numini + 1)); - nuovo.put("I6", (long)_pagine_stampate); + nuovo.put("ANNOREG", _annoes); + nuovo.put("MESEREG", _fino_a_mese); // su libro unico ho un solo mese in gioco! + nuovo.put("PAGINI", _primast + 1); // numero iniziale pagina libro unico + nuovo.put("PAGFIN", _u_stampata); // numero finale pagina libro unico + nuovo.put("CODDITTA", get_firm()); + nuovo.put("CODREG", _codreg); + nuovo.put("CODVID", _codice_vidi); + nuovo.put("PAGINIUT", _numini + 1); + nuovo.put("PAGFINUT", _pagine_stampate); if (mese == _fino_a_mese) - TabInl.rewrite(nuovo); + IndBil.rewrite(nuovo); else - TabInl.write(nuovo); + IndBil.write(nuovo); - aggiorna_lib(); - } + _primast = _u_stampata; //per la numerazione dei registri successivi + } + aggiorna_lib(); } -void TReg_print::aggiorna_lib() +void CG4400_application::aggiorna_lib() { TString16 cod = ""; TTable lbu ("%LBU"); @@ -2126,7 +2138,7 @@ void TReg_print::aggiorna_lib() } } -bool TReg_print::stampo_liquidazione(int mese) +bool CG4400_application::stampo_liquidazione(int mese) { if (_tipo_stampa == 1) { @@ -2146,11 +2158,10 @@ bool TReg_print::stampo_liquidazione(int mese) return FALSE; } -void TReg_print::stampa_vidi() +void CG4400_application::stampa_vidi() { - TTable TabInl ("%INL"); + TLocalisamfile IndBil (LF_INDLIB); TTable TabVid ("VID"); - TString16 codtab = ""; TString16 codreg; TString16 vid; long ditta; @@ -2161,17 +2172,17 @@ void TReg_print::stampa_vidi() if (!printer().isopen()) printer().open(); - codtab << _annoes << _codlib; - TabInl.zero(); - TabInl.put("CODTAB", codtab); + IndBil.zero(); + IndBil.put("ANNO", _annoes); + IndBil.put("CODLIB", _codlib); - TRectype rec (TabInl.curr()); - TabInl.read (_isgteq); - for (; !TabInl.eof(); TabInl.next()) + TRectype rec (IndBil.curr()); + IndBil.read (_isgteq); + for (; !IndBil.eof(); IndBil.next()) { - if (TabInl.curr() != rec) break; - ditta = TabInl.get_long("I4"); - codreg = TabInl.get("S0"); + if (IndBil.curr() != rec) break; + ditta = IndBil.get_long("CODDITTA"); + codreg = IndBil.get("CODREG"); if (ditta == get_firm() && codreg == _codreg) { if (!_ok_vidi) @@ -2180,14 +2191,14 @@ void TReg_print::stampa_vidi() ++_pagine_stampate; _ok_vidi = TRUE; } - mese = TabInl.get_int("I1"); + mese = IndBil.get_int("MESEREG"); 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"); + row.put(format("%5ld", IndBil.get_long("PAGINI")), 10); + row.put(format("%5ld", _u_stampata), 17); + row.put(format("%5ld", IndBil.get_long("PAGINIUT")), 25); + row.put(format("%5ld", _pagine_stampate), 32); + vid = IndBil.get("CODVID"); TabVid.zero(); TabVid.put("CODTAB", vid); if (TabVid.read() == NOERR) @@ -2206,7 +2217,7 @@ void TReg_print::stampa_vidi() printer().close(); } -print_action TReg_print::postprocess_page (int file, int counter) +print_action CG4400_application::postprocess_page (int file, int counter) { if (file == LF_MOV) { @@ -2214,7 +2225,7 @@ print_action TReg_print::postprocess_page (int file, int counter) { reset_print(); if (_liquidazione) - if (stampo_liquidazione(_datareg.month())) + if (!_st_liq[_datareg.month()] && stampo_liquidazione(_datareg.month())) { _st_liq[_datareg.month()] = TRUE; TFilename t; @@ -2270,7 +2281,7 @@ print_action TReg_print::postprocess_page (int file, int counter) return NEXT_PAGE; } -bool TReg_print::set_print(int n) +bool CG4400_application::set_print(int n) { TMask m ("cg4400a"); int giorni_del_mese; @@ -2303,7 +2314,6 @@ bool TReg_print::set_print(int n) { _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) @@ -2372,9 +2382,11 @@ bool TReg_print::set_print(int n) return FALSE; } -bool TReg_print::look_lia(long firm) +bool CG4400_application::look_lia(long ditta) { - TString16 y; y.format("%05ld%04d", firm, _annoes); + if (ditta == 0l) ditta = get_firm(); + + TString16 y; y.format("%05ld%04d", ditta, _annoes); _tablia->zero(); _tablia->put("CODTAB", y); @@ -2386,13 +2398,13 @@ bool TReg_print::look_lia(long firm) return ok; } -void TReg_print::clear_stliq() +void CG4400_application::clear_stliq() { for (int i=0; i < 12; i++) _st_liq[i] = FALSE; } -bool TReg_print::stampa_registri_IVA(const TMask& m) +bool CG4400_application::stampa_registri_IVA(const TMask& m) { bool ok = FALSE; for (int i = 0; i < _ditte->items(); i++) @@ -2402,9 +2414,12 @@ bool TReg_print::stampa_registri_IVA(const TMask& m) bool msg = TRUE; _ditta = _ditte->row(i).get_long(1); _frequiva = _ditte->row(i).get_char(3); - _intesta_liq = FALSE; + _intesta_liq = FALSE; + _intesta_vidi = FALSE; + _ok_vidi = FALSE; _stampa_mese = 13; - look_lia(_ditta); + TApplication::set_firm(_ditta); + look_lia(); ok = compila_reg(m); if (!ok) continue; if (_tipo_stampa == 2 || _tipo_stampa == 4) @@ -2576,6 +2591,9 @@ bool TReg_print::stampa_registri_IVA(const TMask& m) _stampa_ind_comp = _tabreg->get_bool ("B5"); _stampa_cred_pre = _tabreg->get_bool ("B4"); + _intesta_liq = FALSE; + _intesta_vidi = FALSE; + _ok_vidi = FALSE; _stampa_mese = 13; _cur->set_filterfunction(NULL); @@ -2680,7 +2698,7 @@ bool TReg_print::stampa_registri_IVA(const TMask& m) } -void TReg_print::stampa_liq_mesi_succ() +void CG4400_application::stampa_liq_mesi_succ() { int da = _datareg.month() + 1; int a = _data_a.month(); @@ -2709,7 +2727,7 @@ void TReg_print::stampa_liq_mesi_succ() if (printer().isopen()) printer().close(); } -void TReg_print::send_message(char tipo, const TFilename& nome, int mese) +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"; @@ -2730,7 +2748,7 @@ void TReg_print::send_message(char tipo, const TFilename& nome, int mese) pn.run(); } -bool TReg_print::set_ditte(TMask& m) +bool CG4400_application::set_ditte(TMask& m) { /* _selected.reset(); @@ -2749,7 +2767,7 @@ bool TReg_print::set_ditte(TMask& m) return tasto == K_ENTER; } -TRectype& TReg_print::look_comuni (const char * cod) +TRectype& CG4400_application::look_comuni (const char * cod) { _com->zero(); _com->put(COM_COM, cod); @@ -2760,7 +2778,7 @@ TRectype& TReg_print::look_comuni (const char * cod) return _com->curr(); } -void TReg_print::get_dati_ditta() +void CG4400_application::get_dati_ditta() { TLocalisamfile nditte(LF_NDITTE); TLocalisamfile anag(LF_ANAG); @@ -2829,7 +2847,7 @@ void TReg_print::get_dati_ditta() } } -int TReg_print::stampa_intestazione() +int CG4400_application::stampa_intestazione() { int r = 1; TString codice_ditta; @@ -2855,7 +2873,7 @@ int TReg_print::stampa_intestazione() return r; } -void TReg_print::preprocess_header() +void CG4400_application::preprocess_header() { int r=1; char cor, nd1, nd2; @@ -3019,7 +3037,7 @@ if (_stampa_ind_comp && !_intesta_vidi) int cg4400 (int argc, char * argv[]) { - TReg_print a; + CG4400_application a; a.run(argc, argv, "Stampa registri IVA"); return 0; } diff --git a/cg/cg4400.h b/cg/cg4400.h index 70c112f90..a8d808eec 100755 --- a/cg/cg4400.h +++ b/cg/cg4400.h @@ -28,12 +28,12 @@ const int TABREG = (int)TTable::name2log("REG"); -class TReg_print : public TPrintapp +class CG4400_application : public TPrintapp { TCursor * _cur; TRelation *_rel, *_nditte; - TLocalisamfile *_clifo, *_occas, *_tab, *_tabcom, *_com, *_anag, *_unloc, *_attiv; - TTable *_tabreg, *_tablbu, *_tabinl, *_tablim, *_tabpim, *_tablia, *_tabiva; + TLocalisamfile *_clifo, *_occas, *_tab, *_tabcom, *_com, *_anag, *_unloc, *_attiv, *_indlib; + TTable *_tabreg, *_tablbu, *_tablim, *_tabpim, *_tablia, *_tabiva; TTable *_tabpla, *_tabppa, *_tabvid; TRigaiva_array _iva_array, _riga_rmi; TTipodoc_array _doc_array; @@ -84,7 +84,7 @@ protected: bool stampa_totali_finali(); bool stampa_datareg(); bool stampa_registri_IVA(const TMask&); - bool look_lia(long firm); + bool look_lia(long ditta = 0l); void set_choice_limits(TMask&); void build_ditte_sheet(); void cerca_reg(const TString&, byte*); @@ -106,7 +106,6 @@ protected: int stampa_acquisti(int); real stampa_valori_plafonds(const real&, const int, TTable&, const char*); bool preprocess_print(int, int); - //print_action postprocess_print(int, int); print_action postprocess_page (int, int); void preprocess_header(); void build_nomiditte(TProgind* pnd = NULL); @@ -132,8 +131,8 @@ protected: public: - TReg_print() : TPrintapp(), _ditte(NULL), _selected(10000), _nomiditte(100) {} - virtual ~TReg_print() {} + CG4400_application() : TPrintapp(), _ditte(NULL), _selected(10000), _nomiditte(100) {} + virtual ~CG4400_application() {} };