Correzioni ai libri IVA

git-svn-id: svn://10.65.10.50/trunk@909 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
nik 1995-01-26 09:37:22 +00:00
parent 18b9f3f935
commit 9fb1deb9da
3 changed files with 252 additions and 224 deletions

View File

@ -1,4 +1,3 @@
// cg4400.cpp // cg4400.cpp
// Stampa registri IVA // Stampa registri IVA
#include "cg4.h" #include "cg4.h"
@ -6,6 +5,8 @@
#include "cg4400a.h" #include "cg4400a.h"
#include "cg4400b.h" #include "cg4400b.h"
static TString256 TMP;
inline CG4400_application& app() { return (CG4400_application&)main_app(); } inline CG4400_application& app() { return (CG4400_application&)main_app(); }
bool CG4400_application::filter_func (const TRelation * r) 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"); TString16 cod_lib_un = _tabreg->get("S6");
TDate u_data = _tabreg->get_date("D3"); TDate u_data = _tabreg->get_date("D3");
TDate sca_vid = _tabreg->get_date("D0"); TDate sca_vid = _tabreg->get_date("D0");
if (_selected[i]) if (codlib != cod_lib_un)
{ {
if (codlib != cod_lib_un) if (_selected[i]) message_box("Ditta %ld: il codice libro unico del registro non e' uguale al codice libro unico indicato", ditta);
{ return FALSE;
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;
}
} }
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; 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()) for (_tabreg->first(); !_tabreg->eof(); _tabreg->next())
{ {
tipo = _tabreg->get_int("I0"); tipo = _tabreg->get_int("I0");
codtab = _tabreg->get("CODTAB"); codtab = _tabreg->get("CODTAB");
a = atoi(codtab.mid(0,4)); a = atoi(codtab.mid(0,4));
if (a > anno) if (a > anno)
{
// message_box("Non esistono registri IVA della Ditta %ld per l'anno %d", _nditte->get_long("CODDITTA"), anno);
// break;
return FALSE; return FALSE;
}
if (a == anno) if (a == anno)
if ( tipo == 1 || tipo == 2 ) //registro iva if ( tipo == 1 || tipo == 2 ) //registro iva
{ {
@ -265,10 +258,6 @@ bool CG4400_application::look_regs(int anno, TString& codlib, int m, int* umese,
app().set_firm(__firm); app().set_firm(__firm);
return error_box("Ditta %ld: Stampare i registri dei mesi precedenti", ditta); 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; 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 cod(f.mask().get(CODICE_LIBRO_IVA));
TString16 codlib(f.mask().get(CODICE_LIB_UN)); TString16 codlib(f.mask().get(CODICE_LIB_UN));
int fino_a_mese = f.mask().get_int(MESE); int fino_a_mese = f.mask().get_int(MESE);
int anno = f.mask().get_int(ANNO); int anno = f.mask().get_int(ANNO);
bool ok = FALSE; bool ok = FALSE;
int last_mese = 13; int last_mese = 13;
int mese; int mese = 0;
app().__firm = app().get_firm(); 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); ok = app().look_reg(i,anno,codlib,fino_a_mese,cod,&mese,ditta);
if (!ok) 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; continue;
} }
if (mese != 0 && mese < fino_a_mese - 1) //indipendentemente se si tratta di una ditta selezionata oppure no 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 else
{ {
ok = app().look_regs(anno,codlib,fino_a_mese,&mese,ditta); 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); f.message_box("Ditta %ld: nessun registro soddisfa i parametri indicati", ditta);
continue; continue;
@ -321,9 +312,11 @@ bool CG4400_application::mask_libun (TMask_field& f, KEY k)
last_mese = (last_mese < mese) ? last_mese : mese; last_mese = (last_mese < mese) ? last_mese : mese;
} }
} }
app().set_firm(app().__firm); app().set_firm(app().__firm);
if (last_mese == 13) 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 = ""; const char* me = "";
me = format("%02d", last_mese); me = format("%02d", last_mese);
f.mask().set(ULTIMO_MESE, me); f.mask().set(ULTIMO_MESE, me);
@ -337,9 +330,17 @@ bool CG4400_application::mask_cod (TMask_field& f, KEY k)
TString codtab; TString codtab;
int anno; 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); anno = f.mask().get_int(ANNO);
TabLbu.zero(); 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) 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); const int anno = f.mask().get_int(ANNO);
TDate data(f.get()); TDate data(f.get());
@ -370,9 +371,11 @@ bool CG4400_application::mask_data (TMask_field& f, KEY k)
} }
if (f.dlg() == A_DATA) if (f.dlg() == A_DATA)
if (data.ok) if (data.ok)
{
if ( data.day() == 31 && data.month() == 12 ) if ( data.day() == 31 && data.month() == 12 )
f.mask().show (TIPO_RIEPILOGATIVO); f.mask().show (TIPO_RIEPILOGATIVO);
else f.mask().hide (TIPO_RIEPILOGATIVO); else f.mask().hide (TIPO_RIEPILOGATIVO);
}
} }
return TRUE; return TRUE;
} }
@ -652,7 +655,6 @@ bool CG4400_application::user_create()
_occas = new TLocalisamfile(LF_OCCAS); _occas = new TLocalisamfile(LF_OCCAS);
_nditte = new TRelation(LF_NDITTE); _nditte = new TRelation(LF_NDITTE);
//_nditte->add(LF_ATTIV, "CODDITTA=CODDITTA");
_rel = new TRelation (LF_MOV); _rel = new TRelation (LF_MOV);
_rel->add(LF_CAUSALI,"CODCAUS=CODCAUS",1,LF_MOV); _rel->add(LF_CAUSALI,"CODCAUS=CODCAUS",1,LF_MOV);
@ -897,7 +899,6 @@ bool CG4400_application::controlla_liquidazione()
{ {
TTable lim ("LIM"); TTable lim ("LIM");
TTable pim ("PIM"); TTable pim ("PIM");
TString mesi_ric = "";
TString mesi_cal = ""; TString mesi_cal = "";
TString16 chiave = ""; TString16 chiave = "";
TString16 ditta = ""; TString16 ditta = "";
@ -924,13 +925,7 @@ bool CG4400_application::controlla_liquidazione()
chiave = ""; chiave = "";
chiave << _annoes << i; chiave << _annoes << i;
lim.put("CODTAB", chiave); lim.put("CODTAB", chiave);
if (lim.read() == NOERR) if (lim.read() != NOERR)
{
bool calcolato = lim.get_bool("B0");
if (!calcolato)
mesi_ric << itom(i) << "\n";
}
else
mesi_cal << itom(i) << "\n"; mesi_cal << itom(i) << "\n";
} }
} }
@ -941,25 +936,13 @@ bool CG4400_application::controlla_liquidazione()
chiave = ""; chiave = "";
chiave << _annoes << i; chiave << _annoes << i;
lim.put("CODTAB", chiave); lim.put("CODTAB", chiave);
if (lim.read() == NOERR) if (lim.read() != NOERR)
{
bool calcolato = lim.get_bool("B0");
if (!calcolato)
mesi_ric << itom(i) << "\n";
}
else
mesi_cal << itom(i) << "\n"; 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()) 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); 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?"); return yesno_box("Vuoi ugualmente continuare la stampa?");
} }
@ -970,16 +953,11 @@ bool CG4400_application::controlla_liquidazione()
chiave = ""; chiave = "";
chiave << _annoes << 13; chiave << _annoes << 13;
lim.put("CODTAB", chiave); lim.put("CODTAB", chiave);
if (lim.read() == NOERR) if (lim.read() != NOERR)
{ {
bool calcolato = lim.get_bool("B0"); //_liquidazione = FALSE;
if (!calcolato) 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; return TRUE;
} }
@ -1010,14 +988,7 @@ bool CG4400_application::controlla_mov()
{ {
long numreg = mov.get_long(MOV_NUMREG); long numreg = mov.get_long(MOV_NUMREG);
if (!stampato) 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; ok = FALSE;
}
} }
if ( datareg.year() == _annoes && first) if ( datareg.year() == _annoes && first)
if (!stampato) if (!stampato)
@ -1103,15 +1074,15 @@ int CG4400_application::stampa_prospetto()
_stampa = stampa_totali_finali(); _stampa = stampa_totali_finali();
if (_stampa) if (_stampa)
{ {
set_row(++r, "Tipo documento@40gTotale documento"); set_row(++r, "Tipo documento@54gTotale documento");
r+=2; r+=2;
for (int j = 0; j < _doc_array.items(); j++) for (int j = 0; j < _doc_array.items(); j++)
{ {
TTipodoc& doc = (TTipodoc&)_doc_array[j]; TTipodoc& doc = (TTipodoc&)_doc_array[j];
rr = r+j; rr = r+j;
set_row(rr, "%2s", (const char*) doc._tipodoc); set_row(rr, "%2s", (const char*) doc._tipodoc);
set_row(rr, "@3g%-.35s", (const char*) doc._descrdoc); set_row(rr, "@3g%s", (const char*) doc._descrdoc);
set_row(rr, "@39g%r", &doc._totdoc); set_row(rr, "@54g%r", &doc._totdoc);
} }
_doc_array.destroy(); _doc_array.destroy();
} }
@ -1446,9 +1417,9 @@ void CG4400_application::stampa_plafonds(int r)
if (pla.read() == NOERR) if (pla.read() == NOERR)
{ {
r1 = pla.get_real("R1"); //totali esp. art.8 r1 = pla.get_real("R5"); //totali esp. art.8
r2 = pla.get_real("R2"); //totali esp. art.8 bis r2 = pla.get_real("R6"); //totali esp. art.8 bis
r3 = pla.get_real("R3"); //totali esp. art 9 r3 = pla.get_real("R7"); //totali esp. art 9
} }
if (r1 > ZERO || r2 > ZERO || r3 > ZERO) if (r1 > ZERO || r2 > ZERO || r3 > ZERO)
@ -1641,17 +1612,20 @@ bool CG4400_application::compila_reg(const TMask& m)
if (_tipo_stampa != 1) if (_tipo_stampa != 1)
{ {
_u_data = _tabreg->get_date ("D3"); _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 ( _tipo_stampa == 2 || _tipo_stampa == 4 )
{ {
if (_data_a < _u_data) 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); TString16 datas = format("%02d/%02d/%4d", _u_data.day(), _u_data.month(), _u_data.year());
return FALSE; 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()) if (cod_lib_un.not_empty())
{ {
warning_box ("Ditta %ld: sul registro non deve essere indicato il codice del libro unico", _ditta); 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); _datareg = mov.get_date(MOV_DATAREG);
if ((_tipo_stampa == 2 || _tipo_stampa == 4) && _liquidazione) if (_tipo_stampa != 3 && _liquidazione)
for (int m = _stampa_mese; m > 0 && m < _datareg.month(); m++) {
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 (!_st_liq[m])
if (stampo_liquidazione(m)) if (stampo_liquidazione(m))
{ {
_datareg = format("01/%02d/%4d", m, _annoes); //serve per la preprocess_header (intestazione per la stampa liquidazione) _datareg = format("01/%02d/%4d", m, _annoes); //serve per la preprocess_header (intestazione per la stampa liquidazione)
_intesta_liq = TRUE;
TFilename t; TFilename t;
t.temp(); t.temp();
send_message('L',t, m); if (_tipo_stampa == 1)
//if (m > 1) printer().formfeed(); send_message('L',t, m);
merge_export_file(t,FALSE,TRUE); else send_message('l',t,m);
_intesta_liq = FALSE; TString80 nomef; nomef = t.path(); nomef << "\\" << t.name();
_st_liq[m] = TRUE; 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); _datareg = mov.get_date(MOV_DATAREG);
_mov_empty = FALSE; _mov_empty = FALSE;
@ -2007,7 +1992,7 @@ bool CG4400_application::preprocess_page(int file, int counter)
if (corrval != ZERO) if (corrval != ZERO)
{ {
TString vall (corrval.string("###.###.###.###,@@")); 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; return TRUE;
@ -2141,14 +2126,21 @@ void CG4400_application::aggiorna_lib()
bool CG4400_application::stampo_liquidazione(int mese) bool CG4400_application::stampo_liquidazione(int mese)
{ {
//if (_liquidazione) if (_tipo_stampa == 1)
if ( (_frequiva == 'T' && (mese == 3 || mese == 6 || mese == 9 || mese == 12)) {
|| _frequiva != 'T' || (mese == 12 && _tipo_riepilogativo == 'A') ) if ( (_frequiva == 'T' && (mese == 3 || mese == 6 || mese == 9 || mese == 12))
if ( (mese == 12 && _tipo_riepilogativo == 'A' && _mese_ultima_liq != 13) || _frequiva != 'T' || (mese == 12 && _tipo_riepilogativo == 'A') )
|| (mese != 12 && mese > _mese_ultima_liq)
|| (mese == 12 && _tipo_riepilogativo != 'A' && mese > _mese_ultima_liq) )
return TRUE; 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; return FALSE;
} }
@ -2164,7 +2156,8 @@ void CG4400_application::stampa_vidi()
_ok_vidi = FALSE; _ok_vidi = FALSE;
TPrintrow row; TPrintrow row;
printer().open(); if (!printer().isopen())
printer().open();
codtab << _annoes << _codlib; codtab << _annoes << _codlib;
TabInl.zero(); 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 (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(); reset_print();
if (_tipo_stampa != 1 && _liquidazione) if (_liquidazione)
if (stampo_liquidazione(_datareg.month())) if (stampo_liquidazione(_datareg.month()))
{ {
_st_liq[_datareg.month()] = TRUE; _st_liq[_datareg.month()] = TRUE;
_intesta_liq = TRUE;
printer().formfeed();
TFilename t; TFilename t;
t.temp(); t.temp();
send_message('L',t, _datareg.month()); //stampa liquidazione if (_tipo_stampa == 1)
merge_export_file(t,FALSE,TRUE); send_message('L',t, _datareg.month()); //stampa liquidazione
_intesta_liq = FALSE; else send_message('l',t, _datareg.month());
//if (_tipo_stampa != 1) aggiorna_reg(); 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) if (!counter)
@ -2270,22 +2268,6 @@ print_action CG4400_application::postprocess_page (int file, int counter)
return NEXT_PAGE; return NEXT_PAGE;
} }
/*
print_action CG4400_application::postprocess_print(int file, int counter)
{
if (file == LF_MOV)
{
if (_stampa_tutti_i_registri)
//if (!_mov_empty )
{
if (_tipo_stampa == 3)
++ _u_stampata;
}
}
return NEXT_PAGE;
}
*/
bool CG4400_application::set_print(int n) bool CG4400_application::set_print(int n)
{ {
TMask m ("cg4400a"); TMask m ("cg4400a");
@ -2418,13 +2400,6 @@ bool CG4400_application::stampa_registri_IVA(const TMask& m)
_frequiva = _tablia->get("S7")[0]; _frequiva = _tablia->get("S7")[0];
_credito = _tablia->get_real("R0"); //credito iva anno precedente _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); ok = compila_reg(m);
if (!ok) continue; if (!ok) continue;
if (_tipo_stampa == 2 || _tipo_stampa == 4) 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); m = format("%02d", _stampa_mese);
mb.set(U_MESE, m); mb.set(U_MESE, m);
mb.set(U_PAGINA, _pagine_stampate); 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(); KEY tasto = mb.run();
if (tasto != K_ENTER) continue; if (tasto != K_ENTER) continue;
} }
@ -2466,32 +2442,50 @@ bool CG4400_application::stampa_registri_IVA(const TMask& m)
t.temp(); t.temp();
send_message('C',t, _fino_a_mese); send_message('C',t, _fino_a_mese);
} }
print(); print();
if (_tipo_stampa != 3 && _liquidazione)
stampa_liq_mesi_succ();
} }
else else //non ci sono movimenti da stampare nel periodo richiesto!
{ {
_mov_empty = TRUE; _mov_empty = TRUE;
int limite; if (_liquidazione)
//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)
{ {
printer().open(); int da, a;
for (int m = limite; m > 0 && m <= _fino_a_mese; m++) //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)) 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
_intesta_liq = TRUE;
TFilename t; TFilename t;
t.temp(); t.temp();
send_message('L',t, m); if (_tipo_stampa == 1)
if (m > 1) printer().formfeed(); send_message('L',t, m);
merge_export_file(t,FALSE,TRUE); else send_message('l',t, m);
_intesta_liq = FALSE; 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(); printer().close();
@ -2522,18 +2516,15 @@ else //stampa tutti i registri
cod_lib_un = _tabreg->get("S6"); cod_lib_un = _tabreg->get("S6");
sca_vid = _tabreg->get_date("D0"); sca_vid = _tabreg->get_date("D0");
if (_tipo_stampa != 1) if (_tipo_stampa != 1)
{
_u_data = _tabreg->get_date("D3"); _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 (_tipo_stampa == 2 || _tipo_stampa == 4)
{ {
if (_data_a < _u_data) 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; 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()) if (cod_lib_un.not_empty())
continue; continue;
if (sca_vid.ok()) if (sca_vid.ok())
@ -2553,21 +2544,15 @@ else //stampa tutti i registri
{ {
if (cod_lib_un != _codlib) if (cod_lib_un != _codlib)
continue; continue;
if (_fino_a_mese < _u_data.month()) if (_u_data.ok())
continue; if (_fino_a_mese < _u_data.month())
continue;
if (sca_vid.ok()) if (sca_vid.ok())
if (sca_vid.month() < _fino_a_mese) if (sca_vid.month() < _fino_a_mese)
continue; continue;
} }
msg = FALSE; msg = FALSE;
_liquidazione = _tabreg->get_bool("B7"); _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"); _riep_liq = _tabreg->get_bool("B6");
_corrispettivi = _tabreg->get_bool("B0"); _corrispettivi = _tabreg->get_bool("B0");
_pagine_stampate = _tabreg->get_long("I1"); _pagine_stampate = _tabreg->get_long("I1");
@ -2598,7 +2583,8 @@ else //stampa tutti i registri
m = format("%02d", _stampa_mese); m = format("%02d", _stampa_mese);
mb.set(U_MESE, m); mb.set(U_MESE, m);
mb.set(U_PAGINA, _pagine_stampate); 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(); KEY tasto = mb.run();
if (tasto != K_ENTER) continue; if (tasto != K_ENTER) continue;
} }
@ -2615,38 +2601,55 @@ else //stampa tutti i registri
t.temp(); t.temp();
send_message('C',t, _fino_a_mese); 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. else //anche se non ho dei movimenti devo stampare la liq. sotto certe ipotesi.
{ {
int limite;
_mov_empty = TRUE; _mov_empty = TRUE;
//stampo la liquidazione per tutti i mesi fino a _fino_a_mese (in caso di stampa = 2/3/4) //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) if (_liquidazione)
limite = _stampa_mese;
if (_tipo_stampa == 3)
limite = _fino_a_mese;
if (_tipo_stampa != 1 && _liquidazione)
{ {
printer().open(); int da, a;
for (int m = limite; m > 0 && m <= _fino_a_mese; m++) 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)) if (stampo_liquidazione(m))
{ {
ok = controlla_liquidazione(); //ok = controlla_liquidazione();
if (!ok) break; //if (!ok) break;
_datareg = format("01/%02d/%4d", m, _annoes); //serve per la preprocess_header _datareg = format("01/%02d/%4d", m, _annoes); //serve per la preprocess_header
_intesta_liq = TRUE;
TFilename t; TFilename t;
t.temp(); t.temp();
send_message('L',t, m); TString80 nomef; nomef = t.path(); nomef << "\\" << t.name();
if (m > 1) printer().formfeed(); if (_tipo_stampa == 1)
merge_export_file(t,FALSE,TRUE); send_message('L',t, m);
_intesta_liq = FALSE; 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(); printer().close();
//if (_tipo_stampa != 1) aggiorna_reg();
} }
} }
if (_tipo_stampa == 3 && _rif_vid) if (_tipo_stampa == 3 && _rif_vid)
@ -2659,33 +2662,53 @@ else //stampa tutti i registri
if (msg) if (msg)
message_box("Ditta %ld: Nessun registro soddisfa i parametri indicati", _ditta); message_box("Ditta %ld: Nessun registro soddisfa i parametri indicati", _ditta);
} }
//if (_tipo_stampa == 3)
// aggiorna_lib();
} }
} }
TApplication::set_firm(__firm); TApplication::set_firm(__firm);
return TRUE; 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) 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 -icon";
const char* const app = "cg4a -2"; const char* const app = "cg4a -2";
TToken_string ss(10); TToken_string ss(10);
//int mese ;
ss.add(_annoes); ss.add(_annoes);
ss.add(mese); ss.add(mese);
ss.add(_ditta); ss.add(_ditta);
ss.add(tipo); ss.add(tipo);
//if (tipo == 'L')
//{
ss.add(_data_stampa.string()); ss.add(_data_stampa.string());
ss.add(nome); ss.add(nome);
ss.add("x"); ss.add("x");
//}
TMessage liq ("cg4a -2", "RCL", ss); TMessage liq ("cg4a -2", "RCL", ss);
liq.send(); liq.send();
@ -2703,6 +2726,9 @@ bool CG4400_application::set_ditte(TMask& m)
m.field(A_CODICE).set(""); m.field(A_CODICE).set("");
*/ */
m.field(TIPO_STAMPA).set("1"); m.field(TIPO_STAMPA).set("1");
m.field(DA_DATA).set("");
m.field(A_DATA).set("");
m.field(CODICE_LIBRO_PROVA).set("");
KEY tasto; KEY tasto;
tasto = m.run(); tasto = m.run();
@ -2913,20 +2939,24 @@ void CG4400_application::preprocess_header()
tipo = 'A'; tipo = 'A';
type = 'T'; 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 (_tipo_stampa == 1) //stampa di prova (_intesta_vidi e' di sicuro FALSE)
{ {
if (_stampa_width == 132) 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++; 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); 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++; r++;
} }
else //stampa a 198 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++; 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); 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++; r++;
@ -2936,7 +2966,8 @@ else if (!_intesta_vidi)
{ {
if (_stampa_width == 132) 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 if (_tipo_stampa == 4) //stampa definitiva con rif. al libro giornale
set_header(r, "@128gNum."); set_header(r, "@128gNum.");
r++; r++;
@ -2948,7 +2979,8 @@ else if (!_intesta_vidi)
} }
else //stampa a 198 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) if (_tipo_stampa == 4)
set_header(r, "@139gNum."); set_header(r, "@139gNum.");
r++; r++;

