1967 lines
56 KiB
C++
Executable File
1967 lines
56 KiB
C++
Executable File
#include <mask.h>
|
|
#include <printapp.h>
|
|
#include <relation.h>
|
|
#include <tabutil.h>
|
|
#include <utility.h>
|
|
#include <sort.h>
|
|
|
|
#include <lffiles.h>
|
|
#include <clifo.h>
|
|
#include <pconti.h>
|
|
#include <mov.h>
|
|
#include <rmov.h>
|
|
#include <comuni.h>
|
|
#include <saldi.h>
|
|
#include <causali.h>
|
|
#include <nditte.h>
|
|
#include <unloc.h>
|
|
#include <mailbox.h>
|
|
#include <execp.h>
|
|
|
|
#include "cg3.h"
|
|
#include "cg3200.h"
|
|
#include "cglib.h"
|
|
#include "cglib03.h"
|
|
|
|
static TString256 tmp;
|
|
|
|
int date2esc(const TDate& d, int* prevesc = NULL);
|
|
bool sottoc_handler_ini (TMask_field& f, KEY k);
|
|
bool sottoc_handler_fine (TMask_field& f, KEY k);
|
|
|
|
class CG3200_application : public TPrintapp
|
|
{
|
|
static bool data_inizio (TMask_field& f, KEY k);
|
|
static bool data_fine (TMask_field& f, KEY k);
|
|
friend bool sottoc_handler_ini (TMask_field& f, KEY k);
|
|
friend bool sottoc_handler_fine (TMask_field& f, KEY k);
|
|
|
|
TDociva_array _b;
|
|
TRelation* _rel;
|
|
TMask* _msk;
|
|
TTable* _tabivd, * _tabtpd, * _tabreg, * _tabesc;
|
|
TLocalisamfile* _mov;
|
|
TLocalisamfile* _nditte;
|
|
TLocalisamfile* _unloc;
|
|
TLocalisamfile* _comuni;
|
|
TLocalisamfile* _clifo;
|
|
TLocalisamfile* _caus;
|
|
Saldo _sld;
|
|
|
|
TDate _data_ini,_data_fine,_data_finese,_data_finesesucc,_ultima_data_reg;
|
|
TDate _datareg,_datadoc,_data_inizioese,_datareg_stampa,_inizioes;
|
|
int _cur1,_gruppo,_conto,_numcarat,_stampanum,_numivd,_annoiva;
|
|
int _numrig,_natdoc,_tipo,_tipostampa,_g_prec,_c_prec,_numrivd_int;
|
|
real _progredare,_progreavere,_totprogre_dare_al,_totprogre_avere_al;
|
|
real _totprogre_dare,_totprogre_avere,_importo;
|
|
real _riporto_dare,_riporto_avere,_riporto_parziale_dare,_riporto_parziale_avere;
|
|
real _totale_periodo_dare,_totale_periodo_avere,_totale_prima_dare,_totale_prima_avere;
|
|
real _saldo_periodo,_saldo_progre,_saldo_progre_al,_saldo_progre_prec;
|
|
real _saldo_movimenti,_saldo_progressivi,_totale_saldo;
|
|
TString _ragsoc,_indulc,_civulc,_capulc,_com,_prov,_comulc;
|
|
long _codice_ditta,_s_prec;
|
|
TString _tipodoc,_codcaus,_descrcaus,_descrdociva,_regiva,_g_contr,_c_contr,_s_contr;
|
|
char _sezivd,_lettivd;
|
|
TString _descrizione,_sezione,_numdoc,_descrizionemov,_numrivd,_descr;
|
|
TString _dataregs, _datadocs;
|
|
int _gruppocontr,_contocontr;
|
|
long _sottocontocontr;
|
|
|
|
bool _stampaprogre,_stampatotiva,_stampatot,_prima_volta,_stampa_mov_prov;
|
|
|
|
int _annomsk,_annoesmsk,_annoes,_annomsksucc,_tipo_mask,_anno_ghost;
|
|
int _anno_corrente,_anno_precedente,_indbil;
|
|
long _sottoc,_numreg,_numgio,_protiva;
|
|
bool _stampa_progressivi_si,_competenza,_inizio_stampa,_puoi_stampare;
|
|
char _tmcf,_tipo_contr;
|
|
|
|
TDate _dataregrmov;
|
|
int _gruppof,_contof;
|
|
long _sottocf;
|
|
TString _dataregrmovstring,_importo_str,_saldo_movimenti_str,_saldo_progressivi_str;
|
|
|
|
protected:
|
|
virtual bool user_create() ;
|
|
virtual bool user_destroy();
|
|
virtual bool set_print(int m);
|
|
|
|
virtual bool preprocess_print(int file, int counter);
|
|
virtual bool preprocess_page (int,int);
|
|
virtual print_action postprocess_page (int,int);
|
|
virtual void preprocess_header();
|
|
virtual void set_page(int,int);
|
|
virtual void process_link(int id, const char* txt);
|
|
|
|
public:
|
|
TDate _inizioEs,_fineEs;
|
|
void ricerca_clifo();
|
|
void ricerca_gruppo();
|
|
void calcola_progressivi();
|
|
void calcola_progressivi_al();
|
|
void stampa_progressivi();
|
|
void stampa_progre_riporto();
|
|
void documenti_iva();
|
|
void ricerca_regiva();
|
|
void descrizione_causale();
|
|
void saldi_zero();
|
|
void crea_intestazione();
|
|
void fai_stampa132();
|
|
void fai_stampa198();
|
|
void stampa_totali132();
|
|
void stampa_totali198();
|
|
void stampa_totaliiva();
|
|
void ricerca_classe_IV(bool scelta);
|
|
void data_fine_esercizio(int);
|
|
const char* descrizione_gruppo();
|
|
const char* descrizione_conto();
|
|
const char* descrizione_classe(char,char,int,int);
|
|
bool almeno_un_record();
|
|
void ricerca_dati_ditta();
|
|
void conto(int,int,bool);
|
|
|
|
CG3200_application() {}
|
|
};
|
|
|
|
HIDDEN CG3200_application& app() { return (CG3200_application&) main_app(); }
|
|
|
|
void CG3200_application::process_link(int id, const char* txt)
|
|
{
|
|
const char* const app = "cg2 -0";
|
|
TToken_string ss(10);
|
|
ss.add("1");
|
|
ss.add(txt);
|
|
|
|
TMessage fs(cmd2name(app), MSG_LN, ss);
|
|
fs.send();
|
|
|
|
TExternal_app pn(app);
|
|
pn.run();
|
|
}
|
|
|
|
bool sottoc_handler_ini(TMask_field& f, KEY key)
|
|
{
|
|
const short id = f.dlg();
|
|
const int gruppo = f.mask().get_int(F_GRUPPOINI);
|
|
const int conto = f.mask().get_int(F_CONTOINI_CONTO);
|
|
const long sottoconto = f.mask().get_long(id);
|
|
TString ds;
|
|
TString80 rs;
|
|
TLocalisamfile pconti (LF_PCON);
|
|
|
|
if ( key == K_ENTER )
|
|
{
|
|
if (sottoconto != 0 && conto == 0)
|
|
return f.warning_box("Manca il CONTO");
|
|
|
|
if (conto != 0 && gruppo == 0)
|
|
return f.warning_box("Manca il GRUPPO");
|
|
}
|
|
|
|
if ( key == K_TAB )
|
|
{
|
|
if (id == F_SOTTOCINI_CONTO)
|
|
{
|
|
pconti.zero();
|
|
pconti.put(PCN_GRUPPO, gruppo) ;
|
|
pconti.put(PCN_CONTO, conto);
|
|
pconti.put(PCN_SOTTOCONTO, sottoconto);
|
|
pconti.setkey(1);
|
|
pconti.read(_isequal, _nolock);
|
|
if (pconti.good())
|
|
ds = pconti.get(PCN_DESCR);
|
|
else
|
|
ds = "";
|
|
|
|
f.mask().set(F_DESCRINI_CONTO, ds);
|
|
f.mask().set(F_DESCRINI_CLIENTE, ds);
|
|
f.mask().set(F_DESCRINI_FORN, ds);
|
|
}
|
|
if (id == F_SOTTOCINI_CLIENTE || id == F_SOTTOCINI_FORN)
|
|
{
|
|
char tipo = id == F_SOTTOCINI_CLIENTE ? 'C' : 'F';
|
|
TLocalisamfile clifo (LF_CLIFO);
|
|
if (sottoconto != 0)
|
|
{
|
|
clifo.zero();
|
|
clifo.put(CLI_TIPOCF,tipo);
|
|
clifo.put(CLI_CODCF, sottoconto) ;
|
|
clifo.setkey(1);
|
|
if (clifo.read(_isequal, _nolock) == NOERR)
|
|
{
|
|
rs = clifo.get(CLI_RAGSOC);
|
|
char tipoa = clifo.get_char("TIPOAPER");
|
|
|
|
if (tipoa == 'F')
|
|
{
|
|
TString80 cognome, nome;
|
|
cognome = rs.mid(0,30);
|
|
nome = rs.mid(30,20);
|
|
cognome.trim(); nome.trim();
|
|
|
|
rs = cognome;
|
|
rs << " " << nome;
|
|
}
|
|
}
|
|
else
|
|
rs = "";
|
|
|
|
f.mask().set(F_DESCRINI_CLIENTE, rs);
|
|
f.mask().set(F_DESCRINI_FORN, rs);
|
|
}
|
|
else
|
|
if (gruppo != 0 && conto != 0)
|
|
{
|
|
pconti.zero();
|
|
pconti.put(PCN_GRUPPO, gruppo) ;
|
|
pconti.put(PCN_CONTO, conto);
|
|
pconti.setkey(1);
|
|
pconti.read(_isequal, _nolock);
|
|
if (pconti.good())
|
|
ds = pconti.get(PCN_DESCR);
|
|
else
|
|
ds = "";
|
|
|
|
f.mask().set(F_DESCRINI_CLIENTE, ds);
|
|
f.mask().set(F_DESCRINI_FORN, ds);
|
|
f.mask().set(F_DESCRINI_CONTO, ds);
|
|
}
|
|
}
|
|
}
|
|
return TRUE;
|
|
}
|
|
|
|
bool sottoc_handler_fine(TMask_field& f, KEY key)
|
|
{
|
|
const short id = f.dlg();
|
|
const int gruppo = f.mask().get_int(F_GRUPPOFINE);
|
|
const int conto = f.mask().get_int(F_CONTOFINE_CONTO);
|
|
const long sottoconto = f.mask().get_long(id);
|
|
TString ds;
|
|
TString80 rs;
|
|
TLocalisamfile pconti (LF_PCON);
|
|
|
|
if ( key == K_ENTER )
|
|
{
|
|
if (sottoconto != 0 && conto == 0)
|
|
return f.warning_box("Manca il CONTO");
|
|
|
|
if (conto != 0 && gruppo == 0)
|
|
return f.warning_box("Manca il GRUPPO");
|
|
}
|
|
|
|
if ( key == K_TAB )
|
|
{
|
|
// if (!f.focusdirty() && gruppo == 0 && conto == 0) return TRUE;
|
|
/*
|
|
if (sottoconto != 0 && conto == 0)
|
|
{
|
|
f.warning_box("Manca il CONTO");
|
|
return FALSE;
|
|
}
|
|
if (conto != 0 && gruppo == 0)
|
|
{
|
|
f.warning_box("Manca il GRUPPO");
|
|
return FALSE;
|
|
}
|
|
*/
|
|
if (id == F_SOTTOCFINE_CONTO)
|
|
{
|
|
pconti.zero();
|
|
pconti.put(PCN_GRUPPO, gruppo) ;
|
|
pconti.put(PCN_CONTO, conto);
|
|
pconti.put(PCN_SOTTOCONTO, sottoconto);
|
|
pconti.setkey(1);
|
|
pconti.read(_isequal, _nolock);
|
|
if (pconti.good())
|
|
ds = pconti.get(PCN_DESCR);
|
|
else
|
|
ds = "";
|
|
|
|
f.mask().set(F_DESCRFINE_CONTO, ds);
|
|
f.mask().set(F_DESCRFINE_CLIENTE, ds);
|
|
f.mask().set(F_DESCRFINE_FORN, ds);
|
|
}
|
|
if (id == F_SOTTOCFINE_CLIENTE || id == F_SOTTOCFINE_FORN)
|
|
{
|
|
char tipo = id == F_SOTTOCFINE_CLIENTE ? 'C' : 'F';
|
|
TLocalisamfile clifo (LF_CLIFO);
|
|
if (sottoconto != 0)
|
|
{
|
|
clifo.zero();
|
|
clifo.put(CLI_TIPOCF,tipo);
|
|
clifo.put(CLI_CODCF, sottoconto) ;
|
|
clifo.setkey(1);
|
|
if (clifo.read(_isequal, _nolock) == NOERR)
|
|
{
|
|
rs = clifo.get(CLI_RAGSOC);
|
|
char tipoa = clifo.get_char("TIPOAPER");
|
|
|
|
if (tipoa == 'F')
|
|
{
|
|
TString80 cognome, nome;
|
|
cognome = rs.mid(0,30);
|
|
nome = rs.mid(30,20);
|
|
cognome.trim(); nome.trim();
|
|
|
|
rs = cognome;
|
|
rs << " " << nome;
|
|
}
|
|
}
|
|
else
|
|
rs = "";
|
|
|
|
f.mask().set(F_DESCRFINE_CLIENTE, rs);
|
|
f.mask().set(F_DESCRFINE_FORN, rs);
|
|
}
|
|
else
|
|
if (gruppo != 0 && conto != 0)
|
|
{
|
|
pconti.zero();
|
|
pconti.put(PCN_GRUPPO, gruppo) ;
|
|
pconti.put(PCN_CONTO, conto);
|
|
pconti.setkey(1);
|
|
pconti.read(_isequal, _nolock);
|
|
if (pconti.good())
|
|
ds = pconti.get(PCN_DESCR);
|
|
else
|
|
ds = "";
|
|
|
|
f.mask().set(F_DESCRFINE_CLIENTE, ds);
|
|
f.mask().set(F_DESCRFINE_FORN, ds);
|
|
f.mask().set(F_DESCRFINE_CONTO, ds);
|
|
}
|
|
}
|
|
}
|
|
return TRUE;
|
|
}
|
|
|
|
int date2esc(const TDate& d, int* prevesc)
|
|
{
|
|
if (prevesc) *prevesc = 0;
|
|
TTable esc("ESC");
|
|
for (int err = esc.first(); err == NOERR; err = esc.next())
|
|
{
|
|
const TDate ia(esc.get("D0")); // Data inizio esercizio
|
|
const TDate fa(esc.get("D1")); // Data fine esercizio
|
|
app()._inizioEs = ia;
|
|
app()._fineEs = fa;
|
|
const anno = esc.get_int("CODTAB");
|
|
if (d >= ia && d <= fa)
|
|
return anno;
|
|
if (prevesc) *prevesc = anno;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
//Questa funzione restituisce vero se il record su piano dei conti ha almeno un
|
|
//record figlio (e che soddisfa la condizione riguardante la data di registr.).
|
|
//Viene successivamente utilizzata per stampare l'intestazione (e i totali)
|
|
//oppure no
|
|
|
|
bool CG3200_application::almeno_un_record()
|
|
{
|
|
bool trovato=FALSE;
|
|
long record,sottoc;
|
|
int gruppo,conto;
|
|
TDate datareg, datacomp;
|
|
TLocalisamfile& rmov = current_cursor()->file(LF_RMOV);
|
|
|
|
if (current_cursor()->is_first_match(LF_RMOV))
|
|
{
|
|
record = rmov.recno();
|
|
rmov.zero();
|
|
rmov.put(RMV_GRUPPO, _gruppo);
|
|
rmov.put(RMV_CONTO, _conto);
|
|
rmov.put(RMV_SOTTOCONTO, _sottoc);
|
|
for (rmov.read(); !rmov.eof() ;rmov.next())
|
|
{
|
|
int annoes = rmov.get_int (RMV_ANNOES);
|
|
long numreg = rmov.get_long(RMV_NUMREG);
|
|
|
|
_mov->setkey(1);
|
|
_mov->curr().zero();
|
|
_mov->curr().put(MOV_NUMREG,numreg);
|
|
_mov->read();
|
|
if (_mov->bad())
|
|
_mov->zero();
|
|
datacomp = (_mov->curr().get(MOV_DATACOMP));
|
|
|
|
if (_annomsk == 0)
|
|
datareg = rmov.get_date(RMV_DATAREG);
|
|
else
|
|
if (_annomsk != 0)
|
|
datareg = datacomp;
|
|
|
|
gruppo = rmov.get_int(RMV_GRUPPO);
|
|
conto = rmov.get_int(RMV_CONTO);
|
|
sottoc = rmov.get_long(RMV_SOTTOCONTO);
|
|
if ((gruppo != _gruppo)||(conto != _conto)||(sottoc != _sottoc))
|
|
break;
|
|
else
|
|
if (((annoes==_annomsk)||(_annomsk==0))&&((datareg>=_data_ini)&&(datareg<=_data_fine)))
|
|
{
|
|
trovato = TRUE;
|
|
break;
|
|
}
|
|
}
|
|
rmov.readat(record);
|
|
}
|
|
return trovato;
|
|
}
|
|
|
|
bool CG3200_application::data_inizio(TMask_field& f, KEY k)
|
|
{
|
|
int anno;
|
|
TDate data;
|
|
|
|
anno = f.mask().get_int(F_ANNO);
|
|
data = f.mask().get (F_DATAINI);
|
|
app()._annomsk = anno;
|
|
|
|
if (k == K_ENTER)
|
|
{
|
|
if (anno != 0)
|
|
{
|
|
app().data_fine_esercizio(anno);
|
|
|
|
if (data == botime)
|
|
app()._data_ini = app()._data_inizioese;
|
|
else
|
|
if (data < app()._data_inizioese || data > app()._data_finese)
|
|
{
|
|
f.error_box("La data non appartiene all'esercizio indicato");
|
|
return FALSE;
|
|
}
|
|
else
|
|
app()._data_ini = data;
|
|
}
|
|
else
|
|
if (anno == 0)
|
|
{
|
|
if (data == botime)
|
|
{
|
|
f.error_box("La data deve essere obbligatoriamente indicata");
|
|
return FALSE;
|
|
}
|
|
else
|
|
app()._data_ini = data;
|
|
}
|
|
}
|
|
return TRUE;
|
|
}
|
|
|
|
bool CG3200_application::data_fine(TMask_field& f, KEY k)
|
|
{
|
|
int annoes;
|
|
TDate data, data_ini;
|
|
|
|
annoes = f.mask().get_int(F_ANNO);
|
|
data = f.mask().get (F_DATAFINE);
|
|
data_ini = f.mask().get (F_DATAINI);
|
|
app()._annomsk = annoes;
|
|
|
|
if (k == K_ENTER)
|
|
{
|
|
if (annoes != 0)
|
|
{
|
|
app().data_fine_esercizio(annoes);
|
|
|
|
if (data == botime)
|
|
app()._data_fine = app()._data_finese;
|
|
else
|
|
if (data < app()._data_inizioese || data > app()._data_finese)
|
|
{
|
|
f.error_box("La data non appartiene all'esercizio indicato");
|
|
return FALSE;
|
|
}
|
|
else
|
|
app()._data_fine = data;
|
|
}
|
|
else
|
|
if (annoes == 0)
|
|
{
|
|
if (data == botime)
|
|
{
|
|
f.error_box("La data deve essere obbligatoriamente indicata");
|
|
return FALSE;
|
|
}
|
|
|
|
app()._anno_ghost = date2esc(data_ini);
|
|
|
|
app()._inizioes = app()._inizioEs;
|
|
|
|
if (data < app()._inizioEs || data > app()._fineEs)
|
|
{
|
|
f.error_box("La data non appartiene all'esercizio indicato");
|
|
return FALSE;
|
|
}
|
|
else
|
|
app()._data_fine = data;
|
|
}
|
|
|
|
if (data < data_ini)
|
|
{
|
|
f.error_box("La data finale non puo' essere inferiore alla data di partenza");
|
|
return FALSE;
|
|
}
|
|
|
|
|
|
}
|
|
return TRUE;
|
|
}
|
|
|
|
void CG3200_application::saldi_zero()
|
|
{
|
|
TLocalisamfile& rmov = current_cursor()->file(LF_RMOV);
|
|
real saldo_dare, saldo_avere;
|
|
long record;
|
|
|
|
saldo_dare = saldo_avere = 0;
|
|
|
|
if (current_cursor()->is_first_match(LF_RMOV))
|
|
{
|
|
record = rmov.recno();
|
|
|
|
while (!rmov.eof())
|
|
{
|
|
rmov.read();
|
|
char sezione = rmov.curr().get(RMV_SEZIONE)[0];
|
|
real importo = rmov.curr().get_real(RMV_IMPORTO);
|
|
int gruppo = atoi(rmov.get(RMV_GRUPPO));
|
|
int conto = atoi(rmov.get(RMV_CONTO));
|
|
long sottoc = atol(rmov.get(RMV_SOTTOCONTO));
|
|
|
|
if ((gruppo == _gruppo)&&(conto == _conto)&&(sottoc == _sottoc))
|
|
{
|
|
if (sezione == 'D')
|
|
saldo_dare += importo;
|
|
else if (sezione == 'A')
|
|
saldo_avere += importo;
|
|
}
|
|
else break;
|
|
rmov.next();
|
|
}
|
|
rmov.readat(record);
|
|
}
|
|
_totale_saldo = saldo_dare - saldo_avere;
|
|
}
|
|
|
|
void CG3200_application::fai_stampa132()
|
|
{
|
|
set_row (1,"@0g#t", &_dataregs);
|
|
if (_stampanum == 1)
|
|
set_row (1,"@11g$[r]#7d$[n]", &_numreg);
|
|
else
|
|
if (_stampanum == 2)
|
|
{
|
|
set_row (1,"@11g#7d", &_numgio);
|
|
}
|
|
set_row (1,"@19g#t", &_datadocs);
|
|
set_row (1,"@30g#7t", &_numdoc);
|
|
set_row (1,"@38g#3t", &_codcaus);
|
|
|
|
set_row (1,"@117g#3t", &_g_contr);
|
|
set_row (1,"@120g#3t", &_c_contr);
|
|
set_row (1,"@123g#6t", &_s_contr);
|
|
}
|
|
|
|
void CG3200_application::fai_stampa198()
|
|
{
|
|
set_row (1,"@0g#t", &_dataregs);
|
|
if (_stampanum == 1)
|
|
set_row (1,"@11g$[r]#7d$[n]", &_numreg);
|
|
else if (_stampanum == 2)
|
|
set_row (1,"@11g#7d", &_numgio);
|
|
set_row (1,"@19g#t", &_datadocs);
|
|
set_row (1,"@30g#7t", &_numdoc);
|
|
set_row (1,"@38g#3t", &_codcaus);
|
|
|
|
// Stampa saldo movimenti
|
|
|
|
set_row (1,"@153g#t", &_saldo_movimenti_str);
|
|
|
|
set_row (1,"@169g#3t", &_g_contr);
|
|
set_row (1,"@172g#3t", &_c_contr);
|
|
set_row (1,"@175g#6t", &_s_contr);
|
|
}
|
|
|
|
void CG3200_application::stampa_totali132()
|
|
{
|
|
TString sep(132);
|
|
|
|
sep.fill('-'); //Stampa 132 - (sep(132))
|
|
set_row(2,"@0g%s", (const char *) sep);
|
|
|
|
_totprogre_dare=_progredare+_totale_periodo_dare;
|
|
_totprogre_avere=_progreavere+_totale_periodo_avere;
|
|
_saldo_periodo = _totale_periodo_dare - _totale_periodo_avere;
|
|
_saldo_progre = _totprogre_dare - _totprogre_avere;
|
|
_saldo_progre_al = _totprogre_dare_al - _totprogre_avere_al;
|
|
set_row (3,"@32gTOTALI PERIODO@69g%15.0r", &_saldo_periodo);
|
|
set_row (3,"@85g%15.0r", &_totale_periodo_dare);
|
|
set_row (3,"@101g%15.0r", &_totale_periodo_avere);
|
|
set_row (4,"@32gTOTALI PROGRESSIVI@69g%15.0r", &_saldo_progre);
|
|
set_row (4,"@85g%15.0r", &_totprogre_dare);
|
|
set_row (4,"@101g%15.0r", &_totprogre_avere);
|
|
if (_stampaprogre) //Progressivi attuali
|
|
{
|
|
set_row (5,"@32gTOTALI PROGRESSIVI AL@55g%s",(const char*)_ultima_data_reg.string());
|
|
set_row (5,"@69g%15.0r", &_saldo_progre_al);
|
|
set_row (5,"@85g%15.0r", &_totprogre_dare_al);
|
|
set_row (5,"@101g%15.0r", &_totprogre_avere_al);
|
|
}
|
|
}
|
|
|
|
void CG3200_application::stampa_totali198()
|
|
{
|
|
TString sep(198);
|
|
|
|
sep.fill('-'); //Stampa 132 - (sep(132))
|
|
set_row(2,"@0g%s", (const char *) sep);
|
|
|
|
_totprogre_dare=_progredare+_totale_periodo_dare;
|
|
_totprogre_avere=_progreavere+_totale_periodo_avere;
|
|
set_row (3,"@32gTOTALI PERIODO@102g%15.0r", &_totale_periodo_dare);
|
|
set_row (3,"@119g%15.0r", &_totale_periodo_avere);
|
|
set_row (3,"@153g%15.0r", &_saldo_movimenti);
|
|
set_row (4,"@32gTOTALI PROGRESSIVI@102g%15.0r", &_totprogre_dare);
|
|
set_row (4,"@119g%15.0r", &_totprogre_avere);
|
|
set_row (4,"@136g%15.0r", &_saldo_progressivi);
|
|
if (_stampaprogre) //Progressivi attuali
|
|
{
|
|
set_row(5,"@32gTOTALI PROGRESSIVI AL@55g%s",(const char*)_ultima_data_reg.string());
|
|
set_row (5,"@102g%15.0r", &_totprogre_dare_al);
|
|
set_row (5,"@119g%15.0r", &_totprogre_avere_al);
|
|
set_row (5,"@136g%15.0r", &_saldo_progressivi);
|
|
}
|
|
}
|
|
|
|
bool CG3200_application::preprocess_page(int file, int counter)
|
|
{
|
|
TLocalisamfile & rmov = current_cursor()->file(LF_RMOV);
|
|
long rec;
|
|
TDate datasucc;
|
|
TString datasuccstring,dataregrmovstring;
|
|
int gruppof,contof;
|
|
long sottocf;
|
|
long record;
|
|
TString provvis = "";
|
|
int annoes;
|
|
|
|
if (counter)
|
|
return TRUE;
|
|
|
|
switch (file)
|
|
{
|
|
case LF_SALDI:
|
|
|
|
// Usati in crea_intestazione()
|
|
|
|
_gruppo = atoi(current_cursor()->curr(LF_SALDI).get(SLD_GRUPPO));
|
|
_conto = atoi(current_cursor()->curr(LF_SALDI).get(SLD_CONTO));
|
|
_sottoc = atol(current_cursor()->curr(LF_SALDI).get(SLD_SOTTOCONTO));
|
|
annoes = atoi(current_cursor()->curr(LF_SALDI).get(SLD_ANNOES));
|
|
conto(_gruppo,_conto,TRUE);
|
|
|
|
if (annoes != _anno_corrente && annoes != _anno_precedente)
|
|
return FALSE;
|
|
|
|
if (_g_prec == _gruppo && _c_prec == _conto && _s_prec == _sottoc)
|
|
return FALSE;
|
|
|
|
_g_prec = _gruppo;
|
|
_c_prec = _conto;
|
|
_s_prec = _sottoc;
|
|
|
|
_saldo_periodo = ZERO;
|
|
_totale_periodo_dare = ZERO;
|
|
_totale_periodo_avere = ZERO;
|
|
_saldo_progre = ZERO;
|
|
_totprogre_dare = ZERO;
|
|
_totprogre_avere = ZERO;
|
|
_saldo_progre_al = ZERO;
|
|
_totprogre_dare_al = ZERO;
|
|
_totprogre_avere_al = ZERO;
|
|
_progredare = ZERO;
|
|
_progreavere = ZERO;
|
|
_totale_prima_dare = ZERO;
|
|
_totale_prima_avere = ZERO;
|
|
_saldo_movimenti = ZERO;
|
|
_saldo_progressivi = ZERO;
|
|
_saldo_progre_prec = ZERO;
|
|
if (_tipostampa == 2)
|
|
saldi_zero();
|
|
else
|
|
_totale_saldo = 1;
|
|
|
|
if ((_tipostampa == 1) || (_tipostampa == 2))
|
|
{
|
|
if ((almeno_un_record()) && (_totale_saldo != 0))
|
|
{
|
|
_puoi_stampare = TRUE;
|
|
calcola_progressivi();
|
|
_saldo_progressivi += _saldo_progre_prec;
|
|
stampa_progre_riporto();
|
|
}
|
|
else
|
|
{
|
|
_puoi_stampare = FALSE;
|
|
return FALSE;
|
|
}
|
|
}
|
|
else
|
|
if (_tipostampa == 3)
|
|
{
|
|
calcola_progressivi();
|
|
if (_progredare == ZERO && _progreavere == ZERO && !almeno_un_record())
|
|
{
|
|
_puoi_stampare = FALSE;
|
|
return FALSE;
|
|
}
|
|
else
|
|
{
|
|
_puoi_stampare = TRUE;
|
|
_saldo_progressivi += _saldo_progre_prec;
|
|
stampa_progre_riporto();
|
|
}
|
|
}
|
|
break;
|
|
|
|
case LF_RMOV:
|
|
{
|
|
// Ricerca la contropartita di quel movimento
|
|
TLocalisamfile& rmov = current_cursor()->file(LF_RMOV);
|
|
|
|
_numreg = atol (current_cursor()->curr(LF_RMOV).get(RMV_NUMREG));
|
|
|
|
int rcontr = atoi(current_cursor()->curr(LF_RMOV).get(RMV_RCONTR));
|
|
record = rmov.recno();
|
|
rmov.setkey(1);
|
|
rmov.curr().zero();
|
|
rmov.curr().put(RMV_NUMREG,_numreg);
|
|
rmov.curr().put(RMV_NUMRIG,rcontr);
|
|
rmov.read();
|
|
if (rmov.bad())
|
|
rmov.curr().zero();
|
|
_gruppocontr = rmov.curr().get_int (RMV_GRUPPO);
|
|
_contocontr = rmov.curr().get_int (RMV_CONTO);
|
|
_sottocontocontr = rmov.curr().get_long(RMV_SOTTOCONTO);
|
|
_g_contr = rmov.get(RMV_GRUPPO);
|
|
_c_contr = rmov.get(RMV_CONTO);
|
|
_s_contr = rmov.get(RMV_SOTTOCONTO);
|
|
rmov.setkey(2);
|
|
rmov.readat(record);
|
|
|
|
// Stampa solo quelli che hanno anno esercizio uguale a quello specificato
|
|
// nella maschera. Se non viene specificato li stampa tutti
|
|
|
|
_importo = current_cursor()->curr(LF_RMOV).get_real(RMV_IMPORTO);
|
|
_importo_str = _importo.string("###############");
|
|
_mov->setkey(1);
|
|
_mov->curr().zero();
|
|
_mov->curr().put(MOV_NUMREG,_numreg);
|
|
_mov->read();
|
|
if (_mov->bad())
|
|
_mov->zero();
|
|
_annoes = _mov->get_int(MOV_ANNOES);
|
|
_regiva = _mov->curr().get(MOV_REG);
|
|
_annoiva = _mov->curr().get_int(MOV_ANNOIVA);
|
|
|
|
// Controlla se saldo e' diverso da 0
|
|
|
|
if (((_annoes == _annomsk) || (_annomsk == 0)) && (_totale_saldo != 0))
|
|
{
|
|
_sezione = current_cursor()->curr(LF_RMOV).get(RMV_SEZIONE);
|
|
|
|
if (_annomsk == 0)
|
|
{
|
|
_datareg = (_mov->curr().get(MOV_DATAREG));
|
|
_datareg_stampa = _datareg;
|
|
}
|
|
else
|
|
if (_annomsk != 0)
|
|
{
|
|
_datareg = _mov->curr().get(MOV_DATACOMP);
|
|
_datareg_stampa = _mov->curr().get(MOV_DATAREG);
|
|
}
|
|
|
|
provvis = _mov->curr().get(MOV_PROVVIS);
|
|
|
|
_dataregs = _datareg_stampa.string();
|
|
|
|
if ((_stampa_mov_prov)||((!_stampa_mov_prov)&&(provvis.trim().empty())))
|
|
{
|
|
if ((_datareg >= _data_ini) && (_datareg <= _data_fine))
|
|
{
|
|
// Determino l' anno di competenza dell' operazione in esame
|
|
|
|
int anno = date2esc(_datareg_stampa);
|
|
if (anno != _annoes)
|
|
if (_numcarat == 1)
|
|
set_row (1, "@131g*");
|
|
else
|
|
if (_numcarat == 2)
|
|
set_row (1, "@197g*");
|
|
|
|
_codcaus = _mov->curr().get(MOV_CODCAUS);
|
|
_tipodoc = _mov->curr().get(MOV_TIPODOC);
|
|
if (_stampatotiva && (_tmcf == 'C' || _tmcf == 'F'))
|
|
{
|
|
if (_tipodoc != "")
|
|
{
|
|
documenti_iva();
|
|
_b.add_riga(_descrdociva,_importo, _natdoc);
|
|
}
|
|
}
|
|
_datadoc = (_mov->curr().get(MOV_DATADOC));
|
|
_datadocs = _datadoc.string();
|
|
_numdoc = _mov->curr().get(MOV_NUMDOC);
|
|
descrizione_causale();
|
|
_descrizionemov = _mov->curr().get(MOV_DESCR);
|
|
_numgio = atol(_mov->curr().get(MOV_NUMGIO));
|
|
|
|
_descrizione = current_cursor()->curr(LF_RMOV).get(RMV_DESCR);
|
|
|
|
if (_numcarat == 1) // Stampa 132 caratteri
|
|
{
|
|
if (_descrizione != "")
|
|
{
|
|
if (_descrizionemov != "")
|
|
{
|
|
set_row (1,"@42g%.18s", (const char*) _descrizionemov);
|
|
set_row (1,"@61g%.23s", (const char*) _descrizione);
|
|
}
|
|
else if (_descrizionemov == "")
|
|
{
|
|
set_row (1,"@42g%.18s", (const char*) _descrcaus);
|
|
set_row (1,"@61g%.23s", (const char*) _descrizione);
|
|
}
|
|
}
|
|
else if (_descrizione == "")
|
|
if (_descrizionemov != "")
|
|
{
|
|
set_row (1,"@42g%.18s", (const char*) _descrcaus);
|
|
set_row (1,"@61g%.23s", (const char*) _descrizionemov);
|
|
}
|
|
else
|
|
if (_descrizionemov == "")
|
|
{
|
|
conto(_gruppocontr,_contocontr,FALSE);
|
|
TConto tc (_gruppocontr,_contocontr,_sottocontocontr,_tipo_contr);
|
|
TString descr_contr = tc.descrizione();
|
|
set_row (1,"@42g%.18s", (const char*) _descrcaus);
|
|
set_row (1,"@61g%.23s", (const char*) descr_contr);
|
|
}
|
|
}
|
|
else
|
|
if (_numcarat == 2) // Stampa 198 caratteri
|
|
{
|
|
if (_descrizione != "")
|
|
{
|
|
if (_descrizionemov != "")
|
|
{
|
|
set_row (1,"@42g%.25s", (const char*) _descrizionemov);
|
|
set_row (1,"@68g%.32s", (const char*) _descrizione);
|
|
}
|
|
else if (_descrizionemov == "")
|
|
{
|
|
set_row (1,"@42g%.25s", (const char*) _descrcaus);
|
|
set_row (1,"@68g%.32s", (const char*) _descrizione);
|
|
}
|
|
}
|
|
else if (_descrizione == "")
|
|
if (_descrizionemov != "")
|
|
{
|
|
set_row (1,"@42g%.25s", (const char*) _descrcaus);
|
|
set_row (1,"@68g%.32s", (const char*) _descrizionemov);
|
|
}
|
|
else
|
|
if (_descrizionemov == "")
|
|
{
|
|
conto(_gruppocontr,_contocontr,FALSE);
|
|
TConto tc (_gruppocontr,_contocontr,_sottocontocontr,_tipo_contr);
|
|
TString descr_contr = tc.descrizione();
|
|
set_row (1,"@42g%.25s", (const char*) _descrcaus);
|
|
set_row (1,"@68g%.32s", (const char*) descr_contr);
|
|
}
|
|
}
|
|
|
|
if (_sezione == "D")
|
|
{
|
|
_totale_periodo_dare += _importo;
|
|
_riporto_parziale_dare += _importo;
|
|
|
|
if (_numcarat == 1) // Stampa 132 caratteri
|
|
set_row (1,"@85g%s", (const char*) _importo_str);
|
|
else
|
|
if (_numcarat == 2) // Stampa 198 caratteri
|
|
{
|
|
_saldo_progressivi += _importo;
|
|
_saldo_movimenti += _importo;
|
|
set_row (1,"@102g%s", (const char*) _importo_str);
|
|
}
|
|
}
|
|
else if (_sezione == "A")
|
|
{
|
|
_totale_periodo_avere += _importo;
|
|
_riporto_parziale_avere += _importo;
|
|
|
|
if (_numcarat == 1) // Stampa 132 caratteri
|
|
set_row (1,"@101g%s", (const char*) _importo_str);
|
|
else
|
|
if (_numcarat == 2) // Stampa 198 caratteri
|
|
{
|
|
_saldo_progressivi -= _importo;
|
|
_saldo_movimenti -= _importo;
|
|
set_row (1,"@119g%s", (const char*) _importo_str);
|
|
}
|
|
}
|
|
|
|
_saldo_progressivi_str=_saldo_progressivi.string("###############");
|
|
_saldo_movimenti_str=_saldo_movimenti.string("###############");
|
|
if (_numcarat == 2)
|
|
{
|
|
ricerca_regiva();
|
|
_protiva = atol(_mov->curr().get(MOV_PROTIVA));
|
|
if (_protiva != 0)
|
|
set_row (1,"@191g%5d", _protiva);
|
|
|
|
if (_tipo < 3)
|
|
set_row (1,"@182g#t" , &_regiva);
|
|
_dataregrmov = current_cursor()->curr(LF_RMOV).get_date(RMV_DATAREG);
|
|
dataregrmovstring=_dataregrmov.string();
|
|
|
|
//Gestire la stampa di saldo_progressivi nella postprocess_page di RMOV
|
|
|
|
rec = rmov.recno();
|
|
rmov.next();
|
|
gruppof = rmov.get_int(RMV_GRUPPO);
|
|
contof = rmov.get_int(RMV_CONTO);
|
|
sottocf = rmov.get_int(RMV_SOTTOCONTO);
|
|
datasucc = rmov.get_date(RMV_DATAREG);
|
|
datasuccstring=datasucc.string();
|
|
if (((gruppof!=_gruppo)||(contof!=_conto)||(sottocf!=_sottoc))||(rmov.eof()))
|
|
datasucc = ("");
|
|
if (datasucc != _dataregrmov)
|
|
set_row (1,"@136g#t", &_saldo_progressivi_str);
|
|
rmov.readat(rec);
|
|
}
|
|
|
|
return TRUE;
|
|
}
|
|
else
|
|
return FALSE;
|
|
}
|
|
}
|
|
else
|
|
return FALSE;
|
|
break;
|
|
}
|
|
default:
|
|
break;
|
|
}
|
|
return TRUE;
|
|
}
|
|
|
|
void CG3200_application::set_page(int file, int counter)
|
|
{
|
|
switch (file)
|
|
{
|
|
case LF_SALDI:
|
|
reset_print();
|
|
break;
|
|
|
|
case LF_RMOV:
|
|
reset_print();
|
|
if (_numcarat == 1)
|
|
fai_stampa132();
|
|
else if (_numcarat == 2)
|
|
fai_stampa198();
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
|
|
print_action CG3200_application::postprocess_page(int file, int counter)
|
|
{
|
|
if (counter)
|
|
{
|
|
printer().formfeed();
|
|
reset_print(); // per evitare che stampi di nuovo il totale prec.
|
|
_stampa_progressivi_si = TRUE;
|
|
return NEXT_PAGE;
|
|
}
|
|
|
|
switch (file)
|
|
{
|
|
case LF_SALDI:
|
|
if (_tipostampa == 3)
|
|
{
|
|
reset_print();
|
|
if (_numcarat == 1)
|
|
stampa_totali132();
|
|
else if (_numcarat == 2)
|
|
stampa_totali198();
|
|
|
|
if (_stampatotiva)
|
|
stampa_totaliiva();
|
|
}
|
|
else if (_tipostampa == 2)
|
|
{
|
|
reset_print();
|
|
if ((_totale_saldo != 0) && (_puoi_stampare))
|
|
if (_numcarat == 1)
|
|
stampa_totali132();
|
|
else if (_numcarat == 2)
|
|
stampa_totali198();
|
|
if (_stampatotiva)
|
|
stampa_totaliiva();
|
|
}
|
|
else if (_tipostampa == 1)
|
|
{
|
|
reset_print();
|
|
if (_puoi_stampare)
|
|
if (_numcarat == 1)
|
|
stampa_totali132();
|
|
else if (_numcarat == 2)
|
|
stampa_totali198();
|
|
if (_stampatotiva)
|
|
stampa_totaliiva();
|
|
}
|
|
_stampa_progressivi_si = TRUE;
|
|
_prima_volta = TRUE;
|
|
return REPEAT_PAGE;
|
|
case LF_RMOV:
|
|
force_setpage();
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
return NEXT_PAGE;
|
|
}
|
|
|
|
// Stampa dei totali documenti iva se richiesta
|
|
|
|
void CG3200_application::stampa_totaliiva()
|
|
{
|
|
|
|
if (_stampatotiva)
|
|
for (int j = 0; j < _b.items(); j++)
|
|
{
|
|
TDociva& riga = (TDociva&)_b[j];
|
|
set_row(7+j, "@0g%-50s",(const char*) riga._descrdoc);
|
|
set_row(7+j, "@61g%15.0r", &riga._totdociva);
|
|
}
|
|
_b.destroy();
|
|
}
|
|
|
|
// Ricerca della descrizione relativa al codice causale di MOV.dta
|
|
// sull'archivio CAUS.dta
|
|
|
|
void CG3200_application::descrizione_causale()
|
|
{
|
|
_caus->setkey(1);
|
|
_caus->curr().zero();
|
|
_caus->curr().put(CAU_CODCAUS, _codcaus);
|
|
_caus->read();
|
|
if (_caus->bad())
|
|
_caus->zero();
|
|
_descrcaus = _caus->curr().get(CAU_DESCR);
|
|
}
|
|
|
|
// Ricerca sulla tabella dei tipi documento, la descrizione e la natura del
|
|
// documento, accedendovi tramite il tipo documento trovato su MOV.dta
|
|
|
|
void CG3200_application::documenti_iva()
|
|
{
|
|
TString dep;
|
|
|
|
_tabtpd->curr().zero();
|
|
dep << format ("%2s",(const char*) _tipodoc);
|
|
_tabtpd->curr().put("CODTAB", (const char*) dep);
|
|
_tabtpd->read();
|
|
_descrdociva = _tabtpd->curr().get("S0");
|
|
_natdoc = atoi(_tabtpd->curr().get("I0"));
|
|
}
|
|
|
|
void CG3200_application::ricerca_regiva()
|
|
{
|
|
TString16 dep;
|
|
|
|
_tabreg->curr().zero();
|
|
dep << format("%04d", _annoiva);
|
|
dep << format("%3s" , (const char*) _regiva);
|
|
_tabreg->curr().put("CODTAB", (const char*) dep);
|
|
_tabreg->read();
|
|
_tipo = _tabreg->get_int("I0");
|
|
}
|
|
|
|
bool CG3200_application::preprocess_print(int file, int counter)
|
|
{
|
|
if (file == LF_SALDI)
|
|
{
|
|
_g_prec = 0;
|
|
_c_prec = 0;
|
|
_s_prec = 0;
|
|
}
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
bool CG3200_application::set_print(int)
|
|
{
|
|
KEY tasto;
|
|
int crt;
|
|
TLocalisamfile* fl;
|
|
TString data1,data2;
|
|
|
|
_puoi_stampare = TRUE;
|
|
|
|
_msk->set_handler (F_DATAINI , data_inizio);
|
|
_msk->set_handler (F_DATAFINE , data_fine);
|
|
|
|
|
|
tasto = _msk->run();
|
|
|
|
if (tasto == K_ENTER)
|
|
{
|
|
_annomsk = atoi(_msk->get(F_ANNO));
|
|
|
|
_stampaprogre = (bool)(_msk->get(F_STAMPAPROGRE) == "X");
|
|
_stampatotiva = (bool)(_msk->get(F_STAMPATOTIVA) == "X");
|
|
_stampanum = atoi(_msk->get(F_STAMPANUM));
|
|
_stampa_mov_prov = (bool)(_msk->get(F_STAMPAMOVPROV) == "X");
|
|
int gruppoini = atoi(_msk->get(F_GRUPPOINI));
|
|
int contoini = atoi(_msk->get(F_CONTOINI_CONTO));
|
|
long sottocontoini = atol(_msk->get(F_SOTTOCINI_CONTO));
|
|
int gruppofine = atoi(_msk->get(F_GRUPPOFINE));
|
|
int contofine = atoi(_msk->get(F_CONTOFINE_CONTO));
|
|
long sottocontofine = atol(_msk->get(F_SOTTOCFINE_CONTO));
|
|
_tipostampa = atoi(_msk->get(F_TIPOSTAMPA));
|
|
_numcarat = atoi(_msk->get(F_NUMCARAT));
|
|
int formato = atoi(_msk->get(F_FORMATO));
|
|
int nummast = atoi(_msk->get(F_NUMMAST));
|
|
_codice_ditta = get_firm();
|
|
|
|
ricerca_dati_ditta();
|
|
|
|
if (_annomsk != 0)
|
|
_anno_corrente = _annomsk;
|
|
else
|
|
if (_annomsk == 0)
|
|
_anno_corrente = _anno_ghost;
|
|
|
|
_anno_precedente = _anno_corrente - 1;
|
|
|
|
_saldo_periodo = ZERO;
|
|
_totale_periodo_dare = ZERO;
|
|
_totale_periodo_avere = ZERO;
|
|
_saldo_progre = ZERO;
|
|
_totprogre_dare = ZERO;
|
|
_totprogre_avere = ZERO;
|
|
_saldo_progre_al = ZERO;
|
|
_totprogre_dare_al = ZERO;
|
|
_totprogre_avere_al = ZERO;
|
|
_progredare = ZERO;
|
|
_progreavere = ZERO;
|
|
_totale_prima_dare = ZERO;
|
|
_totale_prima_avere = ZERO;
|
|
_saldo_movimenti = ZERO;
|
|
_saldo_progressivi = ZERO;
|
|
_saldo_progre_prec = ZERO;
|
|
_protiva = 0;
|
|
|
|
// Scelta del formato e del numero di mastrini per pagina 1 o 2
|
|
|
|
if (nummast == 1)
|
|
crt = formato;
|
|
else
|
|
crt = (formato / 2);
|
|
|
|
printer().formlen(crt);
|
|
|
|
//Crea il cursore su gruppo, conto e sottoconto del file RMOV
|
|
|
|
reset_files(); //resetta l'albero di stampa
|
|
add_file(LF_SALDI);
|
|
add_file(LF_RMOV,LF_SALDI);
|
|
|
|
select_cursor(_cur1);
|
|
fl = &(current_cursor()->file(LF_SALDI));
|
|
TRectype da (fl->curr());
|
|
TRectype a (fl->curr());
|
|
|
|
da.zero();
|
|
a.zero();
|
|
|
|
da.put(SLD_GRUPPO,gruppoini);
|
|
da.put(SLD_CONTO,contoini);
|
|
da.put(SLD_SOTTOCONTO,sottocontoini);
|
|
|
|
a.put(SLD_GRUPPO,gruppofine);
|
|
a.put(SLD_CONTO,contofine);
|
|
a.put(SLD_SOTTOCONTO,sottocontofine);
|
|
|
|
current_cursor()->setregion(da, a);
|
|
|
|
if (_stampatotiva)
|
|
_b.destroy();
|
|
|
|
switch (_tipostampa)
|
|
{
|
|
case 1: _totale_saldo = 1;
|
|
break;
|
|
case 2: _totale_saldo = 0;
|
|
break;
|
|
case 3: _totale_saldo = 1;
|
|
break;
|
|
default: break;
|
|
}
|
|
_prima_volta = TRUE;
|
|
|
|
_stampa_progressivi_si = TRUE;
|
|
|
|
enable_print_menu();
|
|
|
|
enable_link("Collegamento prima nota: ", 'r');
|
|
|
|
return TRUE;
|
|
}
|
|
else
|
|
return FALSE;
|
|
}
|
|
|
|
void CG3200_application::data_fine_esercizio(int anno)
|
|
{
|
|
TString16 dep;
|
|
|
|
_tabesc->curr().zero();
|
|
dep << format ("%04d", anno);
|
|
_tabesc->curr().put("CODTAB", (const char*) dep);
|
|
_tabesc->read();
|
|
_data_finese = _tabesc->curr().get("D1");
|
|
_data_inizioese = _tabesc->curr().get("D0");
|
|
}
|
|
|
|
void CG3200_application::preprocess_header()
|
|
{
|
|
if (_tipostampa == 3)
|
|
crea_intestazione();
|
|
else
|
|
if (_tipostampa == 2)
|
|
{
|
|
if ((_totale_saldo != 0) && (_puoi_stampare))
|
|
crea_intestazione();
|
|
}
|
|
else if (_tipostampa == 1)
|
|
if (_puoi_stampare)
|
|
crea_intestazione();
|
|
}
|
|
|
|
void CG3200_application::conto(int gruppo, int conto, bool no_contropartita)
|
|
{
|
|
TLocalisamfile pconti(LF_PCON);
|
|
|
|
pconti.setkey(1);
|
|
pconti.zero();
|
|
pconti.put(PCN_GRUPPO, gruppo);
|
|
pconti.put(PCN_CONTO , conto);
|
|
pconti.read();
|
|
if (pconti.bad())
|
|
pconti.zero();
|
|
|
|
if (no_contropartita)
|
|
{
|
|
_indbil = pconti.get_int(PCN_INDBIL);
|
|
_tmcf = pconti.get_char(PCN_TMCF);
|
|
}
|
|
else
|
|
_tipo_contr = pconti.get_char(PCN_TMCF);
|
|
}
|
|
|
|
void CG3200_application::ricerca_dati_ditta()
|
|
{
|
|
long app;
|
|
|
|
_nditte->setkey(1);
|
|
_nditte->curr().zero();
|
|
_nditte->curr().put(NDT_CODDITTA,_codice_ditta);
|
|
_nditte->read();
|
|
app=_nditte->curr().get_long(NDT_CODDITTA);
|
|
_ragsoc=_nditte->curr().get(NDT_RAGSOC);
|
|
|
|
_unloc->setkey(1);
|
|
_unloc->curr().zero();
|
|
_unloc->curr().put(ULC_CODDITTA,app);
|
|
_unloc->curr().put(ULC_CODULC,"1");
|
|
_unloc->read();
|
|
_indulc=_unloc->curr().get(ULC_INDULC);
|
|
_civulc=_unloc->curr().get(ULC_CIVULC);
|
|
_capulc=_unloc->curr().get(ULC_CAPULC);
|
|
_comulc=_unloc->curr().get(ULC_COMULC);
|
|
|
|
_comuni->setkey(1);
|
|
_comuni->curr().zero();
|
|
_comuni->curr().put(COM_COM,_comulc);
|
|
_comuni->read();
|
|
_com=_comuni->curr().get(COM_DENCOM);
|
|
_prov=_comuni->curr().get(COM_PROVCOM);
|
|
}
|
|
|
|
// Crea l'intestazione per la stampa a 132 e a 198 caratteri
|
|
|
|
void CG3200_application::crea_intestazione()
|
|
{
|
|
TString sep(132),sep1(198);
|
|
|
|
reset_header();
|
|
|
|
if (_numcarat == 1)
|
|
{
|
|
sep << "Pag. @#";
|
|
sep.right_just(132);
|
|
set_header(1,(const char*) sep);
|
|
sep ="";
|
|
set_header(2,"@1g%s",(const char*) sep);
|
|
}
|
|
else if (_numcarat == 2)
|
|
{
|
|
sep1 << "Pagina @#";
|
|
sep1.right_just(198);
|
|
set_header(1,(const char*) sep1);
|
|
sep1 ="";
|
|
set_header(2,"@1g%s",(const char*) sep1);
|
|
}
|
|
|
|
set_header (1, "@0gDITTA@6g%5ld", _codice_ditta);
|
|
set_header (1, "@12g%-45s", (const char*) _ragsoc);
|
|
set_header (1, "@59g%-25s", (const char*) _indulc);
|
|
set_header (1, "@86g%-9s", (const char*) _civulc);
|
|
set_header (1, "@97g%-5s", (const char*) _capulc);
|
|
set_header (1, "@103g%-18s", (const char*) _com);
|
|
set_header (1, "@122g%-3s", (const char*) _prov);
|
|
|
|
set_header (3, "@0gSottoconto@12g%d", _gruppo);
|
|
set_header (3, "@16g%d", _conto);
|
|
set_header (3, "@20g%ld", _sottoc);
|
|
|
|
if (_tmcf == 'C')
|
|
_tipo_mask = 1;
|
|
else if (_tmcf == 'F')
|
|
_tipo_mask = 2;
|
|
else if (_tmcf == '\0')
|
|
_tipo_mask = 3;
|
|
switch (_tipo_mask)
|
|
{
|
|
case 1: ricerca_clifo();
|
|
break;
|
|
case 2: ricerca_clifo();
|
|
break;
|
|
case 3: ricerca_gruppo();
|
|
break;
|
|
default: break;
|
|
}
|
|
|
|
if (_numcarat == 1)
|
|
{
|
|
sep.fill('-'); //Stampa 132 - (sep(132))
|
|
set_header (6, (const char *) sep);
|
|
set_header (7,"Operazione@19gDocumento@117gContro@131gA");
|
|
set_header (8,"Data");
|
|
if (_stampanum < 3)
|
|
set_header (8,"@11gnumero");
|
|
set_header (8,"@19gData@30gNumero@38gCod.Causale@61gDescrizione@96gDare@111gAvere@117gPartita@131gC");
|
|
sep.fill('-');
|
|
set_header (9, (const char *) sep);
|
|
}
|
|
else if (_numcarat == 2)
|
|
{
|
|
sep1.fill('-'); //Stampa 198 - (sep1(198))
|
|
set_header (6,"@1g%s", (const char *) sep1);
|
|
set_header (7,"Operazione@19gData@30gNumero@172gContro@182gReg@190gNumero@197gA");
|
|
set_header (8,"Data");
|
|
if (_stampanum < 3)
|
|
set_header (8,"@11gnumero");
|
|
set_header (8,"@19gDocumento@38gCod.Causale@68gDescrizione@113gDare@129gAvere@136gSaldo progress.@156gSaldo movim.@172gPartita@182gIva@186gProtocollo@197gC");
|
|
sep1.fill('-');
|
|
set_header (9,"@1g%s", (const char *) sep1);
|
|
}
|
|
}
|
|
|
|
void CG3200_application::stampa_progre_riporto()
|
|
{
|
|
TString sep(132),sep1(198);
|
|
|
|
if (_stampa_progressivi_si)
|
|
{
|
|
stampa_progressivi();
|
|
_riporto_dare = _progredare;
|
|
_riporto_avere = _progreavere;
|
|
_stampa_progressivi_si = FALSE;
|
|
}
|
|
else
|
|
{
|
|
_riporto_dare += _riporto_parziale_dare;
|
|
_riporto_avere += _riporto_parziale_avere;
|
|
if (_numcarat == 1)
|
|
{
|
|
TString string = _riporto_dare.string("###############");
|
|
set_row (1,"@32gA RIPORTO@85g%15s",(const char*) string);
|
|
string = _riporto_avere.string("###############");
|
|
set_row (1,"@101g%15s",(const char*) string);
|
|
}
|
|
if (_numcarat == 2)
|
|
{
|
|
TString string = _riporto_dare.string("###############");
|
|
set_row (1,"@32gA RIPORTO@102g%15s",(const char*) string);
|
|
string = _riporto_avere.string("###############");
|
|
set_row (1,"@119g%15s",(const char*) string);
|
|
}
|
|
_riporto_parziale_dare = 0;
|
|
_riporto_parziale_avere = 0;
|
|
}
|
|
if (_numcarat == 1)
|
|
{
|
|
sep ="";
|
|
set_row(2,"@1g%s",(const char*) sep);
|
|
}
|
|
else if (_numcarat == 2)
|
|
{
|
|
sep1 ="";
|
|
set_row(2,"@1g%s",(const char*) sep1);
|
|
}
|
|
}
|
|
|
|
void CG3200_application::calcola_progressivi_al()
|
|
{
|
|
long record,sottoc,annoes;
|
|
int gruppo,conto;
|
|
TDate datareg, datacomp;
|
|
TLocalisamfile & rmov = current_cursor()->file(LF_RMOV);
|
|
char sezione;
|
|
real importo;
|
|
TDate data;
|
|
|
|
|
|
record = rmov.recno();
|
|
rmov.zero();
|
|
rmov.put(RMV_GRUPPO, _gruppo);
|
|
rmov.put(RMV_CONTO, _conto);
|
|
rmov.put(RMV_SOTTOCONTO, _sottoc);
|
|
for (rmov.read();!rmov.eof() ;rmov.next())
|
|
{
|
|
annoes = rmov.get_int (RMV_ANNOES);
|
|
datareg = rmov.get_date(RMV_DATAREG);
|
|
sezione = rmov.get (RMV_SEZIONE)[0];
|
|
importo = rmov.get_real(RMV_IMPORTO);
|
|
long numreg = rmov.get_long(RMV_NUMREG);
|
|
|
|
_mov->setkey(1);
|
|
_mov->curr().zero();
|
|
_mov->curr().put(MOV_NUMREG,numreg);
|
|
_mov->read();
|
|
if (_mov->bad())
|
|
_mov->zero();
|
|
datacomp = (_mov->curr().get(MOV_DATACOMP));
|
|
|
|
if (_annomsk == 0)
|
|
{
|
|
datareg = rmov.get_date(RMV_DATAREG);
|
|
data = _inizioes;
|
|
}
|
|
else
|
|
if (_annomsk != 0)
|
|
{
|
|
datareg = datacomp;
|
|
data = _data_inizioese;
|
|
}
|
|
|
|
gruppo = rmov.get_int(RMV_GRUPPO);
|
|
conto = rmov.get_int(RMV_CONTO);
|
|
sottoc = rmov.get_long(RMV_SOTTOCONTO);
|
|
if ((gruppo != _gruppo)||(conto != _conto)||(sottoc != _sottoc))
|
|
break;
|
|
else if (((annoes==_annomsk)||(_annomsk == 0))&&(datareg >= data)&&(datareg < _data_ini)) //Legge movimenti con data < data iniziale
|
|
if (sezione == 'D')
|
|
_totale_prima_dare += importo;
|
|
else if (sezione == 'A')
|
|
_totale_prima_avere += importo;
|
|
}
|
|
rmov.readat(record);
|
|
}
|
|
|
|
void CG3200_application::calcola_progressivi()
|
|
{
|
|
TLocalisamfile saldi(LF_SALDI, FALSE);
|
|
real pdaresca,paveresca,pdarescap,paverescap;
|
|
real progdare_attuale,progavere_attuale,progdare_prec,progavere_prec;
|
|
real saldo,progredare_eseprec,progreavere_eseprec,pdarep,paverep;
|
|
char salini;
|
|
|
|
saldo = ZERO;
|
|
pdarep = ZERO;
|
|
paverep = ZERO;
|
|
pdaresca = ZERO;
|
|
paveresca = ZERO;
|
|
pdarescap = ZERO;
|
|
paverescap = ZERO;
|
|
|
|
// Ricerca sull'archivio saldi dei record con gruppo,conto,sottoconto
|
|
// uguali a quelli di rmov per il calcolo dei progressivi precedenti
|
|
|
|
TRectype record(saldi.curr());
|
|
|
|
record.zero();
|
|
record.put(SLD_GRUPPO, _gruppo);
|
|
record.put(SLD_CONTO, _conto);
|
|
record.put(SLD_SOTTOCONTO, _sottoc);
|
|
|
|
saldi.setkey(2);
|
|
|
|
saldi.zero();
|
|
saldi.put(SLD_GRUPPO, _gruppo);
|
|
saldi.put(SLD_CONTO, _conto);
|
|
saldi.put(SLD_SOTTOCONTO, _sottoc);
|
|
|
|
for (saldi.read(_isgteq); saldi.good(); saldi.next())
|
|
{
|
|
if (saldi.curr() != record)
|
|
break;
|
|
|
|
int annoes_saldi = saldi.curr().get_int(SLD_ANNOES);
|
|
|
|
//Calcola i progressivi dell'esercizio attuale
|
|
|
|
if (annoes_saldi == _anno_corrente)
|
|
{
|
|
pdaresca = saldi.get_real(SLD_PDARESCA);
|
|
paveresca = saldi.get_real(SLD_PAVERESCA);
|
|
progdare_attuale = saldi.get_real(SLD_PDARE);
|
|
progavere_attuale = saldi.get_real(SLD_PAVERE);
|
|
saldo = saldi.get_real(SLD_SALDO);
|
|
salini = saldi.get(SLD_FLAGSALINI)[0];
|
|
_ultima_data_reg = saldi.get_date(SLD_DATAULMOV);
|
|
}
|
|
|
|
//Calcola i progressivi dell'esercizio precedente
|
|
|
|
if (annoes_saldi == _anno_precedente)
|
|
{
|
|
pdarescap = saldi.get_real(SLD_PDARESCA);
|
|
pdarep = saldi.get_real(SLD_PDARE);
|
|
paverescap = saldi.get_real(SLD_PAVERESCA);
|
|
paverep = saldi.get_real(SLD_PAVERE);
|
|
}
|
|
|
|
// Se il saldo dell'esercizio attuale e' diverso da 0 allora significa che
|
|
// quello corrisponde al saldo finale dell'esercizio precedente. Per ottenere
|
|
// i progressivi dell'esercizio precedente devo a questo punto sommare i
|
|
// progressivi dell'esercizio e i progressivi di quelli scaricati, tenendo
|
|
// conto del flag salini per sapere se il saldo e' dare oppure avere.
|
|
|
|
|
|
if (_annomsk != 0 && _anno_corrente == annoes_saldi)
|
|
{
|
|
if (saldo != ZERO)
|
|
{
|
|
if (salini == 'D')
|
|
{
|
|
progredare_eseprec = saldo;// + pdarescap + pdarep;
|
|
progdare_prec = saldo;
|
|
}
|
|
else if (salini == 'A')
|
|
{
|
|
progreavere_eseprec = saldo;// + paverescap + paverep;
|
|
progavere_prec = saldo;
|
|
}
|
|
}
|
|
}
|
|
} // FOR
|
|
|
|
//Se il saldo dell'esercizio attuale non e' diverso da zero, allora il saldo
|
|
// finale dell'esercizio precedente devo calcolarmelo tenendo conto dell'indbil
|
|
|
|
if (_annomsk != 0 && saldo == ZERO)
|
|
{
|
|
if ((_indbil == 1) || (_indbil == 2) || (_indbil == 5))
|
|
{
|
|
const TRecnotype pos = saldi.recno();
|
|
saldo = _sld.saldofin_esprec(_anno_corrente,_gruppo,_conto,_sottoc);
|
|
saldi.readat(pos);
|
|
|
|
if (saldo> ZERO)
|
|
{
|
|
progredare_eseprec = saldo;// + pdarescap + pdarep;
|
|
progdare_prec = saldo;
|
|
}
|
|
else if (saldo < ZERO)
|
|
{
|
|
saldo = -saldo;
|
|
progreavere_eseprec = saldo;// + paverescap + paverep;
|
|
progavere_prec = saldo;
|
|
}
|
|
}
|
|
}
|
|
|
|
calcola_progressivi_al();
|
|
|
|
//Calcolo dei progressivi precedenti: somma di tutti quei movimenti di rmov
|
|
//che hanno la data di registrazione inferiore alla data di inizio stampa,
|
|
//dei progressivi dell'anno esercizio precedente, e dei progressivi dei
|
|
//movimenti scaricati dell'esercizio attuale.
|
|
|
|
_progredare = pdaresca + progredare_eseprec + _totale_prima_dare;
|
|
_progreavere = paveresca + progreavere_eseprec + _totale_prima_avere;
|
|
_saldo_progre_prec = _progredare - _progreavere;
|
|
|
|
//Calcolo dei progressivi al <ultima data registrazione>
|
|
|
|
//Se sulla maschera e' stato selezionato il controllo competenza esercizio
|
|
//Sommo i progressivi dell'esercizio precedente e quelli dell'esercizio attuale
|
|
//altrimenti solo quelli dell'esercizio attuale
|
|
|
|
if (_annomsk != 0)
|
|
{
|
|
_totprogre_dare_al = progdare_attuale + progdare_prec;
|
|
_totprogre_avere_al = progavere_attuale + progavere_prec;
|
|
}
|
|
else
|
|
{
|
|
_totprogre_dare_al = progdare_attuale;
|
|
_totprogre_avere_al = progavere_attuale;
|
|
}
|
|
}
|
|
|
|
void CG3200_application::stampa_progressivi()
|
|
{
|
|
if (_numcarat == 1)
|
|
{
|
|
TString string = _saldo_progre_prec.string("###############");
|
|
set_row (1,"@32gPROGRESSIVI PRECEDENTI@69g%15s",(const char*) string);
|
|
string = _progredare.string("###############");
|
|
set_row (1,"@85g%15s",(const char*) string);
|
|
string = _progreavere.string("###############");
|
|
set_row (1,"@101g%15s",(const char*) string);
|
|
}
|
|
|
|
if (_numcarat == 2)
|
|
{
|
|
TString string = _progredare.string("###############");
|
|
set_row (1,"@32gPROGRESSIVI PRECEDENTI@102g%15s",(const char*)string);
|
|
string = _progreavere.string("###############");
|
|
set_row (1,"@119g%15s",(const char*) string);
|
|
string = _saldo_progre_prec.string("###############");
|
|
set_row (1,"@136g%15s",(const char*) string);
|
|
}
|
|
}
|
|
|
|
// Se la ricerca selezionata nella maschera e' per clienti, oppure fornitori, // allora ricerco su CLIFO i relativi dati, e su PCON il relativo gruppo,conto,// sottoconto e IV direttiva CEE
|
|
|
|
void CG3200_application::ricerca_clifo()
|
|
{
|
|
TString ragsoc,paiv,cofi,indcf,capcf,ptel,tel,statocf,comcf,dencom,provcom,dep;
|
|
TLocalisamfile clifo(LF_CLIFO);
|
|
TLocalisamfile pconti(LF_PCON);
|
|
TString16 dataini,datafine;
|
|
TString descriz,descriz2;
|
|
int numrivd;
|
|
|
|
clifo.setkey(1);
|
|
clifo.zero();
|
|
clifo.put(CLI_TIPOCF, _tmcf);
|
|
clifo.put(CLI_CODCF, _sottoc);
|
|
clifo.read();
|
|
if (clifo.bad())
|
|
clifo.zero();
|
|
TConto tc (_gruppo,_conto,_sottoc,_tmcf);
|
|
|
|
ragsoc = tc.descrizione();
|
|
paiv = clifo.get(CLI_PAIV);
|
|
cofi = clifo.get(CLI_COFI);
|
|
indcf = clifo.get(CLI_INDCF);
|
|
capcf = clifo.get(CLI_CAPCF);
|
|
ptel = clifo.get(CLI_PTEL);
|
|
tel = clifo.get(CLI_TEL);
|
|
statocf = clifo.get(CLI_STATOCF);
|
|
comcf = clifo.get(CLI_COMCF);
|
|
|
|
_comuni->setkey(1);
|
|
_comuni->curr().zero();
|
|
_comuni->curr().put(COM_STATO, statocf);
|
|
_comuni->curr().put(COM_COM, comcf);
|
|
_comuni->read();
|
|
dencom = _comuni->curr().get(COM_DENCOM);
|
|
provcom = _comuni->curr().get(COM_PROVCOM);
|
|
|
|
pconti.setkey(1);
|
|
pconti.zero();
|
|
pconti.put(PCN_GRUPPO, _gruppo);
|
|
pconti.put(PCN_CONTO, _conto);
|
|
pconti.read();
|
|
_sezivd = pconti.get_char(PCN_SEZIVD);
|
|
_lettivd = pconti.get_char(PCN_LETTIVD);
|
|
numrivd = pconti.get_int(PCN_NUMRIVD);
|
|
_numrivd = itor(numrivd);
|
|
_numivd = pconti.get_int(PCN_NUMIVD);
|
|
|
|
descriz = descrizione_classe(_sezivd,_lettivd,numrivd,_numivd);
|
|
|
|
if (_numivd != 0) //Ora devo stampare la descrizione del livello della
|
|
{ //classe immediatamente precedente a quello appena
|
|
if (_numrivd != "") //stampato
|
|
descriz2 = descrizione_classe(_sezivd,_lettivd,_numrivd_int,0);
|
|
else
|
|
descriz2 = descrizione_classe(_sezivd,_lettivd,0,0);
|
|
}
|
|
else
|
|
if (_numrivd != "")
|
|
descriz2 = descrizione_classe(_sezivd,_lettivd,0,0);
|
|
else
|
|
descriz2 = "";
|
|
|
|
set_header(3,"@27g%-30s",(const char*) descrizione_gruppo());
|
|
set_header(3,"@59g%-30s",(const char*) descrizione_conto());
|
|
set_header(3, "@91g%-30s",(const char*) ragsoc);
|
|
set_header(4, "Classe@8g%c", _lettivd);
|
|
set_header(4, "@10g%-8s", (const char*) _numrivd);
|
|
if (_numivd != 0)
|
|
set_header(4, "@19g%2d", _numivd);
|
|
if (descriz2 != "")
|
|
{
|
|
set_header(4,"@23g%-50s",(const char*) descriz2);
|
|
set_header(4,"@80g%-50s",(const char*) descriz);
|
|
}
|
|
else
|
|
set_header(4,"@23g%-50s",(const char*) descriz);
|
|
|
|
dataini = _data_ini.string();
|
|
datafine = _data_fine.string();
|
|
|
|
if (_annomsk == 0)
|
|
{
|
|
set_header (5, "Periodo@10g%s", (const char*) dataini);
|
|
set_header (5, "@22g%s", (const char*) datafine);
|
|
}
|
|
else
|
|
{
|
|
set_header (5, "Comp. da@9g%s", (const char*) dataini);
|
|
set_header (5, "@20ga@22g%s", (const char*) datafine);
|
|
}
|
|
|
|
set_header (5, "@33gP.I.@37g%-11s",(const char*) paiv);
|
|
set_header (5, "@49gCF@52g%-16s",(const char*) cofi);
|
|
set_header (5, "@69g%-25s",(const char*) indcf);
|
|
set_header (5, "@95g%-5s",(const char*) capcf);
|
|
set_header (5, "@101g%-24s",(const char*) dencom);
|
|
set_header (5,"@126g%-5s",(const char*) provcom);
|
|
|
|
if (_numcarat == 2)
|
|
{
|
|
set_header (5,"@134g%-4s",(const char*) ptel);
|
|
set_header (5,"@138g/@139g%-10s",(const char*) tel);
|
|
}
|
|
}
|
|
|
|
// Se la ricerca selezionata sulla maschera e' per gruppo, conto, sottoconto
|
|
// ricerca i corrispondenti su PCON, con relativa IV direttiva CEE
|
|
|
|
void CG3200_application::ricerca_classe_IV(bool scelta)
|
|
{
|
|
TLocalisamfile pconti(LF_PCON);
|
|
|
|
pconti.setkey(1);
|
|
pconti.zero();
|
|
pconti.put(PCN_GRUPPO, _gruppo);
|
|
pconti.put(PCN_CONTO, _conto);
|
|
if (scelta)
|
|
pconti.put(PCN_SOTTOCONTO, _sottoc);
|
|
pconti.read();
|
|
_sezivd = pconti.get_char(PCN_SEZIVD);
|
|
_lettivd = pconti.get_char(PCN_LETTIVD);
|
|
_numrivd_int = pconti.get_int (PCN_NUMRIVD);
|
|
_numrivd = itor(_numrivd_int);
|
|
_numivd = pconti.get_int (PCN_NUMIVD);
|
|
_descr = pconti.get (PCN_DESCR);
|
|
}
|
|
|
|
void CG3200_application::ricerca_gruppo()
|
|
{
|
|
TString80 descr,descriz,descriz2,dep;
|
|
TString dataini,datafine;
|
|
|
|
ricerca_classe_IV (TRUE); //Esiste a livello di sottoconto
|
|
|
|
if (_sezivd == '0') //Non esiste a livello di sottoconto
|
|
ricerca_classe_IV (FALSE); //Allora la cerco a livello di conto
|
|
|
|
descriz = descrizione_classe(_sezivd,_lettivd,_numrivd_int,_numivd);
|
|
if (_numivd != 0) //Ora devo stampare la descrizione del livello della
|
|
{ //classe immediatamente precedente a quello appena
|
|
if (_numrivd != "") //stampato
|
|
descriz2 = descrizione_classe(_sezivd,_lettivd,_numrivd_int,0);
|
|
else
|
|
descriz2 = descrizione_classe(_sezivd,_lettivd,0,0);
|
|
}
|
|
else
|
|
if (_numrivd != "")
|
|
descriz2 = descrizione_classe(_sezivd,_lettivd,0,0);
|
|
else
|
|
descriz2 = "";
|
|
|
|
set_header(3,"@27g%-30s",(const char*) descrizione_gruppo());
|
|
set_header(3,"@59g%-30s",(const char*) descrizione_conto());
|
|
|
|
set_header(3,"@91g%-30s",(const char*) _descr);
|
|
set_header(4, "@0gClasse@12g%c", _lettivd);
|
|
set_header(4, "@14g%-8s",(const char*) _numrivd);
|
|
if (_numivd != 0)
|
|
set_header(4, "@23g%d", _numivd);
|
|
if (descriz2 != "")
|
|
{
|
|
set_header(4,"@27g%-50s",(const char*) descriz2);
|
|
set_header(4,"@80g%-50s",(const char*) descriz);
|
|
}
|
|
else
|
|
set_header(4,"@27g%-50s",(const char*) descriz);
|
|
|
|
dataini = _data_ini.string();
|
|
datafine = _data_fine.string();
|
|
|
|
if (_annomsk == 0)
|
|
{
|
|
set_header (5, "Periodo@12g%s", (const char*) dataini);
|
|
set_header (5, "@24g%s", (const char*) datafine);
|
|
}
|
|
else
|
|
{
|
|
set_header (5, "Periodo di competenza@23g%s", (const char*) dataini);
|
|
set_header (5, "@35g%s", (const char*) datafine);
|
|
}
|
|
}
|
|
|
|
const char* CG3200_application::descrizione_classe(char sezione, char lettera, int numr, int numero)
|
|
{
|
|
TTable tabivd(TAB_IVD);
|
|
TString dep,dep2;
|
|
|
|
tabivd.zero();
|
|
if (numr == 0 && numero == 0)
|
|
dep = format("%c%c",sezione,lettera);
|
|
else
|
|
if (numero == 0)
|
|
{
|
|
if (numr != 0)
|
|
dep = format("%1c%1c%04d",sezione, lettera, numr);
|
|
else
|
|
dep = format("%c%c ",sezione,lettera);
|
|
}
|
|
else
|
|
{
|
|
if (numr != 0)
|
|
dep = format("%1c%1c%04d%02d",sezione, lettera, numr,numero);
|
|
else
|
|
dep = format("%c%c %02d",sezione,lettera,numero);
|
|
}
|
|
|
|
tabivd.put("CODTAB", dep);
|
|
tabivd.read();
|
|
dep2 = tabivd.get("CODTAB");
|
|
if (dep == dep2)
|
|
tmp = tabivd.get("S0");
|
|
else
|
|
tmp = "";
|
|
return (tmp);
|
|
}
|
|
|
|
//Ricerca la descrizione relativa al gruppo da stampare
|
|
|
|
const char* CG3200_application::descrizione_gruppo()
|
|
{
|
|
TLocalisamfile pconti(LF_PCON);
|
|
|
|
pconti.zero();
|
|
pconti.put(PCN_GRUPPO,_gruppo);
|
|
if (pconti.read() != NOERR) pconti.zero();
|
|
tmp = pconti.get(PCN_DESCR);
|
|
return tmp;
|
|
}
|
|
|
|
// Ricerca la descrizione relativa al conto da stampare
|
|
|
|
const char* CG3200_application::descrizione_conto()
|
|
{
|
|
TLocalisamfile pconti(LF_PCON);
|
|
|
|
pconti.zero();
|
|
pconti.put(PCN_GRUPPO,_gruppo);
|
|
pconti.put(PCN_CONTO,_conto);
|
|
if (pconti.read() != NOERR) pconti.zero();
|
|
tmp = pconti.get(PCN_DESCR);
|
|
return tmp;
|
|
}
|
|
|
|
bool CG3200_application::user_create()
|
|
{
|
|
TToken_string exp;
|
|
|
|
_rel = new TRelation (LF_SALDI);
|
|
|
|
exp.add("GRUPPO=GRUPPO");
|
|
exp.add("CONTO=CONTO");
|
|
exp.add("SOTTOCONTO=SOTTOCONTO");
|
|
_rel->add(LF_RMOV,exp,2,LF_SALDI);
|
|
|
|
_cur1=add_cursor(new TCursor(_rel,"",2));
|
|
|
|
_nditte = new TLocalisamfile (LF_NDITTE);
|
|
_unloc = new TLocalisamfile (LF_UNLOC);
|
|
_comuni = new TLocalisamfile (LF_COMUNI);
|
|
_mov = new TLocalisamfile (LF_MOV);
|
|
_clifo = new TLocalisamfile (LF_CLIFO);
|
|
_caus = new TLocalisamfile (LF_CAUSALI);
|
|
_tabivd = new TTable (TAB_IVD);
|
|
_tabtpd = new TTable (TAB_TPD);
|
|
_tabreg = new TTable (TAB_REG);
|
|
_tabesc = new TTable (TAB_ESC);
|
|
|
|
_msk = new TMask("cg3200a");
|
|
_msk->set_handler(F_SOTTOCINI_CONTO, sottoc_handler_ini);
|
|
_msk->set_handler(F_SOTTOCINI_CLIENTE, sottoc_handler_ini);
|
|
_msk->set_handler(F_SOTTOCINI_FORN, sottoc_handler_ini);
|
|
_msk->set_handler(F_SOTTOCFINE_CONTO, sottoc_handler_fine);
|
|
_msk->set_handler(F_SOTTOCFINE_CLIENTE, sottoc_handler_fine);
|
|
_msk->set_handler(F_SOTTOCFINE_FORN, sottoc_handler_fine);
|
|
|
|
_inizio_stampa = TRUE;
|
|
return TRUE;
|
|
}
|
|
|
|
bool CG3200_application::user_destroy()
|
|
{
|
|
delete _msk;
|
|
delete _rel;
|
|
delete _mov;
|
|
delete _nditte;
|
|
delete _unloc;
|
|
delete _comuni;
|
|
delete _clifo;
|
|
delete _caus;
|
|
delete _tabivd;
|
|
delete _tabtpd;
|
|
delete _tabreg;
|
|
delete _tabesc;
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
int cg3200(int argc, char* argv[])
|
|
{
|
|
|
|
CG3200_application a;
|
|
|
|
a.run(argc, argv, "Stampa Mastrini");
|
|
|
|
return 0;
|
|
}
|