1994-08-23 12:53:59 +00:00
//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"
1994-09-20 11:11:53 +00:00
static TString256 TMP ;
1994-08-23 12:53:59 +00:00
bool my_handler ( TMask_field & f , KEY k ) ;
1994-09-20 11:11:53 +00:00
bool mask_anno ( TMask_field & f , KEY k ) ;
bool mask_datalim ( TMask_field & f , KEY k ) ;
bool mask_date ( TMask_field & f , KEY k ) ;
bool mask_bilancio ( TMask_field & f , KEY k ) ;
bool mask_tipost ( TMask_field & f , KEY k ) ;
HIDDEN int date2esc ( const TDate & d , int * prevesc = NULL ) ;
1994-08-23 12:53:59 +00:00
class CG1500_application : public TPrintapp
{
1994-09-20 11:11:53 +00:00
friend bool mask_anno ( TMask_field & f , KEY k ) ;
1994-08-23 12:53:59 +00:00
friend bool mask_datalim ( TMask_field & f , KEY k ) ;
friend bool my_handler ( TMask_field & f , KEY k ) ;
1994-09-20 11:11:53 +00:00
friend bool mask_date ( TMask_field & f , KEY k ) ;
friend bool mask_bilancio ( TMask_field & f , KEY k ) ;
friend bool mask_tipost ( TMask_field & f , KEY k ) ;
1994-08-23 12:53:59 +00:00
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 ;
1994-10-04 17:25:53 +00:00
TDate udata ;
1994-08-23 12:53:59 +00:00
} ;
cli_for * _cf ;
TSort * _sort ;
const char * _buff ;
TRelation * _rel ;
TCursor * _cur ;
TProgind * _prog ;
1994-10-04 17:25:53 +00:00
TSaldi_list * _listacf , * _lista ;
1994-08-23 12:53:59 +00:00
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 ;
1994-10-04 17:25:53 +00:00
TString _cofi , _cap , _paiva , _ragsoc , _comunefis , _provfis , _viafis ;
1994-08-23 12:53:59 +00:00
TString _descr_dare , _descr_avere , _gc_corr_dare , _gc_corr_avere , _descr ;
1994-10-04 17:25:53 +00:00
TString _gc_prec_dare , _gc_prec_avere , _situazione , _descr_succ ;
char _tipo_conto , _tipoc_succ ;
1994-08-23 12:53:59 +00:00
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 ;
1994-10-04 17:25:53 +00:00
int _gruppo , _conto , _gruppo_succ , _conto_succ , _annoapp ;
1994-08-23 12:53:59 +00:00
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 ;
1994-10-04 17:25:53 +00:00
real _gruppo_da_ordine , _gruppo_a_ordine ;
1994-10-17 13:41:53 +00:00
real _prg_saldoini_dare , _prg_saldoini_avere , _prg_inidare_ord , _prg_iniavere_ord ;
1994-10-04 17:25:53 +00:00
TDate _datalim , _data , _datada , _dataa , _dataini , _ultima_data , _u_max ;
1994-09-20 11:11:53 +00:00
bool _cambiato_conto_1 , _cambiato_conto_2 , _add_file_avere ;
1994-08-23 12:53:59 +00:00
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 ;
1994-10-04 17:25:53 +00:00
TArray _clienti , _fornitori ;
1994-08-23 12:53:59 +00:00
public :
1994-09-20 11:11:53 +00:00
TDate _inizioEs , _fineEs ;
1994-08-23 12:53:59 +00:00
bool menu ( MENU_TAG m ) { return TPrintapp : : menu ( m ) ; }
void user_create ( ) ;
void user_destroy ( ) ;
bool set_print ( int ) ;
1994-10-17 13:41:53 +00:00
void next_c ( ) ;
1994-08-23 12:53:59 +00:00
virtual bool preprocess_print ( int , int ) ;
virtual void preprocess_header ( ) ;
virtual bool preprocess_page ( int , int ) ;
virtual print_action postprocess_page ( int , int ) ;
1994-10-04 17:25:53 +00:00
//virtual print_action postprocess_print(int,int);
virtual void postclose_print ( ) ;
1994-08-23 12:53:59 +00:00
virtual void set_page ( int , int ) ;
1994-10-04 17:25:53 +00:00
real compensazione ( bool compensa , int indbil_conto , real & saldo ) ;
1994-08-23 12:53:59 +00:00
const char * causale_chiusura ( ) { return _causale_chi ; }
const char * causale_apertura ( ) { return _causale_ap ; }
bool bil_sez_contr ( ) ;
bool bil_verifica ( ) ;
1994-10-04 17:25:53 +00:00
bool ricerca_sottoc_clifo ( int , int , bool , int , real & ) ;
1994-09-20 11:11:53 +00:00
bool ricerca_cf ( int , int , char , real & , real & , real & , real & , real & , real & , real & ) ;
bool calcola ( int , int , long ) ;
1994-10-04 17:25:53 +00:00
void leggi_pcon ( ) ; // Inizializza i TArray C/F
1994-08-23 12:53:59 +00:00
void crea_sort_clifo ( ) ;
void init_sort ( ) ;
void leggi_sort ( ) ;
1994-10-04 17:25:53 +00:00
void riempi_record ( char , int , int , long , const char * , const real & ,
1994-09-20 11:11:53 +00:00
const real & , const real & , const real & , const real & ) ;
1994-08-23 12:53:59 +00:00
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 & ,
1994-09-20 11:11:53 +00:00
const real & , const real & ) ;
1994-08-23 12:53:59 +00:00
int stampa_record_conto ( int , int , const char * , const real & , const real & ,
1994-10-04 17:25:53 +00:00
const real & , const real & , const real & , const char ) ;
1994-08-23 12:53:59 +00:00
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 ( ) ;
1994-10-17 13:41:53 +00:00
void stampa_totali_uno ( const real & , const real & ) ;
1994-10-04 17:25:53 +00:00
void controlla_conto ( int , int ) ;
const char * DescrizioneConto ( int , int , long , char ) ; //chiama quella di TConto
1994-08-23 12:53:59 +00:00
TDate UltimaData ( int , int , long , int ) ;
1994-09-20 11:11:53 +00:00
1994-08-23 12:53:59 +00:00
CG1500_application ( ) { }
} ;
1994-09-20 11:11:53 +00:00
HIDDEN CG1500_application * app ( ) { return ( CG1500_application * ) MainApp ( ) ; }
1994-08-23 12:53:59 +00:00
TDate InizioEsercizio ( int anno )
{
TTable TabEs ( " ESC " ) ;
1994-09-20 11:11:53 +00:00
TString16 codtab ;
1994-08-23 12:53:59 +00:00
TDate inizio_es ;
TabEs . zero ( ) ;
codtab . format ( " %04d " , anno ) ;
TabEs . put ( " CODTAB " , codtab ) ;
TabEs . read ( ) ;
if ( TabEs . good ( ) )
1994-09-20 11:11:53 +00:00
inizio_es = TabEs . get_date ( " D0 " ) ;
1994-08-23 12:53:59 +00:00
return inizio_es ;
}
TDate FineEsercizio ( int anno )
{
TTable TabEs ( " ESC " ) ;
1994-09-20 11:11:53 +00:00
TString16 codtab ;
1994-08-23 12:53:59 +00:00
TDate fine_es ;
TabEs . zero ( ) ;
codtab . format ( " %04d " , anno ) ;
TabEs . put ( " CODTAB " , codtab ) ;
TabEs . read ( ) ;
if ( TabEs . good ( ) )
1994-09-20 11:11:53 +00:00
fine_es = TabEs . get_date ( " D1 " ) ;
1994-08-23 12:53:59 +00:00
return fine_es ;
}
1994-09-20 11:11:53 +00:00
bool IsEsercizio ( const TDate & datalim , int anno_eser )
1994-08-23 12:53:59 +00:00
{
TTable TabEs ( " ESC " ) ;
1994-10-04 17:25:53 +00:00
TString16 codtab ;
1994-09-20 11:11:53 +00:00
TDate inizio , fine ;
1994-08-23 12:53:59 +00:00
TabEs . zero ( ) ;
1994-09-20 11:11:53 +00:00
codtab . format ( " %04d " , anno_eser ) ;
1994-08-23 12:53:59 +00:00
TabEs . put ( " CODTAB " , codtab ) ;
TabEs . read ( ) ;
if ( TabEs . good ( ) )
{
1994-09-20 11:11:53 +00:00
inizio = TabEs . get_date ( " D0 " ) ;
fine = TabEs . get_date ( " D1 " ) ;
}
if ( datalim > = inizio & & datalim < = fine )
return TRUE ;
1994-08-23 12:53:59 +00:00
return FALSE ;
}
1994-09-20 11:11:53 +00:00
HIDDEN int date2esc ( const TDate & d , int * prevesc )
{
if ( prevesc ) * prevesc = 0 ;
TTable esc ( " ESC " ) ;
for ( int err = esc . first ( ) ; err = = NOERR ; err = esc . next ( ) )
1994-08-23 12:53:59 +00:00
{
1994-09-20 11:11:53 +00:00
const TDate ia ( esc . get ( " D0 " ) ) ; // Data inizio esercizio
const TDate fa ( esc . get ( " D1 " ) ) ; // Data fine esercizio
const anno = esc . get_int ( " CODTAB " ) ;
app ( ) - > _inizioEs = ia ;
1994-10-04 17:25:53 +00:00
app ( ) - > _fineEs = fa ;
1994-09-20 11:11:53 +00:00
if ( d > = ia & & d < = fa )
return anno ;
if ( prevesc ) * prevesc = anno ;
}
return 0 ;
1994-08-23 12:53:59 +00:00
}
1994-09-20 11:11:53 +00:00
bool mask_anno ( TMask_field & f , KEY k )
1994-08-23 12:53:59 +00:00
{
1994-09-20 11:11:53 +00:00
if ( k = = K_ENTER )
{
int tipo_stampa ;
int anno = f . mask ( ) . get_int ( F_ANNO ) ;
int bilancio = f . mask ( ) . get_int ( F_BILANCIO ) ;
if ( bilancio = = 1 )
tipo_stampa = f . mask ( ) . get_int ( F_STAMPA ) ;
else
tipo_stampa = f . mask ( ) . get_int ( F_STAMPA1 ) ;
if ( tipo_stampa = = 2 )
if ( anno = = 0 )
{
f . error_box ( " Indicare l'anno di esercizio " ) ;
return FALSE ;
}
}
1994-10-04 17:25:53 +00:00
if ( k = = K_TAB | | f . focusdirty ( ) )
1994-09-20 11:11:53 +00:00
{
int tipo_stampa ;
int anno = f . mask ( ) . get_int ( F_ANNO ) ;
int bilancio = f . mask ( ) . get_int ( F_BILANCIO ) ;
if ( bilancio = = 1 )
tipo_stampa = f . mask ( ) . get_int ( F_STAMPA ) ;
else
tipo_stampa = f . mask ( ) . get_int ( F_STAMPA1 ) ;
1994-08-23 12:53:59 +00:00
1994-09-20 11:11:53 +00:00
if ( ( bilancio = = 2 ) & & ( tipo_stampa = = 1 ) )
if ( anno ! = 0 )
{
f . mask ( ) . show ( F_DATADA ) ;
f . mask ( ) . show ( F_DATAA ) ;
f . mask ( ) . show ( F_STAMPAMPROV ) ;
f . mask ( ) . show ( 96 ) ;
f . mask ( ) . show ( 97 ) ;
f . mask ( ) . hide ( 98 ) ;
f . mask ( ) . hide ( 99 ) ;
}
else
{
f . mask ( ) . show ( F_DATADA ) ;
f . mask ( ) . show ( F_DATAA ) ;
f . mask ( ) . show ( F_STAMPAMPROV ) ;
f . mask ( ) . show ( 98 ) ;
f . mask ( ) . show ( 99 ) ;
f . mask ( ) . hide ( 96 ) ;
f . mask ( ) . hide ( 97 ) ;
}
}
return TRUE ;
1994-08-23 12:53:59 +00:00
}
1994-09-20 11:11:53 +00:00
bool mask_bilancio ( TMask_field & f , KEY k )
1994-08-23 12:53:59 +00:00
{
1994-09-20 11:11:53 +00:00
TMask & m = f . mask ( ) ;
1994-08-23 12:53:59 +00:00
1994-09-20 11:11:53 +00:00
if ( k = = K_SPACE )
{
int tipo_stampa ;
int anno = m . get_int ( F_ANNO ) ;
int bilancio = m . get_int ( F_BILANCIO ) ;
if ( bilancio = = 1 ) //bilancio a sezioni contrapposte
{
tipo_stampa = m . get_int ( F_STAMPA ) ;
m . disable_page ( 1 ) ;
}
else
{
tipo_stampa = m . get_int ( F_STAMPA1 ) ;
m . enable_page ( 1 ) ;
}
if ( bilancio = = 1 | | bilancio = = 2 )
if ( tipo_stampa = = 2 ) //all'ultima immissione
{
m . hide ( F_DATADA ) ;
m . hide ( F_DATAA ) ;
m . hide ( F_STAMPAMPROV ) ;
m . hide ( 98 ) ;
m . hide ( 99 ) ;
m . hide ( 96 ) ;
m . hide ( 97 ) ;
}
else
{
if ( bilancio = = 2 )
if ( anno ! = 0 )
{
m . show ( F_DATADA ) ;
m . show ( F_DATAA ) ;
m . show ( F_STAMPAMPROV ) ;
m . show ( 96 ) ;
m . show ( 97 ) ;
m . hide ( 98 ) ;
m . hide ( 99 ) ;
}
else
{
m . show ( F_DATADA ) ;
m . show ( F_DATAA ) ;
m . show ( F_STAMPAMPROV ) ;
m . show ( 98 ) ;
m . show ( 99 ) ;
m . hide ( 96 ) ;
m . hide ( 97 ) ;
}
}
}
return TRUE ;
}
bool mask_datalim ( TMask_field & f , KEY k )
{
if ( k = = K_ENTER )
{
int anno = f . mask ( ) . get_int ( F_ANNO ) ;
int bilancio = f . mask ( ) . get_int ( F_BILANCIO ) ;
TDate datalim ( f . mask ( ) . get ( F_DATALIM ) ) ;
if ( bilancio = = 1 )
if ( anno ! = 0 )
{
if ( datalim . ok ( ) )
{
if ( ! IsEsercizio ( datalim , anno ) )
{
f . error_box ( " La data limite deve appartenere all'esercizio indicato " ) ;
return FALSE ;
}
}
else
f . mask ( ) . field ( F_DATALIM ) . set ( FineEsercizio ( anno ) ) ;
}
1994-10-04 17:25:53 +00:00
else //anno == 0
1994-09-20 11:11:53 +00:00
{
if ( ! datalim . ok ( ) )
{
f . error_box ( " La data limite e' obbligatoria " ) ;
return FALSE ;
}
1994-10-04 17:25:53 +00:00
long anno = date2esc ( datalim ) ;
if ( anno = = 0 )
1994-09-20 11:11:53 +00:00
{
f . error_box ( " La data limite deve appartenere ad un esercizio attivo della ditta " ) ;
return FALSE ;
1994-10-04 17:25:53 +00:00
}
f . mask ( ) . set ( F_ANNO , anno ) ;
1994-09-20 11:11:53 +00:00
}
}
return TRUE ;
}
1994-08-23 12:53:59 +00:00
1994-09-20 11:11:53 +00:00
bool mask_date ( TMask_field & f , KEY k )
{
if ( k = = K_ENTER )
{
const short id = f . dlg ( ) ;
int anno = f . mask ( ) . get_int ( F_ANNO ) ;
int bilancio = f . mask ( ) . get_int ( F_BILANCIO ) ;
if ( bilancio = = 2 )
{
TDate data ( f . mask ( ) . get ( id ) ) ;
if ( anno ! = 0 )
{
if ( data . ok ( ) )
{
if ( ! IsEsercizio ( data , anno ) )
{
f . error_box ( " La data indicata deve essere all'interno dell'esercizio " ) ;
return FALSE ;
}
}
if ( ! data . ok ( ) )
{
if ( id = = F_DATADA )
f . mask ( ) . field ( F_DATADA ) . set ( InizioEsercizio ( anno ) ) ;
else if ( id = = F_DATAA )
f . mask ( ) . field ( F_DATAA ) . set ( FineEsercizio ( anno ) ) ;
1994-10-04 17:25:53 +00:00
}
app ( ) - > _annoapp = anno ;
1994-09-20 11:11:53 +00:00
}
else
{
if ( ! data . ok ( ) )
{
1994-10-04 17:25:53 +00:00
f . error_box ( " Indicare una data appartenente ad un esercizio attivo della ditta " ) ;
1994-09-20 11:11:53 +00:00
return FALSE ;
}
else
{
//date2esc(datada);
//const TString16 ie(app()->_inizioEs.string());
//const TString16 fe(app()->_fineEs.string());
//if (datada < app()->_inizioEs || dataa > app()->_fineEs)
//{
// f.error_box("Le date devono essere comprese tra %s e %s",
// (const char*)ie, (const char*)fe);
// return FALSE;
//}
if ( id = = F_DATAA )
{
TDate from ( f . mask ( ) . get ( id - 1 ) ) ;
1994-10-04 17:25:53 +00:00
app ( ) - > _annoapp = date2esc ( from ) ;
if ( app ( ) - > _annoapp ! = date2esc ( data ) )
1994-09-20 11:11:53 +00:00
{
1994-10-04 17:25:53 +00:00
f . error_box ( " Le date devono appartenere ad uno stesso esercizio attivo della ditta " ) ;
1994-09-20 11:11:53 +00:00
return FALSE ;
}
if ( from > data )
{
f . error_box ( " La data limite inferiore non puo' essere maggiore della data limite superiore " ) ;
return FALSE ;
}
1994-10-04 17:25:53 +00:00
//f.mask().set(F_ANNO, anno);
1994-09-20 11:11:53 +00:00
}
}
}
}
}
return TRUE ;
1994-08-23 12:53:59 +00:00
}
1994-09-20 11:11:53 +00:00
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_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 ( ) . hide ( F_STAMPAV ) ;
f . mask ( ) . show ( F_STAMPAMPROV ) ;
}
if ( ( tipo_stampa = = 2 ) & & ( ( 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_STAMPAMPROV ) ;
f . mask ( ) . show ( F_STAMPAV ) ;
}
if ( ( tipo_stampa = = 2 ) & & ( 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_STAMPAMPROV ) ;
f . mask ( ) . hide ( F_STAMPAV ) ;
}
}
return TRUE ;
}
1994-08-23 12:53:59 +00:00
void CG1500_application : : scrivig_file_temp ( )
{
TIsamtempfile * tmp = NULL ;
TString nome_campo ( 12 ) ;
real valore ;
1994-10-17 13:41:53 +00:00
if ( ! _totali )
1994-08-23 12:53:59 +00:00
{
1994-10-17 13:41:53 +00:00
if ( _add_dare )
1994-10-04 17:25:53 +00:00
{
1994-10-17 13:41:53 +00:00
nome_campo = SLD_PDARE ;
valore = _gruppo_da ;
switch ( _indbil )
{
case 1 :
case 2 :
tmp = _tmp_saldi_att ;
break ;
case 3 :
case 4 :
tmp = _tmp_saldi_costi ;
break ;
case 5 :
tmp = _tmp_saldi_conti_uno ;
valore = _gruppo_da_ordine ;
break ;
default :
break ;
}
tmp - > zero ( ) ;
tmp - > put ( SLD_GRUPPO , _gp ) ;
if ( tmp - > read ( ) = = NOERR )
{
tmp - > put ( SLD_CONTO , 0 ) ;
tmp - > put ( SLD_SOTTOCONTO , 0L ) ;
tmp - > put ( nome_campo , valore ) ;
tmp - > rewrite ( ) ;
}
else
{
tmp - > put ( SLD_CONTO , 0 ) ;
tmp - > put ( SLD_SOTTOCONTO , 0L ) ;
tmp - > put ( nome_campo , valore ) ;
tmp - > write ( ) ;
}
1994-10-04 17:25:53 +00:00
}
1994-10-17 13:41:53 +00:00
if ( _add_avere )
1994-10-04 17:25:53 +00:00
{
1994-10-17 13:41:53 +00:00
nome_campo = SLD_PAVERE ;
valore = _gruppo_a ;
switch ( _indbil )
{
case 1 :
case 2 :
tmp = _tmp_saldi_pass ;
break ;
case 3 :
case 4 :
tmp = _tmp_saldi_ricavi ;
break ;
case 5 :
tmp = _tmp_saldi_conti_due ;
valore = _gruppo_a_ordine ;
break ;
default :
break ;
}
tmp - > zero ( ) ;
tmp - > put ( SLD_GRUPPO , _gp ) ;
if ( tmp - > read ( ) = = NOERR )
{
tmp - > put ( SLD_CONTO , 0 ) ;
tmp - > put ( SLD_SOTTOCONTO , 0L ) ;
tmp - > put ( nome_campo , valore ) ;
tmp - > rewrite ( ) ;
}
else
{
tmp - > put ( SLD_CONTO , 0 ) ;
tmp - > put ( SLD_SOTTOCONTO , 0L ) ;
tmp - > put ( nome_campo , valore ) ;
tmp - > write ( ) ;
}
1994-10-04 17:25:53 +00:00
}
1994-08-23 12:53:59 +00:00
}
_add_dare = _add_avere = FALSE ;
}
void CG1500_application : : scrivic_file_temp ( )
{
TIsamtempfile * tmp = NULL ;
TString nome_campo ( 12 ) ;
real valore ;
if ( _add_file_dare )
{
_add_dare = TRUE ;
nome_campo = SLD_PDARE ;
valore = _conto_da ;
if ( _indbil = = 1 | | _indbil = = 2 ) tmp = _tmp_saldi_att ; // da stampare a sx
else
if ( _indbil = = 3 | | _indbil = = 4 ) tmp = _tmp_saldi_costi ; //da stampare a sx
else
1994-09-20 11:11:53 +00:00
if ( _indbil = = 5 ) tmp = _tmp_saldi_conti_uno ;
else return ;
tmp - > zero ( ) ;
tmp - > put ( SLD_GRUPPO , _gp ) ;
tmp - > put ( SLD_CONTO , _cp ) ;
tmp - > put ( SLD_SOTTOCONTO , 0L ) ;
tmp - > put ( nome_campo , valore ) ;
tmp - > write ( ) ;
1994-08-23 12:53:59 +00:00
}
if ( _add_file_avere )
{
_add_avere = TRUE ;
nome_campo = SLD_PAVERE ;
valore = _conto_a ;
if ( _indbil = = 2 | | _indbil = = 1 ) tmp = _tmp_saldi_pass ; //da stampare a dx
else
if ( _indbil = = 4 | | _indbil = = 3 ) tmp = _tmp_saldi_ricavi ; //da stampare a dx
else
1994-09-20 11:11:53 +00:00
if ( _indbil = = 5 ) tmp = _tmp_saldi_conti_due ;
else return ;
tmp - > zero ( ) ;
tmp - > put ( SLD_GRUPPO , _gp ) ;
tmp - > put ( SLD_CONTO , _cp ) ;
tmp - > put ( SLD_SOTTOCONTO , 0L ) ;
tmp - > put ( nome_campo , valore ) ;
tmp - > write ( ) ;
1994-08-23 12:53:59 +00:00
}
1994-09-20 11:11:53 +00:00
/*
tmp - > zero ( ) ;
tmp - > put ( SLD_GRUPPO , _gp ) ;
tmp - > put ( SLD_CONTO , _cp ) ;
tmp - > put ( SLD_SOTTOCONTO , 0L ) ;
tmp - > put ( nome_campo , valore ) ;
tmp - > write ( ) ;
*/
1994-08-23 12:53:59 +00:00
}
void CG1500_application : : scrivis_file_temp ( int g , int c , long s , real saldo )
{
TIsamtempfile * tmp = NULL ;
TString nome_campo ( 12 ) ;
if ( _indbil = = 1 )
{
1994-09-20 11:11:53 +00:00
tmp = _tmp_saldi_att ;
nome_campo = SLD_PDARE ;
1994-08-23 12:53:59 +00:00
}
else
1994-09-20 11:11:53 +00:00
if ( _indbil = = 2 )
1994-08-23 12:53:59 +00:00
{
1994-09-20 11:11:53 +00:00
tmp = _tmp_saldi_pass ;
nome_campo = SLD_PAVERE ;
}
1994-08-23 12:53:59 +00:00
else
1994-09-20 11:11:53 +00:00
if ( _indbil = = 3 )
1994-08-23 12:53:59 +00:00
{
1994-09-20 11:11:53 +00:00
tmp = _tmp_saldi_costi ;
nome_campo = SLD_PDARE ;
1994-08-23 12:53:59 +00:00
}
else
1994-09-20 11:11:53 +00:00
if ( _indbil = = 4 )
{
tmp = _tmp_saldi_ricavi ;
nome_campo = SLD_PAVERE ;
}
else
if ( _sottoc_dare )
{
tmp = _tmp_saldi_conti_uno ;
nome_campo = SLD_PDARE ;
}
else
if ( _sottoc_avere )
{
tmp = _tmp_saldi_conti_due ;
nome_campo = SLD_PAVERE ;
}
1994-08-23 12:53:59 +00:00
tmp - > zero ( ) ;
tmp - > put ( SLD_GRUPPO , g ) ;
tmp - > put ( SLD_CONTO , c ) ;
tmp - > put ( SLD_SOTTOCONTO , s ) ;
tmp - > put ( nome_campo , saldo ) ;
tmp - > write ( ) ;
}
1994-10-04 17:25:53 +00:00
real CG1500_application : : compensazione ( bool compensa , int indbil_conto , real & sld )
{
real saldo = sld ;
if ( ! compensa )
{
switch ( indbil_conto )
{
case 1 :
if ( saldo > ZERO )
_indbil = indbil_conto ;
else
{
_indbil = 2 ;
saldo = - saldo ;
}
break ;
case 3 :
if ( saldo > ZERO )
_indbil = indbil_conto ;
else
{
_indbil = 4 ;
saldo = - saldo ;
}
break ;
case 2 :
if ( saldo < ZERO )
{
_indbil = indbil_conto ;
saldo = - saldo ;
}
else
_indbil = 1 ;
break ;
case 4 :
if ( saldo < ZERO )
{
_indbil = indbil_conto ;
saldo = - saldo ;
}
else
_indbil = 3 ;
break ;
case 5 :
default : break ;
}
}
else //e' richiesta la compensazione
if ( indbil_conto = = 2 | | indbil_conto = = 4 )
saldo = - saldo ;
return saldo ;
}
1994-10-17 13:41:53 +00:00
void CG1500_application : : next_c ( )
{
TRecnotype recnum = _pcn - > recno ( ) ;
_pcn - > next ( ) ;
if ( _pcn - > eof ( ) )
{
scrivic_file_temp ( ) ;
scrivig_file_temp ( ) ;
}
_pcn - > readat ( recnum ) ;
}
1994-08-23 12:53:59 +00:00
bool CG1500_application : : bil_sez_contr ( )
{
Saldo sld ;
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 ;
1994-10-17 13:41:53 +00:00
bool movimentato = FALSE ;
1994-10-04 17:25:53 +00:00
1994-08-23 12:53:59 +00:00
_tmp_saldi_att - > open ( " cg01 " ) ;
1994-09-20 11:11:53 +00:00
_prog - > addstatus ( 1 ) ;
1994-08-23 12:53:59 +00:00
_tmp_saldi_pass - > open ( " cg02 " ) ;
_prog - > addstatus ( 1 ) ;
_tmp_saldi_costi - > open ( " cg03 " ) ;
1994-09-20 11:11:53 +00:00
_prog - > addstatus ( 1 ) ;
1994-08-23 12:53:59 +00:00
_tmp_saldi_ricavi - > open ( " cg04 " ) ;
_prog - > addstatus ( 1 ) ;
_tmp_saldi_conti_uno - > open ( " cg05 " ) ;
1994-09-20 11:11:53 +00:00
_prog - > addstatus ( 1 ) ;
1994-08-23 12:53:59 +00:00
_tmp_saldi_conti_due - > open ( " cg06 " ) ;
1994-09-20 11:11:53 +00:00
_prog - > addstatus ( 1 ) ;
1994-08-23 12:53:59 +00:00
_gp = - 1 ;
_cp = - 1 ;
1994-10-04 17:25:53 +00:00
_gruppo_a = ZERO ;
_gruppo_da = ZERO ;
_gruppo_da_ordine = ZERO ;
_gruppo_a_ordine = ZERO ;
_prg_saldoini_dare = ZERO ;
1994-10-17 13:41:53 +00:00
_prg_saldoini_avere = ZERO ;
_prg_inidare_ord = ZERO ;
_prg_iniavere_ord = ZERO ;
1994-08-23 12:53:59 +00:00
_conto_a = ZERO ;
_conto_da = ZERO ;
_add_dare = FALSE ;
_add_avere = FALSE ;
1994-09-20 11:11:53 +00:00
sld . set_annoes ( _annoes ) ;
1994-08-23 12:53:59 +00:00
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 )
1994-09-20 11:11:53 +00:00
cambiato = TRUE ;
1994-08-23 12:53:59 +00:00
if ( ( ( ( _cp ! = - 1 ) & & ( c ! = _cp ) ) | | ( ( _gp ! = - 1 ) & & ( g ! = _gp ) ) ) & &
1994-09-20 11:11:53 +00:00
esiste_sc )
1994-08-23 12:53:59 +00:00
{
scrivic_file_temp ( ) ;
1994-10-04 17:25:53 +00:00
scrivig_file_temp ( ) ;
1994-08-23 12:53:59 +00:00
_cp = c ;
1994-10-17 13:41:53 +00:00
esiste_conto = TRUE ;
_conto_da = ZERO ;
_conto_a = ZERO ;
1994-08-23 12:53:59 +00:00
}
if ( ( ( _gp ! = - 1 ) & & ( g ! = _gp ) ) & & esiste_conto )
{
scrivig_file_temp ( ) ;
esiste_conto = FALSE ;
_gp = g ;
_gruppo_da = ZERO ;
_gruppo_a = ZERO ;
1994-10-04 17:25:53 +00:00
_gruppo_da_ordine = ZERO ;
_gruppo_a_ordine = ZERO ;
1994-08-23 12:53:59 +00: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 ' ) )
{
1994-10-04 17:25:53 +00:00
saldo = ZERO ;
esiste_sc = ricerca_sottoc_clifo ( g , c , compensa ,
1994-09-20 11:11:53 +00:00
indbil_conto , saldo ) ;
1994-08-23 12:53:59 +00:00
if ( esiste_sc )
1994-09-20 11:11:53 +00:00
{
_gp = g ;
_cp = c ;
1994-08-23 12:53:59 +00:00
}
TRecnotype recnum = _pcn - > recno ( ) ;
_pcn - > next ( ) ;
1994-09-20 11:11:53 +00:00
if ( _pcn - > eof ( ) )
{
if ( esiste_sc )
1994-08-23 12:53:59 +00:00
{
1994-09-20 11:11:53 +00:00
scrivic_file_temp ( ) ;
scrivig_file_temp ( ) ;
}
1994-08-23 12:53:59 +00:00
else if ( esiste_conto )
1994-09-20 11:11:53 +00:00
scrivig_file_temp ( ) ;
1994-08-23 12:53:59 +00:00
}
1994-09-20 11:11:53 +00:00
_pcn - > readat ( recnum ) ;
1994-08-23 12:53:59 +00:00
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
1994-10-17 13:41:53 +00:00
movimentato = sld . data_limite_bilancio ( _bilancio , g , c , s , _dataini , _datalim , indbil_conto , _stampa_mov_prov ) ;
1994-10-04 17:25:53 +00:00
else
if ( _tipo_stampa = = 2 ) //bil. a sez. contrapposte all'ultima immissione es. in corso
1994-10-17 13:41:53 +00:00
movimentato = sld . ultima_immissione_bilancio ( _annoes , g , c , s , indbil_conto ) ;
1994-08-23 12:53:59 +00:00
1994-10-17 13:41:53 +00:00
if ( ! movimentato )
if ( ! sld . esiste_saldo ( ) | | ! sld . significativo ( ) )
{
next_c ( ) ;
continue ;
}
saldo = sld . saldo ( ) ;
1994-08-23 12:53:59 +00:00
1994-10-17 13:41:53 +00:00
if ( _saldo ) //se richiesto di NON stampare i conti con saldo a zero
if ( saldo = = ZERO )
{
next_c ( ) ;
continue ;
}
esiste_sc = TRUE ;
_indbil = indbil_conto ;
//i due flag seguenti servono solo per i conti d'ordine
_sottoc_dare = FALSE ;
_sottoc_avere = FALSE ;
1994-08-23 12:53:59 +00:00
1994-10-17 13:41:53 +00:00
//error_box ("saldo = %s", saldo.string());
if ( saldo ! = ZERO )
saldo = compensazione ( compensa , indbil_conto , saldo ) ;
if ( _indbil = = 1 | | _indbil = = 2 )
{
real app = sld . saldoini ( ) ;
if ( app > ZERO )
_prg_saldoini_dare + = app ;
else if ( app < ZERO )
1994-10-04 17:25:53 +00:00
{
1994-10-17 13:41:53 +00:00
app = - app ;
_prg_saldoini_avere + = app ;
}
}
if ( _indbil = = 5 )
{
real app = sld . saldoini ( ) ;
if ( app > ZERO )
_prg_inidare_ord + = app ;
else if ( app < ZERO )
1994-09-20 11:11:53 +00:00
{
1994-10-17 13:41:53 +00:00
app = - app ;
_prg_iniavere_ord + = app ;
1994-10-04 17:25:53 +00:00
}
1994-10-17 13:41:53 +00:00
}
if ( _indbil = = 1 | | _indbil = = 3 )
{
_gruppo_da + = saldo ;
_conto_da + = saldo ;
_add_file_dare = TRUE ;
}
1994-10-04 17:25:53 +00:00
1994-10-17 13:41:53 +00:00
if ( _indbil = = 2 | | _indbil = = 4 )
{
_gruppo_a + = saldo ;
_conto_a + = saldo ;
_add_file_avere = TRUE ;
}
if ( _indbil = = 5 )
{
if ( saldo > = ZERO | | compensa )
1994-09-20 11:11:53 +00:00
{
1994-10-17 13:41:53 +00:00
_gruppo_da_ordine + = saldo ;
_conto_da + = saldo ;
_add_file_dare = TRUE ;
_sottoc_dare = TRUE ;
}
else
1994-10-04 17:25:53 +00:00
{
1994-10-17 13:41:53 +00:00
saldo = - saldo ;
_gruppo_a_ordine + = saldo ;
_conto_a + = saldo ;
_add_file_avere = TRUE ;
_sottoc_avere = TRUE ;
1994-10-04 17:25:53 +00:00
}
1994-10-17 13:41:53 +00:00
scrivig_file_temp ( ) ;
1994-10-04 17:25:53 +00:00
}
1994-10-17 13:41:53 +00:00
if ( ( dettaglio ) & & ( ( tipo_conto ! = ' C ' ) & & ( tipo_conto ! = ' F ' ) ) )
scrivis_file_temp ( g , c , s , saldo ) ;
_gp = g ;
_cp = c ;
// } // da_considerare
1994-09-20 11:11:53 +00:00
1994-08-23 12:53:59 +00:00
TRecnotype recnum = _pcn - > recno ( ) ;
_pcn - > next ( ) ;
if ( _pcn - > eof ( ) )
{
scrivic_file_temp ( ) ;
scrivig_file_temp ( ) ;
}
_pcn - > readat ( recnum ) ;
}
1994-09-20 11:11:53 +00:00
1994-08-23 12:53:59 +00:00
return TRUE ;
}
1994-10-04 17:25:53 +00:00
bool CG1500_application : : ricerca_sottoc_clifo ( int g , int c , bool compensa , int indbil_conto , real & saldo )
1994-08-23 12:53:59 +00:00
{
1994-10-17 13:41:53 +00:00
TSaldo sld ;
int aep = 0 ;
long s , items ;
bool esiste_sc = FALSE ;
bool movimentato = FALSE ;
if ( _annoes ) aep = _annoes - 1 ;
1994-09-20 11:11:53 +00:00
sld . set_annoes ( _annoes ) ;
1994-10-17 13:41:53 +00:00
_listacf = new TSaldi_list ( g , c , _annoes , aep ) ;
items = _listacf - > items ( ) ;
1994-08-23 12:53:59 +00:00
for ( int i = 0 ; i < items ; i + + )
{
1994-10-17 13:41:53 +00:00
const TRectype * r = _listacf - > saldi ( ) ;
if ( r = = NULL ) break ;
s = r - > get_long ( SLD_SOTTOCONTO ) ;
1994-08-23 12:53:59 +00:00
if ( _tipo_stampa = = 1 ) //bil. a sez. contrapposte per data limite
1994-10-17 13:41:53 +00:00
movimentato = sld . data_limite_bilancio ( _bilancio , g , c , s , _dataini , _datalim , indbil_conto , _stampa_mov_prov ) ;
1994-09-20 11:11:53 +00:00
else if ( _tipo_stampa = = 2 ) //bil. a sez. contrapposte all'ultima immissione es. in corso
1994-10-17 13:41:53 +00:00
movimentato = sld . ultima_immissione_bilancio ( _annoes , g , c , s , indbil_conto ) ;
1994-08-23 12:53:59 +00:00
1994-10-17 13:41:53 +00:00
if ( ! movimentato )
if ( ! sld . esiste_saldo ( ) | | ! sld . significativo ( ) )
continue ;
saldo = sld . saldo ( ) ;
1994-08-23 12:53:59 +00:00
if ( _saldo ) //se richiesto di non stampare i conti con saldo a zero
1994-09-20 11:11:53 +00:00
if ( saldo = = 0 )
continue ;
1994-08-23 12:53:59 +00:00
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());
1994-10-04 17:25:53 +00:00
if ( saldo ! = ZERO )
saldo = compensazione ( compensa , indbil_conto , saldo ) ;
if ( _indbil = = 1 | | _indbil = = 2 )
1994-08-23 12:53:59 +00:00
{
1994-10-04 17:25:53 +00:00
real app = sld . saldoini ( ) ;
if ( app > ZERO )
_prg_saldoini_dare + = app ;
else if ( app < ZERO )
1994-08-23 12:53:59 +00:00
{
1994-10-04 17:25:53 +00:00
app = - app ;
_prg_saldoini_avere + = app ;
}
}
1994-10-17 13:41:53 +00:00
if ( _indbil = = 5 )
{
real app = sld . saldoini ( ) ;
if ( app > ZERO )
_prg_inidare_ord + = app ;
else if ( app < ZERO )
{
app = - app ;
_prg_iniavere_ord + = app ;
}
}
1994-08-23 12:53:59 +00:00
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 )
1994-10-04 17:25:53 +00:00
{
1994-09-20 11:11:53 +00:00
if ( ( saldo > = ZERO ) | | ( compensa ) ) // il sottoconto ha saldo in dare
{
1994-10-04 17:25:53 +00:00
_gruppo_da_ordine + = saldo ;
_conto_da + = saldo ;
_add_file_dare = TRUE ;
_sottoc_dare = TRUE ;
1994-09-20 11:11:53 +00:00
}
else //il sottoconto ha saldo in avere
{
saldo = - saldo ;
1994-10-04 17:25:53 +00:00
_gruppo_a_ordine + = saldo ;
1994-09-20 11:11:53 +00:00
_conto_a + = saldo ;
_add_file_avere = TRUE ;
_sottoc_avere = TRUE ;
1994-10-04 17:25:53 +00:00
}
scrivig_file_temp ( ) ;
}
1994-08-23 12:53:59 +00:00
}
delete _listacf ;
return esiste_sc ;
}
bool CG1500_application : : bil_verifica ( )
{
Saldo sld ;
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 ;
1994-10-04 17:25:53 +00:00
bool esiste_conto = FALSE , esiste_sc = FALSE , movimentato = FALSE ;
1994-09-20 11:11:53 +00:00
1994-08-23 12:53:59 +00:00
_tmp_saldi_att - > open ( " cg01 " ) ;
1994-09-20 11:11:53 +00:00
1994-08-23 12:53:59 +00:00
_gp = - 1 ;
_cp = - 1 ;
_saldo_ini_conto_dare = ZERO ;
_saldo_ini_conto_avere = ZERO ;
_saldo_ini_gruppo_dare = ZERO ;
_saldo_ini_gruppo_avere = ZERO ;
saldo_conto = ZERO ;
mov_conto_dare = ZERO ;
mov_conto_avere = ZERO ;
prg_conto_dare = ZERO ;
prg_conto_avere = ZERO ;
saldo_gruppo = ZERO ;
mov_gruppo_dare = ZERO ;
mov_gruppo_avere = ZERO ;
prg_gruppo_dare = ZERO ;
1994-10-04 17:25:53 +00:00
prg_gruppo_avere = ZERO ;
_u_max = 0l ;
1994-08-23 12:53:59 +00:00
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 ) ) ) & &
1994-09-20 11:11:53 +00:00
esiste_sc )
1994-08-23 12:53:59 +00:00
{
if ( _verifica = = 2 )
1994-09-20 11:11:53 +00:00
if ( ! ( ( _stampav = = 2 ) & & ( saldo_conto = = 0 ) ) )
{
real app = _saldo_ini_conto_dare + _saldo_ini_conto_avere ;
if ( app < ZERO )
_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 ;
}
1994-08-23 12:53:59 +00:00
//scrivo il record del conto;
if ( ( _verifica = = 1 ) | | ( ( _verifica = = 2 ) & &
1994-09-20 11:11:53 +00:00
( ! ( ( _stampav = = 2 ) & & ( saldo_conto = = 0 ) ) ) ) )
1994-08-23 12:53:59 +00:00
{
1994-09-20 11:11:53 +00:00
scrivi_record_conto ( prg_conto_dare , prg_conto_avere , mov_conto_dare ,
mov_conto_avere , saldo_conto ) ;
esiste_conto = TRUE ;
1994-08-23 12:53:59 +00:00
}
_cp = c ;
_saldo_ini_conto_dare = ZERO ;
_saldo_ini_conto_avere = ZERO ;
saldo_conto = ZERO ;
mov_conto_dare = ZERO ;
mov_conto_avere = ZERO ;
prg_conto_dare = ZERO ;
prg_conto_avere = ZERO ;
}
if ( _verifica = = 2 )
1994-09-20 11:11:53 +00:00
if ( ( ( _gp ! = - 1 ) & & ( g ! = _gp ) ) & & ( ! esiste_conto ) )
{
_gp = g ;
_saldo_ini_gruppo_dare = ZERO ;
_saldo_ini_gruppo_avere = ZERO ;
saldo_gruppo = ZERO ;
mov_gruppo_dare = ZERO ;
mov_gruppo_avere = ZERO ;
prg_gruppo_dare = ZERO ;
prg_gruppo_avere = ZERO ;
}
1994-08-23 12:53:59 +00:00
if ( _verifica = = 2 )
1994-09-20 11:11:53 +00:00
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 = ZERO ;
_saldo_ini_gruppo_avere = ZERO ;
saldo_gruppo = ZERO ;
mov_gruppo_dare = ZERO ;
mov_gruppo_avere = ZERO ;
prg_gruppo_dare = ZERO ;
prg_gruppo_avere = ZERO ;
}
1994-08-23 12:53:59 +00: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 ,
1994-09-20 11:11:53 +00:00
mov_conto_dare , mov_conto_avere , prg_conto_dare , prg_conto_avere ,
saldo_conto ) ;
1994-08-23 12:53:59 +00:00
if ( ( _verifica = = 2 ) & & ( _stampav = = 2 ) )
1994-09-20 11:11:53 +00:00
if ( saldo_conto = = 0 )
continue ;
1994-08-23 12:53:59 +00:00
if ( esiste_sc )
{
_gp = g ;
1994-09-20 11:11:53 +00:00
_cp = c ;
TRecnotype recnum = _pcn - > recno ( ) ;
_pcn - > next ( ) ;
if ( _pcn - > eof ( ) )
1994-08-23 12:53:59 +00:00
{
1994-09-20 11:11:53 +00:00
if ( _verifica = = 2 )
{
real app = _saldo_ini_conto_dare + _saldo_ini_conto_avere ;
if ( app < ZERO )
_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 ,
1994-08-23 12:53:59 +00:00
mov_conto_avere , saldo_conto ) ;
1994-09-20 11:11:53 +00:00
}
_pcn - > readat ( recnum ) ;
1994-08-23 12:53:59 +00:00
}
continue ;
}
}
1994-09-20 11:11:53 +00:00
1994-08-23 12:53:59 +00:00
if ( ( c = = 0 ) | | ( s = = 0 ) )
{
esiste_sc = FALSE ;
continue ;
}
saldo_finale = ZERO ; //saldo finale relativo a ciascun sottoconto
_indbil = indbil_conto ;
if ( _tipo_stampa1 = = 1 ) //bil. di verifica per data limite
{
1994-10-04 17:25:53 +00:00
//if ( !calcola(g,c,s) )//il conto non e' movimentato
// if (_stampav == 1)
// continue;
movimentato = calcola ( g , c , s ) ;
1994-09-20 11:11:53 +00:00
1994-10-04 17:25:53 +00:00
if ( movimentato | | _stampav ! = 1 )
{
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 == ZERO)
// if (_stampav == 2)
// continue;
}
1994-08-23 12:53:59 +00:00
//se saldo_finale < 0 verra' stampato con una A, se no con una D
}
else
{
1994-10-04 17:25:53 +00:00
//if (!sld.ultima_immissione_bilancio(_annoes,g,c,s,indbil_conto))
// if (_stampav == 1)
// continue;
1994-10-17 13:41:53 +00:00
movimentato = sld . ultima_immissione_verifica ( _annoes , g , c , s , indbil_conto ) ;
1994-09-20 11:11:53 +00:00
1994-10-04 17:25:53 +00:00
if ( movimentato | | _stampav ! = 1 )
{
saldo_iniziale = sld . saldoini ( ) ;
1994-08-23 12:53:59 +00:00
1994-10-04 17:25:53 +00:00
_mov_periodo_dare = sld . prgdare ( ) ;
_mov_periodo_avere = sld . prgavere ( ) ;
_prg_prec_dare = ZERO ;
_prg_prec_avere = ZERO ;
saldo_finale = saldo_iniziale + _mov_periodo_dare - _mov_periodo_avere ;
//if (saldo_finale == ZERO)
// if (_stampav == 2)
// continue;
}
1994-08-23 12:53:59 +00:00
}
1994-10-04 17:25:53 +00:00
if ( movimentato | | _stampav ! = 1 )
if ( ! ( saldo_finale = = ZERO & & _stampav = = 2 ) )
1994-09-20 11:11:53 +00:00
{
1994-10-04 17:25:53 +00:00
esiste_sc = TRUE ;
esiste_conto = TRUE ;
if ( saldo_iniziale < ZERO )
_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 )
1994-09-20 11:11:53 +00:00
{
1994-10-04 17:25:53 +00:00
_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 > ZERO ) //va stampato in Dare
_tmp_saldi_att - > put ( SLD_PDARESCA , saldo_iniziale ) ;
else if ( saldo_iniziale < ZERO )
{
saldo_iniziale = - saldo_iniziale ;
_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 - > put ( SLD_DATAULMOV , _u_max ) ;
_tmp_saldi_att - > write ( ) ;
1994-09-20 11:11:53 +00:00
}
1994-08-23 12:53:59 +00:00
1994-10-04 17:25:53 +00:00
_gp = g ;
_cp = c ;
}
1994-09-20 11:11:53 +00:00
1994-08-23 12:53:59 +00:00
TRecnotype recnum = _pcn - > recno ( ) ;
_pcn - > next ( ) ;
if ( _pcn - > eof ( ) )
{
1994-09-20 11:11:53 +00:00
if ( ( _verifica = = 2 ) & & esiste_conto )
{
real app = _saldo_ini_conto_dare + _saldo_ini_conto_avere ;
if ( app < ZERO )
1994-08-23 12:53:59 +00:00
_saldo_ini_gruppo_avere + = app ;
1994-09-20 11:11:53 +00:00
else
1994-08-23 12:53:59 +00:00
_saldo_ini_gruppo_dare + = app ;
1994-09-20 11:11:53 +00:00
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 ) ) ) ) )
1994-08-23 12:53:59 +00:00
scrivi_record_conto ( prg_conto_dare , prg_conto_avere , mov_conto_dare ,
1994-10-04 17:25:53 +00:00
mov_conto_avere , saldo_conto ) ;
1994-08-23 12:53:59 +00:00
}
_pcn - > readat ( recnum ) ;
}
return TRUE ;
}
1994-09-20 11:11:53 +00:00
bool CG1500_application : : calcola ( int g , int c , long s )
{
1994-10-04 17:25:53 +00:00
char sezione , provvis ;
1994-09-20 11:11:53 +00:00
real importo ;
int annoe ;
long num_reg ;
TDate data_reg , data , datacomp ;
bool conto_mov = FALSE ;
TLocalisamfile rmov ( LF_RMOV ) ;
TLocalisamfile mov ( LF_MOV ) ;
_mov_periodo_dare = ZERO ;
_mov_periodo_avere = ZERO ;
_prg_prec_dare = ZERO ;
_prg_prec_avere = ZERO ;
_saldo_ini_dare = ZERO ;
_saldo_ini_avere = ZERO ;
1994-10-04 17:25:53 +00:00
_u_max = 0l ;
1994-09-20 11:11:53 +00: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 = 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 ( ) ;
1994-10-04 17:25:53 +00:00
provvis = mov . get_char ( MOV_PROVVIS ) ;
1994-09-20 11:11:53 +00:00
datacomp = mov . get_date ( MOV_DATACOMP ) ;
if ( ( ! _stampa_mov_prov ) & & ( provvis = = ' ' ) ) //se non richiesto
continue ; //stampa mov provv.
TString codcaus ( mov . get ( MOV_CODCAUS ) ) ;
1994-10-04 17:25:53 +00:00
if ( codcaus . not_empty ( ) )
if ( codcaus = = causale_chiusura ( ) )
continue ;
1994-09-20 11:11:53 +00:00
//la causale e' uguale a quella di chiusura
// break;
1994-10-04 17:25:53 +00:00
sezione = rmov . get_char ( RMV_SEZIONE ) ;
1994-09-20 11:11:53 +00:00
importo = rmov . get_real ( RMV_IMPORTO ) ;
if ( _annoes = = 0 )
data_reg = data ;
else data_reg = datacomp ;
if ( importo = = 0 )
continue ;
//calcolo i movimenti del periodo
if ( data_reg > = _datada & & data_reg < = _dataa )
if ( ( codcaus = = causale_apertura ( ) & & _dataini ! = _datada ) | |
( codcaus ! = causale_apertura ( ) ) )
{
conto_mov = TRUE ;
1994-10-04 17:25:53 +00:00
if ( sezione = = ' D ' )
1994-09-20 11:11:53 +00:00
_mov_periodo_dare + = importo ;
else _mov_periodo_avere + = importo ;
1994-10-04 17:25:53 +00:00
_u_max = fnc_max ( _u_max , data ) ;
1994-09-20 11:11:53 +00:00
}
//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 ( codcaus = = causale_apertura ( ) )
{
1994-10-04 17:25:53 +00:00
if ( sezione = = ' D ' )
1994-09-20 11:11:53 +00:00
_saldo_ini_dare + = importo ;
else _saldo_ini_avere + = importo ;
1994-10-04 17:25:53 +00:00
_u_max = fnc_max ( _u_max , data ) ;
1994-09-20 11:11:53 +00:00
conto_mov = TRUE ;
}
}
else if ( _datada > _dataini ) //calcolo i progressivi precedenti
1994-10-04 17:25:53 +00:00
if ( ( data_reg > = _dataini ) & & ( data_reg < = _datada ) )
1994-09-20 11:11:53 +00:00
{
1994-10-04 17:25:53 +00:00
if ( sezione = = ' D ' )
1994-09-20 11:11:53 +00:00
_prg_prec_dare + = importo ;
1994-10-04 17:25:53 +00:00
else _prg_prec_avere + = importo ;
_u_max = fnc_max ( _u_max , data ) ;
1994-09-20 11:11:53 +00:00
conto_mov = TRUE ;
}
}
return conto_mov ;
}
1994-08-23 12:53:59 +00:00
bool CG1500_application : : ricerca_cf ( int g , int c , char tipocf , real & saldo_finale , real & saldo_iniziale ,
1994-09-20 11:11:53 +00:00
real & mov_conto_dare , real & mov_conto_avere , real & prg_conto_dare , real & prg_conto_avere , real & saldo_conto )
1994-08-23 12:53:59 +00:00
{
Saldo sld ;
bool esiste_sc = FALSE ;
long s ;
1994-10-04 17:25:53 +00:00
int anno ;
if ( _tipo_stampa1 = = 1 )
anno = _annoapp ;
else anno = _annoes ;
_lista = new TSaldi_list ( g , c , anno ) ;
1994-08-23 12:53:59 +00:00
TRecnotype items = _lista - > items ( ) ;
for ( int i = 0 ; i < items ; i + + )
{
1994-10-17 13:41:53 +00:00
const TRectype * r = _lista - > saldi ( ) ;
if ( r = = NULL ) break ;
s = r - > get_long ( SLD_SOTTOCONTO ) ;
1994-08-23 12:53:59 +00:00
saldo_finale = ZERO ; //saldo finale relativo a ciascun sottoconto
1994-09-20 11:11:53 +00:00
1994-08-23 12:53:59 +00:00
if ( _tipo_stampa1 = = 1 ) //bil. di verifica per data limite
{
1994-09-20 11:11:53 +00:00
if ( ! calcola ( g , c , s ) ) //il conto non e' movimentato
1994-08-23 12:53:59 +00:00
if ( _stampav = = 1 )
1994-09-20 11:11:53 +00:00
continue ;
saldo_iniziale = _saldo_ini_dare - _saldo_ini_avere ;
if ( _datada = = _dataini )
1994-08-23 12:53:59 +00:00
saldo_finale = saldo_iniziale + _mov_periodo_dare - _mov_periodo_avere ;
1994-09-20 11:11:53 +00:00
else if ( _datada > _dataini )
saldo_finale = _prg_prec_dare - _prg_prec_avere + _mov_periodo_dare -
_mov_periodo_avere ;
if ( saldo_finale = = ZERO )
1994-08-23 12:53:59 +00:00
if ( _stampav = = 2 )
1994-09-20 11:11:53 +00:00
continue ;
//se saldo_finale < 0 verra' stampato con una A, se no con una D
1994-08-23 12:53:59 +00:00
}
else
{
1994-10-17 13:41:53 +00:00
if ( ! sld . ultima_immissione_verifica ( _annoes , g , c , s , _indbil ) )
1994-08-23 12:53:59 +00:00
if ( _stampav = = 1 )
1994-09-20 11:11:53 +00:00
continue ;
saldo_iniziale = sld . saldoini ( ) ;
_mov_periodo_dare = sld . prgdare ( ) ;
_mov_periodo_avere = sld . prgavere ( ) ;
_prg_prec_dare = ZERO ;
_prg_prec_avere = ZERO ;
saldo_finale = saldo_iniziale + _mov_periodo_dare - _mov_periodo_avere ;
if ( saldo_finale = = ZERO )
1994-08-23 12:53:59 +00:00
if ( _stampav = = 2 )
1994-09-20 11:11:53 +00:00
continue ;
1994-08-23 12:53:59 +00:00
}
esiste_sc = TRUE ;
if ( saldo_iniziale < ZERO )
1994-09-20 11:11:53 +00:00
_saldo_ini_conto_avere + = saldo_iniziale ;
1994-08-23 12:53:59 +00:00
else
1994-09-20 11:11:53 +00:00
_saldo_ini_conto_dare + = saldo_iniziale ;
1994-08-23 12:53:59 +00:00
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 > ZERO ) //va stampato in Dare
1994-09-20 11:11:53 +00:00
_tmp_saldi_att - > put ( SLD_PDARESCA , saldo_iniziale ) ;
1994-08-23 12:53:59 +00:00
else if ( saldo_iniziale < ZERO )
{
1994-09-20 11:11:53 +00:00
saldo_iniziale = - saldo_iniziale ;
_tmp_saldi_att - > put ( SLD_PAVERESCA , saldo_iniziale ) ;
1994-08-23 12:53:59 +00:00
}
}
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 ) ;
1994-10-04 17:25:53 +00:00
_tmp_saldi_att - > put ( SLD_SALDO , saldo_finale ) ;
_tmp_saldi_att - > put ( SLD_DATAULMOV , _u_max ) ;
1994-08-23 12:53:59 +00:00
_tmp_saldi_att - > write ( ) ;
}
}
delete _lista ;
return esiste_sc ;
}
void CG1500_application : : scrivi_record_gruppo ( const real & prg_da ,
1994-09-20 11:11:53 +00:00
const real & prg_a , const real & mov_da , const real & mov_a , const real & s )
1994-08-23 12:53:59 +00:00
{
_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 > ZERO ) //va stampato in Dare
1994-09-20 11:11:53 +00:00
_tmp_saldi_att - > put ( SLD_PDARESCA , app ) ;
1994-08-23 12:53:59 +00:00
else if ( app < ZERO )
1994-09-20 11:11:53 +00:00
{
app = - app ;
_tmp_saldi_att - > put ( SLD_PAVERESCA , app ) ;
}
1994-08-23 12:53:59 +00:00
}
else if ( _datada > _dataini )
1994-09-20 11:11:53 +00:00
{
_tmp_saldi_att - > put ( SLD_PDARESCA , prg_da ) ;
_tmp_saldi_att - > put ( SLD_PAVERESCA , prg_a ) ;
}
1994-08-23 12:53:59 +00:00
_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 ,
1994-09-20 11:11:53 +00:00
const real & prg_a , const real & mov_da , const real & mov_a , const real & s )
1994-08-23 12:53:59 +00:00
{
_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 > ZERO ) //va stampato in Dare
1994-09-20 11:11:53 +00:00
_tmp_saldi_att - > put ( SLD_PDARESCA , app ) ;
1994-08-23 12:53:59 +00:00
else if ( app < ZERO )
1994-09-20 11:11:53 +00:00
{
app = - app ;
_tmp_saldi_att - > put ( SLD_PAVERESCA , app ) ;
}
1994-08-23 12:53:59 +00:00
}
else if ( _datada > _dataini )
1994-09-20 11:11:53 +00:00
{
_tmp_saldi_att - > put ( SLD_PDARESCA , prg_da ) ;
_tmp_saldi_att - > put ( SLD_PAVERESCA , prg_a ) ;
}
1994-08-23 12:53:59 +00:00
_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 ) ) ;
1994-10-04 17:25:53 +00:00
if ( _ordinamento = = 1 )
{
_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 - > codcf ) - ( char * ) & ( _cf - > tipocf ) , 6 ) ;
}
else if ( _ordinamento = = 2 )
{
_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 ) ;
}
1994-08-23 12:53:59 +00:00
_sort - > init ( ) ;
}
1994-10-04 17:25:53 +00:00
void CG1500_application : : riempi_record ( char t , int g , int c , long s ,
1994-09-20 11:11:53 +00:00
const char * rs , const real & sd , const real & sa ,
const real & md , const real & ma , const real & sf )
1994-08-23 12:53:59 +00:00
{
1994-10-04 17:25:53 +00:00
_cf - > tipocf = t ;
1994-08-23 12:53:59 +00:00
sprintf ( _cf - > gruppo , " %03d " , g ) ;
sprintf ( _cf - > conto , " %03d " , c ) ;
sprintf ( _cf - > codcf , " %06ld " , s ) ;
1994-10-04 17:25:53 +00:00
sprintf ( _cf - > ragsoc , " %s " , rs ) ;
if ( s = = 999999L )
1994-08-23 12:53:59 +00:00
{
if ( ( _datada = = _dataini ) | | ( _tipo_stampa1 ! = 1 ) )
{
real app = _saldo_ini_conto_dare + _saldo_ini_conto_avere ;
1994-10-04 17:25:53 +00:00
if ( app > ZERO ) //va stampato in Dare
{
_cf - > saldoavere = ZERO ;
1994-09-20 11:11:53 +00:00
_cf - > saldodare = app ;
1994-10-04 17:25:53 +00:00
}
1994-08-23 12:53:59 +00:00
else if ( app < ZERO )
1994-10-04 17:25:53 +00:00
{
app = - app ;
_cf - > saldodare = ZERO ;
_cf - > saldoavere = app ;
1994-08-23 12:53:59 +00:00
}
}
else if ( _datada > _dataini )
{
1994-10-04 17:25:53 +00:00
_cf - > saldodare = sd ;
_cf - > saldoavere = sa ;
1994-08-23 12:53:59 +00:00
}
}
1994-10-04 17:25:53 +00:00
else
{
_cf - > saldodare = sd ;
_cf - > saldoavere = sa ;
}
_cf - > movdare = md ;
_cf - > movavere = ma ;
_cf - > saldofinale = sf ;
_cf - > udata = _u_max ;
_sort - > sort ( ( const char * ) _cf ) ;
}
1994-08-23 12:53:59 +00:00
1994-10-04 17:25:53 +00:00
void CG1500_application : : crea_sort_clifo ( )
1994-08-23 12:53:59 +00:00
{
Saldo sld ;
1994-10-04 17:25:53 +00:00
TLocalisamfile saldi ( LF_SALDI , FALSE ) ;
1994-08-23 12:53:59 +00:00
int g = 0 , c = 0 ;
long codcf = 0l ;
1994-10-04 17:25:53 +00:00
TString80 ragsoc ;
char tipocf , tipocfp ;
real saldo_finale , saldo_conto , saldo_iniziale , saldodare , saldoavere ,
movdare , movavere ;
1994-08-23 12:53:59 +00:00
real mov_conto_dare , mov_conto_avere , prg_conto_dare , prg_conto_avere ;
1994-10-04 17:25:53 +00:00
bool esiste_sc = FALSE , movimentato = FALSE ;
TArray gccf ;
1994-08-23 12:53:59 +00:00
TRecnotype items = _cur - > items ( ) ;
1994-09-20 11:11:53 +00:00
1994-08-23 12:53:59 +00:00
_gp = - 1 ;
_cp = - 1 ;
1994-10-04 17:25:53 +00:00
tipocfp = ' ' ;
1994-08-23 12:53:59 +00:00
_saldo_ini_conto_dare = ZERO ;
_saldo_ini_conto_avere = ZERO ;
saldo_conto = ZERO ;
mov_conto_dare = ZERO ;
mov_conto_avere = ZERO ;
prg_conto_dare = ZERO ;
prg_conto_avere = ZERO ;
1994-10-04 17:25:53 +00:00
_u_max = 0l ;
1994-08-23 12:53:59 +00:00
1994-10-04 17:25:53 +00:00
init_sort ( ) ;
1994-09-20 11:11:53 +00:00
1994-08-23 12:53:59 +00:00
* _cur = 0l ;
for ( int i = 0 ; i < items ; i + + , + + ( * _cur ) )
{
1994-10-04 17:25:53 +00:00
_prog - > addstatus ( 1 ) ;
1994-08-23 12:53:59 +00:00
codcf = _cur - > curr ( ) . get_long ( CLI_CODCF ) ;
1994-10-04 17:25:53 +00:00
tipocf = _cur - > curr ( ) . get ( CLI_TIPOCF ) [ 0 ] ;
ragsoc = _cur - > curr ( ) . get ( CLI_RAGSOC ) ;
1994-09-20 11:11:53 +00:00
1994-10-04 17:25:53 +00:00
if ( tipocf = = ' C ' )
gccf = _clienti ;
1994-08-23 12:53:59 +00:00
else
1994-10-04 17:25:53 +00:00
if ( tipocf = = ' F ' )
gccf = _fornitori ;
for ( int i = 0 ; i < gccf . items ( ) ; i + + )
1994-08-23 12:53:59 +00:00
{
1994-10-04 17:25:53 +00:00
int g = ( ( TToken_string & ) gccf [ i ] ) . get_int ( 0 ) ;
int c = ( ( TToken_string & ) gccf [ i ] ) . get_int ( 1 ) ;
1994-09-20 11:11:53 +00:00
1994-10-04 17:25:53 +00:00
saldi . zero ( ) ;
saldi . put ( SLD_ANNOES , _annoes ) ;
saldi . put ( SLD_GRUPPO , g ) ;
saldi . put ( SLD_CONTO , c ) ;
saldi . put ( SLD_SOTTOCONTO , codcf ) ;
1994-08-23 12:53:59 +00:00
1994-10-04 17:25:53 +00:00
if ( saldi . read ( ) ! = NOERR ) continue ;
1994-09-20 11:11:53 +00:00
1994-10-04 17:25:53 +00:00
if ( ( ( ( _cp ! = - 1 ) & & ( c ! = _cp ) ) | | ( ( _gp ! = - 1 ) & & ( g ! = _gp ) ) ) & &
esiste_sc )
{
//scrivo il record del conto;
riempi_record ( tipocfp , _gp , _cp , 999999L , " 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 = ZERO ;
_saldo_ini_conto_avere = ZERO ;
saldo_conto = ZERO ;
mov_conto_dare = ZERO ;
mov_conto_avere = ZERO ;
prg_conto_dare = ZERO ;
prg_conto_avere = ZERO ;
}
1994-08-23 12:53:59 +00:00
1994-10-04 17:25:53 +00:00
saldo_finale = ZERO ;
saldodare = ZERO ;
saldoavere = ZERO ;
movdare = ZERO ;
movavere = ZERO ;
if ( _tipo_stampa1 = = 1 ) //bilancio per data limite
{
//if ( !calcola(g,c,codcf) )//il conto non e' mov.
// if (_stampac == 1)
// continue;
movimentato = calcola ( g , c , codcf ) ;
if ( movimentato | | _stampac ! = 1 )
{
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 == ZERO)
// if (_stampac == 2)
// continue;
//se saldo_finale < 0 verra' stampato con una A, se no con una D
}
else //bilancio di verifica
1994-08-23 12:53:59 +00:00
{
1994-10-04 17:25:53 +00:00
_indbil = cerca_indbil ( g , c ) ;
//if (!sld.ultima_immissione_bilancio(_annoes,g,c,codcf,_indbil))
// if (_stampac == 1)
// continue;
1994-10-17 13:41:53 +00:00
movimentato = sld . ultima_immissione_verifica ( _annoes , g , c , codcf , _indbil ) ;
1994-10-04 17:25:53 +00:00
if ( movimentato | | _stampac ! = 1 )
{
saldo_iniziale = sld . saldoini ( ) ;
_mov_periodo_dare = sld . prgdare ( ) ;
_mov_periodo_avere = sld . prgavere ( ) ;
_prg_prec_dare = ZERO ;
_prg_prec_avere = ZERO ;
saldo_finale = saldo_iniziale + _mov_periodo_dare - _mov_periodo_avere ;
}
//if (saldo_finale == ZERO)
// if (_stampac == 2)
// continue;
1994-08-23 12:53:59 +00:00
}
1994-10-04 17:25:53 +00:00
if ( movimentato | | _stampac ! = 1 )
if ( ! ( saldo_finale = = ZERO & & _stampac = = 2 ) )
{
esiste_sc = TRUE ;
1994-08-23 12:53:59 +00:00
1994-10-04 17:25:53 +00:00
if ( saldo_iniziale < ZERO )
_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 > ZERO ) //va stampato in Dare
saldodare = saldo_iniziale ;
else if ( saldo_iniziale < ZERO )
{
saldo_iniziale = - saldo_iniziale ;
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 ;
}
}
}
if ( esiste_sc )
riempi_record ( tipocfp , _gp , _cp , 999999L , " zzzz " , prg_conto_dare , prg_conto_avere ,
mov_conto_dare , mov_conto_avere , saldo_conto ) ;
1994-08-23 12:53:59 +00:00
}
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 ) ;
1994-09-20 11:11:53 +00:00
1994-08-23 12:53:59 +00:00
pconti . read ( ) ;
1994-09-20 11:11:53 +00:00
1994-08-23 12:53:59 +00:00
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 ) ;
1994-10-04 17:25:53 +00:00
_descr_dare = DescrizioneConto ( _gruppo_dare , _conto_dare , _sottoconto_dare , ' ' ) ;
1994-08-23 12:53:59 +00:00
_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 )
1994-09-20 11:11:53 +00:00
_cambiato_conto_1 = FALSE ;
1994-08-23 12:53:59 +00:00
}
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 ,
1994-10-04 17:25:53 +00:00
' ' ) ;
1994-08-23 12:53:59 +00:00
_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 )
1994-09-20 11:11:53 +00:00
_cambiato_conto_2 = FALSE ;
1994-08-23 12:53:59 +00:00
}
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 ) ;
1994-09-20 11:11:53 +00:00
_gc_prec_avere = " " ;
1994-08-23 12:53:59 +00:00
_prima_volta = _seconda_volta = TRUE ;
_flag = _controlla = FALSE ;
_salto_pagina = _salto_pagina1 = _stampato = FALSE ;
_cambiato_conto_1 = TRUE ;
_cambiato_conto_2 = TRUE ;
_tot_dare = ZERO ;
_tot_avere = ZERO ;
}
else
{
1994-10-04 17:25:53 +00:00
//if ( (_verifica == 3) && (_ordinamento == 1) )
// _tmp_saldi_att->setkey(2);
1994-08-23 12:53:59 +00:00
set_print_zero ( FALSE ) ;
_cambiato_conto_1 = FALSE ;
_livello_conto = TRUE ;
_saldo_dare_tot = ZERO ;
_saldo_avere_tot = ZERO ;
_mov_dare_tot = ZERO ;
_mov_avere_tot = ZERO ;
_saldo_finale_tot = ZERO ;
}
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 ) ;
1994-10-04 17:25:53 +00:00
_tipo_conto = _tmp_saldi_att - > get_char ( SLD_FLAGSALINI ) ;
1994-08-23 12:53:59 +00:00
_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 ) ;
1994-10-04 17:25:53 +00:00
_tipoc_succ = _tmp_saldi_att - > get_char ( SLD_FLAGSALINI ) ;
if ( ( _verifica ! = 2 ) & & ( _sottoconto_succ ! = 0 ) )
if ( _tipo_stampa1 = = 2 )
_ultima_data = UltimaData ( _gruppo_succ , _conto_succ ,
_sottoconto_succ , _annoes ) ;
else _ultima_data = _tmp_saldi_att - > get_date ( SLD_DATAULMOV ) ;
1994-08-23 12:53:59 +00:00
_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 ) ) | |
1994-09-20 11:11:53 +00:00
( ( _verifica = = 2 ) & & ( _conto_succ = = 0 ) ) )
1994-08-23 12:53:59 +00:00
{
_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 )
{
1994-09-20 11:11:53 +00:00
if ( ( ! _eof1 ) & & ( _cambiato_conto_1 ) )
_eof1 = _tmp_saldi_att - > next ( ) ;
if ( ( ! _eof2 ) & & ( _cambiato_conto_2 ) )
_eof2 = _tmp_saldi_pass - > next ( ) ;
1994-08-23 12:53:59 +00:00
1994-09-20 11:11:53 +00:00
if ( _eof1 & & _eof2 )
{
if ( _prima_volta )
{
1994-10-17 13:41:53 +00:00
stampa_totali_uno ( _prg_saldoini_dare , _prg_saldoini_avere ) ;
1994-09-20 11:11:53 +00:00
_eof3 = _tmp_saldi_costi - > first ( ) ;
_eof4 = _tmp_saldi_ricavi - > first ( ) ;
}
else
{
_controlla = TRUE ;
if ( _salto_pagina )
1994-10-04 17:25:53 +00:00
{
1994-09-20 11:11:53 +00:00
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 )
{
1994-10-04 17:25:53 +00:00
stampa_totali ( ) ;
_eof5 = _tmp_saldi_conti_uno - > first ( ) ;
_eof6 = _tmp_saldi_conti_due - > first ( ) ;
1994-09-20 11:11:53 +00:00
}
else
{
_flag = TRUE ;
if ( _salto_pagina1 )
{
if ( ( ! _eof5 ) & & ( _cambiato_conto_1 ) )
_eof5 = _tmp_saldi_conti_uno - > next ( ) ;
if ( ( ! _eof6 ) & & ( _cambiato_conto_2 ) )
1994-10-04 17:25:53 +00:00
_eof6 = _tmp_saldi_conti_due - > next ( ) ;
1994-09-20 11:11:53 +00:00
}
}
1994-10-04 17:25:53 +00:00
1994-09-20 11:11:53 +00:00
if ( ( ! _eof5 ) & & ( _cambiato_conto_1 ) )
leggi_files_dare ( _tmp_saldi_conti_uno ) ;
1994-08-23 12:53:59 +00:00
1994-09-20 11:11:53 +00:00
if ( ( ! _eof6 ) & & ( _cambiato_conto_2 ) )
1994-10-04 17:25:53 +00:00
leggi_files_avere ( _tmp_saldi_conti_due ) ;
1994-09-20 11:11:53 +00:00
}
}
1994-08-23 12:53:59 +00:00
}
else //counter = 0
{
_gc_prec_dare = _gc_corr_avere = " " ;
_eof1 = _tmp_saldi_att - > first ( ) ;
_eof2 = _tmp_saldi_pass - > first ( ) ;
}
1994-09-20 11:11:53 +00:00
1994-08-23 12:53:59 +00:00
if ( ( ! _eof1 ) & & ( _cambiato_conto_1 ) )
1994-09-20 11:11:53 +00:00
leggi_files_dare ( _tmp_saldi_att ) ;
1994-08-23 12:53:59 +00:00
if ( ( ! _eof2 ) & & ( _cambiato_conto_2 ) )
1994-09-20 11:11:53 +00:00
leggi_files_avere ( _tmp_saldi_pass ) ;
1994-08-23 12:53:59 +00:00
}
else //stampa bilancio di verifica
{
1994-10-04 17:25:53 +00:00
if ( _verifica = = 3 )
1994-09-20 11:11:53 +00:00
leggi_sort ( ) ;
1994-08-23 12:53:59 +00:00
else
{
if ( counter )
{
1994-09-20 11:11:53 +00:00
if ( ! _eof1 )
leggi_file_tmp ( ) ;
1994-08-23 12:53:59 +00:00
}
else
{
1994-09-20 11:11:53 +00:00
_eof1 = _tmp_saldi_att - > first ( ) ;
if ( _eof1 )
return FALSE ;
else leggi_file_tmp ( ) ;
1994-08-23 12:53:59 +00:00
}
1994-10-04 17:25:53 +00:00
}
1994-08-23 12:53:59 +00:00
}
return TRUE ;
}
void CG1500_application : : leggi_sort ( )
{
struct cli_for * cf ;
1994-09-20 11:11:53 +00:00
1994-08-23 12:53:59 +00:00
if ( ( _buff = _sort - > retrieve ( ) ) ! = NULL )
{
cf = ( struct cli_for * ) _buff ;
1994-10-04 17:25:53 +00:00
_tipo_conto = cf - > tipocf ;
1994-08-23 12:53:59 +00:00
_gruppo = atoi ( cf - > gruppo ) ;
_conto = atoi ( cf - > conto ) ;
_sottoconto = atol ( cf - > codcf ) ;
_descr = cf - > ragsoc ;
1994-10-04 17:25:53 +00:00
if ( ( _ordinamento = = 2 & & _descr ! = " zzzz " ) | |
( _ordinamento = = 1 & & _sottoconto ! = 999999L ) )
if ( _tipo_stampa1 = = 2 )
_ultima_data = UltimaData ( _gruppo , _conto , _sottoconto , _annoes ) ;
else _ultima_data = cf - > udata ;
1994-08-23 12:53:59 +00:00
_saldo_dare = cf - > saldodare ;
_saldo_avere = cf - > saldoavere ;
_mov_dare = cf - > movdare ;
_mov_avere = cf - > movavere ;
_saldofinale = cf - > saldofinale ;
}
}
1994-10-04 17:25:53 +00:00
void CG1500_application : : controlla_conto ( int file1 , int file2 )
1994-08-23 12:53:59 +00:00
{
1994-09-20 11:11:53 +00:00
char dep = ' * ' ;
1994-08-23 12:53:59 +00:00
if ( ! file1 )
1994-09-20 11:11:53 +00:00
if ( _cambiato_conto_1 )
{
1994-10-17 13:41:53 +00:00
set_row ( _i , " @66g%c " , dep ) ;
1994-09-20 11:11:53 +00:00
_cambiato_conto_1 = FALSE ;
}
else
{
stampa_prima_colonna ( _gruppo_dare , _conto_dare , _sottoconto_dare ,
_descr_dare , _saldo_dare ) ;
_cambiato_conto_1 = TRUE ;
1994-10-17 13:41:53 +00:00
if ( ! _totali )
if ( ( _conto_dare = = 0 ) & & ( _sottoconto_dare = = 0 ) )
_tot_dare + = _saldo_dare ;
if ( _totali )
if ( _sottoconto_dare = = 0 )
_tot_dare + = _saldo_dare ;
1994-09-20 11:11:53 +00:00
}
1994-08-23 12:53:59 +00:00
if ( ! file2 )
1994-09-20 11:11:53 +00:00
if ( _cambiato_conto_2 )
{
1994-10-17 13:41:53 +00:00
set_row ( _i , " @66g%c " , dep ) ;
_cambiato_conto_2 = FALSE ;
1994-09-20 11:11:53 +00:00
}
else
{
stampa_seconda_colonna ( _gruppo_avere , _conto_avere , _sottoconto_avere ,
_descr_avere , _saldo_avere ) ;
1994-10-17 13:41:53 +00:00
_cambiato_conto_2 = TRUE ;
if ( ! _totali )
if ( ( _conto_avere = = 0 ) & & ( _sottoconto_avere = = 0 ) )
_tot_avere + = _saldo_avere ;
if ( _totali )
if ( _sottoconto_avere = = 0 )
_tot_avere + = _saldo_avere ;
1994-09-20 11:11:53 +00:00
}
1994-08-23 12:53:59 +00:00
}
1994-10-04 17:25:53 +00:00
void CG1500_application : : postclose_print ( )
1994-08-23 12:53:59 +00:00
{
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
{
1994-10-04 17:25:53 +00:00
if ( _verifica = = 3 )
1994-09-20 11:11:53 +00:00
delete _sort ;
1994-10-04 17:25:53 +00:00
else
_tmp_saldi_att - > close ( ) ;
1994-08-23 12:53:59 +00:00
}
1994-10-04 17:25:53 +00:00
//return NEXT_PAGE;
1994-08-23 12:53:59 +00:00
}
void CG1500_application : : set_page ( int file , int counter )
{
TString dep = " " ;
1994-09-20 11:11:53 +00:00
1994-08-23 12:53:59 +00:00
if ( _bilancio = = 1 ) //stampa bilancio a sezioni contrapposte
{
_i = 1 ;
1994-09-20 11:11:53 +00:00
1994-08-23 12:53:59 +00:00
if ( ! counter )
{
set_row ( _i + + , " @29gATTIVITA'@94gPASSIVITA' " ) ;
set_row ( _i + + , " @29g---------@94g---------- " ) ;
set_row ( _i + + , ( const char * ) dep ) ;
}
1994-09-20 11:11:53 +00:00
1994-10-04 17:25:53 +00:00
controlla_conto ( _eof1 , _eof2 ) ; //stampo una riga vuota tra un gruppo e un conto altrimenti no
1994-08-23 12:53:59 +00:00
if ( _eof1 & & _eof2 & & ( ! _prima_volta ) & & _controlla )
1994-09-20 11:11:53 +00:00
if ( ! _salto_pagina )
{
printer ( ) . formfeed ( ) ;
set_row ( _i + + , " @29gCOSTI@94gRICAVI " ) ;
set_row ( _i + + , " @29g-----@94g------ " ) ;
set_row ( _i + + , ( const char * ) dep ) ;
_salto_pagina = TRUE ;
}
1994-08-23 12:53:59 +00:00
if ( _eof1 & & _eof2 & & _controlla )
{
1994-10-04 17:25:53 +00:00
controlla_conto ( _eof3 , _eof4 ) ;
1994-08-23 12:53:59 +00:00
if ( _eof3 & & _eof4 & & ( ! _seconda_volta ) & & _flag )
1994-09-20 11:11:53 +00:00
if ( ! _salto_pagina1 )
1994-10-04 17:25:53 +00:00
{
if ( ! _tmp_saldi_conti_uno - > empty ( ) | | ! _tmp_saldi_conti_due - > empty ( ) )
1994-09-20 11:11:53 +00:00
{
1994-10-04 17:25:53 +00:00
printer ( ) . formfeed ( ) ;
set_row ( _i + + , " @59gCONTI D'ORDINE " ) ;
set_row ( _i + + , " @59g-------------- " ) ;
set_row ( _i + + , ( const char * ) dep ) ;
if ( _eof5 & & _eof6 )
{
_stampato = TRUE ;
1994-10-17 13:41:53 +00:00
//stampa_totali();
stampa_totali_uno ( _prg_inidare_ord , _prg_iniavere_ord ) ;
1994-10-04 17:25:53 +00:00
}
1994-09-20 11:11:53 +00:00
}
1994-10-04 17:25:53 +00:00
_salto_pagina1 = TRUE ;
1994-09-20 11:11:53 +00:00
}
1994-08-23 12:53:59 +00:00
if ( _eof3 & & _eof4 & & _flag )
{
1994-10-04 17:25:53 +00:00
if ( ! _tmp_saldi_conti_uno - > empty ( ) | | ! _tmp_saldi_conti_due - > empty ( ) )
{
controlla_conto ( _eof5 , _eof6 ) ;
if ( _eof5 & & _eof6 )
1994-10-17 13:41:53 +00:00
if ( ! _stampato )
//stampa_totali();
stampa_totali_uno ( _prg_inidare_ord , _prg_iniavere_ord ) ;
1994-10-04 17:25:53 +00:00
}
1994-08-23 12:53:59 +00:00
}
}
}
else //stampa bilancio di verifica
{
TString udata = _ultima_data . string ( 2 , ' / ' ) ;
1994-10-04 17:25:53 +00:00
char app ;
1994-08-23 12:53:59 +00:00
int r = 1 ;
1994-10-04 17:25:53 +00:00
if ( _verifica = = 3 )
1994-08-23 12:53:59 +00:00
{
if ( _buff ! = NULL )
{
1994-09-20 11:11:53 +00:00
if ( _saldofinale > 0 )
1994-10-04 17:25:53 +00:00
app = ' D ' ;
1994-09-20 11:11:53 +00:00
else if ( _saldofinale < 0 )
1994-08-23 12:53:59 +00:00
{
1994-09-20 11:11:53 +00:00
_saldofinale = - _saldofinale ;
1994-10-04 17:25:53 +00:00
app = ' A ' ;
1994-09-20 11:11:53 +00:00
}
1994-10-04 17:25:53 +00:00
if ( ( _ordinamento = = 2 & & _descr = = " zzzz " ) | |
( _ordinamento = = 1 & & _sottoconto = = 999999L ) ) //devo stampare il conto
1994-09-20 11:11:53 +00:00
{
1994-10-04 17:25:53 +00:00
_descr = DescrizioneConto ( _gruppo , _conto , 0L , ' ' ) ;
1994-08-23 12:53:59 +00:00
stampa_record_conto ( _gruppo , _conto , _descr , _saldo_dare , _saldo_avere ,
_mov_dare , _mov_avere , _saldofinale , app ) ;
}
else
1994-09-20 11:11:53 +00:00
if ( _stampa_width = = 132 )
{
set_row ( r , " @1g%6ld " , ( const char * ) _sottoconto ) ;
set_row ( r , " %s " , ( const char * ) udata ) ;
1994-10-04 17:25:53 +00:00
set_row ( r , " @18g%s@49g!@50g%r@67g%r@82g!@83g%r@99g%r@114g!@115g%r %c " , ( const char * ) _descr , & _saldo_dare ,
& _saldo_avere , & _mov_dare , & _mov_avere , & _saldofinale , app ) ;
1994-08-23 12:53:59 +00:00
}
1994-10-04 17:25:53 +00:00
else if ( app = = ' D ' )
1994-09-20 11:11:53 +00:00
{
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 " , ( 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 ) ;
1994-10-04 17:25:53 +00:00
}
1994-08-23 12:53:59 +00:00
}
1994-10-04 17:25:53 +00:00
}
else //_verifica != 3
1994-08-23 12:53:59 +00:00
{
if ( ! _eof1 )
{
1994-09-20 11:11:53 +00:00
if ( _saldofinale_succ > 0 )
1994-10-04 17:25:53 +00:00
app = ' D ' ;
1994-09-20 11:11:53 +00:00
else if ( _saldofinale_succ < 0 )
1994-08-23 12:53:59 +00:00
{
1994-09-20 11:11:53 +00:00
_saldofinale_succ = - _saldofinale_succ ;
1994-10-04 17:25:53 +00:00
app = ' A ' ;
1994-08-23 12:53:59 +00:00
}
1994-09-20 11:11:53 +00:00
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
1994-08-23 12:53:59 +00:00
{
1994-09-20 11:11:53 +00:00
if ( _verifica = = 2 )
{
if ( _stampa_width = = 132 )
{
set_row ( r , " %3d " , _conto_succ ) ;
1994-10-04 17:25:53 +00:00
set_row ( r , " @8g%s@49g!@50g%r@67g%r@82g!@83g%r@99g%r@114g!@115g%r %c " ,
1994-09-20 11:11:53 +00:00
( const char * ) _descr_succ , & _saldoini_dare_succ , & _saldoini_avere_succ ,
1994-10-04 17:25:53 +00:00
& _mov_dare_succ , & _mov_avere_succ , & _saldofinale_succ , app ) ;
1994-09-20 11:11:53 +00:00
}
1994-10-04 17:25:53 +00:00
else if ( app = = ' D ' )
1994-09-20 11:11:53 +00:00
{
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 ) ;
1994-08-23 12:53:59 +00:00
}
1994-09-20 11:11:53 +00:00
else
{
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
1994-08-23 12:53:59 +00:00
{
1994-09-20 11:11:53 +00:00
if ( _stampa_width = = 132 )
{
set_row ( r , " @1g%6ld " , ( const char * ) _sottoconto_succ ) ;
set_row ( r , " %s " , ( const char * ) udata ) ;
1994-10-04 17:25:53 +00:00
set_row ( r , " @18g%s@49g!@50g%r@67g%r@82g!@83g%r@99g%r@114g!@115g%r %c " ,
1994-09-20 11:11:53 +00:00
( const char * ) _descr_succ , & _saldoini_dare_succ , & _saldoini_avere_succ ,
1994-10-04 17:25:53 +00:00
& _mov_dare_succ , & _mov_avere_succ , & _saldofinale_succ , app ) ;
1994-08-23 12:53:59 +00:00
}
1994-10-04 17:25:53 +00:00
else if ( app = = ' D ' )
1994-09-20 11:11:53 +00:00
{
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 " , ( 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 ) ;
}
1994-08-23 12:53:59 +00:00
}
1994-09-20 11:11:53 +00:00
}
1994-08-23 12:53:59 +00:00
}
else
{
1994-09-20 11:11:53 +00:00
if ( _saldofinale > 0 )
1994-10-04 17:25:53 +00:00
app = ' D ' ;
1994-09-20 11:11:53 +00:00
else if ( _saldofinale < 0 )
1994-08-23 12:53:59 +00:00
{
1994-10-04 17:25:53 +00:00
app = ' A ' ;
1994-09-20 11:11:53 +00:00
_saldofinale = - _saldofinale ;
1994-08-23 12:53:59 +00:00
}
1994-09-20 11:11:53 +00:00
r = stampa_record_conto ( _gruppo , _conto , _descr , _saldoini_dare ,
_saldoini_avere , _mov_dare , _mov_avere , _saldofinale , app ) ; //per stampare l'ultimo conto
1994-08-23 12:53:59 +00:00
stampa_riga_totali ( r ) ;
}
}
}
}
1994-09-20 11:11:53 +00:00
1994-08-23 12:53:59 +00:00
int CG1500_application : : stampa_record_conto ( int g , int c , const char * d ,
1994-09-20 11:11:53 +00:00
const real & r1 , const real & r2 , const real & r3 , const real & r4 , const real & r5 ,
1994-10-04 17:25:53 +00:00
const char app )
1994-08-23 12:53:59 +00:00
{
TString dep = " " ;
int r = 1 ;
if ( _stampa_width = = 148 )
1994-10-04 17:25:53 +00:00
{
set_row ( r , " @49g!@82g!@115g! " , ( const char * ) dep ) ; //stampo una riga vuota
1994-09-20 11:11:53 +00:00
set_row ( r , " @148g! " , ( const char * ) dep ) ;
1994-10-04 17:25:53 +00:00
}
else
set_row ( r , " @49g!@82g!@114g! " , ( const char * ) dep ) ; //stampo una riga vuota
1994-08-23 12:53:59 +00:00
r + + ;
if ( _verifica = = 2 )
{
if ( _stampa_width = = 132 )
{
1994-09-20 11:11:53 +00:00
// 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 ) ;
1994-10-04 17:25:53 +00:00
set_row ( r + + , " @49g!@50g%r@67g%r@82g!@83g%r@99g%r@114g!@115g%r %c " , & r1 , & r2 , & r3 , & r4 , & r5 , app ) ;
1994-08-23 12:53:59 +00:00
}
else
1994-10-04 17:25:53 +00:00
if ( app = = ' D ' )
1994-09-20 11:11:53 +00:00
{
// 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 ) ;
}
1994-08-23 12:53:59 +00:00
}
else
{
if ( _stampa_width = = 132 )
{
1994-09-20 11:11:53 +00:00
// 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 ) ;
1994-10-04 17:25:53 +00:00
set_row ( r + + , " @49g!@50g%r@67g%r@82g!@83g%r@99g%r@114g!@115g%r %c " , & r1 , & r2 , & r3 , & r4 , & r5 , app ) ;
1994-08-23 12:53:59 +00:00
}
1994-10-04 17:25:53 +00:00
else if ( app = = ' D ' )
1994-09-20 11:11:53 +00:00
{
// 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 ) ;
}
1994-08-23 12:53:59 +00:00
}
if ( _stampa_width = = 148 )
1994-10-04 17:25:53 +00:00
{
set_row ( r , " @49g!@82g!@115g! " , ( const char * ) dep ) ;
1994-09-20 11:11:53 +00:00
set_row ( r , " @148g! " , ( const char * ) dep ) ;
1994-10-04 17:25:53 +00:00
}
else
set_row ( r , " @49g!@82g!@114g! " , ( const char * ) dep ) ;
1994-08-23 12:53:59 +00:00
r + + ;
1994-10-04 17:25:53 +00:00
if ( _stampa_width = = 148 )
{
set_row ( r , " @49g!@82g!@115g! " , ( const char * ) dep ) ;
set_row ( r , " @148g! " , ( const char * ) dep ) ;
}
else
set_row ( r , " @49g!@82g!@114g! " , ( const char * ) dep ) ;
1994-08-23 12:53:59 +00:00
r + + ;
1994-10-04 17:25:53 +00:00
if ( app = = ' D ' )
1994-09-20 11:11:53 +00:00
_saldo_finale_tot + = r5 ;
1994-08-23 12:53:59 +00:00
else _saldo_finale_tot - = r5 ;
1994-09-20 11:11:53 +00:00
1994-08-23 12:53:59 +00:00
_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 )
{
1994-10-04 17:25:53 +00:00
TString dep = " " ;
char app = ' ' ;
1994-08-23 12:53:59 +00:00
if ( _saldo_finale_tot > 0 )
1994-10-04 17:25:53 +00:00
app = ' D ' ;
1994-08-23 12:53:59 +00:00
else if ( _saldo_finale_tot < 0 )
{
_saldo_finale_tot = - _saldo_finale_tot ;
1994-10-04 17:25:53 +00:00
app = ' A ' ;
1994-08-23 12:53:59 +00:00
}
if ( _datada = = _dataini ) //colonna saldo iniziale
{
real r = _saldo_dare_tot - _saldo_avere_tot ;
if ( r > ZERO )
{
_saldo_dare_tot = r ;
_saldo_avere_tot = ZERO ;
}
else
{
_saldo_avere_tot = - r ;
_saldo_dare_tot = ZERO ;
}
}
if ( _stampa_width = = 148 )
1994-10-04 17:25:53 +00:00
{
set_row ( r , " @49g!@82g!@115g! " , ( const char * ) dep ) ;
1994-09-20 11:11:53 +00:00
set_row ( r , " @148g! " , ( const char * ) dep ) ;
1994-10-04 17:25:53 +00:00
}
else
set_row ( r , " @49g!@82g!@114g! " , ( const char * ) dep ) ;
1994-08-23 12:53:59 +00:00
r + + ;
if ( _verifica = = 2 )
{
if ( _stampa_width = = 132 )
1994-10-04 17:25:53 +00:00
set_row ( r , " ***@8gTOTALE GENERALE@49g!@50g%r@67g%r@82g!@83g%r@99g%r@114g!@115g%r %c " , & _saldo_dare_tot , & _saldo_avere_tot , & _mov_dare_tot ,
& _mov_avere_tot , & _saldo_finale_tot , app ) ;
else if ( app = = ' D ' )
1994-09-20 11:11:53 +00:00
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 ) ;
1994-08-23 12:53:59 +00:00
}
else
{
if ( _stampa_width = = 132 )
1994-10-04 17:25:53 +00:00
set_row ( r , " ****** ********@18gTOTALE GENERALE@49g!@50g%r@67g%r@82g!@83g%r@99g%r@114g!@115g%r %c " , & _saldo_dare_tot , & _saldo_avere_tot ,
& _mov_dare_tot , & _mov_avere_tot , & _saldo_finale_tot , app ) ;
else if ( app = = ' D ' )
1994-09-20 11:11:53 +00:00
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 ) ;
1994-10-04 17:25:53 +00:00
else
1994-09-20 11:11:53 +00:00
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 ) ;
1994-08-23 12:53:59 +00:00
}
}
1994-09-20 11:11:53 +00:00
1994-08-23 12:53:59 +00:00
void CG1500_application : : stampa_totali ( )
{
TString dep = " " ;
real pareggio ;
real sbilancio = _tot_dare - _tot_avere ;
if ( sbilancio > ZERO ) //_tot_dare > _tot_avere
1994-09-20 11:11:53 +00:00
pareggio = _tot_avere + sbilancio ;
1994-08-23 12:53:59 +00:00
else
{
sbilancio = - sbilancio ;
pareggio = _tot_dare + sbilancio ;
}
if ( _prima_volta ) //ho finito di stampare le attivita'/passivita'
1994-09-20 11:11:53 +00:00
_prima_volta = FALSE ;
1994-08-23 12:53:59 +00:00
else
1994-09-20 11:11:53 +00:00
_seconda_volta = FALSE ;
1994-08-23 12:53:59 +00:00
_gc_prec_dare = _gc_corr_avere = " " ;
_cambiato_conto_1 = TRUE ;
_cambiato_conto_2 = TRUE ;
1994-09-20 11:11:53 +00:00
1994-08-23 12:53:59 +00:00
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 " ,
1994-09-20 11:11:53 +00:00
& _tot_dare , & _tot_avere ) ;
1994-08-23 12:53:59 +00:00
if ( _tot_dare > _tot_avere )
{
set_row ( _i + + , " @81gSBILANCIO ESERCIZIO IN CORSO@113g%r " ,
1994-09-20 11:11:53 +00:00
& sbilancio ) ;
1994-08-23 12:53:59 +00:00
set_row ( _i + + , " @92gTOTALE A PAREGGIO@113g%r " , & pareggio ) ;
}
if ( _tot_dare < _tot_avere )
{
set_row ( _i + + , " @13gSBILANCIO ESERCIZIO IN CORSO@45g%r " ,
1994-09-20 11:11:53 +00:00
& sbilancio ) ;
1994-08-23 12:53:59 +00:00
set_row ( _i + + , " @24gTOTALE A PAREGGIO@45g%r " , & pareggio ) ;
}
_tot_dare = ZERO ;
_tot_avere = ZERO ;
}
1994-10-04 17:25:53 +00:00
//per Attivita'/Passivita' stampo anche lo sbilancio es. precedente
1994-10-17 13:41:53 +00:00
void CG1500_application : : stampa_totali_uno ( const real & r1 , const real & r2 )
1994-10-04 17:25:53 +00:00
{
TString dep = " " ;
real pareggio ;
1994-10-17 13:41:53 +00:00
real sbilancio = _tot_dare - r1 - ( _tot_avere - r2 ) ;
real sbilprec = r2 - r1 ;
/*
if ( sbilancio > ZERO ) //ho un utile => va stampato tra le passivita'
{
sbilprec = - sbilprec ;
pareggio = _tot_avere + sbilancio + sbilprec ;
}
else if ( sbilancio < ZERO ) //ho una perdita => va stampato tra le attivita' cambiato di segno
{
sbilancio = - sbilancio ;
pareggio = _tot_dare + sbilancio + sbilprec ;
}
*/
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 ( sbilancio > ZERO ) //ho un utile => va stampato tra le passivita'
1994-10-04 17:25:53 +00:00
{
sbilprec = - sbilprec ;
1994-10-17 13:41:53 +00:00
pareggio = _tot_avere + sbilancio + sbilprec ;
if ( sbilprec ! = ZERO )
set_row ( _i + + , " @79gSBILANCIO ESERCIZIO PRECEDENTE@113g%r " ,
& sbilprec ) ;
set_row ( _i + + , " @81gSBILANCIO ESERCIZIO IN CORSO@113g%r " ,
& sbilancio ) ;
set_row ( _i + + , " @92gTOTALE A PAREGGIO@113g%r " , & pareggio ) ;
}
else if ( sbilancio < ZERO ) //ho una perdita => va stampato tra le attivita'
{
sbilancio = - sbilancio ;
pareggio = _tot_dare + sbilancio + sbilprec ;
if ( sbilprec ! = ZERO )
set_row ( _i + + , " @11gSBILANCIO ESERCIZIO PRECEDENTE@45g%r " ,
& sbilprec ) ;
set_row ( _i + + , " @13gSBILANCIO ESERCIZIO IN CORSO@45g%r " ,
& sbilancio ) ;
set_row ( _i + + , " @24gTOTALE A PAREGGIO@45g%r " , & pareggio ) ;
}
else //sbilancio es. in corso == 0
1994-10-04 17:25:53 +00:00
{
1994-10-17 13:41:53 +00:00
sbilprec = - sbilprec ;
if ( sbilprec > ZERO ) //va stampato sotto le passivita'
{
pareggio = _tot_avere + sbilprec ;
set_row ( _i + + , " @79gSBILANCIO ESERCIZIO PRECEDENTE@113g%r " ,
& sbilprec ) ;
set_row ( _i + + , " @92gTOTALE A PAREGGIO@113g%r " , & pareggio ) ;
}
else if ( sbilprec < ZERO )
{
sbilprec = - sbilprec ;
pareggio = _tot_dare + sbilprec ;
set_row ( _i + + , " @11gSBILANCIO ESERCIZIO PRECEDENTE@45g%r " ,
& sbilprec ) ;
set_row ( _i + + , " @24gTOTALE A PAREGGIO@45g%r " , & pareggio ) ;
}
1994-10-04 17:25:53 +00:00
}
1994-10-17 13:41:53 +00:00
_tot_dare = ZERO ;
_tot_avere = ZERO ;
1994-10-04 17:25:53 +00:00
}
1994-08-23 12:53:59 +00:00
void CG1500_application : : stampa_prima_colonna ( int g , int c , long s ,
1994-09-20 11:11:53 +00:00
const char * desc , const real & saldo )
1994-08-23 12:53:59 +00:00
{
1994-09-20 11:11:53 +00:00
char dep = ' * ' ;
1994-10-04 17:25:53 +00:00
if ( _codici ) //sono stampate solo le descrizioni dei conti
1994-09-20 11:11:53 +00:00
{
1994-10-04 17:25:53 +00:00
if ( ! _totali )
set_row ( _i , " %s @45g%r @66g%c " , desc , & saldo , dep ) ;
else if ( ! ( c = = 0 & & s = = 0 ) )
set_row ( _i , " %s @45g%r @66g%c " , desc , & saldo , dep ) ;
1994-09-20 11:11:53 +00:00
}
else
{
1994-10-04 17:25:53 +00:00
if ( _totali & & c = = 0 & & s = = 0l )
return ;
else if ( c = = 0 & & s = = 0l )
{
set_row ( _i , " %3d " , g ) ;
set_row ( _i , " @18g%s @45g%r @66g%c " , desc , & saldo , dep ) ;
}
else if ( s = = 0l )
{
set_row ( _i , " %3d " , g ) ;
set_row ( _i , " %3d " , c ) ;
set_row ( _i , " @18g%s @45g%r @66g%c " , desc , & saldo , dep ) ;
}
else
{
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%c " , desc , & saldo , dep ) ;
}
1994-09-20 11:11:53 +00:00
}
1994-08-23 12:53:59 +00:00
}
void CG1500_application : : stampa_seconda_colonna ( int g , int c , long s ,
1994-09-20 11:11:53 +00:00
const char * desc , const real & saldo )
1994-08-23 12:53:59 +00:00
{
1994-09-20 11:11:53 +00:00
char dep = ' * ' ;
1994-08-23 12:53:59 +00:00
if ( _codici ) //sono stampate solo le descrizioni dei conti
{
1994-10-04 17:25:53 +00:00
if ( ! _totali )
{
set_row ( _i , " @66g%c " , dep ) ;
set_row ( _i , " @69g%s " , desc ) ;
1994-09-20 11:11:53 +00:00
set_row ( _i , " @113g%r " , & saldo ) ;
1994-10-04 17:25:53 +00:00
}
else if ( ! ( c = = 0 & & s = = 0 ) )
set_row ( _i , " @66g%c @69g%s @113g%r " , dep , desc , & saldo ) ;
}
1994-09-20 11:11:53 +00:00
else
{
1994-10-04 17:25:53 +00:00
if ( _totali & & c = = 0 & & s = = 0l )
return ;
else if ( c = = 0 & & s = = 0l )
{
set_row ( _i , " @66g%c@69g%3d " , dep , g ) ;
set_row ( _i , " @86g%s @113g%r " , desc , & saldo ) ;
}
else if ( s = = 0l )
{
set_row ( _i , " @66g%c@69g%3d " , dep , g ) ;
set_row ( _i , " %3d " , c ) ;
set_row ( _i , " @86g%s @113g%r " , desc , & saldo ) ;
}
else
{
set_row ( _i , " @66g%c@69g%3d " , dep , g ) ;
set_row ( _i , " %3d " , c ) ;
set_row ( _i , " %6ld " , ( const char * ) s ) ;
set_row ( _i , " @86g%s @113g%r " , desc , & saldo ) ;
}
1994-09-20 11:11:53 +00:00
}
1994-08-23 12:53:59 +00:00
}
print_action CG1500_application : : postprocess_page ( int file , int counter )
{
if ( _bilancio = = 1 )
{
1994-10-04 17:25:53 +00:00
if ( _eof1 & & _eof2 & & _eof3 & & _eof4 & & _eof5 & & _eof6 & & _salto_pagina1 )
1994-09-20 11:11:53 +00:00
return NEXT_PAGE ;
1994-08-23 12:53:59 +00:00
}
else //bilancio di verifica
{
1994-10-04 17:25:53 +00:00
if ( _verifica = = 3 )
1994-08-23 12:53:59 +00:00
{
if ( _buff = = NULL )
1994-09-20 11:11:53 +00:00
return NEXT_PAGE ;
1994-08-23 12:53:59 +00:00
}
else if ( _eof1 )
1994-09-20 11:11:53 +00:00
return NEXT_PAGE ;
1994-08-23 12:53:59 +00:00
}
return REPEAT_PAGE ;
}
TDate CG1500_application : : UltimaData ( int g , int c , long s , int anno )
{
TDate uldata ;
1994-10-04 17:25:53 +00:00
TLocalisamfile saldi ( LF_SALDI , FALSE ) ; //il parametro a false permette di usare un record corrente del file saldi differente a quello del file tmp
1994-08-23 12:53:59 +00:00
saldi . zero ( ) ;
if ( _annoes ! = 0 )
1994-09-20 11:11:53 +00:00
saldi . put ( SLD_ANNOES , anno ) ;
1994-08-23 12:53:59 +00:00
saldi . put ( SLD_GRUPPO , g ) ;
if ( c ! = 0 )
1994-09-20 11:11:53 +00:00
saldi . put ( SLD_CONTO , c ) ;
1994-08-23 12:53:59 +00:00
if ( s ! = 0 )
1994-09-20 11:11:53 +00:00
saldi . put ( SLD_SOTTOCONTO , s ) ;
1994-08-23 12:53:59 +00:00
saldi . read ( ) ;
if ( saldi . bad ( ) )
1994-09-20 11:11:53 +00:00
saldi . zero ( ) ;
1994-08-23 12:53:59 +00:00
uldata = saldi . get ( SLD_DATAULMOV ) ;
1994-10-04 17:25:53 +00:00
1994-08-23 12:53:59 +00:00
return uldata ;
}
1994-09-20 11:11:53 +00:00
1994-08-23 12:53:59 +00:00
const char * CG1500_application : : DescrizioneConto ( int g , int c , long s ,
1994-10-04 17:25:53 +00:00
char tipocf )
1994-08-23 12:53:59 +00:00
{
1994-10-04 17:25:53 +00:00
/*
TConto tc ( g , c , s , tipocf ) ;
TMP = tc . descrizione ( ) ;
return TMP ;
*/
1994-08-23 12:53:59 +00:00
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 ( ) )
1994-09-20 11:11:53 +00:00
TMP = pconti . get ( PCN_DESCR ) ;
1994-08-23 12:53:59 +00:00
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 ( ) )
1994-09-20 11:11:53 +00:00
TMP = clifo . get ( CLI_RAGSOC ) ;
1994-08-23 12:53:59 +00:00
else
1994-09-20 11:11:53 +00:00
TMP = " " ;
1994-08-23 12:53:59 +00:00
}
1994-09-20 11:11:53 +00:00
return TMP ;
1994-10-04 17:25:53 +00:00
}
1994-08-23 12:53:59 +00:00
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 ;
}
1994-10-04 17:25:53 +00:00
void CG1500_application : : leggi_pcon ( )
{
TLocalisamfile pconti ( LF_PCON ) ;
TToken_string gc ( 10 ) ;
for ( pconti . first ( ) ; ! pconti . eof ( ) ; pconti . next ( ) )
{
gc . restart ( ) ;
int gruppo = pconti . get_int ( PCN_GRUPPO ) ;
int conto = pconti . get_int ( PCN_CONTO ) ;
long sottoconto = pconti . get_long ( PCN_SOTTOCONTO ) ;
if ( ( sottoconto = = 0l ) & & ( conto ! = 0 ) ) //si tratta di un conto
{
char tipocf = pconti . get_char ( PCN_TMCF ) ;
if ( tipocf = = ' C ' )
{
gc . add ( gruppo , 0 ) ;
gc . add ( conto , 1 ) ;
_clienti . add ( gc ) ;
}
else if ( tipocf = = ' F ' )
{
gc . add ( gruppo , 0 ) ;
gc . add ( conto , 1 ) ;
_fornitori . add ( gc ) ;
}
}
}
}
1994-08-23 12:53:59 +00:00
bool CG1500_application : : set_print ( int )
{
TMask m ( " cg1500a " ) ;
KEY tasto ;
1994-09-20 11:11:53 +00:00
{
TConfig conf ( CONFIG_DITTA ) ;
1994-08-23 12:53:59 +00:00
1994-09-20 11:11:53 +00:00
_causale_ap = conf . get ( " CoCaCh " ) ;
_causale_chi = conf . get ( " CoCaCh " ) ;
}
m . set_handler ( F_VERIFICA , my_handler ) ;
m . set_handler ( F_BILANCIO , mask_bilancio ) ;
m . set_handler ( F_STAMPA1 , mask_bilancio ) ;
m . set_handler ( F_STAMPA , mask_bilancio ) ;
m . set_handler ( F_DATALIM , mask_datalim ) ;
m . set_handler ( F_DATADA , mask_date ) ;
m . set_handler ( F_DATAA , mask_date ) ;
m . set_handler ( F_ANNO , mask_anno ) ;
tasto = m . run ( ) ;
if ( tasto = = K_ENTER )
{
_annoes = atoi ( m . get ( F_ANNO ) ) ;
_bilancio = atoi ( m . get ( F_BILANCIO ) ) ;
_data = m . get ( F_DATASTAMPA ) ;
if ( _bilancio = = 1 )
1994-08-23 12:53:59 +00:00
{
1994-09-20 11:11:53 +00:00
_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 )
1994-08-23 12:53:59 +00:00
{
1994-09-20 11:11:53 +00:00
if ( _annoes ! = 0 )
_dataini = InizioEsercizio ( _annoes ) ;
1994-10-04 17:25:53 +00:00
else _dataini = _inizioEs ;
_datalim = m . get ( F_DATALIM ) ;
1994-09-20 11:11:53 +00:00
_stampa_mov_prov = ( bool ) ( m . get ( F_STAMPAMPROV ) = = " X " ) ;
1994-08-23 12:53:59 +00:00
}
1994-09-20 11:11:53 +00:00
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 (vedi es. di stampa AS/400)
_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 )
1994-08-23 12:53:59 +00:00
{
1994-09-20 11:11:53 +00:00
if ( _annoes ! = 0 )
_dataini = InizioEsercizio ( _annoes ) ;
else _dataini = _inizioEs ;
_datada = m . get ( F_DATADA ) ;
_dataa = m . get ( F_DATAA ) ;
_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 ) ) ;
1994-10-04 17:25:53 +00:00
// _cur->setkey(3);
1994-09-20 11:11:53 +00:00
if ( _situazione . not_empty ( ) )
_cur - > setfilter ( format ( " TIPOCF = \" %s \" " , ( const char * ) _situazione ) ) ;
else
_cur - > setfilter ( " " ) ;
1994-08-23 12:53:59 +00:00
1994-09-20 11:11:53 +00:00
_prog = new TProgind ( _cur - > items ( ) , " Elaborazione in corso... prego attendere " , FALSE ) ;
1994-10-04 17:25:53 +00:00
_clienti . destroy ( ) ;
_fornitori . destroy ( ) ;
leggi_pcon ( ) ;
crea_sort_clifo ( ) ;
_sort - > endsort ( ) ;
delete _cf ;
1994-08-23 12:53:59 +00:00
}
}
1994-09-20 11:11:53 +00:00
delete _prog ;
return TRUE ;
}
return FALSE ;
1994-08-23 12:53:59 +00:00
}
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 ( ) ;
1994-09-20 11:11:53 +00:00
1994-08-23 12:53:59 +00:00
_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 ( ) ;
1994-10-04 17:25:53 +00:00
set_header ( r , " Ditta %s %s %s %s %s %s " , ( const char * ) codice_ditta ,
1994-09-20 11:11:53 +00:00
( const char * ) _ragsoc , ( const char * ) _viafis ,
( const char * ) _cap , ( const char * ) _comunefis ,
( const char * ) _provfis ) ;
1994-08-23 12:53:59 +00:00
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 ( ) ;
1994-09-20 11:11:53 +00:00
1994-08-23 12:53:59 +00:00
set_header ( r , " STAMPA BILANCIO A SEZIONI CONTRAPPOSTE " ) ;
if ( _tipo_stampa = = 1 )
{
1994-09-20 11:11:53 +00:00
//data_da = Controllo_data_limite(_datalim,_annoes,_annoes-1);
//data = data_da.string();
data_da = _dataini . string ( ) ;
data = _datalim . string ( ) ;
set_header ( r , " @41gdalla data %s alla data %s " , ( const char * ) data_da ,
( const char * ) data ) ;
//if (_competenza)
// set_header(r,"@88g(con controllo competenza)");
1994-08-23 12:53:59 +00:00
}
else if ( _tipo_stampa = = 2 )
1994-09-20 11:11:53 +00:00
set_header ( r , " @41gall'ultima immissione Es. %d " , _annoes ) ;
//else set_header(r, "@41gall'ultima immissione Es. Precedente");
1994-08-23 12:53:59 +00:00
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 ) ;
1994-10-04 17:25:53 +00:00
TString16 datada = _datada . string ( ) ;
TString16 dataa = _dataa . string ( ) ;
1994-08-23 12:53:59 +00:00
if ( _verifica = = 1 )
1994-09-20 11:11:53 +00:00
set_header ( r , " STAMPA BILANCIO DI VERIFICA " ) ;
1994-08-23 12:53:59 +00:00
else if ( _verifica = = 2 )
1994-09-20 11:11:53 +00:00
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 " ) ;
}
1994-08-23 12:53:59 +00:00
if ( _tipo_stampa1 = = 1 )
1994-09-20 11:11:53 +00:00
set_header ( r , " @42gdalla data %s alla data %s " , ( const char * ) datada ,
( const char * ) dataa ) ;
1994-08-23 12:53:59 +00:00
else if ( _tipo_stampa1 = = 2 )
1994-09-20 11:11:53 +00:00
set_header ( r , " @42gall'ultima immissione Es. %d " , _annoes ) ;
//else set_header(r, "@42gall'ultima immissione Es. preced.");
1994-08-23 12:53:59 +00:00
if ( ( _verifica = = 1 ) | | ( _verifica = = 2 ) )
{
if ( _stampav = = 1 )
1994-09-20 11:11:53 +00:00
set_header ( r , " @86gTutti i conti movimentati " ) ;
1994-08-23 12:53:59 +00:00
else if ( _stampav = = 2 )
1994-09-20 11:11:53 +00:00
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");
}
1994-08-23 12:53:59 +00:00
r + + ;
riga . fill ( ' - ' ) ;
set_header ( r , ( const char * ) riga ) ;
r + + ;
1994-09-20 11:11:53 +00:00
1994-08-23 12:53:59 +00:00
if ( ( ( _datada = = _dataini ) & & ( _tipo_stampa1 = = 1 ) ) | | ( _tipo_stampa1 ! = 1 ) )
{
1994-09-20 11:11:53 +00:00
if ( ( _verifica = = 1 ) | | ( _verifica = = 3 ) )
1994-10-04 17:25:53 +00:00
set_header ( r , " @7g!@16g!@49g!@58gSALDO INIZIALE@82g!@88gMOVIMENTI DEL PERIODO " ) ;
1994-09-20 11:11:53 +00:00
else
1994-10-04 17:25:53 +00:00
set_header ( r , " @7g!@49g!@58gSALDO INIZIALE@82g!@88gMOVIMENTI DEL PERIODO " ) ;
1994-08-23 12:53:59 +00:00
}
else if ( _tipo_stampa1 = = 1 )
1994-09-20 11:11:53 +00:00
if ( ( _verifica = = 1 ) | | ( _verifica = = 3 ) )
1994-10-04 17:25:53 +00:00
set_header ( r , " @7g!@16g!@49g!@55gPROGRESSIVI PRECEDENTI@82g!@88gMOVIMENTI DEL PERIODO " ) ;
1994-09-20 11:11:53 +00:00
else
1994-10-04 17:25:53 +00:00
set_header ( r , " @7g!@49g!@55gPROGRESSIVI PRECEDENTI@82g!@88gMOVIMENTI DEL PERIODO " ) ;
1994-08-23 12:53:59 +00:00
if ( _stampa_width = = 148 )
1994-10-04 17:25:53 +00:00
set_header ( r , " @115g!@130gSALDO@148g! " ) ;
else
set_header ( r , " @114g! " ) ;
1994-08-23 12:53:59 +00:00
r + + ;
1994-09-20 11:11:53 +00:00
1994-08-23 12:53:59 +00:00
if ( ( _verifica = = 1 ) | | ( _verifica = = 3 ) )
{
if ( _stampa_width = = 132 )
{
1994-10-04 17:25:53 +00:00
set_header ( r + + , " @2gcod. ! ultima !@49g!@50g%.32s@82g!@83g%.32s@114g!@121gSALDO " , ( const char * ) riga , ( const char * ) riga ) ;
set_header ( r + + , " @2gconto! data ! denominazione@49g!@57gDare@66g!@73gAvere@82g!@89gDare@98g!@104gAvere@114g! " ) ;
1994-08-23 12:53:59 +00:00
}
else
{
1994-09-20 11:11:53 +00:00
set_header ( r + + , " @2gcod. ! ultima !@49g!@50g%.32s@82g!@83g%.32s@115g!%.32s@148g! " , ( const char * ) riga , ( const char * ) riga , ( const char * ) riga ) ;
1994-10-04 17:25:53 +00:00
set_header ( r + + , " @2gconto! data ! denominazione@49g!@57gDare@66g!@73gAvere@82g!@91gDare@99g!@106gAvere@115g!@124gDare@132g!@139gAvere@148g! " ) ;
1994-08-23 12:53:59 +00:00
}
}
else
{
if ( _stampa_width = = 132 )
{
1994-10-04 17:25:53 +00:00
set_header ( r + + , " @2gcod. !@49g!@50g%.32s@82g!@83g%.32s@114g!@121gSALDO " , ( const char * ) riga , ( const char * ) riga ) ;
set_header ( r + + , " @1gmastro!descrizione@49g!@57gDare@66g!@73gAvere@82g!@89gDare@98g!@104gAvere@114g! " ) ;
1994-08-23 12:53:59 +00:00
}
else
{
1994-09-20 11:11:53 +00:00
set_header ( r + + , " @2gcod. !@49g!@50g%.32s@82g!@83g%.32s@115g!%.32s@148g! " , ( const char * ) riga , ( const char * ) riga , ( const char * ) riga ) ;
1994-10-04 17:25:53 +00:00
set_header ( r + + , " @1gmastro!descrizione@49g!@57gDare@66g!@73gAvere@82g!@91gDare@99g!@106gAvere@115g!@124gDare@132g!@139gAvere@148g! " ) ;
1994-08-23 12:53:59 +00:00
}
}
set_header ( r , ( const char * ) riga ) ;
if ( _stampa_width = = 148 )
1994-09-20 11:11:53 +00:00
set_header ( r , " @148g! " ) ;
1994-08-23 12:53:59 +00:00
}
}
1994-09-20 11:11:53 +00:00
1994-08-23 12:53:59 +00:00
int cg1500 ( int argc , char * argv [ ] )
{
CG1500_application a ;
a . run ( argc , argv , " Stampa bilanci " ) ;
return 0 ;
}
1994-10-04 17:25:53 +00:00
/*
if ( ! compensa )
{
if ( ( indbil_conto = = 1 ) | | ( indbil_conto = = 3 ) )
if ( saldo > ZERO ) //saldo in dare
_indbil = indbil_conto ;
else //saldo in avere
{
if ( indbil_conto = = 1 )
_indbil = 2 ;
else _indbil = 4 ;
saldo = - saldo ;
}
if ( ( indbil_conto = = 2 ) | | ( indbil_conto = = 4 ) )
if ( saldo < ZERO )
{
_indbil = indbil_conto ;
saldo = - saldo ;
}
else
if ( indbil_conto = = 2 )
_indbil = 1 ;
else _indbil = 3 ;
}
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 ;
}
}
*/