2002-07-02 16:21:23 +00:00
// Stampa bilanci
1995-07-21 10:12:15 +00:00
1996-06-07 15:07:55 +00:00
// W96SALDI e' la sigla di tutte le modifiche effettuate riguardo il cambiamento dell' archivio
// SALDI. L' archivio e' cambiato nel seguente modo:
// - Non esistono piu' i progressivi dei movimenti scaricati PDARESCA e PAVERESCA;
// - Ora esistono un record per i movimenti normali e un record per i movimenti scaricati; la
// distinzione e' resa possibile dall' introduzione in chiave di un flag FLSCA (vedi tracciato)
// che e' un booleano. Il record con FLSCA = FALSE contiene la somma dei saldi dei movimenti
// normali e dei movimenti scaricati, mentre il record con FLSCA = TRUE, contiene solo i saldi
// dei movimenti scaricati.
// Tutti i progressivi che nel programma venivano memorizzati nei campi PDARESCA e PAVERESCA dei
// file temporanei ora sono memorizzati in PDAREPRO e PAVEREPRO.
// Le funzioni che sono state modificate sono:
// - bil_verifica();
// - ricerca_cf(...);
// - scrivi_record_gruppo();
// - scrivi_record_conto();
// - leggi_clifo();
// - leggi_file_tmp();
// - UltimaData();
1999-07-16 14:59:11 +00:00
# include <currency.h>
1995-07-21 10:12:15 +00:00
# include <mask.h>
2002-05-08 16:25:49 +00:00
# include <modaut.h>
1995-07-21 10:12:15 +00:00
# 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 "cg1.h"
1995-11-17 14:29:24 +00:00
# include "cg1500.h"
1997-06-19 14:33:52 +00:00
# include "cglib01.h"
# include "cglib02.h"
1995-07-21 10:12:15 +00:00
2002-05-08 16:25:49 +00:00
class TSaldo_cdc : public TSaldo
{
public :
2002-07-02 16:21:23 +00:00
bool data_limite_commessa ( int bilancio , int g , int c , long s ,
const TString & commessa , const TString & fase , const TDate & data_inf ,
2002-05-08 16:25:49 +00:00
const TDate & data_sup , int indbil , int stp_prov ) ;
} ;
//per bilancio scalare (ovvero a sezioni contrapposte) per data limite
2002-07-02 16:21:23 +00:00
bool TSaldo_cdc : : data_limite_commessa ( int bilancio , int g , int c , long s ,
const TString & commessa , const TString & fase , const TDate & data_inf ,
2002-05-08 16:25:49 +00:00
const TDate & data_sup , int indbil , int stp_prov )
{
TString filter ;
2002-07-02 16:21:23 +00:00
filter < < ' ( ' < < RMV_CODCMS < < " == \" " < < commessa < < " \" ) " ;
if ( fase . not_empty ( ) )
filter < < " &&( " < < RMV_FASCMS < < " == \" " < < fase < < " \" ) " ;
2002-05-08 16:25:49 +00:00
return data_limite_bilancio ( bilancio , g , c , s , data_inf , data_sup , indbil , stp_prov , filter ) ;
}
1997-10-16 08:47:25 +00:00
class TStampa_bilanci : public TPrintapp
1995-07-21 10:12:15 +00:00
{
1997-06-19 14:33:52 +00:00
static bool mask_anno ( TMask_field & f , KEY k ) ;
static bool mask_datalim ( TMask_field & f , KEY k ) ;
2002-07-02 16:21:23 +00:00
static bool verifica_handler ( TMask_field & f , KEY k ) ;
1997-06-19 14:33:52 +00:00
static bool mask_date ( TMask_field & f , KEY k ) ;
static bool mask_bilancio ( TMask_field & f , KEY k ) ;
static bool mask_tipost ( TMask_field & f , KEY k ) ;
2002-07-02 16:21:23 +00:00
static bool cdc_handler ( TMask_field & f , KEY k ) ;
1995-07-21 10:12:15 +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 ;
TDate udata ;
} ;
TSort * _sort ;
TRelation * _rel ;
TCursor * _cur ;
TProgind * _prog ;
TSaldi_list * _listacf , * _lista ;
TLocalisamfile * _com , * _pcn , * _mov , * _rmov , * _clifo , * _saldi , * _nditte , * _anag , * _caus ;
TIsamtempfile * _tmp_saldi_att , * _tmp_saldi_pass , * _tmp_saldi_conti_uno ;
TIsamtempfile * _tmp_saldi_costi , * _tmp_saldi_ricavi , * _tmp_saldi_conti_due ;
TParagraph_string * _d ;
1997-10-16 08:47:25 +00:00
const char * _buff ;
bool _noseparator ; // Usa separatore delle migliaia o no?
1995-07-21 10:12:15 +00:00
TString _cofi , _cap , _paiva , _ragsoc , _comunefis , _provfis , _viafis ;
TString _descr_dare , _descr_avere , _gc_corr_dare , _gc_corr_avere , _descr ;
TString _gc_prec_dare , _gc_prec_avere , _situazione , _descr_succ ;
2002-12-17 12:02:54 +00:00
TString _tmp ;
1995-07-21 10:12:15 +00:00
char _tipo_conto , _tipoc_succ ;
int _annoes , _bilancio , _tipo_stampa , _tipo_stampa1 , _stampa_width , _gp , _cp , _i ;
int _eof1 , _eof2 , _gruppo_dare , _gruppo_avere , _conto_dare , _conto_avere ;
int _add_file_da , _add_file_a , _indbil_dare , _indbil_avere , _indbil ;
int _eof3 , _eof4 , _eof5 , _eof6 , _verifica , _stampac , _stampav , _ordinamento ;
int _gruppo , _conto , _gruppo_succ , _conto_succ , _annoapp ;
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 ;
real _gruppo_da_ordine , _gruppo_a_ordine ;
real _prg_saldoini_dare , _prg_saldoini_avere , _prg_inidare_ord , _prg_iniavere_ord ;
real _nuovo_tot_saldo_d , _nuovo_tot_saldo_a ;
TDate _datalim , _data , _datada , _dataa , _dataini , _ultima_data , _u_max ;
bool _cambiato_conto_1 , _cambiato_conto_2 , _add_file_avere ;
bool _add_file_dare , _prima_volta , _seconda_volta , _totali , _codici , _saldo ;
bool _add_dare , _add_avere , _controlla , _salto_pagina , _flag , _stampato ;
1995-11-30 09:39:32 +00:00
bool _sottoc_dare , _sottoc_avere , _salto_pagina1 , _livello_conto ;
1996-06-19 14:04:56 +00:00
bool _mov_ap , _quadratura ;
2002-12-20 16:15:03 +00:00
bool _print_exercise , _hide_clifo ;
1995-07-21 10:12:15 +00:00
int _stampa_mov_prov ;
2002-05-08 16:25:49 +00:00
2002-07-02 16:21:23 +00:00
TString _cdc , _fsc ;
1997-10-16 08:47:25 +00:00
1995-07-21 10:12:15 +00:00
TArray _clienti , _fornitori ;
public :
TDate _inizioEs , _fineEs ;
1996-07-09 13:00:08 +00:00
int date2esc ( const TDate & d , int * prevesc = NULL ) ;
1995-07-21 10:12:15 +00:00
bool menu ( MENU_TAG m ) { return TPrintapp : : menu ( m ) ; }
virtual bool user_create ( ) ;
virtual bool user_destroy ( ) ;
bool set_print ( int ) ;
2002-05-08 16:25:49 +00:00
void next_c ( ) ;
void header_cdc ( int & r ) ;
1995-07-21 10:12:15 +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 ) ;
virtual void postclose_print ( ) ;
virtual void set_page ( int , int ) ;
real compensazione ( bool compensa , int indbil_conto , real & saldo ) ;
//const char* causale_chiusura() { return _causale_chi;}
//const char* causale_apertura() { return _causale_ap;}
bool bil_sez_contr ( ) ;
bool bil_verifica ( ) ;
bool ricerca_sottoc_clifo ( int , int , bool , int , real & ) ;
bool ricerca_cf ( int , int , char , int , real & , real & , real & , real & , real & , real & , real & ) ;
bool calcola ( int , int , long ) ;
void leggi_pcon ( ) ; // Inizializza i TArray C/F
void crea_sort_clifo ( ) ;
1995-11-03 09:44:29 +00:00
void leggi_clifo ( const TArray & ) ;
1995-07-21 10:12:15 +00:00
void init_sort ( ) ;
void leggi_sort ( ) ;
void riempi_record ( char , int , int , long , const char * , const real & ,
const real & , const real & , const real & , const real & ) ;
void get_dati_ditta ( ) ;
void scrivi_record_conto ( const real & , const real & , const real & ,
const real & , const real & ) ;
void scrivi_record_gruppo ( const real & , const real & , const real & ,
const real & , const real & ) ;
int stampa_record_conto ( int , int , const TString & , const real & , const real & ,
const real & , const real & , const real & , const char ) ;
int stampa_intestazione_ditta ( ) ;
int cerca_indbil ( int , int ) ;
void scrivig_file_temp ( ) ;
void scrivic_file_temp ( ) ;
2002-05-08 16:25:49 +00:00
void scrivis_file_temp ( int , int , long , const real & ) ;
1995-07-21 10:12:15 +00:00
void leggi_files_dare ( TIsamtempfile * ) ;
void leggi_files_avere ( TIsamtempfile * ) ;
void leggi_file_tmp ( ) ;
void stampa_riga_totali ( int ) ;
void stampa_prima_colonna ( int , int , long , const char * , const real & ) ;
void stampa_seconda_colonna ( int , int , long , const char * , const real & ) ;
void stampa_totali ( ) ;
void stampa_totali_uno ( const real & , const real & ) ;
void controlla_conto ( int , int ) ;
const char * DescrizioneConto ( int , int , long , char ) ; //chiama quella di TConto
TDate UltimaData ( int , int , long , int ) ;
2002-05-08 16:25:49 +00:00
void stampa_un_bilancio ( const TMask & m ) ;
1995-07-21 10:12:15 +00:00
1997-10-16 08:47:25 +00:00
TStampa_bilanci ( ) { }
1995-07-21 10:12:15 +00:00
} ;
1997-10-16 08:47:25 +00:00
HIDDEN inline TStampa_bilanci & app ( ) { return ( TStampa_bilanci & ) main_app ( ) ; }
1995-07-21 10:12:15 +00:00
TDate InizioEsercizio ( int anno )
{
1997-10-16 08:47:25 +00:00
TEsercizi_contabili esc ;
TDate inizio_es ;
if ( esc . exist ( anno ) )
inizio_es = esc [ anno ] . inizio ( ) ;
return inizio_es ;
1995-07-21 10:12:15 +00:00
}
TDate FineEsercizio ( int anno )
{
1997-10-16 08:47:25 +00:00
TEsercizi_contabili esc ;
1995-07-21 10:12:15 +00:00
TDate fine_es ;
1997-10-16 08:47:25 +00:00
if ( esc . exist ( anno ) )
fine_es = esc [ anno ] . fine ( ) ;
1995-07-21 10:12:15 +00:00
return fine_es ;
}
bool IsEsercizio ( const TDate & datalim , int anno_eser )
{
1997-10-16 08:47:25 +00:00
TEsercizi_contabili esc ;
bool yes = esc . date2esc ( datalim ) = = anno_eser ;
return yes ;
1995-07-21 10:12:15 +00:00
}
1997-10-16 08:47:25 +00:00
int TStampa_bilanci : : date2esc ( const TDate & d , int * prevesc )
1996-07-09 13:00:08 +00:00
{
1997-10-16 08:47:25 +00:00
TEsercizi_contabili esc ;
int anno = esc . date2esc ( d ) ;
if ( prevesc )
* prevesc = esc . pred ( anno ) ;
return anno ;
1996-07-09 13:00:08 +00:00
}
1997-10-16 08:47:25 +00:00
bool TStampa_bilanci : : mask_anno ( TMask_field & f , KEY k )
1995-07-21 10:12:15 +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 )
{
2003-02-25 15:20:00 +00:00
f . error_box ( TR ( " Indicare l'anno di esercizio " ) ) ;
1995-07-21 10:12:15 +00:00
return FALSE ;
}
}
if ( k = = K_TAB | | f . focusdirty ( ) )
{
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 ( ( 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 ) ;
}
1996-07-09 13:00:08 +00:00
}
if ( k = = K_TAB )
{
int tipo_bil , tipo_stp ;
tipo_bil = f . mask ( ) . get_int ( F_BILANCIO ) ;
if ( tipo_bil = = 1 )
tipo_stp = f . mask ( ) . get_int ( F_STAMPA ) ;
else
tipo_stp = f . mask ( ) . get_int ( F_STAMPA1 ) ;
2001-05-01 08:17:07 +00:00
if ( tipo_bil = = 2 & & tipo_stp = = 1 /* && f.mask().get_int(F_ANNO) == 0 */ )
1996-07-09 13:00:08 +00:00
f . mask ( ) . show ( F_QUADRATURA ) ;
else
{
f . mask ( ) . set ( F_QUADRATURA , " " ) ;
f . mask ( ) . hide ( F_QUADRATURA ) ;
}
1995-07-21 10:12:15 +00:00
}
return TRUE ;
}
1997-10-16 08:47:25 +00:00
bool TStampa_bilanci : : mask_bilancio ( TMask_field & f , KEY k )
1996-07-09 13:00:08 +00:00
{
int tipo_bil , tipo_stp ;
1995-07-21 10:12:15 +00:00
if ( k = = K_SPACE )
{
2002-07-02 16:21:23 +00:00
TMask & m = f . mask ( ) ;
const int anno = m . get_int ( F_ANNO ) ;
const int bilancio = m . get_int ( F_BILANCIO ) ;
1995-07-21 10:12:15 +00:00
int tipo_stampa ;
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 ) ;
}
2002-07-02 16:21:23 +00:00
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 ) ;
// Disabilito le commesse nelle stampe all'ultima immissione
m . hide ( - 4 ) ;
m . reset ( - 4 ) ;
}
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 ) ;
}
// Abilito eventualmente le commesse
if ( main_app ( ) . has_module ( CMAUT ) )
m . show ( - 4 ) ;
else
1995-07-21 10:12:15 +00:00
{
2002-07-02 16:21:23 +00:00
m . hide ( - 4 ) ;
m . reset ( - 4 ) ;
1995-07-21 10:12:15 +00:00
}
2002-07-02 16:21:23 +00:00
}
1996-07-09 13:00:08 +00:00
tipo_bil = f . mask ( ) . get_int ( F_BILANCIO ) ;
if ( tipo_bil = = 1 )
tipo_stp = f . mask ( ) . get_int ( F_STAMPA ) ;
else
tipo_stp = f . mask ( ) . get_int ( F_STAMPA1 ) ;
2001-05-01 08:17:07 +00:00
if ( tipo_bil = = 2 & & tipo_stp = = 1 /* && f.mask().get_int(F_ANNO) == 0 */ )
1996-07-09 13:00:08 +00:00
f . mask ( ) . show ( F_QUADRATURA ) ;
else
2001-05-01 08:17:07 +00:00
{
f . mask ( ) . set ( F_QUADRATURA , " " ) ;
1996-07-09 13:00:08 +00:00
f . mask ( ) . hide ( F_QUADRATURA ) ;
2001-05-01 08:17:07 +00:00
}
1995-07-21 10:12:15 +00:00
}
return TRUE ;
}
1997-10-16 08:47:25 +00:00
bool TStampa_bilanci : : mask_datalim ( TMask_field & f , KEY k )
1995-07-21 10:12:15 +00:00
{
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 ) )
{
2003-02-25 15:20:00 +00:00
f . error_box ( TR ( " La data limite deve appartenere all'esercizio indicato " ) ) ;
1995-07-21 10:12:15 +00:00
return FALSE ;
}
}
else
f . mask ( ) . field ( F_DATALIM ) . set ( FineEsercizio ( anno ) ) ;
}
else //anno == 0
{
if ( ! datalim . ok ( ) )
{
2003-02-25 15:20:00 +00:00
f . error_box ( TR ( " La data limite e' obbligatoria " ) ) ;
1995-07-21 10:12:15 +00:00
return FALSE ;
}
1996-07-09 13:00:08 +00:00
long anno = app ( ) . date2esc ( datalim ) ;
1995-07-21 10:12:15 +00:00
if ( anno = = 0 )
{
2003-02-25 15:20:00 +00:00
f . error_box ( TR ( " La data limite deve appartenere ad un esercizio attivo della ditta " ) ) ;
1995-07-21 10:12:15 +00:00
return FALSE ;
}
}
}
return TRUE ;
}
1997-10-16 08:47:25 +00:00
bool TStampa_bilanci : : mask_date ( TMask_field & f , KEY k )
1995-07-21 10:12:15 +00:00
{
1996-06-19 14:04:56 +00:00
if ( k = = K_TAB )
{
const short id = f . dlg ( ) ;
if ( id = = F_DATAA )
{
TDate data ( f . get ( ) ) ;
int bil = f . mask ( ) . get_int ( F_BILANCIO ) ;
1997-10-16 08:47:25 +00:00
TEsercizi_contabili esc ;
int anno = esc . date2esc ( data ) ;
if ( anno )
1996-06-19 14:04:56 +00:00
{
1997-10-16 08:47:25 +00:00
TDate dataini = esc [ anno ] . fine ( ) ;
2001-05-01 08:17:07 +00:00
if ( data = = dataini & & bil = = 2 /*&& f.mask().get_int(F_ANNO) == 0*/ )
1996-06-19 14:04:56 +00:00
f . mask ( ) . show ( F_QUADRATURA ) ;
else
2001-05-01 08:17:07 +00:00
{
f . mask ( ) . reset ( F_QUADRATURA ) ;
1996-06-19 14:04:56 +00:00
f . mask ( ) . hide ( F_QUADRATURA ) ;
2001-05-01 08:17:07 +00:00
}
1996-06-19 14:04:56 +00:00
}
}
}
1995-07-21 10:12:15 +00:00
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 ) )
{
2003-02-25 15:20:00 +00:00
f . error_box ( TR ( " La data indicata deve essere all'interno dell'esercizio " ) ) ;
1995-07-21 10:12:15 +00:00
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 ) ) ;
}
app ( ) . _annoapp = anno ;
}
else
{
if ( ! data . ok ( ) )
{
2003-02-25 15:20:00 +00:00
f . error_box ( TR ( " Indicare una data appartenente ad un esercizio attivo della ditta " ) ) ;
1995-07-21 10:12:15 +00:00
return FALSE ;
}
else
{
if ( id = = F_DATAA )
{
TDate from ( f . mask ( ) . get ( id - 1 ) ) ;
1996-07-09 13:00:08 +00:00
app ( ) . _annoapp = app ( ) . date2esc ( from ) ;
if ( app ( ) . _annoapp ! = app ( ) . date2esc ( data ) )
1995-07-21 10:12:15 +00:00
{
2003-02-25 15:20:00 +00:00
f . error_box ( TR ( " Le date devono appartenere ad uno stesso esercizio attivo della ditta " ) ) ;
1995-07-21 10:12:15 +00:00
return FALSE ;
}
if ( from > data )
{
2003-02-25 15:20:00 +00:00
f . error_box ( TR ( " La data limite inferiore non puo' essere maggiore della data limite superiore " ) ) ;
1995-07-21 10:12:15 +00:00
return FALSE ;
}
}
}
}
}
}
return TRUE ;
}
2002-07-02 16:21:23 +00:00
bool TStampa_bilanci : : verifica_handler ( TMask_field & f , KEY k )
1995-07-21 10:12:15 +00:00
{
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 ) ;
}
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 ) ;
}
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 ( ) . 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_STAMPAV ) ;
}
}
return TRUE ;
}
2002-07-02 16:21:23 +00:00
bool TStampa_bilanci : : cdc_handler ( TMask_field & f , KEY k )
{
if ( k = = K_TAB )
{
TMask & m = f . mask ( ) ;
const bool on = ! ( m . field ( F_DACDC ) . empty ( ) & & m . field ( F_ACDC ) . empty ( ) ) ;
if ( ! on )
{
m . reset ( F_DAFSC ) ;
m . reset ( F_AFSC ) ;
}
m . enable ( F_DAFSC , on ) ;
m . enable ( F_AFSC , on ) ;
}
return TRUE ;
}
1997-10-16 08:47:25 +00:00
void TStampa_bilanci : : scrivig_file_temp ( )
1995-07-21 10:12:15 +00:00
{
TIsamtempfile * tmp = NULL ;
TString nome_campo ( 12 ) ;
real valore ;
if ( ! _totali )
{
if ( _add_dare )
{
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 ) ;
1996-06-07 15:07:55 +00:00
tmp - > put ( SLD_CONTO , 0 ) ;
tmp - > put ( SLD_SOTTOCONTO , 0L ) ;
tmp - > put ( SLD_ANNOES , 0 ) ; // W96SALDI del 07-06-96
tmp - > put ( SLD_FLSCA , FALSE ) ;
1995-07-21 10:12:15 +00:00
if ( tmp - > read ( ) = = NOERR )
{
tmp - > put ( SLD_CONTO , 0 ) ;
tmp - > put ( SLD_SOTTOCONTO , 0L ) ;
tmp - > put ( nome_campo , valore ) ;
tmp - > rewrite ( ) ;
}
else
1996-06-07 15:07:55 +00:00
{
tmp - > put ( SLD_GRUPPO , _gp ) ;
1995-07-21 10:12:15 +00:00
tmp - > put ( SLD_CONTO , 0 ) ;
tmp - > put ( SLD_SOTTOCONTO , 0L ) ;
1996-06-07 15:07:55 +00:00
tmp - > put ( SLD_ANNOES , 0 ) ; // W96SALDI del 07-06-96
tmp - > put ( SLD_FLSCA , FALSE ) ;
1995-07-21 10:12:15 +00:00
tmp - > put ( nome_campo , valore ) ;
tmp - > write ( ) ;
}
}
if ( _add_avere )
{
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 ) ;
1996-06-07 15:07:55 +00:00
tmp - > put ( SLD_CONTO , 0 ) ;
tmp - > put ( SLD_SOTTOCONTO , 0L ) ;
tmp - > put ( SLD_ANNOES , 0 ) ; // W96SALDI del 07-06-96
tmp - > put ( SLD_FLSCA , FALSE ) ;
1995-07-21 10:12:15 +00:00
if ( tmp - > read ( ) = = NOERR )
{
tmp - > put ( SLD_CONTO , 0 ) ;
tmp - > put ( SLD_SOTTOCONTO , 0L ) ;
tmp - > put ( nome_campo , valore ) ;
tmp - > rewrite ( ) ;
}
else
1996-06-07 15:07:55 +00:00
{
tmp - > put ( SLD_GRUPPO , _gp ) ;
1995-07-21 10:12:15 +00:00
tmp - > put ( SLD_CONTO , 0 ) ;
tmp - > put ( SLD_SOTTOCONTO , 0L ) ;
1996-06-07 15:07:55 +00:00
tmp - > put ( SLD_ANNOES , 0 ) ; // W96SALDI del 07-06-96
tmp - > put ( SLD_FLSCA , FALSE ) ;
1995-07-21 10:12:15 +00:00
tmp - > put ( nome_campo , valore ) ;
tmp - > write ( ) ;
}
}
}
_add_dare = _add_avere = FALSE ;
}
1997-10-16 08:47:25 +00:00
void TStampa_bilanci : : scrivic_file_temp ( )
1995-07-21 10:12:15 +00:00
{
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
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 ( ) ;
}
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
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 ( ) ;
}
}
2002-05-08 16:25:49 +00:00
void TStampa_bilanci : : scrivis_file_temp ( int g , int c , long s , const real & saldo )
1995-07-21 10:12:15 +00:00
{
TIsamtempfile * tmp = NULL ;
TString16 nome_campo ;
if ( _indbil = = 1 )
{
tmp = _tmp_saldi_att ;
nome_campo = SLD_PDARE ;
}
else
if ( _indbil = = 2 )
{
tmp = _tmp_saldi_pass ;
nome_campo = SLD_PAVERE ;
}
else
if ( _indbil = = 3 )
{
tmp = _tmp_saldi_costi ;
nome_campo = SLD_PDARE ;
}
else
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 ;
}
1997-10-16 08:47:25 +00:00
CHECKD ( tmp , " Null tmp file: indbil = " , _indbil ) ;
1995-07-21 10:12:15 +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 ( ) ;
}
1997-10-16 08:47:25 +00:00
real TStampa_bilanci : : compensazione ( bool compensa , int indbil_conto , real & sld )
1995-07-21 10:12:15 +00:00
{
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 ;
}
1997-10-16 08:47:25 +00:00
void TStampa_bilanci : : next_c ( )
1995-07-21 10:12:15 +00:00
{
TRecnotype recnum = _pcn - > recno ( ) ;
_pcn - > next ( ) ;
if ( _pcn - > eof ( ) )
{
scrivic_file_temp ( ) ;
scrivig_file_temp ( ) ;
}
_pcn - > readat ( recnum ) ;
}
1997-10-16 08:47:25 +00:00
bool TStampa_bilanci : : bil_sez_contr ( )
1995-07-21 10:12:15 +00:00
{
2002-05-08 16:25:49 +00:00
TSaldo_cdc sld ;
1995-07-21 10:12:15 +00:00
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 ;
bool movimentato = FALSE ;
CHECK ( _tmp_saldi_att = = NULL , " Non posso riaprire cg01 " ) ;
1997-11-12 10:46:27 +00:00
_tmp_saldi_att = new TIsamtempfile ( LF_SALDI , " cg01 " , TRUE , TRUE ) ;
1995-07-21 10:12:15 +00:00
_prog - > addstatus ( 1 ) ;
1997-11-12 10:46:27 +00:00
_tmp_saldi_pass = new TIsamtempfile ( LF_SALDI , " cg02 " , TRUE , TRUE ) ;
1995-07-21 10:12:15 +00:00
_prog - > addstatus ( 1 ) ;
1997-11-12 10:46:27 +00:00
_tmp_saldi_costi = new TIsamtempfile ( LF_SALDI , " cg03 " , TRUE , TRUE ) ;
1995-07-21 10:12:15 +00:00
_prog - > addstatus ( 1 ) ;
1997-11-12 10:46:27 +00:00
_tmp_saldi_ricavi = new TIsamtempfile ( LF_SALDI , " cg04 " , TRUE , TRUE ) ;
1995-07-21 10:12:15 +00:00
_prog - > addstatus ( 1 ) ;
1997-11-12 10:46:27 +00:00
_tmp_saldi_conti_uno = new TIsamtempfile ( LF_SALDI , " cg05 " , TRUE , TRUE ) ;
1995-07-21 10:12:15 +00:00
_prog - > addstatus ( 1 ) ;
1997-11-12 10:46:27 +00:00
_tmp_saldi_conti_due = new TIsamtempfile ( LF_SALDI , " cg06 " , TRUE , TRUE ) ;
1995-07-21 10:12:15 +00:00
_prog - > addstatus ( 1 ) ;
_gp = - 1 ;
_cp = - 1 ;
_gruppo_a = ZERO ;
_gruppo_da = ZERO ;
_gruppo_da_ordine = ZERO ;
_gruppo_a_ordine = ZERO ;
_prg_saldoini_dare = ZERO ;
_prg_saldoini_avere = ZERO ;
_prg_inidare_ord = ZERO ;
_prg_iniavere_ord = ZERO ;
_conto_a = ZERO ;
_conto_da = ZERO ;
_add_dare = FALSE ;
_add_avere = FALSE ;
1996-06-07 15:07:55 +00:00
1995-07-21 10:12:15 +00:00
sld . set_annoes ( _annoes ) ;
for ( _pcn - > first ( ) ; ! _pcn - > eof ( ) ; _pcn - > next ( ) )
{
_prog - > addstatus ( 1 ) ;
g = _pcn - > get_int ( PCN_GRUPPO ) ;
c = _pcn - > get_int ( PCN_CONTO ) ;
s = _pcn - > get_long ( PCN_SOTTOCONTO ) ;
if ( c ! = _cp )
cambiato = TRUE ;
if ( ( ( ( _cp ! = - 1 ) & & ( c ! = _cp ) ) | | ( ( _gp ! = - 1 ) & & ( g ! = _gp ) ) ) & &
esiste_sc )
{
scrivic_file_temp ( ) ;
scrivig_file_temp ( ) ;
_cp = c ;
esiste_conto = TRUE ;
_conto_da = ZERO ;
_conto_a = ZERO ;
}
if ( ( ( _gp ! = - 1 ) & & ( g ! = _gp ) ) & & esiste_conto )
{
scrivig_file_temp ( ) ;
esiste_conto = FALSE ;
_gp = g ;
_gruppo_da = ZERO ;
_gruppo_a = ZERO ;
_gruppo_da_ordine = ZERO ;
_gruppo_a_ordine = ZERO ;
}
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 ) ;
dettaglio = ! _pcn - > get_bool ( PCN_STSOTTBIL ) ;
2002-12-20 16:15:03 +00:00
tipo_conto = _pcn - > get_char ( PCN_TMCF ) ;
indbil_conto = _pcn - > get_int ( PCN_INDBIL ) ;
1997-10-16 08:47:25 +00:00
if ( indbil_conto < = 0 ) // Warning per Roberto!
{
2003-02-25 15:20:00 +00:00
yesnofatal_box ( FR ( " Indicatore di bilancio %d nel conto %03d %03d " ) , indbil_conto ,
1997-10-16 08:47:25 +00:00
_pcn - > get_int ( PCN_GRUPPO ) , _pcn - > get_int ( PCN_CONTO ) ) ;
indbil_conto = 1 ;
}
1995-07-21 10:12:15 +00:00
if ( ( tipo_conto = = ' C ' ) | | ( tipo_conto = = ' F ' ) )
{
saldo = ZERO ;
2002-12-20 16:15:03 +00:00
esiste_sc = ricerca_sottoc_clifo ( g , c , compensa , indbil_conto , saldo ) ;
1995-07-21 10:12:15 +00:00
if ( esiste_sc )
{
_gp = g ;
_cp = c ;
}
TRecnotype recnum = _pcn - > recno ( ) ;
_pcn - > next ( ) ;
if ( _pcn - > eof ( ) )
{
if ( esiste_sc )
{
scrivic_file_temp ( ) ;
scrivig_file_temp ( ) ;
}
else if ( esiste_conto )
scrivig_file_temp ( ) ;
}
_pcn - > readat ( recnum ) ;
continue ;
}
}
if ( ( c = = 0 ) | | ( s = = 0 ) ) //si tratta di un conto o di un gruppo
{
esiste_sc = FALSE ;
continue ;
}
if ( _tipo_stampa = = 1 ) //bil. a sez. contrapposte per data limite
2002-05-08 16:25:49 +00:00
{
if ( _cdc . not_empty ( ) )
2002-07-02 16:21:23 +00:00
movimentato = sld . data_limite_commessa ( _bilancio , g , c , s , _cdc , _fsc , _dataini , _datalim , indbil_conto , _stampa_mov_prov ) ;
2002-05-08 16:25:49 +00:00
else
movimentato = sld . data_limite_bilancio ( _bilancio , g , c , s , _dataini , _datalim , indbil_conto , _stampa_mov_prov ) ;
}
1995-07-21 10:12:15 +00:00
else
2002-07-02 16:21:23 +00:00
{
1995-07-21 10:12:15 +00:00
if ( _tipo_stampa = = 2 ) //bil. a sez. contrapposte all'ultima immissione es. in corso
movimentato = sld . ultima_immissione_bilancio ( _annoes , g , c , s , indbil_conto , _stampa_mov_prov ) ;
2002-07-02 16:21:23 +00:00
}
1995-07-21 10:12:15 +00:00
if ( ! movimentato )
if ( ! sld . esiste_saldo ( ) | | ! sld . significativo ( ) )
{
next_c ( ) ;
continue ;
}
saldo = sld . saldo ( ) ;
real app = sld . saldoini ( ) ;
bool flag = sld . flagprec ( ) ;
if ( _saldo ) //se richiesto di NON stampare i conti con saldo a zero
if ( saldo = = ZERO )
{
//modifica del 06/07/1995
if ( indbil_conto = = 1 | | indbil_conto = = 2 | | indbil_conto = = 5 )
{
//real app = sld.saldoini();
//bool flag = sld.flagprec();
if ( flag )
{
if ( app > ZERO )
{
if ( indbil_conto = = 5 )
_prg_inidare_ord + = app ;
else _prg_saldoini_dare + = app ;
}
else if ( app < ZERO )
{
app = - app ;
if ( indbil_conto = = 5 )
_prg_iniavere_ord + = app ;
else _prg_saldoini_avere + = app ;
}
}
}
//fine
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 ;
if ( saldo ! = ZERO )
saldo = compensazione ( compensa , indbil_conto , saldo ) ;
if ( _indbil = = 1 | | _indbil = = 2 )
{
if ( flag )
{
if ( app > ZERO )
_prg_saldoini_dare + = app ;
else if ( app < ZERO )
{
app = - app ;
_prg_saldoini_avere + = app ;
}
}
}
if ( _indbil = = 5 )
{
//real app = sld.saldoini();
if ( flag )
{
if ( app > ZERO )
_prg_inidare_ord + = app ;
else if ( app < ZERO )
{
app = - app ;
_prg_iniavere_ord + = app ;
}
}
}
if ( _indbil = = 1 | | _indbil = = 3 )
{
_gruppo_da + = saldo ;
_conto_da + = saldo ;
_add_file_dare = TRUE ;
}
if ( _indbil = = 2 | | _indbil = = 4 )
{
_gruppo_a + = saldo ;
_conto_a + = saldo ;
_add_file_avere = TRUE ;
}
if ( _indbil = = 5 )
{
if ( saldo > = ZERO | | compensa )
{
_gruppo_da_ordine + = saldo ;
_conto_da + = saldo ;
_add_file_dare = TRUE ;
_sottoc_dare = TRUE ;
}
else
{
saldo = - saldo ;
_gruppo_a_ordine + = saldo ;
_conto_a + = saldo ;
_add_file_avere = TRUE ;
_sottoc_avere = TRUE ;
}
scrivig_file_temp ( ) ;
}
if ( ( dettaglio ) & & ( ( tipo_conto ! = ' C ' ) & & ( tipo_conto ! = ' F ' ) ) )
scrivis_file_temp ( g , c , s , saldo ) ;
_gp = g ;
_cp = c ;
// } // da_considerare
TRecnotype recnum = _pcn - > recno ( ) ;
_pcn - > next ( ) ;
if ( _pcn - > eof ( ) )
{
scrivic_file_temp ( ) ;
scrivig_file_temp ( ) ;
}
_pcn - > readat ( recnum ) ;
}
return TRUE ;
}
1997-10-16 08:47:25 +00:00
bool TStampa_bilanci : : ricerca_sottoc_clifo ( int g , int c , bool compensa , int indbil_conto , real & saldo )
1995-07-21 10:12:15 +00:00
{
2002-05-08 16:25:49 +00:00
TSaldo_cdc sld ;
1995-07-21 10:12:15 +00:00
int aep = 0 ;
long s , items ;
bool esiste_sc = FALSE ;
bool movimentato = FALSE ;
1997-06-19 14:33:52 +00:00
if ( _annoes )
{
TEsercizi_contabili ese ;
aep = ese . pred ( _annoes ) ;
}
1995-07-21 10:12:15 +00:00
sld . set_annoes ( _annoes ) ;
_listacf = new TSaldi_list ( g , c , _annoes , aep ) ;
items = _listacf - > items ( ) ;
for ( int i = 0 ; i < items ; i + + )
{
const TRectype * r = _listacf - > saldi ( ) ;
if ( r = = NULL ) break ;
s = r - > get_long ( SLD_SOTTOCONTO ) ;
if ( _tipo_stampa = = 1 ) //bil. a sez. contrapposte per data limite
2002-05-08 16:25:49 +00:00
{
if ( _cdc . not_empty ( ) )
2002-07-02 16:21:23 +00:00
movimentato = sld . data_limite_commessa ( _bilancio , g , c , s , _cdc , _fsc , _dataini , _datalim , indbil_conto , _stampa_mov_prov ) ;
2002-05-08 16:25:49 +00:00
else
movimentato = sld . data_limite_bilancio ( _bilancio , g , c , s , _dataini , _datalim , indbil_conto , _stampa_mov_prov ) ;
}
1995-07-21 10:12:15 +00:00
else if ( _tipo_stampa = = 2 ) //bil. a sez. contrapposte all'ultima immissione es. in corso
movimentato = sld . ultima_immissione_bilancio ( _annoes , g , c , s , indbil_conto , _stampa_mov_prov ) ;
if ( ! movimentato )
if ( ! sld . esiste_saldo ( ) | | ! sld . significativo ( ) )
continue ;
saldo = sld . saldo ( ) ;
real app = sld . saldoini ( ) ;
bool flag = sld . flagprec ( ) ;
if ( _saldo ) //se richiesto di non stampare i conti con saldo a zero
if ( saldo = = ZERO )
{
//modifica del 06/07/1995
if ( indbil_conto = = 1 | | indbil_conto = = 2 | | indbil_conto = = 5 )
{
//real app = sld.saldoini();
if ( flag )
{
if ( app > ZERO )
{
if ( indbil_conto = = 5 )
_prg_inidare_ord + = app ;
else _prg_saldoini_dare + = app ;
}
else if ( app < ZERO )
{
app = - app ;
if ( indbil_conto = = 5 )
_prg_iniavere_ord + = app ;
else _prg_saldoini_avere + = app ;
}
}
}
//fine
continue ;
}
esiste_sc = TRUE ;
_indbil = indbil_conto ;
//i due flag seguenti servono solo per i conti d'ordine
_sottoc_dare = FALSE ;
_sottoc_avere = FALSE ;
if ( saldo ! = ZERO )
saldo = compensazione ( compensa , indbil_conto , saldo ) ;
if ( _indbil = = 1 | | _indbil = = 2 )
{
if ( flag )
{
if ( app > ZERO )
_prg_saldoini_dare + = app ;
else if ( app < ZERO )
{
app = - app ;
_prg_saldoini_avere + = app ;
}
}
}
if ( _indbil = = 5 )
{
//real app = sld.saldoini();
if ( flag )
{
if ( app > ZERO )
_prg_inidare_ord + = app ;
else if ( app < ZERO )
{
app = - app ;
_prg_iniavere_ord + = app ;
}
}
}
if ( ( _indbil = = 1 ) | | ( _indbil = = 3 ) )
{
_gruppo_da + = saldo ;
_conto_da + = saldo ;
_add_file_dare = TRUE ;
}
if ( ( _indbil = = 2 ) | | ( _indbil = = 4 ) )
{
_gruppo_a + = saldo ;
_conto_a + = saldo ;
_add_file_avere = TRUE ;
}
if ( _indbil = = 5 )
{
if ( ( saldo > = ZERO ) | | ( compensa ) ) // il sottoconto ha saldo in dare
{
_gruppo_da_ordine + = saldo ;
_conto_da + = saldo ;
_add_file_dare = TRUE ;
_sottoc_dare = TRUE ;
}
else //il sottoconto ha saldo in avere
{
saldo = - saldo ;
_gruppo_a_ordine + = saldo ;
_conto_a + = saldo ;
_add_file_avere = TRUE ;
_sottoc_avere = TRUE ;
}
scrivig_file_temp ( ) ;
}
}
delete _listacf ;
return esiste_sc ;
}
1997-10-16 08:47:25 +00:00
bool TStampa_bilanci : : bil_verifica ( )
1995-07-21 10:12:15 +00:00
{
TSaldo 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 ;
bool esiste_conto = FALSE , esiste_sc = FALSE , movimentato = FALSE ;
CHECK ( _tmp_saldi_att = = NULL , " Non posso riaprire cg01 " ) ;
1997-11-12 10:46:27 +00:00
_tmp_saldi_att = new TIsamtempfile ( LF_SALDI , " cg01 " , TRUE , TRUE ) ;
1995-07-21 10:12:15 +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 ;
_nuovo_tot_saldo_d = ZERO ;
_nuovo_tot_saldo_a = 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 ;
prg_gruppo_avere = ZERO ;
_u_max = 0l ;
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 ) ;
2002-07-02 16:21:23 +00:00
if ( ( ( ( _cp ! = - 1 ) & & ( c ! = _cp ) ) | | ( ( _gp ! = - 1 ) & & ( g ! = _gp ) ) ) & & esiste_sc )
1995-07-21 10:12:15 +00:00
{
if ( _verifica = = 2 )
if ( ! ( ( _stampav = = 2 ) & & ( saldo_conto = = 0 ) ) )
{
1995-11-30 09:39:32 +00:00
//modifica del 21/11/1995
if ( _tipo_stampa1 = = 1 & & _datada = = _dataini )
{
_saldo_ini_gruppo_dare + = _saldo_ini_conto_dare ;
_saldo_ini_gruppo_avere + = _saldo_ini_conto_avere ;
}
1995-07-21 10:12:15 +00:00
else
1995-11-30 09:39:32 +00:00
//fine
{
2002-07-02 16:21:23 +00:00
const real app = _saldo_ini_conto_dare + _saldo_ini_conto_avere ;
if ( app < ZERO )
1995-11-30 09:39:32 +00:00
_saldo_ini_gruppo_avere + = app ;
2002-07-02 16:21:23 +00:00
else
1995-11-30 09:39:32 +00:00
_saldo_ini_gruppo_dare + = app ;
}
1995-07-21 10:12:15 +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 ;
}
//scrivo il record del conto;
if ( ( _verifica = = 1 ) | | ( ( _verifica = = 2 ) & &
2002-05-08 16:25:49 +00:00
( ! ( ( _stampav = = 2 ) & & ( saldo_conto = = 0 ) ) ) ) )
1995-07-21 10:12:15 +00:00
{
scrivi_record_conto ( prg_conto_dare , prg_conto_avere , mov_conto_dare ,
mov_conto_avere , saldo_conto ) ;
esiste_conto = TRUE ;
}
_cp = c ;
_saldo_ini_conto_dare = 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 )
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 ;
}
if ( _verifica = = 2 )
if ( ( ( _gp ! = - 1 ) & & ( g ! = _gp ) ) & & esiste_conto )
{
//scrivo il record del gruppo
scrivi_record_gruppo ( prg_gruppo_dare , prg_gruppo_avere , mov_gruppo_dare ,
mov_gruppo_avere , saldo_gruppo ) ;
_gp = g ;
esiste_conto = FALSE ;
_saldo_ini_gruppo_dare = 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 ;
}
if ( ( s = = 0 ) & & ( c ! = 0 ) ) //si tratta di un conto
{
2002-12-20 16:15:03 +00:00
tipo_conto = _pcn - > get_char ( PCN_TMCF ) ;
1995-07-21 10:12:15 +00:00
indbil_conto = _pcn - > get_int ( PCN_INDBIL ) ;
if ( ( tipo_conto = = ' C ' ) | | ( tipo_conto = = ' F ' ) )
{
esiste_sc = ricerca_cf ( g , c , tipo_conto , indbil_conto , saldo_finale , saldo_iniziale ,
mov_conto_dare , mov_conto_avere , prg_conto_dare , prg_conto_avere ,
saldo_conto ) ;
2002-07-02 16:21:23 +00:00
if ( _verifica = = 2 & & _stampav = = 2 & & saldo_conto . is_zero ( ) )
continue ;
1995-07-21 10:12:15 +00:00
if ( esiste_sc )
{
_gp = g ;
_cp = c ;
2002-07-02 16:21:23 +00:00
const TRecnotype recnum = _pcn - > recno ( ) ;
1995-07-21 10:12:15 +00:00
_pcn - > next ( ) ;
if ( _pcn - > eof ( ) )
{
if ( _verifica = = 2 )
{
1995-11-30 09:39:32 +00:00
//modifica del 21/11/1995
if ( _tipo_stampa1 = = 1 & & _datada = = _dataini )
{
_saldo_ini_gruppo_dare + = _saldo_ini_conto_dare ;
_saldo_ini_gruppo_avere + = _saldo_ini_conto_avere ;
}
1995-07-21 10:12:15 +00:00
else
1995-11-30 09:39:32 +00:00
//fine
{
real app = _saldo_ini_conto_dare + _saldo_ini_conto_avere ;
if ( app < ZERO )
_saldo_ini_gruppo_avere + = app ;
else
_saldo_ini_gruppo_dare + = app ;
}
1995-07-21 10:12:15 +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 ) ;
}
scrivi_record_conto ( prg_conto_dare , prg_conto_avere , mov_conto_dare ,
mov_conto_avere , saldo_conto ) ;
}
_pcn - > readat ( recnum ) ;
}
continue ;
}
}
if ( ( c = = 0 ) | | ( s = = 0 ) )
{
esiste_sc = FALSE ;
continue ;
}
1995-11-30 09:39:32 +00:00
saldo_finale = saldo_iniziale = ZERO ; //saldi relativi a ciascun sottoconto
1995-07-21 10:12:15 +00:00
_indbil = indbil_conto ;
if ( _tipo_stampa1 = = 1 ) //bil. di verifica per data limite
{
1995-11-30 09:39:32 +00:00
//modifica del 21/11/95
_mov_ap = FALSE ;
1995-07-21 10:12:15 +00:00
//modifica del 19/06/95
movimentato = calcola ( g , c , s ) ;
2002-07-02 16:21:23 +00:00
if ( _stampa_mov_prov ! = 3 & & _cdc . empty ( ) )
1995-07-21 10:12:15 +00:00
{
if ( movimentato )
{
1995-11-30 09:39:32 +00:00
//modifica del 21/11/95
if ( _mov_ap )
saldo_iniziale = _saldo_ini_dare - _saldo_ini_avere ;
else //discorso flag "movimentato" (video)
1995-07-21 10:12:15 +00:00
{
1996-06-07 15:07:55 +00:00
TLocalisamfile saldi ( LF_SALDI ) ; // W96SALDI
saldi . zero ( ) ; // Modifica SALDI per movimenti
saldi . put ( SLD_ANNOES , _annoes ) ; // scaricati del 05-06-96
saldi . put ( SLD_FLSCA , FALSE ) ; // Ho aggiunto saldi.put(SLD_FLSCA, FALSE);
saldi . put ( SLD_GRUPPO , g ) ; // In questo modo considero il record con
saldi . put ( SLD_CONTO , c ) ; // la somma fra progressivi normali e scaricati
saldi . put ( SLD_SOTTOCONTO , s ) ;
1995-11-30 09:39:32 +00:00
if ( saldi . read ( ) = = NOERR )
{
2002-07-02 16:21:23 +00:00
const real ss = saldi . get_real ( SLD_SALDO ) ;
if ( ss . is_zero ( ) )
{
if ( _annoes ! = 0 & & ( indbil_conto = = 1 | | indbil_conto = = 2 | | indbil_conto = = 5 ) )
{
saldo_iniziale = sld . saldofin_esprec ( _annoes , g , c , s ) ;
//modifica del 21/11/95
if ( saldo_iniziale > ZERO )
_saldo_ini_dare = saldo_iniziale ;
else
_saldo_ini_avere = - saldo_iniziale ;
//fine
}
}
else
{
const char fsi = saldi . get_char ( SLD_FLAGSALINI ) ;
if ( fsi = = ' D ' )
{
saldo_iniziale = ss ;
_saldo_ini_dare = ss ;
}
else
{
saldo_iniziale = - ss ;
_saldo_ini_avere = ss ;
}
}
1995-11-30 09:39:32 +00:00
}
2002-07-02 16:21:23 +00:00
}
1995-07-21 10:12:15 +00:00
}
2000-10-03 13:45:12 +00:00
else // !movimentato -> _mov_ap e' di sicuro FALSE
{
if ( _annoes ! = 0 & & ( indbil_conto = = 1 | | indbil_conto = = 2 | | indbil_conto = = 5 ) )
{
saldo_iniziale = sld . saldofin_esprec ( _annoes , g , c , s ) ;
//modifica del 21/11/95
if ( saldo_iniziale > ZERO )
_saldo_ini_dare = saldo_iniziale ;
else _saldo_ini_avere = - saldo_iniziale ;
//fine
if ( _stampav = = 1 & & sld . significativo ( ) )
movimentato = TRUE ;
}
}
1995-07-21 10:12:15 +00:00
}
2003-02-25 15:20:00 +00:00
1995-07-21 10:12:15 +00:00
if ( movimentato | | _stampav ! = 1 )
{
_nuovo_tot_saldo_d + = _mov_periodo_dare ;
_nuovo_tot_saldo_a + = _mov_periodo_avere ;
1995-11-30 09:39:32 +00:00
_nuovo_tot_saldo_d + = _saldo_ini_dare ;
_nuovo_tot_saldo_a + = _saldo_ini_avere ;
1995-07-21 10:12:15 +00:00
if ( _datada = = _dataini )
saldo_finale = saldo_iniziale + _mov_periodo_dare - _mov_periodo_avere ;
else if ( _datada > _dataini )
{
if ( saldo_iniziale > 0 )
_prg_prec_dare + = saldo_iniziale ;
else _prg_prec_avere - = saldo_iniziale ;
saldo_finale = _prg_prec_dare - _prg_prec_avere + _mov_periodo_dare -
_mov_periodo_avere ;
}
//if (saldo_finale == ZERO)
// if (_stampav == 2)
// continue;
}
//se saldo_finale < 0 verra' stampato con una A, se no con una D
2002-07-02 16:21:23 +00:00
}
else
{
movimentato = sld . ultima_immissione_verifica ( _annoes , g , c , s , indbil_conto , _stampa_mov_prov ) ;
if ( _stampa_mov_prov ! = 3 )
1995-07-21 10:12:15 +00:00
{
2002-07-02 16:21:23 +00:00
if ( movimentato )
saldo_iniziale = sld . saldoini ( ) ;
if ( ! movimentato )
1995-07-21 10:12:15 +00:00
{
2002-07-02 16:21:23 +00:00
if ( indbil_conto = = 1 | | indbil_conto = = 2 | | indbil_conto = = 5 )
{
saldo_iniziale = sld . saldofin_esprec ( _annoes , g , c , s , FALSE ) ;
if ( _stampav = = 1 & & sld . significativo ( ) )
movimentato = TRUE ;
}
}
}
1995-07-21 10:12:15 +00:00
2002-07-02 16:21:23 +00:00
if ( movimentato | | _stampav ! = 1 )
{
_mov_periodo_dare = sld . prgdare ( ) ;
_mov_periodo_avere = sld . prgavere ( ) ;
_prg_prec_dare = ZERO ;
_prg_prec_avere = ZERO ;
if ( sld . sezsf ( ) = = ' A ' )
_mov_periodo_avere - = sld . saldofin ( ) ;
else
_mov_periodo_dare + = sld . saldofin ( ) ;
1995-07-21 10:12:15 +00:00
2002-07-02 16:21:23 +00:00
saldo_finale = saldo_iniziale + _mov_periodo_dare - _mov_periodo_avere ;
}
}
if ( ( movimentato | | _stampav ! = 1 ) & & ! ( saldo_finale . is_zero ( ) & & _stampav = = 2 ) )
1995-07-21 10:12:15 +00:00
{
2002-07-02 16:21:23 +00:00
esiste_sc = TRUE ;
esiste_conto = TRUE ;
if ( _tipo_stampa1 = = 2 )
1995-07-21 10:12:15 +00:00
{
2002-07-02 16:21:23 +00:00
_nuovo_tot_saldo_d + = _mov_periodo_dare ;
_nuovo_tot_saldo_a + = _mov_periodo_avere ;
real nuovo = sld . saldoinisusaldi ( ) ;
if ( nuovo > ZERO )
_nuovo_tot_saldo_d + = nuovo ;
else
{
nuovo = - nuovo ;
_nuovo_tot_saldo_a + = nuovo ;
}
1995-11-30 09:39:32 +00:00
}
2002-07-02 16:21:23 +00:00
//modifica del 21/11/1995
if ( _tipo_stampa1 = = 1 & & _datada = = _dataini )
{
_saldo_ini_conto_dare + = _saldo_ini_dare ;
_saldo_ini_conto_avere + = _saldo_ini_avere ;
}
else //_tipo_stampa1 == 1 || _tipo_stampa1 == 2
{
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 pitagorica
1995-11-30 09:39:32 +00:00
2002-07-02 16:21:23 +00:00
//scrivo il record relat. al sottoconto se non e' richiesto saldi di mastro
if ( _verifica ! = 2 )
1995-07-21 10:12:15 +00:00
{
2002-07-02 16:21:23 +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 ) )
{
//modifica del 21/11/1995
if ( _datada = = _dataini & & _tipo_stampa1 = = 1 )
{
_tmp_saldi_att - > put ( SLD_PDAREPRO , _saldo_ini_dare ) ; // W96SALDI del 05-06-96
_tmp_saldi_att - > put ( SLD_PAVEREPRO , _saldo_ini_avere ) ;
}
else
{
if ( saldo_iniziale > ZERO ) //va stampato in Dare
_tmp_saldi_att - > put ( SLD_PDAREPRO , saldo_iniziale ) ; // W96SALDI del 05-06-96
else if ( saldo_iniziale < ZERO )
{
saldo_iniziale = - saldo_iniziale ;
_tmp_saldi_att - > put ( SLD_PAVEREPRO , saldo_iniziale ) ; // W96SALDI del 05-06-96
}
}
}
else if ( _datada > _dataini )
1995-07-21 10:12:15 +00:00
{
2002-07-02 16:21:23 +00:00
_tmp_saldi_att - > put ( SLD_PDAREPRO , _prg_prec_dare ) ; // W96SALDI del 05-06-96
_tmp_saldi_att - > put ( SLD_PAVEREPRO , _prg_prec_avere ) ;
1995-07-21 10:12:15 +00:00
}
2002-07-02 16:21:23 +00:00
_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 ( ) ;
1995-07-21 10:12:15 +00:00
}
2002-07-02 16:21:23 +00:00
_gp = g ;
_cp = c ;
1995-07-21 10:12:15 +00:00
}
2002-07-02 16:21:23 +00:00
TRecnotype recnum = _pcn - > recno ( ) ;
_pcn - > next ( ) ;
if ( _pcn - > eof ( ) )
1995-07-21 10:12:15 +00:00
{
2002-07-02 16:21:23 +00:00
if ( ( _verifica = = 2 ) & & esiste_conto )
1995-11-30 09:39:32 +00:00
{
2002-07-02 16:21:23 +00:00
//modifica del 21/11/1995
if ( _tipo_stampa1 = = 1 & & _datada = = _dataini )
{
_saldo_ini_gruppo_dare + = _saldo_ini_conto_dare ;
_saldo_ini_gruppo_avere + = _saldo_ini_conto_avere ;
}
else
//fine
{
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 ) ;
1995-11-30 09:39:32 +00:00
}
2002-07-02 16:21:23 +00:00
if ( esiste_sc )
if ( ( _verifica = = 1 ) | | ( ( _verifica = = 2 ) & &
( ! ( ( _stampav = = 2 ) & & ( saldo_conto = = 0 ) ) ) ) )
scrivi_record_conto ( prg_conto_dare , prg_conto_avere , mov_conto_dare ,
mov_conto_avere , saldo_conto ) ;
1995-07-21 10:12:15 +00:00
}
2002-07-02 16:21:23 +00:00
_pcn - > readat ( recnum ) ;
}
1995-07-21 10:12:15 +00:00
return TRUE ;
}
2002-07-02 16:21:23 +00:00
// bilancio di verifica per data limite
// Calcola totali delle righe relative al g,c,s
1997-10-16 08:47:25 +00:00
bool TStampa_bilanci : : calcola ( int g , int c , long s )
1995-07-21 10:12:15 +00:00
{
int annoe ;
long num_reg ;
2002-05-08 16:25:49 +00:00
TDate data_reg , data ;
1995-07-21 10:12:15 +00:00
bool conto_mov = FALSE ;
1996-12-12 16:17:35 +00:00
TDecoder causali ( LF_CAUSALI , CAU_MOVAP ) ;
2002-05-08 16:25:49 +00:00
TRelation rel ( LF_RMOV ) ;
rel . add ( LF_MOV , " NUMREG==NUMREG " ) ;
TRectype & rmov = rel . curr ( ) ;
const TRectype & mov = rel . curr ( LF_MOV ) ;
1996-11-29 14:58:01 +00:00
1995-07-21 10:12:15 +00:00
_mov_periodo_dare = ZERO ;
_mov_periodo_avere = ZERO ;
_prg_prec_dare = ZERO ;
_prg_prec_avere = ZERO ;
_saldo_ini_dare = ZERO ;
_saldo_ini_avere = ZERO ;
_u_max = 0l ;
2002-05-08 16:25:49 +00:00
TDate data_start = _dataini ;
1999-10-22 10:00:18 +00:00
// Calcolo progressivi precedenti:
// e non <20> indicato l'anno esercizio, prende il primo giorno dell'anno indicato da _datada
if ( _annoes = = 0 )
{
data_start = _datada ;
data_start . set_day ( 1 ) ;
data_start . set_month ( 1 ) ;
}
1995-07-21 10:12:15 +00:00
rmov . zero ( ) ;
rmov . put ( RMV_GRUPPO , g ) ;
if ( c ! = 0 )
2002-07-02 16:21:23 +00:00
{
1995-07-21 10:12:15 +00:00
rmov . put ( RMV_CONTO , c ) ;
2002-07-02 16:21:23 +00:00
if ( s ! = 0 )
rmov . put ( RMV_SOTTOCONTO , s ) ;
}
2002-05-08 16:25:49 +00:00
TString filter ;
if ( _cdc . not_empty ( ) )
2002-07-02 16:21:23 +00:00
{
2002-05-08 16:25:49 +00:00
filter < < ' ( ' < < RMV_CODCMS < < " ==' " < < _cdc < < " ') " ;
2002-07-02 16:21:23 +00:00
if ( _fsc . not_empty ( ) )
filter < < " &&( " < < RMV_FASCMS < < " ==' " < < _fsc < < " ') " ;
}
2002-05-08 16:25:49 +00:00
TCursor cur ( & rel , filter , 2 , & rmov , & rmov ) ;
const long items = cur . items ( ) ;
cur . freeze ( ) ;
for ( cur = 0L ; cur . pos ( ) < items ; + + cur )
1995-07-21 10:12:15 +00:00
{
annoe = rmov . get_int ( RMV_ANNOES ) ;
data = rmov . get_date ( RMV_DATAREG ) ;
num_reg = rmov . get_long ( RMV_NUMREG ) ;
1996-11-29 14:58:01 +00:00
2002-05-08 16:25:49 +00:00
const char provvis = mov . get_char ( MOV_PROVVIS ) ;
const TDate datacomp = mov . get_date ( MOV_DATACOMP ) ;
1995-07-21 10:12:15 +00:00
if ( _stampa_mov_prov = = 1 & & provvis ! = ' \0 ' ) //bilancio normale (non comprende i provvisori)
continue ;
if ( _stampa_mov_prov = = 3 & & provvis = = ' \0 ' ) //bilancio dei soli provvisori
continue ;
1996-11-29 14:58:01 +00:00
const TString & codcaus = mov . get ( MOV_CODCAUS ) ;
const char causap = causali . decode ( codcaus ) [ 0 ] ;
1995-07-21 10:12:15 +00:00
2001-05-01 08:17:07 +00:00
if ( ! _quadratura & & causap = = ' C ' )
1996-11-29 14:58:01 +00:00
{
// Si tratta di causale di chiusura:
// Non e' richiesta la quadratura con il Libro Giornale (Modifica
// del 18-06-96 richiesta da Patrizia in seguito alla modifica dei SALDI)
continue ;
}
1995-07-21 10:12:15 +00:00
2002-05-08 16:25:49 +00:00
const char sezione = rmov . get_char ( RMV_SEZIONE ) ;
const real importo = rmov . get_real ( RMV_IMPORTO ) ;
1995-07-21 10:12:15 +00:00
if ( _annoes = = 0 )
data_reg = data ;
1996-11-29 14:58:01 +00:00
else
data_reg = datacomp ;
1995-07-21 10:12:15 +00:00
2002-07-02 16:21:23 +00:00
if ( importo . is_zero ( ) )
1995-07-21 10:12:15 +00:00
continue ;
//calcolo i movimenti del periodo
if ( data_reg > = _datada & & data_reg < = _dataa )
1999-04-26 15:58:05 +00:00
if ( ( causap = = ' A ' & & _dataini . ok ( ) & & _dataini ! = _datada ) | | ( causap ! = ' A ' ) )
1995-07-21 10:12:15 +00:00
{
conto_mov = TRUE ;
if ( sezione = = ' D ' )
_mov_periodo_dare + = importo ;
2000-10-03 13:45:12 +00:00
else
_mov_periodo_avere + = importo ;
1995-07-21 10:12:15 +00:00
_u_max = fnc_max ( _u_max , data ) ;
2000-10-03 13:45:12 +00:00
if ( causap = = ' A ' )
_mov_ap = TRUE ;
1995-07-21 10:12:15 +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
{
1996-11-29 14:58:01 +00:00
if ( causap = = ' A ' )
{
1995-07-21 10:12:15 +00:00
if ( ( data_reg > = _dataini ) & & ( data_reg < = _dataa ) )
{
if ( sezione = = ' D ' )
_saldo_ini_dare + = importo ;
2000-10-03 13:45:12 +00:00
else
_saldo_ini_avere + = importo ;
1995-07-21 10:12:15 +00:00
_u_max = fnc_max ( _u_max , data ) ;
1995-11-30 09:39:32 +00:00
conto_mov = _mov_ap = TRUE ;
1995-07-21 10:12:15 +00:00
}
1996-11-29 14:58:01 +00:00
}
1995-07-21 10:12:15 +00:00
}
else if ( _datada > _dataini ) //calcolo i progressivi precedenti
1999-10-22 10:00:18 +00:00
if ( ( data_reg > = data_start ) & & ( data_reg < _datada ) )
1995-07-21 10:12:15 +00:00
{
if ( sezione = = ' D ' )
_prg_prec_dare + = importo ;
2000-10-03 13:45:12 +00:00
else
_prg_prec_avere + = importo ;
1995-07-21 10:12:15 +00:00
_u_max = fnc_max ( _u_max , data ) ;
conto_mov = TRUE ;
2000-10-13 13:38:43 +00:00
if ( causap = = ' A ' )
_mov_ap = TRUE ;
1995-07-21 10:12:15 +00:00
}
}
2002-05-08 16:25:49 +00:00
return conto_mov ;
1995-07-21 10:12:15 +00:00
}
1997-10-16 08:47:25 +00:00
bool TStampa_bilanci : : ricerca_cf ( int g , int c , char tipocf , int ib , real & saldo_finale , real & saldo_iniziale ,
1995-07-21 10:12:15 +00:00
real & mov_conto_dare , real & mov_conto_avere , real & prg_conto_dare , real & prg_conto_avere , real & saldo_conto )
{
TSaldo sld ;
bool esiste_sc = FALSE ;
2002-05-08 16:25:49 +00:00
const int anno = _tipo_stampa1 = = 1 ? _annoapp : _annoes ;
1995-07-21 10:12:15 +00:00
_lista = new TSaldi_list ( g , c , anno ) ;
2002-05-08 16:25:49 +00:00
const TRecnotype items = _lista - > items ( ) ;
1995-07-21 10:12:15 +00:00
2002-05-08 16:25:49 +00:00
for ( TRecnotype i = 0 ; i < items ; i + + )
1995-07-21 10:12:15 +00:00
{
const TRectype * r = _lista - > saldi ( ) ;
if ( r = = NULL ) break ;
2002-05-08 16:25:49 +00:00
const long s = r - > get_long ( SLD_SOTTOCONTO ) ;
1995-07-21 10:12:15 +00:00
1995-11-30 09:39:32 +00:00
saldo_finale = saldo_iniziale = ZERO ; //saldi relativi a ciascun sottoconto
1995-07-21 10:12:15 +00:00
if ( _tipo_stampa1 = = 1 ) //bil. di verifica per data limite
{
1995-11-30 09:39:32 +00:00
//modifica del 21/11/1995
_mov_ap = FALSE ;
1995-07-21 10:12:15 +00:00
//modifica del 19/06. Vedi appunti per capire
bool movimentato = calcola ( g , c , s ) ;
2002-07-02 16:21:23 +00:00
if ( _stampa_mov_prov ! = 3 & & _cdc . empty ( ) )
1995-07-21 10:12:15 +00:00
{
if ( movimentato )
{
1995-11-30 09:39:32 +00:00
if ( _mov_ap )
2000-10-03 13:45:12 +00:00
{
saldo_iniziale = _saldo_ini_dare - _saldo_ini_avere ;
}
1995-11-30 09:39:32 +00:00
else
{
1995-07-21 10:12:15 +00:00
TLocalisamfile saldi ( LF_SALDI ) ;
saldi . zero ( ) ;
1996-06-07 15:07:55 +00:00
saldi . put ( SLD_ANNOES , _annoes ) ;
saldi . put ( SLD_FLSCA , FALSE ) ; // W96SALDI del 05-06-96
saldi . put ( SLD_GRUPPO , g ) ; // Ho aggiunto in chiave saldi.put(SLD_FLSCA, FALSE);
saldi . put ( SLD_CONTO , c ) ; // in questa maniera reperisco il record dei saldi
saldi . put ( SLD_SOTTOCONTO , s ) ; // contenente la somma degli scaricati e non scaricati
1995-07-21 10:12:15 +00:00
if ( saldi . read ( ) = = NOERR )
{
//se il saldo iniziale e' diverso da zero non lo devo considerare
//perche' l'ho gia' considerato nella funzione calcola
2000-10-03 13:45:12 +00:00
const real ss = saldi . get_real ( SLD_SALDO ) ;
if ( ss . is_zero ( ) )
{
if ( _annoes ! = 0 & & ( ib = = 1 | | ib = = 2 | | ib = = 5 ) )
1995-11-30 09:39:32 +00:00
{
1995-07-21 10:12:15 +00:00
saldo_iniziale + = sld . saldofin_esprec ( _annoes , g , c , s ) ;
1995-11-30 09:39:32 +00:00
//modifica del 21/11/1995
if ( saldo_iniziale > ZERO )
_saldo_ini_dare = saldo_iniziale ;
2000-10-03 13:45:12 +00:00
else
_saldo_ini_avere = - saldo_iniziale ;
1995-11-30 09:39:32 +00:00
//fine
}
2000-10-03 13:45:12 +00:00
}
else
{
const char fsi = saldi . get_char ( SLD_FLAGSALINI ) ;
if ( fsi = = ' D ' )
{
saldo_iniziale = ss ;
_saldo_ini_dare = ss ;
}
else
{
saldo_iniziale = - ss ;
_saldo_ini_avere = ss ;
}
}
1995-11-30 09:39:32 +00:00
}
}
1995-07-21 10:12:15 +00:00
}
2000-10-03 13:45:12 +00:00
else
{
if ( _annoes ! = 0 & & ( ib = = 1 | | ib = = 2 | | ib = = 5 ) )
{
saldo_iniziale = sld . saldofin_esprec ( _annoes , g , c , s ) ;
//modifica del 21/11/1995
if ( saldo_iniziale > ZERO )
_saldo_ini_dare = saldo_iniziale ;
else
_saldo_ini_avere = - saldo_iniziale ;
//fine
movimentato = sld . significativo ( ) ;
}
}
1995-07-21 10:12:15 +00:00
}
if ( ! movimentato )
continue ;
//fine modifica
_nuovo_tot_saldo_d + = _mov_periodo_dare ;
_nuovo_tot_saldo_a + = _mov_periodo_avere ;
1995-11-30 09:39:32 +00:00
//modifica del 21/11/1995
_nuovo_tot_saldo_d + = _saldo_ini_dare ;
_nuovo_tot_saldo_a + = _saldo_ini_avere ;
//fine
1995-07-21 10:12:15 +00:00
if ( _datada = = _dataini )
saldo_finale = saldo_iniziale + _mov_periodo_dare - _mov_periodo_avere ;
else if ( _datada > _dataini )
{
if ( saldo_iniziale > 0 )
_prg_prec_dare + = saldo_iniziale ;
2002-07-02 16:21:23 +00:00
else
_prg_prec_avere - = saldo_iniziale ;
1995-07-21 10:12:15 +00:00
saldo_finale = _prg_prec_dare - _prg_prec_avere + _mov_periodo_dare -
_mov_periodo_avere ;
}
if ( saldo_finale = = ZERO )
if ( _stampav = = 2 )
continue ;
//se saldo_finale < 0 verra' stampato con una A, se no con una D
}
2002-12-20 16:15:03 +00:00
else // Bilancio di verifica all'ultima immissione
2002-07-02 16:21:23 +00:00
{
//Attenzione! Nel caso di "tutti i conti" devono scendere solo i cli/for movimentati!!!
1995-07-21 10:12:15 +00:00
2002-07-02 16:21:23 +00:00
//modifica del 31/03/1995
bool movimentato = sld . ultima_immissione_verifica ( _annoes , g , c , s , ib , _stampa_mov_prov ) ;
1995-07-21 10:12:15 +00:00
2002-07-02 16:21:23 +00:00
if ( _stampa_mov_prov ! = 3 )
{
saldo_iniziale = sld . saldoini ( ) ;
if ( ! movimentato )
1995-07-21 10:12:15 +00:00
{
2002-07-02 16:21:23 +00:00
//vado sui saldi con l'anno precedente e calcolo saldo_finale es.prec
//se esiste tale record e almeno un valore e' significativo (indipendentemente dal valore
//del saldo iniziale calcolato, allora metto a TRUE il flag movimentato
//solo se e' un conto patrimoniale
if ( ib = = 1 | | ib = = 2 | | ib = = 5 )
1995-07-21 10:12:15 +00:00
{
2002-07-02 16:21:23 +00:00
saldo_iniziale = sld . saldofin_esprec ( _annoes , g , c , s , FALSE ) ;
movimentato = sld . significativo ( ) ;
}
}
}
1995-07-21 10:12:15 +00:00
2002-07-02 16:21:23 +00:00
if ( ! movimentato )
continue ;
//fine modifica 31/03/1995
1995-07-21 10:12:15 +00:00
2002-07-02 16:21:23 +00:00
_mov_periodo_dare = sld . prgdare ( ) ;
_mov_periodo_avere = sld . prgavere ( ) ;
_prg_prec_dare = ZERO ;
_prg_prec_avere = ZERO ;
1999-04-26 15:58:05 +00:00
2002-07-02 16:21:23 +00:00
if ( sld . sezsf ( ) = = ' A ' )
_mov_periodo_avere - = sld . saldofin ( ) ;
else
_mov_periodo_dare + = sld . saldofin ( ) ;
1995-07-21 10:12:15 +00:00
2002-07-02 16:21:23 +00:00
saldo_finale = saldo_iniziale + _mov_periodo_dare - _mov_periodo_avere ;
if ( saldo_finale . is_zero ( ) & & _stampav = = 2 )
continue ;
1995-07-21 10:12:15 +00:00
2002-07-02 16:21:23 +00:00
_nuovo_tot_saldo_d + = _mov_periodo_dare ;
_nuovo_tot_saldo_a + = _mov_periodo_avere ;
real nuovo = sld . saldoinisusaldi ( ) ;
if ( nuovo > ZERO )
_nuovo_tot_saldo_d + = nuovo ;
else
{
nuovo = - nuovo ;
_nuovo_tot_saldo_a + = nuovo ;
1995-07-21 10:12:15 +00:00
}
2002-07-02 16:21:23 +00:00
}
1995-07-21 10:12:15 +00:00
esiste_sc = TRUE ;
1995-11-30 09:39:32 +00:00
//modifica del 21/11/1995
if ( _tipo_stampa1 = = 1 & & _datada = = _dataini )
{
_saldo_ini_conto_dare + = _saldo_ini_dare ;
_saldo_ini_conto_avere + = _saldo_ini_avere ;
}
1995-07-21 10:12:15 +00:00
else
1995-11-30 09:39:32 +00:00
//fine
{
if ( saldo_iniziale < ZERO )
_saldo_ini_conto_avere + = saldo_iniziale ;
else
_saldo_ini_conto_dare + = saldo_iniziale ;
}
1995-07-21 10:12:15 +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
2002-12-20 16:15:03 +00:00
if ( _verifica ! = 2 & & ! _hide_clifo )
1995-07-21 10:12:15 +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 , tipocf ) ;
if ( ( _datada = = _dataini ) | | ( _tipo_stampa1 ! = 1 ) )
{
1995-11-30 09:39:32 +00:00
//modifica del 21/11/1995
if ( _tipo_stampa1 = = 1 & & _datada = = _dataini )
{
1996-06-07 15:07:55 +00:00
_tmp_saldi_att - > put ( SLD_PDAREPRO , _saldo_ini_dare ) ; // W96SALDI del 05-06-96
_tmp_saldi_att - > put ( SLD_PAVEREPRO , _saldo_ini_avere ) ;
1995-11-30 09:39:32 +00:00
}
else
1995-07-21 10:12:15 +00:00
{
1996-06-07 15:07:55 +00:00
if ( saldo_iniziale > ZERO ) //va stampato in Dare
_tmp_saldi_att - > put ( SLD_PDAREPRO , saldo_iniziale ) ; // W96SALDI del 05-06-96
1995-11-30 09:39:32 +00:00
else if ( saldo_iniziale < ZERO )
{
1995-07-21 10:12:15 +00:00
saldo_iniziale = - saldo_iniziale ;
1996-06-07 15:07:55 +00:00
_tmp_saldi_att - > put ( SLD_PAVEREPRO , saldo_iniziale ) ; // W96SALDI del 05-06-96
1995-11-30 09:39:32 +00:00
}
1995-07-21 10:12:15 +00:00
}
}
else if ( _datada > _dataini )
{
1996-06-07 15:07:55 +00:00
_tmp_saldi_att - > put ( SLD_PDAREPRO , _prg_prec_dare ) ; // W96SALDI del 05-06-96
_tmp_saldi_att - > put ( SLD_PAVEREPRO , _prg_prec_avere ) ;
1995-07-21 10:12:15 +00:00
}
_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 ) ;
2002-12-20 16:15:03 +00:00
_tmp_saldi_att - > put ( SLD_DATAULMOV , _u_max ) ;
1995-07-21 10:12:15 +00:00
_tmp_saldi_att - > write ( ) ;
}
}
delete _lista ;
return esiste_sc ;
}
1997-10-16 08:47:25 +00:00
void TStampa_bilanci : : scrivi_record_gruppo ( const real & prg_da ,
1995-07-21 10:12:15 +00:00
const real & prg_a , const real & mov_da , const real & mov_a , const real & s )
{
_tmp_saldi_att - > zero ( ) ;
_tmp_saldi_att - > put ( SLD_GRUPPO , _gp ) ;
_tmp_saldi_att - > put ( SLD_CONTO , 0 ) ;
_tmp_saldi_att - > put ( SLD_SOTTOCONTO , 0L ) ;
if ( ( _datada = = _dataini ) | | ( _tipo_stampa1 ! = 1 ) )
{
1995-11-30 09:39:32 +00:00
//modifica del 21/11/1995
if ( _datada = = _dataini & & _tipo_stampa1 = = 1 )
{
1996-06-07 15:07:55 +00:00
_tmp_saldi_att - > put ( SLD_PDAREPRO , _saldo_ini_gruppo_dare ) ; // W96SALDI del 05-06-96
_tmp_saldi_att - > put ( SLD_PAVEREPRO , _saldo_ini_gruppo_avere ) ;
1995-11-30 09:39:32 +00:00
}
else
{
real app = _saldo_ini_gruppo_dare + _saldo_ini_gruppo_avere ;
if ( app > ZERO ) //va stampato in Dare
1996-06-07 15:07:55 +00:00
_tmp_saldi_att - > put ( SLD_PDAREPRO , app ) ; // W96SALDI del 05-06-96
1995-11-30 09:39:32 +00:00
else if ( app < ZERO )
{
1995-07-21 10:12:15 +00:00
app = - app ;
1996-06-07 15:07:55 +00:00
_tmp_saldi_att - > put ( SLD_PAVEREPRO , app ) ; // W96SALDI del 05-06-96
1995-11-30 09:39:32 +00:00
}
}
1995-07-21 10:12:15 +00:00
}
else if ( _datada > _dataini )
{
1996-06-07 15:07:55 +00:00
_tmp_saldi_att - > put ( SLD_PDAREPRO , prg_da ) ; // W96SALDI del 05-06-96
_tmp_saldi_att - > put ( SLD_PAVEREPRO , prg_a ) ;
1995-07-21 10:12:15 +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 ( ) ;
}
2002-07-02 16:21:23 +00:00
void TStampa_bilanci : : scrivi_record_conto ( const real & prg_da , const real & prg_a ,
const real & mov_da , const real & mov_a , const real & s )
1995-07-21 10:12:15 +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 ) )
{
1995-11-30 09:39:32 +00:00
//modifica del 21/11/1995
if ( _datada = = _dataini & & _tipo_stampa1 = = 1 )
{
1996-06-07 15:07:55 +00:00
_tmp_saldi_att - > put ( SLD_PDAREPRO , _saldo_ini_conto_dare ) ; // W96SALDI del 05-06-96
_tmp_saldi_att - > put ( SLD_PAVEREPRO , _saldo_ini_conto_avere ) ;
1995-11-30 09:39:32 +00:00
}
else
{
real app = _saldo_ini_conto_dare + _saldo_ini_conto_avere ;
if ( app > ZERO ) //va stampato in Dare
1996-06-07 15:07:55 +00:00
_tmp_saldi_att - > put ( SLD_PDAREPRO , app ) ; // W96SALDI del 05-06-96
1995-11-30 09:39:32 +00:00
else if ( app < ZERO )
{
1995-07-21 10:12:15 +00:00
app = - app ;
1996-06-07 15:07:55 +00:00
_tmp_saldi_att - > put ( SLD_PAVEREPRO , app ) ; // W96SALDI del 05-06-96
1995-11-30 09:39:32 +00:00
}
}
1995-07-21 10:12:15 +00:00
}
else if ( _datada > _dataini )
{
1996-06-07 15:07:55 +00:00
_tmp_saldi_att - > put ( SLD_PDAREPRO , prg_da ) ; // W96SALDI del 05-06-96
_tmp_saldi_att - > put ( SLD_PAVEREPRO , prg_a ) ;
1995-07-21 10:12:15 +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 ( ) ;
}
1997-10-16 08:47:25 +00:00
void TStampa_bilanci : : init_sort ( )
1995-07-21 10:12:15 +00:00
{
2002-12-20 16:15:03 +00:00
cli_for cf ;
1995-07-21 10:12:15 +00:00
2002-12-20 16:15:03 +00:00
_sort = new TSort ( sizeof ( cli_for ) ) ;
_sort - > addsortkey ( ( char * ) & ( cf . tipocf ) - ( char * ) & ( cf . tipocf ) , 1 ) ;
_sort - > addsortkey ( ( char * ) & ( cf . gruppo ) - ( char * ) & ( cf . tipocf ) , 3 ) ;
_sort - > addsortkey ( ( char * ) & ( cf . conto ) - ( char * ) & ( cf . tipocf ) , 3 ) ;
1995-07-21 10:12:15 +00:00
if ( _ordinamento = = 1 )
2002-12-20 16:15:03 +00:00
_sort - > addsortkey ( ( char * ) & ( cf . codcf ) - ( char * ) & ( cf . tipocf ) , 6 ) ;
1995-07-21 10:12:15 +00:00
else if ( _ordinamento = = 2 )
2002-12-20 16:15:03 +00:00
_sort - > addsortkey ( ( char * ) & ( cf . ragsoc ) - ( char * ) & ( cf . tipocf ) , 50 ) ;
1995-07-21 10:12:15 +00:00
_sort - > init ( ) ;
}
1997-10-16 08:47:25 +00:00
void TStampa_bilanci : : riempi_record ( char t , int g , int c , long s ,
1995-07-21 10:12:15 +00:00
const char * rs , const real & sd , const real & sa ,
const real & md , const real & ma , const real & sf )
2002-12-20 16:15:03 +00:00
{
cli_for cf ;
cf . tipocf = t ;
sprintf ( cf . gruppo , " %03d " , g ) ;
sprintf ( cf . conto , " %03d " , c ) ;
sprintf ( cf . codcf , " %06ld " , s ) ;
sprintf ( cf . ragsoc , " %s " , rs ) ;
1995-07-21 10:12:15 +00:00
if ( s = = 999999L )
{
if ( ( _datada = = _dataini ) | | ( _tipo_stampa1 ! = 1 ) )
{
1995-11-30 09:39:32 +00:00
//modifica del 21/11/1995
if ( _tipo_stampa1 = = 1 & & _datada = = _dataini )
{
2002-12-20 16:15:03 +00:00
cf . saldodare = _saldo_ini_conto_dare ;
cf . saldoavere = _saldo_ini_conto_avere ;
1995-11-30 09:39:32 +00:00
}
else
//fine
1995-07-21 10:12:15 +00:00
{
1995-11-30 09:39:32 +00:00
real app = _saldo_ini_conto_dare + _saldo_ini_conto_avere ;
if ( app > ZERO ) //va stampato in Dare
{
2002-12-20 16:15:03 +00:00
cf . saldoavere = ZERO ;
cf . saldodare = app ;
1995-11-30 09:39:32 +00:00
}
else if ( app < ZERO )
{
1995-07-21 10:12:15 +00:00
app = - app ;
2002-12-20 16:15:03 +00:00
cf . saldodare = ZERO ;
cf . saldoavere = app ;
1995-11-30 09:39:32 +00:00
}
}
1995-07-21 10:12:15 +00:00
}
else if ( _datada > _dataini )
{
2002-12-20 16:15:03 +00:00
cf . saldodare = sd ;
cf . saldoavere = sa ;
1995-07-21 10:12:15 +00:00
}
}
else
{
2002-12-20 16:15:03 +00:00
cf . saldodare = sd ;
cf . saldoavere = sa ;
1995-07-21 10:12:15 +00:00
}
2002-12-20 16:15:03 +00:00
cf . movdare = md ;
cf . movavere = ma ;
cf . saldofinale = sf ;
cf . udata = _u_max ;
_sort - > sort ( ( const char * ) & cf ) ;
1995-07-21 10:12:15 +00:00
}
1997-10-16 08:47:25 +00:00
void TStampa_bilanci : : leggi_clifo ( const TArray & gccf )
1995-11-03 09:44:29 +00:00
{
TSaldo sld ;
1998-03-16 13:46:03 +00:00
TLocalisamfile saldi ( LF_SALDI ) ;
1995-11-03 09:44:29 +00:00
int g = 0 , c = 0 ;
long codcf = 0l ;
TString80 ragsoc ;
char tipocf , tipocfp , tipoa ;
real saldo_finale , saldo_conto , saldo_iniziale , saldodare , saldoavere ,
movdare , movavere ;
real mov_conto_dare , mov_conto_avere , prg_conto_dare , prg_conto_avere ;
bool esiste_sc = FALSE , movimentato = FALSE ;
TRecnotype items = _cur - > items ( ) ;
_gp = - 1 ;
_cp = - 1 ;
tipocfp = ' ' ;
_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 ;
_u_max = 0l ;
2002-05-08 16:25:49 +00:00
const int anno = _tipo_stampa1 = = 1 ? _annoapp : _annoes ;
1995-11-03 09:44:29 +00:00
for ( int i = 0 ; i < gccf . items ( ) ; i + + )
{
int g = ( ( TToken_string & ) gccf [ i ] ) . get_int ( 0 ) ;
int c = ( ( TToken_string & ) gccf [ i ] ) . get_int ( 1 ) ;
* _cur = 0l ;
for ( int i = 0 ; i < items ; i + + , + + ( * _cur ) )
{
_prog - > addstatus ( 1 ) ;
codcf = _cur - > curr ( ) . get_long ( CLI_CODCF ) ;
tipocf = _cur - > curr ( ) . get ( CLI_TIPOCF ) [ 0 ] ;
ragsoc = _cur - > curr ( ) . get ( CLI_RAGSOC ) ;
tipoa = _cur - > curr ( ) . get_char ( CLI_TIPOAPER ) ;
if ( tipoa = = ' F ' ) //persona fisica
{
TString80 cognome , nome ;
cognome = ragsoc . mid ( 0 , 30 ) ;
nome = ragsoc . mid ( 30 , 20 ) ;
cognome . trim ( ) ; nome . trim ( ) ;
ragsoc = cognome ;
2002-12-20 16:15:03 +00:00
ragsoc < < ' ' < < nome ;
1995-11-03 09:44:29 +00:00
}
1997-06-19 14:33:52 +00:00
TEsercizi_contabili ese ;
int aprec = ese . pred ( anno ) ;
1995-11-03 09:44:29 +00:00
saldi . zero ( ) ;
1996-06-07 15:07:55 +00:00
saldi . put ( SLD_ANNOES , anno ) ; // W96SALDI del 05-06-96
saldi . put ( SLD_FLSCA , FALSE ) ;
saldi . put ( SLD_GRUPPO , g ) ;
saldi . put ( SLD_CONTO , c ) ;
1995-11-03 09:44:29 +00:00
saldi . put ( SLD_SOTTOCONTO , codcf ) ;
if ( saldi . read ( ) ! = NOERR )
1997-04-03 09:22:40 +00:00
{
//if (_tipo_stampa1 == 1) //bilancio per data limite
// continue;
//else
if ( _stampac = = 2 ) //se sono richiesti i conti movimentati
1995-11-03 09:44:29 +00:00
{ //esco, se no...
_indbil = cerca_indbil ( g , c ) ;
if ( _indbil = = 1 | | _indbil = = 2 | | _indbil = = 5 )
{
saldi . zero ( ) ;
1996-06-07 15:07:55 +00:00
saldi . put ( SLD_ANNOES , aprec ) ; // W96SALDI del 05-06-96
saldi . put ( SLD_FLSCA , FALSE ) ;
saldi . put ( SLD_GRUPPO , g ) ;
saldi . put ( SLD_CONTO , c ) ;
1995-11-03 09:44:29 +00:00
saldi . put ( SLD_SOTTOCONTO , codcf ) ;
if ( saldi . read ( ) ! = NOERR )
continue ;
}
}
1997-04-03 09:22:40 +00:00
}
1995-11-03 09:44:29 +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 ;
}
saldo_finale = ZERO ;
saldodare = ZERO ;
saldoavere = ZERO ;
movdare = ZERO ;
1995-11-30 09:39:32 +00:00
movavere = ZERO ;
saldo_iniziale = ZERO ;
1995-11-03 09:44:29 +00:00
if ( _tipo_stampa1 = = 1 ) //bilancio di verifica per data limite
{
1995-11-30 09:39:32 +00:00
//modifica del 21/11/1995
_mov_ap = FALSE ;
1995-11-03 09:44:29 +00:00
//modifica del 19/06/95
_indbil = cerca_indbil ( g , c ) ;
movimentato = calcola ( g , c , codcf ) ;
if ( _stampa_mov_prov ! = 3 )
2003-02-25 15:20:00 +00:00
if ( ! movimentato )
1995-11-03 09:44:29 +00:00
if ( _indbil = = 1 | | _indbil = = 2 | | _indbil = = 5 )
1997-04-03 09:22:40 +00:00
if ( _annoes ! = 0 ) //cioe' se sto ragionando per competenza
{
1995-11-03 09:44:29 +00:00
saldo_iniziale = sld . saldofin_esprec ( _annoes , g , c , codcf ) ;
1997-04-03 09:22:40 +00:00
if ( saldo_iniziale > ZERO )
_saldo_ini_dare = saldo_iniziale ;
else _saldo_ini_avere = - saldo_iniziale ;
}
1995-11-03 09:44:29 +00:00
if ( movimentato )
{
1995-11-30 09:39:32 +00:00
//modifica del 21/11/1995
if ( _mov_ap )
saldo_iniziale = _saldo_ini_dare - _saldo_ini_avere ;
else
1995-11-03 09:44:29 +00:00
{
2002-07-02 16:21:23 +00:00
TLocalisamfile saldi ( LF_SALDI ) ;
saldi . zero ( ) ;
saldi . put ( SLD_ANNOES , _annoes ) ; // W96SALDI del 05-06-96
saldi . put ( SLD_FLSCA , FALSE ) ;
saldi . put ( SLD_GRUPPO , g ) ;
saldi . put ( SLD_CONTO , c ) ;
saldi . put ( SLD_SOTTOCONTO , codcf ) ;
if ( saldi . read ( ) = = NOERR )
{
const real s = saldi . get_real ( SLD_SALDO ) ;
if ( _stampa_mov_prov ! = 3 )
if ( _indbil = = 1 | | _indbil = = 2 | | _indbil = = 5 )
if ( s . is_zero ( ) & & _annoes ! = 0 ) //competenza!!!
{
saldo_iniziale + = sld . saldofin_esprec ( _annoes , g , c , codcf ) ;
//modifica del 21/11/1995
if ( saldo_iniziale > ZERO )
_saldo_ini_dare = saldo_iniziale ;
else _saldo_ini_avere = - saldo_iniziale ;
//fine
}
}
1995-11-03 09:44:29 +00:00
}
}
1995-11-30 09:39:32 +00:00
//fine modifica del 19/06/95
1995-11-03 09:44:29 +00:00
//movimentato = calcola(g,c,codcf);
1997-04-03 09:22:40 +00:00
if ( movimentato | | _stampac ! = 1 | | saldo_iniziale ! = ZERO )
1995-11-03 09:44:29 +00:00
{
if ( _datada = = _dataini )
saldo_finale = saldo_iniziale + _mov_periodo_dare - _mov_periodo_avere ;
else if ( _datada > _dataini )
{
//modifica del 19/06
if ( saldo_iniziale > 0 )
_prg_prec_dare + = saldo_iniziale ;
else _prg_prec_avere - = saldo_iniziale ;
//fine modifica
saldo_finale = _prg_prec_dare - _prg_prec_avere + _mov_periodo_dare
- _mov_periodo_avere ;
}
}
//se saldo_finale < 0 verra' stampato con una A, se no con una D
}
else //bilancio di verifica all'ultima immissione
{
_indbil = cerca_indbil ( g , c ) ;
movimentato = sld . ultima_immissione_verifica ( anno , g , c , codcf , _indbil , _stampa_mov_prov ) ;
if ( _stampa_mov_prov ! = 3 )
1997-04-03 09:22:40 +00:00
if ( ! movimentato /* && _stampac!=1 */ )
1995-11-03 09:44:29 +00:00
if ( _indbil = = 1 | | _indbil = = 2 | | _indbil = = 5 )
1997-09-08 13:33:08 +00:00
saldo_iniziale = sld . saldofin_esprec ( anno , g , c , codcf , FALSE ) ;
1995-11-03 09:44:29 +00:00
if ( movimentato )
saldo_iniziale = sld . saldoini ( ) ;
1997-04-03 09:22:40 +00:00
if ( movimentato | | _stampac ! = 1 | | saldo_iniziale ! = ZERO )
1995-11-03 09:44:29 +00:00
{
_mov_periodo_dare = sld . prgdare ( ) ;
_mov_periodo_avere = sld . prgavere ( ) ;
_prg_prec_dare = ZERO ;
_prg_prec_avere = ZERO ;
1999-04-26 15:58:05 +00:00
if ( sld . sezsf ( ) = = ' A ' )
_mov_periodo_avere - = sld . saldofin ( ) ;
else
_mov_periodo_dare + = sld . saldofin ( ) ;
1995-11-03 09:44:29 +00:00
saldo_finale = saldo_iniziale + _mov_periodo_dare - _mov_periodo_avere ;
}
}
1997-04-03 09:22:40 +00:00
if ( movimentato | | _stampac ! = 1 | | saldo_iniziale ! = ZERO )
2002-07-02 16:21:23 +00:00
if ( ! ( saldo_finale . is_zero ( ) & & _stampac = = 2 ) )
1995-11-03 09:44:29 +00:00
{
esiste_sc = TRUE ;
1995-11-30 09:39:32 +00:00
//modifica del 21/11/1995
if ( _tipo_stampa1 = = 1 & & _datada = = _dataini )
{
_saldo_ini_conto_dare + = _saldo_ini_dare ;
_saldo_ini_conto_avere + = _saldo_ini_avere ;
}
1995-11-03 09:44:29 +00:00
else
1995-11-30 09:39:32 +00:00
{
if ( saldo_iniziale < ZERO )
_saldo_ini_conto_avere + = saldo_iniziale ;
else
_saldo_ini_conto_dare + = saldo_iniziale ;
}
//fine
1995-11-03 09:44:29 +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!!!
if ( ( _datada = = _dataini ) | | ( _tipo_stampa1 ! = 1 ) )
{
1995-11-30 09:39:32 +00:00
//modifica del 21/11/1995
if ( _tipo_stampa1 = = 1 & & _datada = = _dataini )
{
saldodare = _saldo_ini_dare ;
saldoavere = _saldo_ini_avere ;
}
else
//
1995-11-03 09:44:29 +00:00
{
1995-11-30 09:39:32 +00:00
if ( saldo_iniziale > ZERO ) //va stampato in Dare
saldodare = saldo_iniziale ;
else if ( saldo_iniziale < ZERO )
{
1995-11-03 09:44:29 +00:00
saldo_iniziale = - saldo_iniziale ;
saldoavere = saldo_iniziale ;
1995-11-30 09:39:32 +00:00
}
1995-11-03 09:44:29 +00:00
}
}
else if ( _datada > _dataini )
{
saldodare = _prg_prec_dare ;
saldoavere = _prg_prec_avere ;
}
movdare = _mov_periodo_dare ;
movavere = _mov_periodo_avere ;
2002-12-20 16:15:03 +00:00
1995-11-03 09:44:29 +00:00
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 ) ;
}
1997-10-16 08:47:25 +00:00
void TStampa_bilanci : : crea_sort_clifo ( )
1995-11-03 09:44:29 +00:00
{
long ncur = _cur - > items ( ) ;
//serve solo per la progind: stima alla meno peggio
if ( _situazione . empty ( ) ) ncur / = 2 ;
long nitems = ncur * ( _clienti . items ( ) + _fornitori . items ( ) ) ;
2003-02-25 15:20:00 +00:00
_prog = new TProgind ( nitems , TR ( " Elaborazione in corso... prego attendere " ) , FALSE ) ;
1995-11-03 09:44:29 +00:00
_prog - > addstatus ( 1 ) ;
init_sort ( ) ;
if ( _situazione = = " C " ) leggi_clifo ( _clienti ) ;
else if ( _situazione = = " F " ) leggi_clifo ( _fornitori ) ;
else
{
_cur - > setfilter ( " TIPOCF = \" C \" " ) ;
leggi_clifo ( _clienti ) ;
_cur - > setfilter ( " TIPOCF = \" F \" " ) ;
leggi_clifo ( _fornitori ) ;
}
}
1995-07-21 10:12:15 +00:00
1997-10-16 08:47:25 +00:00
int TStampa_bilanci : : cerca_indbil ( int g , int c )
1995-07-21 10:12:15 +00:00
{
TLocalisamfile pconti ( LF_PCON ) ;
pconti . zero ( ) ;
pconti . put ( PCN_GRUPPO , g ) ;
if ( c ! = 0 )
pconti . put ( PCN_CONTO , c ) ;
pconti . put ( PCN_SOTTOCONTO , 0l ) ;
pconti . read ( ) ;
return pconti . get_int ( PCN_INDBIL ) ;
}
1997-10-16 08:47:25 +00:00
void TStampa_bilanci : : leggi_files_dare ( TIsamtempfile * file )
1995-07-21 10:12:15 +00:00
{
_gruppo_dare = file - > get_int ( SLD_GRUPPO ) ;
_conto_dare = file - > get_int ( SLD_CONTO ) ;
_sottoconto_dare = file - > get_long ( SLD_SOTTOCONTO ) ;
_saldo_dare = file - > get_real ( SLD_PDARE ) ;
_descr_dare = DescrizioneConto ( _gruppo_dare , _conto_dare , _sottoconto_dare , ' ' ) ;
_gc_corr_dare = format ( " %3d%3d " , _gruppo_dare , _conto_dare ) ;
if ( _gc_corr_dare ! = _gc_prec_dare )
{
_cambiato_conto_1 = TRUE ;
_gc_prec_dare = _gc_corr_dare ;
}
else if ( _sottoconto_dare ! = 0l )
_cambiato_conto_1 = FALSE ;
}
1997-10-16 08:47:25 +00:00
void TStampa_bilanci : : leggi_files_avere ( TIsamtempfile * file )
1995-07-21 10:12:15 +00:00
{
_gruppo_avere = file - > get_int ( SLD_GRUPPO ) ;
_conto_avere = file - > get_int ( SLD_CONTO ) ;
_sottoconto_avere = file - > get_long ( SLD_SOTTOCONTO ) ;
_saldo_avere = file - > get_real ( SLD_PAVERE ) ;
_descr_avere = DescrizioneConto ( _gruppo_avere , _conto_avere , _sottoconto_avere ,
' ' ) ;
_gc_corr_avere = format ( " %3d%3d " , _gruppo_avere , _conto_avere ) ;
if ( _gc_corr_avere ! = _gc_prec_avere )
{
_cambiato_conto_2 = TRUE ;
_gc_prec_avere = _gc_corr_avere ;
}
else if ( _sottoconto_avere ! = 0l )
_cambiato_conto_2 = FALSE ;
}
1997-10-16 08:47:25 +00:00
# define TOTAL_PICTURE "###.###.###.###.###"
1999-07-16 14:59:11 +00:00
HIDDEN void total2string ( const real & tot , TString & str )
{
TCurrency cur ( tot ) ;
str = cur . string ( TRUE ) ;
str . right_just ( strlen ( TOTAL_PICTURE ) ) ;
}
1997-10-16 08:47:25 +00:00
bool TStampa_bilanci : : preprocess_print ( int file , int counter )
1995-07-21 10:12:15 +00:00
{
if ( _bilancio = = 1 )
{
1997-10-16 08:47:25 +00:00
set_real_picture ( " ##.###.###.###.### " ) ;
1995-07-21 10:12:15 +00:00
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 ) ;
_gc_prec_avere = " " ;
_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
1997-10-16 08:47:25 +00:00
{
if ( _noseparator )
set_real_picture ( " ################ " ) ;
else
set_real_picture ( " ####.###.###.### " ) ;
1995-07-21 10:12:15 +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 ;
1999-07-16 14:59:11 +00:00
}
set_magic_currency ( TRUE ) ;
1995-07-21 10:12:15 +00:00
return TRUE ;
}
1997-10-16 08:47:25 +00:00
void TStampa_bilanci : : leggi_file_tmp ( )
1995-07-21 10:12:15 +00:00
{
if ( _livello_conto ) // era meglio chiamarla _livello_conto_oppure_gruppo, perche' nel caso dei saldi di mastro _livello_conto==TRUE <=> si tratta di un gruppo, mentre nel caso del bilancio _livello_conto==TRUE <=> si tratta di un conto
{
_gruppo = _tmp_saldi_att - > get_int ( SLD_GRUPPO ) ;
_conto = _tmp_saldi_att - > get_int ( SLD_CONTO ) ;
_sottoconto = _tmp_saldi_att - > get_long ( SLD_SOTTOCONTO ) ;
_tipo_conto = _tmp_saldi_att - > get_char ( SLD_FLAGSALINI ) ;
_descr = DescrizioneConto ( _gruppo , _conto , _sottoconto , _tipo_conto ) ;
1996-06-07 15:07:55 +00:00
_saldoini_dare = _tmp_saldi_att - > get_real ( SLD_PDAREPRO ) ; // W96SALDI del 05-06-96
_saldoini_avere = _tmp_saldi_att - > get_real ( SLD_PAVEREPRO ) ;
1995-07-21 10:12:15 +00:00
_mov_dare = _tmp_saldi_att - > get_real ( SLD_PDARE ) ;
_mov_avere = _tmp_saldi_att - > get_real ( SLD_PAVERE ) ;
_saldofinale = _tmp_saldi_att - > get_real ( SLD_SALDO ) ;
}
_eof1 = _tmp_saldi_att - > next ( ) ;
if ( ! _eof1 )
{
_gruppo_succ = _tmp_saldi_att - > get_int ( SLD_GRUPPO ) ;
_conto_succ = _tmp_saldi_att - > get_int ( SLD_CONTO ) ;
_sottoconto_succ = _tmp_saldi_att - > get_long ( SLD_SOTTOCONTO ) ;
_tipoc_succ = _tmp_saldi_att - > get_char ( SLD_FLAGSALINI ) ;
if ( ( _verifica ! = 2 ) & & ( _sottoconto_succ ! = 0 ) )
2002-07-02 16:21:23 +00:00
{
1995-07-21 10:12:15 +00:00
if ( _tipo_stampa1 = = 2 )
2002-07-02 16:21:23 +00:00
_ultima_data = UltimaData ( _gruppo_succ , _conto_succ , _sottoconto_succ , _annoes ) ;
else
_ultima_data = _tmp_saldi_att - > get_date ( SLD_DATAULMOV ) ;
}
1995-07-21 10:12:15 +00:00
_descr_succ = DescrizioneConto ( _gruppo_succ , _conto_succ ,
_sottoconto_succ , _tipoc_succ ) ;
1996-06-07 15:07:55 +00:00
_saldoini_dare_succ = _tmp_saldi_att - > get_real ( SLD_PDAREPRO ) ; // W96SALDI del 05-06-96
_saldoini_avere_succ = _tmp_saldi_att - > get_real ( SLD_PAVEREPRO ) ;
1995-07-21 10:12:15 +00:00
_mov_dare_succ = _tmp_saldi_att - > get_real ( SLD_PDARE ) ;
_mov_avere_succ = _tmp_saldi_att - > get_real ( SLD_PAVERE ) ;
_saldofinale_succ = _tmp_saldi_att - > get_real ( SLD_SALDO ) ;
_livello_conto = FALSE ;
if ( ( ( _verifica ! = 2 ) & & ( _sottoconto_succ = = 0 ) ) | |
( ( _verifica = = 2 ) & & ( _conto_succ = = 0 ) ) )
{
_livello_conto = TRUE ;
_gruppo_succ = _gruppo ;
_conto_succ = _conto ;
_sottoconto_succ = _sottoconto ;
_descr_succ = _descr ;
_saldoini_dare_succ = _saldoini_dare ;
_saldoini_avere_succ = _saldoini_avere ;
_mov_dare_succ = _mov_dare ;
_mov_avere_succ = _mov_avere ;
_saldofinale_succ = _saldofinale ;
}
}
}
1997-10-16 08:47:25 +00:00
bool TStampa_bilanci : : preprocess_page ( int file , int counter )
1995-07-21 10:12:15 +00:00
{
reset_print ( ) ;
if ( _bilancio = = 1 ) //stampa bilancio a sez. contrapposte
{
if ( counter )
{
if ( ( ! _eof1 ) & & ( _cambiato_conto_1 ) )
_eof1 = _tmp_saldi_att - > next ( ) ;
if ( ( ! _eof2 ) & & ( _cambiato_conto_2 ) )
_eof2 = _tmp_saldi_pass - > next ( ) ;
if ( _eof1 & & _eof2 )
{
if ( _prima_volta )
{
stampa_totali_uno ( _prg_saldoini_dare , _prg_saldoini_avere ) ;
_eof3 = _tmp_saldi_costi - > first ( ) ;
_eof4 = _tmp_saldi_ricavi - > first ( ) ;
}
else
{
_controlla = TRUE ;
if ( _salto_pagina )
{
if ( ( ! _eof3 ) & & ( _cambiato_conto_1 ) )
_eof3 = _tmp_saldi_costi - > next ( ) ;
if ( ( ! _eof4 ) & & ( _cambiato_conto_2 ) )
_eof4 = _tmp_saldi_ricavi - > next ( ) ;
}
}
if ( ( ! _eof3 ) & & ( _cambiato_conto_1 ) )
leggi_files_dare ( _tmp_saldi_costi ) ;
if ( ( ! _eof4 ) & & ( _cambiato_conto_2 ) )
leggi_files_avere ( _tmp_saldi_ricavi ) ;
if ( _eof3 & & _eof4 & & _salto_pagina )
{
if ( _seconda_volta )
{
stampa_totali ( ) ;
_eof5 = _tmp_saldi_conti_uno - > first ( ) ;
_eof6 = _tmp_saldi_conti_due - > first ( ) ;
}
else
{
_flag = TRUE ;
if ( _salto_pagina1 )
{
if ( ( ! _eof5 ) & & ( _cambiato_conto_1 ) )
_eof5 = _tmp_saldi_conti_uno - > next ( ) ;
if ( ( ! _eof6 ) & & ( _cambiato_conto_2 ) )
_eof6 = _tmp_saldi_conti_due - > next ( ) ;
}
}
if ( ( ! _eof5 ) & & ( _cambiato_conto_1 ) )
leggi_files_dare ( _tmp_saldi_conti_uno ) ;
if ( ( ! _eof6 ) & & ( _cambiato_conto_2 ) )
leggi_files_avere ( _tmp_saldi_conti_due ) ;
}
}
}
else //counter = 0
{
_gc_prec_dare = _gc_corr_avere = " " ;
_eof1 = _tmp_saldi_att - > first ( ) ;
_eof2 = _tmp_saldi_pass - > first ( ) ;
}
if ( ( ! _eof1 ) & & ( _cambiato_conto_1 ) )
leggi_files_dare ( _tmp_saldi_att ) ;
if ( ( ! _eof2 ) & & ( _cambiato_conto_2 ) )
leggi_files_avere ( _tmp_saldi_pass ) ;
}
else //stampa bilancio di verifica
{
if ( _verifica = = 3 )
leggi_sort ( ) ;
else
{
if ( counter )
{
if ( ! _eof1 )
leggi_file_tmp ( ) ;
}
else
{
_eof1 = _tmp_saldi_att - > first ( ) ;
if ( _eof1 )
return FALSE ;
2002-12-20 16:15:03 +00:00
else
leggi_file_tmp ( ) ;
1995-07-21 10:12:15 +00:00
}
}
}
return TRUE ;
}
1997-10-16 08:47:25 +00:00
void TStampa_bilanci : : leggi_sort ( )
1995-07-21 10:12:15 +00:00
{
1997-10-16 08:47:25 +00:00
_buff = _sort - > retrieve ( ) ;
if ( _buff ! = NULL )
1995-07-21 10:12:15 +00:00
{
1997-10-16 08:47:25 +00:00
struct cli_for * cf = ( struct cli_for * ) _buff ;
1995-07-21 10:12:15 +00:00
_tipo_conto = cf - > tipocf ;
_gruppo = atoi ( cf - > gruppo ) ;
_conto = atoi ( cf - > conto ) ;
_sottoconto = atol ( cf - > codcf ) ;
_descr = cf - > ragsoc ;
2002-07-02 16:21:23 +00:00
if ( ( _ordinamento = = 2 & & _descr ! = " zzzz " ) | | ( _ordinamento = = 1 & & _sottoconto ! = 999999L ) )
{
1995-07-21 10:12:15 +00:00
if ( _tipo_stampa1 = = 2 )
_ultima_data = UltimaData ( _gruppo , _conto , _sottoconto , _annoes ) ;
2002-07-02 16:21:23 +00:00
else
_ultima_data = cf - > udata ;
}
1995-07-21 10:12:15 +00:00
_saldo_dare = cf - > saldodare ;
_saldo_avere = cf - > saldoavere ;
_mov_dare = cf - > movdare ;
_mov_avere = cf - > movavere ;
_saldofinale = cf - > saldofinale ;
}
}
1997-10-16 08:47:25 +00:00
void TStampa_bilanci : : controlla_conto ( int file1 , int file2 )
1995-07-21 10:12:15 +00:00
{
char dep = ' * ' ;
if ( ! file1 )
if ( _cambiato_conto_1 )
{
1997-10-16 08:47:25 +00:00
set_row ( _i , " @68g%c " , dep ) ;
1995-07-21 10:12:15 +00:00
_cambiato_conto_1 = FALSE ;
}
else
{
stampa_prima_colonna ( _gruppo_dare , _conto_dare , _sottoconto_dare ,
_descr_dare , _saldo_dare ) ;
_cambiato_conto_1 = TRUE ;
if ( ! _totali )
if ( ( _conto_dare = = 0 ) & & ( _sottoconto_dare = = 0 ) )
_tot_dare + = _saldo_dare ;
if ( _totali )
if ( _sottoconto_dare = = 0 )
_tot_dare + = _saldo_dare ;
}
if ( ! file2 )
if ( _cambiato_conto_2 )
{
1997-10-16 08:47:25 +00:00
set_row ( _i , " @68g%c " , dep ) ;
1995-07-21 10:12:15 +00:00
_cambiato_conto_2 = FALSE ;
}
else
{
stampa_seconda_colonna ( _gruppo_avere , _conto_avere , _sottoconto_avere ,
_descr_avere , _saldo_avere ) ;
_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 ;
}
}
1997-10-16 08:47:25 +00:00
void TStampa_bilanci : : postclose_print ( )
1995-07-21 10:12:15 +00:00
{
if ( _bilancio = = 1 )
{
delete _tmp_saldi_att ; _tmp_saldi_att = NULL ;
delete _tmp_saldi_pass ; _tmp_saldi_pass = NULL ;
delete _tmp_saldi_costi ; _tmp_saldi_costi = NULL ;
delete _tmp_saldi_ricavi ; _tmp_saldi_ricavi = NULL ;
delete _tmp_saldi_conti_uno ; _tmp_saldi_conti_uno = NULL ;
delete _tmp_saldi_conti_due ; _tmp_saldi_conti_due = NULL ;
}
else
{
if ( _verifica = = 3 )
2002-12-20 16:15:03 +00:00
{
delete _sort ; _sort = NULL ;
}
1995-07-21 10:12:15 +00:00
else
{
delete _tmp_saldi_att ; _tmp_saldi_att = NULL ;
}
}
}
1997-10-16 08:47:25 +00:00
void TStampa_bilanci : : set_page ( int file , int counter )
1996-12-03 09:21:30 +00:00
{
const TString16 dep ;
1995-07-21 10:12:15 +00:00
if ( _bilancio = = 1 ) //stampa bilancio a sezioni contrapposte
{
_i = 1 ;
if ( ! counter )
{
2003-02-25 15:20:00 +00:00
set_row ( _i + + , FR ( " @29gATTIVITA'@94gPASSIVITA' " ) ) ;
1995-07-21 10:12:15 +00:00
set_row ( _i + + , " @29g---------@94g---------- " ) ;
1996-12-03 09:21:30 +00:00
set_row ( _i + + , dep ) ;
1995-07-21 10:12:15 +00:00
}
controlla_conto ( _eof1 , _eof2 ) ; //stampo una riga vuota tra un gruppo e un conto altrimenti no
if ( _eof1 & & _eof2 & & ( ! _prima_volta ) & & _controlla )
if ( ! _salto_pagina )
{
printer ( ) . formfeed ( ) ;
2003-02-25 15:20:00 +00:00
set_row ( _i + + , FR ( " @29gCOSTI@94gRICAVI " ) ) ;
1995-07-21 10:12:15 +00:00
set_row ( _i + + , " @29g-----@94g------ " ) ;
1996-12-03 09:21:30 +00:00
set_row ( _i + + , dep ) ;
1995-07-21 10:12:15 +00:00
_salto_pagina = TRUE ;
}
if ( _eof1 & & _eof2 & & _controlla )
{
controlla_conto ( _eof3 , _eof4 ) ;
if ( _eof3 & & _eof4 & & ( ! _seconda_volta ) & & _flag )
if ( ! _salto_pagina1 )
{
if ( ! _tmp_saldi_conti_uno - > empty ( ) | | ! _tmp_saldi_conti_due - > empty ( ) )
{
printer ( ) . formfeed ( ) ;
2003-02-25 15:20:00 +00:00
set_row ( _i + + , FR ( " @59gCONTI D'ORDINE " ) ) ;
1995-07-21 10:12:15 +00:00
set_row ( _i + + , " @59g-------------- " ) ;
1996-12-03 09:21:30 +00:00
set_row ( _i + + , dep ) ;
1995-07-21 10:12:15 +00:00
if ( _eof5 & & _eof6 )
{
_stampato = TRUE ;
stampa_totali_uno ( _prg_inidare_ord , _prg_iniavere_ord ) ;
}
}
_salto_pagina1 = TRUE ;
}
if ( _eof3 & & _eof4 & & _flag )
{
if ( ! _tmp_saldi_conti_uno - > empty ( ) | | ! _tmp_saldi_conti_due - > empty ( ) )
{
controlla_conto ( _eof5 , _eof6 ) ;
if ( _eof5 & & _eof6 )
if ( ! _stampato )
stampa_totali_uno ( _prg_inidare_ord , _prg_iniavere_ord ) ;
}
}
}
}
else //stampa bilancio di verifica
{
2002-07-02 16:21:23 +00:00
const TString16 udata = _ultima_data . string ( brief , ' / ' ) ;
1995-07-21 10:12:15 +00:00
char app ;
int r = 1 ;
if ( _verifica = = 3 )
{
if ( _buff ! = NULL )
{
* _d = ( const char * ) _descr ;
if ( _saldofinale > 0 )
app = ' D ' ;
else if ( _saldofinale < 0 )
{
_saldofinale = - _saldofinale ;
app = ' A ' ;
}
if ( ( _ordinamento = = 2 & & _descr = = " zzzz " ) | |
( _ordinamento = = 1 & & _sottoconto = = 999999L ) ) //devo stampare il conto
{
_descr = DescrizioneConto ( _gruppo , _conto , 0L , ' ' ) ;
stampa_record_conto ( _gruppo , _conto , _descr , _saldo_dare , _saldo_avere ,
_mov_dare , _mov_avere , _saldofinale , app ) ;
}
else
if ( _stampa_width = = 132 )
{
set_row ( r , " @1g%6ld " , ( const char * ) _sottoconto ) ;
1997-01-07 09:47:34 +00:00
if ( ( _saldo_dare ! = ZERO ) | | ( _saldo_avere ! = ZERO ) | | ( _mov_dare ! = ZERO ) | |
1997-04-03 09:22:40 +00:00
( _mov_avere ! = ZERO ) | | ( _saldofinale ! = ZERO ) )
set_row ( r , " %s " , ( const char * ) udata ) ;
1997-10-16 08:47:25 +00:00
set_row ( r , " @17g#a@46g!%r@64g%r@80g!%r@98g%r@114g!@115g%r " , _d , & _saldo_dare ,
1996-07-09 13:00:08 +00:00
& _saldo_avere , & _mov_dare , & _mov_avere , & _saldofinale ) ;
if ( _saldofinale ! = ZERO )
set_row ( r , " @131g%c " , app ) ;
1995-07-21 10:12:15 +00:00
if ( _descr . len ( ) > 30 )
1997-10-16 08:47:25 +00:00
set_row ( + + r , " @46g!@80g!@114g! " ) ;
1995-07-21 10:12:15 +00:00
}
else if ( app = = ' D ' )
{
set_row ( r , " @1g%6ld " , ( const char * ) _sottoconto ) ;
1997-01-07 09:47:34 +00:00
if ( ( _saldo_dare ! = ZERO ) | | ( _saldo_avere ! = ZERO ) | | ( _mov_dare ! = ZERO ) | |
1997-04-03 09:22:40 +00:00
( _mov_avere ! = ZERO ) | | ( _saldofinale ! = ZERO ) )
set_row ( r , " %s " , ( const char * ) udata ) ;
1997-10-16 08:47:25 +00:00
set_row ( r , " @17g#a@46g!%r@64g%r@80g!%r@98g%r@114g!%r@148g! " , _d ,
1995-07-21 10:12:15 +00:00
& _saldo_dare , & _saldo_avere , & _mov_dare , & _mov_avere , & _saldofinale ) ;
if ( _descr . len ( ) > 30 )
1997-10-16 08:47:25 +00:00
set_row ( + + r , " @46g!@80g!@114g!@148g! " ) ;
1995-07-21 10:12:15 +00:00
}
else
{
set_row ( r , " @1g%6ld " , ( const char * ) _sottoconto ) ;
1997-01-07 09:47:34 +00:00
if ( ( _saldo_dare ! = ZERO ) | | ( _saldo_avere ! = ZERO ) | | ( _mov_dare ! = ZERO ) | |
1997-04-03 09:22:40 +00:00
( _mov_avere ! = ZERO ) | | ( _saldofinale ! = ZERO ) )
set_row ( r , " %s " , ( const char * ) udata ) ;
1997-10-16 08:47:25 +00:00
set_row ( r , " @17g#a@46g!%r@64g%r@80g!%r@100g%r@114g!@132g%r@148g! " ,
1995-07-21 10:12:15 +00:00
_d , & _saldo_dare , & _saldo_avere , & _mov_dare , & _mov_avere , & _saldofinale ) ;
if ( _descr . len ( ) > 30 )
1997-10-16 08:47:25 +00:00
set_row ( + + r , " @46g!@80g!@114g!@148g! " ) ;
1995-07-21 10:12:15 +00:00
}
}
}
else //_verifica != 3
{
if ( ! _eof1 )
{
2002-12-20 16:15:03 +00:00
if ( _saldofinale_succ > = ZERO )
1995-07-21 10:12:15 +00:00
app = ' D ' ;
2002-12-20 16:15:03 +00:00
else
1995-07-21 10:12:15 +00:00
{
_saldofinale_succ = - _saldofinale_succ ;
app = ' A ' ;
}
if ( _livello_conto ) //sto stampando un conto/gruppo
r = stampa_record_conto ( _gruppo_succ , _conto_succ , _descr_succ ,
_saldoini_dare_succ , _saldoini_avere_succ , _mov_dare_succ ,
_mov_avere_succ , _saldofinale_succ , app ) ;
else //sto stampando un sottoconto/conto
{
if ( _verifica = = 2 )
{
if ( _stampa_width = = 132 )
{
set_row ( r , " %3d " , _conto_succ ) ;
1997-10-16 08:47:25 +00:00
set_row ( r , " @8g%-.40s@46g!%r@64g%r@80g!%r@98g%r@114g!@115g%r " ,
1995-07-21 10:12:15 +00:00
( const char * ) _descr_succ , & _saldoini_dare_succ , & _saldoini_avere_succ ,
1996-07-09 13:00:08 +00:00
& _mov_dare_succ , & _mov_avere_succ , & _saldofinale_succ ) ;
if ( _saldofinale_succ ! = ZERO )
set_row ( r , " @131g%c " , app ) ;
1995-07-21 10:12:15 +00:00
}
else if ( app = = ' D ' )
{
set_row ( r , " %3d " , _conto_succ ) ;
1997-10-16 08:47:25 +00:00
set_row ( r , " @8g%-.40s@46g!%r@64g%r@80g!%r@98g%r@114g!%r@148g! " ,
1995-07-21 10:12:15 +00:00
( const char * ) _descr_succ , & _saldoini_dare_succ , & _saldoini_avere_succ ,
& _mov_dare_succ , & _mov_avere_succ , & _saldofinale_succ ) ;
}
else
{
set_row ( r , " %3d " , _conto_succ ) ;
1997-10-16 08:47:25 +00:00
set_row ( r , " @8g%-.40s@46g!%r@64g%r@80g!%r@98g%r@114g!@132g%r@148g! " ,
1995-07-21 10:12:15 +00:00
( const char * ) _descr_succ , & _saldoini_dare_succ , & _saldoini_avere_succ ,
& _mov_dare_succ , & _mov_avere_succ , & _saldofinale_succ ) ;
}
} // _verifica != 2
else
{
* _d = ( const char * ) _descr_succ ;
if ( _stampa_width = = 132 )
{
set_row ( r , " @1g%6ld " , ( const char * ) _sottoconto_succ ) ;
1997-01-07 09:47:34 +00:00
if ( ( _saldoini_dare_succ ! = ZERO ) | | ( _saldoini_avere_succ ! = ZERO ) | |
1997-04-03 09:22:40 +00:00
( _mov_dare_succ ! = ZERO ) | | ( _mov_avere_succ ! = ZERO ) | |
( _saldofinale_succ ! = ZERO ) )
set_row ( r , " %s " , ( const char * ) udata ) ;
1997-10-16 08:47:25 +00:00
set_row ( r , " @17g#a@46g!%r@64g%r@80g!%r@98g%r@114g!@115g%r " ,
1995-07-21 10:12:15 +00:00
_d , & _saldoini_dare_succ , & _saldoini_avere_succ ,
1996-07-09 13:00:08 +00:00
& _mov_dare_succ , & _mov_avere_succ , & _saldofinale_succ ) ;
if ( _saldofinale_succ ! = ZERO )
set_row ( r , " @131g%c " , app ) ;
1995-07-21 10:12:15 +00:00
if ( _descr_succ . len ( ) > 30 )
1997-10-16 08:47:25 +00:00
set_row ( + + r , " @46g!@80g!@114g! " ) ;
1995-07-21 10:12:15 +00:00
}
2002-12-20 16:15:03 +00:00
else // Stampa estesa
{
1995-07-21 10:12:15 +00:00
set_row ( r , " @1g%6ld " , ( const char * ) _sottoconto_succ ) ;
1997-01-07 09:47:34 +00:00
if ( ( _saldoini_dare_succ ! = ZERO ) | | ( _saldoini_avere_succ ! = ZERO ) | |
1997-04-03 09:22:40 +00:00
( _mov_dare_succ ! = ZERO ) | | ( _mov_avere_succ ! = ZERO ) | |
( _saldofinale_succ ! = ZERO ) )
set_row ( r , " %s " , ( const char * ) udata ) ;
2002-12-20 16:15:03 +00:00
if ( app = = ' D ' )
{
set_row ( r , " @17g#a@46g!%r@64g%r@80g!%r@98g%r@114g!%r@148g! " ,
_d , & _saldoini_dare_succ , & _saldoini_avere_succ ,
& _mov_dare_succ , & _mov_avere_succ , & _saldofinale_succ ) ;
}
else
{
set_row ( r , " @17g#a@46g!%r@64g%r@80g!%r@98g%r@114g!@132g%r@148g! " ,
_d , & _saldoini_dare_succ , & _saldoini_avere_succ ,
& _mov_dare_succ , & _mov_avere_succ , & _saldofinale_succ ) ;
}
1995-07-21 10:12:15 +00:00
if ( _descr_succ . len ( ) > 30 )
1997-10-16 08:47:25 +00:00
set_row ( + + r , " @46g!@80g!@114g!@148g! " ) ;
1995-07-21 10:12:15 +00:00
}
}
}
}
else
{
2002-12-20 16:15:03 +00:00
if ( _saldofinale > = ZERO )
1995-07-21 10:12:15 +00:00
app = ' D ' ;
2002-12-20 16:15:03 +00:00
else
1995-07-21 10:12:15 +00:00
{
app = ' A ' ;
_saldofinale = - _saldofinale ;
}
r = stampa_record_conto ( _gruppo , _conto , _descr , _saldoini_dare ,
_saldoini_avere , _mov_dare , _mov_avere , _saldofinale , app ) ; //per stampare l'ultimo conto
stampa_riga_totali ( r ) ;
}
}
}
}
1997-10-16 08:47:25 +00:00
int TStampa_bilanci : : stampa_record_conto ( int g , int c , const TString & d ,
1995-07-21 10:12:15 +00:00
const real & r1 , const real & r2 , const real & r3 , const real & r4 , const real & r5 ,
const char app )
{
int r = 1 ;
1997-10-16 08:47:25 +00:00
if ( _stampa_width ! = 132 )
set_row ( r , " @46g!@80g!@114g!@148g! " ) ; //stampo una riga vuota
1995-07-21 10:12:15 +00:00
else
1997-10-16 08:47:25 +00:00
set_row ( r , " @46g!@80g!@114g! " ) ; //stampo una riga vuota
1995-07-21 10:12:15 +00:00
r + + ;
if ( _verifica = = 2 )
{
if ( _stampa_width = = 132 )
{
set_row ( r , " %3d- " , g ) ;
set_row ( r , " @8g%-.40s " , ( const char * ) d ) ;
1997-10-16 08:47:25 +00:00
set_row ( r , " @46g!%r@64g%r@80g!%r@98g%r@114g!@115g%r " , & r1 , & r2 , & r3 , & r4 , & r5 ) ;
1996-07-09 13:00:08 +00:00
if ( r5 ! = ZERO )
set_row ( r , " @131g%c " , app ) ;
r + + ;
1995-07-21 10:12:15 +00:00
}
else
if ( app = = ' D ' )
{
set_row ( r , " %3d- " , g ) ;
set_row ( r , " @8g%-.40s " , ( const char * ) d ) ;
1997-10-16 08:47:25 +00:00
set_row ( r + + , " @46g!%r@64g%r@80g!%r@98g%r@114g!%r@148g! " , & r1 , & r2 , & r3 , & r4 , & r5 ) ;
1995-07-21 10:12:15 +00:00
}
else
{
set_row ( r , " %3d- " , g ) ;
set_row ( r , " @8g%-.40s " , ( const char * ) d ) ;
1997-10-16 08:47:25 +00:00
set_row ( r + + , " @46g!%r@64g%r@80g!%r@98g%r@114g!@132g%r@148g! " , & r1 , & r2 , & r3 , & r4 , & r5 ) ;
1995-07-21 10:12:15 +00:00
}
}
else
{
* _d = ( const char * ) d ;
if ( _stampa_width = = 132 )
{
set_row ( r , " %3d- " , g ) ;
set_row ( r , " %3d ******** " , c ) ;
1997-10-16 08:47:25 +00:00
set_row ( r , " @17g#a " , _d ) ;
set_row ( r , " @46g!%r@64g%r@80g!%r@98g%r@114g!@115g%r " , & r1 , & r2 , & r3 , & r4 , & r5 ) ;
1996-07-09 13:00:08 +00:00
if ( r5 ! = ZERO )
set_row ( r , " @131g%c " , app ) ;
r + + ;
1995-07-21 10:12:15 +00:00
if ( d . len ( ) > 30 )
1997-10-16 08:47:25 +00:00
set_row ( r + 1 , " @46g!@80g!@114g! " ) ;
1995-07-21 10:12:15 +00:00
}
else if ( app = = ' D ' )
{
set_row ( r , " %3d- " , g ) ;
set_row ( r , " %3d ******** " , c ) ;
1997-10-16 08:47:25 +00:00
set_row ( r , " @17g#a " , _d ) ;
set_row ( r + + , " @46g!%r@64g%r@80g!%r@98g%r@114g!%r@148g! " , & r1 , & r2 , & r3 , & r4 , & r5 ) ;
1995-07-21 10:12:15 +00:00
if ( d . len ( ) > 30 )
1997-10-16 08:47:25 +00:00
set_row ( r + 1 , " @46g!@80g!@114g!@148g! " ) ;
1995-07-21 10:12:15 +00:00
}
else
{
set_row ( r , " %3d- " , g ) ;
set_row ( r , " %3d ******** " , c ) ;
1997-10-16 08:47:25 +00:00
set_row ( r , " @17g#a " , _d ) ;
set_row ( r + + , " @46g!%r@64g%r@80g!%r@98g%r@114g!@132g%r@148g! " , & r1 , & r2 , & r3 , & r4 , & r5 ) ;
1995-07-21 10:12:15 +00:00
if ( d . len ( ) > 30 )
1997-10-16 08:47:25 +00:00
set_row ( r + 1 , " @46g!@80g!@114g!@148g! " ) ;
1995-07-21 10:12:15 +00:00
}
}
1997-10-16 08:47:25 +00:00
set_row ( r , " @46g!@80g!@114g! " ) ;
if ( _stampa_width ! = 132 )
1996-11-29 14:58:01 +00:00
set_row ( r , " @148g! " ) ;
1995-07-21 10:12:15 +00:00
r + + ;
1997-10-16 08:47:25 +00:00
set_row ( r , " @46g!@80g!@114g! " ) ;
if ( _stampa_width ! = 132 )
1996-11-29 14:58:01 +00:00
set_row ( r , " @148g! " ) ;
1995-07-21 10:12:15 +00:00
r + + ;
if ( app = = ' D ' )
_saldo_finale_tot + = r5 ;
else _saldo_finale_tot - = r5 ;
_saldo_dare_tot + = r1 ;
_saldo_avere_tot + = r2 ;
_mov_dare_tot + = r3 ;
_mov_avere_tot + = r4 ;
return r ;
}
1997-10-16 08:47:25 +00:00
void TStampa_bilanci : : stampa_riga_totali ( int r )
1995-07-21 10:12:15 +00:00
{
1996-12-03 09:21:30 +00:00
const TString16 dep ;
1995-07-21 10:12:15 +00:00
char app = ' ' ;
if ( _saldo_finale_tot > 0 )
app = ' D ' ;
else if ( _saldo_finale_tot < 0 )
{
_saldo_finale_tot = - _saldo_finale_tot ;
app = ' A ' ;
}
1995-11-30 09:39:32 +00:00
//modifica del 21/11/1995
if ( _tipo_stampa1 = = 2 )
1995-07-21 10:12:15 +00:00
{
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 ;
}
}
1997-10-16 08:47:25 +00:00
set_row ( r , " @46g!@80g!@114g! " ) ;
if ( _stampa_width ! = 132 )
set_row ( r , " @148g! " ) ;
1995-07-21 10:12:15 +00:00
r + + ;
1995-11-17 14:29:24 +00:00
1995-07-21 10:12:15 +00:00
if ( _verifica = = 2 )
{
if ( _stampa_width = = 132 )
1995-11-17 14:29:24 +00:00
{
2003-02-25 15:20:00 +00:00
set_row ( r , FR ( " ***@8gTOTALE GENERALE@46g!%r@64g%r@80g!%r@98g%r@114g!@115g%r " ) , & _saldo_dare_tot , & _saldo_avere_tot , & _mov_dare_tot ,
1997-10-16 08:47:25 +00:00
& _mov_avere_tot , & _saldo_finale_tot ) ;
if ( _saldo_finale_tot ! = ZERO )
set_row ( r , " @131g%c " , app ) ;
1995-11-17 14:29:24 +00:00
}
1995-07-21 10:12:15 +00:00
else
1995-11-17 14:29:24 +00:00
{
2000-10-03 13:45:12 +00:00
if ( app = = ' D ' )
2003-02-25 15:20:00 +00:00
set_row ( r , FR ( " ***@8gTOTALE GENERALE@46g!%r@64g%r@80g!%r@98g%r@114g!%r@148g! " ) , & _saldo_dare_tot , & _saldo_avere_tot ,
1995-11-17 14:29:24 +00:00
& _mov_dare_tot , & _mov_avere_tot , & _saldo_finale_tot ) ;
2000-10-03 13:45:12 +00:00
else
2003-02-25 15:20:00 +00:00
set_row ( r , FR ( " ***@8gTOTALE GENERALE@46g!%r@64g%r@80g!%r@98g%r@114g!@132g%r@148g! " ) , & _saldo_dare_tot , & _saldo_avere_tot ,
2000-10-03 13:45:12 +00:00
& _mov_dare_tot , & _mov_avere_tot , & _saldo_finale_tot ) ;
}
1995-07-21 10:12:15 +00:00
}
else
{
if ( _stampa_width = = 132 )
{
2003-02-25 15:20:00 +00:00
set_row ( r , FR ( " @1g****** ********@17gTOTALE GENERALE@46g!%r@64g%r@80g!%r@98g%r@114g!@115g%r " ) , & _saldo_dare_tot , & _saldo_avere_tot ,
1997-10-16 08:47:25 +00:00
& _mov_dare_tot , & _mov_avere_tot , & _saldo_finale_tot ) ;
if ( _saldo_finale_tot ! = ZERO )
set_row ( r , " @131g%c " , app ) ;
r + + ;
2002-07-02 16:21:23 +00:00
if ( _cdc . empty ( ) ) // Non ha senso parlare di saldi iniziali delle commesse
1995-11-17 14:29:24 +00:00
{
2002-07-02 16:21:23 +00:00
if ( ( _tipo_stampa1 = = 1 & & _datada = = _dataini ) | | _tipo_stampa1 = = 2 )
{
//modifica del 21/11/1995
if ( _tipo_stampa1 = = 2 )
2003-02-25 15:20:00 +00:00
set_row ( r , FR ( " @1g****** ********@17gTOTALE CON SALDI INIZIALI@46g!@80g!%r@98g%r@114g! " ) , & _nuovo_tot_saldo_d , & _nuovo_tot_saldo_a ) ;
2002-07-02 16:21:23 +00:00
else
2003-02-25 15:20:00 +00:00
set_row ( r , FR ( " @1g****** ********@17gTOTALE CON MOVIM. DI APERTURA@46g!@80g!%r@98g%r@114g! " ) , & _nuovo_tot_saldo_d , & _nuovo_tot_saldo_a ) ;
2002-07-02 16:21:23 +00:00
//fine
}
}
1995-07-21 10:12:15 +00:00
}
else
{
if ( app = = ' D ' )
1995-11-17 14:29:24 +00:00
{
2003-02-25 15:20:00 +00:00
set_row ( r + + , FR ( " @1g****** ********@17gTOTALE GENERALE@46g!%r@64g%r@80g!%r@98g%r@114g!%r@148g! " ) , & _saldo_dare_tot ,
2000-10-03 13:45:12 +00:00
& _saldo_avere_tot , & _mov_dare_tot , & _mov_avere_tot , & _saldo_finale_tot ) ;
1995-11-17 14:29:24 +00:00
}
else
{
2003-02-25 15:20:00 +00:00
set_row ( r + + , FR ( " @1g****** ********@17gTOTALE GENERALE@46g!%r@64g%r@80g!%r@98g%r@114g!@132g%r@148g! " ) , & _saldo_dare_tot ,
2000-10-03 13:45:12 +00:00
& _saldo_avere_tot , & _mov_dare_tot , & _mov_avere_tot , & _saldo_finale_tot ) ;
1995-11-17 14:29:24 +00:00
}
2002-07-02 16:21:23 +00:00
if ( _cdc . empty ( ) ) // Non ha senso parlare di saldi iniziali delle commesse
1995-11-17 14:29:24 +00:00
{
2002-07-02 16:21:23 +00:00
if ( ( _tipo_stampa1 = = 1 & & _datada = = _dataini ) | | _tipo_stampa1 = = 2 )
{
if ( _tipo_stampa1 = = 2 )
2003-02-25 15:20:00 +00:00
set_row ( r , FR ( " @1g****** ********@17gTOTALE CON SALDI INIZIALI@46g!@80g!%r@98g%r@114g!@148g! " ) , & _nuovo_tot_saldo_d , & _nuovo_tot_saldo_a ) ;
2002-07-02 16:21:23 +00:00
else
2003-02-25 15:20:00 +00:00
set_row ( r , FR ( " @1g****** ********@17gTOTALE CON MOVIM. DI APERTURA@46g!@80g!%r@98g%r@114g!@148g! " ) , & _nuovo_tot_saldo_d , & _nuovo_tot_saldo_a ) ;
2002-07-02 16:21:23 +00:00
}
}
1995-07-21 10:12:15 +00:00
}
}
}
1997-10-16 08:47:25 +00:00
void TStampa_bilanci : : stampa_totali ( )
1995-07-21 10:12:15 +00:00
{
1996-12-03 09:21:30 +00:00
const TString16 dep = " " ;
1995-07-21 10:12:15 +00:00
real pareggio ;
real sbilancio = _tot_dare - _tot_avere ;
if ( sbilancio > ZERO ) //_tot_dare > _tot_avere
pareggio = _tot_avere + sbilancio ;
else
{
sbilancio = - sbilancio ;
pareggio = _tot_dare + sbilancio ;
}
if ( _prima_volta ) //ho finito di stampare le attivita'/passivita'
_prima_volta = FALSE ;
else
_seconda_volta = FALSE ;
_gc_prec_dare = _gc_corr_avere = " " ;
_cambiato_conto_1 = TRUE ;
_cambiato_conto_2 = TRUE ;
set_row ( _i + + , ( const char * ) dep ) ;
set_row ( _i + + , ( const char * ) dep ) ;
set_row ( _i + + , ( const char * ) dep ) ;
set_row ( _i + + , ( const char * ) dep ) ;
1999-07-16 14:59:11 +00:00
TString pal ; total2string ( _tot_dare , pal ) ;
TString bal ; total2string ( _tot_avere , bal ) ;
2003-02-25 15:20:00 +00:00
set_row ( _i + + , FR ( " @39gTOTALE@48g%s@102gTOTALE@113g%s " ) ,
1995-11-17 14:29:24 +00:00
( const char * ) pal , ( const char * ) bal ) ;
1999-07-16 14:59:11 +00:00
TString sb ; total2string ( sbilancio , sb ) ;
TString pa ; total2string ( pareggio , pa ) ;
1995-07-21 10:12:15 +00:00
if ( _tot_dare > _tot_avere )
{
2003-02-25 15:20:00 +00:00
set_row ( _i + + , FR ( " @80gSBILANCIO ESERCIZIO IN CORSO@113g%s " ) , ( const char * ) sb ) ;
set_row ( _i + + , FR ( " @91gTOTALE A PAREGGIO@113g%s " ) , ( const char * ) pa ) ;
1995-07-21 10:12:15 +00:00
}
if ( _tot_dare < _tot_avere )
{
2003-02-25 15:20:00 +00:00
set_row ( _i + + , FR ( " @17gSBILANCIO ESERCIZIO IN CORSO@48g%s " ) , ( const char * ) sb ) ;
set_row ( _i + + , FR ( " @28gTOTALE A PAREGGIO@48g%s " ) , ( const char * ) pa ) ;
1995-07-21 10:12:15 +00:00
}
_tot_dare = ZERO ;
_tot_avere = ZERO ;
}
//per i conti patrimoniali stampo anche lo sbilancio es. precedente
1997-10-16 08:47:25 +00:00
void TStampa_bilanci : : stampa_totali_uno ( const real & r1 , const real & r2 )
1995-07-21 10:12:15 +00:00
{
real pareggio ;
real sbilancio = _tot_dare - r1 - ( _tot_avere - r2 ) ;
real sbilprec = r2 - r1 ;
2003-02-25 15:20:00 +00:00
1995-07-21 10:12:15 +00:00
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 ;
2002-02-26 16:20:19 +00:00
const char * dep = " " ;
1995-07-21 10:12:15 +00:00
set_row ( _i + + , ( const char * ) dep ) ;
set_row ( _i + + , ( const char * ) dep ) ;
set_row ( _i + + , ( const char * ) dep ) ;
1995-11-17 14:29:24 +00:00
set_row ( _i + + , ( const char * ) dep ) ;
1999-07-16 14:59:11 +00:00
TString pal ; total2string ( _tot_dare , pal ) ;
TString bal ; total2string ( _tot_avere , bal ) ;
2003-02-25 15:20:00 +00:00
set_row ( _i + + , FR ( " @39gTOTALE@48g%s@102gTOTALE@113g%s " ) ,
1995-11-17 14:29:24 +00:00
( const char * ) pal , ( const char * ) bal ) ;
1995-07-21 10:12:15 +00:00
if ( sbilancio > ZERO ) //ho un utile => va stampato tra le passivita'
{
sbilprec = - sbilprec ;
pareggio = _tot_avere + sbilancio + sbilprec ;
if ( sbilprec ! = ZERO )
1995-11-17 14:29:24 +00:00
{
1999-07-16 14:59:11 +00:00
TString sb ; total2string ( sbilprec , sb ) ;
2003-02-25 15:20:00 +00:00
set_row ( _i + + , FR ( " @83gSBILANCIO ESERCIZIO PRECEDENTE@113g%s " ) ,
1995-11-17 14:29:24 +00:00
( const char * ) sb ) ;
}
1999-07-16 14:59:11 +00:00
TString pal ; total2string ( sbilancio , pal ) ;
TString bal ; total2string ( pareggio , bal ) ;
2003-02-25 15:20:00 +00:00
set_row ( _i + + , FR ( " @80gSBILANCIO ESERCIZIO IN CORSO@113g%s " ) ,
1995-11-17 14:29:24 +00:00
( const char * ) pal ) ;
2003-02-25 15:20:00 +00:00
set_row ( _i + + , FR ( " @91gTOTALE A PAREGGIO@113g%s " ) , ( const char * ) bal ) ;
1995-11-17 14:29:24 +00:00
}
else if ( sbilancio < ZERO ) //ho una perdita => va stampato tra le attivita'
{
sbilancio = - sbilancio ;
pareggio = _tot_dare + sbilancio + sbilprec ;
if ( sbilprec ! = ZERO )
{
1999-07-16 14:59:11 +00:00
TString sb ; total2string ( sbilprec , sb ) ;
2003-02-25 15:20:00 +00:00
set_row ( _i + + , FR ( " @15gSBILANCIO ESERCIZIO PRECEDENTE@48g%s " ) ,
1995-11-17 14:29:24 +00:00
( const char * ) sb ) ;
}
1997-10-16 08:47:25 +00:00
1999-07-16 14:59:11 +00:00
TString pal ; total2string ( sbilancio , pal ) ;
TString bal ; total2string ( pareggio , bal ) ;
2003-02-25 15:20:00 +00:00
set_row ( _i + + , FR ( " @17gSBILANCIO ESERCIZIO IN CORSO@48g%s " ) ,
1995-11-17 14:29:24 +00:00
( const char * ) pal ) ;
2003-02-25 15:20:00 +00:00
set_row ( _i + + , FR ( " @28gTOTALE A PAREGGIO@48g%s " ) , ( const char * ) bal ) ;
1995-07-21 10:12:15 +00:00
}
else //sbilancio es. in corso == 0
{
sbilprec = - sbilprec ;
if ( sbilprec > ZERO ) //va stampato sotto le passivita'
{
1999-07-16 14:59:11 +00:00
TString pal ; total2string ( sbilprec , pal ) ;
1995-07-21 10:12:15 +00:00
pareggio = _tot_avere + sbilprec ;
1999-07-16 14:59:11 +00:00
TString bal ; total2string ( pareggio , bal ) ;
2003-02-25 15:20:00 +00:00
set_row ( _i + + , FR ( " @83gSBILANCIO ESERCIZIO PRECEDENTE@113g%s " ) ,
1995-11-17 14:29:24 +00:00
( const char * ) pal ) ;
2003-02-25 15:20:00 +00:00
set_row ( _i + + , FR ( " @96gTOTALE A PAREGGIO@113g%s " ) , ( const char * ) bal ) ;
1995-11-17 14:29:24 +00:00
}
else if ( sbilprec < ZERO )
{
sbilprec = - sbilprec ;
pareggio = _tot_dare + sbilprec ;
1999-07-16 14:59:11 +00:00
TString pal ; total2string ( sbilprec , pal ) ;
TString bal ; total2string ( pareggio , bal ) ;
2003-02-25 15:20:00 +00:00
set_row ( _i + + , FR ( " @15gSBILANCIO ESERCIZIO PRECEDENTE@48g%s " ) , ( const char * ) pal ) ;
set_row ( _i + + , FR ( " @28gTOTALE A PAREGGIO@48g%s " ) , ( const char * ) bal ) ;
1995-07-21 10:12:15 +00:00
}
}
_tot_dare = ZERO ;
_tot_avere = ZERO ;
}
1997-10-16 08:47:25 +00:00
// Guy: stampa la prima colonna del bilancio di raffronto
void TStampa_bilanci : : stampa_prima_colonna ( int g , int c , long s ,
1995-07-21 10:12:15 +00:00
const char * desc , const real & saldo )
{
char dep = ' * ' ;
if ( _codici ) //sono stampate solo le descrizioni dei conti
{
if ( ! _totali )
{
if ( c ! = 0 & & s = = 0 )
2000-10-03 13:45:12 +00:00
set_row ( _i , " %-.44s @44g @49g%r @68g%c " , desc , & saldo , dep ) ;
1997-10-16 08:47:25 +00:00
else
set_row ( _i , " %-.48s @49g%r @68g%c " , desc , & saldo , dep ) ;
1995-07-21 10:12:15 +00:00
}
else if ( ! ( c = = 0 & & s = = 0 ) ) //se cioe' non e' un gruppo
{
if ( s = = 0 ) //se e' un conto
2000-10-03 13:45:12 +00:00
set_row ( _i , " %-.44s @44g @49g%r @68g%c " , desc , & saldo , dep ) ;
1997-10-16 08:47:25 +00:00
else
set_row ( _i , " %-.48s @49g%r @68g%c " , desc , & saldo , dep ) ;
1995-07-21 10:12:15 +00:00
}
}
else
{
1997-10-16 08:47:25 +00:00
if ( _totali & & c = = 0 & & s = = 0l )
return ;
else if ( c = = 0 & & s = = 0l )
{
set_row ( _i , " %3d " , g ) ;
set_row ( _i , " @15g%-.31s @49g%r @68g%c " , desc , & saldo , dep ) ;
}
else if ( s = = 0l )
{
set_row ( _i , " %3d " , g ) ;
set_row ( _i , " %3d " , c ) ;
set_row ( _i , " @15g%-.31s @49g%r @68g%c " , desc , & saldo , dep ) ;
}
else
{
set_row ( _i , " %3d " , g ) ;
set_row ( _i , " %3d " , c ) ;
set_row ( _i , " %6ld " , s ) ;
set_row ( _i , " @15g%-.31s @49g%r @68g%c " , desc , & saldo , dep ) ;
}
1995-07-21 10:12:15 +00:00
}
}
1997-10-16 08:47:25 +00:00
// Guy: stampa la seconda colonna del bilancio di raffronto
void TStampa_bilanci : : stampa_seconda_colonna ( int g , int c , long s ,
const char * desc , const real & saldo )
1995-07-21 10:12:15 +00:00
{
char dep = ' * ' ;
if ( _codici ) //sono stampate solo le descrizioni dei conti
{
if ( ! _totali )
{
1997-10-16 08:47:25 +00:00
set_row ( _i , " @68g%c@69g%-.47s @114g%r " , dep , desc , & saldo ) ;
1995-07-21 10:12:15 +00:00
}
2003-02-25 15:20:00 +00:00
else
if ( ! ( c = = 0 & & s = = 0 ) )
{
set_row ( _i , " @68g%c @69g%-.47s @114g%r " , dep , desc , & saldo ) ;
}
1995-07-21 10:12:15 +00:00
}
else
{
1997-10-16 08:47:25 +00:00
if ( _totali & & c = = 0 & & s = = 0l )
return ;
else if ( c = = 0 & & s = = 0l )
{
set_row ( _i , " @68g%c@69g%3d " , dep , g ) ;
set_row ( _i , " @84g%-.30s @114g%r " , desc , & saldo ) ;
}
else if ( s = = 0l )
{
set_row ( _i , " @68g%c@69g%3d " , dep , g ) ;
set_row ( _i , " %3d " , c ) ;
set_row ( _i , " @84g%-.30s @114g%r " , desc , & saldo ) ;
}
else
{
set_row ( _i , " @68g%c@69g%3d " , dep , g ) ;
set_row ( _i , " %3d " , c ) ;
set_row ( _i , " %6ld " , s ) ;
set_row ( _i , " @84g%-.30s @114g%r " , desc , & saldo ) ;
}
1995-07-21 10:12:15 +00:00
}
}
1997-10-16 08:47:25 +00:00
print_action TStampa_bilanci : : postprocess_page ( int file , int counter )
1995-07-21 10:12:15 +00:00
{
if ( _bilancio = = 1 )
{
if ( _eof1 & & _eof2 & & _eof3 & & _eof4 & & _eof5 & & _eof6 & & _salto_pagina1 )
return NEXT_PAGE ;
}
else //bilancio di verifica
{
if ( _verifica = = 3 )
{
if ( _buff = = NULL )
return NEXT_PAGE ;
}
else if ( _eof1 )
return NEXT_PAGE ;
}
return REPEAT_PAGE ;
}
1997-10-16 08:47:25 +00:00
TDate TStampa_bilanci : : UltimaData ( int g , int c , long s , int anno )
1995-07-21 10:12:15 +00:00
{
TDate uldata ;
1998-11-04 18:04:26 +00:00
TLocalisamfile saldi ( LF_SALDI ) ;
1995-07-21 10:12:15 +00:00
saldi . zero ( ) ;
if ( _annoes ! = 0 )
1996-06-07 15:07:55 +00:00
saldi . put ( SLD_ANNOES , anno ) ;
saldi . put ( SLD_FLSCA , FALSE ) ; // W96SALDI del 05-06-96
1995-07-21 10:12:15 +00:00
saldi . put ( SLD_GRUPPO , g ) ;
if ( c ! = 0 )
saldi . put ( SLD_CONTO , c ) ;
if ( s ! = 0 )
saldi . put ( SLD_SOTTOCONTO , s ) ;
saldi . read ( ) ;
if ( saldi . bad ( ) )
saldi . zero ( ) ;
uldata = saldi . get ( SLD_DATAULMOV ) ;
return uldata ;
}
1998-11-04 18:04:26 +00:00
// Non ho potuto usare quella di TConto!!! Chiedere a me!
// Guy: E tu chi sei?
1997-10-16 08:47:25 +00:00
const char * TStampa_bilanci : : DescrizioneConto ( int g , int c , long s , char tipocf )
1995-07-21 10:12:15 +00:00
{
2003-03-14 15:13:36 +00:00
static TString80 ragsoc ;
1995-07-21 10:12:15 +00:00
const char * desc = NULL ;
2003-03-14 15:13:36 +00:00
TString80 key ; key < < g ;
1995-07-21 10:12:15 +00:00
if ( c ! = 0 )
2003-03-14 15:13:36 +00:00
key < < " | " < < c ;
1995-07-21 10:12:15 +00:00
if ( s ! = 0 )
2003-03-14 15:13:36 +00:00
key < < " | " < < s ;
const TRectype & pconti = cache ( ) . get ( LF_PCON , key ) ;
if ( ! pconti . empty ( ) )
2002-12-17 12:02:54 +00:00
_tmp = pconti . get ( PCN_DESCR ) ;
1995-07-21 10:12:15 +00:00
else
{
2003-03-14 15:13:36 +00:00
key . format ( " %c|%ld " , tipocf , s ) ;
const TRectype & clifo = cache ( ) . get ( LF_CLIFO , key ) ;
if ( ! clifo . empty ( ) )
1995-07-21 10:12:15 +00:00
{
char tipoa = clifo . get_char ( " TIPOAPER " ) ;
if ( tipoa = = ' F ' ) //persona fisica
{
TString80 cognome , nome ;
ragsoc = clifo . get ( " RAGSOC " ) ;
cognome = ragsoc . mid ( 0 , 30 ) ;
nome = ragsoc . mid ( 30 , 20 ) ;
cognome . trim ( ) ; nome . trim ( ) ;
ragsoc = cognome ;
ragsoc < < " " < < nome ;
desc = ragsoc ;
}
else
desc = clifo . get ( " RAGSOC " ) ;
2002-12-17 12:02:54 +00:00
_tmp = desc ;
1995-07-21 10:12:15 +00:00
}
else
2002-12-17 12:02:54 +00:00
_tmp = " " ;
2003-03-14 15:13:36 +00:00
1995-07-21 10:12:15 +00:00
}
2002-12-17 12:02:54 +00:00
return _tmp ;
2003-03-14 15:13:36 +00:00
1995-07-21 10:12:15 +00:00
}
1997-10-16 08:47:25 +00:00
bool TStampa_bilanci : : user_create ( )
1995-07-21 10:12:15 +00:00
{
2002-12-20 16:15:03 +00:00
open_files ( LF_TAB , 0 ) ;
1995-07-21 10:12:15 +00:00
_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 ) ;
_caus = new TLocalisamfile ( LF_CAUSALI ) ;
1997-10-16 08:47:25 +00:00
_d = new TParagraph_string ( " " , 29 ) ;
2002-12-20 16:15:03 +00:00
_sort = NULL ;
1995-07-21 10:12:15 +00:00
_tmp_saldi_att = NULL ;
_tmp_saldi_pass = NULL ;
_tmp_saldi_costi = NULL ;
_tmp_saldi_ricavi = NULL ;
_tmp_saldi_conti_uno = NULL ;
_tmp_saldi_conti_due = NULL ;
return TRUE ;
}
1997-10-16 08:47:25 +00:00
bool TStampa_bilanci : : user_destroy ( )
1995-07-21 10:12:15 +00:00
{
delete _rel ;
delete _cur ;
delete _com ;
delete _pcn ;
delete _mov ;
delete _rmov ;
delete _clifo ;
delete _saldi ;
delete _nditte ;
delete _anag ;
delete _caus ;
delete _d ;
if ( _tmp_saldi_att ) delete _tmp_saldi_att ;
if ( _tmp_saldi_pass ) delete _tmp_saldi_pass ;
if ( _tmp_saldi_costi ) delete _tmp_saldi_costi ;
if ( _tmp_saldi_ricavi ) delete _tmp_saldi_ricavi ;
if ( _tmp_saldi_conti_uno ) delete _tmp_saldi_conti_uno ;
if ( _tmp_saldi_conti_due ) delete _tmp_saldi_conti_due ;
return TRUE ;
}
1997-10-16 08:47:25 +00:00
void TStampa_bilanci : : leggi_pcon ( )
2002-05-08 16:25:49 +00:00
{
TRelation rel ( LF_PCON ) ;
TCursor cur ( & rel ) ;
const TRectype & pconti = rel . curr ( ) ;
const long items = cur . items ( ) ;
cur . freeze ( ) ;
1995-07-21 10:12:15 +00:00
2002-05-08 16:25:49 +00:00
TToken_string gc ( 10 ) ;
for ( cur = 0L ; cur . pos ( ) < items ; + + cur )
1995-07-21 10:12:15 +00:00
{
2002-05-08 16:25:49 +00:00
const int gruppo = pconti . get_int ( PCN_GRUPPO ) ;
const int conto = pconti . get_int ( PCN_CONTO ) ;
const long sottoconto = pconti . get_long ( PCN_SOTTOCONTO ) ;
1995-07-21 10:12:15 +00:00
if ( ( sottoconto = = 0l ) & & ( conto ! = 0 ) ) //si tratta di un conto
{
2002-05-08 16:25:49 +00:00
const char tipocf = pconti . get_char ( PCN_TMCF ) ;
if ( tipocf = = ' C ' & & ( _situazione . empty ( ) | | _situazione = = " C " ) )
1995-07-21 10:12:15 +00:00
{
1995-11-03 09:44:29 +00:00
gc . add ( gruppo , 0 ) ;
gc . add ( conto , 1 ) ;
_clienti . add ( gc ) ;
}
2002-05-08 16:25:49 +00:00
else if ( tipocf = = ' F ' & & ( _situazione . empty ( ) | | _situazione = = " F " ) )
1995-07-21 10:12:15 +00:00
{
gc . add ( gruppo , 0 ) ;
gc . add ( conto , 1 ) ;
_fornitori . add ( gc ) ;
1995-11-03 09:44:29 +00:00
}
1995-07-21 10:12:15 +00:00
}
}
}
2002-05-08 16:25:49 +00:00
void TStampa_bilanci : : stampa_un_bilancio ( const TMask & m )
{
2002-12-20 16:15:03 +00:00
_prog = NULL ;
2002-05-08 16:25:49 +00:00
if ( _bilancio = = 1 )
{
printer ( ) . footerlen ( 3 ) ;
2003-02-25 15:20:00 +00:00
_prog = new TProgind ( _pcn - > items ( ) , TR ( " Elaborazione in corso... " ) , FALSE ) ;
2002-05-08 16:25:49 +00:00
_totali = m . get_bool ( F_TOTALI ) ;
_codici = m . get_bool ( F_CODICI ) ;
_saldo = m . get_bool ( F_SALDO ) ;
_tipo_stampa = m . get_int ( F_STAMPA ) ;
if ( _tipo_stampa = = 1 )
{
_datalim = m . get ( F_DATALIM ) ;
_print_exercise = TRUE ;
if ( _annoes = = 0 )
{
_print_exercise = FALSE ;
_annoes = date2esc ( _datalim ) ;
}
if ( _annoes ! = 0 )
_dataini = InizioEsercizio ( _annoes ) ;
else
_dataini = _inizioEs ;
}
bil_sez_contr ( ) ;
}
else
{
printer ( ) . footerlen ( 5 ) ;
2002-07-02 16:21:23 +00:00
_stampa_width = ( m . get_int ( F_MODULO ) = = 1 ) ? 132 : 148 ; //perche' questo e' in realta' il margine dx (vedi es. di stampa AS/400)
2002-05-08 16:25:49 +00:00
_verifica = m . get_int ( F_VERIFICA ) ;
if ( ( _verifica = = 1 ) | | ( _verifica = = 2 ) )
2003-02-25 15:20:00 +00:00
_prog = new TProgind ( _pcn - > items ( ) , TR ( " Elaborazione in corso... " ) , FALSE ) ;
2002-05-08 16:25:49 +00:00
_tipo_stampa1 = m . get_int ( F_STAMPA1 ) ;
if ( _tipo_stampa1 = = 1 )
{
if ( _annoes ! = 0 )
_dataini = InizioEsercizio ( _annoes ) ;
else
_dataini = _inizioEs ;
_datada = m . get ( F_DATADA ) ;
_dataa = m . get ( F_DATAA ) ;
}
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 ) ) ;
if ( _situazione . not_empty ( ) )
_cur - > setfilter ( format ( " TIPOCF= \" %s \" " , ( const char * ) _situazione ) ) ;
else
_cur - > setfilter ( " " ) ;
_clienti . destroy ( ) ;
_fornitori . destroy ( ) ;
leggi_pcon ( ) ;
2002-12-20 16:15:03 +00:00
crea_sort_clifo ( ) ; // Crea la sua _prog
2002-05-08 16:25:49 +00:00
_sort - > endsort ( ) ;
}
}
2002-12-20 16:15:03 +00:00
if ( _prog )
delete _prog ;
2002-05-08 16:25:49 +00:00
print ( ) ;
}
1997-10-16 08:47:25 +00:00
bool TStampa_bilanci : : set_print ( int )
1995-07-21 10:12:15 +00:00
{
TMask m ( " cg1500a " ) ;
2002-07-02 16:21:23 +00:00
m . set_handler ( F_VERIFICA , verifica_handler ) ;
1996-07-09 13:00:08 +00:00
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 ) ;
2002-07-02 16:21:23 +00:00
m . set_handler ( F_DACDC , cdc_handler ) ;
m . set_handler ( F_ACDC , cdc_handler ) ;
2002-05-08 16:25:49 +00:00
while ( m . run ( ) = = K_ENTER )
1995-07-21 10:12:15 +00:00
{
1997-10-16 08:47:25 +00:00
_annoes = m . get_int ( F_ANNO ) ;
_bilancio = m . get_int ( F_BILANCIO ) ;
_data = m . get ( F_DATASTAMPA ) ;
1996-06-19 14:04:56 +00:00
_stampa_mov_prov = m . get_int ( F_STAMPAMPROV ) ;
_quadratura = m . get_bool ( F_QUADRATURA ) ;
2002-12-20 16:15:03 +00:00
_hide_clifo = m . get_bool ( F_HIDE_CLIFO ) ;
1997-10-16 08:47:25 +00:00
_noseparator = m . get_bool ( F_SEPARATOR ) ;
1996-06-19 14:04:56 +00:00
2002-09-13 14:06:05 +00:00
if ( m . field ( F_DACDC ) . active ( ) & & ( m . get ( F_DACDC ) . not_empty ( ) | | m . get ( F_ACDC ) . not_empty ( ) ) )
2002-05-08 16:25:49 +00:00
{
2002-07-02 16:21:23 +00:00
TRelation cdcrel ( " CMS " ) ;
TRectype da_cdc ( cdcrel . curr ( ) ) , a_cdc ( cdcrel . curr ( ) ) ;
2002-05-08 16:25:49 +00:00
da_cdc . put ( " CODTAB " , m . get ( F_DACDC ) ) ;
a_cdc . put ( " CODTAB " , m . get ( F_ACDC ) ) ;
2002-07-02 16:21:23 +00:00
TCursor cdccur ( & cdcrel , " " , 1 , & da_cdc , & a_cdc ) ;
const TRecnotype cdc_items = cdccur . items ( ) ;
cdccur . freeze ( ) ;
TRelation fscrel ( " FSC " ) ;
TRectype da_fsc ( fscrel . curr ( ) ) , a_fsc ( fscrel . curr ( ) ) ;
da_fsc . put ( " CODTAB " , m . get ( F_DAFSC ) ) ;
a_fsc . put ( " CODTAB " , m . get ( F_AFSC ) ) ;
TCursor fsccur ( & fscrel , " " , 1 , & da_fsc , & a_fsc ) ;
const TRecnotype fsc_items = fsccur . items ( ) ;
fsccur . freeze ( ) ;
for ( cdccur = 0L ; cdccur . pos ( ) < cdc_items ; + + cdccur )
2002-05-08 16:25:49 +00:00
{
2002-07-02 16:21:23 +00:00
_cdc = cdccur . curr ( ) . get ( " CODTAB " ) ;
if ( ! da_fsc . empty ( ) | | ! a_fsc . empty ( ) )
{
for ( fsccur = 0L ; fsccur . pos ( ) < fsc_items ; + + fsccur )
{
_fsc = fsccur . curr ( ) . get ( " CODTAB " ) ;
stampa_un_bilancio ( m ) ;
}
}
else
{
_fsc . cut ( 0 ) ;
stampa_un_bilancio ( m ) ;
}
1995-07-21 10:12:15 +00:00
}
}
else
{
2002-07-02 16:21:23 +00:00
_cdc . cut ( 0 ) ; _fsc . cut ( 0 ) ;
2002-05-08 16:25:49 +00:00
stampa_un_bilancio ( m ) ;
1995-07-21 10:12:15 +00:00
}
}
return FALSE ;
}
1995-11-30 09:39:32 +00:00
TRectype & look_com ( const char * cod , TLocalisamfile * comuni )
1995-07-21 10:12:15 +00:00
{
comuni - > zero ( ) ;
comuni - > put ( COM_COM , cod ) ;
comuni - > read ( ) ;
if ( comuni - > bad ( ) )
comuni - > zero ( ) ;
return comuni - > curr ( ) ;
}
1997-10-16 08:47:25 +00:00
void TStampa_bilanci : : get_dati_ditta ( )
1995-07-21 10:12:15 +00:00
{
TLocalisamfile nditte ( LF_NDITTE ) ;
TLocalisamfile anag ( LF_ANAG ) ;
TString codanagr ;
TString tipoa ;
nditte . zero ( ) ;
nditte . put ( NDT_CODDITTA , get_firm ( ) ) ;
nditte . read ( ) ;
if ( nditte . bad ( ) ) nditte . zero ( ) ;
codanagr = nditte . get ( NDT_CODANAGR ) ;
tipoa = nditte . get ( NDT_TIPOA ) ;
_ragsoc = nditte . get ( NDT_RAGSOC ) ;
anag . setkey ( 1 ) ;
anag . zero ( ) ;
anag . put ( ANA_TIPOA , tipoa ) ;
anag . put ( ANA_CODANAGR , codanagr ) ;
anag . read ( ) ;
if ( anag . bad ( ) ) anag . zero ( ) ;
_cofi = anag . get ( ANA_COFI ) ;
_paiva = anag . get ( ANA_PAIV ) ;
_comunefis = anag . get ( ANA_COMRF ) ;
if ( _comunefis . empty ( ) )
_comunefis = anag . get ( ANA_COMRES ) ;
TRectype dep = look_com ( _comunefis , _com ) ;
_comunefis = dep . get ( COM_DENCOM ) ;
_provfis = dep . get ( COM_PROVCOM ) ;
_cap = dep . get ( COM_CAPCOM ) ;
if ( _comunefis . empty ( ) )
{
_viafis = anag . get ( ANA_INDRF ) ;
_viafis . rtrim ( ) ;
_viafis < < " " < < anag . get ( ANA_CIVRF ) ;
}
else
{
_viafis = anag . get ( ANA_INDRES ) ;
_viafis . rtrim ( ) ;
_viafis < < " " < < anag . get ( ANA_CIVRES ) ;
}
}
1997-10-16 08:47:25 +00:00
int TStampa_bilanci : : stampa_intestazione_ditta ( )
1995-07-21 10:12:15 +00:00
{
int r = 1 ;
TString codice_ditta ;
TString riga ( _stampa_width ) ;
get_dati_ditta ( ) ;
codice_ditta < < get_firm ( ) ;
2003-02-25 15:20:00 +00:00
set_header ( r + + , " %s %s %s %s %s %s %s " , TR ( " Ditta " ) , ( const char * ) codice_ditta ,
1995-07-21 10:12:15 +00:00
( const char * ) _ragsoc , ( const char * ) _viafis ,
( const char * ) _cap , ( const char * ) _comunefis ,
( const char * ) _provfis ) ;
printer ( ) . setdate ( _data ) ;
2003-02-25 15:20:00 +00:00
riga = TR ( " Data " ) ; riga < < " @> " < < TR ( " Pag. " ) < < " @# " ;
2000-10-03 13:45:12 +00:00
riga . right_just ( _stampa_width - 10 ) ;
1997-10-16 08:47:25 +00:00
2003-02-25 15:20:00 +00:00
riga . overwrite ( format ( " %s %s %s %s " , TR ( " Partita iva " ) , ( const char * ) _paiva , TR ( " Codice fiscale " ) , ( const char * ) _cofi ) ) ;
2002-05-08 16:25:49 +00:00
set_header ( r + + , " %s " , ( const char * ) riga ) ;
1995-07-21 10:12:15 +00:00
return r ;
}
2002-05-08 16:25:49 +00:00
void TStampa_bilanci : : header_cdc ( int & r )
{
if ( _cdc . not_empty ( ) )
{
2002-07-02 16:21:23 +00:00
const TString & desc_cdc = cache ( ) . get ( " CMS " , _cdc , " S0 " ) ;
if ( _fsc . not_empty ( ) )
{
const TString & desc_fsc = cache ( ) . get ( " FSC " , _fsc , " S0 " ) ;
2003-02-25 15:20:00 +00:00
set_header ( r + + , " @b%s %s %s - %s %s %s " , TR ( " Commessa " ) ,
( const char * ) _cdc , ( const char * ) desc_cdc , TR ( " Fase " ) ,
2002-07-02 16:21:23 +00:00
( const char * ) _fsc , ( const char * ) desc_fsc ) ;
}
else
2003-02-25 15:20:00 +00:00
set_header ( r + + , " @b%s %s %s " , TR ( " Commessa " ) , ( const char * ) _cdc , ( const char * ) desc_cdc ) ;
2002-05-08 16:25:49 +00:00
}
}
1997-10-16 08:47:25 +00:00
void TStampa_bilanci : : preprocess_header ( )
1995-07-21 10:12:15 +00:00
{
int r ;
reset_header ( ) ;
r = stampa_intestazione_ditta ( ) ;
if ( _bilancio = = 1 ) //bilancio a sezioni contrapposte
{
TString riga ( 132 ) ;
TDate data_da ;
TString data ;
TString data_lim = _datalim . string ( ) ;
2003-02-25 15:20:00 +00:00
set_header ( r , TR ( " STAMPA BILANCIO A SEZIONI CONTRAPPOSTE " ) ) ;
1995-07-21 10:12:15 +00:00
if ( _tipo_stampa = = 1 )
{
data_da = _dataini . string ( ) ;
data = _datalim . string ( ) ;
2003-02-25 15:20:00 +00:00
set_header ( r , " @41g%s %s %s %s " , TR ( " dalla data " ) , ( const char * ) data_da , TR ( " alla data " ) ,
1995-07-21 10:12:15 +00:00
( const char * ) data ) ;
}
else if ( _tipo_stampa = = 2 )
2003-02-25 15:20:00 +00:00
set_header ( r , FR ( " @41gall'ultima immissione Es. %d " ) , _annoes ) ;
1995-07-21 10:12:15 +00:00
1996-03-11 08:06:41 +00:00
//modifica del 20/04/1995
1999-04-26 15:58:05 +00:00
if ( _print_exercise )
1996-03-11 08:06:41 +00:00
{
2003-02-25 15:20:00 +00:00
TString d1 ( InizioEsercizio ( _annoes ) . string ( ) ) ;
TString d2 ( FineEsercizio ( _annoes ) . string ( ) ) ;
set_header ( r , " @84g%s %s %s " , TR ( " Esercizio " ) , ( const char * ) d1 , ( const char * ) d2 ) ; /**/
1996-03-11 08:06:41 +00:00
}
1995-07-21 10:12:15 +00:00
r + + ;
2002-05-08 16:25:49 +00:00
header_cdc ( r ) ;
riga . fill ( ' _ ' ) ;
1995-07-21 10:12:15 +00:00
set_header ( r , ( const char * ) riga ) ;
r + + ;
riga = " " ;
set_header ( r , ( const char * ) riga ) ;
}
else // bilancio di verifica
{
TString riga ( _stampa_width ) ;
TString16 datada = _datada . string ( ) ;
TString16 dataa = _dataa . string ( ) ;
if ( _verifica = = 1 )
2003-02-25 15:20:00 +00:00
set_header ( r , TR ( " STAMPA BILANCIO DI VERIFICA " ) ) ;
1995-07-21 10:12:15 +00:00
else if ( _verifica = = 2 )
2003-02-25 15:20:00 +00:00
set_header ( r , TR ( " STAMPA SALDI DI MASTRO " ) ) ;
1995-07-21 10:12:15 +00:00
else
{
if ( _situazione = = " C " )
2003-02-25 15:20:00 +00:00
set_header ( r , TR ( " SITUAZIONE CONTABILE CLIENTI " ) ) ;
1995-07-21 10:12:15 +00:00
else if ( _situazione = = " F " )
2003-02-25 15:20:00 +00:00
set_header ( r , TR ( " SITUAZIONE CONTABILE FORNITORI " ) ) ;
else set_header ( r , TR ( " SITUAZIONE CLIENTI/FORNITORI " ) ) ;
1995-07-21 10:12:15 +00:00
}
if ( _tipo_stampa1 = = 1 )
{
2003-02-25 15:20:00 +00:00
set_header ( r , " @30g%s %s %s %s " , TR ( " dalla data " ) , ( const char * ) datada , TR ( " alla data " ) ,
( const char * ) dataa ) ;
1995-07-21 10:12:15 +00:00
//modifica del 20/04/1995
1996-03-11 08:06:41 +00:00
if ( _annoes ! = 0 ) //se l'anno e' 0 non si considera la competenza
{
1997-10-16 08:47:25 +00:00
TString16 d1 ( InizioEsercizio ( _annoes ) . string ( ) ) ;
TString16 d2 ( FineEsercizio ( _annoes ) . string ( ) ) ;
2003-02-25 15:20:00 +00:00
set_header ( r , " @74g%s %s %s " , TR ( " Esercizio " ) , ( const char * ) d1 , ( const char * ) d2 ) ; /**/
1996-03-11 08:06:41 +00:00
}
1995-07-21 10:12:15 +00:00
}
else if ( _tipo_stampa1 = = 2 )
{
2003-02-25 15:20:00 +00:00
set_header ( r , FR ( " @36gall'ultima immissione Es. %d " ) , _annoes ) ;
1995-07-21 10:12:15 +00:00
//modifica del 20/04/1995
1997-10-16 08:47:25 +00:00
TString16 d1 ( InizioEsercizio ( _annoes ) . string ( ) ) ;
TString16 d2 ( FineEsercizio ( _annoes ) . string ( ) ) ;
2003-02-25 15:20:00 +00:00
set_header ( r , " @72g%s %s %s " , TR ( " Esercizio " ) , ( const char * ) d1 , ( const char * ) d2 ) ; /**/
1995-07-21 10:12:15 +00:00
}
if ( ( _verifica = = 1 ) | | ( _verifica = = 2 ) )
{
if ( _stampav = = 1 )
2003-02-25 15:20:00 +00:00
set_header ( r , " @107g%s " , TR ( " Tutti i conti movimentati " ) ) ;
1995-07-21 10:12:15 +00:00
else if ( _stampav = = 2 )
2003-02-25 15:20:00 +00:00
set_header ( r , " @107g%s " , TR ( " Conti con saldo <> 0 " ) ) ;
1997-10-16 08:47:25 +00:00
else
2003-02-25 15:20:00 +00:00
set_header ( r , " @107g%s " , TR ( " Tutti i conti " ) ) ;
1995-07-21 10:12:15 +00:00
}
else
{
if ( _stampac = = 1 )
2003-02-25 15:20:00 +00:00
set_header ( r , " @107g%s " , TR ( " Tutti i conti movimentati " ) ) ;
1997-10-16 08:47:25 +00:00
else
2003-02-25 15:20:00 +00:00
set_header ( r , " @107g%s " , TR ( " Conti con saldo <> 0 " ) ) ;
1995-07-21 10:12:15 +00:00
}
r + + ;
2002-05-08 16:25:49 +00:00
header_cdc ( r ) ;
riga . fill ( ' _ ' ) ;
1995-07-21 10:12:15 +00:00
set_header ( r , ( const char * ) riga ) ;
r + + ;
1997-10-16 08:47:25 +00:00
2003-02-25 15:20:00 +00:00
TString h ( " @7g!@46g!@55g " ) ;
1995-07-21 10:12:15 +00:00
if ( ( ( _datada = = _dataini ) & & ( _tipo_stampa1 = = 1 ) ) | | ( _tipo_stampa1 ! = 1 ) )
{
1995-11-30 09:39:32 +00:00
if ( _tipo_stampa1 = = 1 & & _datada = = _dataini )
2003-02-25 15:20:00 +00:00
h < < TR ( " MOVIMENTI DI APERTURA " ) ;
1995-11-30 09:39:32 +00:00
else
2003-02-25 15:20:00 +00:00
h < < TR ( " SALDO INIZIALE " ) ;
1995-11-30 09:39:32 +00:00
}
2003-02-25 15:20:00 +00:00
else
if ( _tipo_stampa1 = = 1 )
set_header ( r , TR ( " PROGRESSIVI PRECEDENTI " ) ) ;
h < < " @80g!@88g " ;
h < < TR ( " MOVIMENTI DEL PERIODO " ) ;
set_header ( r , h ) ;
1997-10-16 08:47:25 +00:00
if ( ( _verifica = = 1 ) | | ( _verifica = = 3 ) )
set_header ( r , " @16g! " ) ;
1995-07-21 10:12:15 +00:00
1997-10-16 08:47:25 +00:00
set_header ( r , " @114g! " ) ;
if ( _stampa_width ! = 132 )
2003-02-25 15:20:00 +00:00
{
h = " @129g " ;
h < < TR ( " SALDO " ) ;
h < < " @148g! " ;
set_header ( r , h ) ;
}
1995-07-21 10:12:15 +00:00
r + + ;
if ( ( _verifica = = 1 ) | | ( _verifica = = 3 ) )
1997-10-16 08:47:25 +00:00
{
2003-02-25 15:20:00 +00:00
set_header ( r , FR ( " @2gcod. ! ultima !@46g!@47g%.67s@80g!@83g@114g! " ) , ( const char * ) riga ) ;
1995-07-21 10:12:15 +00:00
if ( _stampa_width = = 132 )
2003-02-25 15:20:00 +00:00
set_header ( r , FR ( " @121gSALDO " ) ) ;
1995-07-21 10:12:15 +00:00
else
1997-10-16 08:47:25 +00:00
set_header ( r , " %.33s@148g! " , ( const char * ) riga ) ;
r + + ;
2003-02-25 15:20:00 +00:00
set_header ( r , FR ( " @2gconto! data ! denominazione@46g!@53gDare@63g!@69gAvere@80g!@87gDare@97g!@103gAvere@114g! " ) ) ;
1997-10-16 08:47:25 +00:00
if ( _stampa_width ! = 132 )
2003-02-25 15:20:00 +00:00
set_header ( r , FR ( " @121gDare@131g!@137gAvere@148g! " ) ) ;
1997-10-16 08:47:25 +00:00
r + + ;
1995-07-21 10:12:15 +00:00
}
else
1997-10-16 08:47:25 +00:00
{
2003-02-25 15:20:00 +00:00
set_header ( r , FR ( " @2gcod. !@46g!@47g%.67s@80g!@83g@114g! " ) , ( const char * ) riga ) ;
1995-07-21 10:12:15 +00:00
if ( _stampa_width = = 132 )
2003-02-25 15:20:00 +00:00
set_header ( r , FR ( " @121gSALDO " ) ) ;
1995-07-21 10:12:15 +00:00
else
1997-10-16 08:47:25 +00:00
set_header ( r , " %.33s@148g! " , ( const char * ) riga ) ;
r + + ;
2003-02-25 15:20:00 +00:00
set_header ( r , FR ( " @1gmastro!descrizione@46g!@53gDare@63g!@69gAvere@80g!@87gDare@97g!@103gAvere@114g! " ) ) ;
1997-10-16 08:47:25 +00:00
if ( _stampa_width ! = 132 )
2003-02-25 15:20:00 +00:00
set_header ( r , FR ( " @121gDare@131g!@137gAvere@148g! " ) ) ;
1997-10-16 08:47:25 +00:00
r + + ;
1995-07-21 10:12:15 +00:00
}
set_header ( r , ( const char * ) riga ) ;
1997-10-16 08:47:25 +00:00
if ( _stampa_width ! = 132 )
1995-07-21 10:12:15 +00:00
set_header ( r , " @148g! " ) ;
}
}
int cg1500 ( int argc , char * argv [ ] )
{
1997-10-16 08:47:25 +00:00
TStampa_bilanci a ;
2003-02-25 15:20:00 +00:00
a . run ( argc , argv , TR ( " Stampa bilanci " ) ) ;
1995-07-21 10:12:15 +00:00
return 0 ;
}