diff --git a/cg/cg4400.cpp b/cg/cg4400.cpp index bcc49a51f..112b7d60a 100755 --- a/cg/cg4400.cpp +++ b/cg/cg4400.cpp @@ -1,4 +1,3 @@ - // cg4400.cpp // Stampa registri IVA #include "cg4.h" @@ -6,6 +5,8 @@ #include "cg4400a.h" #include "cg4400b.h" +static TString256 TMP; + inline CG4400_application& app() { return (CG4400_application&)main_app(); } bool CG4400_application::filter_func (const TRelation * r) @@ -196,32 +197,28 @@ bool CG4400_application::look_reg(int i, int anno, TString& codlib, int m, const TString16 cod_lib_un = _tabreg->get("S6"); TDate u_data = _tabreg->get_date("D3"); TDate sca_vid = _tabreg->get_date("D0"); - if (_selected[i]) + if (codlib != cod_lib_un) { - if (codlib != cod_lib_un) - { - 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", ditta); - 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 (_selected[i]) message_box("Ditta %ld: il codice libro unico del registro non e' uguale al codice libro unico indicato", ditta); + return FALSE; } - return TRUE; + if (m < *umese) + { + if (_selected[i]) message_box("Ditta %ld: il mese indicato e' inferiore al mese dell'ultima data di stampa del registro", ditta); + return FALSE; + } + if (u_data.ok()) + *umese = u_data.month(); + else *umese = 0; + + if (sca_vid.ok()) + if (sca_vid.month() < m) + { + if (_selected[i]) message_box("Ditta %ld: la data scadenza di vidimazione del registro non deve essere inferiore al mese indicato", ditta); + return FALSE; + } } + return TRUE; } return FALSE; } @@ -234,15 +231,11 @@ bool CG4400_application::look_regs(int anno, TString& codlib, int m, int* umese, for (_tabreg->first(); !_tabreg->eof(); _tabreg->next()) { - tipo = _tabreg->get_int("I0"); + 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 { @@ -255,7 +248,7 @@ bool CG4400_application::look_regs(int anno, TString& codlib, int m, int* umese, if (m < u_data.month()) continue; if (u_data.ok()) - *umese = (*umese < u_data.month()) ? *umese : u_data.month(); + *umese = (*umese < u_data.month()) ? *umese : u_data.month(); if (sca_vid.ok()) if (sca_vid.month() < m) continue; @@ -265,10 +258,6 @@ bool CG4400_application::look_regs(int anno, TString& codlib, int m, int* umese, app().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; @@ -280,11 +269,12 @@ bool CG4400_application::mask_libun (TMask_field& f, KEY k) { 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; int last_mese = 13; - int mese; + int mese = 0; app().__firm = app().get_firm(); @@ -299,7 +289,7 @@ bool CG4400_application::mask_libun (TMask_field& f, KEY k) 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); + if (app()._selected[i]) 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 @@ -311,7 +301,8 @@ bool CG4400_application::mask_libun (TMask_field& f, KEY k) else { ok = app().look_regs(anno,codlib,fino_a_mese,&mese,ditta); - if ( app()._selected[i] && (!ok || mese == 13) ) + //if ( app()._selected[i] && (!ok || mese == 13) ) + if ( app()._selected[i] && !ok ) { f.message_box("Ditta %ld: nessun registro soddisfa i parametri indicati", ditta); continue; @@ -320,10 +311,12 @@ bool CG4400_application::mask_libun (TMask_field& f, KEY k) if (app()._selected[i]) last_mese = (last_mese < mese) ? last_mese : mese; } - } + } + app().set_firm(app().__firm); if (last_mese == 13) - return FALSE; + //return FALSE; + last_mese = 0; //l'ultima data di stampa sul/sui registri specificati e' vuota (cioe' non sono ancora stati stampati sul libro unico specificato per l'anno specificato) const char* me = ""; me = format("%02d", last_mese); f.mask().set(ULTIMO_MESE, me); @@ -337,9 +330,17 @@ bool CG4400_application::mask_cod (TMask_field& f, KEY k) TString codtab; int anno; - if (k == K_TAB || f.focusdirty()) + if (k == K_ENTER) { - TString codlib = f.mask().get(CODICE_LIB_UN); + TString16 codlib(f.get()); + if (codlib.empty()) + return f.warning_box("Inserire il codice del libro unico"); + } + + //if (k == K_TAB || f.focusdirty()) + if (k == K_TAB) + { + TString16 codlib(f.mask().get(CODICE_LIB_UN)); anno = f.mask().get_int(ANNO); TabLbu.zero(); @@ -358,7 +359,7 @@ bool CG4400_application::mask_cod (TMask_field& f, KEY k) bool CG4400_application::mask_data (TMask_field& f, KEY k) { - if (k == K_TAB) + if (k == K_TAB && f.mask().is_running()) { const int anno = f.mask().get_int(ANNO); TDate data(f.get()); @@ -370,9 +371,11 @@ bool CG4400_application::mask_data (TMask_field& f, KEY k) } if (f.dlg() == A_DATA) if (data.ok) + { if ( data.day() == 31 && data.month() == 12 ) f.mask().show (TIPO_RIEPILOGATIVO); else f.mask().hide (TIPO_RIEPILOGATIVO); + } } return TRUE; } @@ -652,7 +655,6 @@ bool CG4400_application::user_create() _occas = new TLocalisamfile(LF_OCCAS); _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); @@ -897,7 +899,6 @@ bool CG4400_application::controlla_liquidazione() { TTable lim ("LIM"); TTable pim ("PIM"); - TString mesi_ric = ""; TString mesi_cal = ""; TString16 chiave = ""; TString16 ditta = ""; @@ -924,13 +925,7 @@ bool CG4400_application::controlla_liquidazione() 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 + if (lim.read() != NOERR) mesi_cal << itom(i) << "\n"; } } @@ -941,25 +936,13 @@ bool CG4400_application::controlla_liquidazione() 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 + if (lim.read() != NOERR) mesi_cal << itom(i) << "\n"; } } - if (mesi_ric.not_empty()) - { - _liquidazione = FALSE; - warning_box ("Ditta %s: deve essere ricalcolata la liquidazione da stampare sul registro %s relativa ai mesi di:\n %s ", (const char*)ditta, (const char*) _codreg, (const char *)mesi_ric); - return yesno_box("Vuoi ugualmente continuare la stampa?"); - } if (mesi_cal.not_empty()) { - _liquidazione = FALSE; + //_liquidazione = FALSE; warning_box ("Ditta %s: la liquidazione da stampare sul registro %s relativa ai mesi di \n %s non e' stata ancora calcolata", (const char*)ditta, (const char*) _codreg, (const char *)mesi_cal); return yesno_box("Vuoi ugualmente continuare la stampa?"); } @@ -970,16 +953,11 @@ bool CG4400_application::controlla_liquidazione() chiave = ""; chiave << _annoes << 13; lim.put("CODTAB", chiave); - if (lim.read() == NOERR) + if (lim.read() != NOERR) { - bool calcolato = lim.get_bool("B0"); - if (!calcolato) - { - _liquidazione = FALSE; - return yesno_box("Ditta %s: non eseguito calcolo liquidazione da stampare sul registro %s. Vuoi ugualmente continuare la stampa?", (const char*)ditta, (const char*) _codreg); - } + //_liquidazione = FALSE; + return yesno_box("Ditta %s: non eseguito calcolo liquidazione da stampare sul registro %s. Vuoi ugualmente continuare la stampa?", (const char*)ditta, (const char*) _codreg); } - //else ? } return TRUE; } @@ -1010,14 +988,7 @@ bool CG4400_application::controlla_mov() { long numreg = mov.get_long(MOV_NUMREG); if (!stampato) - { - /* - ditta = ""; - ditta << get_firm(); - 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) @@ -1103,15 +1074,15 @@ int CG4400_application::stampa_prospetto() _stampa = stampa_totali_finali(); if (_stampa) { - set_row(++r, "Tipo documento@40gTotale documento"); + set_row(++r, "Tipo documento@54gTotale 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%-.35s", (const char*) doc._descrdoc); - set_row(rr, "@39g%r", &doc._totdoc); + set_row(rr, "@3g%s", (const char*) doc._descrdoc); + set_row(rr, "@54g%r", &doc._totdoc); } _doc_array.destroy(); } @@ -1446,9 +1417,9 @@ void CG4400_application::stampa_plafonds(int r) 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 + r1 = pla.get_real("R5"); //totali esp. art.8 + r2 = pla.get_real("R6"); //totali esp. art.8 bis + r3 = pla.get_real("R7"); //totali esp. art 9 } if (r1 > ZERO || r2 > ZERO || r3 > ZERO) @@ -1641,17 +1612,20 @@ bool CG4400_application::compila_reg(const TMask& m) if (_tipo_stampa != 1) { _u_data = _tabreg->get_date ("D3"); - if (!_u_data.ok()) - _u_data = format("01/01/%4d", _annoes); + /* + 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)", _ditta, (const char*)datas); - return FALSE; - } + if (_u_data.ok()) + 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)", _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", _ditta); @@ -1758,24 +1732,35 @@ bool CG4400_application::preprocess_page(int file, int counter) _datareg = mov.get_date(MOV_DATAREG); - if ((_tipo_stampa == 2 || _tipo_stampa == 4) && _liquidazione) - for (int m = _stampa_mese; m > 0 && m < _datareg.month(); m++) + if (_tipo_stampa != 3 && _liquidazione) + { + int da; + if (_tipo_stampa == 1) + da = _data_da.month(); + else da = 1; + for (int m = da; 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 (intestazione per la stampa liquidazione) - _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; - } - } - + t.temp(); + if (_tipo_stampa == 1) + send_message('L',t, m); + else send_message('l',t,m); + TString80 nomef; nomef = t.path(); nomef << "\\" << t.name(); + if (fexist(nomef)) + { + _intesta_liq = TRUE; + if (m > da) printer().formfeed(); + merge_export_file(t,FALSE,TRUE); + _intesta_liq = FALSE; + } + } + _st_liq[m] = TRUE; + } + } _datareg = mov.get_date(MOV_DATAREG); _mov_empty = FALSE; @@ -2007,7 +1992,7 @@ bool CG4400_application::preprocess_page(int file, int counter) if (corrval != ZERO) { TString vall (corrval.string("###.###.###.###,@@")); - set_row(riga, "@30gCodice valuta %-3s Corrispettivo in valuta %s", (const char*) codval, (const char*) vall); + set_row(riga, "@26gCodice valuta %-3s Corrispettivo in valuta %s", (const char*) codval, (const char*) vall); } } return TRUE; @@ -2141,14 +2126,21 @@ 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) ) + if (_tipo_stampa == 1) + { + if ( (_frequiva == 'T' && (mese == 3 || mese == 6 || mese == 9 || mese == 12)) + || _frequiva != 'T' || (mese == 12 && _tipo_riepilogativo == 'A') ) return TRUE; - + } + else + { + 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; } @@ -2164,7 +2156,8 @@ void CG4400_application::stampa_vidi() _ok_vidi = FALSE; TPrintrow row; - printer().open(); + if (!printer().isopen()) + printer().open(); codtab << _annoes << _codlib; TabInl.zero(); @@ -2217,20 +2210,25 @@ 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 && _liquidazione) + if (_liquidazione) 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 (_tipo_stampa == 1) + send_message('L',t, _datareg.month()); //stampa liquidazione + else send_message('l',t, _datareg.month()); + TString80 nomef; + nomef = t.path(); nomef << "\\" << t.name(); + if (fexist(nomef)) + { + printer().formfeed(); + _intesta_liq = TRUE; + merge_export_file(t,FALSE,TRUE); + _intesta_liq = FALSE; + } } } if (!counter) @@ -2270,22 +2268,6 @@ print_action CG4400_application::postprocess_page (int file, int counter) 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"); @@ -2418,13 +2400,6 @@ 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 - } - */ ok = compila_reg(m); if (!ok) continue; if (_tipo_stampa == 2 || _tipo_stampa == 4) @@ -2456,7 +2431,8 @@ bool CG4400_application::stampa_registri_IVA(const TMask& m) m = format("%02d", _stampa_mese); mb.set(U_MESE, m); mb.set(U_PAGINA, _pagine_stampate); - mb.set(U_DATA, _u_data.string()); + if (_u_data.ok()) + mb.set(U_DATA, _u_data.string()); KEY tasto = mb.run(); if (tasto != K_ENTER) continue; } @@ -2466,32 +2442,50 @@ bool CG4400_application::stampa_registri_IVA(const TMask& m) t.temp(); send_message('C',t, _fino_a_mese); } + print(); + + if (_tipo_stampa != 3 && _liquidazione) + stampa_liq_mesi_succ(); } -else +else //non ci sono movimenti da stampare nel periodo richiesto! { _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; - if (_tipo_stampa != 1 && _liquidazione) + if (_liquidazione) { - printer().open(); - for (int m = limite; m > 0 && m <= _fino_a_mese; m++) + int da, a; + //stampo la liquidazione per tutti i mesi fino a _fino_a_mese + if (_tipo_stampa == 2 || _tipo_stampa == 4) + //da = _stampa_mese; + da = 1; + if (_tipo_stampa == 3) + da = _fino_a_mese; + if (_tipo_stampa == 1) + da = _data_da.month(); + if (_tipo_stampa == 1) + a = _data_a.month(); + else a = _fino_a_mese; + if (! printer().isopen()) + printer().open(); + for (int m = da; m > 0 && m <= a; 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; + if (_tipo_stampa == 1) + send_message('L',t, m); + else send_message('l',t, m); + TString80 nomef; + nomef = t.path(); nomef << "\\" << t.name(); + if (fexist(nomef)) + { + _intesta_liq = TRUE; + if (m > da) printer().formfeed(); + merge_export_file(t,FALSE,TRUE); + _intesta_liq = FALSE; + } } } printer().close(); @@ -2522,18 +2516,15 @@ else //stampa tutti i registri 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", _ditta, (const char*) _codreg, itom(_fino_a_mese)); - continue; - } + if (_u_data.ok()) + if (_data_a < _u_data) + { + 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.ok()) @@ -2553,21 +2544,15 @@ else //stampa tutti i registri { if (cod_lib_un != _codlib) continue; - if (_fino_a_mese < _u_data.month()) - continue; + if (_u_data.ok()) + if (_fino_a_mese < _u_data.month()) + 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; - } - */ _riep_liq = _tabreg->get_bool("B6"); _corrispettivi = _tabreg->get_bool("B0"); _pagine_stampate = _tabreg->get_long("I1"); @@ -2598,7 +2583,8 @@ else //stampa tutti i registri m = format("%02d", _stampa_mese); mb.set(U_MESE, m); mb.set(U_PAGINA, _pagine_stampate); - mb.set(U_DATA, _u_data.string()); + if (_u_data.ok()) + mb.set(U_DATA, _u_data.string()); KEY tasto = mb.run(); if (tasto != K_ENTER) continue; } @@ -2615,38 +2601,55 @@ else //stampa tutti i registri t.temp(); send_message('C',t, _fino_a_mese); } - print(); + + print(); + + if (_tipo_stampa != 3 && _liquidazione) + stampa_liq_mesi_succ(); } else //anche se non ho dei movimenti devo stampare la liq. sotto certe ipotesi. { - 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; - if (_tipo_stampa != 1 && _liquidazione) + if (_liquidazione) { - printer().open(); - for (int m = limite; m > 0 && m <= _fino_a_mese; m++) + int da, a; + if (_tipo_stampa == 2 || _tipo_stampa == 4) + da = 1; + if (_tipo_stampa == 3) + da = _fino_a_mese; + if (_tipo_stampa == 1) + da = _data_da.month(); + if (_tipo_stampa == 1) + a = _data_a.month(); + else a = _fino_a_mese; + + if (!printer().isopen()) + printer().open(); + + for (int m = da; m > 0 && m <= a; m++) { if (stampo_liquidazione(m)) { - ok = controlla_liquidazione(); - if (!ok) break; + //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; + TString80 nomef; nomef = t.path(); nomef << "\\" << t.name(); + if (_tipo_stampa == 1) + send_message('L',t, m); + else send_message('l',t, m); + if (fexist(nomef)) + { + _intesta_liq = TRUE; + if (m > da) 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) @@ -2659,33 +2662,53 @@ else //stampa tutti i registri if (msg) message_box("Ditta %ld: Nessun registro soddisfa i parametri indicati", _ditta); } -//if (_tipo_stampa == 3) -// aggiorna_lib(); } } TApplication::set_firm(__firm); return TRUE; } +void CG4400_application::stampa_liq_mesi_succ() +{ + int da = _datareg.month() + 1; + if (!printer().isopen()) + printer().open(); + for (int m = da; m > 0 && m <= _data_a.month(); m++) + { + if (stampo_liquidazione(m)) + { + _datareg = format("01/%02d/%4d", m, _annoes); //serve per la preprocess_header (intestazione per la stampa liquidazione) + TFilename t; + t.temp(); + if (_tipo_stampa == 1) + send_message('L',t, m); + else send_message('l',t,m); + TString80 nomef; nomef = t.path(); nomef << "\\" << t.name(); + if (fexist(nomef)) + { + _intesta_liq = TRUE; + if (m > da) printer().formfeed(); + merge_export_file(t,FALSE,TRUE); + _intesta_liq = FALSE; + } + } + } + printer().close(); +} 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 ; ss.add(_annoes); ss.add(mese); ss.add(_ditta); 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(); @@ -2703,6 +2726,9 @@ bool CG4400_application::set_ditte(TMask& m) m.field(A_CODICE).set(""); */ m.field(TIPO_STAMPA).set("1"); + m.field(DA_DATA).set(""); + m.field(A_DATA).set(""); + m.field(CODICE_LIBRO_PROVA).set(""); KEY tasto; tasto = m.run(); @@ -2913,20 +2939,24 @@ void CG4400_application::preprocess_header() tipo = 'A'; type = 'T'; } - if ((!_stampa_data_reg) && _stampa_width == 132) - set_header(r,"Data I/P"); + /* + 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); + //set_header(r,"@10gNum.@19gDocumento@68gT Tipo@76gIncassi/Pag.@103gCod %c@124gT %c@128gNum", nd1, tipo); + set_header(r,"@10gNum.@19gDocumento@68gT Tipo@103gCod %c@124gT %c@128gNum", nd1, tipo); r++; 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); + //set_header(r,"Registrazione Documento@68gT Tipo@80gTot.Inc./Pag.@110gCod %c@132g%c T@139gNum.", nd1, tipo, cor); + set_header(r,"Registrazione Documento@68gT Tipo@110gCod %c@132g%c T@139gNum.", nd1, tipo, cor); r++; 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++; @@ -2936,7 +2966,8 @@ else if (!_intesta_vidi) { if (_stampa_width == 132) { - set_header(r,"@10gNum.@19gDocumento@68gT Tipo@76gIncassi/Pag.@103gCod %c@124gT %c", nd1, tipo); + //set_header(r,"@10gNum.@19gDocumento@68gT Tipo@76gIncassi/Pag.@103gCod %c@124gT %c", nd1, tipo); + set_header(r,"@10gNum.@19gDocumento@68gT Tipo@103gCod %c@124gT %c", nd1, tipo); if (_tipo_stampa == 4) //stampa definitiva con rif. al libro giornale set_header(r, "@128gNum."); r++; @@ -2948,7 +2979,8 @@ else if (!_intesta_vidi) } else //stampa a 198 { - set_header(r,"Registrazione Documento@68gT Tipo@80gTot.Inc./Pag.@110gCod %c@132g%c T", nd1, tipo); + //set_header(r,"Registrazione Documento@68gT Tipo@80gTot.Inc./Pag.@110gCod %c@132g%c T", nd1, tipo); + set_header(r,"Registrazione Documento@68gT Tipo@110gCod %c@132g%c T", nd1, tipo); if (_tipo_stampa == 4) set_header(r, "@139gNum."); r++; diff --git a/cg/cg4400.h b/cg/cg4400.h index de671d0a2..627028511 100755 --- a/cg/cg4400.h +++ b/cg/cg4400.h @@ -13,7 +13,7 @@ #include #include #include -#include "conto.h" +#include #include #include #include @@ -37,11 +37,10 @@ class CG4400_application : public TPrintapp TRigaiva_array _iva_array, _riga_rmi; TTipodoc_array _doc_array; TRiga_array _tot_iva_array; - + bool _st_liq[12]; TBit_array _selected; TArray_sheet *_ditte; TArray _nomiditte; - 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; @@ -92,7 +91,8 @@ protected: void send_message(char, const TFilename&,int); void aggiorna_reg(); void aggiorna_lib(); - void calcola_progressivi(); + void calcola_progressivi(); + void stampa_liq_mesi_succ(); bool user_create(); bool user_destroy(); bool preprocess_page(int, int); diff --git a/cg/cg4400a.uml b/cg/cg4400a.uml index 3e0fdd8d4..31ccdcf6b 100755 --- a/cg/cg4400a.uml +++ b/cg/cg4400a.uml @@ -10,13 +10,13 @@ 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@ + MESSAGE SHOW,3@|SHOW,CODICE_LIBRO_PROVA|SHOW,DATA_STAMPA|SHOW,TIPO_RIEPILOGATIVO|HIDE,RIF_VID|RESET,RIF_VID|HIDE,1@|RESET,1@|HIDE,2@|RESET,2@ 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@ + MESSAGE SHOW,1@|HIDE,CODICE_LIBRO_PROVA|RESET,CODICE_LIBRO_PROVA|HIDE,2@|RESET,2@|HIDE,3@|RESET,3@|HIDE,DATA_STAMPA|HIDE,TIPO_RIEPILOGATIVO|RESET,TIPO_RIEPILOGATIVO|HIDE,RIF_VID|RESET,RIF_VID 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@ + MESSAGE SHOW,2@|HIDE,1@|RESET,1@|HIDE,3@|RESET,3@|HIDE,DATA_STAMPA|HIDE,CODICE_LIBRO_PROVA|RESET,CODICE_LIBRO_PROVA|HIDE,TIPO_RIEPILOGATIVO|RESET,TIPO_RIEPILOGATIVO|HIDE,RIF_VID|RESET,RIF_VID 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@ + MESSAGE SHOW,1@|HIDE,CODICE_LIBRO_PROVA|RESET,CODICE_LIBRO_PROVA|HIDE,2@|RESET,2@|HIDE,3@|RESET,3@|HIDE,DATA_STAMPA|HIDE,TIPO_RIEPILOGATIVO|RESET,TIPO_RIEPILOGATIVO|HIDE,RIF_VID|RESET,RIF_VID END NUMBER ANNO 4 @@ -36,7 +36,6 @@ END NUMBER DA_CODICE 6 BEGIN PROMPT 17 3 "Da codice " - //FLAGS "UR" HELP "Codice ditta di inizio selezione" END @@ -49,7 +48,6 @@ END NUMBER A_CODICE 6 BEGIN PROMPT 17 4 "A codice " - //FLAGS "UR" HELP "Codice ditta di fine selezione" END @@ -98,7 +96,6 @@ BEGIN DISPLAY "Descrizione @40" S0 OUTPUT ANNO CODTAB[1,4] OUTPUT CODICE_LIBRO CODTAB[5,7] - //CHECKTYPE NORMAL FLAGS "U" VALIDATE ZEROFILL_FUNC 3 GROUP 1 @@ -182,7 +179,6 @@ BEGIN HELP "Indicare il tipo stampa di liquidazione sul registro" ITEM "P|Del periodo" ITEM "A|Annuale" - GROUP 4 END GROUPBOX DLG_NULL 35 4 @@ -249,13 +245,13 @@ LISTBOX ULTIMO_MESE 10 BEGIN PROMPT 2 4 "Ultimo mese stampa su libro unico " FLAGS "MD" + ITEM "00|Nessuno" GROUP 2 END BOOLEAN RIF_VID BEGIN PROMPT 2 5 "Stampa riferimenti vidimazione" - GROUP 4 END BUTTON DLG_PRINT 10 2