View File

@ -13,7 +13,7 @@
#include <sheet.h> #include <sheet.h>
#include <config.h> #include <config.h>
#include <prefix.h> #include <prefix.h>
#include "conto.h" #include <conto.h>
#include <nditte.h> #include <nditte.h>
#include <anagr.h> #include <anagr.h>
#include <comuni.h> #include <comuni.h>
@ -37,11 +37,10 @@ class CG4400_application : public TPrintapp
TRigaiva_array _iva_array, _riga_rmi; TRigaiva_array _iva_array, _riga_rmi;
TTipodoc_array _doc_array; TTipodoc_array _doc_array;
TRiga_array _tot_iva_array; TRiga_array _tot_iva_array;
bool _st_liq[12];
TBit_array _selected; TBit_array _selected;
TArray_sheet *_ditte; TArray_sheet *_ditte;
TArray _nomiditte; TArray _nomiditte;
bool _st_liq[12];
TRecnotype _nrec; TRecnotype _nrec;
bool _mov_empty, _stampa_ind_ditta, _stampa_tutti_i_registri, _auto_intraf, _stampa; 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 _corrispettivi, _liquidazione, _riep_liq, _stampa_ind_comp, _esiste_riga_iva, _stampa_cred_pre;
@ -93,6 +92,7 @@ protected:
void aggiorna_reg(); void aggiorna_reg();
void aggiorna_lib(); void aggiorna_lib();
void calcola_progressivi(); void calcola_progressivi();
void stampa_liq_mesi_succ();
bool user_create(); bool user_create();
bool user_destroy(); bool user_destroy();
bool preprocess_page(int, int); bool preprocess_page(int, int);

