Corretta stampa del libro giornale.
git-svn-id: svn://10.65.10.50/trunk@3715 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
d534d22b12
commit
6489a14237
279
cg/cg3400.cpp
279
cg/cg3400.cpp
@ -80,7 +80,7 @@ const TContoOccas& TContoOccas::set(int g, int c, long s, char t,const char* d,
|
||||
|
||||
const TString& TContoOccas::descrizione()
|
||||
{
|
||||
bool really_occas = FALSE;
|
||||
bool really_occas = FALSE;
|
||||
|
||||
if (_occfpi.not_empty())
|
||||
{
|
||||
@ -89,12 +89,11 @@ const TString& TContoOccas::descrizione()
|
||||
clifo.put(CLI_CODCF, (long)_s);
|
||||
clifo.put(CLI_TIPOCF, _t);
|
||||
const bool clifo_ok = (clifo.read() == NOERR);
|
||||
if (clifo_ok) really_occas = clifo.get_bool(CLI_OCCAS);
|
||||
if (clifo_ok)
|
||||
really_occas = clifo.get_bool(CLI_OCCAS);
|
||||
}
|
||||
|
||||
if (_occfpi.empty() || !really_occas)
|
||||
_descrizione = TBill::descrizione();
|
||||
else
|
||||
if (really_occas)
|
||||
{
|
||||
TLocalisamfile occ(LF_OCCAS);
|
||||
occ.zero();
|
||||
@ -102,6 +101,9 @@ const TString& TContoOccas::descrizione()
|
||||
if (occ.read() != NOERR) occ.zero();
|
||||
_descrizione = occ.get("RAGSOC");
|
||||
}
|
||||
else
|
||||
_descrizione = TBill::descrizione();
|
||||
|
||||
return _descrizione;
|
||||
}
|
||||
|
||||
@ -137,7 +139,6 @@ private:
|
||||
char _sezione;
|
||||
int _pagine_contate; // cnt pag. stampate.
|
||||
public:
|
||||
TDate _inizioEs, _fineEs; // date inizio e fine esercizio
|
||||
TRigaiva_array _iva_array;
|
||||
|
||||
TString16 _reg_cod;
|
||||
@ -243,27 +244,24 @@ bool CG3400_application::filtra_reg(const TRelation * r)
|
||||
bool CG3400_application::filter_func(const TRelation * r)
|
||||
{
|
||||
const TRectype& recmov = r->lfile().curr();
|
||||
TRectype& recrmov = r->lfile(LF_RMOV).curr();
|
||||
const long numreg = recmov.get_long("NUMREG");
|
||||
|
||||
// Scarto SEMPRE i provvisori
|
||||
TString16 provvis = recmov.get(MOV_PROVVIS);
|
||||
if (provvis.trim().not_empty())
|
||||
const TString& provvis = recmov.get(MOV_PROVVIS);
|
||||
if (!provvis.blank())
|
||||
return FALSE;
|
||||
|
||||
// In caso di NO libro con iva scarta quelli che non hanno righe contabili
|
||||
if (!app()._libro_giornale_iva_unico)
|
||||
{
|
||||
const long numreg = recmov.get_long("NUMREG");
|
||||
TRectype& recrmov = r->lfile(LF_RMOV).curr();
|
||||
recrmov.zero();
|
||||
recrmov.put("NUMREG", (long)numreg);
|
||||
// TRectype cfr(r->lfile(LF_RMOV).curr());
|
||||
if (r->lfile(LF_RMOV).read())
|
||||
recrmov.put("NUMREG", numreg);
|
||||
recrmov.put("NUMRIG", 1);
|
||||
if (r->lfile(LF_RMOV).read() != NOERR)
|
||||
{
|
||||
const long numreg2 = recrmov.get_long("NUMREG");
|
||||
if (numreg2 != numreg)
|
||||
return FALSE;
|
||||
else
|
||||
return TRUE;
|
||||
return numreg2 == numreg;
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
@ -718,6 +716,11 @@ int CG3400_application::set_headers()
|
||||
|
||||
if (_stampa_intesta || !_stampa_definitiva)
|
||||
r = stampa_intestazione_ditta();
|
||||
else
|
||||
{
|
||||
set_header(r++, "");
|
||||
set_header(r++, "");
|
||||
}
|
||||
|
||||
if (_stampa_definitiva)
|
||||
set_header(r++, "Codice libro: %s %s ",(const char *) _reg_cod, (const char *) _reg_descr);
|
||||
@ -1402,73 +1405,73 @@ int CG3400_application::setta_righe_indirizzo(char tipocf, long codcf,int rdes)
|
||||
capcf = occ.get (OCC_CAP);
|
||||
comcf = occ.get (OCC_COM);
|
||||
}
|
||||
else
|
||||
{
|
||||
// E' possibile cio' ?
|
||||
if (!clifo_ok) return r;
|
||||
|
||||
viacf = _clifo->get(CLI_INDCF);
|
||||
civcf = _clifo->get(CLI_CIVCF);
|
||||
comcf = _clifo->get(CLI_COMCF);
|
||||
capcf = _clifo->get(CLI_CAPCF);
|
||||
statocf = _clifo->get(CLI_STATOCF);
|
||||
tipoa = _clifo->get_char(CLI_TIPOAPER);
|
||||
codanagr = _clifo->get_long(CLI_CODANAGPER);
|
||||
}
|
||||
|
||||
TRectype rec = look_com (comcf);
|
||||
comune = rec.get(COM_DENCOM);
|
||||
prov = rec.get(COM_PROVCOM);
|
||||
|
||||
if (viacf.not_empty())
|
||||
{
|
||||
sprintf (riga, "@%dg%s %s",
|
||||
POSCONTO,
|
||||
(const char*) viacf,
|
||||
(const char*) civcf
|
||||
);
|
||||
|
||||
set_row (r++, riga);
|
||||
}
|
||||
|
||||
if (comune.not_empty() || prov.not_empty() || capcf.not_empty())
|
||||
{
|
||||
sprintf (riga, "@%dg%s %s %s",
|
||||
POSCONTO,
|
||||
(const char*) capcf, (const char*) comune,
|
||||
(const char*) prov
|
||||
);
|
||||
set_row (r++, riga);
|
||||
}
|
||||
|
||||
// Se fisica prendo anche data nascita e luogo
|
||||
if (tipoa == 'F')
|
||||
{
|
||||
TString80 comna;
|
||||
TString16 datana, codcomna, provna, capna, statona;
|
||||
|
||||
datana = _clifo->get("DATANASC");
|
||||
|
||||
if (datana.not_empty())
|
||||
else
|
||||
{
|
||||
codcomna = _clifo->get("COMNASC");
|
||||
TRectype dep = look_com (codcomna);
|
||||
|
||||
comna = dep.get(COM_DENCOM);
|
||||
provna = dep.get(COM_PROVCOM);
|
||||
capna = dep.get(COM_CAPCOM);
|
||||
|
||||
statona = dep.get("STATO");
|
||||
|
||||
sprintf (riga, "@%dg%s %s %s %s", POSCONTO,
|
||||
(const char*)datana,
|
||||
(const char*)comna,
|
||||
(const char*)provna, (const char*) capna);
|
||||
|
||||
set_row(r++, riga);
|
||||
// E' possibile cio' ?
|
||||
if (!clifo_ok) return r;
|
||||
|
||||
viacf = _clifo->get(CLI_INDCF);
|
||||
civcf = _clifo->get(CLI_CIVCF);
|
||||
comcf = _clifo->get(CLI_COMCF);
|
||||
capcf = _clifo->get(CLI_CAPCF);
|
||||
statocf = _clifo->get(CLI_STATOCF);
|
||||
tipoa = _clifo->get_char(CLI_TIPOAPER);
|
||||
codanagr = _clifo->get_long(CLI_CODANAGPER);
|
||||
}
|
||||
}
|
||||
return r;
|
||||
|
||||
TRectype rec = look_com (comcf);
|
||||
comune = rec.get(COM_DENCOM);
|
||||
prov = rec.get(COM_PROVCOM);
|
||||
|
||||
if (viacf.not_empty())
|
||||
{
|
||||
sprintf (riga, "@%dg%s %s",
|
||||
POSCONTO,
|
||||
(const char*) viacf,
|
||||
(const char*) civcf
|
||||
);
|
||||
|
||||
set_row (r++, riga);
|
||||
}
|
||||
|
||||
if (comune.not_empty() || prov.not_empty() || capcf.not_empty())
|
||||
{
|
||||
sprintf (riga, "@%dg%s %s %s",
|
||||
POSCONTO,
|
||||
(const char*) capcf, (const char*) comune,
|
||||
(const char*) prov
|
||||
);
|
||||
set_row (r++, riga);
|
||||
}
|
||||
|
||||
// Se fisica prendo anche data nascita e luogo
|
||||
if (tipoa == 'F')
|
||||
{
|
||||
TString80 comna;
|
||||
TString16 datana, codcomna, provna, capna, statona;
|
||||
|
||||
datana = _clifo->get("DATANASC");
|
||||
|
||||
if (datana.not_empty())
|
||||
{
|
||||
codcomna = _clifo->get("COMNASC");
|
||||
TRectype dep = look_com (codcomna);
|
||||
|
||||
comna = dep.get(COM_DENCOM);
|
||||
provna = dep.get(COM_PROVCOM);
|
||||
capna = dep.get(COM_CAPCOM);
|
||||
|
||||
statona = dep.get("STATO");
|
||||
|
||||
sprintf (riga, "@%dg%s %s %s %s", POSCONTO,
|
||||
(const char*)datana,
|
||||
(const char*)comna,
|
||||
(const char*)provna, (const char*) capna);
|
||||
|
||||
set_row(r++, riga);
|
||||
}
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
//
|
||||
@ -1498,56 +1501,52 @@ void CG3400_application::aggiorna_tabreg(int partito_da, int stampate)
|
||||
|
||||
void CG3400_application::get_date_aep(int aep, TDate* in, TDate* fin)
|
||||
{
|
||||
/* L'anno del giornale non e' piu' un esercizio ma un anno solare
|
||||
TTable esc("ESC");
|
||||
|
||||
esc.zero(); esc.put("CODTAB", format("%04d",aep));
|
||||
if (esc.read() == NOERR)
|
||||
{
|
||||
*in = esc.get_date("D0");
|
||||
*fin = esc.get_date("D1");
|
||||
}
|
||||
*/
|
||||
*in = TDate(1,1,aep);
|
||||
*fin = TDate(31,12,aep);
|
||||
}
|
||||
|
||||
const int es_prec(const int es_corr)
|
||||
{
|
||||
/* L'anno del giornale non e' piu' un esercizio ma un anno solare
|
||||
TEsercizi_contabili esc;
|
||||
return esc.pred(es_corr);
|
||||
*/
|
||||
return es_corr-1;
|
||||
}
|
||||
|
||||
bool CG3400_application::controlla_mov_aep()
|
||||
{
|
||||
begin_wait();
|
||||
|
||||
const int aep = es_prec(_ae);
|
||||
bool gia_stampati = TRUE;
|
||||
TDate inizio_ep, fine_ep;
|
||||
|
||||
if (aep == 0) // = e' il primo esercizio
|
||||
return TRUE;
|
||||
else
|
||||
get_date_aep(aep,&inizio_ep, &fine_ep);
|
||||
else
|
||||
get_date_aep(aep,&inizio_ep, &fine_ep);
|
||||
|
||||
#ifdef DBG
|
||||
TString instr(inizio_ep.string());
|
||||
TString finstr(fine_ep.string());
|
||||
#endif
|
||||
|
||||
TRectype da (_cur->file(LF_MOV).curr());
|
||||
TRectype a (_cur->file(LF_MOV).curr());
|
||||
|
||||
da.zero(); a.zero();
|
||||
TRectype da (LF_MOV);
|
||||
TRectype a (LF_MOV);
|
||||
da.put(MOV_DATAREG, inizio_ep);
|
||||
a.put (MOV_DATAREG, fine_ep);
|
||||
|
||||
_cur->setregion(da, a);
|
||||
_cur->set_filterfunction(filter_func);
|
||||
// _cur->setfilter(format("ANNOES=%04d && STAMPATO!=\"X\"", aep));
|
||||
|
||||
(*_cur) = 0L;
|
||||
for ( ; _cur->pos() < _cur->items(); ++(*_cur))
|
||||
|
||||
bool gia_stampati = TRUE;
|
||||
for (*_cur = 0L ; _cur->ok(); ++(*_cur))
|
||||
{
|
||||
#ifdef DBG
|
||||
TString datareg(_cur->file().get("DATAREG"));
|
||||
TString numreg(_cur->file().get("NUMREG"));
|
||||
#endif
|
||||
gia_stampati = _cur->file().get_bool("STAMPATO");
|
||||
if (!gia_stampati) break; // basta trovarne uno ancora da stampare
|
||||
}
|
||||
@ -1555,10 +1554,14 @@ else
|
||||
if (_cur->items() > 0L && !gia_stampati)
|
||||
{
|
||||
_cur->setfilter("");
|
||||
warning_box("Impossibile proseguire nella stampa.\nEsistono movimenti nell'esercizio precedente non ancora stampati su bollato");
|
||||
warning_box("Impossibile proseguire con la stampa:\n"
|
||||
"Esistono movimenti nell'esercizio precedente\n"
|
||||
"che non sono ancora stati stampati su bollato.");
|
||||
return FALSE;
|
||||
}
|
||||
_cur->setfilter("");
|
||||
|
||||
end_wait();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@ -1609,26 +1612,20 @@ void CG3400_application::set_reg_filter(TMask& m)
|
||||
//
|
||||
bool CG3400_application::data_a_hndl (TMask_field& f, KEY k)
|
||||
{
|
||||
TMask& m = f.mask();
|
||||
TMask& m = f.mask();
|
||||
|
||||
if (f.to_check(k))
|
||||
{
|
||||
const TDate data_a(f.get());
|
||||
TString16 dep(data_a.string());
|
||||
const TDate data_a(f.get());
|
||||
|
||||
if (dep.empty()) return TRUE;
|
||||
|
||||
const int ae = date2esc(data_a); // Anno esercizio
|
||||
if (!data_a.ok())
|
||||
return TRUE;
|
||||
|
||||
app()._ae_solare = data_a.year();
|
||||
app()._ae = ae;
|
||||
if (ae == 0)
|
||||
return f.error_box("La data specificata non appartiene a nessun esercizio");
|
||||
else
|
||||
{
|
||||
m.set(ANNO_ESER, app()._ae_solare);
|
||||
m.send_key(K_TAB, CODREG);
|
||||
}
|
||||
app()._ae = app()._ae_solare;
|
||||
|
||||
m.set(ANNO_ESER, app()._ae_solare);
|
||||
m.send_key(K_TAB, CODREG);
|
||||
}
|
||||
|
||||
if (k == K_ENTER)
|
||||
@ -1642,10 +1639,10 @@ bool CG3400_application::data_a_hndl (TMask_field& f, KEY k)
|
||||
|
||||
if (definitiva)
|
||||
{
|
||||
if (dtda.not_empty()) // senno' ci metto inizioEs
|
||||
if (dtda.not_empty())
|
||||
{
|
||||
if (data_da < app()._inizioEs || data_a > app()._fineEs);
|
||||
return f.warning_box("Le date specificate non appartengono allo stesso esercizio");
|
||||
if (data_da.year() != data_a.year());
|
||||
return f.warning_box("Le date specificate non appartengono allo stesso anno");
|
||||
if (data_da > data_a)
|
||||
return f.warning_box("La data di partenza non puo' essere maggiore della data finale");
|
||||
}
|
||||
@ -1661,17 +1658,14 @@ bool CG3400_application::data_da_hndl(TMask_field& f, KEY k)
|
||||
// if (f.to_check(k))
|
||||
if (k == K_TAB)
|
||||
{
|
||||
const TDate data_da (f.get());
|
||||
const TString16 data_a(m.get(DATA_A));
|
||||
const int ae_data_da = date2esc(data_da);
|
||||
const TString16 dep(data_da.string());
|
||||
|
||||
if (dep.empty() || data_a.empty())
|
||||
const TDate data_da (f.get());
|
||||
const TDate data_a(m.get(DATA_A));
|
||||
|
||||
if (!data_da.ok() || !data_a.ok())
|
||||
return TRUE;
|
||||
|
||||
if (app()._ae != 0)
|
||||
if (app()._ae != ae_data_da)
|
||||
return f.error_box("Le due date non appartengono allo stesso esercizio");
|
||||
if (data_da.year() != data_a.year())
|
||||
return f.error_box("Le due date non appartengono allo stesso anno");
|
||||
}
|
||||
|
||||
if (k == K_ENTER)
|
||||
@ -1679,17 +1673,14 @@ bool CG3400_application::data_da_hndl(TMask_field& f, KEY k)
|
||||
const bool definitiva = m.get_bool(STAMPA_DEF);
|
||||
const TDate data_a(m.get(DATA_A));
|
||||
const TDate data_da(f.get());
|
||||
TString16 dtda(data_da.string());
|
||||
|
||||
// Controlli sulle date
|
||||
|
||||
// se la stampa e' di prova DALLA_DATA e' obbligatoria
|
||||
if (!definitiva)
|
||||
if (dtda.empty())
|
||||
if (!definitiva && !data_da.ok())
|
||||
return f.warning_box("Manca la data di partenza");
|
||||
|
||||
if (dtda.not_empty())
|
||||
if (data_da > data_a)
|
||||
if (data_da.ok() && data_da > data_a)
|
||||
return f.warning_box("La data di partenza non puo' essere maggiore della data finale");
|
||||
}
|
||||
return TRUE;
|
||||
@ -1716,7 +1707,7 @@ bool CG3400_application::mask_a_cod_reg (TMask_field& f, KEY k)
|
||||
else
|
||||
{
|
||||
a._ae_solare = data_a.year(); // Anno solare usato per la tabella dei registri
|
||||
a._ae = date2esc(data_a); // Anno esercizio
|
||||
a._ae = a._ae_solare; // Anno esercizio
|
||||
}
|
||||
|
||||
const TString16 reg_cod(f.get());
|
||||
@ -1788,11 +1779,7 @@ void CG3400_application::init_print()
|
||||
{
|
||||
// 17.5.95 Leggo parametri di stampa del registro
|
||||
TString16 config;
|
||||
const long codditta = get_firm();
|
||||
const char* reg = (const char*)_reg_cod;
|
||||
|
||||
config.format("REG%05ld%03s", codditta, reg);
|
||||
|
||||
config.format("REG%05ld%03s", get_firm(), (const char*)_reg_cod);
|
||||
printer().read_configuration(config);
|
||||
|
||||
if (_stampa_len != 0)
|
||||
@ -1852,15 +1839,9 @@ bool CG3400_application::init_cursor()
|
||||
{
|
||||
bool gia_stampati = FALSE;
|
||||
|
||||
TRectype da (_cur->file(LF_MOV).curr());
|
||||
TRectype a (_cur->file(LF_MOV).curr());
|
||||
TRectype da (LF_MOV);
|
||||
TRectype a (LF_MOV);
|
||||
|
||||
#ifdef DBG
|
||||
TString instr(_data_da.string());
|
||||
TString finstr(_data_a.string());
|
||||
#endif
|
||||
|
||||
da.zero(); a.zero();
|
||||
da.put(MOV_DATAREG, _data_da);
|
||||
a.put (MOV_DATAREG, _data_a);
|
||||
|
||||
@ -1910,7 +1891,7 @@ bool CG3400_application::set_print(int)
|
||||
// e si scartano i movimenti gia' stampati su bollato
|
||||
if (_stampa_definitiva)
|
||||
{
|
||||
_data_da = _inizioEs;
|
||||
_data_da = TDate(1,1,_ae);
|
||||
|
||||
// Controlla che non siano rimasti movimenti ancora da stampare dell'es.prec.
|
||||
if (_stampa_stesso_registro)
|
||||
|
Loading…
x
Reference in New Issue
Block a user