3174 lines
96 KiB
C++
Executable File
3174 lines
96 KiB
C++
Executable File
//Stampa bilanci
|
|
|
|
#include <config.h>
|
|
#include <mask.h>
|
|
#include <progind.h>
|
|
#include <printapp.h>
|
|
#include <sort.h>
|
|
#include <tabutil.h>
|
|
#include <utility.h>
|
|
|
|
#include <mov.h>
|
|
#include <rmov.h>
|
|
#include <rmoviva.h>
|
|
#include <pconti.h>
|
|
#include <comuni.h>
|
|
#include <clifo.h>
|
|
#include <attiv.h>
|
|
#include <causali.h>
|
|
#include <saldi.h>
|
|
#include <nditte.h>
|
|
#include <anagr.h>
|
|
|
|
#include "cglib.h"
|
|
#include "cg1.h"
|
|
#include "cg1500.h"
|
|
|
|
bool mask_data_da (TMask_field& f, KEY k);
|
|
bool mask_data_a (TMask_field& f, KEY k);
|
|
bool mask_datalim (TMask_field& f, KEY k);
|
|
bool my_handler (TMask_field& f, KEY k);
|
|
|
|
class CG1500_application : public TPrintapp
|
|
{
|
|
friend bool mask_data_da (TMask_field& f, KEY k);
|
|
friend bool mask_data_a (TMask_field& f, KEY k);
|
|
friend bool mask_datalim (TMask_field& f, KEY k);
|
|
friend bool my_handler (TMask_field& f, KEY k);
|
|
|
|
struct cli_for
|
|
{
|
|
char tipocf;
|
|
char gruppo[4];
|
|
char conto[4];
|
|
char codcf[7];
|
|
char ragsoc[51];
|
|
real saldodare;
|
|
real saldoavere;
|
|
real movdare;
|
|
real movavere;
|
|
real saldofinale;
|
|
};
|
|
|
|
cli_for* _cf;
|
|
TSort * _sort;
|
|
const char* _buff;
|
|
|
|
TRelation* _rel;
|
|
TCursor * _cur;
|
|
TProgind * _prog;
|
|
TClifo_list* _listacf, * _lista;
|
|
TLocalisamfile* _com, * _pcn, * _mov, * _rmov, * _clifo, * _saldi, * _nditte,* _anag;
|
|
TIsamtempfile * _tmp_saldi_att, * _tmp_saldi_pass, * _tmp_saldi_conti_uno;
|
|
TIsamtempfile * _tmp_saldi_costi, * _tmp_saldi_ricavi,* _tmp_saldi_conti_due;
|
|
TTable* _esc;
|
|
|
|
TString _cofi,_cap,_paiva,_ragsoc,_comunefis,_provfis,_viafis,_tipoc_succ;
|
|
TString _descr_dare, _descr_avere, _gc_corr_dare, _gc_corr_avere, _descr;
|
|
TString _gc_prec_dare, _gc_prec_avere, _situazione, _descr_succ, _tipo_conto;
|
|
|
|
int _annoes, _bilancio, _tipo_stampa, _tipo_stampa1,_stampa_width,_gp,_cp,_i;
|
|
int _eof1, _eof2, _gruppo_dare, _gruppo_avere, _conto_dare, _conto_avere;
|
|
int _add_file_da, _add_file_a, _indbil_dare, _indbil_avere, _indbil;
|
|
int _eof3, _eof4, _eof5, _eof6, _verifica, _stampac, _stampav, _ordinamento;
|
|
int _gruppo, _conto, _gruppo_succ, _conto_succ;
|
|
long _sottoconto_dare, _sottoconto_avere, _sottoconto, _sottoconto_succ;
|
|
|
|
real _saldo_dare, _saldo_avere, _gruppo_a, _gruppo_da, _conto_a;
|
|
real _conto_da, _tot_dare, _tot_avere, _mov_periodo_dare, _saldo_ini_dare;
|
|
real _mov_periodo_avere, _saldo_ini_avere, _prg_prec_dare, _prg_prec_avere;
|
|
real _saldo_ini_conto_dare, _saldo_ini_conto_avere, _saldoini_dare;
|
|
real _saldoini_avere, _mov_dare, _mov_avere, _saldofinale;
|
|
real _saldoini_dare_succ, _saldoini_avere_succ, _mov_dare_succ;
|
|
real _mov_avere_succ, _saldofinale_succ;
|
|
real _saldo_dare_tot, _saldo_avere_tot, _mov_dare_tot, _mov_avere_tot;
|
|
real _saldo_finale_tot, _saldo_ini_gruppo_dare, _saldo_ini_gruppo_avere;
|
|
|
|
TDate _datalim, _data, _datada, _dataa, _dataini, _ultima_data;
|
|
bool _competenza, _cambiato_conto_1, _cambiato_conto_2, _add_file_avere;
|
|
bool _add_file_dare, _prima_volta, _seconda_volta, _totali, _codici, _saldo;
|
|
bool _add_dare, _add_avere, _controlla, _salto_pagina, _flag, _stampato;
|
|
bool _sottoc_dare, _sottoc_avere, _salto_pagina1, _livello_conto;
|
|
bool _stampa_mov_prov;
|
|
TString _causale_ap, _causale_chi;
|
|
|
|
public:
|
|
|
|
bool menu (MENU_TAG m) { return TPrintapp::menu(m) ; }
|
|
void user_create() ;
|
|
void user_destroy();
|
|
bool set_print(int);
|
|
|
|
virtual bool preprocess_print(int,int);
|
|
virtual void preprocess_header();
|
|
virtual bool preprocess_page(int,int);
|
|
virtual print_action postprocess_page(int,int);
|
|
virtual print_action postprocess_print(int,int);
|
|
virtual void set_page(int,int);
|
|
|
|
const char* causale_chiusura_es() { return _causale_chi;}
|
|
bool causale_chiusura(long);
|
|
const char* causale_apertura_es() { return _causale_ap;}
|
|
bool causale_apertura(long);
|
|
bool bil_sez_contr();
|
|
bool bil_verifica();
|
|
bool situazione_clifo();
|
|
bool ricerca_sottoc_clifo(int,int,char,bool,int,real&,const TDate&,
|
|
const TDate&,const TDate&);
|
|
bool ricerca_cf(int,int,char,real&,real&,real&,real&,real&,real&,real&,
|
|
const TDate&,const TDate&);
|
|
bool calcola(int,int,long,const TDate&,const TDate&);
|
|
void crea_sort_clifo();
|
|
void init_sort();
|
|
void leggi_sort();
|
|
void riempi_record(const char*,int,int,long,const char*,const real&,
|
|
const real&,const real&,const real&,const real&);
|
|
void get_dati_ditta();
|
|
void scrivi_record_conto(const real&,const real&,const real&,
|
|
const real&, const real&);
|
|
void scrivi_record_gruppo(const real&,const real&,const real&,
|
|
const real&, const real&);
|
|
int stampa_record_conto(int,int,const char*,const real&,const real&,
|
|
const real&,const real&,const real&,const TString&);
|
|
int stampa_intestazione_ditta();
|
|
int cerca_indbil(int,int);
|
|
void scrivig_file_temp();
|
|
void scrivic_file_temp();
|
|
void scrivis_file_temp(int,int,long,real);
|
|
void leggi_files_dare (TIsamtempfile*);
|
|
void leggi_files_avere(TIsamtempfile*);
|
|
void leggi_file_tmp();
|
|
void stampa_riga_totali(int);
|
|
void stampa_prima_colonna(int,int,long,const char*,const real&);
|
|
void stampa_seconda_colonna(int,int,long,const char*,const real&);
|
|
void stampa_totali();
|
|
void controlla_conto_uno(int,int);
|
|
//void controlla_conto_due();
|
|
const char* DescrizioneConto(int,int,long,const char*);
|
|
TDate UltimaData(int,int,long,int);
|
|
|
|
CG1500_application() {}
|
|
};
|
|
|
|
TDate InizioEsercizio(int anno)
|
|
{
|
|
TTable TabEs ("ESC");
|
|
TString codtab;
|
|
TDate inizio_es;
|
|
|
|
TabEs.zero();
|
|
codtab.format ("%04d", anno);
|
|
TabEs.put ("CODTAB", codtab);
|
|
TabEs.read();
|
|
if (TabEs.good())
|
|
inizio_es= TabEs.get_date ("D0");
|
|
|
|
return inizio_es;
|
|
}
|
|
|
|
TDate FineEsercizio(int anno)
|
|
{
|
|
TTable TabEs ("ESC");
|
|
TString codtab;
|
|
TDate fine_es;
|
|
|
|
TabEs.zero();
|
|
codtab.format ("%04d", anno);
|
|
TabEs.put ("CODTAB", codtab);
|
|
TabEs.read();
|
|
if (TabEs.good())
|
|
fine_es= TabEs.get_date ("D1");
|
|
|
|
return fine_es;
|
|
}
|
|
|
|
bool IsEsercizioA (TDate a, int anno)
|
|
{
|
|
TTable TabEs ("ESC");
|
|
TString codtab;
|
|
|
|
if ( !a.ok() ) return FALSE;
|
|
|
|
TabEs.zero();
|
|
|
|
codtab.format ("%04d", anno);
|
|
TabEs.put ("CODTAB", codtab);
|
|
TabEs.read();
|
|
if (TabEs.good())
|
|
{
|
|
TDate fine (TabEs.get_date ("D1"));
|
|
if (fine.ok() && a <= fine)
|
|
return TRUE;
|
|
}
|
|
return FALSE;
|
|
}
|
|
|
|
bool IsEsercizioDa (TDate da, int anno)
|
|
{
|
|
TTable TabEs ("ESC");
|
|
TString codtab;
|
|
|
|
if ( !da.ok() ) return FALSE;
|
|
|
|
TabEs.zero();
|
|
|
|
codtab.format ("%04d", anno);
|
|
TabEs.put ("CODTAB", codtab);
|
|
TabEs.read();
|
|
if (TabEs.good())
|
|
{
|
|
TDate inizio (TabEs.get_date ("D0"));
|
|
if (da.ok() && da >= inizio)
|
|
return TRUE;
|
|
}
|
|
return FALSE;
|
|
}
|
|
|
|
bool IsEsercizio (const TDate& datalim, int anno_eser, int anno_eser_prec)
|
|
{
|
|
TTable TabEs ("ESC");
|
|
TString codtab;
|
|
TDate inizio,fine;
|
|
|
|
TabEs.zero();
|
|
|
|
codtab.format ("%04d", anno_eser_prec);
|
|
TabEs.put ("CODTAB", codtab);
|
|
TabEs.read();
|
|
if (TabEs.good())
|
|
inizio = TabEs.get_date ("D0");
|
|
|
|
TabEs.zero();
|
|
|
|
codtab.format ("%04d", anno_eser);
|
|
TabEs.put ("CODTAB", codtab);
|
|
TabEs.read();
|
|
if (TabEs.good())
|
|
fine = TabEs.get_date ("D1");
|
|
|
|
if (datalim.ok() && datalim >= inizio && datalim <= fine)
|
|
return TRUE;
|
|
|
|
return FALSE;
|
|
}
|
|
|
|
TDate Controllo_data_limite(const TDate& datalim, int anno_eser, int anno_eser_prec)
|
|
{
|
|
TTable TabEs ("ESC");
|
|
TString codtab;
|
|
TDate data;
|
|
TDate inizio_es_prec, inizio_es_corr;
|
|
|
|
TabEs.zero();
|
|
|
|
codtab.format ("%04d", anno_eser_prec);
|
|
TabEs.put ("CODTAB", codtab);
|
|
TabEs.read();
|
|
if (TabEs.good())
|
|
inizio_es_prec = TabEs.get_date ("D0");
|
|
|
|
TabEs.zero();
|
|
|
|
codtab.format ("%04d", anno_eser);
|
|
TabEs.put ("CODTAB", codtab);
|
|
TabEs.read();
|
|
if (TabEs.good())
|
|
inizio_es_corr = TabEs.get_date ("D0");
|
|
|
|
if (datalim >= inizio_es_corr)
|
|
data = inizio_es_corr;
|
|
else if (datalim >= inizio_es_prec)
|
|
data = inizio_es_prec;
|
|
|
|
return data;
|
|
}
|
|
|
|
void CG1500_application::scrivig_file_temp()
|
|
{
|
|
if (_add_dare)
|
|
{
|
|
if ( (_indbil==1)||(_indbil==2) )
|
|
{
|
|
_tmp_saldi_att->zero();
|
|
_tmp_saldi_att->put(SLD_GRUPPO,_gp);
|
|
_tmp_saldi_att->put(SLD_CONTO,0);
|
|
_tmp_saldi_att->put(SLD_SOTTOCONTO,0L);
|
|
_tmp_saldi_att->put(SLD_PDARE,_gruppo_da);//da stampare a sx
|
|
_tmp_saldi_att->write();
|
|
}
|
|
if ( (_indbil==3)||(_indbil==4) )
|
|
{
|
|
_tmp_saldi_costi->zero();
|
|
_tmp_saldi_costi->put(SLD_GRUPPO,_gp);
|
|
_tmp_saldi_costi->put(SLD_CONTO,0);
|
|
_tmp_saldi_costi->put(SLD_SOTTOCONTO,0L);
|
|
_tmp_saldi_costi->put(SLD_PDARE,_gruppo_da);//da stampare a sx
|
|
_tmp_saldi_costi->write();
|
|
}
|
|
if (_indbil==5)
|
|
{
|
|
_tmp_saldi_conti_uno->zero();
|
|
_tmp_saldi_conti_uno->put(SLD_GRUPPO,_gp);
|
|
_tmp_saldi_conti_uno->put(SLD_CONTO,0);
|
|
_tmp_saldi_conti_uno->put(SLD_SOTTOCONTO,0L);
|
|
_tmp_saldi_conti_uno->put(SLD_PDARE,_gruppo_da);
|
|
_tmp_saldi_conti_uno->write();
|
|
}
|
|
}
|
|
if (_add_avere)
|
|
{
|
|
if ( (_indbil==2)||(_indbil==1) )
|
|
{
|
|
_tmp_saldi_pass->zero();
|
|
_tmp_saldi_pass->put(SLD_GRUPPO,_gp);
|
|
_tmp_saldi_pass->put(SLD_CONTO,0);
|
|
_tmp_saldi_pass->put(SLD_SOTTOCONTO,0L);
|
|
_tmp_saldi_pass->put(SLD_PAVERE,_gruppo_a);//da stampare a dx
|
|
_tmp_saldi_pass->write();
|
|
}
|
|
if ( (_indbil==4)||(_indbil==3) )
|
|
{
|
|
_tmp_saldi_ricavi->zero();
|
|
_tmp_saldi_ricavi->put(SLD_GRUPPO,_gp);
|
|
_tmp_saldi_ricavi->put(SLD_CONTO,0);
|
|
_tmp_saldi_ricavi->put(SLD_SOTTOCONTO,0L);
|
|
_tmp_saldi_ricavi->put(SLD_PAVERE,_gruppo_a);//da stampare a dx
|
|
_tmp_saldi_ricavi->write();
|
|
}
|
|
if (_indbil==5)
|
|
{
|
|
_tmp_saldi_conti_due->zero();
|
|
_tmp_saldi_conti_due->put(SLD_GRUPPO,_gp);
|
|
_tmp_saldi_conti_due->put(SLD_CONTO,0);
|
|
_tmp_saldi_conti_due->put(SLD_SOTTOCONTO,0L);
|
|
_tmp_saldi_conti_due->put(SLD_PAVERE,_gruppo_a);
|
|
_tmp_saldi_conti_due->write();
|
|
}
|
|
}
|
|
_add_dare = _add_avere = FALSE;
|
|
}
|
|
|
|
void CG1500_application::scrivic_file_temp()
|
|
{
|
|
if (_add_file_dare)
|
|
{
|
|
_add_dare = TRUE;
|
|
if ( (_indbil==1)||(_indbil==2) )
|
|
{
|
|
_tmp_saldi_att->zero();
|
|
_tmp_saldi_att->put(SLD_GRUPPO,_gp);
|
|
_tmp_saldi_att->put(SLD_CONTO,_cp);
|
|
_tmp_saldi_att->put(SLD_SOTTOCONTO,0L);
|
|
_tmp_saldi_att->put(SLD_PDARE,_conto_da);
|
|
_tmp_saldi_att->write();
|
|
}
|
|
if ( (_indbil==3)||(_indbil==4) )
|
|
{
|
|
_tmp_saldi_costi->zero();
|
|
_tmp_saldi_costi->put(SLD_GRUPPO,_gp);
|
|
_tmp_saldi_costi->put(SLD_CONTO,_cp);
|
|
_tmp_saldi_costi->put(SLD_SOTTOCONTO,0L);
|
|
_tmp_saldi_costi->put(SLD_PDARE,_conto_da);
|
|
_tmp_saldi_costi->write();
|
|
}
|
|
if (_indbil==5)
|
|
{
|
|
_tmp_saldi_conti_uno->zero();
|
|
_tmp_saldi_conti_uno->put(SLD_GRUPPO,_gp);
|
|
_tmp_saldi_conti_uno->put(SLD_CONTO,_cp);
|
|
_tmp_saldi_conti_uno->put(SLD_SOTTOCONTO,0L);
|
|
_tmp_saldi_conti_uno->put(SLD_PDARE,_conto_da);
|
|
_tmp_saldi_conti_uno->write();
|
|
}
|
|
}
|
|
if (_add_file_avere)
|
|
{
|
|
_add_avere = TRUE;
|
|
if ( (_indbil==1)||(_indbil==2) )
|
|
{
|
|
_tmp_saldi_pass->zero();
|
|
_tmp_saldi_pass->put(SLD_GRUPPO,_gp);
|
|
_tmp_saldi_pass->put(SLD_CONTO,_cp);
|
|
_tmp_saldi_pass->put(SLD_SOTTOCONTO,0L);
|
|
_tmp_saldi_pass->put(SLD_PAVERE,_conto_a);
|
|
_tmp_saldi_pass->write();
|
|
}
|
|
if ( (_indbil==3)||(_indbil==4) )
|
|
{
|
|
_tmp_saldi_ricavi->zero();
|
|
_tmp_saldi_ricavi->put(SLD_GRUPPO,_gp);
|
|
_tmp_saldi_ricavi->put(SLD_CONTO,_cp);
|
|
_tmp_saldi_ricavi->put(SLD_SOTTOCONTO,0L);
|
|
_tmp_saldi_ricavi->put(SLD_PAVERE,_conto_a);
|
|
_tmp_saldi_ricavi->write();
|
|
}
|
|
if (_indbil==5)
|
|
{
|
|
_tmp_saldi_conti_due->zero();
|
|
_tmp_saldi_conti_due->put(SLD_GRUPPO,_gp);
|
|
_tmp_saldi_conti_due->put(SLD_CONTO,_cp);
|
|
_tmp_saldi_conti_due->put(SLD_SOTTOCONTO,0L);
|
|
_tmp_saldi_conti_due->put(SLD_PAVERE,_conto_a);
|
|
_tmp_saldi_conti_due->write();
|
|
}
|
|
}
|
|
}
|
|
|
|
void CG1500_application::scrivis_file_temp(int g, int c, long s, real saldo)
|
|
{
|
|
if (_indbil==1)
|
|
{
|
|
_tmp_saldi_att->zero();
|
|
_tmp_saldi_att->put(SLD_GRUPPO,g);
|
|
_tmp_saldi_att->put(SLD_CONTO,c);
|
|
_tmp_saldi_att->put(SLD_SOTTOCONTO,s);
|
|
_tmp_saldi_att->put(SLD_PDARE,saldo);
|
|
_tmp_saldi_att->write();
|
|
}
|
|
if (_indbil==2)
|
|
{
|
|
_tmp_saldi_pass->zero();
|
|
_tmp_saldi_pass->put(SLD_GRUPPO,g);
|
|
_tmp_saldi_pass->put(SLD_CONTO,c);
|
|
_tmp_saldi_pass->put(SLD_SOTTOCONTO,s);
|
|
_tmp_saldi_pass->put(SLD_PAVERE,saldo);
|
|
_tmp_saldi_pass->write();
|
|
}
|
|
if (_indbil==3)
|
|
{
|
|
_tmp_saldi_costi->zero();
|
|
_tmp_saldi_costi->put(SLD_GRUPPO,g);
|
|
_tmp_saldi_costi->put(SLD_CONTO,c);
|
|
_tmp_saldi_costi->put(SLD_SOTTOCONTO,s);
|
|
_tmp_saldi_costi->put(SLD_PDARE,saldo);
|
|
_tmp_saldi_costi->write();
|
|
}
|
|
if (_indbil==4)
|
|
{
|
|
_tmp_saldi_ricavi->zero();
|
|
_tmp_saldi_ricavi->put(SLD_GRUPPO,g);
|
|
_tmp_saldi_ricavi->put(SLD_CONTO,c);
|
|
_tmp_saldi_ricavi->put(SLD_SOTTOCONTO,s);
|
|
_tmp_saldi_ricavi->put(SLD_PAVERE,saldo);
|
|
_tmp_saldi_ricavi->write();
|
|
}
|
|
if (_sottoc_dare)
|
|
{
|
|
_tmp_saldi_conti_uno->zero();
|
|
_tmp_saldi_conti_uno->put(SLD_GRUPPO,g);
|
|
_tmp_saldi_conti_uno->put(SLD_CONTO,c);
|
|
_tmp_saldi_conti_uno->put(SLD_SOTTOCONTO,s);
|
|
_tmp_saldi_conti_uno->put(SLD_PDARE,saldo);
|
|
_tmp_saldi_conti_uno->write();
|
|
}
|
|
else if (_sottoc_avere)
|
|
{
|
|
_tmp_saldi_conti_due->zero();
|
|
_tmp_saldi_conti_due->put(SLD_GRUPPO,g);
|
|
_tmp_saldi_conti_due->put(SLD_CONTO,c);
|
|
_tmp_saldi_conti_due->put(SLD_SOTTOCONTO,s);
|
|
_tmp_saldi_conti_due->put(SLD_PAVERE,saldo);
|
|
_tmp_saldi_conti_due->write();
|
|
}
|
|
}
|
|
|
|
bool CG1500_application::bil_sez_contr()
|
|
{
|
|
Saldo sld;
|
|
TDate datai, fine_es, fine_es_prec;
|
|
int indbil_conto=0;
|
|
int g, c;
|
|
long s;
|
|
char tipo_conto = ' ';
|
|
real saldo;
|
|
bool compensa=FALSE, dettaglio=FALSE, cambiato=FALSE;
|
|
bool esiste_conto=FALSE, esiste_sc = FALSE;
|
|
|
|
_tmp_saldi_att->open("cg01");
|
|
_tmp_saldi_pass->open("cg02");
|
|
_prog->addstatus(1);
|
|
_tmp_saldi_costi->open("cg03");
|
|
_tmp_saldi_ricavi->open("cg04");
|
|
_prog->addstatus(1);
|
|
_tmp_saldi_conti_uno->open("cg05");
|
|
_tmp_saldi_conti_due->open("cg06");
|
|
|
|
_gp=-1;
|
|
_cp=-1;
|
|
_gruppo_a = 0.00;
|
|
_gruppo_da = 0.00;
|
|
_conto_a = 0.00;
|
|
_conto_da = 0.00;
|
|
_add_dare = FALSE;
|
|
_add_avere = FALSE;
|
|
|
|
datai = Controllo_data_limite(_datalim, _annoes, _annoes-1);
|
|
fine_es = FineEsercizio(_annoes);
|
|
fine_es_prec = FineEsercizio(_annoes-1);
|
|
|
|
for (_pcn->first(); !_pcn->eof(); _pcn->next())
|
|
{
|
|
_prog->addstatus(1);
|
|
g = _pcn->get_int (PCN_GRUPPO);
|
|
c = _pcn->get_int (PCN_CONTO);
|
|
s = _pcn->get_long(PCN_SOTTOCONTO);
|
|
|
|
if (c != _cp)
|
|
cambiato = TRUE;
|
|
|
|
if ( (((_cp != -1) && (c != _cp)) || ((_gp != -1) && (g != _gp))) &&
|
|
esiste_sc )
|
|
{
|
|
scrivic_file_temp();
|
|
_cp = c;
|
|
esiste_conto = TRUE;
|
|
_conto_da = 0.00;
|
|
_conto_a = 0.00;
|
|
}
|
|
|
|
if ( ((_gp != -1) && (g != _gp)) && esiste_conto )
|
|
{
|
|
scrivig_file_temp();
|
|
esiste_conto = FALSE;
|
|
_gp = g;
|
|
_gruppo_da = 0.00;
|
|
_gruppo_a = 0.00;
|
|
}
|
|
|
|
if (cambiato)
|
|
{
|
|
_add_file_avere = FALSE;
|
|
_add_file_dare = FALSE;
|
|
cambiato = FALSE;
|
|
}
|
|
|
|
if ( (s == 0) && (c != 0) ) //si tratta di un conto
|
|
{
|
|
compensa = _pcn->get_bool(PCN_COMPENS);
|
|
indbil_conto = _pcn->get_int (PCN_INDBIL);
|
|
dettaglio = _pcn->get_bool(PCN_STSOTTBIL);
|
|
tipo_conto = _pcn->get(PCN_TMCF)[0];
|
|
if ( (tipo_conto == 'C') || (tipo_conto == 'F') )
|
|
{
|
|
saldo = 0;
|
|
esiste_sc = ricerca_sottoc_clifo(g, c, tipo_conto, compensa,
|
|
indbil_conto, saldo, fine_es, fine_es_prec, datai);
|
|
if (esiste_sc)
|
|
{
|
|
_gp = g;
|
|
_cp = c;
|
|
}
|
|
TRecnotype recnum = _pcn->recno();
|
|
_pcn->next();
|
|
if (_pcn->eof())
|
|
{
|
|
if (esiste_sc)
|
|
{
|
|
scrivic_file_temp();
|
|
scrivig_file_temp();
|
|
}
|
|
else if (esiste_conto)
|
|
scrivig_file_temp();
|
|
}
|
|
_pcn->readat(recnum);
|
|
|
|
continue;
|
|
}
|
|
}
|
|
|
|
if ( (c == 0) || (s == 0) ) //si tratta di un conto o di un gruppo
|
|
{
|
|
esiste_sc = FALSE;
|
|
continue;
|
|
}
|
|
|
|
if (_tipo_stampa == 1) //bil. a sez. contrapposte per data limite
|
|
{
|
|
if (!sld.calcola (_annoes,0,g,c,s,datai,_datalim,indbil_conto,_competenza,
|
|
_dataini,fine_es,fine_es_prec,_stampa_mov_prov)) continue;
|
|
else saldo = sld.saldo();
|
|
}
|
|
else if (_tipo_stampa == 2) //bil. a sez. contrapposte all'ultima immissione es. in corso
|
|
{
|
|
if (!sld.calcola (_annoes,0,g,c,s,"","",indbil_conto,FALSE,"","","",FALSE))
|
|
continue;
|
|
else saldo = sld.saldo();
|
|
}
|
|
else //bil. a sez. contrapposte all'ultima immissione es. precedente
|
|
{
|
|
if (!sld.calcola (_annoes,_annoes-1,g,c,s,"","",indbil_conto,FALSE,"",
|
|
"","",FALSE) ) continue;
|
|
else saldo = sld.saldo();
|
|
}
|
|
|
|
if (_saldo) //se richiesto di non stampare i conti con saldo a zero
|
|
if (saldo == 0)
|
|
continue;
|
|
|
|
esiste_sc = TRUE;
|
|
_indbil = indbil_conto;
|
|
|
|
//i due flag seguenti servono solo per i conti d'ordine
|
|
_sottoc_dare = FALSE;
|
|
_sottoc_avere = FALSE;
|
|
|
|
//error_box ("saldo = %s", saldo.string());
|
|
|
|
if (!compensa)
|
|
{
|
|
if ( (indbil_conto==1)||(indbil_conto==3) )
|
|
if (saldo > 0.00) //saldo in dare
|
|
_indbil = indbil_conto;
|
|
else //saldo in avere
|
|
{
|
|
if (indbil_conto == 1)
|
|
_indbil = 2;
|
|
else _indbil = 3;
|
|
saldo = saldo * (-1.0);
|
|
}
|
|
if ( (indbil_conto==2)||(indbil_conto==4) )
|
|
if (saldo < 0.00)
|
|
{
|
|
_indbil = indbil_conto;
|
|
saldo = saldo * (-1.0);
|
|
}
|
|
else
|
|
if (indbil_conto == 2)
|
|
_indbil = 1;
|
|
else _indbil = 4;
|
|
}
|
|
else //e' richiesta la compensazione
|
|
{
|
|
if ( (indbil_conto==1)||(indbil_conto==3) )
|
|
_indbil = indbil_conto;
|
|
if ( (indbil_conto==2)||(indbil_conto==4) )
|
|
{
|
|
_indbil = indbil_conto;
|
|
saldo = saldo * (-1.0);
|
|
}
|
|
}
|
|
|
|
if ( (_indbil==1) || (_indbil==3) )
|
|
{
|
|
_gruppo_da += saldo;
|
|
_conto_da += saldo;
|
|
_add_file_dare = TRUE;
|
|
}
|
|
|
|
if ( (_indbil==2) || (_indbil==4) )
|
|
{
|
|
_gruppo_a += saldo;
|
|
_conto_a += saldo;
|
|
_add_file_avere = TRUE;
|
|
}
|
|
|
|
if (_indbil==5)
|
|
if ( (saldo >= 0.00)||(compensa) )
|
|
{
|
|
_gruppo_da += saldo;
|
|
_conto_da += saldo;
|
|
_add_file_dare = TRUE;
|
|
_sottoc_dare = TRUE;
|
|
}
|
|
else
|
|
{
|
|
saldo = saldo * (-1.0);
|
|
_gruppo_a += saldo;
|
|
_conto_a += saldo;
|
|
_add_file_avere = TRUE;
|
|
_sottoc_avere = TRUE;
|
|
}
|
|
|
|
if ( (dettaglio) && ( (tipo_conto != 'C') && (tipo_conto != 'F') ) )
|
|
scrivis_file_temp(g, c, s, saldo);
|
|
|
|
_gp = g;
|
|
_cp = c;
|
|
|
|
TRecnotype recnum = _pcn->recno();
|
|
_pcn->next();
|
|
if (_pcn->eof())
|
|
{
|
|
scrivic_file_temp();
|
|
scrivig_file_temp();
|
|
}
|
|
_pcn->readat(recnum);
|
|
}
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
bool CG1500_application::ricerca_sottoc_clifo(int g,int c,char tipocf,bool compensa, int indbil_conto,real& saldo, const TDate& fines, const TDate& finesp, const TDate& datai)
|
|
{
|
|
Saldo sld;
|
|
_listacf = new TClifo_list(g, c, tipocf);
|
|
long s;
|
|
TRecnotype items = _listacf->items();
|
|
bool esiste_sc = FALSE;
|
|
|
|
for (int i = 0; i < items; i++)
|
|
{
|
|
const TRectype& r = _listacf->clifo(i);
|
|
s = r.get_long(CLI_CODCF);
|
|
|
|
if (_tipo_stampa == 1) //bil. a sez. contrapposte per data limite
|
|
{
|
|
if (!sld.calcola (_annoes,0,g,c,s,datai,_datalim,indbil_conto,_competenza,
|
|
_dataini,fines,finesp,_stampa_mov_prov)) continue;
|
|
else saldo = sld.saldo();
|
|
}
|
|
else if (_tipo_stampa == 2)
|
|
{
|
|
if (!sld.calcola (_annoes,0,g,c,s,"","",indbil_conto,FALSE,"","","",FALSE))
|
|
continue;
|
|
else saldo = sld.saldo();
|
|
}
|
|
else
|
|
{
|
|
if (!sld.calcola (_annoes,_annoes-1,g,c,s,"","",indbil_conto,FALSE,"",
|
|
"","",FALSE) ) continue;
|
|
else saldo = sld.saldo();
|
|
}
|
|
|
|
if (_saldo) //se richiesto di non stampare i conti con saldo a zero
|
|
if (saldo == 0)
|
|
continue;
|
|
|
|
esiste_sc = TRUE;
|
|
_indbil = indbil_conto;
|
|
|
|
//i due flag seguenti servono solo per i conti d'ordine
|
|
_sottoc_dare = FALSE;
|
|
_sottoc_avere = FALSE;
|
|
|
|
//error_box ("saldo = %s", saldo.string());
|
|
|
|
if (!compensa)
|
|
{
|
|
if ( (indbil_conto==1)||(indbil_conto==3) )
|
|
if (saldo > 0.00) //saldo in dare
|
|
_indbil = indbil_conto;
|
|
else //saldo in avere
|
|
{
|
|
if (indbil_conto == 1)
|
|
_indbil = 2;
|
|
else _indbil = 3;
|
|
saldo = saldo * (-1.0);
|
|
}
|
|
if ( (indbil_conto==2)||(indbil_conto==4) )
|
|
if (saldo < 0.00)
|
|
{
|
|
_indbil = indbil_conto;
|
|
saldo = saldo * (-1.0);
|
|
}
|
|
else
|
|
if (indbil_conto == 2)
|
|
_indbil = 1;
|
|
else _indbil = 4;
|
|
}
|
|
else //e' richiesta la compensazione
|
|
{
|
|
if ( (indbil_conto==1)||(indbil_conto==3) )
|
|
_indbil = indbil_conto;
|
|
if ( (indbil_conto==2)||(indbil_conto==4) )
|
|
{
|
|
_indbil = indbil_conto;
|
|
saldo = saldo * (-1.0);
|
|
}
|
|
}
|
|
|
|
if ( (_indbil==1) || (_indbil==3) )
|
|
{
|
|
_gruppo_da += saldo;
|
|
_conto_da += saldo;
|
|
_add_file_dare = TRUE;
|
|
}
|
|
|
|
if ( (_indbil==2) || (_indbil==4) )
|
|
{
|
|
_gruppo_a += saldo;
|
|
_conto_a += saldo;
|
|
_add_file_avere = TRUE;
|
|
}
|
|
|
|
if (_indbil==5)
|
|
if ( (saldo >= 0.00) || (compensa) ) // il sottoconto ha saldo in dare
|
|
{
|
|
_gruppo_da += saldo;
|
|
_conto_da += saldo;
|
|
_add_file_dare = TRUE;
|
|
_sottoc_dare = TRUE;
|
|
}
|
|
else //il sottoconto ha saldo in avere
|
|
{
|
|
saldo = saldo * (-1.0);
|
|
_gruppo_a += saldo;
|
|
_conto_a += saldo;
|
|
_add_file_avere = TRUE;
|
|
_sottoc_avere = TRUE;
|
|
}
|
|
}
|
|
delete _listacf;
|
|
return esiste_sc;
|
|
}
|
|
|
|
bool CG1500_application::calcola(int g, int c, long s,
|
|
const TDate& fine_es, const TDate& fine_es_prec)
|
|
{
|
|
TString sezione, provvis;
|
|
real importo;
|
|
int annoe;
|
|
long num_reg;
|
|
TDate data_rmv;
|
|
bool conto_mov = FALSE;
|
|
TLocalisamfile rmov(LF_RMOV);
|
|
TLocalisamfile mov(LF_MOV);
|
|
|
|
_mov_periodo_dare = 0.00;
|
|
_mov_periodo_avere = 0.00;
|
|
_prg_prec_dare = 0.00;
|
|
_prg_prec_avere = 0.00;
|
|
_saldo_ini_dare = 0.00;
|
|
_saldo_ini_avere = 0.00;
|
|
|
|
rmov.setkey(2);
|
|
rmov.zero();
|
|
rmov.put(RMV_GRUPPO,g);
|
|
if (c != 0)
|
|
rmov.put(RMV_CONTO,c);
|
|
if (s != 0)
|
|
rmov.put(RMV_SOTTOCONTO,s);
|
|
TRectype rec(rmov.curr());
|
|
|
|
rmov.read(_isgteq);
|
|
for ( ; !rmov.eof(); rmov.next())
|
|
{
|
|
if (rmov.curr() != rec) break;
|
|
|
|
annoe = rmov.get_int(RMV_ANNOES);
|
|
data_rmv = rmov.get_date(RMV_DATAREG);
|
|
num_reg = rmov.get_long(RMV_NUMREG);
|
|
|
|
mov.setkey(1);
|
|
mov.zero();
|
|
mov.put(MOV_NUMREG, num_reg);
|
|
mov.read();
|
|
if (mov.bad())
|
|
mov.zero();
|
|
provvis = mov.get(MOV_PROVVIS);
|
|
|
|
if ((!_stampa_mov_prov)&&(provvis.trim().not_empty())) //se non richiesto
|
|
continue; //stampa mov provv.
|
|
//li scarto
|
|
|
|
if (causale_chiusura(num_reg)) //la causale e' uguale a quella di chiusura
|
|
break;
|
|
|
|
sezione = rmov.get(RMV_SEZIONE);
|
|
importo = rmov.get_real(RMV_IMPORTO);
|
|
|
|
if (annoe != _annoes)
|
|
if (annoe != _annoes - 1)
|
|
continue;
|
|
|
|
if (importo == 0)
|
|
continue;
|
|
|
|
if (_competenza)
|
|
if (annoe == _annoes -1)
|
|
if (_dataa == fine_es)
|
|
if ( ((data_rmv > fine_es) || (data_rmv > fine_es_prec)) &&
|
|
(data_rmv <= fine_es) ) //viene stampato tra i mov del periodo
|
|
{
|
|
if (sezione == "D")
|
|
_mov_periodo_dare += importo;
|
|
else _mov_periodo_avere += importo;
|
|
}
|
|
|
|
//calcolo i movimenti del periodo
|
|
if ( (data_rmv >= _datada) && (data_rmv <= _dataa) )
|
|
if ( ((causale_apertura(num_reg))&&(_dataini != _datada)) ||
|
|
(!causale_apertura(num_reg)) )
|
|
{
|
|
conto_mov = TRUE;
|
|
if (sezione == "D")
|
|
_mov_periodo_dare += importo;
|
|
else _mov_periodo_avere += importo;
|
|
}
|
|
|
|
//il saldo inizio es. e' dato dall'importo dare - importo avere di quei movimenti che hanno causale == apertura e data reg >= data inizio es. e <= data limite sup.
|
|
if (_datada == _dataini) //calcolo il saldo iniziale
|
|
{
|
|
if (causale_apertura(num_reg))
|
|
{
|
|
if (sezione == "D")
|
|
_saldo_ini_dare += importo;
|
|
else _saldo_ini_avere += importo;
|
|
conto_mov = TRUE;
|
|
}
|
|
}
|
|
else if (_datada > _dataini) //calcolo i progressivi precedenti
|
|
if ( (data_rmv >= _dataini) && (data_rmv < _datada) )
|
|
{
|
|
if (sezione == "D")
|
|
_prg_prec_dare += importo;
|
|
else _prg_prec_avere += importo;
|
|
conto_mov = TRUE;
|
|
}
|
|
}
|
|
return conto_mov;
|
|
}
|
|
|
|
|
|
bool CG1500_application::causale_apertura(long nr)
|
|
{
|
|
TString codcaus;
|
|
TLocalisamfile mov (LF_MOV);
|
|
|
|
mov.zero();
|
|
mov.put (MOV_NUMREG,nr);
|
|
|
|
if (mov.read() == NOERR)
|
|
{
|
|
codcaus = mov.get(MOV_CODCAUS);
|
|
if (codcaus == causale_apertura_es())
|
|
return TRUE;
|
|
}
|
|
return FALSE;
|
|
}
|
|
|
|
bool CG1500_application::causale_chiusura(long nr)
|
|
{
|
|
TString codcaus;
|
|
TLocalisamfile mov (LF_MOV);
|
|
|
|
mov.zero();
|
|
mov.put (MOV_NUMREG,nr);
|
|
|
|
if (mov.read() == NOERR)
|
|
{
|
|
codcaus = mov.get(MOV_CODCAUS);
|
|
if (codcaus == causale_chiusura_es())
|
|
return TRUE;
|
|
}
|
|
return FALSE;
|
|
}
|
|
|
|
bool CG1500_application::bil_verifica()
|
|
{
|
|
Saldo sld;
|
|
TDate fine_es, fine_es_prec;
|
|
int g, c, indbil_conto = 0;
|
|
long s;
|
|
char tipo_conto = ' ';
|
|
real saldo_finale, saldo_conto, saldo_gruppo, saldo_iniziale;
|
|
real mov_conto_dare, mov_conto_avere, prg_conto_dare, prg_conto_avere;
|
|
real mov_gruppo_dare, mov_gruppo_avere, prg_gruppo_dare, prg_gruppo_avere;
|
|
bool esiste_conto = FALSE, esiste_sc = FALSE;
|
|
|
|
_tmp_saldi_att->open("cg01");
|
|
|
|
_gp=-1;
|
|
_cp=-1;
|
|
|
|
_saldo_ini_conto_dare = 0.00;
|
|
_saldo_ini_conto_avere = 0.00;
|
|
_saldo_ini_gruppo_dare = 0.00;
|
|
_saldo_ini_gruppo_avere = 0.00;
|
|
saldo_conto = 0.00;
|
|
mov_conto_dare = 0.00;
|
|
mov_conto_avere = 0.00;
|
|
prg_conto_dare = 0.00;
|
|
prg_conto_avere = 0.00;
|
|
saldo_gruppo = 0.00;
|
|
mov_gruppo_dare = 0.00;
|
|
mov_gruppo_avere = 0.00;
|
|
prg_gruppo_dare = 0.00;
|
|
prg_gruppo_avere = 0.00;
|
|
|
|
fine_es = FineEsercizio(_annoes);
|
|
fine_es_prec = FineEsercizio(_annoes-1);
|
|
|
|
for (_pcn->first(); !_pcn->eof(); _pcn->next())
|
|
{
|
|
_prog->addstatus(1);
|
|
g = _pcn->get_int (PCN_GRUPPO);
|
|
c = _pcn->get_int (PCN_CONTO);
|
|
s = _pcn->get_long(PCN_SOTTOCONTO);
|
|
|
|
if ( (((_cp != -1) && (c != _cp)) || ((_gp != -1) && (g != _gp))) &&
|
|
esiste_sc )
|
|
{
|
|
if (_verifica == 2)
|
|
if (!((_stampav == 2) && (saldo_conto == 0)))
|
|
{
|
|
real app = _saldo_ini_conto_dare + _saldo_ini_conto_avere;
|
|
if (app < 0.00)
|
|
_saldo_ini_gruppo_avere += app;
|
|
else
|
|
_saldo_ini_gruppo_dare += app;
|
|
mov_gruppo_dare += mov_conto_dare;
|
|
mov_gruppo_avere += mov_conto_avere;
|
|
prg_gruppo_dare += prg_conto_dare;
|
|
prg_gruppo_avere += prg_conto_avere;
|
|
saldo_gruppo += saldo_conto;
|
|
}
|
|
//scrivo il record del conto;
|
|
if ( (_verifica == 1)||( (_verifica == 2)&&
|
|
(!((_stampav == 2)&&(saldo_conto == 0))) ) )
|
|
{
|
|
scrivi_record_conto(prg_conto_dare,prg_conto_avere,mov_conto_dare,
|
|
mov_conto_avere,saldo_conto);
|
|
esiste_conto = TRUE;
|
|
}
|
|
_cp = c;
|
|
_saldo_ini_conto_dare = 0.00;
|
|
_saldo_ini_conto_avere = 0.00;
|
|
saldo_conto = 0.00;
|
|
mov_conto_dare = 0.00;
|
|
mov_conto_avere = 0.00;
|
|
prg_conto_dare = 0.00;
|
|
prg_conto_avere = 0.00;
|
|
}
|
|
if (_verifica == 2)
|
|
if ( ((_gp != -1) && (g != _gp)) && (!esiste_conto) )
|
|
{
|
|
_gp = g;
|
|
_saldo_ini_gruppo_dare = 0.00;
|
|
_saldo_ini_gruppo_avere = 0.00;
|
|
saldo_gruppo = 0.00;
|
|
mov_gruppo_dare = 0.00;
|
|
mov_gruppo_avere = 0.00;
|
|
prg_gruppo_dare = 0.00;
|
|
prg_gruppo_avere = 0.00;
|
|
}
|
|
if (_verifica == 2)
|
|
if ( ((_gp != -1) && (g != _gp)) && esiste_conto )
|
|
{
|
|
//scrivo il record del gruppo
|
|
scrivi_record_gruppo(prg_gruppo_dare,prg_gruppo_avere,mov_gruppo_dare,
|
|
mov_gruppo_avere,saldo_gruppo);
|
|
_gp = g;
|
|
esiste_conto = FALSE;
|
|
_saldo_ini_gruppo_dare = 0.00;
|
|
_saldo_ini_gruppo_avere = 0.00;
|
|
saldo_gruppo = 0.00;
|
|
mov_gruppo_dare = 0.00;
|
|
mov_gruppo_avere = 0.00;
|
|
prg_gruppo_dare = 0.00;
|
|
prg_gruppo_avere = 0.00;
|
|
}
|
|
if ( (s == 0) && (c != 0) ) //si tratta di un conto
|
|
{
|
|
tipo_conto = _pcn->get(PCN_TMCF)[0];
|
|
indbil_conto = _pcn->get_int(PCN_INDBIL);
|
|
if ( (tipo_conto == 'C') || (tipo_conto == 'F') )
|
|
{
|
|
esiste_sc = ricerca_cf(g,c,tipo_conto,saldo_finale,saldo_iniziale,
|
|
mov_conto_dare,mov_conto_avere,prg_conto_dare,prg_conto_avere,
|
|
saldo_conto,fine_es,fine_es_prec);
|
|
if ( (_verifica == 2) && (_stampav == 2) )
|
|
if (saldo_conto == 0)
|
|
continue;
|
|
if (esiste_sc)
|
|
{
|
|
_gp = g;
|
|
_cp = c;
|
|
TRecnotype recnum = _pcn->recno();
|
|
_pcn->next();
|
|
if (_pcn->eof())
|
|
{
|
|
if (_verifica == 2)
|
|
{
|
|
real app = _saldo_ini_conto_dare + _saldo_ini_conto_avere;
|
|
if (app < 0.00)
|
|
_saldo_ini_gruppo_avere += app;
|
|
else
|
|
_saldo_ini_gruppo_dare += app;
|
|
mov_gruppo_dare += mov_conto_dare;
|
|
mov_gruppo_avere += mov_conto_avere;
|
|
prg_gruppo_dare += prg_conto_dare;
|
|
prg_gruppo_avere += prg_conto_avere;
|
|
saldo_gruppo += saldo_conto;
|
|
|
|
scrivi_record_gruppo(prg_gruppo_dare,prg_gruppo_avere,
|
|
mov_gruppo_dare,mov_gruppo_avere,saldo_gruppo);
|
|
}
|
|
scrivi_record_conto(prg_conto_dare,prg_conto_avere,mov_conto_dare,
|
|
mov_conto_avere,saldo_conto);
|
|
}
|
|
_pcn->readat(recnum);
|
|
}
|
|
continue;
|
|
}
|
|
}
|
|
|
|
if ( (c == 0) || (s == 0) )
|
|
{
|
|
esiste_sc = FALSE;
|
|
continue;
|
|
}
|
|
|
|
saldo_finale = 0.00; //saldo finale relativo a ciascun sottoconto
|
|
_indbil = indbil_conto;
|
|
if (_tipo_stampa1 == 1) //bil. di verifica per data limite
|
|
{
|
|
if ( !calcola(g,c,s,fine_es,fine_es_prec) )//il conto non e' movimentato
|
|
if (_stampav == 1)
|
|
continue;
|
|
|
|
saldo_iniziale = _saldo_ini_dare - _saldo_ini_avere;
|
|
|
|
if (_datada == _dataini)
|
|
saldo_finale = saldo_iniziale+_mov_periodo_dare-_mov_periodo_avere;
|
|
else if (_datada > _dataini)
|
|
saldo_finale = _prg_prec_dare-_prg_prec_avere+_mov_periodo_dare-
|
|
_mov_periodo_avere;
|
|
if (saldo_finale == 0.00)
|
|
if (_stampav == 2)
|
|
continue;
|
|
|
|
//se saldo_finale < 0 verra' stampato con una A, se no con una D
|
|
}
|
|
else
|
|
{
|
|
int annoprec;
|
|
if (_tipo_stampa1 == 2) //all'ultima immissione es. in corso
|
|
annoprec = 0;
|
|
else annoprec = _annoes-1;
|
|
if (!sld.calcola(_annoes,annoprec,g,c,s,"","",indbil_conto,FALSE,"","","",FALSE))
|
|
if (_stampav == 1)
|
|
continue;
|
|
|
|
if (_tipo_stampa1 == 3) //all'ultima immissione es. precedente
|
|
saldo_iniziale = 0.00;
|
|
else saldo_iniziale = sld.saldoini();
|
|
|
|
_mov_periodo_dare = sld.prgdare();
|
|
_mov_periodo_avere = sld.prgavere();
|
|
_prg_prec_dare = 0.00;
|
|
_prg_prec_avere = 0.00;
|
|
|
|
saldo_finale = saldo_iniziale+_mov_periodo_dare-_mov_periodo_avere;
|
|
|
|
if (saldo_finale == 0.00)
|
|
if (_stampav == 2)
|
|
continue;
|
|
}
|
|
|
|
esiste_sc = TRUE;
|
|
|
|
if (saldo_iniziale < 0.00)
|
|
_saldo_ini_conto_avere += saldo_iniziale;
|
|
else
|
|
_saldo_ini_conto_dare += saldo_iniziale;
|
|
mov_conto_dare += _mov_periodo_dare;
|
|
mov_conto_avere += _mov_periodo_avere;
|
|
prg_conto_dare += _prg_prec_dare;
|
|
prg_conto_avere += _prg_prec_avere;
|
|
saldo_conto += saldo_finale; // somma algebrica!!!
|
|
|
|
//scrivo il record relat. al sottoconto se non e' richiesto saldi di mastro
|
|
if (_verifica != 2)
|
|
{
|
|
_tmp_saldi_att->zero();
|
|
_tmp_saldi_att->put(SLD_GRUPPO,g);
|
|
_tmp_saldi_att->put(SLD_CONTO,c);
|
|
_tmp_saldi_att->put(SLD_SOTTOCONTO,s);
|
|
_tmp_saldi_att->put(SLD_FLAGSALINI,tipo_conto);
|
|
if ( (_datada == _dataini) || (_tipo_stampa1 != 1) )
|
|
{
|
|
if (saldo_iniziale > 0.00) //va stampato in Dare
|
|
_tmp_saldi_att->put(SLD_PDARESCA,saldo_iniziale);
|
|
else if (saldo_iniziale < 0.00)
|
|
{
|
|
saldo_iniziale = saldo_iniziale * (-1.00);
|
|
_tmp_saldi_att->put(SLD_PAVERESCA,saldo_iniziale);
|
|
}
|
|
}
|
|
else if (_datada > _dataini)
|
|
{
|
|
_tmp_saldi_att->put(SLD_PDARESCA,_prg_prec_dare);
|
|
_tmp_saldi_att->put(SLD_PAVERESCA,_prg_prec_avere);
|
|
}
|
|
_tmp_saldi_att->put(SLD_PDARE,_mov_periodo_dare);
|
|
_tmp_saldi_att->put(SLD_PAVERE,_mov_periodo_avere);
|
|
_tmp_saldi_att->put(SLD_SALDO,saldo_finale);
|
|
_tmp_saldi_att->write();
|
|
}
|
|
|
|
_gp = g;
|
|
_cp = c;
|
|
|
|
TRecnotype recnum = _pcn->recno();
|
|
_pcn->next();
|
|
if (_pcn->eof())
|
|
{
|
|
if ( (_verifica == 2) && esiste_conto )
|
|
{
|
|
real app = _saldo_ini_conto_dare + _saldo_ini_conto_avere;
|
|
if (app < 0.00)
|
|
_saldo_ini_gruppo_avere += app;
|
|
else
|
|
_saldo_ini_gruppo_dare += app;
|
|
mov_gruppo_dare += mov_conto_dare;
|
|
mov_gruppo_avere += mov_conto_avere;
|
|
prg_gruppo_dare += prg_conto_dare;
|
|
prg_gruppo_avere += prg_conto_avere;
|
|
saldo_gruppo += saldo_conto;
|
|
|
|
scrivi_record_gruppo(prg_gruppo_dare,prg_gruppo_avere,
|
|
mov_gruppo_dare,mov_gruppo_avere,saldo_gruppo);
|
|
}
|
|
if ( (_verifica == 1)||( (_verifica == 2)&&
|
|
(!((_stampav == 2)&&(saldo_conto == 0))) ) )
|
|
scrivi_record_conto(prg_conto_dare,prg_conto_avere,mov_conto_dare,
|
|
mov_conto_avere,saldo_conto);
|
|
}
|
|
_pcn->readat(recnum);
|
|
}
|
|
return TRUE;
|
|
}
|
|
|
|
bool CG1500_application::ricerca_cf(int g,int c,char tipocf,real& saldo_finale,real& saldo_iniziale,
|
|
real& mov_conto_dare,real& mov_conto_avere,real& prg_conto_dare,real& prg_conto_avere,real& saldo_conto,
|
|
const TDate& fine_es,const TDate& fine_es_prec)
|
|
{
|
|
Saldo sld;
|
|
bool esiste_sc = FALSE;
|
|
_lista = new TClifo_list(g, c, tipocf);
|
|
long s;
|
|
TRecnotype items = _lista->items();
|
|
|
|
for (int i = 0; i < items; i++)
|
|
{
|
|
const TRectype& r = _lista->clifo(i);
|
|
s = r.get_long(CLI_CODCF);
|
|
|
|
saldo_finale = 0.00; //saldo finale relativo a ciascun sottoconto
|
|
|
|
if (_tipo_stampa1 == 1) //bil. di verifica per data limite
|
|
{
|
|
if ( !calcola(g,c,s,fine_es,fine_es_prec) )//il conto non e' movimentato
|
|
if (_stampav == 1)
|
|
continue;
|
|
|
|
saldo_iniziale = _saldo_ini_dare - _saldo_ini_avere;
|
|
|
|
if (_datada == _dataini)
|
|
saldo_finale = saldo_iniziale+_mov_periodo_dare-_mov_periodo_avere;
|
|
else if (_datada > _dataini)
|
|
saldo_finale = _prg_prec_dare-_prg_prec_avere+_mov_periodo_dare-
|
|
_mov_periodo_avere;
|
|
if (saldo_finale == 0.00)
|
|
if (_stampav == 2)
|
|
continue;
|
|
|
|
//se saldo_finale < 0 verra' stampato con una A, se no con una D
|
|
}
|
|
else
|
|
{
|
|
int annoprec;
|
|
if (_tipo_stampa1 == 2) //all'ultima immissione es. in corso
|
|
annoprec = 0;
|
|
else annoprec = _annoes-1;
|
|
if (!sld.calcola(_annoes,annoprec,g,c,s,"","",_indbil,FALSE,"","","",FALSE))
|
|
if (_stampav == 1)
|
|
continue;
|
|
|
|
if (_tipo_stampa1 == 3) //all'ultima immissione es. precedente
|
|
saldo_iniziale = 0.00;
|
|
else saldo_iniziale = sld.saldoini();
|
|
|
|
_mov_periodo_dare = sld.prgdare();
|
|
_mov_periodo_avere = sld.prgavere();
|
|
_prg_prec_dare = 0.00;
|
|
_prg_prec_avere = 0.00;
|
|
|
|
saldo_finale = saldo_iniziale+_mov_periodo_dare-_mov_periodo_avere;
|
|
|
|
if (saldo_finale == 0.00)
|
|
if (_stampav == 2)
|
|
continue;
|
|
}
|
|
|
|
esiste_sc = TRUE;
|
|
|
|
if (saldo_iniziale < 0.00)
|
|
_saldo_ini_conto_avere += saldo_iniziale;
|
|
else
|
|
_saldo_ini_conto_dare += saldo_iniziale;
|
|
mov_conto_dare += _mov_periodo_dare;
|
|
mov_conto_avere += _mov_periodo_avere;
|
|
prg_conto_dare += _prg_prec_dare;
|
|
prg_conto_avere += _prg_prec_avere;
|
|
saldo_conto += saldo_finale; // somma algebrica!!!
|
|
|
|
//scrivo il record relat. al sottoconto se non e' richiesto saldi di mastro
|
|
if (_verifica != 2)
|
|
{
|
|
_tmp_saldi_att->zero();
|
|
_tmp_saldi_att->put(SLD_GRUPPO,g);
|
|
_tmp_saldi_att->put(SLD_CONTO,c);
|
|
_tmp_saldi_att->put(SLD_SOTTOCONTO,s);
|
|
_tmp_saldi_att->put(SLD_FLAGSALINI,tipocf);
|
|
if ( (_datada == _dataini) || (_tipo_stampa1 != 1) )
|
|
{
|
|
if (saldo_iniziale > 0.00) //va stampato in Dare
|
|
_tmp_saldi_att->put(SLD_PDARESCA,saldo_iniziale);
|
|
else if (saldo_iniziale < 0.00)
|
|
{
|
|
saldo_iniziale = saldo_iniziale * (-1.00);
|
|
_tmp_saldi_att->put(SLD_PAVERESCA,saldo_iniziale);
|
|
}
|
|
}
|
|
else if (_datada > _dataini)
|
|
{
|
|
_tmp_saldi_att->put(SLD_PDARESCA,_prg_prec_dare);
|
|
_tmp_saldi_att->put(SLD_PAVERESCA,_prg_prec_avere);
|
|
}
|
|
_tmp_saldi_att->put(SLD_PDARE,_mov_periodo_dare);
|
|
_tmp_saldi_att->put(SLD_PAVERE,_mov_periodo_avere);
|
|
_tmp_saldi_att->put(SLD_SALDO,saldo_finale);
|
|
_tmp_saldi_att->write();
|
|
}
|
|
}
|
|
delete _lista;
|
|
return esiste_sc;
|
|
}
|
|
|
|
void CG1500_application::scrivi_record_gruppo(const real& prg_da,
|
|
const real& prg_a,const real& mov_da,const real& mov_a,const real& s)
|
|
{
|
|
_tmp_saldi_att->zero();
|
|
_tmp_saldi_att->put(SLD_GRUPPO,_gp);
|
|
_tmp_saldi_att->put(SLD_CONTO,0);
|
|
_tmp_saldi_att->put(SLD_SOTTOCONTO,0L);
|
|
if ( (_datada == _dataini) || (_tipo_stampa1 != 1) )
|
|
{
|
|
real app = _saldo_ini_gruppo_dare + _saldo_ini_gruppo_avere;
|
|
if (app > 0.00) //va stampato in Dare
|
|
_tmp_saldi_att->put(SLD_PDARESCA,app);
|
|
else if (app < 0.00)
|
|
{
|
|
app = app * (-1.00);
|
|
_tmp_saldi_att->put(SLD_PAVERESCA,app);
|
|
}
|
|
}
|
|
else if (_datada > _dataini)
|
|
{
|
|
_tmp_saldi_att->put(SLD_PDARESCA,prg_da);
|
|
_tmp_saldi_att->put(SLD_PAVERESCA,prg_a);
|
|
}
|
|
_tmp_saldi_att->put(SLD_PDARE,mov_da);
|
|
_tmp_saldi_att->put(SLD_PAVERE,mov_a);
|
|
_tmp_saldi_att->put(SLD_SALDO,s);
|
|
_tmp_saldi_att->write();
|
|
}
|
|
|
|
void CG1500_application::scrivi_record_conto(const real& prg_da,
|
|
const real& prg_a,const real& mov_da,const real& mov_a,const real& s)
|
|
{
|
|
_tmp_saldi_att->zero();
|
|
_tmp_saldi_att->put(SLD_GRUPPO,_gp);
|
|
_tmp_saldi_att->put(SLD_CONTO,_cp);
|
|
_tmp_saldi_att->put(SLD_SOTTOCONTO,0L);
|
|
if ( (_datada == _dataini) || (_tipo_stampa1 != 1) )
|
|
{
|
|
real app = _saldo_ini_conto_dare + _saldo_ini_conto_avere;
|
|
if (app > 0.00) //va stampato in Dare
|
|
_tmp_saldi_att->put(SLD_PDARESCA,app);
|
|
else if (app < 0.00)
|
|
{
|
|
app = app * (-1.00);
|
|
_tmp_saldi_att->put(SLD_PAVERESCA,app);
|
|
}
|
|
}
|
|
else if (_datada > _dataini)
|
|
{
|
|
_tmp_saldi_att->put(SLD_PDARESCA,prg_da);
|
|
_tmp_saldi_att->put(SLD_PAVERESCA,prg_a);
|
|
}
|
|
_tmp_saldi_att->put(SLD_PDARE,mov_da);
|
|
_tmp_saldi_att->put(SLD_PAVERE,mov_a);
|
|
_tmp_saldi_att->put(SLD_SALDO,s);
|
|
_tmp_saldi_att->write();
|
|
}
|
|
|
|
void CG1500_application::init_sort()
|
|
{
|
|
_cf = new cli_for;
|
|
_sort = new TSort(sizeof(cli_for));
|
|
|
|
_sort->addsortkey ((char*)&(_cf->tipocf)-(char*)&(_cf->tipocf),1);
|
|
_sort->addsortkey ((char*)&(_cf->gruppo)-(char*)&(_cf->tipocf),3);
|
|
_sort->addsortkey ((char*)&(_cf->conto)-(char*)&(_cf->tipocf),3);
|
|
_sort->addsortkey ((char*)&(_cf->ragsoc)-(char*)&(_cf->tipocf),50);
|
|
_sort->init();
|
|
}
|
|
|
|
void CG1500_application::riempi_record(const char* t,int g,int c,long s,
|
|
const char* rs,const real& sd,const real& sa,
|
|
const real& md,const real& ma,const real& sf)
|
|
{
|
|
_cf->tipocf = t[0];
|
|
sprintf(_cf->gruppo, "%03d", g);
|
|
sprintf(_cf->conto, "%03d", c);
|
|
sprintf(_cf->codcf, "%06ld", s);
|
|
sprintf(_cf->ragsoc, "%s", rs);
|
|
if (s == 0L)
|
|
{
|
|
if ( (_datada == _dataini)||(_tipo_stampa1 != 1) )
|
|
{
|
|
real app = _saldo_ini_conto_dare + _saldo_ini_conto_avere;
|
|
if (app > 0.00) //va stampato in Dare
|
|
_cf->saldodare = app;
|
|
else if (app < 0.00)
|
|
{
|
|
app = app * (-1.00);
|
|
_cf->saldoavere = app;
|
|
}
|
|
}
|
|
else if (_datada > _dataini)
|
|
{
|
|
_cf->saldodare = sd;
|
|
_cf->saldoavere = sa;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
_cf->saldodare = sd;
|
|
_cf->saldoavere = sa;
|
|
}
|
|
_cf->movdare = md;
|
|
_cf->movavere = ma;
|
|
_cf->saldofinale = sf;
|
|
_sort->sort((const char*)_cf);
|
|
}
|
|
|
|
void CG1500_application::crea_sort_clifo()
|
|
{
|
|
Saldo sld;
|
|
TDate fine_es, fine_es_prec;
|
|
int g=0, c=0;
|
|
long codcf=0l;
|
|
TString tipocf, tipocfp, ragsoc;
|
|
real saldo_finale, saldo_conto, saldo_iniziale, saldodare, saldoavere,
|
|
movdare, movavere;
|
|
real mov_conto_dare, mov_conto_avere, prg_conto_dare, prg_conto_avere;
|
|
bool esiste_sc=FALSE;
|
|
|
|
TRecnotype items = _cur->items();
|
|
|
|
_gp=-1;
|
|
_cp=-1;
|
|
tipocfp = "";
|
|
|
|
_saldo_ini_conto_dare = 0.00;
|
|
_saldo_ini_conto_avere = 0.00;
|
|
saldo_conto = 0.00;
|
|
mov_conto_dare = 0.00;
|
|
mov_conto_avere = 0.00;
|
|
prg_conto_dare = 0.00;
|
|
prg_conto_avere = 0.00;
|
|
|
|
fine_es = FineEsercizio(_annoes);
|
|
fine_es_prec = FineEsercizio(_annoes-1);
|
|
|
|
init_sort();
|
|
|
|
*_cur = 0l;
|
|
|
|
for (int i = 0; i < items; i++,++(*_cur))
|
|
{
|
|
_prog->addstatus(1);
|
|
g = _cur->curr().get_int (CLI_GRUPPO);
|
|
c = _cur->curr().get_int (CLI_CONTO);
|
|
codcf = _cur->curr().get_long(CLI_CODCF);
|
|
tipocf = _cur->curr().get(CLI_TIPOCF);
|
|
ragsoc = _cur->curr().get(CLI_RAGSOC);
|
|
|
|
if ( (((_cp != -1) && (c != _cp)) || ((_gp != -1) && (g != _gp))) &&
|
|
esiste_sc )
|
|
{
|
|
//scrivo il record del conto;
|
|
riempi_record(tipocfp,_gp,_cp,0l,"zzzz",prg_conto_dare,
|
|
prg_conto_avere,mov_conto_dare,mov_conto_avere,saldo_conto);
|
|
tipocfp = tipocf;
|
|
_cp = c;
|
|
esiste_sc = FALSE;
|
|
_saldo_ini_conto_dare = 0.00;
|
|
_saldo_ini_conto_avere = 0.00;
|
|
saldo_conto = 0.00;
|
|
mov_conto_dare = 0.00;
|
|
mov_conto_avere = 0.00;
|
|
prg_conto_dare = 0.00;
|
|
prg_conto_avere = 0.00;
|
|
}
|
|
|
|
saldo_finale = 0.00;
|
|
saldodare = 0.00;
|
|
saldoavere = 0.00;
|
|
movdare = 0.00;
|
|
movavere = 0.00;
|
|
|
|
if (_tipo_stampa1 == 1) //bilancio per data limite
|
|
{
|
|
if ( !calcola(g,c,codcf,fine_es,fine_es_prec) )//il conto non e' mov.
|
|
if (_stampac == 1)
|
|
continue;
|
|
|
|
saldo_iniziale = _saldo_ini_dare - _saldo_ini_avere;
|
|
|
|
if (_datada == _dataini)
|
|
saldo_finale = saldo_iniziale+_mov_periodo_dare-_mov_periodo_avere;
|
|
else if (_datada > _dataini)
|
|
saldo_finale = _prg_prec_dare-_prg_prec_avere+_mov_periodo_dare
|
|
-_mov_periodo_avere;
|
|
if (saldo_finale == 0.00)
|
|
if (_stampac == 2)
|
|
continue;
|
|
|
|
//se saldo_finale < 0 verra' stampato con una A, se no con una D
|
|
}
|
|
else
|
|
{
|
|
int annoprec;
|
|
if (_tipo_stampa1 == 2) //all'ultima immissione es. in corso
|
|
annoprec = 0;
|
|
else annoprec = _annoes-1;
|
|
_indbil = cerca_indbil(g,c);
|
|
if (!sld.calcola(_annoes,annoprec,g,c,codcf,"","",_indbil,FALSE,"","","",FALSE))
|
|
if (_stampac == 1)
|
|
continue;
|
|
if (_tipo_stampa1 == 3) //all'ultima immissione es. precedente
|
|
saldo_iniziale = 0.00;
|
|
else saldo_iniziale = sld.saldoini();
|
|
|
|
_mov_periodo_dare = sld.prgdare();
|
|
_mov_periodo_avere = sld.prgavere();
|
|
_prg_prec_dare = 0.00;
|
|
_prg_prec_avere = 0.00;
|
|
|
|
saldo_finale = saldo_iniziale+_mov_periodo_dare-_mov_periodo_avere;
|
|
|
|
if (saldo_finale == 0.00)
|
|
if (_stampac == 2)
|
|
continue;
|
|
}
|
|
|
|
esiste_sc = TRUE;
|
|
|
|
if (saldo_iniziale < 0.00)
|
|
_saldo_ini_conto_avere += saldo_iniziale;
|
|
else
|
|
_saldo_ini_conto_dare += saldo_iniziale;
|
|
mov_conto_dare += _mov_periodo_dare;
|
|
mov_conto_avere += _mov_periodo_avere;
|
|
prg_conto_dare += _prg_prec_dare;
|
|
prg_conto_avere += _prg_prec_avere;
|
|
saldo_conto += saldo_finale; // somma algebrica!!!
|
|
|
|
if ( (_datada == _dataini)||(_tipo_stampa1 != 1) )
|
|
{
|
|
if (saldo_iniziale > 0.00) //va stampato in Dare
|
|
saldodare = saldo_iniziale;
|
|
else if (saldo_iniziale < 0.00)
|
|
{
|
|
saldo_iniziale = saldo_iniziale * (-1.00);
|
|
saldoavere = saldo_iniziale;
|
|
}
|
|
}
|
|
else if (_datada > _dataini)
|
|
{
|
|
saldodare = _prg_prec_dare;
|
|
saldoavere = _prg_prec_avere;
|
|
}
|
|
movdare = _mov_periodo_dare;
|
|
movavere = _mov_periodo_avere;
|
|
|
|
riempi_record(tipocf,g,c,codcf,ragsoc,saldodare,saldoavere,movdare,
|
|
movavere,saldo_finale);
|
|
tipocfp = tipocf;
|
|
_gp = g;
|
|
_cp = c;
|
|
|
|
TRecnotype pos = _cur->pos();
|
|
bool finito = (pos == items - 1);
|
|
|
|
if (finito)
|
|
riempi_record(tipocfp,_gp,_cp,0L,"zzzz",prg_conto_dare,prg_conto_avere,
|
|
mov_conto_dare,mov_conto_avere,saldo_conto);
|
|
}
|
|
}
|
|
|
|
bool CG1500_application::situazione_clifo()
|
|
{
|
|
Saldo sld;
|
|
TDate fine_es, fine_es_prec;
|
|
int g=0, c=0;
|
|
long codcf=0l;
|
|
TString tipocf;
|
|
real saldo_finale, saldo_conto, saldo_iniziale;
|
|
real mov_conto_dare, mov_conto_avere, prg_conto_dare, prg_conto_avere;
|
|
bool esiste_sc=FALSE;
|
|
|
|
TRecnotype items = _cur->items();
|
|
|
|
_tmp_saldi_att->open("cg01");
|
|
|
|
_gp=-1;
|
|
_cp=-1;
|
|
|
|
_saldo_ini_conto_dare = 0.00;
|
|
_saldo_ini_conto_avere = 0.00;
|
|
saldo_conto = 0.00;
|
|
mov_conto_dare = 0.00;
|
|
mov_conto_avere = 0.00;
|
|
prg_conto_dare = 0.00;
|
|
prg_conto_avere = 0.00;
|
|
|
|
fine_es = FineEsercizio(_annoes);
|
|
fine_es_prec = FineEsercizio(_annoes-1);
|
|
|
|
*_cur = 0l;
|
|
|
|
for (int i = 0; i < items; i++,++(*_cur))
|
|
{
|
|
_prog->addstatus(1);
|
|
g = _cur->curr().get_int (CLI_GRUPPO);
|
|
c = _cur->curr().get_int (CLI_CONTO);
|
|
codcf = _cur->curr().get_long(CLI_CODCF);
|
|
tipocf = _cur->curr().get(CLI_TIPOCF);
|
|
|
|
if ( (((_cp != -1) && (c != _cp)) || ((_gp != -1) && (g != _gp))) &&
|
|
esiste_sc )
|
|
{
|
|
//scrivo il record del conto;
|
|
scrivi_record_conto(prg_conto_dare,prg_conto_avere,mov_conto_dare,
|
|
mov_conto_avere,saldo_conto);
|
|
_cp = c;
|
|
esiste_sc = FALSE;
|
|
_saldo_ini_conto_dare = 0.00;
|
|
_saldo_ini_conto_avere = 0.00;
|
|
saldo_conto = 0.00;
|
|
mov_conto_dare = 0.00;
|
|
mov_conto_avere = 0.00;
|
|
prg_conto_dare = 0.00;
|
|
prg_conto_avere = 0.00;
|
|
}
|
|
|
|
saldo_finale = 0.00; //saldo finale relativo a ciascun sottoconto
|
|
|
|
if (_tipo_stampa1 == 1) //bilancio per data limite
|
|
{
|
|
if ( !calcola(g,c,codcf,fine_es,fine_es_prec) )//il conto non e' movimentato
|
|
if (_stampac == 1)
|
|
continue;
|
|
|
|
saldo_iniziale = _saldo_ini_dare - _saldo_ini_avere;
|
|
|
|
if (_datada == _dataini)
|
|
saldo_finale = saldo_iniziale+_mov_periodo_dare-_mov_periodo_avere;
|
|
else if (_datada > _dataini)
|
|
saldo_finale = _prg_prec_dare-_prg_prec_avere+_mov_periodo_dare-
|
|
_mov_periodo_avere;
|
|
if (saldo_finale == 0.00)
|
|
if (_stampac == 2)
|
|
continue;
|
|
|
|
//se saldo_finale < 0 verra' stampato con una A, se no con una D
|
|
|
|
}
|
|
else
|
|
{
|
|
int annoprec;
|
|
if (_tipo_stampa1 == 2) //all'ultima immissione es. in corso
|
|
annoprec = 0;
|
|
else annoprec = _annoes-1;
|
|
_indbil = cerca_indbil(g,c);
|
|
if (!sld.calcola(_annoes,annoprec,g,c,codcf,"","",_indbil,FALSE,"","","",FALSE))
|
|
if (_stampac == 1)
|
|
continue;
|
|
if (_tipo_stampa1 == 3) //all'ultima immissione es. precedente
|
|
saldo_iniziale = 0.00;
|
|
else saldo_iniziale = sld.saldoini();
|
|
|
|
_mov_periodo_dare = sld.prgdare();
|
|
_mov_periodo_avere = sld.prgavere();
|
|
_prg_prec_dare = 0.00;
|
|
_prg_prec_avere = 0.00;
|
|
|
|
saldo_finale = saldo_iniziale+_mov_periodo_dare-_mov_periodo_avere;
|
|
|
|
if (saldo_finale == 0.00)
|
|
if (_stampac == 2)
|
|
continue;
|
|
}
|
|
|
|
esiste_sc = TRUE;
|
|
|
|
if (saldo_iniziale < 0.00)
|
|
_saldo_ini_conto_avere += saldo_iniziale;
|
|
else
|
|
_saldo_ini_conto_dare += saldo_iniziale;
|
|
mov_conto_dare += _mov_periodo_dare;
|
|
mov_conto_avere += _mov_periodo_avere;
|
|
prg_conto_dare += _prg_prec_dare;
|
|
prg_conto_avere += _prg_prec_avere;
|
|
saldo_conto += saldo_finale; // somma algebrica!!!
|
|
|
|
_tmp_saldi_att->zero();
|
|
_tmp_saldi_att->put(SLD_GRUPPO,g);
|
|
_tmp_saldi_att->put(SLD_CONTO,c);
|
|
_tmp_saldi_att->put(SLD_SOTTOCONTO,codcf);
|
|
_tmp_saldi_att->put(SLD_FLAGSALINI,tipocf);
|
|
if ( (_datada == _dataini)||(_tipo_stampa1 != 1) )
|
|
{
|
|
if (saldo_iniziale > 0.00) //va stampato in Dare
|
|
_tmp_saldi_att->put(SLD_PDARESCA,saldo_iniziale);
|
|
else if (saldo_iniziale < 0.00)
|
|
{
|
|
saldo_iniziale = saldo_iniziale * (-1.00);
|
|
_tmp_saldi_att ->put(SLD_PAVERESCA,saldo_iniziale);
|
|
}
|
|
}
|
|
else if (_datada > _dataini)
|
|
{
|
|
_tmp_saldi_att->put(SLD_PDARESCA,_prg_prec_dare);
|
|
_tmp_saldi_att->put(SLD_PAVERESCA,_prg_prec_avere);
|
|
}
|
|
_tmp_saldi_att->put(SLD_PDARE,_mov_periodo_dare);
|
|
_tmp_saldi_att->put(SLD_PAVERE,_mov_periodo_avere);
|
|
_tmp_saldi_att->put(SLD_SALDO,saldo_finale);
|
|
_tmp_saldi_att->write();
|
|
|
|
_gp = g;
|
|
_cp = c;
|
|
|
|
TRecnotype pos = _cur->pos();
|
|
bool finito = (pos == items - 1);
|
|
|
|
if (finito)
|
|
scrivi_record_conto(prg_conto_dare,prg_conto_avere,mov_conto_dare,
|
|
mov_conto_avere,saldo_conto);
|
|
}
|
|
return TRUE;
|
|
}
|
|
|
|
int CG1500_application::cerca_indbil(int g, int c)
|
|
{
|
|
TLocalisamfile pconti(LF_PCON);
|
|
|
|
pconti.zero();
|
|
pconti.put(PCN_GRUPPO,g);
|
|
if (c != 0)
|
|
pconti.put(PCN_CONTO,c);
|
|
pconti.put(PCN_SOTTOCONTO,0l);
|
|
|
|
pconti.read();
|
|
|
|
return pconti.get_int(PCN_INDBIL);
|
|
}
|
|
|
|
void CG1500_application::leggi_files_dare(TIsamtempfile* file)
|
|
{
|
|
_gruppo_dare = file->get_int(SLD_GRUPPO);
|
|
_conto_dare = file->get_int(SLD_CONTO);
|
|
_sottoconto_dare = file->get_long(SLD_SOTTOCONTO);
|
|
_saldo_dare = file->get_real(SLD_PDARE);
|
|
|
|
_descr_dare = DescrizioneConto(_gruppo_dare,_conto_dare,_sottoconto_dare,"");
|
|
|
|
_gc_corr_dare = format("%3d%3d", _gruppo_dare, _conto_dare);
|
|
|
|
if (_gc_corr_dare != _gc_prec_dare)
|
|
{
|
|
_cambiato_conto_1 = TRUE;
|
|
_gc_prec_dare = _gc_corr_dare;
|
|
}
|
|
else if (_sottoconto_dare != 0l)
|
|
_cambiato_conto_1 = FALSE;
|
|
}
|
|
|
|
void CG1500_application::leggi_files_avere(TIsamtempfile* file)
|
|
{
|
|
_gruppo_avere = file->get_int(SLD_GRUPPO);
|
|
_conto_avere = file->get_int(SLD_CONTO);
|
|
_sottoconto_avere = file->get_long(SLD_SOTTOCONTO);
|
|
_saldo_avere = file->get_real(SLD_PAVERE);
|
|
|
|
_descr_avere = DescrizioneConto(_gruppo_avere,_conto_avere,_sottoconto_avere,
|
|
"");
|
|
_gc_corr_avere = format("%3d%3d", _gruppo_avere, _conto_avere);
|
|
|
|
if (_gc_corr_avere != _gc_prec_avere)
|
|
{
|
|
_cambiato_conto_2 = TRUE;
|
|
_gc_prec_avere = _gc_corr_avere;
|
|
}
|
|
else if (_sottoconto_avere != 0l)
|
|
_cambiato_conto_2 = FALSE;
|
|
}
|
|
|
|
bool CG1500_application::preprocess_print(int file, int counter)
|
|
{
|
|
set_real_picture ("###.###.###.###");
|
|
if (_bilancio == 1)
|
|
{
|
|
set_print_zero();
|
|
_tmp_saldi_att->setkey(2);
|
|
_tmp_saldi_pass->setkey(2);
|
|
_tmp_saldi_costi->setkey(2);
|
|
_tmp_saldi_ricavi->setkey(2);
|
|
_tmp_saldi_conti_uno->setkey(2);
|
|
_tmp_saldi_conti_due->setkey(2);
|
|
_prima_volta = _seconda_volta = TRUE;
|
|
_flag = _controlla = FALSE;
|
|
_salto_pagina = _salto_pagina1 = _stampato = FALSE;
|
|
_cambiato_conto_1 = TRUE;
|
|
_cambiato_conto_2 = TRUE;
|
|
_tot_dare = 0.00;
|
|
_tot_avere = 0.00;
|
|
}
|
|
else
|
|
{
|
|
if ( (_verifica == 3) && (_ordinamento == 1) )
|
|
_tmp_saldi_att->setkey(2);
|
|
set_print_zero(FALSE);
|
|
_cambiato_conto_1 = FALSE;
|
|
_livello_conto = TRUE;
|
|
_saldo_dare_tot = 0.00;
|
|
_saldo_avere_tot = 0.00;
|
|
_mov_dare_tot = 0.00;
|
|
_mov_avere_tot = 0.00;
|
|
_saldo_finale_tot = 0.00;
|
|
}
|
|
return TRUE;
|
|
}
|
|
|
|
void CG1500_application::leggi_file_tmp()
|
|
{
|
|
if (_livello_conto) // era meglio chiamarla _livello_conto_oppure_gruppo, perche' nel caso dei saldi di mastro _livello_conto==TRUE <=> si tratta di un gruppo, mentre nel caso del bilancio _livello_conto==TRUE <=> si tratta di un conto
|
|
{
|
|
_gruppo = _tmp_saldi_att->get_int(SLD_GRUPPO);
|
|
_conto = _tmp_saldi_att->get_int(SLD_CONTO);
|
|
_sottoconto = _tmp_saldi_att->get_long(SLD_SOTTOCONTO);
|
|
_tipo_conto = _tmp_saldi_att->get(SLD_FLAGSALINI);
|
|
_descr = DescrizioneConto(_gruppo,_conto,_sottoconto,_tipo_conto);
|
|
_saldoini_dare = _tmp_saldi_att->get_real(SLD_PDARESCA);
|
|
_saldoini_avere = _tmp_saldi_att->get_real(SLD_PAVERESCA);
|
|
_mov_dare = _tmp_saldi_att->get_real(SLD_PDARE);
|
|
_mov_avere = _tmp_saldi_att->get_real(SLD_PAVERE);
|
|
_saldofinale = _tmp_saldi_att->get_real(SLD_SALDO);
|
|
}
|
|
_eof1 = _tmp_saldi_att->next();
|
|
if (!_eof1)
|
|
{
|
|
_gruppo_succ = _tmp_saldi_att->get_int(SLD_GRUPPO);
|
|
_conto_succ = _tmp_saldi_att->get_int(SLD_CONTO);
|
|
_sottoconto_succ = _tmp_saldi_att->get_long(SLD_SOTTOCONTO);
|
|
_tipoc_succ = _tmp_saldi_att->get(SLD_FLAGSALINI);
|
|
if ( (_verifica != 2) && (_sottoconto_succ != 0) )
|
|
_ultima_data = UltimaData(_gruppo_succ,_conto_succ,
|
|
_sottoconto_succ,_annoes);
|
|
_descr_succ = DescrizioneConto(_gruppo_succ,_conto_succ,
|
|
_sottoconto_succ,_tipoc_succ);
|
|
_saldoini_dare_succ = _tmp_saldi_att->get_real(SLD_PDARESCA);
|
|
_saldoini_avere_succ = _tmp_saldi_att->get_real(SLD_PAVERESCA);
|
|
_mov_dare_succ = _tmp_saldi_att->get_real(SLD_PDARE);
|
|
_mov_avere_succ = _tmp_saldi_att->get_real(SLD_PAVERE);
|
|
_saldofinale_succ = _tmp_saldi_att->get_real(SLD_SALDO);
|
|
_livello_conto = FALSE;
|
|
if ( ((_verifica != 2)&&(_sottoconto_succ == 0)) ||
|
|
((_verifica == 2)&&(_conto_succ == 0)) )
|
|
{
|
|
_livello_conto = TRUE;
|
|
_gruppo_succ = _gruppo;
|
|
_conto_succ = _conto;
|
|
_sottoconto_succ = _sottoconto;
|
|
_descr_succ = _descr;
|
|
_saldoini_dare_succ = _saldoini_dare;
|
|
_saldoini_avere_succ = _saldoini_avere;
|
|
_mov_dare_succ = _mov_dare;
|
|
_mov_avere_succ = _mov_avere;
|
|
_saldofinale_succ = _saldofinale;
|
|
}
|
|
}
|
|
}
|
|
|
|
bool CG1500_application::preprocess_page(int file, int counter)
|
|
{
|
|
reset_print();
|
|
|
|
if (_bilancio == 1) //stampa bilancio a sez. contrapposte
|
|
{
|
|
if (counter)
|
|
{
|
|
if ( (!_eof1) && (_cambiato_conto_1) )
|
|
_eof1 = _tmp_saldi_att->next();
|
|
|
|
if ( (!_eof2) && (_cambiato_conto_2) )
|
|
_eof2 = _tmp_saldi_pass->next();
|
|
|
|
if (_eof1 && _eof2)
|
|
{
|
|
if (_prima_volta)
|
|
{
|
|
stampa_totali();
|
|
|
|
_eof3 = _tmp_saldi_costi->first();
|
|
_eof4 = _tmp_saldi_ricavi->first();
|
|
}
|
|
else
|
|
{
|
|
_controlla = TRUE;
|
|
|
|
if (_salto_pagina)
|
|
{
|
|
if ( (!_eof3) && (_cambiato_conto_1) )
|
|
_eof3 = _tmp_saldi_costi->next();
|
|
|
|
if ( (!_eof4) && (_cambiato_conto_2) )
|
|
_eof4 = _tmp_saldi_ricavi->next();
|
|
}
|
|
}
|
|
|
|
if ( (!_eof3) && (_cambiato_conto_1) )
|
|
leggi_files_dare(_tmp_saldi_costi);
|
|
|
|
if ( (!_eof4) && (_cambiato_conto_2) )
|
|
leggi_files_avere(_tmp_saldi_ricavi);
|
|
|
|
if (_eof3 && _eof4 && _salto_pagina)
|
|
{
|
|
if (_seconda_volta)
|
|
{
|
|
stampa_totali();
|
|
_eof5 = _tmp_saldi_conti_uno->first();
|
|
_eof6 = _tmp_saldi_conti_due->first();
|
|
}
|
|
else
|
|
{
|
|
_flag = TRUE;
|
|
|
|
if (_salto_pagina1)
|
|
{
|
|
if ( (!_eof5) && (_cambiato_conto_1) )
|
|
_eof5 = _tmp_saldi_conti_uno->next();
|
|
|
|
if ( (!_eof6) && (_cambiato_conto_2) )
|
|
_eof6 = _tmp_saldi_conti_due->next();
|
|
}
|
|
}
|
|
|
|
if ( (!_eof5) && (_cambiato_conto_1) )
|
|
leggi_files_dare(_tmp_saldi_conti_uno);
|
|
|
|
if ( (!_eof6) && (_cambiato_conto_2) )
|
|
leggi_files_avere(_tmp_saldi_conti_due);
|
|
}
|
|
}
|
|
}
|
|
else //counter = 0
|
|
{
|
|
_gc_prec_dare = _gc_corr_avere = "";
|
|
_eof1 = _tmp_saldi_att->first();
|
|
_eof2 = _tmp_saldi_pass->first();
|
|
}
|
|
|
|
if ( (!_eof1) && (_cambiato_conto_1) )
|
|
leggi_files_dare(_tmp_saldi_att);
|
|
|
|
if ( (!_eof2) && (_cambiato_conto_2) )
|
|
leggi_files_avere(_tmp_saldi_pass);
|
|
}
|
|
else //stampa bilancio di verifica
|
|
{
|
|
if ( (_verifica == 3) && (_ordinamento == 2) )
|
|
leggi_sort();
|
|
else
|
|
{
|
|
if (counter)
|
|
{
|
|
if (!_eof1)
|
|
leggi_file_tmp();
|
|
}
|
|
else
|
|
{
|
|
_eof1 = _tmp_saldi_att->first();
|
|
if (_eof1)
|
|
return FALSE;
|
|
else leggi_file_tmp();
|
|
}
|
|
}
|
|
}
|
|
return TRUE;
|
|
}
|
|
|
|
void CG1500_application::leggi_sort()
|
|
{
|
|
struct cli_for* cf;
|
|
|
|
if ( (_buff = _sort->retrieve()) != NULL)
|
|
{
|
|
cf = (struct cli_for*)_buff;
|
|
_gruppo = atoi(cf->gruppo);
|
|
_conto = atoi(cf->conto);
|
|
_sottoconto = atol(cf->codcf);
|
|
_descr = cf->ragsoc;
|
|
if (_descr != "zzzz")
|
|
_ultima_data = UltimaData(_gruppo,_conto,_sottoconto,_annoes);
|
|
_saldo_dare = cf->saldodare;
|
|
_saldo_avere = cf->saldoavere;
|
|
_mov_dare = cf->movdare;
|
|
_mov_avere = cf->movavere;
|
|
_saldofinale = cf->saldofinale;
|
|
}
|
|
}
|
|
|
|
void CG1500_application::controlla_conto_uno(int file1,int file2)
|
|
{
|
|
TString dep = "";
|
|
|
|
if (!file1)
|
|
if (_cambiato_conto_1)
|
|
{
|
|
set_row(_i,"%s @66g|", (const char*)dep);
|
|
_cambiato_conto_1 = FALSE;
|
|
}
|
|
else
|
|
{
|
|
stampa_prima_colonna(_gruppo_dare, _conto_dare, _sottoconto_dare,
|
|
_descr_dare,_saldo_dare);
|
|
|
|
_cambiato_conto_1 = TRUE;
|
|
if ( (_conto_dare == 0) && (_sottoconto_dare == 0) )
|
|
_tot_dare += _saldo_dare;
|
|
}
|
|
|
|
if (!file2)
|
|
if (_cambiato_conto_2)
|
|
{
|
|
set_row(_i,"%s @66g|", (const char*)dep);
|
|
_cambiato_conto_2 = FALSE;
|
|
}
|
|
else
|
|
{
|
|
stampa_seconda_colonna(_gruppo_avere, _conto_avere, _sottoconto_avere,
|
|
_descr_avere, _saldo_avere);
|
|
|
|
_cambiato_conto_2 = TRUE;
|
|
if ( (_conto_avere == 0) && (_sottoconto_avere == 0) )
|
|
_tot_avere += _saldo_avere;
|
|
}
|
|
}
|
|
|
|
/*
|
|
void CG1500_application::controlla_conto_due()
|
|
{
|
|
TString dep = "";
|
|
|
|
if (!_eof3)
|
|
if (_cambiato_conto_2)
|
|
{
|
|
set_row(_i,"%s @66g|", (const char*)dep);
|
|
_cambiato_conto_2 = FALSE;
|
|
}
|
|
else
|
|
{
|
|
stampa_prima_colonna(_gruppo_avere, _conto_avere, _sottoconto_avere,
|
|
_descr_avere, _saldo_avere);
|
|
|
|
_cambiato_conto_2 = TRUE;
|
|
if ( (_conto_avere == 0) && (_sottoconto_avere == 0) )
|
|
_tot_avere += _saldo_avere;
|
|
}
|
|
|
|
if (!_eof4)
|
|
if (_cambiato_conto_1)
|
|
{
|
|
set_row(_i,"%s @66g|", (const char*)dep);
|
|
_cambiato_conto_1 = FALSE;
|
|
}
|
|
else
|
|
{
|
|
stampa_seconda_colonna(_gruppo_dare, _conto_dare, _sottoconto_dare,
|
|
_descr_dare, _saldo_dare);
|
|
|
|
_cambiato_conto_1 = TRUE;
|
|
if ( (_conto_dare == 0) && (_sottoconto_dare == 0) )
|
|
_tot_dare += _saldo_dare;
|
|
}
|
|
}
|
|
*/
|
|
|
|
print_action CG1500_application::postprocess_print(int file, int counter)
|
|
{
|
|
if (_bilancio == 1)
|
|
{
|
|
_tmp_saldi_att->close();
|
|
_tmp_saldi_pass->close();
|
|
_tmp_saldi_costi->close();
|
|
_tmp_saldi_ricavi->close();
|
|
_tmp_saldi_conti_uno->close();
|
|
_tmp_saldi_conti_due->close();
|
|
}
|
|
else
|
|
{
|
|
if (! ((_verifica == 3) && (_ordinamento == 2)))
|
|
_tmp_saldi_att->close();
|
|
if ( (_verifica == 3) && (_ordinamento == 2) )
|
|
delete _sort;
|
|
}
|
|
return NEXT_PAGE;
|
|
}
|
|
|
|
void CG1500_application::set_page(int file, int counter)
|
|
{
|
|
TString dep = "";
|
|
|
|
if (_bilancio == 1) //stampa bilancio a sezioni contrapposte
|
|
{
|
|
_i = 1;
|
|
|
|
if (!counter)
|
|
{
|
|
set_row(_i++,"@29gATTIVITA'@94gPASSIVITA'");
|
|
set_row(_i++,"@29g---------@94g----------");
|
|
set_row(_i++, (const char*)dep);
|
|
}
|
|
|
|
controlla_conto_uno(_eof1,_eof2); //stampo una riga vuota tra un gruppo e un conto altrimenti no
|
|
|
|
if ( _eof1 && _eof2 && (!_prima_volta) && _controlla )
|
|
if (!_salto_pagina)
|
|
{
|
|
printer().formfeed();
|
|
set_row(_i++,"@29gCOSTI@94gRICAVI");
|
|
set_row(_i++,"@29g-----@94g------");
|
|
set_row(_i++, (const char*)dep);
|
|
_salto_pagina = TRUE;
|
|
|
|
}
|
|
|
|
if (_eof1 && _eof2 && _controlla)
|
|
{
|
|
//controlla_conto_due();
|
|
controlla_conto_uno(_eof3,_eof4);
|
|
|
|
if ( _eof3 && _eof4 && (!_seconda_volta) && _flag )
|
|
if (!_salto_pagina1)
|
|
{
|
|
printer().formfeed();
|
|
set_row(_i++,"@59gCONTI D'ORDINE");
|
|
set_row(_i++,"@59g--------------");
|
|
set_row(_i++, (const char*)dep);
|
|
_salto_pagina1 = TRUE;
|
|
if (_eof5 && _eof6)
|
|
{
|
|
_stampato = TRUE;
|
|
stampa_totali();
|
|
}
|
|
}
|
|
|
|
if (_eof3 && _eof4 && _flag)
|
|
{
|
|
controlla_conto_uno(_eof5,_eof6);
|
|
if (_eof5 && _eof6)
|
|
if (!_stampato) stampa_totali();
|
|
}
|
|
}
|
|
}
|
|
else //stampa bilancio di verifica
|
|
{
|
|
TString udata = _ultima_data.string(2,'/');
|
|
TString app;
|
|
int r = 1;
|
|
|
|
if ( (_verifica == 3) && (_ordinamento == 2) )
|
|
{
|
|
if (_buff != NULL)
|
|
{
|
|
if (_saldofinale > 0)
|
|
app = "D";
|
|
else if (_saldofinale < 0)
|
|
{
|
|
_saldofinale = _saldofinale * (-1.00);
|
|
app = "A";
|
|
}
|
|
|
|
if (_descr == "zzzz") //devo stampare il conto
|
|
{
|
|
_descr = DescrizioneConto(_gruppo,_conto,_sottoconto,"");
|
|
stampa_record_conto(_gruppo,_conto,_descr,_saldo_dare,_saldo_avere,
|
|
_mov_dare,_mov_avere,_saldofinale,app);
|
|
}
|
|
else
|
|
if (_stampa_width == 132)
|
|
{
|
|
// set_row(r,"@1g%6ld %s@18g%s@49g|@50g%r@67g%r@82g|@83g%r@100g%r@115g|@116g%r%s",
|
|
// _sottoconto,(const char*)udata,(const char*)_descr,&_saldo_dare,&_saldo_avere,
|
|
// &_mov_dare,&_mov_avere,&_saldofinale,(const char*)app);
|
|
set_row(r,"@1g%6ld",(const char*)_sottoconto);
|
|
set_row(r," %s",(const char*)udata);
|
|
set_row(r,"@18g%s@49g|@50g%r@67g%r@82g|@83g%r@100g%r@115g|@116g%r",(const char*)_descr,&_saldo_dare,
|
|
&_saldo_avere,&_mov_dare,&_mov_avere,&_saldofinale);
|
|
set_row(r,"%s",(const char*)app);
|
|
}
|
|
else if (app == "D")
|
|
{
|
|
// set_row(r,"@1g%6ld %s@18g%s@49g|@50g%r@67g%r@82g|@83g%r@100g%r@115g|@116g%r@148g|",
|
|
// _sottoconto,(const char*)udata,(const char*)_descr,&_saldo_dare,
|
|
// &_saldo_avere,&_mov_dare,&_mov_avere,&_saldofinale);
|
|
set_row(r,"@1g%6ld",(const char*)_sottoconto);
|
|
set_row(r," %s",(const char*)udata);
|
|
set_row(r,"@18g%s@49g|@50g%r@67g%r@82g|@83g%r@100g%r@115g|@116g%r@148g|",(const char*)_descr,
|
|
&_saldo_dare,&_saldo_avere,&_mov_dare,&_mov_avere,&_saldofinale);
|
|
}
|
|
else
|
|
{
|
|
// set_row(r,"@1g%6ld %s@18g%s@49g|@50g%r@67g%r@82g|@83g%r@100g%r@115g|@132g%r@148g|",
|
|
// _sottoconto,(const char*)udata,(const char*)_descr,&_saldo_dare,
|
|
// &_saldo_avere,&_mov_dare,&_mov_avere,&_saldofinale);
|
|
set_row(r,"@1g%6ld",(const char*)_sottoconto);
|
|
set_row(r," %s",(const char*)udata);
|
|
set_row(r,"@18g%s@49g|@50g%r@67g%r@82g|@83g%r@100g%r@115g|@132g%r@148g|",
|
|
(const char*)_descr,&_saldo_dare,&_saldo_avere,&_mov_dare,&_mov_avere,&_saldofinale);
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (!_eof1)
|
|
{
|
|
if (_saldofinale_succ > 0)
|
|
app = "D";
|
|
else if (_saldofinale_succ < 0)
|
|
{
|
|
_saldofinale_succ = _saldofinale_succ * (-1.00);
|
|
app = "A";
|
|
}
|
|
|
|
if (_livello_conto) //sto stampando un conto/gruppo
|
|
r = stampa_record_conto(_gruppo_succ,_conto_succ,_descr_succ,
|
|
_saldoini_dare_succ,_saldoini_avere_succ,_mov_dare_succ,
|
|
_mov_avere_succ,_saldofinale_succ,app);
|
|
|
|
else //sto stampando un sottoconto/conto
|
|
{
|
|
if (_verifica == 2)
|
|
{
|
|
if (_stampa_width == 132)
|
|
{
|
|
// set_row(r,"%3d @8g%s@49g|@50g%r@67g%r@82g|@83g%r@100g%r@115g|@116g%r%s",
|
|
// _conto_succ,(const char*)_descr_succ,&_saldoini_dare_succ,&_saldoini_avere_succ,
|
|
// &_mov_dare_succ,&_mov_avere_succ,&_saldofinale_succ,(const char*)app);
|
|
set_row(r,"%3d",_conto_succ);
|
|
set_row(r," @8g%s@49g|@50g%r@67g%r@82g|@83g%r@100g%r@115g|@116g%r",
|
|
(const char*)_descr_succ,&_saldoini_dare_succ,&_saldoini_avere_succ,
|
|
&_mov_dare_succ,&_mov_avere_succ,&_saldofinale_succ);
|
|
set_row(r,"%s",(const char*)app);
|
|
}
|
|
else if (app == "D")
|
|
{
|
|
// set_row(r,"%3d @8g%s@49g|@50g%r@67g%r@82g|@83g%r@100g%r@115g|@116g%r@148g|",
|
|
// _conto_succ,(const char*)_descr_succ,&_saldoini_dare_succ,&_saldoini_avere_succ,
|
|
// &_mov_dare_succ,&_mov_avere_succ,&_saldofinale_succ);
|
|
set_row(r,"%3d",_conto_succ);
|
|
set_row(r," @8g%s@49g|@50g%r@67g%r@82g|@83g%r@100g%r@115g|@116g%r@148g|",
|
|
(const char*)_descr_succ,&_saldoini_dare_succ,&_saldoini_avere_succ,
|
|
&_mov_dare_succ,&_mov_avere_succ,&_saldofinale_succ);
|
|
}
|
|
else
|
|
{
|
|
// set_row(r,"%3d @8g%s@49g|@50g%r@67g%r@82g|@83g%r@100g%r@115g|@132g%r@148g|",
|
|
// _conto_succ,(const char*)_descr_succ,&_saldoini_dare_succ,&_saldoini_avere_succ,
|
|
// &_mov_dare_succ,&_mov_avere_succ,&_saldofinale_succ);
|
|
set_row(r,"%3d",_conto_succ);
|
|
set_row(r," @8g%s@49g|@50g%r@67g%r@82g|@83g%r@100g%r@115g|@132g%r@148g|",
|
|
(const char*)_descr_succ,&_saldoini_dare_succ,&_saldoini_avere_succ,
|
|
&_mov_dare_succ,&_mov_avere_succ,&_saldofinale_succ);
|
|
}
|
|
} // _verifica != 2
|
|
else
|
|
{
|
|
if (_stampa_width == 132)
|
|
{
|
|
// set_row(r,"@1g%6ld %s@18g%s@49g|@50g%r@67g%r@82g|@83g%r@100g%r@115g|@116g%r%s",
|
|
// _sottoconto_succ,(const char*)udata,(const char*)_descr_succ,&_saldoini_dare_succ,
|
|
// &_saldoini_avere_succ,&_mov_dare_succ,&_mov_avere_succ,&_saldofinale_succ,
|
|
// (const char*)app);
|
|
set_row(r,"@1g%6ld",(const char*)_sottoconto_succ);
|
|
set_row(r," %s",(const char*)udata);
|
|
set_row(r,"@18g%s@49g|@50g%r@67g%r@82g|@83g%r@100g%r@115g|@116g%r",
|
|
(const char*)_descr_succ,&_saldoini_dare_succ,&_saldoini_avere_succ,
|
|
&_mov_dare_succ,&_mov_avere_succ,&_saldofinale_succ);
|
|
set_row(r,"%s",(const char*)app);
|
|
}
|
|
else if (app == "D")
|
|
{
|
|
// set_row(r,"@1g%6ld %s@18g%s@49g|@50g%r@67g%r@82g|@83g%r@100g%r@115g|@116g%r@148g|",
|
|
// _sottoconto_succ,(const char*)udata,(const char*)_descr_succ,
|
|
// &_saldoini_dare_succ,&_saldoini_avere_succ,
|
|
// &_mov_dare_succ,&_mov_avere_succ,&_saldofinale_succ);
|
|
set_row(r,"@1g%6ld",(const char*)_sottoconto_succ);
|
|
set_row(r," %s",(const char*)udata);
|
|
set_row(r,"@18g%s@49g|@50g%r@67g%r@82g|@83g%r@100g%r@115g|@116g%r@148g|",
|
|
(const char*)_descr_succ,&_saldoini_dare_succ,&_saldoini_avere_succ,
|
|
&_mov_dare_succ,&_mov_avere_succ,&_saldofinale_succ);
|
|
}
|
|
else
|
|
{
|
|
// set_row(r,"@1g%6ld %s@18g%s@49g|@50g%r@67g%r@82g|@83g%r@100g%r@115g|@132g%r@148g|",
|
|
// _sottoconto_succ,(const char*)udata,(const char*)_descr_succ,
|
|
// &_saldoini_dare_succ,&_saldoini_avere_succ,
|
|
// &_mov_dare_succ,&_mov_avere_succ,&_saldofinale_succ);
|
|
set_row(r,"@1g%6ld",(const char*)_sottoconto_succ);
|
|
set_row(r," %s",(const char*)udata);
|
|
set_row(r,"@18g%s@49g|@50g%r@67g%r@82g|@83g%r@100g%r@115g|@132g%r@148g|",
|
|
(const char*)_descr_succ,&_saldoini_dare_succ,&_saldoini_avere_succ,
|
|
&_mov_dare_succ,&_mov_avere_succ,&_saldofinale_succ);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (_saldofinale > 0)
|
|
app = "D";
|
|
else if (_saldofinale < 0)
|
|
{
|
|
app = "A";
|
|
_saldofinale = _saldofinale * (-1.00);
|
|
}
|
|
r = stampa_record_conto(_gruppo,_conto,_descr,_saldoini_dare,
|
|
_saldoini_avere,_mov_dare,_mov_avere,_saldofinale,app);//per stampare l'ultimo conto
|
|
|
|
stampa_riga_totali(r);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
int CG1500_application::stampa_record_conto(int g,int c,const char* d,
|
|
const real& r1,const real& r2,const real& r3,const real& r4,const real& r5,
|
|
const TString& app)
|
|
{
|
|
TString dep = "";
|
|
int r = 1;
|
|
|
|
set_row(r,"@49g|@82g|@115g|",(const char*)dep); //stampo una riga vuota
|
|
if (_stampa_width == 148)
|
|
set_row(r,"@148g|",(const char*)dep);
|
|
r++;
|
|
if (_verifica == 2)
|
|
{
|
|
if (_stampa_width == 132)
|
|
{
|
|
// set_row(r++,"%3d-@8g%s@49g|@50g%r@67g%r@82g|@83g%r@100g%r@115g|@116g%r%s",g,d,&r1,&r2,&r3,&r4,&r5,(const char*)app);
|
|
set_row(r,"%3d-",g);
|
|
set_row(r,"@8g%s",d);
|
|
set_row(r,"@49g|@50g%r@67g%r@82g|@83g%r@100g%r@115g|@116g%r",&r1,&r2,&r3,&r4,&r5);
|
|
set_row(r++,"%s",(const char*)app);
|
|
}
|
|
else
|
|
if (app == "D")
|
|
{
|
|
// set_row(r++,"%3d-@8g%s@49g|@50g%r@67g%r@82g|@83g%r@100g%r@115g|@116g%r@148g|",g,d,&r1,&r2,&r3,&r4,&r5);
|
|
set_row(r,"%3d-",g);
|
|
set_row(r,"@8g%s",d);
|
|
set_row(r++,"@49g|@50g%r@67g%r@82g|@83g%r@100g%r@115g|@116g%r@148g|",&r1,&r2,&r3,&r4,&r5);
|
|
}
|
|
else
|
|
{
|
|
// set_row(r++,"%3d-@8g%s@49g|@50g%r@67g%r@82g|@83g%r@100g%r@115g|@132g%r@148g|",g,d,&r1,&r2,&r3,&r4,&r5);
|
|
set_row(r,"%3d-",g);
|
|
set_row(r,"@8g%s",d);
|
|
set_row(r++,"@49g|@50g%r@67g%r@82g|@83g%r@100g%r@115g|@132g%r@148g|",&r1,&r2,&r3,&r4,&r5);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (_stampa_width == 132)
|
|
{
|
|
// set_row(r++,"%3d-%3d ********@18g%s@49g|@50g%r@67g%r@82g|@83g%r@100g%r@115g|@116g%r%s",g,c,d,&r1,&r2,&r3,&r4,&r5,(const char*)app);
|
|
set_row(r,"%3d-",g);
|
|
set_row(r,"%3d ********",c);
|
|
set_row(r,"@18g%s",d);
|
|
set_row(r,"@49g|@50g%r@67g%r@82g|@83g%r@100g%r@115g|@116g%r",&r1,&r2,&r3,&r4,&r5);
|
|
set_row(r++,"%s",(const char*)app);
|
|
}
|
|
else if (app == "D")
|
|
{
|
|
// set_row(r++,"%3d-%3d ********@18g%s@49g|@50g%r@67g%r@82g|@83g%r@100g%r@115g|@116g%r@148g|",g,c,d,&r1,&r2,&r3,&r4,&r5);
|
|
set_row(r,"%3d-",g);
|
|
set_row(r,"%3d ********",c);
|
|
set_row(r,"@18g%s",d);
|
|
set_row(r++,"@49g|@50g%r@67g%r@82g|@83g%r@100g%r@115g|@116g%r@148g|",&r1,&r2,&r3,&r4,&r5);
|
|
}
|
|
else
|
|
{
|
|
// set_row(r++,"%3d-%3d ********@18g%s@49g|@50g%r@67g%r@82g|@83g%r@100g%r@115g|@132g%r@148g|",g,c,d,&r1,&r2,&r3,&r4,&r5);
|
|
set_row(r,"%3d-",g);
|
|
set_row(r,"%3d ********",c);
|
|
set_row(r,"@18g%s",d);
|
|
set_row(r++,"@49g|@50g%r@67g%r@82g|@83g%r@100g%r@115g|@132g%r@148g|",&r1,&r2,&r3,&r4,&r5);
|
|
}
|
|
}
|
|
set_row(r,"@49g|@82g|@115g|",(const char*)dep);
|
|
if (_stampa_width == 148)
|
|
set_row(r,"@148g|",(const char*)dep);
|
|
r++;
|
|
set_row(r,"@49g|@82g|@115g|",(const char*)dep);
|
|
if (_stampa_width == 148)
|
|
set_row(r,"@148g|",(const char*)dep);
|
|
r++;
|
|
|
|
if (app == "D")
|
|
_saldo_finale_tot += r5;
|
|
else _saldo_finale_tot -= r5;
|
|
|
|
_saldo_dare_tot += r1;
|
|
_saldo_avere_tot += r2;
|
|
_mov_dare_tot += r3;
|
|
_mov_avere_tot += r4;
|
|
|
|
return r;
|
|
}
|
|
|
|
void CG1500_application::stampa_riga_totali(int r)
|
|
{
|
|
TString app, dep = "";
|
|
|
|
if (_saldo_finale_tot > 0)
|
|
app = "D";
|
|
else if (_saldo_finale_tot < 0)
|
|
{
|
|
_saldo_finale_tot = _saldo_finale_tot * (-1.00);
|
|
app = "A";
|
|
}
|
|
|
|
if (_datada == _dataini) //colonna saldo iniziale
|
|
{
|
|
real r = _saldo_dare_tot - _saldo_avere_tot;
|
|
if (r > 0.00)
|
|
{
|
|
_saldo_dare_tot = r;
|
|
_saldo_avere_tot = 0.00;
|
|
}
|
|
else
|
|
{
|
|
_saldo_avere_tot = r * (-1.00);
|
|
_saldo_dare_tot = 0.00;
|
|
}
|
|
}
|
|
set_row(r,"@49g|@82g|@115g|",(const char*)dep);
|
|
if (_stampa_width == 148)
|
|
set_row(r,"@148g|",(const char*)dep);
|
|
r++;
|
|
if (_verifica == 2)
|
|
{
|
|
if (_stampa_width == 132)
|
|
set_row(r,"***@8gTOTALE GENERALE@49g|@50g%r@67g%r@82g|@83g%r@100g%r@115g|@116g%r%s",&_saldo_dare_tot,&_saldo_avere_tot,&_mov_dare_tot,
|
|
&_mov_avere_tot,&_saldo_finale_tot,(const char*)app);
|
|
else if (app == "D")
|
|
set_row(r,"***@8gTOTALE GENERALE@49g|@50g%r@67g%r@82g|@83g%r@100g%r@115g|@116g%r@148g|",&_saldo_dare_tot,&_saldo_avere_tot,
|
|
&_mov_dare_tot,&_mov_avere_tot,&_saldo_finale_tot);
|
|
else
|
|
set_row(r,"***@8gTOTALE GENERALE@49g|@50g%r@67g%r@82g|@83g%r@100g%r@115g|@132g%r@148g|",&_saldo_dare_tot,&_saldo_avere_tot,
|
|
&_mov_dare_tot,&_mov_avere_tot,&_saldo_finale_tot);
|
|
}
|
|
else
|
|
{
|
|
if (_stampa_width == 132)
|
|
set_row(r,"****** ********@18gTOTALE GENERALE@49g|@50g%r@67g%r@82g|@83g%r@100g%r@115g|@116g%r%s",&_saldo_dare_tot,&_saldo_avere_tot,
|
|
&_mov_dare_tot,&_mov_avere_tot,&_saldo_finale_tot,
|
|
(const char*)app);
|
|
else if (app == "D")
|
|
set_row(r,"****** ********@18gTOTALE GENERALE@49g|@50g%r@67g%r@82g|@83g%r@100g%r@115g|@116g%r@148g|",&_saldo_dare_tot,
|
|
&_saldo_avere_tot,&_mov_dare_tot,&_mov_avere_tot,
|
|
&_saldo_finale_tot);
|
|
else
|
|
set_row(r,"****** ********@18gTOTALE GENERALE@49g|@50g%r@67g%r@82g|@83g%r@100g%r@115g|@132g%r@148g|",&_saldo_dare_tot,
|
|
&_saldo_avere_tot,&_mov_dare_tot,&_mov_avere_tot,
|
|
&_saldo_finale_tot);
|
|
}
|
|
}
|
|
|
|
void CG1500_application::stampa_totali()
|
|
{
|
|
TString dep = "";
|
|
real pareggio;
|
|
real sbilancio = _tot_dare - _tot_avere;
|
|
if (sbilancio > 0.00) //_tot_dare > _tot_avere
|
|
pareggio = _tot_avere + sbilancio;
|
|
else
|
|
{
|
|
sbilancio = sbilancio * (-1.00);
|
|
pareggio = _tot_dare + sbilancio;
|
|
}
|
|
if (_prima_volta) //ho finito di stampare le attivita'/passivita'
|
|
_prima_volta = FALSE;
|
|
else
|
|
_seconda_volta = FALSE;
|
|
_gc_prec_dare = _gc_corr_avere = "";
|
|
_cambiato_conto_1 = TRUE;
|
|
_cambiato_conto_2 = TRUE;
|
|
|
|
set_row(_i++, (const char*)dep);
|
|
set_row(_i++, (const char*)dep);
|
|
set_row(_i++, (const char*)dep);
|
|
set_row(_i++, (const char*)dep);
|
|
set_row(_i++, "@35gTOTALE@45g%r@103gTOTALE@113g%r",
|
|
&_tot_dare, &_tot_avere);
|
|
if (_tot_dare > _tot_avere)
|
|
{
|
|
set_row(_i++, "@81gSBILANCIO ESERCIZIO IN CORSO@113g%r",
|
|
&sbilancio);
|
|
set_row(_i++, "@92gTOTALE A PAREGGIO@113g%r",&pareggio);
|
|
}
|
|
if (_tot_dare < _tot_avere)
|
|
{
|
|
set_row(_i++, "@13gSBILANCIO ESERCIZIO IN CORSO@45g%r",
|
|
&sbilancio);
|
|
set_row(_i++, "@24gTOTALE A PAREGGIO@45g%r", &pareggio);
|
|
}
|
|
_tot_dare = 0.00;
|
|
_tot_avere = 0.00;
|
|
}
|
|
|
|
void CG1500_application::stampa_prima_colonna(int g, int c, long s,
|
|
const char* desc, const real& saldo)
|
|
{
|
|
if (_codici) //sono stampate solo le descrizioni dei conti
|
|
{
|
|
set_row(_i, "%s @66g|", desc);
|
|
|
|
if ( (!_totali) || ((c != 0) || (s != 0)) )
|
|
set_row(_i, "@45g%r", &saldo);
|
|
}
|
|
else if ( _totali && (c == 0) && (s == 0l) )
|
|
{
|
|
set_row(_i, "%3d ", g);
|
|
set_row(_i, "@18g%s @66g|", desc);
|
|
}
|
|
else if ( (c == 0) && (s == 0l) )
|
|
{
|
|
set_row(_i, "%3d ", g);
|
|
set_row(_i, "@18g%s @45g%r @66g|", desc, &saldo);
|
|
}
|
|
else if (s == 0l)
|
|
{
|
|
// set_row(_i, "%3d %3d ", g, c);
|
|
set_row(_i, "%3d ", g);
|
|
set_row(_i, "%3d ", c);
|
|
set_row(_i, "@18g%s @45g%r @66g|", desc, &saldo);
|
|
}
|
|
else
|
|
{
|
|
// set_row(_i, "%3d %3d %6ld ", g, c, s);
|
|
set_row(_i, "%3d ", g);
|
|
set_row(_i, "%3d ", c);
|
|
set_row(_i, "%6ld ",(const char*) s);
|
|
set_row(_i, "@18g%s @45g%r @66g|", desc, &saldo);
|
|
}
|
|
}
|
|
|
|
void CG1500_application::stampa_seconda_colonna(int g, int c, long s,
|
|
const char* desc, const real& saldo)
|
|
{
|
|
if (_codici) //sono stampate solo le descrizioni dei conti
|
|
{
|
|
set_row(_i, "@66g|");
|
|
set_row(_i, "@69g%s", desc);
|
|
|
|
if ( (!_totali) || ((c != 0) || (s != 0)) )
|
|
set_row(_i, "@113g%r", &saldo);
|
|
}
|
|
else if ( (_totali) && (c == 0) && (s == 0l) )
|
|
{
|
|
set_row(_i, "@66g|@69g%3d ", g);
|
|
set_row(_i, "@86g%s", desc);
|
|
}
|
|
else if ( (c == 0) && (s == 0l) )
|
|
{
|
|
set_row(_i, "@66g|@69g%3d ", g);
|
|
set_row(_i, "@86g%s @113g%r", desc, &saldo);
|
|
}
|
|
else if (s == 0l)
|
|
{
|
|
// set_row(_i, "@66g|@69g%3d %3d ", g, c);
|
|
set_row(_i, "@66g|@69g%3d ", g);
|
|
set_row(_i, "%3d", c);
|
|
set_row(_i, "@86g%s @113g%r", desc, &saldo);
|
|
}
|
|
else
|
|
{
|
|
// set_row(_i, "@66g|@69g%3d %3d %6ld ", g, c, s);
|
|
set_row(_i, "@66g|@69g%3d ", g);
|
|
set_row(_i, "%3d ", c);
|
|
set_row(_i, "%6ld ",(const char*) s);
|
|
set_row(_i, "@86g%s @113g%r", desc, &saldo);
|
|
}
|
|
}
|
|
|
|
print_action CG1500_application::postprocess_page(int file, int counter)
|
|
{
|
|
if (_bilancio == 1)
|
|
{
|
|
if ( _eof1 && _eof2 && _eof3 && _eof4 && _eof5 && _salto_pagina1 )
|
|
return NEXT_PAGE;
|
|
}
|
|
else //bilancio di verifica
|
|
{
|
|
if ( (_verifica == 3) && (_ordinamento == 2) )
|
|
{
|
|
if (_buff == NULL)
|
|
return NEXT_PAGE;
|
|
}
|
|
else if (_eof1)
|
|
return NEXT_PAGE;
|
|
}
|
|
return REPEAT_PAGE;
|
|
}
|
|
|
|
bool mask_data_da (TMask_field& f, KEY k)
|
|
{
|
|
if ( (k == K_TAB) && f.mask().is_running() )
|
|
{
|
|
TDate da(f.mask().get(F_DATADA));
|
|
int anno = atoi(f.mask().get(F_ANNO));
|
|
if ( (da.year() != anno) && (da.year() != anno-1) )
|
|
{
|
|
f.warning_box ("La data deve essere relativa all'es. in corso o all'es. precedente");
|
|
return FALSE;
|
|
}
|
|
if ( (anno != 0) && (!IsEsercizioDa(da,anno-1)) )
|
|
{
|
|
f.warning_box ("La data limite inf. non puo' essere minore della data inizio es. precedente");
|
|
return FALSE;
|
|
}
|
|
}
|
|
return TRUE;
|
|
}
|
|
|
|
bool mask_data_a (TMask_field& f, KEY k)
|
|
{
|
|
if ( (k == K_TAB) && f.mask().is_running() )
|
|
{
|
|
TDate a (f.mask().get(F_DATAA));
|
|
int anno = atoi(f.mask().get(F_ANNO));
|
|
if ( (a.year() != anno) && (a.year() != anno-1) )
|
|
{
|
|
f.warning_box ("La data deve essere relativa all'es. in corso o all'es. precedente");
|
|
return FALSE;
|
|
}
|
|
if ( (anno != 0) && (!IsEsercizioA(a,anno)) )
|
|
{
|
|
f.warning_box ("La data limite sup. non puo' essere maggiore della data fine es. in corso");
|
|
return FALSE;
|
|
}
|
|
}
|
|
return TRUE;
|
|
}
|
|
|
|
bool mask_datalim (TMask_field& f, KEY k)
|
|
{
|
|
if ( (k == K_TAB) && f.mask().is_running() )
|
|
{
|
|
TDate datalim(f.mask().get(F_DATALIM));
|
|
int anno = atoi(f.mask().get(F_ANNO));
|
|
if ( (anno != 0) && (!IsEsercizio(datalim,anno,anno-1)) )
|
|
{
|
|
f.warning_box ("La data limite deve essere compresa tra la data inizio es. precedente e la data fine esercizio in corso");
|
|
return FALSE;
|
|
}
|
|
}
|
|
return TRUE;
|
|
}
|
|
|
|
bool my_handler (TMask_field& f, KEY k)
|
|
{
|
|
if (k == K_SPACE)
|
|
{
|
|
int tipo_stampa = atoi(f.mask().get(F_STAMPA1));
|
|
int verifica = atoi(f.mask().get(F_VERIFICA));
|
|
if ( (tipo_stampa == 1) && ((verifica == 1) || (verifica == 2)) )
|
|
{
|
|
f.mask().hide (F_SITUAZIONE);
|
|
f.mask().hide (F_STAMPAC);
|
|
f.mask().hide (F_ORDINAMENTO);
|
|
f.mask().show (F_STAMPAV);
|
|
f.mask().show (F_DATADA);
|
|
f.mask().show (F_DATAA);
|
|
f.mask().show (F_COMPETENZA);
|
|
f.mask().show (F_STAMPAMPROV);
|
|
}
|
|
if ( (tipo_stampa == 1) && (verifica == 3) )
|
|
{
|
|
f.mask().show (F_SITUAZIONE);
|
|
f.mask().show (F_STAMPAC);
|
|
f.mask().show (F_ORDINAMENTO);
|
|
f.mask().show (F_DATADA);
|
|
f.mask().show (F_DATAA);
|
|
f.mask().show (F_COMPETENZA);
|
|
f.mask().hide (F_STAMPAV);
|
|
f.mask().show (F_STAMPAMPROV);
|
|
}
|
|
if ( ((tipo_stampa == 2)||(tipo_stampa == 3)) && ((verifica == 1)||(verifica == 2)) )
|
|
{
|
|
f.mask().hide (F_SITUAZIONE);
|
|
f.mask().hide (F_STAMPAC);
|
|
f.mask().hide (F_ORDINAMENTO);
|
|
f.mask().hide (F_DATADA);
|
|
f.mask().hide (F_DATAA);
|
|
f.mask().hide (F_COMPETENZA);
|
|
f.mask().hide (F_STAMPAMPROV);
|
|
f.mask().show (F_STAMPAV);
|
|
}
|
|
if ( ((tipo_stampa == 2)||(tipo_stampa == 3)) && (verifica == 3) )
|
|
{
|
|
f.mask().show (F_SITUAZIONE);
|
|
f.mask().show (F_STAMPAC);
|
|
f.mask().show (F_ORDINAMENTO);
|
|
f.mask().hide (F_DATADA);
|
|
f.mask().hide (F_DATAA);
|
|
f.mask().hide (F_COMPETENZA);
|
|
f.mask().hide (F_STAMPAMPROV);
|
|
f.mask().hide (F_STAMPAV);
|
|
}
|
|
}
|
|
return TRUE;
|
|
}
|
|
|
|
TDate CG1500_application::UltimaData(int g, int c, long s, int anno)
|
|
{
|
|
TLocalisamfile saldi(LF_SALDI, FALSE); //il parametro a false permette di usare un record corrente del file saldi differente a quello del file tmp
|
|
TDate uldata;
|
|
|
|
saldi.zero();
|
|
if (_annoes != 0)
|
|
saldi.put(SLD_ANNOES, anno);
|
|
saldi.put(SLD_GRUPPO,g);
|
|
if (c != 0)
|
|
saldi.put(SLD_CONTO, c);
|
|
if (s != 0)
|
|
saldi.put(SLD_SOTTOCONTO, s);
|
|
saldi.read();
|
|
if (saldi.bad())
|
|
saldi.zero();
|
|
uldata = saldi.get(SLD_DATAULMOV);
|
|
|
|
return uldata;
|
|
}
|
|
|
|
|
|
// Please don't use this function any more: use TConto class instead
|
|
// It'll be removed within some days
|
|
const char* CG1500_application::DescrizioneConto(int g, int c, long s,
|
|
const char* tipocf)
|
|
{
|
|
static TString256 tmp;
|
|
|
|
TLocalisamfile pconti(LF_PCON,FALSE);
|
|
TLocalisamfile clifo (LF_CLIFO);
|
|
|
|
pconti.zero();
|
|
pconti.put(PCN_GRUPPO, g);
|
|
if (c != 0)
|
|
pconti.put(PCN_CONTO, c);
|
|
if (s != 0)
|
|
pconti.put(PCN_SOTTOCONTO, s);
|
|
pconti.read();
|
|
if (pconti.good())
|
|
tmp = pconti.get(PCN_DESCR);
|
|
else
|
|
{
|
|
clifo.setkey(1); //occorre settare la chiave 1, anche se di solito e' di default, poiche' nella create il file clifo e' stato aperto con la chiave 3
|
|
clifo.zero();
|
|
clifo.put(CLI_CODCF, s);
|
|
clifo.put(CLI_TIPOCF,tipocf);
|
|
clifo.read();
|
|
if (clifo.good())
|
|
tmp = clifo.get(CLI_RAGSOC);
|
|
else
|
|
tmp = "";
|
|
}
|
|
return tmp;
|
|
}
|
|
|
|
void CG1500_application::user_create()
|
|
{
|
|
_stampa_width = 132;
|
|
_rel = new TRelation(LF_CLIFO);
|
|
_cur = new TCursor (_rel,"",3);
|
|
_mov = new TLocalisamfile(LF_MOV);
|
|
_rmov = new TLocalisamfile(LF_RMOV);
|
|
_clifo = new TLocalisamfile(LF_CLIFO);
|
|
_com = new TLocalisamfile(LF_COMUNI);
|
|
_pcn = new TLocalisamfile(LF_PCON);
|
|
_saldi = new TLocalisamfile(LF_SALDI);
|
|
_nditte = new TLocalisamfile(LF_NDITTE);
|
|
_anag = new TLocalisamfile(LF_ANAG);
|
|
_esc = new TTable("ESC");
|
|
_tmp_saldi_att = new TIsamtempfile(LF_SALDI);
|
|
_tmp_saldi_pass = new TIsamtempfile(LF_SALDI);
|
|
_tmp_saldi_costi = new TIsamtempfile(LF_SALDI);
|
|
_tmp_saldi_ricavi = new TIsamtempfile(LF_SALDI);
|
|
_tmp_saldi_conti_uno = new TIsamtempfile(LF_SALDI);
|
|
_tmp_saldi_conti_due = new TIsamtempfile(LF_SALDI);
|
|
}
|
|
|
|
void CG1500_application::user_destroy()
|
|
{
|
|
delete _rel;
|
|
delete _cur;
|
|
delete _com;
|
|
delete _pcn;
|
|
delete _mov;
|
|
delete _rmov;
|
|
delete _clifo;
|
|
delete _saldi;
|
|
delete _nditte;
|
|
delete _anag;
|
|
delete _esc;
|
|
delete _tmp_saldi_att;
|
|
delete _tmp_saldi_pass;
|
|
delete _tmp_saldi_costi;
|
|
delete _tmp_saldi_ricavi;
|
|
delete _tmp_saldi_conti_uno;
|
|
delete _tmp_saldi_conti_due;
|
|
}
|
|
|
|
bool CG1500_application::set_print(int)
|
|
{
|
|
TMask m ("cg1500a");
|
|
KEY tasto;
|
|
{
|
|
TConfig conf(CONFIG_DITTA);
|
|
|
|
_causale_ap = conf.get("CoCaCh");
|
|
_causale_chi = conf.get("CoCaCh");
|
|
}
|
|
m.set_handler (F_DATADA, mask_data_da);
|
|
m.set_handler (F_DATAA, mask_data_a);
|
|
m.set_handler (F_DATALIM, mask_datalim);
|
|
m.set_handler (F_STAMPA1, my_handler);
|
|
m.set_handler (F_VERIFICA, my_handler);
|
|
|
|
tasto = m.run();
|
|
if (tasto == K_ENTER)
|
|
{
|
|
_annoes = atoi(m.get(F_ANNO));
|
|
_bilancio = atoi(m.get(F_BILANCIO));
|
|
_data = m.get(F_DATASTAMPA);
|
|
_dataini = InizioEsercizio(_annoes);
|
|
if (_bilancio == 1)
|
|
{
|
|
_prog = new TProgind(_pcn->items(),"Elaborazione in corso... prego attendere",FALSE);
|
|
_totali = (bool)(m.get(F_TOTALI) == "X");
|
|
_codici = (bool)(m.get(F_CODICI) == "X");
|
|
_saldo = (bool)(m.get(F_SALDO) == "X");
|
|
_tipo_stampa = atoi(m.get(F_STAMPA));
|
|
if (_tipo_stampa == 1)
|
|
{
|
|
_datalim = m.get(F_DATALIM);
|
|
_competenza = (bool)(m.get(F_COMPETENZA) == "X");
|
|
_stampa_mov_prov = (bool)(m.get(F_STAMPAMPROV) == "X");
|
|
}
|
|
bil_sez_contr();
|
|
}
|
|
else
|
|
{
|
|
_stampa_width = atoi(m.get(F_MODULO));
|
|
if (_stampa_width == 1)
|
|
_stampa_width = 132;
|
|
else _stampa_width = 148; //perche' questo e' in realta' il margine dx
|
|
_verifica = atoi(m.get(F_VERIFICA));
|
|
if ( (_verifica == 1)||(_verifica == 2) )
|
|
_prog = new TProgind(_pcn->items(),"Elaborazione in corso... prego attendere",FALSE);
|
|
_tipo_stampa1 = atoi(m.get(F_STAMPA1));
|
|
if (_tipo_stampa1 == 1)
|
|
{
|
|
_datada = m.get(F_DATADA);
|
|
_dataa = m.get(F_DATAA);
|
|
_competenza = (bool)(m.get(F_COMPETENZA) == "X");
|
|
_stampa_mov_prov = (bool)(m.get(F_STAMPAMPROV) == "X");
|
|
}
|
|
if ( (_verifica == 1)||(_verifica == 2) )
|
|
{
|
|
_stampav = atoi(m.get(F_STAMPAV));
|
|
bil_verifica();
|
|
}
|
|
else
|
|
{
|
|
_situazione = m.get(F_SITUAZIONE);
|
|
_stampac = atoi(m.get(F_STAMPAC));
|
|
_ordinamento = atoi(m.get(F_ORDINAMENTO));
|
|
|
|
_cur->setkey(3);
|
|
|
|
if (_situazione.not_empty())
|
|
_cur->filter(format("TIPOCF = \"%s\"",(const char*)_situazione));
|
|
else
|
|
_cur->filter("");
|
|
|
|
_prog = new TProgind(_cur->items(),"Elaborazione in corso... prego attendere",FALSE);
|
|
|
|
if (_ordinamento == 2)
|
|
{
|
|
crea_sort_clifo();
|
|
_sort->endsort();
|
|
delete _cf;
|
|
}
|
|
else
|
|
situazione_clifo();
|
|
}
|
|
}
|
|
delete _prog;
|
|
return TRUE;
|
|
}
|
|
return FALSE;
|
|
}
|
|
|
|
TRectype& look_com (const char * cod, TLocalisamfile *comuni)
|
|
{
|
|
comuni->zero();
|
|
comuni->put(COM_COM, cod);
|
|
comuni->read();
|
|
if (comuni->bad())
|
|
comuni->zero();
|
|
|
|
return comuni->curr();
|
|
}
|
|
|
|
void CG1500_application::get_dati_ditta()
|
|
{
|
|
TLocalisamfile nditte(LF_NDITTE);
|
|
TLocalisamfile anag(LF_ANAG);
|
|
TString codanagr;
|
|
TString tipoa;
|
|
|
|
nditte.zero();
|
|
nditte.put(NDT_CODDITTA, get_firm());
|
|
nditte.read();
|
|
|
|
if (nditte.bad()) nditte.zero();
|
|
|
|
codanagr = nditte.get(NDT_CODANAGR);
|
|
tipoa = nditte.get(NDT_TIPOA);
|
|
_ragsoc = nditte.get(NDT_RAGSOC);
|
|
|
|
anag.setkey(1);
|
|
anag.zero();
|
|
anag.put (ANA_TIPOA, tipoa);
|
|
anag.put (ANA_CODANAGR, codanagr);
|
|
anag.read();
|
|
if (anag.bad()) anag.zero();
|
|
|
|
_cofi = anag.get(ANA_COFI);
|
|
_paiva = anag.get(ANA_PAIV);
|
|
_comunefis = anag.get(ANA_COMRF);
|
|
|
|
if (_comunefis.empty())
|
|
_comunefis = anag.get(ANA_COMRES);
|
|
|
|
TRectype dep = look_com (_comunefis, _com);
|
|
|
|
_comunefis = dep.get(COM_DENCOM);
|
|
_provfis = dep.get(COM_PROVCOM);
|
|
_cap = dep.get(COM_CAPCOM);
|
|
if (_comunefis.empty())
|
|
{
|
|
_viafis = anag.get(ANA_INDRF);
|
|
_viafis.rtrim();
|
|
_viafis << " " << anag.get (ANA_CIVRF);
|
|
}
|
|
else
|
|
{
|
|
_viafis = anag.get(ANA_INDRES);
|
|
_viafis.rtrim();
|
|
_viafis << " " << anag.get (ANA_CIVRES);
|
|
}
|
|
}
|
|
|
|
int CG1500_application::stampa_intestazione_ditta()
|
|
{
|
|
int r = 1;
|
|
TString codice_ditta;
|
|
TString riga(_stampa_width);
|
|
//TString riga(132);
|
|
|
|
get_dati_ditta();
|
|
codice_ditta << get_firm();
|
|
|
|
set_header (r, "Ditta %s %s Via %s %s %s %s", (const char*)codice_ditta,
|
|
(const char*)_ragsoc, (const char*)_viafis,
|
|
(const char*)_cap, (const char*)_comunefis,
|
|
(const char*)_provfis);
|
|
r++;
|
|
printer().setdate(_data);
|
|
riga = "Data @< Pag. @#";
|
|
riga.right_just(_stampa_width-5);
|
|
//riga.right_just(127);
|
|
riga.overwrite (format ("Partita iva %s Codice fiscale %s", (const char*)_paiva, (const char*)_cofi));
|
|
set_header (r, "%s", (const char*) riga);
|
|
r++;
|
|
|
|
return r;
|
|
}
|
|
|
|
void CG1500_application::preprocess_header()
|
|
{
|
|
int r;
|
|
|
|
reset_header();
|
|
r = stampa_intestazione_ditta();
|
|
|
|
if (_bilancio == 1)
|
|
{
|
|
TString riga (132);
|
|
TDate data_da;
|
|
TString data;
|
|
TString data_lim = _datalim.string();
|
|
|
|
set_header(r, "STAMPA BILANCIO A SEZIONI CONTRAPPOSTE");
|
|
if (_tipo_stampa == 1)
|
|
{
|
|
data_da = Controllo_data_limite(_datalim,_annoes,_annoes-1);
|
|
data = data_da.string();
|
|
set_header(r,"@41gdalla data %s alla data %s", (const char*) data,
|
|
(const char*) data_lim);
|
|
if (_competenza)
|
|
set_header(r,"@88g(con controllo competenza)");
|
|
}
|
|
else if (_tipo_stampa == 2)
|
|
set_header(r,"@41gall'ultima immissione Es. in corso");
|
|
else set_header(r, "@41gall'ultima immissione Es. Precedente");
|
|
|
|
r++;
|
|
riga.fill('-');
|
|
set_header(r, (const char*)riga);
|
|
r++;
|
|
riga = "";
|
|
set_header(r, (const char*)riga);
|
|
}
|
|
else // bilancio di verifica
|
|
{
|
|
TString riga (_stampa_width);
|
|
TString datada = _datada.string();
|
|
TString dataa = _dataa.string();
|
|
if (_verifica == 1)
|
|
set_header(r, "STAMPA BILANCIO DI VERIFICA");
|
|
else if (_verifica == 2)
|
|
set_header(r, "STAMPA SALDI DI MASTRO");
|
|
else
|
|
{
|
|
if (_situazione == "C")
|
|
set_header(r, "SITUAZIONE CONTABILE CLIENTI");
|
|
else if (_situazione == "F")
|
|
set_header(r, "SITUAZIONE CONTABILE FORNITORI");
|
|
else set_header(r,"SITUAZIONE CONTABILE CLIENTI E FORNITORI");
|
|
}
|
|
|
|
if (_tipo_stampa1 == 1)
|
|
set_header(r,"@42gdalla data %s alla data %s", (const char*)datada,
|
|
(const char*) dataa);
|
|
else if (_tipo_stampa1 == 2)
|
|
set_header(r,"@42gall'ultima immissione Es. in corso");
|
|
else set_header(r, "@42gall'ultima immissione Es. preced.");
|
|
|
|
if ( (_verifica == 1)||(_verifica == 2) )
|
|
{
|
|
if (_stampav == 1)
|
|
set_header(r,"@86gTutti i conti movimentati");
|
|
else if (_stampav == 2)
|
|
set_header(r,"@86gConti con saldo <> 0");
|
|
else set_header(r,"@86gTutti i conti");
|
|
if (_tipo_stampa1 == 1)
|
|
if (_competenza)
|
|
set_header(r,"@112gControllo competenza");
|
|
}
|
|
else
|
|
{
|
|
if (_stampac == 1)
|
|
set_header(r,"@86gTutti i conti movimentati");
|
|
else set_header(r,"@86gConti con saldo <> 0");
|
|
if (_tipo_stampa1 == 1)
|
|
if (_competenza)
|
|
set_header(r,"@112gControllo competenza");
|
|
}
|
|
|
|
r++;
|
|
riga.fill('-');
|
|
set_header(r, (const char*)riga);
|
|
r++;
|
|
|
|
if ( ((_datada == _dataini)&&(_tipo_stampa1 == 1))||(_tipo_stampa1 != 1) )
|
|
{
|
|
if ( (_verifica == 1)||(_verifica == 3) )
|
|
set_header(r,"@7g|@16g|@49g|@58gSALDO INIZIALE@82g|@88gMOVIMENTI DEL PERIODO@115g|");
|
|
else
|
|
set_header(r,"@7g|@49g|@58gSALDO INIZIALE@82g|@88gMOVIMENTI DEL PERIODO@115g|");
|
|
}
|
|
else if (_tipo_stampa1 == 1)
|
|
if ( (_verifica == 1)||(_verifica == 3) )
|
|
set_header(r,"@7g|@16g|@49g|@55gPROGRESSIVI PRECEDENTI@82g|@88gMOVIMENTI DEL PERIODO@115g|");
|
|
else
|
|
set_header(r,"@7g|@49g|@55gPROGRESSIVI PRECEDENTI@82g|@88gMOVIMENTI DEL PERIODO@115g|");
|
|
|
|
if (_stampa_width == 148)
|
|
set_header(r,"@130gSALDO@148g|");
|
|
r++;
|
|
|
|
if ( (_verifica == 1)||(_verifica == 3) )
|
|
{
|
|
if (_stampa_width == 132)
|
|
{
|
|
set_header(r++,"@2gcod. | ultima |@49g|@50g%.32s@82g|@83g%.32s@115g|@123gSALDO",(const char*)riga, (const char*)riga);
|
|
set_header(r++,"@2gconto| data | denominazione@49g|@58gDare@66g|@73gAvere@82g|@91gDare@99g|@106gAvere@115g|");
|
|
}
|
|
else
|
|
{
|
|
set_header(r++,"@2gcod. | ultima |@49g|@50g%.32s@82g|@83g%.32s@115g|%.32s@148g|",(const char*)riga, (const char*)riga, (const char*)riga);
|
|
set_header(r++,"@2gconto| data | denominazione@49g|@58gDare@66g|@73gAvere@82g|@91gDare@99g|@106gAvere@115g|@124gDare@132g|@139gAvere@148g|");
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (_stampa_width == 132)
|
|
{
|
|
set_header(r++,"@2gcod. |@49g|@50g%.32s@82g|@83g%.32s@115g|@123gSALDO",(const char*)riga, (const char*)riga);
|
|
set_header(r++,"@1gmastro|descrizione@49g|@58gDare@66g|@73gAvere@82g|@91gDare@99g|@106gAvere@115g|");
|
|
}
|
|
else
|
|
{
|
|
set_header(r++,"@2gcod. |@49g|@50g%.32s@82g|@83g%.32s@115g|%.32s@148g|",(const char*)riga, (const char*)riga, (const char*)riga);
|
|
set_header(r++,"@1gmastro|descrizione@49g|@58gDare@66g|@73gAvere@82g|@91gDare@99g|@106gAvere@115g|@124gDare@132g|@139gAvere@148g|");
|
|
}
|
|
}
|
|
set_header(r, (const char*)riga);
|
|
if (_stampa_width == 148)
|
|
set_header(r,"@148g|");
|
|
}
|
|
}
|
|
|
|
int cg1500 (int argc, char* argv[])
|
|
{
|
|
|
|
CG1500_application a;
|
|
|
|
a.run(argc, argv, "Stampa bilanci");
|
|
|
|
return 0;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|