View File

@ -10,13 +10,13 @@ BEGIN
PROMPT 2 1 "Tipo " PROMPT 2 1 "Tipo "
HELP "Indicare il tipo di stampa da eseguire" HELP "Indicare il tipo di stampa da eseguire"
ITEM "1|Stampa di prova" 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" 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" 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" 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 END
NUMBER ANNO 4 NUMBER ANNO 4
@ -36,7 +36,6 @@ END
NUMBER DA_CODICE 6 NUMBER DA_CODICE 6
BEGIN BEGIN
PROMPT 17 3 "Da codice " PROMPT 17 3 "Da codice "
//FLAGS "UR"
HELP "Codice ditta di inizio selezione" HELP "Codice ditta di inizio selezione"
END END
@ -49,7 +48,6 @@ END
NUMBER A_CODICE 6 NUMBER A_CODICE 6
BEGIN BEGIN
PROMPT 17 4 "A codice " PROMPT 17 4 "A codice "
//FLAGS "UR"
HELP "Codice ditta di fine selezione" HELP "Codice ditta di fine selezione"
END END
@ -98,7 +96,6 @@ BEGIN
DISPLAY "Descrizione @40" S0 DISPLAY "Descrizione @40" S0
OUTPUT ANNO CODTAB[1,4] OUTPUT ANNO CODTAB[1,4]
OUTPUT CODICE_LIBRO CODTAB[5,7] OUTPUT CODICE_LIBRO CODTAB[5,7]
//CHECKTYPE NORMAL
FLAGS "U" FLAGS "U"
VALIDATE ZEROFILL_FUNC 3 VALIDATE ZEROFILL_FUNC 3
GROUP 1 GROUP 1
@ -182,7 +179,6 @@ BEGIN
HELP "Indicare il tipo stampa di liquidazione sul registro" HELP "Indicare il tipo stampa di liquidazione sul registro"
ITEM "P|Del periodo" ITEM "P|Del periodo"
ITEM "A|Annuale" ITEM "A|Annuale"
GROUP 4
END END
GROUPBOX DLG_NULL 35 4 GROUPBOX DLG_NULL 35 4
@ -249,13 +245,13 @@ LISTBOX ULTIMO_MESE 10
BEGIN BEGIN
PROMPT 2 4 "Ultimo mese stampa su libro unico " PROMPT 2 4 "Ultimo mese stampa su libro unico "
FLAGS "MD" FLAGS "MD"
ITEM "00|Nessuno"
GROUP 2 GROUP 2
END END
BOOLEAN RIF_VID BOOLEAN RIF_VID
BEGIN BEGIN
PROMPT 2 5 "Stampa riferimenti vidimazione" PROMPT 2 5 "Stampa riferimenti vidimazione"
GROUP 4
END END
BUTTON DLG_PRINT 10 2 BUTTON DLG_PRINT 10 2