1724 lines
48 KiB
C++
Executable File
1724 lines
48 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 "cg3401.h"
|
|
#include "cglib.h"
|
|
|
|
const MAXSTR = 128;
|
|
static char __tmp [MAXSTR];
|
|
static TFixed_string tmp (__tmp, MAXSTR);
|
|
|
|
class CG3200_application : public TPrintapp
|
|
{
|
|
TDociva_array _b;
|
|
TRelation* _rel;
|
|
TRelation* _rel_clifo;
|
|
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;
|
|
int _cur1,_cur2,_cur3,_gruppo,_conto,_numcarat,_stampanum,_numivd;
|
|
int _numrig,_natdoc,_tipo,_tipostampa;
|
|
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;
|
|
TString _sezivd,_lettivd,_tipodoc,_codcaus,_descrcaus,_descrdociva,_regiva;
|
|
TString _descrizione,_sezione,_numdoc,_descrizionemov,_numrivd;
|
|
TString _dataregs, _datadocs,_gruppocontr,_contocontr,_sottocontocontr;
|
|
|
|
bool _stampaprogre,_stampatotiva,_stampatot,_prima_volta,_stampa_mov_prov;
|
|
|
|
int _annomsk,_annoesmsk,_annoes,_annomsksucc;
|
|
long _sottoc,_numreg,_protiva,_numgio;
|
|
|
|
bool _stampa_progressivi_si,_competenza,_inizio_stampa,_puoi_stampare;
|
|
int _tipocf;
|
|
char _ricerca;
|
|
|
|
TDate _dataregrmov;
|
|
int _gruppof,_contof;
|
|
long _sottocf;
|
|
TString _dataregrmovstring,_importo_str,_saldo_movimenti_str,_saldo_progressivi_str;
|
|
|
|
protected:
|
|
virtual void user_create() ;
|
|
virtual void user_destroy();
|
|
virtual bool set_print(int m);
|
|
|
|
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:
|
|
bool preprocess_pconti(int file, int counter);
|
|
bool preprocess_clifo(int file, int counter);
|
|
void set_page_pconti(int file, int counter);
|
|
void set_page_clifo(int file, int counter);
|
|
void ricerca_clifo();
|
|
void ricerca_gruppo();
|
|
void calcola_progressivi();
|
|
void calcola_progressivi_al();
|
|
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 data_fine_esercizio();
|
|
void data_fine_esercizio_succ();
|
|
const char* descrizione_gruppo();
|
|
const char* descrizione_conto();
|
|
const char* descrizione_gruppo_clifo();
|
|
const char* descrizione_conto_clifo();
|
|
bool almeno_un_record();
|
|
void ricerca_dati_ditta();
|
|
|
|
CG3200_application();
|
|
};
|
|
|
|
void CG3200_application::process_link(int id, const char* txt)
|
|
{
|
|
TToken_string ss(10);
|
|
|
|
ss.add("1");
|
|
ss.add(txt);
|
|
const TString app("cg2");
|
|
TMessage fs(cmd2name(app,""), MSG_LN, ss);
|
|
TMailbox m;
|
|
m.send(fs);
|
|
|
|
TExternal_app pn(app);
|
|
|
|
if (pn.run()) beep();
|
|
}
|
|
|
|
//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;
|
|
TLocalisamfile* rmov;
|
|
|
|
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->next())
|
|
{
|
|
long annoes = rmov->get_long(RMV_ANNOES);
|
|
datareg = rmov->get_date(RMV_DATAREG);
|
|
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;
|
|
}
|
|
|
|
HIDDEN bool our_handler(TMask_field& field, KEY key)
|
|
{
|
|
if (key == K_TAB)
|
|
{
|
|
const long anno = atol(field.get());
|
|
field.mask().enable(F_COMPESE);
|
|
}
|
|
return TRUE;
|
|
}
|
|
|
|
void CG3200_application::saldi_zero()
|
|
{
|
|
TLocalisamfile* rmov;
|
|
real saldo_dare, saldo_avere;
|
|
long record;
|
|
|
|
saldo_dare = saldo_avere = 0;
|
|
|
|
rmov = current_cursor()->file(LF_RMOV);
|
|
if (current_cursor()->is_first_match(LF_RMOV))
|
|
{
|
|
record = rmov->recno();
|
|
|
|
while (!rmov->eof())
|
|
{
|
|
rmov->read();
|
|
// char sezione = *(_rmov->curr().get(RMV_SEZIONE));
|
|
TString sezione = rmov->curr().get(RMV_SEZIONE);
|
|
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;
|
|
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#7d", &_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,"@42g#.18t", &_descrcaus);
|
|
_descrizione = current_cursor()->curr(LF_RMOV).get(RMV_DESCR);
|
|
if (_descrizione == "")
|
|
set_row (1,"@61g%.23s", (const char*) _descrizionemov);
|
|
else
|
|
set_row (1,"@61g%.23s", (const char*) _descrizione);
|
|
_sezione = current_cursor()->curr(LF_RMOV).get(RMV_SEZIONE);
|
|
if (_sezione == "D")
|
|
set_row (1,"@85g#t", &_importo_str);
|
|
else if (_sezione == "A")
|
|
set_row (1,"@101g#t", &_importo_str);
|
|
|
|
set_row (1,"@117g#3t", &_gruppocontr);
|
|
set_row (1,"@120g#3t", &_contocontr);
|
|
set_row (1,"@123g#6t", &_sottocontocontr);
|
|
}
|
|
|
|
void CG3200_application::fai_stampa198()
|
|
{
|
|
TLocalisamfile* rmov;
|
|
long rec;
|
|
TDate datasucc;
|
|
TString datasuccstring,dataregrmovstring;
|
|
int gruppof,contof;
|
|
long sottocf;
|
|
|
|
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,"@42g#.25t", &_descrcaus);
|
|
|
|
_descrizione = current_cursor()->curr(LF_RMOV).get(RMV_DESCR);
|
|
if (_descrizione == "")
|
|
set_row (1,"@68g%.32s", (const char*) _descrizionemov);
|
|
else
|
|
set_row (1,"@68g%.32s", (const char*) _descrizione);
|
|
_sezione = current_cursor()->curr(LF_RMOV).get(RMV_SEZIONE);
|
|
if (_sezione == "D")
|
|
set_row (1,"@102g#t", &_importo_str);
|
|
else if (_sezione == "A")
|
|
set_row (1,"@119g#t", &_importo_str);
|
|
|
|
// Stampa saldo movimenti
|
|
|
|
set_row (1,"@153g#t", &_saldo_movimenti_str);
|
|
|
|
set_row (1,"@169g#3t", &_gruppocontr);
|
|
set_row (1,"@172g#3t", &_contocontr);
|
|
set_row (1,"@175g#6t", &_sottocontocontr);
|
|
|
|
if (_tipo < 3)
|
|
set_row (1,"@185g#t" , &_regiva);
|
|
set_row (1,"@194g#5d", &_protiva);
|
|
_dataregrmov = current_cursor()->curr(LF_RMOV).get_date(RMV_DATAREG);
|
|
dataregrmovstring=_dataregrmov.string();
|
|
|
|
//Gestire la stampa di saldo_progressivi nella postprocess_page di RMOV
|
|
|
|
rmov = current_cursor()->file(LF_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);
|
|
}
|
|
|
|
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%r", &_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_pconti(int file, int counter)
|
|
{
|
|
TLocalisamfile* rmov;
|
|
long record;
|
|
TString provvis = "";
|
|
|
|
if (counter)
|
|
return TRUE;
|
|
|
|
switch (file)
|
|
{
|
|
case LF_PCON:
|
|
// Usati in crea_intestazione()
|
|
_gruppo = atoi(current_cursor()->curr(LF_PCON).get(PCN_GRUPPO));
|
|
_conto = atoi(current_cursor()->curr(LF_PCON).get(PCN_CONTO));
|
|
_sottoc = atol(current_cursor()->curr(LF_PCON).get(PCN_SOTTOCONTO));
|
|
|
|
_saldo_periodo =0;
|
|
_totale_periodo_dare =0;
|
|
_totale_periodo_avere =0;
|
|
_saldo_progre =0;
|
|
_totprogre_dare =0;
|
|
_totprogre_avere =0;
|
|
_saldo_progre_al =0;
|
|
_totprogre_dare_al =0;
|
|
_totprogre_avere_al =0;
|
|
_progredare =0;
|
|
_progreavere =0;
|
|
_totale_prima_dare =0;
|
|
_totale_prima_avere =0;
|
|
_saldo_movimenti =0;
|
|
_saldo_progressivi =0;
|
|
_saldo_progre_prec =0;
|
|
if (_tipostampa == 2)
|
|
saldi_zero();
|
|
else
|
|
_totale_saldo = 1;
|
|
|
|
if ((_tipostampa == 1) || (_tipostampa == 2))
|
|
if ((almeno_un_record()) && (_totale_saldo != 0))
|
|
_puoi_stampare = TRUE;
|
|
else
|
|
{
|
|
_puoi_stampare = FALSE;
|
|
return FALSE;
|
|
}
|
|
break;
|
|
|
|
case LF_RMOV:
|
|
{
|
|
// Ricerca la contropartita di quel movimento
|
|
|
|
_numreg = atol (current_cursor()->curr(LF_RMOV).get(RMV_NUMREG));
|
|
|
|
int rcontr = atoi(current_cursor()->curr(LF_RMOV).get(RMV_RCONTR));
|
|
rmov = current_cursor()->file(LF_RMOV);
|
|
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(RMV_GRUPPO);
|
|
_contocontr = rmov->curr().get(RMV_CONTO);
|
|
_sottocontocontr = rmov->curr().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();
|
|
_annoes = _mov->get_int(MOV_ANNOES);
|
|
_regiva = _mov->curr().get(MOV_REG);
|
|
|
|
// Controlla se saldo e' diverso da 0
|
|
|
|
if (((_annoes == _annomsk) || (_annomsk == 0)) && (_totale_saldo != 0))
|
|
{
|
|
_sezione = current_cursor()->curr(LF_RMOV).get(RMV_SEZIONE);
|
|
|
|
_datareg = (_mov->curr().get(MOV_DATAREG));
|
|
provvis = _mov->curr().get(MOV_PROVVIS);
|
|
|
|
_dataregs = _datareg.string();
|
|
|
|
if ((_stampa_mov_prov)||((!_stampa_mov_prov)&&(provvis.trim().empty())))
|
|
{
|
|
if ((_datareg >= _data_ini) && (_datareg <= _data_fine))
|
|
{
|
|
_codcaus = _mov->curr().get(MOV_CODCAUS);
|
|
_tipodoc = _mov->curr().get(MOV_TIPODOC);
|
|
if (_stampatotiva)
|
|
{
|
|
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 = _mov->get_long(MOV_NUMGIO);
|
|
if (_sezione == "D")
|
|
{
|
|
_totale_periodo_dare += _importo;
|
|
_riporto_parziale_dare += _importo;
|
|
if (_numcarat == 2)
|
|
{
|
|
_saldo_progressivi += _importo;
|
|
_saldo_movimenti += _importo;
|
|
}
|
|
}
|
|
else if (_sezione == "A")
|
|
{
|
|
_totale_periodo_avere += _importo;
|
|
_riporto_parziale_avere += _importo;
|
|
if (_numcarat == 2)
|
|
{
|
|
_saldo_progressivi -= _importo;
|
|
_saldo_movimenti -= _importo;
|
|
}
|
|
}
|
|
_saldo_progressivi_str=_saldo_progressivi.string("###############");
|
|
_saldo_movimenti_str=_saldo_movimenti.string("###############");
|
|
if (_numcarat == 2)
|
|
{
|
|
ricerca_regiva();
|
|
_protiva = atol(_mov->curr().get(MOV_PROTIVA));
|
|
}
|
|
return TRUE;
|
|
}
|
|
else
|
|
return FALSE;
|
|
}
|
|
else
|
|
return FALSE;
|
|
}
|
|
break;
|
|
}
|
|
default:
|
|
break;
|
|
}
|
|
return TRUE;
|
|
}
|
|
|
|
bool CG3200_application::preprocess_clifo(int file, int counter)
|
|
{
|
|
TLocalisamfile* rmov;
|
|
long record;
|
|
TString provvis = "";
|
|
|
|
if (counter)
|
|
return TRUE;
|
|
|
|
switch (file)
|
|
{
|
|
case LF_CLIFO:
|
|
// Usati in crea_intestazione()
|
|
_gruppo = atoi(current_cursor()->curr(LF_CLIFO).get(CLI_GRUPPO));
|
|
_conto = atoi(current_cursor()->curr(LF_CLIFO).get(CLI_CONTO));
|
|
_sottoc = atol(current_cursor()->curr(LF_CLIFO).get(CLI_CODCF));
|
|
|
|
_saldo_periodo =0;
|
|
_totale_periodo_dare =0;
|
|
_totale_periodo_avere =0;
|
|
_saldo_progre =0;
|
|
_totprogre_dare =0;
|
|
_totprogre_avere =0;
|
|
_saldo_progre_al =0;
|
|
_totprogre_dare_al =0;
|
|
_totprogre_avere_al =0;
|
|
_progredare =0;
|
|
_progreavere =0;
|
|
_totale_prima_dare =0;
|
|
_totale_prima_avere =0;
|
|
_saldo_movimenti =0;
|
|
_saldo_progressivi =0;
|
|
_saldo_progre_prec =0;
|
|
if (_tipostampa == 2)
|
|
saldi_zero();
|
|
else
|
|
_totale_saldo = 1;
|
|
|
|
if ((_tipostampa == 1) || (_tipostampa == 2))
|
|
if ((almeno_un_record()) && (_totale_saldo != 0))
|
|
_puoi_stampare = TRUE;
|
|
else
|
|
{
|
|
_puoi_stampare = FALSE;
|
|
return FALSE;
|
|
}
|
|
break;
|
|
|
|
case LF_RMOV:
|
|
{
|
|
// Ricerca la contropartita di quel movimento
|
|
|
|
_numreg = atol (current_cursor()->curr(LF_RMOV).get(RMV_NUMREG));
|
|
|
|
int rcontr = atoi(current_cursor()->curr(LF_RMOV).get(RMV_RCONTR));
|
|
rmov = current_cursor()->file(LF_RMOV);
|
|
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(RMV_GRUPPO);
|
|
_contocontr = rmov->curr().get(RMV_CONTO);
|
|
_sottocontocontr = rmov->curr().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();
|
|
_annoes = _mov->get_int(MOV_ANNOES);
|
|
_regiva = _mov->curr().get(MOV_REG);
|
|
|
|
// Controlla se saldo e' diverso da 0
|
|
|
|
if (((_annoes == _annomsk) || (_annomsk == 0)) && (_totale_saldo != 0))
|
|
{
|
|
_sezione = current_cursor()->curr(LF_RMOV).get(RMV_SEZIONE);
|
|
|
|
_datareg = (_mov->curr().get(MOV_DATAREG));
|
|
provvis = _mov->curr().get(MOV_PROVVIS);
|
|
|
|
_dataregs = _datareg.string();
|
|
|
|
if ((_stampa_mov_prov)||((!_stampa_mov_prov)&&(provvis.trim().empty())))
|
|
{
|
|
if ((_datareg >= _data_ini) && (_datareg <= _data_fine))
|
|
{
|
|
_codcaus = _mov->curr().get(MOV_CODCAUS);
|
|
_tipodoc = _mov->curr().get(MOV_TIPODOC);
|
|
if (_stampatotiva)
|
|
{
|
|
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 = _mov->get_int(MOV_NUMGIO);
|
|
if (_sezione == "D")
|
|
{
|
|
_totale_periodo_dare += _importo;
|
|
_riporto_parziale_dare += _importo;
|
|
if (_numcarat == 2)
|
|
{
|
|
_saldo_progressivi += _importo;
|
|
_saldo_movimenti += _importo;
|
|
}
|
|
}
|
|
else if (_sezione == "A")
|
|
{
|
|
_totale_periodo_avere += _importo;
|
|
_riporto_parziale_avere += _importo;
|
|
if (_numcarat == 2)
|
|
{
|
|
_saldo_progressivi -= _importo;
|
|
_saldo_movimenti -= _importo;
|
|
}
|
|
}
|
|
_saldo_progressivi_str=_saldo_progressivi.string("###############");
|
|
_saldo_movimenti_str=_saldo_movimenti.string("###############");
|
|
if (_numcarat == 2)
|
|
{
|
|
ricerca_regiva();
|
|
_protiva = atol(_mov->curr().get(MOV_PROTIVA));
|
|
}
|
|
return TRUE;
|
|
}
|
|
else
|
|
return FALSE;
|
|
}
|
|
else
|
|
return FALSE;
|
|
}
|
|
break;
|
|
}
|
|
default:
|
|
break;
|
|
}
|
|
return TRUE;
|
|
}
|
|
|
|
bool CG3200_application::preprocess_page(int file, int counter)
|
|
{
|
|
if (_ricerca == 'P')
|
|
{
|
|
if (preprocess_pconti(file,counter))
|
|
return TRUE;
|
|
else
|
|
return FALSE;
|
|
}
|
|
else
|
|
{
|
|
if ((_ricerca == 'C') || (_ricerca == 'F'))
|
|
{
|
|
if (preprocess_clifo(file,counter))
|
|
return TRUE;
|
|
else
|
|
return FALSE;
|
|
}
|
|
}
|
|
return TRUE;
|
|
}
|
|
|
|
void CG3200_application::set_page(int file, int counter)
|
|
{
|
|
if (_ricerca == 'P')
|
|
set_page_pconti(file,counter);
|
|
else
|
|
if ((_ricerca == 'C') || (_ricerca == 'F'))
|
|
set_page_clifo(file,counter);
|
|
}
|
|
|
|
void CG3200_application::set_page_pconti(int file, int counter)
|
|
{
|
|
switch (file)
|
|
{
|
|
case LF_PCON:
|
|
reset_print();
|
|
break;
|
|
|
|
case LF_RMOV:
|
|
reset_print();
|
|
if (_numcarat == 1)
|
|
fai_stampa132();
|
|
else if (_numcarat == 2)
|
|
fai_stampa198();
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
|
|
void CG3200_application::set_page_clifo(int file, int counter)
|
|
{
|
|
switch (file)
|
|
{
|
|
case LF_CLIFO:
|
|
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 (_ricerca == 'P')
|
|
{
|
|
if (counter)
|
|
{
|
|
printer().formfeed();
|
|
reset_print(); // per evitare che stampi di nuovo il totale prec.
|
|
return NEXT_PAGE;
|
|
}
|
|
|
|
switch (file)
|
|
{
|
|
case LF_PCON:
|
|
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;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if ((_ricerca == 'C') || (_ricerca == 'F'))
|
|
{
|
|
if (counter)
|
|
{
|
|
printer().formfeed();
|
|
reset_print(); // per evitare che stampi di nuovo il totale prec.
|
|
return NEXT_PAGE;
|
|
}
|
|
|
|
switch (file)
|
|
{
|
|
case LF_CLIFO:
|
|
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;
|
|
// _tipodoc = _mov->curr().get(MOV_TIPODOC);
|
|
|
|
_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()
|
|
{
|
|
TString dep;
|
|
|
|
_tabreg->curr().zero();
|
|
dep << format("%04d%3s", _annoes, (const char*) _regiva);
|
|
_tabreg->curr().put("CODTAB", (const char*) dep);
|
|
_tabreg->read();
|
|
_tipo = atoi(_tabreg->curr().get("I0"));
|
|
}
|
|
|
|
CG3200_application::CG3200_application()
|
|
{
|
|
}
|
|
|
|
bool CG3200_application::set_print(int)
|
|
{
|
|
KEY tasto;
|
|
int crt;
|
|
TLocalisamfile* fl;
|
|
TString data1,data2;
|
|
|
|
_puoi_stampare = TRUE;
|
|
|
|
tasto = _msk->run();
|
|
|
|
if (tasto == K_ENTER)
|
|
{
|
|
_data_ini = (_msk->get(F_DATAINI));
|
|
_data_fine = (_msk->get(F_DATAFINE));
|
|
|
|
_annomsk = _msk->get_int(F_ANNO);
|
|
|
|
if (_annomsk == 0)
|
|
if (_data_fine == botime) //Se data_fine e' vuota
|
|
_data_fine = eotime;
|
|
|
|
if (_annomsk != 0)
|
|
{
|
|
_annoesmsk = _annomsk - 1;
|
|
data_fine_esercizio();
|
|
if (_data_ini == botime)
|
|
_data_ini = _data_inizioese;
|
|
if (_data_fine == botime)
|
|
_data_fine = _data_finese;
|
|
}
|
|
|
|
data1 = _data_ini.string();
|
|
data2 = _data_fine.string();
|
|
|
|
_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));
|
|
long sottocontoini = atol(_msk->get(F_SOTTOCONTOINI));
|
|
int gruppofine = atoi(_msk->get(F_GRUPPOFINE));
|
|
int contofine = atoi(_msk->get(F_CONTOFINE));
|
|
long sottocontofine = atol(_msk->get(F_SOTTOCONTOFINE));
|
|
_competenza = (bool)(_msk->get(F_COMPESE) == "X");
|
|
_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));
|
|
_ricerca = _msk->get(F_RICERCA)[0];
|
|
_codice_ditta = get_firm();
|
|
|
|
ricerca_dati_ditta();
|
|
|
|
// 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
|
|
if (_ricerca == 'P')
|
|
{
|
|
reset_files(); //resetta l'albero di stampa
|
|
add_file(LF_PCON);
|
|
add_file(LF_RMOV,LF_PCON);
|
|
|
|
select_cursor(_cur1);
|
|
fl = current_cursor()->file(LF_PCON);
|
|
TRectype da (fl->curr());
|
|
TRectype a (fl->curr());
|
|
|
|
da.zero();
|
|
a.zero();
|
|
|
|
da.put(PCN_GRUPPO,gruppoini);
|
|
da.put(PCN_CONTO,contoini);
|
|
da.put(PCN_SOTTOCONTO,sottocontoini);
|
|
|
|
a.put(PCN_GRUPPO,gruppofine);
|
|
a.put(PCN_CONTO,contofine);
|
|
a.put(PCN_SOTTOCONTO,sottocontofine);
|
|
|
|
current_cursor()->setregion(da, a);
|
|
}
|
|
else
|
|
{
|
|
if (_ricerca == 'C')
|
|
select_cursor(_cur2);
|
|
if (_ricerca == 'F')
|
|
select_cursor(_cur3);
|
|
|
|
reset_files();
|
|
add_file(LF_CLIFO);
|
|
add_file(LF_RMOV,LF_CLIFO);
|
|
|
|
fl = current_cursor()->file(LF_CLIFO);
|
|
TRectype da (fl->curr());
|
|
TRectype a (fl->curr());
|
|
|
|
da.zero();
|
|
a.zero();
|
|
|
|
da.put(CLI_TIPOCF,_ricerca);
|
|
da.put(CLI_GRUPPO,gruppoini);
|
|
da.put(CLI_CONTO,contoini);
|
|
da.put(CLI_CODCF,sottocontoini);
|
|
|
|
a.put(CLI_TIPOCF,_ricerca);
|
|
a.put(CLI_GRUPPO,gruppofine);
|
|
a.put(CLI_CONTO,contofine);
|
|
a.put(CLI_CODCF,sottocontofine);
|
|
|
|
current_cursor()->setregion(da, a);
|
|
}
|
|
|
|
if (_stampatotiva)
|
|
_b.destroy();
|
|
|
|
if (_competenza)
|
|
if (_data_fine == _data_finese)
|
|
{
|
|
TDate datafinesucc = _data_fine;
|
|
datafinesucc.addyear(1);
|
|
data_fine_esercizio_succ();
|
|
if (datafinesucc == _data_finesesucc)
|
|
_data_fine = datafinesucc;
|
|
}
|
|
|
|
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()
|
|
{
|
|
TString dep;
|
|
|
|
_tabesc->curr().zero();
|
|
dep << format ("%04d",_annomsk);
|
|
_tabesc->curr().put("CODTAB", (const char*) dep);
|
|
_tabesc->read();
|
|
_data_finese = _tabesc->curr().get("D1");
|
|
_data_inizioese = _tabesc->curr().get("D0");
|
|
}
|
|
|
|
void CG3200_application::data_fine_esercizio_succ()
|
|
{
|
|
TString dep;
|
|
|
|
_annomsksucc = _annomsk + 1;
|
|
_tabesc->curr().zero();
|
|
dep << format ("%04d",_annomsksucc);
|
|
_tabesc->curr().put("CODTAB", (const char*) dep);
|
|
_tabesc->read();
|
|
_data_finesesucc = _tabesc->curr().get("D1");
|
|
}
|
|
|
|
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::ricerca_dati_ditta()
|
|
{
|
|
long app;
|
|
|
|
_nditte->setkey(1);
|
|
// _codice_ditta << get_firm();
|
|
_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%5d", _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%d", _sottoc);
|
|
|
|
TString tipocf = (_msk->get(F_RICERCA));
|
|
if (tipocf == "C")
|
|
_tipocf = 1;
|
|
else if (tipocf == "F")
|
|
_tipocf = 2;
|
|
else if (tipocf == "P")
|
|
_tipocf = 3;
|
|
switch (_tipocf)
|
|
{
|
|
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,"Data@11gNumero@19gDocumento@117gContro@130gAn");
|
|
set_header (8,"Registr.@11gregistr@19gData@30gNumero@38gCod.Causale@61gDescrizione@90gDare@106gAvere@117gPartita@130gCo");
|
|
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,"Data@11gNumero@19gData@30gNumero@172gContro@183gA@185gReg@193gNumero");
|
|
set_header (8,"Registr.@11gregistr.@19gDocumento@38gCod.Causale@68gDescrizione@108gDare@124gAvere@136gSaldo progress.@154gSaldo movim.@172gPartita@183gC@185gIva@189gProtocollo");
|
|
sep1.fill('-');
|
|
set_header (9,"@1g%s", (const char *) sep1);
|
|
}
|
|
if (_stampa_progressivi_si)
|
|
{
|
|
calcola_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_header (10,"@32gA RIPORTO@85g%15s",(const char*) string);
|
|
string = _riporto_avere.string("###############");
|
|
set_header (10,"@101g%15s",(const char*) string);
|
|
}
|
|
if (_numcarat == 2)
|
|
{
|
|
TString string = _riporto_dare.string("###############");
|
|
set_header (10,"@32gA RIPORTO@102g%15s",(const char*) string);
|
|
string = _riporto_avere.string("###############");
|
|
set_header (10,"@119g%15s",(const char*) string);
|
|
}
|
|
_riporto_parziale_dare = 0;
|
|
_riporto_parziale_avere = 0;
|
|
}
|
|
if (_numcarat == 1)
|
|
{
|
|
sep ="";
|
|
set_header(11,"@1g%s",(const char*) sep);
|
|
}
|
|
else if (_numcarat == 2)
|
|
{
|
|
sep1 ="";
|
|
set_header(11,"@1g%s",(const char*) sep1);
|
|
}
|
|
}
|
|
|
|
void CG3200_application::calcola_progressivi_al()
|
|
{
|
|
long record,sottoc,annoes;
|
|
int gruppo,conto;
|
|
TDate datareg;
|
|
TLocalisamfile* rmov;
|
|
|
|
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->next())
|
|
{
|
|
annoes = rmov->get_long(RMV_ANNOES);
|
|
datareg = rmov->get_date(RMV_DATAREG);
|
|
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)&&(_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 pconti(LF_PCON);
|
|
TLocalisamfile saldi (LF_SALDI);
|
|
real pdaresca,paveresca,pdarescap,paverescap;
|
|
real progdare_attuale,progavere_attuale,progdare_prec,progavere_prec;
|
|
real saldo,progredare_eseprec,progreavere_eseprec,pdarep,paverep;
|
|
int indbil;
|
|
char salini;
|
|
TRectype record(saldi.curr());
|
|
|
|
saldo = 0.00;
|
|
pdarep = 0.00;
|
|
paverep = 0.00;
|
|
pdaresca = 0.00;
|
|
paveresca = 0.00;
|
|
pdarescap = 0.00;
|
|
paverescap = 0.00;
|
|
// Ricerca sull'archivio saldi dei record con gruppo,conto,sottoconto
|
|
// uguali a quelli di rmov per il calcolo dei progressivi precedenti
|
|
|
|
record.zero();
|
|
record.put(SLD_GRUPPO, _gruppo);
|
|
record.put(SLD_CONTO, _conto);
|
|
record.put(SLD_SOTTOCONTO, _sottoc);
|
|
|
|
if (_ricerca == 'P')
|
|
indbil = atoi (current_cursor()->file(LF_PCON)->get(PCN_INDBIL));
|
|
else
|
|
{
|
|
if ((_ricerca == 'C') || (_ricerca == 'F'))
|
|
{
|
|
pconti.setkey(1);
|
|
pconti.zero();
|
|
pconti.put(PCN_GRUPPO, _gruppo);
|
|
pconti.put(PCN_CONTO , _conto);
|
|
pconti.read();
|
|
if (pconti.good())
|
|
indbil = atoi (pconti.get(PCN_INDBIL));
|
|
else
|
|
indbil = 0;
|
|
}
|
|
}
|
|
|
|
saldi.setkey(2);
|
|
|
|
saldi.zero();
|
|
saldi.put(SLD_GRUPPO, _gruppo);
|
|
saldi.put(SLD_CONTO, _conto);
|
|
saldi.put(SLD_SOTTOCONTO, _sottoc);
|
|
|
|
for ( saldi.read();
|
|
((saldi.curr()==record) && !saldi.eof());
|
|
saldi.next())
|
|
{
|
|
long annoes_saldi = saldi.curr().get_long(SLD_ANNOES);
|
|
|
|
//Calcola i progressivi dell'esercizio attuale
|
|
|
|
if (annoes_saldi == _annomsk)
|
|
{
|
|
pdaresca = saldi.curr().get_real(SLD_PDARESCA);
|
|
paveresca = saldi.curr().get_real(SLD_PAVERESCA);
|
|
saldo = saldi.curr().get_real(SLD_SALDO);
|
|
salini = saldi.curr().get(SLD_FLAGSALINI)[0];
|
|
}
|
|
|
|
//Calcola i progressivi dell'esercizio precedente
|
|
|
|
if (annoes_saldi == _annoesmsk)
|
|
{
|
|
pdarescap = saldi.curr().get_real(SLD_PDARESCA);
|
|
pdarep = saldi.curr().get_real(SLD_PDARE);
|
|
paverescap = saldi.curr().get_real(SLD_PAVERESCA);
|
|
paverep = saldi.curr().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 (saldo != 0)
|
|
{
|
|
if (salini == 'D')
|
|
{
|
|
progredare_eseprec = saldo + pdarescap + pdarep;
|
|
progreavere_eseprec = paverescap + paverep;
|
|
}
|
|
else if (salini == 'A')
|
|
{
|
|
progredare_eseprec = pdarescap + pdarep;
|
|
progreavere_eseprec = saldo + paverescap + paverep;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
|
|
//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 ((indbil == 1) || (indbil == 2) || (indbil == 5))
|
|
{
|
|
saldo = _sld.saldofin_esprec(_annomsk,_gruppo,_conto,_sottoc);
|
|
|
|
if (saldo.sign() > 0)
|
|
{
|
|
progredare_eseprec = saldo + pdarescap + pdarep;
|
|
progreavere_eseprec = paverescap + paverep;
|
|
}
|
|
else if (saldo.sign() < 0)
|
|
{
|
|
progredare_eseprec = pdarescap + pdarep;
|
|
progreavere_eseprec = saldo + paverescap + paverep;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
//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.
|
|
|
|
calcola_progressivi_al();
|
|
|
|
_progredare = pdaresca + progredare_eseprec + _totale_prima_dare;
|
|
_progreavere = paveresca + progreavere_eseprec + _totale_prima_avere;
|
|
_saldo_progre_prec = _progredare - _progreavere;
|
|
} // FOR
|
|
|
|
if (_numcarat == 1)
|
|
{
|
|
TString string = _saldo_progre_prec.string("###############");
|
|
set_header (10,"@32gPROGRESSIVI PRECEDENTI@69g%15s",(const char*) string);
|
|
string = _progredare.string("###############");
|
|
set_header (10,"@85g%15s",(const char*) string);
|
|
string = _progreavere.string("###############");
|
|
set_header (10,"@101g%15s",(const char*) string);
|
|
}
|
|
|
|
if (_numcarat == 2)
|
|
{
|
|
TString string = _progredare.string("###############");
|
|
set_header (10,"@32gPROGRESSIVI PRECEDENTI@102g%15s",(const char*)string);
|
|
string = _progreavere.string("###############");
|
|
set_header (10,"@119g%15s",(const char*) string);
|
|
}
|
|
//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 (_competenza)
|
|
{
|
|
_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;
|
|
}
|
|
}
|
|
|
|
// 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 pconti(LF_PCON);
|
|
TString dataini,datafine;
|
|
|
|
ragsoc = (current_cursor()->curr(LF_CLIFO).get(CLI_RAGSOC));
|
|
paiv = (current_cursor()->curr(LF_CLIFO).get(CLI_PAIV));
|
|
cofi = (current_cursor()->curr(LF_CLIFO).get(CLI_COFI));
|
|
indcf = (current_cursor()->curr(LF_CLIFO).get(CLI_INDCF));
|
|
capcf = (current_cursor()->curr(LF_CLIFO).get(CLI_CAPCF));
|
|
ptel = (current_cursor()->curr(LF_CLIFO).get(CLI_PTEL));
|
|
tel = (current_cursor()->curr(LF_CLIFO).get(CLI_TEL));
|
|
statocf = (current_cursor()->curr(LF_CLIFO).get(CLI_STATOCF));
|
|
comcf = (current_cursor()->curr(LF_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.curr().zero();
|
|
pconti.curr().put(PCN_GRUPPO, _gruppo);
|
|
pconti.curr().put(PCN_CONTO, _conto);
|
|
pconti.curr().put(PCN_SOTTOCONTO, _sottoc);
|
|
pconti.read();
|
|
_sezivd = pconti.curr().get(PCN_SEZIVD);
|
|
_lettivd = pconti.curr().get(PCN_LETTIVD);
|
|
_numrivd = atoi(pconti.curr().get(PCN_NUMRIVD));
|
|
_numivd = atoi(pconti.curr().get(PCN_NUMIVD));
|
|
|
|
_tabivd->curr().zero();
|
|
dep << format ("%1s%1s%8d%2d",(const char*)_sezivd,(const char*)_lettivd,(const char*)_numrivd,_numivd);
|
|
_tabivd->curr().put("CODTAB", (const char*) dep);
|
|
_tabivd->read();
|
|
TString descriz = _tabivd->curr().get("S0");
|
|
|
|
if (_ricerca == 'P')
|
|
{
|
|
set_header(3,"@27g%-30s",(const char*) descrizione_gruppo());
|
|
set_header(3,"@59g%-30s",(const char*) descrizione_conto());
|
|
}
|
|
else
|
|
if ((_ricerca == 'C')||(_ricerca == 'F'))
|
|
{
|
|
set_header(3,"@27g%-30s",(const char*) descrizione_gruppo_clifo());
|
|
set_header(3,"@59g%-30s",(const char*) descrizione_conto_clifo());
|
|
}
|
|
set_header(3, "@91g%-30s",(const char*) ragsoc);
|
|
set_header(4, "@1gClasse@8g%1s",(const char*) _lettivd);
|
|
set_header(4, "@10g%8s",(const char*) _numrivd);
|
|
set_header(4, "@19g%2d", _numivd);
|
|
set_header(4,"@23g%-50s",(const char*) descriz);
|
|
|
|
dataini = _data_ini.string();
|
|
set_header (5, "@1gPeriodo@10g%s", (const char*) dataini);
|
|
if (_data_fine != eotime)
|
|
{
|
|
datafine = _data_fine.string();
|
|
set_header (5, "@22g%s", (const char*) datafine);
|
|
}
|
|
set_header (5, "@34g%-11s",(const char*) paiv);
|
|
set_header (5, "@46g%-16s",(const char*) cofi);
|
|
set_header (5, "@63g%-25s",(const char*) indcf);
|
|
set_header (5, "@89g%-5s",(const char*) capcf);
|
|
set_header (5, "@95g%-30s",(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_gruppo()
|
|
{
|
|
TString descr,descriz,dep;
|
|
int numrivd;
|
|
TString dataini,datafine;
|
|
|
|
descr = (current_cursor()->curr(LF_PCON).get(PCN_DESCR));
|
|
_sezivd = (current_cursor()->curr(LF_PCON).get(PCN_SEZIVD));
|
|
_lettivd = (current_cursor()->curr(LF_PCON).get(PCN_LETTIVD));
|
|
numrivd = atoi(current_cursor()->curr(LF_PCON).get(PCN_NUMRIVD));
|
|
_numrivd = itor(numrivd);
|
|
_numivd = atoi(current_cursor()->curr(LF_PCON).get(PCN_NUMIVD));
|
|
|
|
_tabivd->curr().zero();
|
|
dep << format ("%1s%1s%8d%2d",(const char*)_sezivd,(const char*)_lettivd,(const char*)_numrivd,_numivd);
|
|
_tabivd->curr().put("CODTAB", (const char*) dep);
|
|
_tabivd->read();
|
|
descriz = _tabivd->curr().get("S0");
|
|
|
|
if (_ricerca == 'P')
|
|
{
|
|
set_header(3,"@27g%-30s",(const char*) descrizione_gruppo());
|
|
set_header(3,"@59g%-30s",(const char*) descrizione_conto());
|
|
}
|
|
else
|
|
if ((_ricerca == 'C')||(_ricerca == 'F'))
|
|
{
|
|
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%1s",(const char*) _lettivd);
|
|
set_header(4, "@14g%8s",(const char*) _numrivd);
|
|
set_header(4, "@23g%d", _numivd);
|
|
set_header(4,"@27g%-50s",(const char*) descriz);
|
|
|
|
dataini = _data_ini.string();
|
|
set_header (5, "@0gPeriodo@12g%s", (const char*) dataini);
|
|
if (_data_fine != eotime)
|
|
{
|
|
datafine = _data_fine.string();
|
|
set_header (5, "@24g%s", (const char*) datafine);
|
|
}
|
|
}
|
|
|
|
//Ricerca la descrizione relativa al gruppo da stampare
|
|
|
|
const char* CG3200_application::descrizione_gruppo()
|
|
{
|
|
TLocalisamfile* pconti;
|
|
long record;
|
|
|
|
pconti = current_cursor()->file(LF_PCON);
|
|
record = pconti->recno();
|
|
pconti->curr().zero();
|
|
pconti->curr().put(PCN_GRUPPO,_gruppo);
|
|
pconti->read();
|
|
tmp = pconti->curr().get(PCN_DESCR);
|
|
pconti->readat(record);
|
|
return (tmp);
|
|
}
|
|
|
|
// Ricerca la descrizione relativa al conto da stampare
|
|
|
|
const char* CG3200_application::descrizione_conto()
|
|
{
|
|
TLocalisamfile* pconti;
|
|
long record;
|
|
|
|
pconti = current_cursor()->file(LF_PCON);
|
|
record = pconti->recno();
|
|
pconti->curr().zero();
|
|
pconti->curr().put(PCN_GRUPPO,_gruppo);
|
|
pconti->curr().put(PCN_CONTO,_conto);
|
|
pconti->read();
|
|
tmp = pconti->curr().get(PCN_DESCR);
|
|
pconti->readat(record);
|
|
return (tmp);
|
|
}
|
|
|
|
//Ricerca la descrizione relativa al gruppo da stampare
|
|
|
|
const char* CG3200_application::descrizione_gruppo_clifo()
|
|
{
|
|
TLocalisamfile pconti(LF_PCON);
|
|
|
|
pconti.curr().zero();
|
|
pconti.curr().put(PCN_GRUPPO,_gruppo);
|
|
pconti.read();
|
|
tmp = pconti.curr().get(PCN_DESCR);
|
|
return (tmp);
|
|
}
|
|
|
|
// Ricerca la descrizione relativa al conto da stampare
|
|
|
|
const char* CG3200_application::descrizione_conto_clifo()
|
|
{
|
|
TLocalisamfile pconti(LF_PCON);
|
|
|
|
pconti.curr().zero();
|
|
pconti.curr().put(PCN_GRUPPO,_gruppo);
|
|
pconti.curr().put(PCN_CONTO,_conto);
|
|
pconti.read();
|
|
tmp = pconti.curr().get(PCN_DESCR);
|
|
return (tmp);
|
|
}
|
|
|
|
void CG3200_application::user_create()
|
|
{
|
|
TToken_string exp,exp1;
|
|
|
|
_rel = new TRelation (LF_PCON);
|
|
|
|
exp.add("GRUPPO=GRUPPO");
|
|
exp.add("CONTO=CONTO");
|
|
exp.add("SOTTOCONTO=SOTTOCONTO");
|
|
_rel->add(LF_RMOV,exp,2,LF_PCON);
|
|
|
|
_cur1=add_cursor(new TCursor(_rel,"((CONTO!=\"\")&&(SOTTOCONTO!=\"\"))",1));
|
|
|
|
_rel_clifo = new TRelation (LF_CLIFO);
|
|
|
|
exp1.add("GRUPPO=GRUPPO");
|
|
exp1.add("CONTO=CONTO");
|
|
exp1.add("SOTTOCONTO=CODCF");
|
|
_rel_clifo->add(LF_RMOV,exp1,2,LF_CLIFO);
|
|
|
|
_cur2=add_cursor(new TCursor(_rel_clifo,"TIPOCF=\"C\"",3));
|
|
|
|
_cur3=add_cursor(new TCursor(_rel_clifo,"TIPOCF=\"F\"",3));
|
|
|
|
_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_ANNO, our_handler);
|
|
|
|
_inizio_stampa = TRUE;
|
|
}
|
|
|
|
void CG3200_application::user_destroy()
|
|
{
|
|
delete _msk;
|
|
delete _rel;
|
|
delete _rel_clifo;
|
|
delete _mov;
|
|
delete _nditte;
|
|
delete _unloc;
|
|
delete _comuni;
|
|
delete _clifo;
|
|
delete _caus;
|
|
delete _tabivd;
|
|
delete _tabtpd;
|
|
delete _tabreg;
|
|
delete _tabesc;
|
|
|
|
}
|
|
|
|
int cg3200(int argc, char* argv[])
|
|
{
|
|
|
|
CG3200_application a;
|
|
|
|
a.run(argc, argv, "Stampa Mastrini");
|
|
|
|
return 0;
|
|
}
|
|
|
|
|
|
|
|
|
|
|