diff --git a/cg/cg4400.cpp b/cg/cg4400.cpp index a33781a40..80fdd9ea2 100755 --- a/cg/cg4400.cpp +++ b/cg/cg4400.cpp @@ -1,130 +1,9 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "conto.h" -#include "cglib03.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include - - // cg4400.cpp // Stampa registri IVA #include "cg4.h" +#include "cg4400.h" #include "cg4400a.h" -#include "cg4400b.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() {} -}; +#include "cg4400b.h" static TString256 TMP; @@ -145,7 +24,8 @@ 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 (app()._tipo_stampa == 2 || app()._tipo_stampa == 4) //stampa di bollato + if (app()._tipo_stampa != 1) //stampa di bollato if (regst) //il movimento e' gia' stato stampato in forma definitiva return FALSE; @@ -174,85 +54,73 @@ HIDDEN int compare_fields(const TObject** o1, const TObject** o2) bool CG4400_application::stampa_totali_finali() { - static bool st = 2; - if (st == 2) - { - TConfig conf(CONFIG_DITTA); - st = conf.get_bool("StTfFr"); - } - return st; + TConfig conf(CONFIG_DITTA); + return conf.get_bool("StTfFr"); } bool CG4400_application::stampa_datareg() -{ - static bool sd = 2; - if (sd == 2) - { - TConfig conf(CONFIG_STUDIO); - sd = !conf.get_bool("NoDtRg"); - } - return sd; +{ + TConfig conf(CONFIG_STUDIO); + return conf.get_bool("NoDtRg"); } bool CG4400_application::mask_select (TMask_field& f, KEY k) { if (k == K_SPACE) - { - TBit_array& sel = app()._selected; - TArray_sheet& dit = *app()._ditte; - - for (int j = 0; j < dit.items(); j++) - dit.check(j, sel[j]); - + { + app()._ditte->enable_check(); // seleziona e aggiungi alle gia' selezionate - if (dit.run() == K_ENTER) + if (app()._ditte->run() == K_ENTER) { - for (int j = 0; j < dit.items(); j++) - sel.set(j, dit.checked(j)); + for (long j = 0l; j < app()._ditte->items(); j++) + app()._selected.set(j, app()._ditte->checked(j)); + app().set_choice_limits(f.mask()); } - const long numd = sel.ones(); - f.mask().set(F_SELECT, numd); } return TRUE; -} +} bool CG4400_application::mask_azzera (TMask_field& f, KEY k) { if (k == K_SPACE) { - app()._selected.reset(); - app()._ditte->uncheck(-1); + app()._selected.reset(); f.mask().reset(F_SELECT); + f.mask().reset(DA_CODICE); + f.mask().reset(A_CODICE); + app()._ditte->check(-1, FALSE); } return TRUE; } -bool CG4400_application::mask_firm_to (TMask_field& f, KEY k) -{ - if (k == K_TAB && f.focusdirty()) - { - TMask& m = f.mask(); - const long from = m.get_long(DA_CODICE); - long to = m.get_long(A_CODICE); - if (from != 0 || to != 0) - { - TBit_array& sel = app()._selected; - if (to == 0) to = 99999; - for (int i = 0; i < app()._ditte->items(); i++) - { - TToken_string& d = app()._ditte->row(i); - const long cod = d.get_long(1); - if (cod >= from && cod <= to) - sel.set(i); - } - // m.reset(DA_CODICE); - // m.reset(A_CODICE); - const long numd = sel.ones(); - f.mask().set(F_SELECT, numd); - } - } - return TRUE; -} +/* + bool CG4400_application::mask_firm_to (TMask_field& f, KEY k) + { + if (k == K_TAB && f.focusdirty()) + { + TMask& m = f.mask(); + const long from = m.get_long(DA_CODICE); + long to = m.get_long(A_CODICE); + if (from != 0 || to != 0) + { + TBit_array& sel = app()._selected; + if (to == 0) to = 99999; + for (int i = 0; i < app()._ditte->items(); i++) + { + TToken_string& d = app()._ditte->row(i); + const long cod = d.get_long(1); + if (cod >= from && cod <= to) + sel.set(i); + } + // m.reset(DA_CODICE); + // m.reset(A_CODICE); + const long numd = sel.ones(); + f.mask().set(F_SELECT, numd); + } + } + return TRUE; + } + */ bool CG4400_application::mask_tipo_stampa(TMask_field& f, KEY k) { @@ -313,7 +181,7 @@ 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) +bool CG4400_application::look_reg(int i, int anno, TString& codlib, int m, const char* cod, int* umese, long ditta) { TString16 y; @@ -329,39 +197,37 @@ bool CG4400_application::look_reg(long l, int anno, TString& codlib, int m, cons 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 (_selected[i]) { 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")); + message_box("Ditta %ld: il codice libro unico del registro non e' uguale al codice libro unico indicato", ditta); 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")); + message_box("Ditta %ld: il mese indicato e' inferiore al mese dell'ultima data di stampa del registro", ditta); 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 (u_data.ok()) + *umese = u_data.month(); + else *umese = 0; + + if (sca_vid.ok()) + if (sca_vid.month() < m) + { + message_box("Ditta %ld: la data scadenza di vidimazione del registro non deve essere inferiore al mese indicato", ditta); + 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) +bool CG4400_application::look_regs(int anno, TString& codlib, int m, int* umese, long ditta) { int a, tipo; TString16 codtab; @@ -386,16 +252,24 @@ bool CG4400_application::look_regs(int anno, TString& codlib, int m, int* umese) 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(); + if (u_data.ok()) + if (m < u_data.month()) + continue; + if (u_data.ok()) + *umese = (*umese < u_data.month()) ? *umese : u_data.month(); + if (sca_vid.ok()) + if (sca_vid.month() < m) + continue; + if (u_data.ok()) + if (u_data.month() < m - 1) + { + app().TApplication::set_firm(__firm); + return error_box("Ditta %ld: Stampare i registri dei mesi precedenti", ditta); + } + /* + if (u_data.ok()) + *umese = (*umese < u_data.month()) ? *umese : u_data.month(); + */ } } return TRUE; @@ -403,9 +277,6 @@ bool CG4400_application::look_regs(int anno, TString& codlib, int m, int* umese) 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)); @@ -413,44 +284,43 @@ bool CG4400_application::mask_libun (TMask_field& f, KEY k) 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()) + for (int i = 0; i < app()._ditte->items(); i++) { - if (!prefhndl->exist(app()._nditte->get_long("CODDITTA"))) - continue; - app().TApplication::set_firm(app()._nditte->get_long("CODDITTA")); - - if (cod.not_empty()) + long ditta = app()._ditte->row(i).get_long(1); + if (prefhndl->exist(ditta)) { - ok = app().look_reg(l,anno,codlib,fino_a_mese,cod,&mese); - if ( app()._selected[l] && !ok) + app().TApplication::set_firm(ditta); + if (cod.not_empty()) { - f.message_box("Ditta %ld: il registro %s non soddisfa i parametri indicati",app()._nditte->get_long("CODDITTA"), (const char*)cod); - continue; + ok = app().look_reg(i,anno,codlib,fino_a_mese,cod,&mese,ditta); + if (!ok) + { + f.message_box("Ditta %ld: il registro %s non soddisfa i parametri indicati", ditta, (const char*)cod); + continue; + } + if (mese != 0 && 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", ditta); + } + } + else + { + ok = app().look_regs(anno,codlib,fino_a_mese,&mese,ditta); + if ( app()._selected[i] && (!ok || mese == 13) ) + { + f.message_box("Ditta %ld: nessun registro soddisfa i parametri indicati", ditta); + 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; + if (app()._selected[i]) + last_mese = (last_mese < mese) ? last_mese : mese; + } } app().TApplication::set_firm(app().__firm); if (last_mese == 13) @@ -588,9 +458,181 @@ TRectype& CG4400_application::ricerca_occ(const char * occ) return occas.curr(); } +bool CG4400_application::year_handler(TMask_field& f, KEY key) +{ + if (key == K_TAB && f.focusdirty()) + { + app().begin_wait(); + app().set_year(atoi(f.get())); + app().build_nomiditte(); + app().build_ditte_sheet(); + app().end_wait(); + } + return TRUE; +} + +void CG4400_application::build_ditte_sheet() +{ + // build sheet + _ditte->destroy(); + for (int i = 0; i < _nomiditte.items(); i++) + { + TToken_string* d = new TToken_string(64); + *d = (TToken_string&)_nomiditte[i]; + const char vers = d->get_char(2); + bool selectable = vers == '?'; + d->insert(" |", 0); + const long pos = _ditte->add(d); + if (selectable) + _ditte->disable(pos); + else if (_selected[i]) + _ditte->check(pos); + } +} + +// --------------------------- handlers per selezione ditte + +bool CG4400_application::to_ditt_handler(TMask_field& f, KEY key) +{ + TMask& m = f.mask(); + if (key == K_F9) + { + app().to_butt_handler(m.field(BUT_DTO), K_SPACE); + } + if (key == K_TAB && f.focusdirty()) + { + const long l = app().select_firm_range(m.get_long(DA_CODICE), m.get_long(A_CODICE)); + app().set_choice_limits(m); + m.field(F_SELECT).set(format("%ld", l)); + } + return TRUE; +} + +bool CG4400_application::fr_ditt_handler(TMask_field& f, KEY key) +{ + TMask& m = f.mask(); + if (key == K_F9) + { + app().fr_butt_handler(m.field(BUT_DFR), K_SPACE); + } + else if (key == K_TAB && f.focusdirty()) + { + const long l = app().select_firm_range(m.get_long(DA_CODICE), m.get_long(A_CODICE)); + app().set_choice_limits(m); + m.field(F_SELECT).set(format("%ld", l)); + } + return TRUE; +} + +bool CG4400_application::to_butt_handler(TMask_field& f, KEY key) +{ + if (key == K_SPACE) + { + TArray_sheet* sh = app().get_ditte_sheet(); + TMask& m = f.mask(); + + sh->disable_check(); + if (sh->run() == K_ENTER) + { + app().select_firm_range(m.get_long(DA_CODICE),sh->row(sh->selected()).get_long(1)); + app().set_choice_limits(m); + } + } + return TRUE; +} + +bool CG4400_application::fr_butt_handler(TMask_field& f, KEY key) +{ + if (key == K_SPACE) + { + TMask& m = f.mask(); + TArray_sheet* sh = app().get_ditte_sheet(); + + sh->disable_check(); + if (sh->run() == K_ENTER) + { + app().select_firm_range(sh->row(sh->selected()).get_long(1), m.get_long(A_CODICE)); + app().set_choice_limits(m); + } + } + return TRUE; +} + +void CG4400_application::set_choice_limits(TMask& m) +{ + long first = -1l, last = -1l; + for (int i = 0; i < _ditte->items(); i++) + { + if (_selected[i]) + { + long dit = _ditte->row(i).get_long(1); + if (first == -1l) first = dit; + if (last < dit) last = dit; + } + } + 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 CG4400_application::select_firm_range(long from, long to) +{ + if (to == 0l) to = 99999L; + for (int i = 0; i < _ditte->items(); i++) + { + if (_ditte->disabled(i)) + continue; + + TToken_string& d = _ditte->row(i); + const char vers = d.get_char(3); + if (vers == '?') + continue; + + const long cod = d.get_long(1); + if (cod >= from && cod <= to) + { + _selected.set(i); + _ditte->check(i); + } + else + { + _selected.set(i,FALSE); + _ditte->uncheck(i); + } + } + return _selected.ones(); +} + +void CG4400_application::build_nomiditte() +{ + _nomiditte.destroy(); + // ricostruire _nomiditte e rifare build_ditte_sheet + TLocalisamfile& dt = _nditte->lfile(); + + for (dt.first(); !dt.eof(); dt.next()) + { + // check no archivi + bool good = prefhndl->exist(dt.get_long("CODDITTA")); + if (good) + { + // check no parametri liquidazione + TApplication::set_firm(dt.get_long("CODDITTA")); + if (!look_lia()) good = FALSE; + } + _n_ditte++; + TToken_string* d = new TToken_string(64); + // add record + d->add(dt.get("CODDITTA")); + d->add(dt.get("RAGSOC")); + if (good) d->add(_tablia->get("S7")); + else d->add("??"); + _nomiditte.add(d); + } + TApplication::set_firm(__firm); +} + bool CG4400_application::user_create() { - _nditte = new TLocalisamfile(LF_NDITTE); _com = new TLocalisamfile(LF_COMUNI); _anag = new TLocalisamfile(LF_ANAG); _unloc = new TLocalisamfile(LF_UNLOC); @@ -609,32 +651,29 @@ bool CG4400_application::user_create() _tabvid = new TTable("VID"); _clifo = new TLocalisamfile(LF_CLIFO); _occas = new TLocalisamfile(LF_OCCAS); - _rel = new TRelation (LF_MOV); + _nditte = new TRelation(LF_NDITTE); + //_nditte->add(LF_ATTIV, "CODDITTA=CODDITTA"); + + _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, "", 2); _ditte = new TArray_sheet(-1, -1, 0, 0, "Selezione Ditte", - "@1|Cod.@5|Ragione Sociale@50"); + "@1|Cod.@5|Ragione Sociale@50|Vers."); + _n_ditte = 0l; + __firm = TApplication::get_firm(); - 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); + TDate oggi(TODAY); + _annoes = oggi.year(); + + build_nomiditte(); + build_ditte_sheet(); + //set_real_picture(REAL_PICTURE); + add_cursor(_cur); add_file(LF_MOV); add_file(LF_RMOVIVA); @@ -670,47 +709,6 @@ bool CG4400_application::user_destroy() 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; iget_date("D3"); - if (_data_a > data) + if (data > _data_a) { datas = format("%02/%02d/%4d", data.day(), data.month(), data.year()); return FALSE; @@ -1102,15 +1104,15 @@ int CG4400_application::stampa_prospetto() _stampa = stampa_totali_finali(); if (_stampa) { - set_row(++r, "Tipo documento@30gTotale documento"); + set_row(++r, "Tipo documento@40gTotale 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); + set_row(rr, "@3g%-.35s", (const char*) doc._descrdoc); + set_row(rr, "@39g%r", &doc._totdoc); } _doc_array.destroy(); } @@ -1123,7 +1125,8 @@ int CG4400_application::stampa_prospetto() 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); + //set_row (++rr, "** CREDITO INIZIO ANNO %r = credito iva anno precedente", &_credito); + set_row (++rr, "** CREDITO INIZIO ANNO @39g%r", &_credito); rr++; } @@ -1371,9 +1374,9 @@ void CG4400_application::set_page_tot_reg() { TRiga& riga = (TRiga&)_tot_iva_array[k]; //row = rr+k; - set_row(rr, "%3s", (const char*)riga._codiva); + set_row(rr, "%4s", (const char*)riga._codiva); TString80 descr = descr_iva(riga._codiva); - set_row(rr, "@5g%s",(const char*)descr); + set_row(rr, "@5g%-.21s",(const char*)descr); if (riga._imponibile != ZERO) set_row(rr, "@25g%r", &riga._imponibile); if (riga._imposta != ZERO) @@ -1401,7 +1404,7 @@ void CG4400_application::set_page_tot_reg() } _tot_iva_array.destroy(); rr++; - set_row(++rr, "TOTALE@25g%r@41g%r", &tot_imponib, &tot_imposta); + set_row(rr, "TOTALE@25g%r@41g%r", &tot_imponib, &tot_imposta); if (_tipo_reg == 1 && _corrispettivi) set_row(rr, "@61g%r", &tot_lordo); if (_tipo_stampa != 1) @@ -1412,10 +1415,9 @@ void CG4400_application::set_page_tot_reg() } if (_tipo_reg == 2) rr = stampa_acquisti(rr); - - if (_tipo_reg == 2 && _tipo_stampa != 1) - stampa_plafonds(rr); - } + } + if (_tipo_reg == 2 && _tipo_stampa != 1) + stampa_plafonds(rr); } void CG4400_application::stampa_plafonds(int r) @@ -1434,11 +1436,13 @@ void CG4400_application::stampa_plafonds(int r) num = _datareg.month(); // forza il tipoatt a 1 - char buf[10]; strcpy(buf,_codatt); - buf[strlen(buf) - 1] = '1'; + //char buf[10]; strcpy(buf,_codatt); + //buf[strlen(buf) - 1] = '1'; chiave = ""; - chiave << _annoes << buf; + //chiave << _annoes << buf; + chiave << _annoes; + chiave << _codatt << "1"; pla.put("CODTAB", chiave); if (pla.read() == NOERR) @@ -1456,6 +1460,7 @@ void CG4400_application::stampa_plafonds(int r) mese = itom(num); mese.right_just(); set_row(++r, "%s", (const char*) mese); + set_row(++r, ""); r++; } else return; @@ -1486,8 +1491,8 @@ void CG4400_application::stampa_plafonds(int r) } 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); + set_row(r++, "Utilizzato all'interno@44g%r", &pri); + set_row(r++, "Utilizzato per l'importazione@44g%r riporto %r", &pre, &x); } } @@ -1518,8 +1523,8 @@ void CG4400_application::stampa_plafonds(int r) 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); + set_row(r++, "Utilizzato all'interno@44g%r", &pri); + set_row(r++, "Utilizzato per l'importazione@44g%r riporto %r", &pre, &x); } } @@ -1550,8 +1555,8 @@ void CG4400_application::stampa_plafonds(int r) 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); + set_row(r++, "Utilizzato all'interno@44g%r", &pri); + set_row(r++, "Utilizzato per l'importazione@44g%r riporto %r", &pre, &x); } } } @@ -1593,7 +1598,6 @@ real CG4400_application::stampa_valori_plafonds(const real& r1, const int mese, bool CG4400_application::compila_reg(const TMask& m) { int anno; - long codditta = _nditte->get_long("CODDITTA"); TString16 codtab = ""; TString16 cod_lib_un; TDate sca_vid; @@ -1617,7 +1621,7 @@ bool CG4400_application::compila_reg(const TMask& m) { 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); + _ditta, _annoes); return FALSE; } } @@ -1646,26 +1650,27 @@ bool CG4400_application::compila_reg(const TMask& m) 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); + warning_box ("Ditta %ld: la data specificata non deve essere inferiore al %s (ultima data di stampa specificata sul registro)", _ditta, (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); + warning_box ("Ditta %ld: sul registro non deve essere indicato il codice del libro unico", _ditta); 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 (sca_vid.ok()) + 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", _ditta); + 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); + warning_box ("Ditta %ld: la data indicata non deve essere superiore al %s (ultima data di stampa del libro giornale)", _ditta, (const char*)datas); return FALSE; } } @@ -1689,7 +1694,7 @@ bool CG4400_application::compila_reg(const TMask& m) } else if (_tipo_stampa != 3) { - warning_box("Il registro IVA specificato non esiste nella \n Ditta %ld", codditta); + warning_box("Il registro IVA specificato non esiste nella \n Ditta %ld", _ditta); return FALSE; } } @@ -1730,7 +1735,7 @@ bool CG4400_application::preprocess_print(int file, int counter) _intesta_liq = FALSE; set_print_zero(); if (_tipo_stampa == 3) - calcola_progressivi(); + calcola_progressivi(); //va fatto una volta sola, in questo caso } return TRUE; } @@ -1743,6 +1748,7 @@ bool CG4400_application::preprocess_page(int file, int counter) reset_print(); int rr = 0, riga = 0; + bool intra; TString80 comune, prov, comcf, capcf, civcf; TString80 viacf; TString ragsoc; @@ -1753,18 +1759,18 @@ bool CG4400_application::preprocess_page(int file, int counter) _datareg = mov.get_date(MOV_DATAREG); - if (_tipo_stampa == 2 || _tipo_stampa == 4) + if ((_tipo_stampa == 2 || _tipo_stampa == 4) && _liquidazione) 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 + _datareg = format("01/%02d/%4d", m, _annoes); //serve per la preprocess_header (intestazione per la stampa liquidazione) _intesta_liq = TRUE; TFilename t; t.temp(); send_message('L',t, m); - if (m > 1) printer().formfeed(); + //if (m > 1) printer().formfeed(); merge_export_file(t,FALSE,TRUE); _intesta_liq = FALSE; _st_liq[m] = TRUE; @@ -1795,7 +1801,7 @@ bool CG4400_application::preprocess_page(int file, int counter) 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 intra = caus.get_bool(CAU_INTRACOM); //da prendere sul movimento bool autof = caus.get_bool(CAU_AUTOFATT); TString80 descrcau = caus.get(CAU_DESCR); @@ -1810,15 +1816,17 @@ bool CG4400_application::preprocess_page(int file, int counter) mov.rewrite(); } - if ( intra && autof) - { - _auto_intraf = TRUE; - tipo_op = "3"; - } - else if (intra) - tipo_op = "1"; - else if (autof) - tipo_op = "2"; + /* + if ( intra && autof) + { + _auto_intraf = TRUE; + tipo_op = "3"; + } + else if (intra) + tipo_op = "1"; + else if (autof) + tipo_op = "2"; + */ if (codcf == 0l) ragsoc = descrcau; @@ -1832,6 +1840,16 @@ bool CG4400_application::preprocess_page(int file, int counter) civcf = dep.get (CLI_CIVCF); capcf = dep.get (CLI_CAPCF); comcf = dep.get (CLI_COMCF); + char tipoa = dep.get_char(CLI_TIPOAPER); + if (tipoa == 'F') + { + TString80 cognome, nome; + cognome = ragsoc.mid(0,30); + nome = ragsoc.mid(30,20); + cognome.trim(); nome.trim(); + ragsoc = cognome; + ragsoc << " " << nome; + } } else { @@ -1856,15 +1874,16 @@ bool CG4400_application::preprocess_page(int file, int counter) //setto le righe di stampa _r = 1; - if (_stampa_data_reg) + 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); + if (codcf != 0l) + set_row(_r, "@31g%6ld", codcf); + set_row(_r, "@38g%-.29s",(const char*) ragsoc); + //set_row(_r, "@68g%s", (const char*) tipo_op); set_row(_r, "@70g%2s", (const char*) _tipodoc); if (_stampa_width == 132) set_row(_r, "@72g%r", &totdoc); @@ -1884,10 +1903,18 @@ bool CG4400_application::preprocess_page(int file, int counter) 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; - } + if (viacf.not_empty()) //se la via non e' vuota non puo' essere vuoto il comune + { + set_row (_r+1, "@38g%-.24s %-3s",(const char *)viacf, (const char *)civcf); + set_row (_r+2, "@38g%s %-.22s", (const char *)capcf, (const char *)comune); + riga = _r+3; + } + else if (comune.not_empty()) + { + set_row (_r+1, "@38g%s %-.22s", (const char *)capcf, (const char *)comune); + riga = _r+2; + } + } _nrec = riga_rmoviva(); if (_nrec > 0) { @@ -1896,6 +1923,7 @@ bool CG4400_application::preprocess_page(int file, int counter) { TRigaiva& riga = (TRigaiva&)_riga_rmi[j]; rr = _r+j; + intra = riga._intra; if (_stampa_width == 132) { set_row(rr, "@87g%r", &riga._imponibile); @@ -1925,6 +1953,19 @@ bool CG4400_application::preprocess_page(int file, int counter) } _riga_rmi.destroy(); } + + if ( intra && autof) + { + _auto_intraf = TRUE; + tipo_op = "3"; + } + else if (intra) + tipo_op = "1"; + else if (autof) + tipo_op = "2"; + + set_row(_r, "@68g%s", (const char*) tipo_op); + if (_tipo_stampa == 1) //stampa di prova { if (_stampa_width == 132) @@ -1965,13 +2006,10 @@ bool CG4400_application::preprocess_page(int file, int counter) 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 == 4) - // set_row(_r, "@125g%ld", numgio); + { + TString vall (corrval.string("###.###.###.###,@@")); + set_row(riga, "@30gCodice valuta %-3s Corrispettivo in valuta %s", (const char*) codval, (const char*) vall); + } } return TRUE; } @@ -2012,7 +2050,7 @@ void CG4400_application::aggiorna_reg() if (_mese_credito == 0 && _credito > ZERO) if (_mov_empty) Tabreg.put("I8", (long)_fino_a_mese); - else Tabreg.put("I8", _datareg.month()); + else Tabreg.put("I8", (long)_datareg.month()); Tabreg.rewrite(); } @@ -2073,8 +2111,8 @@ void CG4400_application::aggiorna_reg() 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); + nuovo.put("I5", (long)(_numini + 1)); + nuovo.put("I6", (long)_pagine_stampate); if (mese == _fino_a_mese) TabInl.rewrite(nuovo); @@ -2104,13 +2142,13 @@ 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; + //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; } @@ -2181,9 +2219,8 @@ print_action CG4400_application::postprocess_page (int file, int counter) 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 (_tipo_stampa != 1 && _liquidazione) if (stampo_liquidazione(_datareg.month())) { _st_liq[_datareg.month()] = TRUE; @@ -2252,12 +2289,12 @@ print_action CG4400_application::postprocess_page (int file, int counter) bool CG4400_application::set_print(int n) { - TMask m("cg4400a"); + TMask m ("cg4400a"); int giorni_del_mese; bool ok; m.set_handler (TIPO_STAMPA, mask_tipo_stampa); - m.set_handler (A_CODICE, mask_firm_to); + //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); @@ -2266,6 +2303,14 @@ bool CG4400_application::set_print(int n) m.set_handler (CODICE_LIBRO_IVA, mask_libun); m.set_handler (DLG_SELECT, mask_select); m.set_handler (F_ANNULLA, mask_azzera); + m.set_handler (A_CODICE, to_ditt_handler); + m.set_handler (DA_CODICE, fr_ditt_handler); + m.set_handler (BUT_DTO, to_butt_handler); + m.set_handler (BUT_DFR, fr_butt_handler); + m.set_handler (ANNO, year_handler); + + m.field(F_SELECT).set(format("%ld",_selected.ones())); + set_choice_limits(m); set_real_picture("###.###.###.###"); @@ -2325,7 +2370,9 @@ bool CG4400_application::set_print(int n) else { _tipo_riepilogativo = ' '; - giorni_del_mese = TDate::last_day(_fino_a_mese, _annoes); + 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); } @@ -2343,18 +2390,27 @@ bool CG4400_application::set_print(int n) return FALSE; } +bool CG4400_application::look_lia() +{ + TString16 y; y << _annoes; + + _tablia->zero(); + _tablia->put("CODTAB", y); + _tablia->read(); + const bool ok = _tablia->good(); + return ok; +} + bool CG4400_application::stampa_registri_IVA(const TMask& m) { - long l; - __firm = TApplication::get_firm(); bool ok = FALSE; - - for (l = 0l, _nditte->first(); !_nditte->eof(); l++, _nditte->next()) + for (int i = 0; i < _ditte->items(); i++) { - if (_selected[l]) + if (_selected[i]) { bool msg = TRUE; - set_firm(_nditte->get_long("CODDITTA")); + _ditta = _ditte->row(i).get_long(1); + TApplication::set_firm(_ditta); TString16 y; y << _annoes; _tablia->zero(); _tablia->put("CODTAB", y); @@ -2363,32 +2419,32 @@ bool CG4400_application::stampa_registri_IVA(const TMask& m) _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 - } + /* + 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()) { - set_firm(__firm); + 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 (!_stampa_tutti_i_registri) { if (_liquidazione) { ok = controlla_liquidazione(); if (!ok) continue; + for (int i=0; i < 12; i++) + _st_liq[i] = FALSE; } - for (int i=0; i < 12; i++) - _st_liq[i] = FALSE; - (*_cur) = 0L; const long item = _cur->items(); if (item > 0) //cioe' se ci sono dei movimenti da stampare @@ -2422,22 +2478,25 @@ else 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 (_tipo_stampa != 1 && _liquidazione) { - if (stampo_liquidazione(m)) + printer().open(); + for (int m = limite; m > 0 && m <= _fino_a_mese; 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 (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) { @@ -2445,7 +2504,7 @@ if (_tipo_stampa == 3 && _rif_vid) stampa_vidi(); //stampa riferimenti vidimazione } } -else +else //stampa tutti i registri { TString16 codtab, cod_lib_un; int anno; @@ -2467,23 +2526,23 @@ else { _u_data = _tabreg->get_date("D3"); if (!_u_data.ok()) //e' la prima volta che stampo - _u_data = format("01/01/%4d", _annoes); + _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)); + message_box("Ditta %ld: Il registro %s e' gia' stato stampato come bollato di %s", _ditta, (const char*) _codreg, itom(_fino_a_mese)); continue; } if (cod_lib_un.not_empty()) continue; - if (sca_vid.month() < _fino_a_mese) - continue; + if (sca_vid.ok()) + 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); @@ -2497,17 +2556,19 @@ else continue; if (_fino_a_mese < _u_data.month()) continue; - if (sca_vid.month() < _fino_a_mese) - continue; + if (sca_vid.ok()) + 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; - } + /* + 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"); @@ -2525,8 +2586,6 @@ else _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(); @@ -2546,13 +2605,20 @@ else } if (_tipo_stampa != 1) { + if (_liquidazione) //per i registri "validi" eseguo il controllo liquidazione + { + ok = controlla_liquidazione(); + if (!ok) continue; + for (int i=0; i < 12; i++) + _st_liq[i] = FALSE; + } TFilename t; t.temp(); send_message('C',t, _fino_a_mese); } print(); } - else + else //anche se non ho dei movimenti devo stampare la liq. sotto certe ipotesi. { int limite; _mov_empty = TRUE; @@ -2561,23 +2627,28 @@ else 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 (_tipo_stampa != 1 && _liquidazione) { - if (stampo_liquidazione(m)) + printer().open(); + for (int m = limite; m > 0 && m <= _fino_a_mese; 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 (stampo_liquidazione(m)) + { + ok = controlla_liquidazione(); + if (!ok) break; + _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) { @@ -2587,7 +2658,7 @@ else } } //for if (msg) - message_box("Ditta %ld: Nessun registro soddisfa i parametri indicati", _nditte->get_long("CODDITTA")); + message_box("Ditta %ld: Nessun registro soddisfa i parametri indicati", _ditta); } //if (_tipo_stampa == 3) // aggiorna_lib(); @@ -2600,24 +2671,14 @@ return TRUE; 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(_ditta); ss.add(tipo); //if (tipo == 'L') @@ -2627,7 +2688,7 @@ void CG4400_application::send_message(char tipo, const TFilename& nome, int mese ss.add("x"); //} - TMessage liq (app, "RCL", ss); + TMessage liq ("cg4a -2", "RCL", ss); liq.send(); TExternal_app pn(app); @@ -2636,11 +2697,12 @@ void CG4400_application::send_message(char tipo, const TFilename& nome, int mese bool CG4400_application::set_ditte(TMask& m) { - _selected.reset(); - - m.field(F_SELECT).set("0"); - m.field(DA_CODICE).set(""); - m.field(A_CODICE).set(""); + /* + _selected.reset(); + m.field(F_SELECT).set("0"); + m.field(DA_CODICE).set(""); + m.field(A_CODICE).set(""); + */ m.field(TIPO_STAMPA).set("1"); KEY tasto; @@ -2796,6 +2858,9 @@ void CG4400_application::preprocess_header() ++_pagine_stampate; } + if (_tipo_stampa == 2 || _tipo_stampa == 4) + ++_pagine_stampate; + 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); @@ -2835,8 +2900,8 @@ void CG4400_application::preprocess_header() if (_tipo_reg == 1) //registro vendite { cor = 'R'; - nd1 = NULL; - nd2 = NULL; + nd1 = ' '; + nd2 = ' '; } if (_tipo_reg == 2) { @@ -2849,7 +2914,7 @@ void CG4400_application::preprocess_header() tipo = 'A'; type = 'T'; } - if (_stampa_data_reg && _stampa_width == 132) + 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) { @@ -2857,14 +2922,14 @@ void CG4400_application::preprocess_header() { 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); + set_header(r, "Data reg. prot.@17gData@24gNumero Codice Ragione sociale/descrizione@68gO Doc.@76gTotale doc.@91gImponibile Iva %c@116gImposta@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); + set_header(r, "Data Protocollo Data@24gNumero Codice Ragione sociale/descrizione@68gO Documento@80gTot.Documento@99gImponibile Iva %c@124gImposta@132g%c %c@139gReg.", nd2, type, cor); r++; } } @@ -2876,7 +2941,7 @@ else if (!_intesta_vidi) 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 %c@112gImposta@124g%c %c", + set_header(r, "Data reg. prot.@17gData@24gNumero Codice Ragione sociale/descrizione@68gO Doc.@76gTotale doc.@91gImponibile Iva %c@116gImposta@124g%c %c", nd2, cor, type); if (_tipo_stampa == 4) set_header(r, "@128gop."); @@ -2888,7 +2953,7 @@ else if (!_intesta_vidi) 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); + set_header(r, "Data Protocollo Data@24gNumero 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++; @@ -2902,7 +2967,7 @@ else if (_tipo_stampa == 3 && _intesta_vidi) 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++, "@38gGeneralita'"); set_header(r, riga); } diff --git a/cg/cg4400.h b/cg/cg4400.h index fb91b51f8..b946fd264 100755 --- a/cg/cg4400.h +++ b/cg/cg4400.h @@ -13,7 +13,7 @@ #include #include #include -#include "conto.h" +#include #include #include #include @@ -23,7 +23,6 @@ #include #include #include - #include "cglib03.h" const int TABREG = (int)TTable::name2log("REG"); @@ -31,8 +30,8 @@ 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; + TRelation *_rel, *_nditte; + TLocalisamfile *_clifo, *_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; @@ -40,7 +39,8 @@ class CG4400_application : public TPrintapp TRiga_array _tot_iva_array; TBit_array _selected; - TArray_sheet *_ditte; + TArray_sheet *_ditte; + TArray _nomiditte; bool _st_liq[12]; TRecnotype _nrec; bool _mov_empty, _stampa_ind_ditta, _stampa_tutti_i_registri, _auto_intraf, _stampa; @@ -49,7 +49,7 @@ class CG4400_application : public TPrintapp 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 _n_ditte, _u_stampata, _primast, __firm, _uprotivap, _ditta; 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; @@ -67,6 +67,7 @@ protected: TRectype& ricerca_occ(const char*); TRectype& ricerca_cf (char, long); TRectype& look_comuni(const char*); + TArray_sheet* get_ditte_sheet() { return _ditte; } int setta_riga (int, const TRigaiva&, real&, real&, real&, real&); int riga_rmoviva(); bool set_print(int); @@ -78,11 +79,14 @@ protected: 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 look_reg (int, int, TString&, int, const char*, int*, long); + bool look_regs(int, TString&, int, int*, long); bool stampa_totali_finali(); bool stampa_datareg(); bool stampa_registri_IVA(const TMask&); + bool look_lia(); + void set_choice_limits(TMask&); + void build_ditte_sheet(); void cerca_reg(const TString&, byte*); void set_page_tot_reg(); void send_message(char, const TFilename&,int); @@ -93,7 +97,8 @@ protected: bool user_destroy(); bool preprocess_page(int, int); int stampa_intestazione(); - int stampa_prospetto(); + int stampa_prospetto(); + long select_firm_range(long,long); void stampa_plafonds(int); void get_dati_ditta(); void stampa_vidi(); @@ -103,11 +108,17 @@ protected: //print_action postprocess_print(int, int); print_action postprocess_page (int, int); void preprocess_header(); - + void build_nomiditte(); + void set_year(int y) { _annoes = y; } + 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_firm_to (TMask_field&, KEY); + static bool to_ditt_handler (TMask_field&, KEY); + static bool fr_ditt_handler (TMask_field&, KEY); + static bool to_butt_handler (TMask_field&, KEY); + static bool fr_butt_handler (TMask_field&, KEY); static bool mask_cod (TMask_field&, KEY); static bool mask_libun (TMask_field&, KEY); static bool mask_data (TMask_field&, KEY); @@ -115,10 +126,11 @@ protected: static bool mask_fino_a_mese (TMask_field&, KEY); static bool mask_select (TMask_field&, KEY); static bool mask_azzera (TMask_field&, KEY); + static bool year_handler (TMask_field&, KEY); public: - CG4400_application() : TPrintapp(), _ditte(NULL) {} + CG4400_application() : TPrintapp(), _ditte(NULL), _selected(10000), _nomiditte(100) {} virtual ~CG4400_application() {} }; diff --git a/cg/cg4400a.h b/cg/cg4400a.h index 14d149828..35039b9b6 100755 --- a/cg/cg4400a.h +++ b/cg/cg4400a.h @@ -13,15 +13,17 @@ #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 +#define BUT_DFR 114 +#define BUT_DTO 115 +#define F_SELECT 116 +#define F_ANNULLA 117 +#define F_VERIFICA 118 +#define CODICE_LIB_UN 119 +#define MESE 120 +#define CODICE_LIBRO_PROVA 121 +#define RIF_VID 122 +#define STAMPA_WIDTH 123 +#define STAMPA_LEN 124 diff --git a/cg/cg4400a.uml b/cg/cg4400a.uml index 2597cebac..3e0fdd8d4 100755 --- a/cg/cg4400a.uml +++ b/cg/cg4400a.uml @@ -19,51 +19,61 @@ BEGIN 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 +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 + +GROUPBOX DLG_NULL 39 5 BEGIN - PROMPT 20 2 "Scelta ditte" + PROMPT 16 2 "Scelta ditte" END NUMBER DA_CODICE 6 BEGIN - PROMPT 21 3 "Da codice " - FLAGS "UR" + PROMPT 17 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 + +BUTTON BUT_DFR 2 1 +BEGIN + PROMPT 34 3 "*" + PICTURE 109 END NUMBER A_CODICE 6 BEGIN - PROMPT 21 4 "A codice " - FLAGS "UR" + PROMPT 17 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 +BUTTON BUT_DTO 2 1 BEGIN - PROMPT 21 5 "Scelte n. " - FLAGS "DR" + PROMPT 34 4 "*" + PICTURE 109 END -BUTTON DLG_SELECT 9 2 +STRING F_SELECT 5 BEGIN - PROMPT 42 3 "~Selezione" + PROMPT 17 5 "Scelte n. " + FLAGS "D" +END + +BUTTON DLG_SELECT 10 2 +BEGIN + PROMPT 41 3 "~Selezione" HELP "Indicare le ditte da selezionare per la stampa" END -BUTTON F_ANNULLA 9 +BUTTON F_ANNULLA 10 BEGIN - PROMPT 42 5 "A~zzera" + PROMPT 41 5 "A~zzera" HELP "Annullare la selezione delle ditte" MESSAGE RESET,DA_CODICE|RESET,A_CODICE END @@ -76,18 +86,9 @@ BEGIN 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 " + 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 @@ -98,13 +99,14 @@ BEGIN OUTPUT ANNO CODTAB[1,4] OUTPUT CODICE_LIBRO CODTAB[5,7] //CHECKTYPE NORMAL - FLAGS "UR" + FLAGS "U" + VALIDATE ZEROFILL_FUNC 3 GROUP 1 END STRING CODICE_LIBRO_PROVA 3 BEGIN - PROMPT 2 7 "Codice libro " + 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 @@ -114,12 +116,13 @@ BEGIN DISPLAY "Descrizione @40" S0 OUTPUT ANNO CODTAB[1,4] OUTPUT CODICE_LIBRO_PROVA CODTAB[5,7] - FLAGS "UR" + FLAGS "U" + VALIDATE ZEROFILL_FUNC 3 END STRING CODICE_LIB_UN 3 BEGIN - PROMPT 2 7 "Libro unico " + 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 @@ -129,9 +132,10 @@ BEGIN DISPLAY "Descrizione @40" S0 OUTPUT ANNO CODTAB[1,4] OUTPUT CODICE_LIB_UN CODTAB[5,7] - FLAGS "UR" + FLAGS "U" CHECKTYPE REQUIRED - WARNING "Inserire il codice del libro unico" + WARNING "Inserire il codice del libro unico" + VALIDATE ZEROFILL_FUNC 3 GROUP 2 END @@ -158,7 +162,7 @@ END LISTBOX FINO_A_MESE 10 BEGIN - PROMPT 4 9 "Fino al mese " + PROMPT 3 9 "Fino al mese " HELP "Mese fino al quale eseguire la stampa" FLAGS "M" GROUP 1 @@ -166,7 +170,7 @@ END LISTBOX MESE 10 BEGIN - PROMPT 4 9 "Mese " + PROMPT 4 9 "Mese " HELP "Mese di cui eseguire la stampa" FLAGS "M" GROUP 2 @@ -236,7 +240,8 @@ BEGIN OUTPUT ANNO CODTAB[1,4] OUTPUT CODICE_LIBRO_IVA CODTAB[5,7] //CHECKTYPE NORMAL - FLAGS "UR" + FLAGS "U" + VALIDATE ZEROFILL_FUNC 3 GROUP 2 END diff --git a/cg/cg4400b.uml b/cg/cg4400b.uml index 13177b891..eb432ee83 100755 --- a/cg/cg4400b.uml +++ b/cg/cg4400b.uml @@ -1,10 +1,11 @@ #include "cg4400b.h" -PAGE "Stampa registri IVA" -1 -1 58 10 +PAGE "Stampa registri IVA" -1 -1 54 10 STRING COD_LIB 3 BEGIN PROMPT 2 1 "Codice Libro " + FLAGS "D" END LISTBOX U_MESE 10 @@ -22,16 +23,17 @@ END DATE U_DATA BEGIN PROMPT 2 4 "Ultima data di stampa " + FLAGS "D" END BUTTON DLG_OK 9 2 BEGIN - PROMPT -13 7 "" + PROMPT -12 7 "" END BUTTON DLG_CANCEL 9 2 BEGIN - PROMPT -23 7 "" + PROMPT -22 7 "" END ENDPAGE