1997-07-22 08:03:29 +00:00
//Stampa bilanci
// 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();
# include <mask.h>
# include <progind.h>
# include <printapp.h>
1998-11-04 18:04:26 +00:00
# include <sheet.h>
1997-07-22 08:03:29 +00:00
# include <sort.h>
# include <tabutil.h>
1998-11-04 18:04:26 +00:00
# include <urldefid.h>
1997-07-22 08:03:29 +00:00
# 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 "cgp1.h"
# include "cgp1200.h"
# include "cglib01.h"
# include "cglib02.h"
class TCGPSaldo
{
TString16 _codcaus ;
TDate _datareg ;
TDate _datacomp ;
TString _provv ;
real _saldo , _saldo_iniziale ;
int _annoes ;
bool _movimentato ;
bool _significativo ;
bool _rec_presente_ec ;
bool _rec_presente_ep ;
bool _prec ;
bool _movcas ;
long _cdc ;
TDecoder _causali_apertura ;
1999-04-06 15:34:39 +00:00
TExternisamfile * _mvcs ;
1997-07-22 08:03:29 +00:00
public :
bool significativo ( ) const { return _significativo ; }
bool esiste_saldo ( ) const { return _rec_presente_ec | | _rec_presente_ep ; }
bool data_limite_bilancio ( int , int , int , long , const TDate & , const TDate & , int , int ) ;
void set_annoes ( int anno ) { _annoes = anno ; }
const real & saldo ( ) const { return _saldo ; }
const real & saldoini ( ) const { return _saldo_iniziale ; }
const bool flagprec ( ) { return _prec ; }
1999-04-06 15:34:39 +00:00
TCGPSaldo ( bool m , long c , TExternisamfile * mc ) ;
1997-07-22 08:03:29 +00:00
} ;
1999-04-06 15:34:39 +00:00
TCGPSaldo : : TCGPSaldo ( bool m , long c , TExternisamfile * mc ) : _movcas ( m ) , _cdc ( c ) , _mvcs ( mc ) ,
1997-07-22 08:03:29 +00:00
_causali_apertura ( LF_CAUSALI , CAU_MOVAP ) , _saldo_iniziale ( ZERO ) , _saldo ( ZERO ) ,
_annoes ( 0 ) , _prec ( FALSE ) , _movimentato ( FALSE ) , _significativo ( FALSE )
{ }
//per bilancio scalare (ovvero a sezioni contrapposte) per data limite
bool TCGPSaldo : : data_limite_bilancio ( int bilancio , int g , int c , long s , const TDate & data_inf ,
const TDate & data_sup , int indbil , int stp_prov )
{
1999-04-06 15:34:39 +00:00
// TExternisamfile movcas("$movcas");
1997-07-22 08:03:29 +00:00
TLocalisamfile xmov ( LF_RMOV ) ;
1999-04-06 15:34:39 +00:00
TLocalisamfile & rmov = _movcas ? ( TLocalisamfile & ) ( * _mvcs ) : xmov ;
1997-07-22 08:03:29 +00:00
TLocalisamfile mov ( LF_MOV ) ;
_saldo_iniziale = ZERO ;
_saldo = ZERO ;
_movimentato = FALSE ;
_rec_presente_ep = FALSE ;
_rec_presente_ec = FALSE ;
_prec = FALSE ;
rmov . setkey ( 2 ) ;
rmov . zero ( ) ;
rmov . put ( RMV_GRUPPO , g ) ;
rmov . put ( RMV_CONTO , c ) ;
rmov . put ( RMV_SOTTOCONTO , s ) ;
// Anche se non movimentato vado a vedere il saldo
/*
if ( stp_prov ! = 3 )
_saldo = calcola_saldo_iniziale ( g , c , s , indbil ) ;
*/
# ifdef DBG
long num_rec = 0 ;
const clock_t clock_start = clock ( ) ;
# endif
for ( rmov . read ( _isgteq ) ; ! rmov . eof ( ) ; rmov . next ( ) )
{
const int gruppo = rmov . get_int ( RMV_GRUPPO ) ;
const int conto = rmov . get_int ( RMV_CONTO ) ;
const long sottoconto = rmov . get_long ( RMV_SOTTOCONTO ) ;
if ( gruppo ! = g | | conto ! = c | | sottoconto ! = s )
break ;
if ( _cdc ! = 0L )
if ( rmov . get_long ( RMV_NUMGIO ) ! = _cdc ) // Filtro per centro di costo
continue ;
# ifdef DBG
num_rec + + ;
if ( ( num_rec & 0x7F ) = = 0 )
{
const double sec = ( clock ( ) - clock_start ) / CLOCKS_PER_SEC ;
if ( sec > 0.0 )
{
TString80 msg ;
msg . format ( " %ld records at %ld rec/sec " , num_rec , long ( num_rec / sec ) ) ;
xvt_statbar_set ( msg ) ;
do_events ( ) ;
}
}
# endif
const long num_reg = rmov . get_long ( RMV_NUMREG ) ;
TDate data_mov ;
// Leggo la testata
mov . put ( MOV_NUMREG , num_reg ) ;
const bool ok = mov . read ( ) = = NOERR ;
if ( ok )
{
_codcaus = mov . get ( MOV_CODCAUS ) ;
_datareg = mov . get ( MOV_DATAREG ) ;
_provv = mov . get ( MOV_PROVVIS ) ; // _provv.trim();
_datacomp = mov . get ( MOV_DATACOMP ) ;
}
else
NFCHECK ( " Testata assente: %ld " , num_reg ) ;
if ( _movcas ) // Se movimento di cassa, corregge _datareg e _datacomp
{
_datareg = rmov . get ( RMV_DATAREG ) ;
_datacomp = _datareg ;
}
if ( bilancio = = DataLimite )
data_mov = _datacomp ;
else
{
if ( _annoes = = 0 )
data_mov = _datareg ;
else
data_mov = _datacomp ;
}
if ( data_mov < data_inf | | data_mov > data_sup )
continue ;
// "Se la causale del movimento e' di chiusura,
// o di apertura il movimento non va considerato"
if ( _codcaus . not_empty ( ) )
{
const TString & movap = _causali_apertura . decode ( _codcaus ) ;
if ( movap = = " C " )
continue ;
}
//bilancio normale (non comprende i provvisori) ?
if ( stp_prov = = 1 & & _provv . not_empty ( ) )
continue ;
//bilancio dei soli provvisori ?
if ( stp_prov = = 3 & & _provv . empty ( ) )
continue ;
const char sezione = rmov . get_char ( RMV_SEZIONE ) ;
const real importo = rmov . get ( RMV_IMPORTO ) ;
// I mov. di puro riferimento (= con importo = 0) vanno scartati
if ( importo = = ZERO )
continue ;
_movimentato = TRUE ;
if ( sezione = = ' D ' )
_saldo + = importo ;
else
_saldo - = importo ;
}
# ifdef DBG
xvt_statbar_refresh ( ) ;
# endif
return _movimentato ;
}
class TStampaBilanciCDC_application : public TPrintapp
{
static bool mask_anno ( TMask_field & f , KEY k ) ;
static bool mask_datalim ( TMask_field & f , KEY k ) ;
static bool my_handler ( TMask_field & f , KEY k ) ;
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 ) ;
1998-11-04 18:04:26 +00:00
static bool fr_cdc_handler ( TMask_field & f , KEY k ) ;
static bool to_cdc_handler ( TMask_field & f , KEY k ) ;
static bool select_button ( TMask_field & f , KEY k ) ;
static bool reset_button ( TMask_field & f , KEY k ) ;
1997-07-22 08:03:29 +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 ;
} ;
cli_for * _cf ;
TSort * _sort ;
const char * _buff ;
1998-11-04 18:04:26 +00:00
TMask * _mask ;
1997-07-22 08:03:29 +00:00
TRelation * _rel ;
TCursor * _cur ;
TProgind * _prog ;
TSaldi_list * _listacf , * _lista ;
1998-11-04 18:04:26 +00:00
TArray_sheet * _cdc_sheet ;
1997-07-22 08:03:29 +00:00
TLocalisamfile * _com , * _pcn , * _mov , * _rmov , * _clifo , * _saldi , * _nditte , * _anag , * _caus ;
1999-04-06 15:34:39 +00:00
TExternisamfile * _mvcs ;
1997-07-22 08:03:29 +00:00
TIsamtempfile * _tmp_saldi_att , * _tmp_saldi_pass , * _tmp_saldi_conti_uno ;
TIsamtempfile * _tmp_saldi_costi , * _tmp_saldi_ricavi , * _tmp_saldi_conti_due ;
1998-11-04 18:04:26 +00:00
TTable * _esc , * _cdc_table ;
1997-07-22 08:03:29 +00:00
TParagraph_string * _d ;
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 ;
TString _cdc_descr ;
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 ;
long _cdc_cod ;
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 ;
bool _sottoc_dare , _sottoc_avere , _salto_pagina1 , _livello_conto ;
bool _mov_ap , _quadratura ;
bool _movcas_print ;
int _stampa_mov_prov ;
//TString _causale_ap, _causale_chi;
TArray _clienti , _fornitori ;
2001-05-01 08:17:07 +00:00
TString TMP ;
TString _extra_picture , _total_picture ;
1997-07-22 08:03:29 +00:00
public :
TDate _inizioEs , _fineEs ;
int date2esc ( const TDate & d , int * prevesc = NULL ) ;
1998-11-04 18:04:26 +00:00
void reset_choices ( TMask & ) ;
void set_choice_limits ( TMask & ) ;
long select_cdc_range ( long from , long to ) ;
1997-07-22 08:03:29 +00:00
bool menu ( MENU_TAG m ) { return TPrintapp : : menu ( m ) ; }
virtual bool user_create ( ) ;
virtual bool user_destroy ( ) ;
bool set_print ( int ) ;
void next_c ( ) ;
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 ( ) ;
void leggi_clifo ( const TArray & ) ;
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 ( ) ;
void scrivis_file_temp ( int , int , long , real ) ;
void leggi_files_dare ( TIsamtempfile * ) ;
void leggi_files_avere ( TIsamtempfile * ) ;
void leggi_file_tmp ( ) ;
void stampa_riga_totali ( int ) ;
void stampa_prima_colonna ( int , int , long , const char * , const real & ) ;
void stampa_seconda_colonna ( int , int , long , const char * , const real & ) ;
void stampa_totali ( ) ;
void 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 ) ;
TStampaBilanciCDC_application ( ) { }
} ;
HIDDEN inline TStampaBilanciCDC_application & app ( ) { return ( TStampaBilanciCDC_application & ) main_app ( ) ; }
TDate InizioEsercizio ( int anno )
{
TTable TabEs ( " ESC " ) ;
TString16 codtab ;
TDate inizio_es ;
TabEs . zero ( ) ;
codtab . format ( " %04d " , anno ) ;
TabEs . put ( " CODTAB " , codtab ) ;
TabEs . read ( ) ;
if ( TabEs . good ( ) )
inizio_es = TabEs . get_date ( " D0 " ) ;
return inizio_es ;
}
TDate FineEsercizio ( int anno )
{
TTable TabEs ( " ESC " ) ;
TString16 codtab ;
TDate fine_es ;
TabEs . zero ( ) ;
codtab . format ( " %04d " , anno ) ;
TabEs . put ( " CODTAB " , codtab ) ;
TabEs . read ( ) ;
if ( TabEs . good ( ) )
fine_es = TabEs . get_date ( " D1 " ) ;
return fine_es ;
}
bool IsEsercizio ( const TDate & datalim , int anno_eser )
{
TTable TabEs ( " ESC " ) ;
TString16 codtab ;
TDate inizio , fine ;
TabEs . zero ( ) ;
codtab . format ( " %04d " , anno_eser ) ;
TabEs . put ( " CODTAB " , codtab ) ;
TabEs . read ( ) ;
if ( TabEs . good ( ) )
{
inizio = TabEs . get_date ( " D0 " ) ;
fine = TabEs . get_date ( " D1 " ) ;
}
if ( datalim > = inizio & & datalim < = fine )
return TRUE ;
return FALSE ;
}
int TStampaBilanciCDC_application : : date2esc ( const TDate & d , int * prevesc )
{
if ( prevesc ) * prevesc = 0 ;
TTable esc ( " ESC " ) ;
for ( int err = esc . first ( ) ; err = = NOERR ; err = esc . next ( ) )
{
const TDate ia ( esc . get ( " D0 " ) ) ; // Data inizio esercizio
const TDate fa ( esc . get ( " D1 " ) ) ; // Data fine esercizio
const anno = esc . get_int ( " CODTAB " ) ;
app ( ) . _inizioEs = ia ;
app ( ) . _fineEs = fa ;
if ( d > = ia & & d < = fa )
return anno ;
if ( prevesc ) * prevesc = anno ;
}
return 0 ;
}
bool TStampaBilanciCDC_application : : mask_anno ( TMask_field & f , KEY k )
{
if ( k = = K_TAB | | f . focusdirty ( ) )
{
int anno = f . mask ( ) . get_int ( F_ANNO ) ;
int bilancio = f . mask ( ) . get_int ( F_BILANCIO ) ;
if ( ( bilancio = = 2 ) )
if ( anno ! = 0 )
{
f . mask ( ) . show ( F_DATADA ) ;
f . mask ( ) . show ( F_DATAA ) ;
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 ( 98 ) ;
f . mask ( ) . show ( 99 ) ;
f . mask ( ) . hide ( 96 ) ;
f . mask ( ) . hide ( 97 ) ;
}
}
if ( k = = K_TAB )
{
int tipo_bil = f . mask ( ) . get_int ( F_BILANCIO ) ;
if ( tipo_bil = = 2 & & f . mask ( ) . get_int ( F_ANNO ) = = 0 )
f . mask ( ) . show ( F_QUADRATURA ) ;
else
{
f . mask ( ) . set ( F_QUADRATURA , " " ) ;
f . mask ( ) . hide ( F_QUADRATURA ) ;
}
}
return TRUE ;
}
bool TStampaBilanciCDC_application : : mask_bilancio ( TMask_field & f , KEY k )
{
int tipo_bil , tipo_stp = 1 ;
TMask & m = f . mask ( ) ;
if ( k = = K_SPACE )
{
int tipo_stampa = 1 ;
int anno = m . get_int ( F_ANNO ) ;
int bilancio = m . get_int ( F_BILANCIO ) ;
if ( bilancio = = 1 ) //bilancio a sezioni contrapposte
m . disable_page ( 1 ) ;
else
m . enable_page ( 1 ) ;
if ( bilancio = = 1 | | bilancio = = 2 )
{
if ( bilancio = = 2 )
if ( anno ! = 0 )
{
m . show ( F_DATADA ) ;
m . show ( F_DATAA ) ;
m . show ( 96 ) ;
m . show ( 97 ) ;
m . hide ( 98 ) ;
m . hide ( 99 ) ;
}
else
{
m . show ( F_DATADA ) ;
m . show ( F_DATAA ) ;
m . show ( 98 ) ;
m . show ( 99 ) ;
m . hide ( 96 ) ;
m . hide ( 97 ) ;
}
}
tipo_bil = f . mask ( ) . get_int ( F_BILANCIO ) ;
if ( tipo_bil = = 2 & & f . mask ( ) . get_int ( F_ANNO ) = = 0 )
f . mask ( ) . show ( F_QUADRATURA ) ;
else
f . mask ( ) . hide ( F_QUADRATURA ) ;
}
return TRUE ;
}
bool TStampaBilanciCDC_application : : mask_datalim ( TMask_field & f , KEY k )
{
if ( k = = K_ENTER )
{
int anno = f . mask ( ) . get_int ( F_ANNO ) ;
int bilancio = f . mask ( ) . get_int ( F_BILANCIO ) ;
TDate datalim ( f . mask ( ) . get ( F_DATALIM ) ) ;
if ( bilancio = = 1 )
if ( anno ! = 0 )
{
if ( datalim . ok ( ) )
{
if ( ! IsEsercizio ( datalim , anno ) )
{
f . error_box ( " La data limite deve appartenere all'esercizio indicato " ) ;
return FALSE ;
}
}
else
f . mask ( ) . field ( F_DATALIM ) . set ( FineEsercizio ( anno ) ) ;
}
else //anno == 0
{
if ( ! datalim . ok ( ) )
{
f . error_box ( " La data limite e' obbligatoria " ) ;
return FALSE ;
}
long anno = app ( ) . date2esc ( datalim ) ;
if ( anno = = 0 )
{
f . error_box ( " La data limite deve appartenere ad un esercizio attivo della ditta " ) ;
return FALSE ;
}
f . mask ( ) . set ( F_ANNO , anno ) ;
}
}
return TRUE ;
}
bool TStampaBilanciCDC_application : : mask_date ( TMask_field & f , KEY k )
{
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 ) ;
int anno = app ( ) . date2esc ( data ) ;
TTable esc ( " ESC " ) ;
TString dep ( format ( " %04d " , anno ) ) ;
esc . zero ( ) ;
esc . put ( " CODTAB " , dep ) ;
if ( esc . read ( ) = = NOERR )
{
TDate dataini ( esc . get_date ( " D1 " ) ) ;
if ( data = = dataini & & bil = = 2 & & f . mask ( ) . get_int ( F_ANNO ) = = 0 )
f . mask ( ) . show ( F_QUADRATURA ) ;
else
f . mask ( ) . hide ( F_QUADRATURA ) ;
}
}
}
if ( k = = K_ENTER )
{
const short id = f . dlg ( ) ;
int anno = f . mask ( ) . get_int ( F_ANNO ) ;
int bilancio = f . mask ( ) . get_int ( F_BILANCIO ) ;
if ( bilancio = = 2 )
{
TDate data ( f . mask ( ) . get ( id ) ) ;
if ( anno ! = 0 )
{
if ( data . ok ( ) )
{
if ( ! IsEsercizio ( data , anno ) )
{
f . error_box ( " La data indicata deve essere all'interno dell'esercizio " ) ;
return FALSE ;
}
}
if ( ! data . ok ( ) )
{
if ( id = = F_DATADA )
f . mask ( ) . field ( F_DATADA ) . set ( InizioEsercizio ( anno ) ) ;
else if ( id = = F_DATAA )
f . mask ( ) . field ( F_DATAA ) . set ( FineEsercizio ( anno ) ) ;
}
app ( ) . _annoapp = anno ;
}
else
{
if ( ! data . ok ( ) )
{
f . error_box ( " Indicare una data appartenente ad un esercizio attivo della ditta " ) ;
return FALSE ;
}
else
{
//date2esc(datada);
//const TString16 ie(app()._inizioEs.string());
//const TString16 fe(app()._fineEs.string());
//if (datada < app()._inizioEs || dataa > app()._fineEs)
//{
// f.error_box("Le date devono essere comprese tra %s e %s",
// (const char*)ie, (const char*)fe);
// return FALSE;
//}
if ( id = = F_DATAA )
{
TDate from ( f . mask ( ) . get ( id - 1 ) ) ;
app ( ) . _annoapp = app ( ) . date2esc ( from ) ;
if ( app ( ) . _annoapp ! = app ( ) . date2esc ( data ) )
{
f . error_box ( " Le date devono appartenere ad uno stesso esercizio attivo della ditta " ) ;
return FALSE ;
}
if ( from > data )
{
f . error_box ( " La data limite inferiore non puo' essere maggiore della data limite superiore " ) ;
return FALSE ;
}
//f.mask().set(F_ANNO, anno);
}
}
}
}
}
return TRUE ;
}
bool TStampaBilanciCDC_application : : my_handler ( TMask_field & f , KEY k )
{
if ( k = = K_SPACE )
{
int verifica = atoi ( f . mask ( ) . get ( F_VERIFICA ) ) ;
if ( 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 ( 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 ) ;
}
}
return TRUE ;
}
1998-11-04 18:04:26 +00:00
/*
1997-07-22 08:03:29 +00:00
bool TStampaBilanciCDC_application : : movcascdc_handler ( TMask_field & f , KEY k )
{
if ( k = = K_ENTER )
{
const long cdc = atol ( f . get ( ) ) ;
const bool movcas = f . mask ( ) . get_bool ( F_MOVCAS ) ;
if ( cdc = = 0L & & ! movcas )
return f . error_box ( " Non e' stata selezionata ne' la stampa per cassa ne' per centro di costo. Eseguire la stampa bilanci standard. " ) ;
}
return TRUE ;
}
1998-11-04 18:04:26 +00:00
*/
long TStampaBilanciCDC_application : : select_cdc_range ( long from , long to )
{
if ( to = = 0l ) to = 9999999L ;
for ( int i = 0 ; i < _cdc_sheet - > items ( ) ; i + + )
{
TToken_string & c = _cdc_sheet - > row ( i ) ;
const long cod = c . get_long ( 1 ) ;
if ( cod > = from & & cod < = to )
_cdc_sheet - > check ( i ) ;
else
_cdc_sheet - > uncheck ( i ) ;
}
return _cdc_sheet - > checked ( ) ;
}
bool TStampaBilanciCDC_application : : fr_cdc_handler ( TMask_field & f , KEY key )
{
TMask & m = f . mask ( ) ;
if ( key = = K_F9 )
{
TMask & m = f . mask ( ) ;
TArray_sheet * sh = app ( ) . _cdc_sheet ;
sh - > disable_check ( ) ;
sh - > disable ( DLG_USER ) ;
if ( sh - > run ( ) = = K_ENTER )
{
app ( ) . select_cdc_range ( sh - > row ( sh - > selected ( ) ) . get_long ( 1 ) , m . get_long ( F_CDC_TO ) ) ;
app ( ) . set_choice_limits ( m ) ;
}
sh - > enable ( DLG_USER ) ;
}
else if ( key = = K_TAB & & f . focusdirty ( ) )
{
const long l = app ( ) . select_cdc_range ( m . get_long ( F_CDC_FR ) ,
m . get_long ( F_CDC_TO ) ) ;
app ( ) . set_choice_limits ( m ) ;
m . set ( F_SELECTED , l ) ;
}
else
if ( key = = K_ENTER )
{
const long selen = f . mask ( ) . get_long ( F_SELECTED ) ;
const bool movcas = f . mask ( ) . get_bool ( F_MOVCAS ) ;
if ( selen = = 0L & & ! movcas )
return f . error_box ( " Non e' stata selezionata ne' la stampa per cassa ne' per centro di costo. Eseguire la stampa bilanci standard. " ) ;
}
return TRUE ;
}
bool TStampaBilanciCDC_application : : to_cdc_handler ( TMask_field & f , KEY key )
{
TMask & m = f . mask ( ) ;
if ( key = = K_F9 )
{
TArray_sheet * sh = app ( ) . _cdc_sheet ;
TMask & m = f . mask ( ) ;
sh - > disable_check ( ) ;
sh - > disable ( DLG_USER ) ;
if ( sh - > run ( ) = = K_ENTER )
{
app ( ) . select_cdc_range ( m . get_long ( F_CDC_FR ) , sh - > row ( sh - > selected ( ) ) . get_long ( 1 ) ) ;
app ( ) . set_choice_limits ( m ) ;
}
sh - > enable ( DLG_USER ) ;
}
if ( key = = K_TAB & & f . focusdirty ( ) )
{
const long l = app ( ) . select_cdc_range ( m . get_long ( F_CDC_FR ) ,
m . get_long ( F_CDC_TO ) ) ;
app ( ) . set_choice_limits ( m ) ;
m . field ( F_SELECTED ) . set ( format ( " %ld " , l ) ) ;
}
return TRUE ;
}
void TStampaBilanciCDC_application : : set_choice_limits ( TMask & m )
{
long first = - 1l , last = - 1l ;
for ( int i = 0 ; i < _cdc_sheet - > items ( ) ; i + + )
{
if ( _cdc_sheet - > checked ( i ) )
{
const long cod = _cdc_sheet - > row ( i ) . get_long ( 1 ) ;
if ( first = = - 1l ) first = cod ;
if ( last < cod ) last = cod ;
}
}
if ( first ! = - 1 ) m . set ( F_CDC_FR , first ) ;
if ( last ! = - 1 ) m . set ( F_CDC_TO , last ) ;
m . set ( F_SELECTED , _cdc_sheet - > checked ( ) ) ;
}
void TStampaBilanciCDC_application : : reset_choices ( TMask & m )
{
m . reset ( F_SELECTED ) ;
m . reset ( F_CDC_FR ) ;
m . reset ( F_CDC_TO ) ;
_cdc_sheet - > check ( - 1 , FALSE ) ;
}
bool TStampaBilanciCDC_application : : select_button ( TMask_field & f , KEY key )
{
if ( key = = K_SPACE )
{
app ( ) . _cdc_sheet - > enable_check ( ) ;
if ( app ( ) . _cdc_sheet - > run ( ) = = K_ENTER )
app ( ) . set_choice_limits ( f . mask ( ) ) ;
}
return TRUE ;
}
bool TStampaBilanciCDC_application : : reset_button ( TMask_field & f , KEY key )
{
if ( key = = K_SPACE )
app ( ) . reset_choices ( f . mask ( ) ) ;
return TRUE ;
}
1997-07-22 08:03:29 +00:00
void TStampaBilanciCDC_application : : scrivig_file_temp ( )
{
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 ) ;
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 ) ;
if ( tmp - > read ( ) = = NOERR )
{
tmp - > put ( SLD_CONTO , 0 ) ;
tmp - > put ( SLD_SOTTOCONTO , 0L ) ;
tmp - > put ( nome_campo , valore ) ;
tmp - > rewrite ( ) ;
}
else
{
tmp - > put ( SLD_GRUPPO , _gp ) ;
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 ) ;
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 ) ;
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 ) ;
if ( tmp - > read ( ) = = NOERR )
{
tmp - > put ( SLD_CONTO , 0 ) ;
tmp - > put ( SLD_SOTTOCONTO , 0L ) ;
tmp - > put ( nome_campo , valore ) ;
tmp - > rewrite ( ) ;
}
else
{
tmp - > put ( SLD_GRUPPO , _gp ) ;
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 ) ;
tmp - > put ( nome_campo , valore ) ;
tmp - > write ( ) ;
}
}
}
_add_dare = _add_avere = FALSE ;
}
void TStampaBilanciCDC_application : : scrivic_file_temp ( )
{
TIsamtempfile * tmp = NULL ;
TString nome_campo ( 12 ) ;
real valore ;
if ( _add_file_dare )
{
_add_dare = TRUE ;
nome_campo = SLD_PDARE ;
valore = _conto_da ;
if ( _indbil = = 1 | | _indbil = = 2 ) tmp = _tmp_saldi_att ; // da stampare a sx
else
if ( _indbil = = 3 | | _indbil = = 4 ) tmp = _tmp_saldi_costi ; //da stampare a sx
else
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 ( ) ;
}
/*
tmp - > zero ( ) ;
tmp - > put ( SLD_GRUPPO , _gp ) ;
tmp - > put ( SLD_CONTO , _cp ) ;
tmp - > put ( SLD_SOTTOCONTO , 0L ) ;
tmp - > put ( nome_campo , valore ) ;
tmp - > write ( ) ;
*/
}
void TStampaBilanciCDC_application : : scrivis_file_temp ( int g , int c , long s , real saldo )
{
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 ;
}
tmp - > zero ( ) ;
tmp - > put ( SLD_GRUPPO , g ) ;
tmp - > put ( SLD_CONTO , c ) ;
tmp - > put ( SLD_SOTTOCONTO , s ) ;
tmp - > put ( nome_campo , saldo ) ;
tmp - > write ( ) ;
}
real TStampaBilanciCDC_application : : compensazione ( bool compensa , int indbil_conto , real & sld )
{
real saldo = sld ;
if ( ! compensa )
{
switch ( indbil_conto )
{
case 1 :
if ( saldo > ZERO )
_indbil = indbil_conto ;
else
{
_indbil = 2 ;
saldo = - saldo ;
}
break ;
case 3 :
if ( saldo > ZERO )
_indbil = indbil_conto ;
else
{
_indbil = 4 ;
saldo = - saldo ;
}
break ;
case 2 :
if ( saldo < ZERO )
{
_indbil = indbil_conto ;
saldo = - saldo ;
}
else
_indbil = 1 ;
break ;
case 4 :
if ( saldo < ZERO )
{
_indbil = indbil_conto ;
saldo = - saldo ;
}
else
_indbil = 3 ;
break ;
case 5 :
default : break ;
}
}
else //e' richiesta la compensazione
if ( indbil_conto = = 2 | | indbil_conto = = 4 )
saldo = - saldo ;
return saldo ;
}
void TStampaBilanciCDC_application : : next_c ( )
{
TRecnotype recnum = _pcn - > recno ( ) ;
_pcn - > next ( ) ;
if ( _pcn - > eof ( ) )
{
scrivic_file_temp ( ) ;
scrivig_file_temp ( ) ;
}
_pcn - > readat ( recnum ) ;
}
bool TStampaBilanciCDC_application : : bil_sez_contr ( )
{
1999-04-06 15:34:39 +00:00
TCGPSaldo sld ( _movcas_print , _cdc_cod , _mvcs ) ;
1997-07-22 08:03:29 +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 " ) ;
1998-11-04 18:04:26 +00:00
_tmp_saldi_att = new TIsamtempfile ( LF_SALDI , " cg01 " , TRUE , TRUE ) ;
1997-07-22 08:03:29 +00:00
_prog - > addstatus ( 1 ) ;
1998-11-04 18:04:26 +00:00
_tmp_saldi_pass = new TIsamtempfile ( LF_SALDI , " cg02 " , TRUE , TRUE ) ;
1997-07-22 08:03:29 +00:00
_prog - > addstatus ( 1 ) ;
1998-11-04 18:04:26 +00:00
_tmp_saldi_costi = new TIsamtempfile ( LF_SALDI , " cg03 " , TRUE , TRUE ) ;
1997-07-22 08:03:29 +00:00
_prog - > addstatus ( 1 ) ;
1998-11-04 18:04:26 +00:00
_tmp_saldi_ricavi = new TIsamtempfile ( LF_SALDI , " cg04 " , TRUE , TRUE ) ;
1997-07-22 08:03:29 +00:00
_prog - > addstatus ( 1 ) ;
1998-11-04 18:04:26 +00:00
_tmp_saldi_conti_uno = new TIsamtempfile ( LF_SALDI , " cg05 " , TRUE , TRUE ) ;
1997-07-22 08:03:29 +00:00
_prog - > addstatus ( 1 ) ;
1998-11-04 18:04:26 +00:00
_tmp_saldi_conti_due = new TIsamtempfile ( LF_SALDI , " cg06 " , TRUE , TRUE ) ;
1997-07-22 08:03:29 +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 ;
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 ) ;
indbil_conto = _pcn - > get_int ( PCN_INDBIL ) ;
dettaglio = ! _pcn - > get_bool ( PCN_STSOTTBIL ) ;
tipo_conto = _pcn - > get ( PCN_TMCF ) [ 0 ] ;
if ( ( tipo_conto = = ' C ' ) | | ( tipo_conto = = ' F ' ) )
{
saldo = ZERO ;
esiste_sc = ricerca_sottoc_clifo ( g , c , compensa ,
indbil_conto , saldo ) ;
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
movimentato = sld . data_limite_bilancio ( _bilancio , g , c , s , _dataini , _datalim , indbil_conto , _stampa_mov_prov ) ;
/*
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 ( ) )
{
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 ;
//error_box ("saldo = %s", saldo.string());
if ( saldo ! = ZERO )
saldo = compensazione ( compensa , indbil_conto , saldo ) ;
if ( _indbil = = 1 | | _indbil = = 2 )
{
//real app = sld.saldoini();
//bool flag = sld.flagprec();
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 ;
}
bool TStampaBilanciCDC_application : : ricerca_sottoc_clifo ( int g , int c , bool compensa , int indbil_conto , real & saldo )
{
1999-04-06 15:34:39 +00:00
TCGPSaldo sld ( _movcas_print , _cdc_cod , _mvcs ) ;
1997-07-22 08:03:29 +00:00
int aep = 0 ;
long s , items ;
bool esiste_sc = FALSE ;
bool movimentato = FALSE ;
if ( _annoes )
{
TEsercizi_contabili ese ;
aep = ese . pred ( _annoes ) ;
}
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
movimentato = sld . data_limite_bilancio ( _bilancio , g , c , s , _dataini , _datalim , indbil_conto , _stampa_mov_prov ) ;
1997-07-31 14:43:20 +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);
1997-07-22 08:03:29 +00:00
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 ;
//error_box ("saldo = %s", saldo.string());
if ( saldo ! = ZERO )
saldo = compensazione ( compensa , indbil_conto , saldo ) ;
if ( _indbil = = 1 | | _indbil = = 2 )
{
//real app = sld.saldoini();
if ( 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 ;
}
bool TStampaBilanciCDC_application : : bil_verifica ( )
{
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 ;
2000-10-03 13:45:12 +00:00
CHECK ( _tmp_saldi_att = = NULL , " Non posso riaprire cg01.dbf " ) ;
1998-11-04 18:04:26 +00:00
_tmp_saldi_att = new TIsamtempfile ( LF_SALDI , " cg01 " , TRUE , TRUE ) ;
1997-07-22 08:03:29 +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 ) ;
2000-10-03 13:45:12 +00:00
if ( ( ( ( _cp ! = - 1 ) & & ( c ! = _cp ) ) | | ( ( _gp ! = - 1 ) & & ( g ! = _gp ) ) ) & & esiste_sc )
1997-07-22 08:03:29 +00:00
{
if ( _verifica = = 2 )
2000-10-03 13:45:12 +00:00
{
1997-07-22 08:03:29 +00:00
if ( ! ( ( _stampav = = 2 ) & & ( saldo_conto = = 0 ) ) )
{
//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 ;
}
2000-10-03 13:45:12 +00:00
}
1997-07-22 08:03:29 +00:00
//scrivo il record del conto;
if ( ( _verifica = = 1 ) | | ( ( _verifica = = 2 ) & &
( ! ( ( _stampav = = 2 ) & & ( saldo_conto = = 0 ) ) ) ) )
{
scrivi_record_conto ( prg_conto_dare , prg_conto_avere , mov_conto_dare ,
mov_conto_avere , saldo_conto ) ;
esiste_conto = TRUE ;
}
_cp = c ;
_saldo_ini_conto_dare = 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 ;
}
2000-10-03 13:45:12 +00:00
if ( _verifica = = 2 & & ( _gp ! = - 1 & & g ! = _gp ) )
{
if ( ! esiste_conto )
1997-07-22 08:03:29 +00:00
{
_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 ;
}
2000-10-03 13:45:12 +00:00
else
1997-07-22 08:03:29 +00:00
{
//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 ;
}
2000-10-03 13:45:12 +00:00
}
1997-07-22 08:03:29 +00:00
if ( ( s = = 0 ) & & ( c ! = 0 ) ) //si tratta di un conto
{
tipo_conto = _pcn - > get ( PCN_TMCF ) [ 0 ] ;
indbil_conto = _pcn - > get_int ( PCN_INDBIL ) ;
if ( ( tipo_conto = = ' C ' ) | | ( tipo_conto = = ' F ' ) )
2000-10-03 13:45:12 +00:00
{
// Per CLIENTI/FORNITORI lascio la lettura dal file dei saldi
1997-07-22 08:03:29 +00:00
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 ) ;
if ( ( _verifica = = 2 ) & & ( _stampav = = 2 ) )
if ( saldo_conto = = 0 )
continue ;
if ( esiste_sc )
{
_gp = g ;
_cp = c ;
TRecnotype recnum = _pcn - > recno ( ) ;
_pcn - > next ( ) ;
if ( _pcn - > eof ( ) )
{
if ( _verifica = = 2 )
{
//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 ) ;
}
scrivi_record_conto ( prg_conto_dare , prg_conto_avere , mov_conto_dare ,
mov_conto_avere , saldo_conto ) ;
}
_pcn - > readat ( recnum ) ;
}
continue ;
}
}
if ( ( c = = 0 ) | | ( s = = 0 ) )
{
esiste_sc = FALSE ;
continue ;
}
saldo_finale = saldo_iniziale = ZERO ; //saldi relativi a ciascun sottoconto
_indbil = indbil_conto ;
2000-10-03 13:45:12 +00:00
1997-07-22 08:03:29 +00:00
if ( _tipo_stampa1 = = 1 ) //bil. di verifica per data limite
{
//modifica del 21/11/95
_mov_ap = FALSE ;
//modifica del 19/06/95
movimentato = calcola ( g , c , s ) ;
if ( _stampa_mov_prov ! = 3 )
{
if ( movimentato )
{
//modifica del 21/11/95
if ( _mov_ap )
saldo_iniziale = _saldo_ini_dare - _saldo_ini_avere ;
}
if ( ! movimentato ) //_mov_ap e' di sicuro FALSE
if ( indbil_conto = = 1 | | indbil_conto = = 2 | | indbil_conto = = 5 )
if ( _annoes ! = 0 )
{
// saldo_iniziale = sld.saldofin_esprec(_annoes,g,c,s);
//modifica del 21/11/95
if ( saldo_iniziale > ZERO )
_saldo_ini_dare = saldo_iniziale ;
2000-10-03 13:45:12 +00:00
else
_saldo_ini_avere = - saldo_iniziale ;
1997-07-22 08:03:29 +00:00
//fine
1997-07-31 16:19:05 +00:00
if ( _stampav = = 1 & & sld . significativo ( ) )
1997-07-22 08:03:29 +00:00
movimentato = TRUE ;
}
}
//if (movimentato)
// saldo_iniziale = _saldo_ini_dare - _saldo_ini_avere;
//movimentato = calcola(g,c,s);
if ( movimentato | | _stampav ! = 1 )
{
//saldo_iniziale = _saldo_ini_dare - _saldo_ini_avere;
_nuovo_tot_saldo_d + = _mov_periodo_dare ;
_nuovo_tot_saldo_a + = _mov_periodo_avere ;
_nuovo_tot_saldo_d + = _saldo_ini_dare ;
_nuovo_tot_saldo_a + = _saldo_ini_avere ;
//fine
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
}
2000-10-03 13:45:12 +00:00
1997-07-22 08:03:29 +00:00
if ( movimentato | | _stampav ! = 1 )
2000-10-03 13:45:12 +00:00
if ( ! ( saldo_finale = = ZERO & & _stampav = = 2 ) )
1997-07-22 08:03:29 +00:00
{
2000-10-03 13:45:12 +00:00
esiste_sc = TRUE ;
esiste_conto = TRUE ;
1997-07-22 08:03:29 +00:00
2000-10-03 13:45:12 +00:00
if ( _tipo_stampa1 = = 2 )
1997-07-22 08:03:29 +00:00
{
2000-10-03 13:45:12 +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 ;
}
1997-07-22 08:03:29 +00:00
}
2000-10-03 13:45:12 +00:00
//modifica del 21/11/1995
/*
1997-07-22 08:03:29 +00:00
if ( saldo_iniziale < ZERO )
_saldo_ini_conto_avere + = saldo_iniziale ;
else
_saldo_ini_conto_dare + = saldo_iniziale ;
2000-10-03 13:45:12 +00:00
*/
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
1997-07-22 08:03:29 +00:00
2000-10-03 13:45:12 +00:00
//scrivo il record relat. al sottoconto se non e' richiesto saldi di mastro
if ( _verifica ! = 2 )
1997-07-22 08:03:29 +00:00
{
2000-10-03 13:45:12 +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 ) )
1997-07-22 08:03:29 +00:00
{
2000-10-03 13:45:12 +00:00
//modifica del 21/11/1995
if ( _datada = = _dataini & & _tipo_stampa1 = = 1 )
{
//_tmp_saldi_att->put(SLD_PDARESCA,_saldo_ini_dare);
//_tmp_saldi_att->put(SLD_PAVERESCA,_saldo_ini_avere);
_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
//_tmp_saldi_att->put(SLD_PDARESCA,saldo_iniziale);
else if ( saldo_iniziale < ZERO )
{
saldo_iniziale = - saldo_iniziale ;
//_tmp_saldi_att->put(SLD_PAVERESCA,saldo_iniziale);
_tmp_saldi_att - > put ( SLD_PAVEREPRO , saldo_iniziale ) ; // W96SALDI del 05-06-96
}
}
1997-07-22 08:03:29 +00:00
}
2000-10-03 13:45:12 +00:00
else if ( _datada > _dataini )
{
//_tmp_saldi_att->put(SLD_PDARESCA,_prg_prec_dare);
//_tmp_saldi_att->put(SLD_PAVERESCA,_prg_prec_avere);
_tmp_saldi_att - > put ( SLD_PDAREPRO , _prg_prec_dare ) ; // W96SALDI del 05-06-96
_tmp_saldi_att - > put ( SLD_PAVEREPRO , _prg_prec_avere ) ;
}
_tmp_saldi_att - > put ( SLD_PDARE , _mov_periodo_dare ) ;
_tmp_saldi_att - > put ( SLD_PAVERE , _mov_periodo_avere ) ;
_tmp_saldi_att - > put ( SLD_SALDO , saldo_finale ) ;
_tmp_saldi_att - > put ( SLD_DATAULMOV , _u_max ) ;
_tmp_saldi_att - > write ( ) ;
1997-07-22 08:03:29 +00:00
}
2000-10-03 13:45:12 +00:00
_gp = g ;
_cp = c ;
1997-07-22 08:03:29 +00:00
}
2000-10-03 13:45:12 +00:00
TRecnotype recnum = _pcn - > recno ( ) ;
_pcn - > next ( ) ;
if ( _pcn - > eof ( ) )
1997-07-22 08:03:29 +00:00
{
2000-10-03 13:45:12 +00:00
if ( ( _verifica = = 2 ) & & esiste_conto )
1997-07-22 08:03:29 +00:00
{
2000-10-03 13:45:12 +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 ) ;
1997-07-22 08:03:29 +00:00
}
2000-10-03 13:45:12 +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 ) ;
1997-07-22 08:03:29 +00:00
}
2000-10-03 13:45:12 +00:00
_pcn - > readat ( recnum ) ;
}
return TRUE ;
1997-07-22 08:03:29 +00:00
}
//bilancio di verifica per data limite
bool TStampaBilanciCDC_application : : calcola ( int g , int c , long s )
{
char sezione , provvis ;
real importo ;
int annoe ;
long num_reg ;
TDate data_reg , data , datacomp ;
bool conto_mov = FALSE ;
1999-04-06 15:34:39 +00:00
//TExternisamfile movcas("$movcas");
1997-07-22 08:03:29 +00:00
TLocalisamfile xmov ( LF_RMOV ) ;
1999-04-06 15:34:39 +00:00
TLocalisamfile & rmov = _movcas_print ? ( TLocalisamfile & ) ( * _mvcs ) : xmov ;
1997-07-22 08:03:29 +00:00
TLocalisamfile mov ( LF_MOV ) ;
TDecoder causali ( LF_CAUSALI , CAU_MOVAP ) ;
_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 ;
rmov . setkey ( 2 ) ;
rmov . zero ( ) ;
rmov . put ( RMV_GRUPPO , g ) ;
if ( c ! = 0 )
rmov . put ( RMV_CONTO , c ) ;
if ( s ! = 0 )
rmov . put ( RMV_SOTTOCONTO , s ) ;
const TRectype rec ( rmov . curr ( ) ) ;
for ( int err = rmov . read ( _isgteq ) ; err = = NOERR ; err = rmov . next ( ) )
{
if ( rmov . curr ( ) ! = rec )
break ;
2000-10-03 13:45:12 +00:00
annoe = rmov . get_int ( RMV_ANNOES ) ;
data = rmov . get_date ( RMV_DATAREG ) ;
num_reg = rmov . get_long ( RMV_NUMREG ) ;
1997-07-22 08:03:29 +00:00
2000-10-03 13:45:12 +00:00
if ( _cdc_cod ! = 0L & & _cdc_cod ! = rmov . get_long ( RMV_CDC ) )
continue ;
1997-07-22 08:03:29 +00:00
mov . setkey ( 1 ) ;
mov . put ( MOV_NUMREG , num_reg ) ;
if ( mov . read ( ) ! = NOERR )
mov . zero ( ) ;
provvis = mov . get_char ( MOV_PROVVIS ) ;
datacomp = _movcas_print ? rmov . get_date ( RMV_DATAREG ) : mov . get_date ( MOV_DATACOMP ) ;
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 ;
const TString & codcaus = mov . get ( MOV_CODCAUS ) ;
const char causap = causali . decode ( codcaus ) [ 0 ] ;
if ( ! _quadratura & & causap = = ' C ' )
{
// 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 ;
}
sezione = rmov . get_char ( RMV_SEZIONE ) ;
importo = rmov . get_real ( RMV_IMPORTO ) ;
if ( _annoes = = 0 )
data_reg = data ;
else
data_reg = datacomp ;
if ( importo = = 0 )
continue ;
//calcolo i movimenti del periodo
if ( data_reg > = _datada & & data_reg < = _dataa )
if ( ( causap = = ' A ' & & _dataini ! = _datada ) | | ( causap ! = ' A ' ) )
{
conto_mov = TRUE ;
if ( sezione = = ' D ' )
_mov_periodo_dare + = importo ;
else _mov_periodo_avere + = importo ;
_u_max = fnc_max ( _u_max , data ) ;
}
//il saldo inizio es. e' dato dall'importo dare - importo avere di quei movimenti che hanno causale == apertura e data reg >= data inizio es. e <= data limite sup.
if ( _datada = = _dataini ) //calcolo il saldo iniziale
{
if ( causap = = ' A ' )
{
if ( ( data_reg > = _dataini ) & & ( data_reg < = _dataa ) )
{
if ( sezione = = ' D ' )
_saldo_ini_dare + = importo ;
else _saldo_ini_avere + = importo ;
_u_max = fnc_max ( _u_max , data ) ;
conto_mov = _mov_ap = TRUE ;
}
}
}
else if ( _datada > _dataini ) //calcolo i progressivi precedenti
if ( ( data_reg > = _dataini ) & & ( data_reg < _datada ) )
{
if ( sezione = = ' D ' )
_prg_prec_dare + = importo ;
2000-10-03 13:45:12 +00:00
else
_prg_prec_avere + = importo ;
1997-07-22 08:03:29 +00:00
_u_max = fnc_max ( _u_max , data ) ;
conto_mov = TRUE ;
}
}
return conto_mov ;
}
bool TStampaBilanciCDC_application : : ricerca_cf ( int g , int c , char tipocf , int ib , real & saldo_finale , real & saldo_iniziale ,
real & mov_conto_dare , real & mov_conto_avere , real & prg_conto_dare , real & prg_conto_avere , real & saldo_conto )
{
TSaldo sld ;
bool esiste_sc = FALSE ;
long s ;
int anno ;
if ( _tipo_stampa1 = = 1 )
anno = _annoapp ;
else anno = _annoes ;
_lista = new TSaldi_list ( g , c , anno ) ;
TRecnotype items = _lista - > items ( ) ;
for ( int i = 0 ; i < items ; i + + )
{
const TRectype * r = _lista - > saldi ( ) ;
if ( r = = NULL ) break ;
s = r - > get_long ( SLD_SOTTOCONTO ) ;
saldo_finale = saldo_iniziale = ZERO ; //saldi relativi a ciascun sottoconto
if ( _tipo_stampa1 = = 1 ) //bil. di verifica per data limite
{
/*
if ( ! calcola ( g , c , s ) ) //il conto non e' movimentato
if ( _stampav = = 1 | | _stampav = = 3 ) //per i C/F anche se seleziono -tutti i conti, voglio solo quelli movimentati
continue ;
*/
//modifica del 21/11/1995
_mov_ap = FALSE ;
//modifica del 19/06. Vedi appunti per capire
bool movimentato = calcola ( g , c , s ) ;
2000-10-03 13:45:12 +00:00
/*
1997-07-22 08:03:29 +00:00
if ( _stampa_mov_prov ! = 3 )
{
if ( movimentato )
{
//modifica del 21/11/1995
if ( _mov_ap )
saldo_iniziale = _saldo_ini_dare - _saldo_ini_avere ;
else
{
TLocalisamfile saldi ( LF_SALDI ) ;
saldi . zero ( ) ;
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
if ( saldi . read ( ) = = NOERR )
{
//se il saldo iniziale e' diverso da zero non lo devo considerare
//perche' l'ho gia' considerato nella funzione calcola
real ss = saldi . get_real ( SLD_SALDO ) ;
if ( ib = = 1 | | ib = = 2 | | ib = = 5 )
if ( ss = = ZERO & & _annoes ! = 0 ) //competenza!!!
{
saldo_iniziale + = sld . saldofin_esprec ( _annoes , g , c , s ) ;
//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 ;
1997-07-22 08:03:29 +00:00
//fine
}
}
}
}
2000-10-03 13:45:12 +00:00
else
{
1997-07-22 08:03:29 +00:00
if ( ib = = 1 | | ib = = 2 | | ib = = 5 )
if ( _annoes ! = 0 ) //cioe' se sto ragionando per competenza
{
saldo_iniziale = sld . saldofin_esprec ( _annoes , g , c , s ) ;
//modifica del 21/11/1995
2000-10-03 13:45:12 +00:00
if ( saldo_iniziale > = ZERO )
1997-07-22 08:03:29 +00:00
_saldo_ini_dare = saldo_iniziale ;
2000-10-03 13:45:12 +00:00
else
_saldo_ini_avere = - saldo_iniziale ;
1997-07-22 08:03:29 +00:00
//fine
movimentato = sld . significativo ( ) ;
}
2000-10-03 13:45:12 +00:00
}
1997-07-22 08:03:29 +00:00
}
2000-10-03 13:45:12 +00:00
*/
// Saldo iniziale <20> sempre nullo per centri di costo
_saldo_ini_dare = _saldo_ini_avere = saldo_iniziale = ZERO ;
1997-07-22 08:03:29 +00:00
if ( ! movimentato )
continue ;
//fine modifica
_nuovo_tot_saldo_d + = _mov_periodo_dare ;
_nuovo_tot_saldo_a + = _mov_periodo_avere ;
//modifica del 21/11/1995
/*
if ( saldo_iniziale > ZERO )
_nuovo_tot_saldo_d + = saldo_iniziale ;
else
{
real app = - saldo_iniziale ;
_nuovo_tot_saldo_a + = app ;
}
*/
_nuovo_tot_saldo_d + = _saldo_ini_dare ;
_nuovo_tot_saldo_a + = _saldo_ini_avere ;
//fine
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
}
2000-10-03 13:45:12 +00:00
else
{
//Attenzione! Nel caso di "tutti i conti" devono scendere solo i cli/for movimentati!!!
1997-07-22 08:03:29 +00:00
2000-10-03 13:45:12 +00:00
//modifica del 31/03/1995
bool movimentato = sld . ultima_immissione_verifica ( _annoes , g , c , s , ib , _stampa_mov_prov ) ;
1997-07-22 08:03:29 +00:00
2000-10-03 13:45:12 +00:00
if ( _stampa_mov_prov ! = 3 )
{
saldo_iniziale = sld . saldoini ( ) ;
if ( ! movimentato )
1997-07-22 08:03:29 +00:00
{
2000-10-03 13:45:12 +00:00
//if (_stampav == 1)
// continue;
//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 )
1997-07-22 08:03:29 +00:00
{
2000-10-03 13:45:12 +00:00
saldo_iniziale = sld . saldofin_esprec ( _annoes , g , c , s , FALSE ) ;
movimentato = sld . significativo ( ) ;
}
}
}
1997-07-22 08:03:29 +00:00
2000-10-03 13:45:12 +00:00
if ( ! movimentato )
continue ;
//fine modifica 31/03/1995
1997-07-22 08:03:29 +00:00
2000-10-03 13:45:12 +00:00
_mov_periodo_dare = sld . prgdare ( ) ;
_mov_periodo_avere = sld . prgavere ( ) ;
_prg_prec_dare = ZERO ;
_prg_prec_avere = ZERO ;
1997-07-22 08:03:29 +00:00
2000-10-03 13:45:12 +00:00
saldo_finale = saldo_iniziale + _mov_periodo_dare - _mov_periodo_avere ;
1997-07-22 08:03:29 +00:00
2000-10-03 13:45:12 +00:00
if ( saldo_finale = = ZERO )
if ( _stampav = = 2 )
continue ;
1997-07-22 08:03:29 +00:00
2000-10-03 13:45:12 +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 ;
1997-07-22 08:03:29 +00:00
}
2000-10-03 13:45:12 +00:00
}
1997-07-22 08:03:29 +00:00
esiste_sc = TRUE ;
//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
//fine
{
if ( saldo_iniziale < ZERO )
_saldo_ini_conto_avere + = saldo_iniziale ;
else
_saldo_ini_conto_dare + = saldo_iniziale ;
}
mov_conto_dare + = _mov_periodo_dare ;
mov_conto_avere + = _mov_periodo_avere ;
prg_conto_dare + = _prg_prec_dare ;
prg_conto_avere + = _prg_prec_avere ;
saldo_conto + = saldo_finale ; // somma algebrica!!!
//scrivo il record relat. al sottoconto se non e' richiesto saldi di mastro
if ( _verifica ! = 2 )
{
_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 ) )
{
//modifica del 21/11/1995
if ( _tipo_stampa1 = = 1 & & _datada = = _dataini )
{
//_tmp_saldi_att->put(SLD_PDARESCA,_saldo_ini_dare);
//_tmp_saldi_att->put(SLD_PAVERESCA,_saldo_ini_avere);
_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
//_tmp_saldi_att->put(SLD_PDARESCA,saldo_iniziale);
else if ( saldo_iniziale < ZERO )
{
saldo_iniziale = - saldo_iniziale ;
//_tmp_saldi_att->put(SLD_PAVERESCA,saldo_iniziale);
_tmp_saldi_att - > put ( SLD_PAVEREPRO , saldo_iniziale ) ; // W96SALDI del 05-06-96
}
}
}
else if ( _datada > _dataini )
{
//_tmp_saldi_att->put(SLD_PDARESCA,_prg_prec_dare);
//_tmp_saldi_att->put(SLD_PAVERESCA,_prg_prec_avere);
_tmp_saldi_att - > put ( SLD_PDAREPRO , _prg_prec_dare ) ; // W96SALDI del 05-06-96
_tmp_saldi_att - > put ( SLD_PAVEREPRO , _prg_prec_avere ) ;
}
_tmp_saldi_att - > put ( SLD_PDARE , _mov_periodo_dare ) ;
_tmp_saldi_att - > put ( SLD_PAVERE , _mov_periodo_avere ) ;
_tmp_saldi_att - > put ( SLD_SALDO , saldo_finale ) ;
_tmp_saldi_att - > put ( SLD_DATAULMOV , _u_max ) ;
_tmp_saldi_att - > write ( ) ;
}
}
delete _lista ;
2000-10-03 13:45:12 +00:00
_lista = NULL ;
1997-07-22 08:03:29 +00:00
return esiste_sc ;
}
void TStampaBilanciCDC_application : : scrivi_record_gruppo ( const real & prg_da ,
const real & prg_a , const real & mov_da , const real & mov_a , const real & s )
{
_tmp_saldi_att - > zero ( ) ;
_tmp_saldi_att - > put ( SLD_GRUPPO , _gp ) ;
_tmp_saldi_att - > put ( SLD_CONTO , 0 ) ;
_tmp_saldi_att - > put ( SLD_SOTTOCONTO , 0L ) ;
if ( ( _datada = = _dataini ) | | ( _tipo_stampa1 ! = 1 ) )
{
//modifica del 21/11/1995
if ( _datada = = _dataini & & _tipo_stampa1 = = 1 )
{
_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 ) ;
}
else
{
real app = _saldo_ini_gruppo_dare + _saldo_ini_gruppo_avere ;
if ( app > ZERO ) //va stampato in Dare
_tmp_saldi_att - > put ( SLD_PDAREPRO , app ) ; // W96SALDI del 05-06-96
else if ( app < ZERO )
{
app = - app ;
_tmp_saldi_att - > put ( SLD_PAVEREPRO , app ) ; // W96SALDI del 05-06-96
}
}
}
else if ( _datada > _dataini )
{
_tmp_saldi_att - > put ( SLD_PDAREPRO , prg_da ) ; // W96SALDI del 05-06-96
_tmp_saldi_att - > put ( SLD_PAVEREPRO , prg_a ) ;
}
_tmp_saldi_att - > put ( SLD_PDARE , mov_da ) ;
_tmp_saldi_att - > put ( SLD_PAVERE , mov_a ) ;
_tmp_saldi_att - > put ( SLD_SALDO , s ) ;
_tmp_saldi_att - > write ( ) ;
}
void TStampaBilanciCDC_application : : scrivi_record_conto ( const real & prg_da ,
const real & prg_a , const real & mov_da , const real & mov_a , const real & s )
{
_tmp_saldi_att - > zero ( ) ;
_tmp_saldi_att - > put ( SLD_GRUPPO , _gp ) ;
_tmp_saldi_att - > put ( SLD_CONTO , _cp ) ;
_tmp_saldi_att - > put ( SLD_SOTTOCONTO , 0L ) ;
if ( ( _datada = = _dataini ) | | ( _tipo_stampa1 ! = 1 ) )
{
//modifica del 21/11/1995
if ( _datada = = _dataini & & _tipo_stampa1 = = 1 )
{
_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 ) ;
}
else
{
real app = _saldo_ini_conto_dare + _saldo_ini_conto_avere ;
if ( app > ZERO ) //va stampato in Dare
_tmp_saldi_att - > put ( SLD_PDAREPRO , app ) ; // W96SALDI del 05-06-96
else if ( app < ZERO )
{
app = - app ;
_tmp_saldi_att - > put ( SLD_PAVEREPRO , app ) ; // W96SALDI del 05-06-96
}
}
}
else if ( _datada > _dataini )
{
_tmp_saldi_att - > put ( SLD_PDAREPRO , prg_da ) ; // W96SALDI del 05-06-96
_tmp_saldi_att - > put ( SLD_PAVEREPRO , prg_a ) ;
}
_tmp_saldi_att - > put ( SLD_PDARE , mov_da ) ;
_tmp_saldi_att - > put ( SLD_PAVERE , mov_a ) ;
_tmp_saldi_att - > put ( SLD_SALDO , s ) ;
_tmp_saldi_att - > write ( ) ;
}
void TStampaBilanciCDC_application : : init_sort ( )
{
_cf = new cli_for ;
_sort = new TSort ( sizeof ( cli_for ) ) ;
if ( _ordinamento = = 1 )
{
_sort - > addsortkey ( ( char * ) & ( _cf - > tipocf ) - ( char * ) & ( _cf - > tipocf ) , 1 ) ;
_sort - > addsortkey ( ( char * ) & ( _cf - > gruppo ) - ( char * ) & ( _cf - > tipocf ) , 3 ) ;
_sort - > addsortkey ( ( char * ) & ( _cf - > conto ) - ( char * ) & ( _cf - > tipocf ) , 3 ) ;
_sort - > addsortkey ( ( char * ) & ( _cf - > codcf ) - ( char * ) & ( _cf - > tipocf ) , 6 ) ;
}
else if ( _ordinamento = = 2 )
{
_sort - > addsortkey ( ( char * ) & ( _cf - > tipocf ) - ( char * ) & ( _cf - > tipocf ) , 1 ) ;
_sort - > addsortkey ( ( char * ) & ( _cf - > gruppo ) - ( char * ) & ( _cf - > tipocf ) , 3 ) ;
_sort - > addsortkey ( ( char * ) & ( _cf - > conto ) - ( char * ) & ( _cf - > tipocf ) , 3 ) ;
_sort - > addsortkey ( ( char * ) & ( _cf - > ragsoc ) - ( char * ) & ( _cf - > tipocf ) , 50 ) ;
}
_sort - > init ( ) ;
}
void TStampaBilanciCDC_application : : riempi_record ( char t , int g , int c , long s ,
const char * rs , const real & sd , const real & sa ,
const real & md , const real & ma , const real & sf )
{
_cf - > tipocf = t ;
sprintf ( _cf - > gruppo , " %03d " , g ) ;
sprintf ( _cf - > conto , " %03d " , c ) ;
sprintf ( _cf - > codcf , " %06ld " , s ) ;
sprintf ( _cf - > ragsoc , " %s " , rs ) ;
if ( s = = 999999L )
{
if ( ( _datada = = _dataini ) | | ( _tipo_stampa1 ! = 1 ) )
{
//modifica del 21/11/1995
if ( _tipo_stampa1 = = 1 & & _datada = = _dataini )
{
_cf - > saldodare = _saldo_ini_conto_dare ;
_cf - > saldoavere = _saldo_ini_conto_avere ;
}
else
//fine
{
real app = _saldo_ini_conto_dare + _saldo_ini_conto_avere ;
if ( app > ZERO ) //va stampato in Dare
{
_cf - > saldoavere = ZERO ;
_cf - > saldodare = app ;
}
else if ( app < ZERO )
{
app = - app ;
_cf - > saldodare = ZERO ;
_cf - > saldoavere = app ;
}
}
}
else if ( _datada > _dataini )
{
_cf - > saldodare = sd ;
_cf - > saldoavere = sa ;
}
}
else
{
_cf - > saldodare = sd ;
_cf - > saldoavere = sa ;
}
_cf - > movdare = md ;
_cf - > movavere = ma ;
_cf - > saldofinale = sf ;
_cf - > udata = _u_max ;
_sort - > sort ( ( const char * ) _cf ) ;
}
void TStampaBilanciCDC_application : : leggi_clifo ( const TArray & gccf )
{
TSaldo sld ;
TLocalisamfile saldi ( LF_SALDI , FALSE ) ;
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 ;
int anno ;
if ( _tipo_stampa1 = = 1 )
anno = _annoapp ;
else anno = _annoes ;
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 ;
ragsoc < < " " < < nome ;
}
TEsercizi_contabili ese ;
int aprec = ese . pred ( anno ) ;
saldi . zero ( ) ;
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 ) ;
saldi . put ( SLD_SOTTOCONTO , codcf ) ;
if ( saldi . read ( ) ! = NOERR )
{
//if (_tipo_stampa1 == 1) //bilancio per data limite
// continue;
//else
if ( _stampac = = 2 ) //se sono richiesti i conti movimentati
{ //esco, se no...
_indbil = cerca_indbil ( g , c ) ;
if ( _indbil = = 1 | | _indbil = = 2 | | _indbil = = 5 )
{
saldi . zero ( ) ;
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 ) ;
saldi . put ( SLD_SOTTOCONTO , codcf ) ;
if ( saldi . read ( ) ! = NOERR )
continue ;
}
}
}
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 ;
movavere = ZERO ;
saldo_iniziale = ZERO ;
if ( _tipo_stampa1 = = 1 ) //bilancio di verifica per data limite
{
//modifica del 21/11/1995
_mov_ap = FALSE ;
//modifica del 19/06/95
_indbil = cerca_indbil ( g , c ) ;
movimentato = calcola ( g , c , codcf ) ;
if ( _stampa_mov_prov ! = 3 )
if ( ! movimentato /* && _stampac!=1 */ )
if ( _indbil = = 1 | | _indbil = = 2 | | _indbil = = 5 )
if ( _annoes ! = 0 ) //cioe' se sto ragionando per competenza
{
saldo_iniziale = sld . saldofin_esprec ( _annoes , g , c , codcf ) ;
if ( saldo_iniziale > ZERO )
_saldo_ini_dare = saldo_iniziale ;
else _saldo_ini_avere = - saldo_iniziale ;
}
if ( movimentato )
{
//modifica del 21/11/1995
if ( _mov_ap )
saldo_iniziale = _saldo_ini_dare - _saldo_ini_avere ;
else
{
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 )
{
real s = saldi . get_real ( SLD_SALDO ) ;
if ( _stampa_mov_prov ! = 3 )
if ( _indbil = = 1 | | _indbil = = 2 | | _indbil = = 5 )
if ( s = = 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
}
}
}
}
//fine modifica del 19/06/95
//movimentato = calcola(g,c,codcf);
if ( movimentato | | _stampac ! = 1 | | saldo_iniziale ! = ZERO )
{
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 ;
}
}
//if (saldo_finale == ZERO)
// if (_stampac == 2)
// continue;
//se saldo_finale < 0 verra' stampato con una A, se no con una D
}
else //bilancio di verifica 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 )
if ( ! movimentato /* && _stampac!=1 */ )
if ( _indbil = = 1 | | _indbil = = 2 | | _indbil = = 5 )
1997-07-31 14:43:20 +00:00
saldo_iniziale = sld . saldofin_esprec ( anno , g , c , codcf , FALSE ) ;
1997-07-22 08:03:29 +00:00
if ( movimentato )
saldo_iniziale = sld . saldoini ( ) ;
if ( movimentato | | _stampac ! = 1 | | saldo_iniziale ! = ZERO )
{
_mov_periodo_dare = sld . prgdare ( ) ;
_mov_periodo_avere = sld . prgavere ( ) ;
_prg_prec_dare = ZERO ;
_prg_prec_avere = ZERO ;
saldo_finale = saldo_iniziale + _mov_periodo_dare - _mov_periodo_avere ;
}
//if (saldo_finale == ZERO)
// if (_stampac == 2)
// continue;
}
if ( movimentato | | _stampac ! = 1 | | saldo_iniziale ! = ZERO )
if ( ! ( saldo_finale = = ZERO & & _stampac = = 2 ) )
{
esiste_sc = TRUE ;
//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
{
if ( saldo_iniziale < ZERO )
_saldo_ini_conto_avere + = saldo_iniziale ;
else
_saldo_ini_conto_dare + = saldo_iniziale ;
}
//fine
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 ) )
{
//modifica del 21/11/1995
if ( _tipo_stampa1 = = 1 & & _datada = = _dataini )
{
saldodare = _saldo_ini_dare ;
saldoavere = _saldo_ini_avere ;
}
else
//
{
if ( saldo_iniziale > ZERO ) //va stampato in Dare
saldodare = saldo_iniziale ;
else if ( saldo_iniziale < ZERO )
{
saldo_iniziale = - saldo_iniziale ;
saldoavere = saldo_iniziale ;
}
}
}
else if ( _datada > _dataini )
{
saldodare = _prg_prec_dare ;
saldoavere = _prg_prec_avere ;
}
movdare = _mov_periodo_dare ;
movavere = _mov_periodo_avere ;
riempi_record ( tipocf , g , c , codcf , ragsoc , saldodare , saldoavere , movdare ,
movavere , saldo_finale ) ;
tipocfp = tipocf ;
_gp = g ;
_cp = c ;
}
}
}
if ( esiste_sc )
riempi_record ( tipocfp , _gp , _cp , 999999L , " zzzz " , prg_conto_dare , prg_conto_avere ,
mov_conto_dare , mov_conto_avere , saldo_conto ) ;
}
void TStampaBilanciCDC_application : : crea_sort_clifo ( )
{
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 ( ) ) ;
_prog = new TProgind ( nitems , " Elaborazione in corso... prego attendere " , FALSE ) ;
_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 ) ;
}
}
int TStampaBilanciCDC_application : : cerca_indbil ( int g , int c )
{
TLocalisamfile pconti ( LF_PCON ) ;
pconti . zero ( ) ;
pconti . put ( PCN_GRUPPO , g ) ;
if ( c ! = 0 )
pconti . put ( PCN_CONTO , c ) ;
pconti . put ( PCN_SOTTOCONTO , 0l ) ;
pconti . read ( ) ;
return pconti . get_int ( PCN_INDBIL ) ;
}
void TStampaBilanciCDC_application : : leggi_files_dare ( TIsamtempfile * file )
{
_gruppo_dare = file - > get_int ( SLD_GRUPPO ) ;
_conto_dare = file - > get_int ( SLD_CONTO ) ;
_sottoconto_dare = file - > get_long ( SLD_SOTTOCONTO ) ;
_saldo_dare = file - > get_real ( SLD_PDARE ) ;
_descr_dare = DescrizioneConto ( _gruppo_dare , _conto_dare , _sottoconto_dare , ' ' ) ;
_gc_corr_dare = format ( " %3d%3d " , _gruppo_dare , _conto_dare ) ;
if ( _gc_corr_dare ! = _gc_prec_dare )
{
_cambiato_conto_1 = TRUE ;
_gc_prec_dare = _gc_corr_dare ;
}
else if ( _sottoconto_dare ! = 0l )
_cambiato_conto_1 = FALSE ;
}
void TStampaBilanciCDC_application : : leggi_files_avere ( TIsamtempfile * file )
{
_gruppo_avere = file - > get_int ( SLD_GRUPPO ) ;
_conto_avere = file - > get_int ( SLD_CONTO ) ;
_sottoconto_avere = file - > get_long ( SLD_SOTTOCONTO ) ;
_saldo_avere = file - > get_real ( SLD_PAVERE ) ;
_descr_avere = DescrizioneConto ( _gruppo_avere , _conto_avere , _sottoconto_avere ,
' ' ) ;
_gc_corr_avere = format ( " %3d%3d " , _gruppo_avere , _conto_avere ) ;
if ( _gc_corr_avere ! = _gc_prec_avere )
{
_cambiato_conto_2 = TRUE ;
_gc_prec_avere = _gc_corr_avere ;
}
else if ( _sottoconto_avere ! = 0l )
_cambiato_conto_2 = FALSE ;
}
bool TStampaBilanciCDC_application : : preprocess_print ( int file , int counter )
{
2001-05-01 08:17:07 +00:00
if ( TCurrency : : get_firm_dec ( ) = = 0 )
{
set_real_picture ( " ###.###.###.### " ) ;
_extra_picture = " #.###.###.###.### " ;
_total_picture = " ############# " ;
}
else
{
set_real_picture ( " ####.###.###,@@ " ) ;
_extra_picture = " ##.###.###.###,@@ " ;
_total_picture = " ##########,@@ " ;
}
1997-07-22 08:03:29 +00:00
if ( _bilancio = = 1 )
{
set_print_zero ( ) ;
_tmp_saldi_att - > setkey ( 2 ) ;
_tmp_saldi_pass - > setkey ( 2 ) ;
_tmp_saldi_costi - > setkey ( 2 ) ;
_tmp_saldi_ricavi - > setkey ( 2 ) ;
_tmp_saldi_conti_uno - > setkey ( 2 ) ;
_tmp_saldi_conti_due - > setkey ( 2 ) ;
_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
{
//if ( (_verifica == 3) && (_ordinamento == 1) )
// _tmp_saldi_att->setkey(2);
set_print_zero ( FALSE ) ;
_cambiato_conto_1 = FALSE ;
_livello_conto = TRUE ;
_saldo_dare_tot = ZERO ;
_saldo_avere_tot = ZERO ;
_mov_dare_tot = ZERO ;
_mov_avere_tot = ZERO ;
_saldo_finale_tot = ZERO ;
}
return TRUE ;
}
void TStampaBilanciCDC_application : : leggi_file_tmp ( )
{
if ( _livello_conto ) // era meglio chiamarla _livello_conto_oppure_gruppo, perche' nel caso dei saldi di mastro _livello_conto==TRUE <=> si tratta di un gruppo, mentre nel caso del bilancio _livello_conto==TRUE <=> si tratta di un conto
{
_gruppo = _tmp_saldi_att - > get_int ( SLD_GRUPPO ) ;
_conto = _tmp_saldi_att - > get_int ( SLD_CONTO ) ;
_sottoconto = _tmp_saldi_att - > get_long ( SLD_SOTTOCONTO ) ;
_tipo_conto = _tmp_saldi_att - > get_char ( SLD_FLAGSALINI ) ;
_descr = DescrizioneConto ( _gruppo , _conto , _sottoconto , _tipo_conto ) ;
_saldoini_dare = _tmp_saldi_att - > get_real ( SLD_PDAREPRO ) ; // W96SALDI del 05-06-96
_saldoini_avere = _tmp_saldi_att - > get_real ( SLD_PAVEREPRO ) ;
_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 ) )
if ( _tipo_stampa1 = = 2 )
_ultima_data = UltimaData ( _gruppo_succ , _conto_succ ,
_sottoconto_succ , _annoes ) ;
else _ultima_data = _tmp_saldi_att - > get_date ( SLD_DATAULMOV ) ;
_descr_succ = DescrizioneConto ( _gruppo_succ , _conto_succ ,
_sottoconto_succ , _tipoc_succ ) ;
_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 ) ;
_mov_dare_succ = _tmp_saldi_att - > get_real ( SLD_PDARE ) ;
_mov_avere_succ = _tmp_saldi_att - > get_real ( SLD_PAVERE ) ;
_saldofinale_succ = _tmp_saldi_att - > get_real ( SLD_SALDO ) ;
_livello_conto = FALSE ;
if ( ( ( _verifica ! = 2 ) & & ( _sottoconto_succ = = 0 ) ) | |
( ( _verifica = = 2 ) & & ( _conto_succ = = 0 ) ) )
{
_livello_conto = TRUE ;
_gruppo_succ = _gruppo ;
_conto_succ = _conto ;
_sottoconto_succ = _sottoconto ;
_descr_succ = _descr ;
_saldoini_dare_succ = _saldoini_dare ;
_saldoini_avere_succ = _saldoini_avere ;
_mov_dare_succ = _mov_dare ;
_mov_avere_succ = _mov_avere ;
_saldofinale_succ = _saldofinale ;
}
}
}
bool TStampaBilanciCDC_application : : preprocess_page ( int file , int counter )
{
reset_print ( ) ;
if ( _bilancio = = 1 ) //stampa bilancio a sez. contrapposte
{
if ( counter )
{
if ( ( ! _eof1 ) & & ( _cambiato_conto_1 ) )
_eof1 = _tmp_saldi_att - > next ( ) ;
if ( ( ! _eof2 ) & & ( _cambiato_conto_2 ) )
_eof2 = _tmp_saldi_pass - > next ( ) ;
if ( _eof1 & & _eof2 )
{
if ( _prima_volta )
{
stampa_totali_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 ;
else leggi_file_tmp ( ) ;
}
}
}
return TRUE ;
}
void TStampaBilanciCDC_application : : leggi_sort ( )
{
struct cli_for * cf ;
if ( ( _buff = _sort - > retrieve ( ) ) ! = NULL )
{
cf = ( struct cli_for * ) _buff ;
_tipo_conto = cf - > tipocf ;
_gruppo = atoi ( cf - > gruppo ) ;
_conto = atoi ( cf - > conto ) ;
_sottoconto = atol ( cf - > codcf ) ;
_descr = cf - > ragsoc ;
if ( ( _ordinamento = = 2 & & _descr ! = " zzzz " ) | |
( _ordinamento = = 1 & & _sottoconto ! = 999999L ) )
if ( _tipo_stampa1 = = 2 )
_ultima_data = UltimaData ( _gruppo , _conto , _sottoconto , _annoes ) ;
else _ultima_data = cf - > udata ;
_saldo_dare = cf - > saldodare ;
_saldo_avere = cf - > saldoavere ;
_mov_dare = cf - > movdare ;
_mov_avere = cf - > movavere ;
_saldofinale = cf - > saldofinale ;
}
}
void TStampaBilanciCDC_application : : controlla_conto ( int file1 , int file2 )
{
char dep = ' * ' ;
if ( ! file1 )
if ( _cambiato_conto_1 )
{
set_row ( _i , " @66g%c " , dep ) ;
_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 )
{
set_row ( _i , " @66g%c " , dep ) ;
_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 ;
}
}
void TStampaBilanciCDC_application : : postclose_print ( )
{
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 )
delete _sort ;
else
{
delete _tmp_saldi_att ; _tmp_saldi_att = NULL ;
}
}
}
void TStampaBilanciCDC_application : : set_page ( int file , int counter )
{
const TString16 dep ;
if ( _bilancio = = 1 ) //stampa bilancio a sezioni contrapposte
{
_i = 1 ;
if ( ! counter )
{
set_row ( _i + + , " @29gATTIVITA'@94gPASSIVITA' " ) ;
set_row ( _i + + , " @29g---------@94g---------- " ) ;
set_row ( _i + + , dep ) ;
}
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 ( ) ;
set_row ( _i + + , " @29gCOSTI@94gRICAVI " ) ;
set_row ( _i + + , " @29g-----@94g------ " ) ;
set_row ( _i + + , dep ) ;
_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 ( ) ;
set_row ( _i + + , " @59gCONTI D'ORDINE " ) ;
set_row ( _i + + , " @59g-------------- " ) ;
set_row ( _i + + , dep ) ;
if ( _eof5 & & _eof6 )
{
_stampato = TRUE ;
//stampa_totali();
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();
stampa_totali_uno ( _prg_inidare_ord , _prg_iniavere_ord ) ;
}
}
}
}
else //stampa bilancio di verifica
{
TString16 udata = _ultima_data . string ( brief , ' / ' ) ;
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 ) ;
if ( ( _saldo_dare ! = ZERO ) | | ( _saldo_avere ! = ZERO ) | | ( _mov_dare ! = ZERO ) | |
( _mov_avere ! = ZERO ) | | ( _saldofinale ! = ZERO ) )
set_row ( r , " %s " , ( const char * ) udata ) ;
set_row ( r , " @18g#a@49g!@50g%r@67g%r@82g!@83g%r@99g%r@114g!@115g%r " , _d , & _saldo_dare ,
& _saldo_avere , & _mov_dare , & _mov_avere , & _saldofinale ) ;
if ( _saldofinale ! = ZERO )
set_row ( r , " @131g%c " , app ) ;
if ( _descr . len ( ) > 30 )
set_row ( + + r , " @49g!@82g!@114g! " ) ;
}
else if ( app = = ' D ' )
{
set_row ( r , " @1g%6ld " , ( const char * ) _sottoconto ) ;
if ( ( _saldo_dare ! = ZERO ) | | ( _saldo_avere ! = ZERO ) | | ( _mov_dare ! = ZERO ) | |
( _mov_avere ! = ZERO ) | | ( _saldofinale ! = ZERO ) )
set_row ( r , " %s " , ( const char * ) udata ) ;
set_row ( r , " @18g#a@49g!@50g%r@67g%r@82g!@83g%r@100g%r@115g!@116g%r@148g! " , _d ,
& _saldo_dare , & _saldo_avere , & _mov_dare , & _mov_avere , & _saldofinale ) ;
if ( _descr . len ( ) > 30 )
set_row ( + + r , " @49g!@82g!@115g!@148g! " ) ;
}
else
{
set_row ( r , " @1g%6ld " , ( const char * ) _sottoconto ) ;
if ( ( _saldo_dare ! = ZERO ) | | ( _saldo_avere ! = ZERO ) | | ( _mov_dare ! = ZERO ) | |
( _mov_avere ! = ZERO ) | | ( _saldofinale ! = ZERO ) )
set_row ( r , " %s " , ( const char * ) udata ) ;
set_row ( r , " @18g#a@49g!@50g%r@67g%r@82g!@83g%r@100g%r@115g!@132g%r@148g! " ,
_d , & _saldo_dare , & _saldo_avere , & _mov_dare , & _mov_avere , & _saldofinale ) ;
if ( _descr . len ( ) > 30 )
set_row ( + + r , " @49g!@82g!@115g!@148g! " ) ;
}
}
}
else //_verifica != 3
{
if ( ! _eof1 )
{
if ( _saldofinale_succ > 0 )
app = ' D ' ;
else if ( _saldofinale_succ < 0 )
{
_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 ) ;
set_row ( r , " @8g%-.40s@49g!@50g%r@67g%r@82g!@83g%r@99g%r@114g!@115g%r " ,
( const char * ) _descr_succ , & _saldoini_dare_succ , & _saldoini_avere_succ ,
& _mov_dare_succ , & _mov_avere_succ , & _saldofinale_succ ) ;
if ( _saldofinale_succ ! = ZERO )
set_row ( r , " @131g%c " , app ) ;
}
else if ( app = = ' D ' )
{
set_row ( r , " %3d " , _conto_succ ) ;
set_row ( r , " @8g%-.40s@49g!@50g%r@67g%r@82g!@83g%r@100g%r@115g!@116g%r@148g! " ,
( const char * ) _descr_succ , & _saldoini_dare_succ , & _saldoini_avere_succ ,
& _mov_dare_succ , & _mov_avere_succ , & _saldofinale_succ ) ;
}
else
{
set_row ( r , " %3d " , _conto_succ ) ;
set_row ( r , " @8g%-.40s@49g!@50g%r@67g%r@82g!@83g%r@100g%r@115g!@132g%r@148g! " ,
( const char * ) _descr_succ , & _saldoini_dare_succ , & _saldoini_avere_succ ,
& _mov_dare_succ , & _mov_avere_succ , & _saldofinale_succ ) ;
}
} // _verifica != 2
else
{
* _d = ( const char * ) _descr_succ ;
if ( _stampa_width = = 132 )
{
set_row ( r , " @1g%6ld " , ( const char * ) _sottoconto_succ ) ;
if ( ( _saldoini_dare_succ ! = ZERO ) | | ( _saldoini_avere_succ ! = ZERO ) | |
( _mov_dare_succ ! = ZERO ) | | ( _mov_avere_succ ! = ZERO ) | |
( _saldofinale_succ ! = ZERO ) )
set_row ( r , " %s " , ( const char * ) udata ) ;
set_row ( r , " @18g#a@49g!@50g%r@67g%r@82g!@83g%r@99g%r@114g!@115g%r " ,
_d , & _saldoini_dare_succ , & _saldoini_avere_succ ,
& _mov_dare_succ , & _mov_avere_succ , & _saldofinale_succ ) ;
if ( _saldofinale_succ ! = ZERO )
set_row ( r , " @131g%c " , app ) ;
if ( _descr_succ . len ( ) > 30 )
set_row ( + + r , " @49g!@82g!@114g! " ) ;
}
else if ( app = = ' D ' )
{
set_row ( r , " @1g%6ld " , ( const char * ) _sottoconto_succ ) ;
if ( ( _saldoini_dare_succ ! = ZERO ) | | ( _saldoini_avere_succ ! = ZERO ) | |
( _mov_dare_succ ! = ZERO ) | | ( _mov_avere_succ ! = ZERO ) | |
( _saldofinale_succ ! = ZERO ) )
set_row ( r , " %s " , ( const char * ) udata ) ;
set_row ( r , " @18g#a@49g!@50g%r@67g%r@82g!@83g%r@100g%r@115g!@116g%r@148g! " ,
_d , & _saldoini_dare_succ , & _saldoini_avere_succ ,
& _mov_dare_succ , & _mov_avere_succ , & _saldofinale_succ ) ;
if ( _descr_succ . len ( ) > 30 )
set_row ( + + r , " @49g!@82g!@115g!@148g! " ) ;
}
else
{
set_row ( r , " @1g%6ld " , ( const char * ) _sottoconto_succ ) ;
if ( ( _saldoini_dare_succ ! = ZERO ) | | ( _saldoini_avere_succ ! = ZERO ) | |
( _mov_dare_succ ! = ZERO ) | | ( _mov_avere_succ ! = ZERO ) | |
( _saldofinale_succ ! = ZERO ) )
set_row ( r , " %s " , ( const char * ) udata ) ;
set_row ( r , " @18g#a@49g!@50g%r@67g%r@82g!@83g%r@100g%r@115g!@132g%r@148g! " ,
_d , & _saldoini_dare_succ , & _saldoini_avere_succ ,
& _mov_dare_succ , & _mov_avere_succ , & _saldofinale_succ ) ;
if ( _descr_succ . len ( ) > 30 )
set_row ( + + r , " @49g!@82g!@115g!@148g! " ) ;
}
}
}
}
else
{
if ( _saldofinale > 0 )
app = ' D ' ;
else if ( _saldofinale < 0 )
{
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 ) ;
}
}
}
}
int TStampaBilanciCDC_application : : stampa_record_conto ( int g , int c , const TString & d ,
const real & r1 , const real & r2 , const real & r3 , const real & r4 , const real & r5 ,
const char app )
{
int r = 1 ;
if ( _stampa_width = = 148 )
{
set_row ( r , " @49g!@82g!@115g! " ) ; //stampo una riga vuota
set_row ( r , " @148g! " ) ;
}
else
set_row ( r , " @49g!@82g!@114g! " ) ; //stampo una riga vuota
r + + ;
if ( _verifica = = 2 )
{
if ( _stampa_width = = 132 )
{
// set_row(r++,"%3d-@8g%s@49g|@50g%r@67g%r@82g|@83g%r@100g%r@115g|@116g%r%s",g,d,&r1,&r2,&r3,&r4,&r5,(const char*)app);
set_row ( r , " %3d- " , g ) ;
set_row ( r , " @8g%-.40s " , ( const char * ) d ) ;
set_row ( r , " @49g!@50g%r@67g%r@82g!@83g%r@99g%r@114g!@115g%r " , & r1 , & r2 , & r3 , & r4 , & r5 ) ;
if ( r5 ! = ZERO )
set_row ( r , " @131g%c " , app ) ;
r + + ;
}
else
if ( app = = ' D ' )
{
// set_row(r++,"%3d-@8g%s@49g|@50g%r@67g%r@82g|@83g%r@100g%r@115g|@116g%r@148g|",g,d,&r1,&r2,&r3,&r4,&r5);
set_row ( r , " %3d- " , g ) ;
set_row ( r , " @8g%-.40s " , ( const char * ) d ) ;
set_row ( r + + , " @49g!@50g%r@67g%r@82g!@83g%r@100g%r@115g!@116g%r@148g! " , & r1 , & r2 , & r3 , & r4 , & r5 ) ;
}
else
{
// set_row(r++,"%3d-@8g%s@49g|@50g%r@67g%r@82g|@83g%r@100g%r@115g|@132g%r@148g|",g,d,&r1,&r2,&r3,&r4,&r5);
set_row ( r , " %3d- " , g ) ;
set_row ( r , " @8g%-.40s " , ( const char * ) d ) ;
set_row ( r + + , " @49g!@50g%r@67g%r@82g!@83g%r@100g%r@115g!@132g%r@148g! " , & r1 , & r2 , & r3 , & r4 , & r5 ) ;
}
}
else
{
* _d = ( const char * ) d ;
if ( _stampa_width = = 132 )
{
// set_row(r++,"%3d-%3d ********@18g%s@49g|@50g%r@67g%r@82g|@83g%r@100g%r@115g|@116g%r%s",g,c,d,&r1,&r2,&r3,&r4,&r5,(const char*)app);
set_row ( r , " %3d- " , g ) ;
set_row ( r , " %3d ******** " , c ) ;
set_row ( r , " @18g#a " , _d ) ;
set_row ( r , " @49g!@50g%r@67g%r@82g!@83g%r@99g%r@114g!@115g%r " , & r1 , & r2 , & r3 , & r4 , & r5 ) ;
if ( r5 ! = ZERO )
set_row ( r , " @131g%c " , app ) ;
r + + ;
if ( d . len ( ) > 30 )
set_row ( r + 1 , " @49g!@82g!@114g! " ) ;
}
else if ( app = = ' D ' )
{
// set_row(r++,"%3d-%3d ********@18g%s@49g|@50g%r@67g%r@82g|@83g%r@100g%r@115g|@116g%r@148g|",g,c,d,&r1,&r2,&r3,&r4,&r5);
set_row ( r , " %3d- " , g ) ;
set_row ( r , " %3d ******** " , c ) ;
set_row ( r , " @18g#a " , _d ) ;
set_row ( r + + , " @49g!@50g%r@67g%r@82g!@83g%r@100g%r@115g!@116g%r@148g! " , & r1 , & r2 , & r3 , & r4 , & r5 ) ;
if ( d . len ( ) > 30 )
set_row ( r + 1 , " @49g!@82g!@115g!@148g! " ) ;
}
else
{
// set_row(r++,"%3d-%3d ********@18g%s@49g|@50g%r@67g%r@82g|@83g%r@100g%r@115g|@132g%r@148g|",g,c,d,&r1,&r2,&r3,&r4,&r5);
set_row ( r , " %3d- " , g ) ;
set_row ( r , " %3d ******** " , c ) ;
set_row ( r , " @18g#a " , _d ) ;
set_row ( r + + , " @49g!@50g%r@67g%r@82g!@83g%r@100g%r@115g!@132g%r@148g! " , & r1 , & r2 , & r3 , & r4 , & r5 ) ;
if ( d . len ( ) > 30 )
set_row ( r + 1 , " @49g!@82g!@115g!@148g! " ) ;
}
}
if ( _stampa_width = = 148 )
{
set_row ( r , " @49g!@82g!@115g! " ) ;
set_row ( r , " @148g! " ) ;
}
else
set_row ( r , " @49g!@82g!@114g! " ) ;
r + + ;
if ( _stampa_width = = 148 )
{
set_row ( r , " @49g!@82g!@115g! " ) ;
set_row ( r , " @148g! " ) ;
}
else
set_row ( r , " @49g!@82g!@114g! " ) ;
r + + ;
if ( app = = ' D ' )
_saldo_finale_tot + = r5 ;
else _saldo_finale_tot - = r5 ;
_saldo_dare_tot + = r1 ;
_saldo_avere_tot + = r2 ;
_mov_dare_tot + = r3 ;
_mov_avere_tot + = r4 ;
return r ;
}
void TStampaBilanciCDC_application : : stampa_riga_totali ( int r )
{
const TString16 dep ;
char app = ' ' ;
if ( _saldo_finale_tot > 0 )
app = ' D ' ;
else if ( _saldo_finale_tot < 0 )
{
_saldo_finale_tot = - _saldo_finale_tot ;
app = ' A ' ;
}
//modifica del 21/11/1995
//if (_datada == _dataini) //colonna saldo iniziale
if ( _tipo_stampa1 = = 2 )
{
real r = _saldo_dare_tot - _saldo_avere_tot ;
if ( r > ZERO )
{
_saldo_dare_tot = r ;
_saldo_avere_tot = ZERO ;
}
else
{
_saldo_avere_tot = - r ;
_saldo_dare_tot = ZERO ;
}
}
if ( _stampa_width = = 148 )
{
set_row ( r , " @49g!@82g!@115g! " , ( const char * ) dep ) ;
set_row ( r , " @148g! " , ( const char * ) dep ) ;
}
else
set_row ( r , " @49g!@82g!@114g! " , ( const char * ) dep ) ;
r + + ;
//basta che ci sia un importo >= a mille miliardi che tutto
//il resto della riga va stampato senza puntini!(P.Tresoldi)
bool palla = FALSE ;
TString16 sdt ;
TString16 sat ;
TString16 mdt ;
TString16 mat ;
TString16 sft ;
TString16 ntsd ;
TString16 ntsa ;
if ( strlen ( _saldo_dare_tot . string ( ) ) > 12 | |
strlen ( _saldo_avere_tot . string ( ) ) > 12 | |
strlen ( _mov_dare_tot . string ( ) ) > 12 | |
strlen ( _mov_avere_tot . string ( ) ) > 12 | |
strlen ( _saldo_finale_tot . string ( ) ) > 12 )
{
palla = TRUE ;
2001-05-01 08:17:07 +00:00
if ( ! _saldo_dare_tot . is_zero ( ) ) sdt = _saldo_dare_tot . string ( _total_picture ) ;
if ( ! _saldo_avere_tot . is_zero ( ) ) sat = _saldo_avere_tot . string ( _total_picture ) ;
if ( ! _mov_dare_tot . is_zero ( ) ) mdt = _mov_dare_tot . string ( _total_picture ) ;
if ( ! _mov_avere_tot . is_zero ( ) ) mat = _mov_avere_tot . string ( _total_picture ) ;
if ( ! _saldo_finale_tot . is_zero ( ) ) sft = _saldo_finale_tot . string ( _total_picture ) ;
1997-07-22 08:03:29 +00:00
}
if ( _verifica = = 2 )
{
if ( _stampa_width = = 132 )
{
if ( ! palla )
{
set_row ( r , " ***@8gTOTALE GENERALE@49g!@50g%r@67g%r@82g!@83g%r@99g%r@114g!@115g%r " , & _saldo_dare_tot , & _saldo_avere_tot , & _mov_dare_tot ,
& _mov_avere_tot , & _saldo_finale_tot ) ;
if ( _saldo_finale_tot ! = ZERO )
set_row ( r , " @131g%c " , app ) ;
}
else
{
set_row ( r , " ***@8gTOTALE GENERALE@49g!@52g%s@69g%s@82g!@85g%s@101g%s@114g!@117g%s " , ( const char * ) sdt , ( const char * ) sat , ( const char * ) mdt ,
( const char * ) mat , ( const char * ) sft ) ;
if ( _saldo_finale_tot ! = ZERO )
set_row ( r , " %c " , app ) ;
}
}
else if ( app = = ' D ' )
{
if ( ! palla )
set_row ( r , " ***@8gTOTALE GENERALE@49g!@50g%r@67g%r@82g!@83g%r@100g%r@115g!@116g%r@148g! " , & _saldo_dare_tot , & _saldo_avere_tot ,
& _mov_dare_tot , & _mov_avere_tot , & _saldo_finale_tot ) ;
else
set_row ( r , " ***@8gTOTALE GENERALE@49g!@52g%s@69g%s@82g!@85g%s@102g%s@115g!@118g%s@148g! " , ( const char * ) sdt , ( const char * ) sat ,
( const char * ) mdt , ( const char * ) mat , ( const char * ) sft ) ;
}
else
{
if ( ! palla )
set_row ( r , " ***@8gTOTALE GENERALE@49g!@50g%r@67g%r@82g!@83g%r@100g%r@115g!@132g%r@148g! " , & _saldo_dare_tot , & _saldo_avere_tot ,
& _mov_dare_tot , & _mov_avere_tot , & _saldo_finale_tot ) ;
else
set_row ( r , " ***@8gTOTALE GENERALE@49g!@52g%s@69g%s@82g!@85g%s@102g%s@115g!@134g%s@148g! " , ( const char * ) sdt , ( const char * ) sat ,
( const char * ) mdt , ( const char * ) mat , ( const char * ) sft ) ;
}
}
else
{
if ( _stampa_width = = 132 )
{
if ( ! palla )
{
set_row ( r , " @1g****** ********@18gTOTALE GENERALE@49g!@50g%r@67g%r@82g!@83g%r@99g%r@114g!@115g%r " , & _saldo_dare_tot , & _saldo_avere_tot ,
& _mov_dare_tot , & _mov_avere_tot , & _saldo_finale_tot ) ;
if ( _saldo_finale_tot ! = ZERO )
set_row ( r , " @131g%c " , app ) ;
r + + ;
}
else
{
set_row ( r , " @1g****** ********@18gTOTALE GENERALE@49g!@52g%s@69g%s@82g!@85g%s@101g%s@114g!@117g%s " , ( const char * ) sdt , ( const char * ) sat ,
( const char * ) mdt , ( const char * ) mat , ( const char * ) sft ) ;
if ( _saldo_finale_tot ! = ZERO )
set_row ( r , " %c " , app ) ;
r + + ;
}
if ( ( _tipo_stampa1 = = 1 & & _datada = = _dataini ) | | _tipo_stampa1 = = 2 )
{
if ( strlen ( _nuovo_tot_saldo_d . string ( ) ) > 12 | |
strlen ( _nuovo_tot_saldo_a . string ( ) ) > 12 )
{
2001-05-01 08:17:07 +00:00
if ( ! _nuovo_tot_saldo_d . is_zero ( ) ) ntsd = _nuovo_tot_saldo_d . string ( _total_picture ) ;
if ( ! _nuovo_tot_saldo_a . is_zero ( ) ) ntsa = _nuovo_tot_saldo_a . string ( _total_picture ) ;
1997-07-22 08:03:29 +00:00
//modifica del 21/11/1995
if ( _tipo_stampa1 = = 2 )
set_row ( r , " @1g****** ********@18gTOTALE CON SALDI INIZIALI@49g!@82g!@85g%s@101g%s@114g! " , ( const char * ) ntsd , ( const char * ) ntsa ) ;
//else set_row(r,"@1g****** ********@18gTOTALE CON MOVIM. DI APERTURA@49g!@82g!@85g%s@101g%s@114g!",(const char*)ntsd,(const char*)ntsa);
//fine
}
else
{
//modifica del 21/11/1995
if ( _tipo_stampa1 = = 2 )
set_row ( r , " @1g****** ********@18gTOTALE CON SALDI INIZIALI@49g!@82g!@83g%r@99g%r@114g! " , & _nuovo_tot_saldo_d , & _nuovo_tot_saldo_a ) ;
//else set_row(r,"@1g****** ********@18gTOTALE CON MOVIM. DI APERTURA@49g!@82g!@83g%r@99g%r@114g!",&_nuovo_tot_saldo_d,&_nuovo_tot_saldo_a);
//fine
}
}
}
else
{
if ( app = = ' D ' )
{
if ( ! palla )
set_row ( r + + , " @1g****** ********@18gTOTALE GENERALE@49g!@50g%r@67g%r@82g!@83g%r@100g%r@115g!@116g%r@148g! " , & _saldo_dare_tot ,
& _saldo_avere_tot , & _mov_dare_tot , & _mov_avere_tot ,
& _saldo_finale_tot ) ;
else
set_row ( r + + , " @1g****** ********@18gTOTALE GENERALE@49g!@52g%s@69g%s@82g!@85g%s@102g%s@115g!@118g%s@148g! " , ( const char * ) sdt ,
( const char * ) sat , ( const char * ) mdt , ( const char * ) mat ,
( const char * ) sft ) ;
}
else
{
if ( ! palla )
set_row ( r + + , " @1g****** ********@18gTOTALE GENERALE@49g!@50g%r@67g%r@82g!@83g%r@100g%r@115g!@132g%r@148g! " , & _saldo_dare_tot ,
& _saldo_avere_tot , & _mov_dare_tot , & _mov_avere_tot ,
& _saldo_finale_tot ) ;
else
set_row ( r + + , " @1g****** ********@18gTOTALE GENERALE@49g!@52g%s@69g%s@82g!@85g%s@102g%s@115g!@134g%s@148g! " , ( const char * ) sdt ,
( const char * ) sat , ( const char * ) mdt , ( const char * ) mat ,
( const char * ) sft ) ;
}
if ( ( _tipo_stampa1 = = 1 & & _datada = = _dataini ) | | _tipo_stampa1 = = 2 )
{
if ( strlen ( _nuovo_tot_saldo_d . string ( ) ) > 12 | |
strlen ( _nuovo_tot_saldo_a . string ( ) ) > 12 )
{
2001-05-01 08:17:07 +00:00
if ( ! _nuovo_tot_saldo_d . is_zero ( ) ) ntsd = _nuovo_tot_saldo_d . string ( _total_picture ) ;
if ( ! _nuovo_tot_saldo_a . is_zero ( ) ) ntsa = _nuovo_tot_saldo_a . string ( _total_picture ) ;
1997-07-22 08:03:29 +00:00
if ( _tipo_stampa1 = = 2 )
set_row ( r , " @1g****** ********@18gTOTALE CON SALDI INIZIALI@49g!@82g!@85g%s@102g%s@115g!@148g! " , ( const char * ) ntsd , ( const char * ) ntsa ) ;
//else set_row(r,"@1g****** ********@18gTOTALE CON MOVIM. DI APERTURA@49g!@82g!@85g%s@102g%s@115g!@148g!",(const char*)ntsd,(const char*)ntsa);
}
else
{
if ( _tipo_stampa1 = = 2 )
set_row ( r , " @1g****** ********@18gTOTALE CON SALDI INIZIALI@49g!@82g!@83g%r@100g%r@115g!@148g! " , & _nuovo_tot_saldo_d , & _nuovo_tot_saldo_a ) ;
//else set_row(r,"@1g****** ********@18gTOTALE CON MOVIM. DI APERTURA@49g!@82g!@83g%r@100g%r@115g!@148g!",&_nuovo_tot_saldo_d,&_nuovo_tot_saldo_a);
}
}
}
}
}
void TStampaBilanciCDC_application : : stampa_totali ( )
{
const TString16 dep = " " ;
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 ) ;
2001-05-01 08:17:07 +00:00
set_row ( _i + + , ( const char * ) dep ) ;
TString pal ( _tot_dare . string ( _extra_picture ) ) ;
TString bal ( _tot_avere . string ( _extra_picture ) ) ;
1997-07-22 08:03:29 +00:00
//set_row(_i++, "@39gTOTALE@49g%r@107gTOTALE@117g%r",
// &_tot_dare, &_tot_avere);
set_row ( _i + + , " @39gTOTALE@47g%s@107gTOTALE@115g%s " ,
( const char * ) pal , ( const char * ) bal ) ;
2001-05-01 08:17:07 +00:00
TString sb ( sbilancio . string ( _extra_picture ) ) ;
TString pa ( pareggio . string ( _extra_picture ) ) ;
1997-07-22 08:03:29 +00:00
if ( _tot_dare > _tot_avere )
{
/*
set_row ( _i + + , " @85gSBILANCIO ESERCIZIO IN CORSO@117g%r " ,
& sbilancio ) ;
set_row ( _i + + , " @96gTOTALE A PAREGGIO@117g%r " , & pareggio ) ;
*/
set_row ( _i + + , " @85gSBILANCIO ESERCIZIO IN CORSO@115g%s " ,
( const char * ) sb ) ;
set_row ( _i + + , " @96gTOTALE A PAREGGIO@115g%s " , ( const char * ) pa ) ;
}
if ( _tot_dare < _tot_avere )
{
/*
set_row ( _i + + , " @17gSBILANCIO ESERCIZIO IN CORSO@49g%r " ,
& sbilancio ) ;
set_row ( _i + + , " @28gTOTALE A PAREGGIO@49g%r " , & pareggio ) ;
*/
set_row ( _i + + , " @17gSBILANCIO ESERCIZIO IN CORSO@47g%s " ,
( const char * ) sb ) ;
set_row ( _i + + , " @28gTOTALE A PAREGGIO@47g%s " , ( const char * ) pa ) ;
}
_tot_dare = ZERO ;
_tot_avere = ZERO ;
}
//per i conti patrimoniali stampo anche lo sbilancio es. precedente
void TStampaBilanciCDC_application : : stampa_totali_uno ( const real & r1 , const real & r2 )
{
const TString16 dep ;
real pareggio ;
real sbilancio = _tot_dare - r1 - ( _tot_avere - r2 ) ;
real sbilprec = r2 - r1 ;
/*
if ( sbilancio > ZERO ) //ho un utile => va stampato tra le passivita'
{
sbilprec = - sbilprec ;
pareggio = _tot_avere + sbilancio + sbilprec ;
}
else if ( sbilancio < ZERO ) //ho una perdita => va stampato tra le attivita' cambiato di segno
{
sbilancio = - sbilancio ;
pareggio = _tot_dare + sbilancio + sbilprec ;
}
*/
if ( _prima_volta ) //ho finito di stampare le attivita'/passivita'
_prima_volta = FALSE ;
else
_seconda_volta = FALSE ;
_gc_prec_dare = _gc_corr_avere = " " ;
_cambiato_conto_1 = TRUE ;
_cambiato_conto_2 = TRUE ;
set_row ( _i + + , ( const char * ) dep ) ;
set_row ( _i + + , ( const char * ) dep ) ;
set_row ( _i + + , ( const char * ) dep ) ;
set_row ( _i + + , ( const char * ) dep ) ;
2001-05-01 08:17:07 +00:00
TString pal ( _tot_dare . string ( _extra_picture ) ) ;
TString bal ( _tot_avere . string ( _extra_picture ) ) ;
1997-07-22 08:03:29 +00:00
set_row ( _i + + , " @39gTOTALE@47g%s@107gTOTALE@115g%s " ,
( const char * ) pal , ( const char * ) bal ) ;
/*
set_row ( _i + + , " @39gTOTALE@49g%r@107gTOTALE@117g%r " ,
& _tot_dare , & _tot_avere ) ;
*/
if ( sbilancio > ZERO ) //ho un utile => va stampato tra le passivita'
{
sbilprec = - sbilprec ;
pareggio = _tot_avere + sbilancio + sbilprec ;
if ( sbilprec ! = ZERO )
{
//set_row(_i++, "@83gSBILANCIO ESERCIZIO PRECEDENTE@117g%r",
// &sbilprec);
2001-05-01 08:17:07 +00:00
TString sb ( sbilprec . string ( _extra_picture ) ) ;
1997-07-22 08:03:29 +00:00
set_row ( _i + + , " @83gSBILANCIO ESERCIZIO PRECEDENTE@115g%s " ,
( const char * ) sb ) ;
}
/*
set_row ( _i + + , " @85gSBILANCIO ESERCIZIO IN CORSO@117g%r " ,
& sbilancio ) ;
set_row ( _i + + , " @96gTOTALE A PAREGGIO@117g%r " , & pareggio ) ;
*/
2001-05-01 08:17:07 +00:00
TString pal ( sbilancio . string ( _extra_picture ) ) ;
TString bal ( pareggio . string ( _extra_picture ) ) ;
1997-07-22 08:03:29 +00:00
set_row ( _i + + , " @85gSBILANCIO ESERCIZIO IN CORSO@115g%s " ,
( const char * ) pal ) ;
set_row ( _i + + , " @96gTOTALE A PAREGGIO@115g%s " , ( const char * ) bal ) ;
}
else if ( sbilancio < ZERO ) //ho una perdita => va stampato tra le attivita'
{
sbilancio = - sbilancio ;
pareggio = _tot_dare + sbilancio + sbilprec ;
if ( sbilprec ! = ZERO )
{
//set_row(_i++, "@15gSBILANCIO ESERCIZIO PRECEDENTE@49g%r",
// &sbilprec);
2001-05-01 08:17:07 +00:00
TString sb ( sbilprec . string ( _extra_picture ) ) ;
1997-07-22 08:03:29 +00:00
set_row ( _i + + , " @15gSBILANCIO ESERCIZIO PRECEDENTE@47g%s " ,
( const char * ) sb ) ;
}
/*
set_row ( _i + + , " @17gSBILANCIO ESERCIZIO IN CORSO@49g%r " ,
& sbilancio ) ;
set_row ( _i + + , " @28gTOTALE A PAREGGIO@49g%r " , & pareggio ) ;
*/
2001-05-01 08:17:07 +00:00
TString pal ( sbilancio . string ( _extra_picture ) ) ;
TString bal ( pareggio . string ( _extra_picture ) ) ;
1997-07-22 08:03:29 +00:00
set_row ( _i + + , " @17gSBILANCIO ESERCIZIO IN CORSO@47g%s " ,
( const char * ) pal ) ;
set_row ( _i + + , " @28gTOTALE A PAREGGIO@47g%s " , ( const char * ) bal ) ;
}
else //sbilancio es. in corso == 0
{
sbilprec = - sbilprec ;
if ( sbilprec > ZERO ) //va stampato sotto le passivita'
{
2001-05-01 08:17:07 +00:00
TString pal ( sbilprec . string ( _extra_picture ) ) ;
1997-07-22 08:03:29 +00:00
pareggio = _tot_avere + sbilprec ;
2001-05-01 08:17:07 +00:00
TString bal ( pareggio . string ( _extra_picture ) ) ;
1997-07-22 08:03:29 +00:00
/*
set_row ( _i + + , " @83gSBILANCIO ESERCIZIO PRECEDENTE@117g%r " ,
& sbilprec ) ;
set_row ( _i + + , " @96gTOTALE A PAREGGIO@117g%r " , & pareggio ) ;
*/
set_row ( _i + + , " @83gSBILANCIO ESERCIZIO PRECEDENTE@115g%s " ,
( const char * ) pal ) ;
set_row ( _i + + , " @96gTOTALE A PAREGGIO@115g%s " , ( const char * ) bal ) ;
}
else if ( sbilprec < ZERO )
{
sbilprec = - sbilprec ;
pareggio = _tot_dare + sbilprec ;
2001-05-01 08:17:07 +00:00
TString pal ( sbilprec . string ( _extra_picture ) ) ;
TString bal ( pareggio . string ( _extra_picture ) ) ;
1997-07-22 08:03:29 +00:00
/*
set_row ( _i + + , " @15gSBILANCIO ESERCIZIO PRECEDENTE@49g%r " ,
& sbilprec ) ;
set_row ( _i + + , " @28gTOTALE A PAREGGIO@49g%r " , & pareggio ) ;
*/
set_row ( _i + + , " @15gSBILANCIO ESERCIZIO PRECEDENTE@47g%s " ,
( const char * ) pal ) ;
set_row ( _i + + , " @28gTOTALE A PAREGGIO@47g%s " , ( const char * ) bal ) ;
}
}
_tot_dare = ZERO ;
_tot_avere = ZERO ;
}
void TStampaBilanciCDC_application : : stampa_prima_colonna ( int g , int c , long s ,
const char * desc , const real & saldo )
{
char dep = ' * ' ;
if ( _codici ) //sono stampate solo le descrizioni dei conti
{
if ( ! _totali )
{
if ( c ! = 0 & & s = = 0 )
set_row ( _i , " %-.44s @44g *** @49g%r @66g%c " , desc , & saldo , dep ) ;
else set_row ( _i , " %-.48s @49g%r @66g%c " , desc , & saldo , dep ) ;
}
else if ( ! ( c = = 0 & & s = = 0 ) ) //se cioe' non e' un gruppo
{
if ( s = = 0 ) //se e' un conto
set_row ( _i , " %-.44s @44g *** @49g%r @66g%c " , desc , & saldo , dep ) ;
else set_row ( _i , " %-.48s @49g%r @66g%c " , desc , & saldo , dep ) ;
}
}
else
{
if ( _totali & & c = = 0 & & s = = 0l )
return ;
else if ( c = = 0 & & s = = 0l )
{
set_row ( _i , " %3d " , g ) ;
set_row ( _i , " @17g%-.31s @49g%r @66g%c " , desc , & saldo , dep ) ;
}
else if ( s = = 0l )
{
set_row ( _i , " %3d " , g ) ;
set_row ( _i , " %3d " , c ) ;
set_row ( _i , " @17g%-.31s @49g%r @66g%c " , desc , & saldo , dep ) ;
}
else
{
set_row ( _i , " %3d " , g ) ;
set_row ( _i , " %3d " , c ) ;
set_row ( _i , " %6ld " , s ) ;
set_row ( _i , " @17g%-.31s @49g%r @66g%c " , desc , & saldo , dep ) ;
}
}
}
void TStampaBilanciCDC_application : : stampa_seconda_colonna ( int g , int c , long s ,
const char * desc , const real & saldo )
{
char dep = ' * ' ;
if ( _codici ) //sono stampate solo le descrizioni dei conti
{
if ( ! _totali )
{
if ( c ! = 0 & & s = = 0 )
set_row ( _i , " @66g%c@69g%-.43s @112g ***@117g%r " , dep , desc , & saldo ) ;
else set_row ( _i , " @66g%c@69g%-.47s @117g%r " , dep , desc , & saldo ) ;
}
else if ( ! ( c = = 0 & & s = = 0 ) )
{
if ( s = = 0 ) //se e' un conto
set_row ( _i , " @66g%c @69g%-.43s @112g *** @117g%r " , dep , desc , & saldo ) ;
else set_row ( _i , " @66g%c @69g%-.47s @117g%r " , dep , desc , & saldo ) ;
}
}
else
{
if ( _totali & & c = = 0 & & s = = 0l )
return ;
else if ( c = = 0 & & s = = 0l )
{
set_row ( _i , " @66g%c@69g%3d " , dep , g ) ;
set_row ( _i , " @86g%-.30s @117g%r " , desc , & saldo ) ;
}
else if ( s = = 0l )
{
set_row ( _i , " @66g%c@69g%3d " , dep , g ) ;
set_row ( _i , " %3d " , c ) ;
set_row ( _i , " @86g%-.30s @117g%r " , desc , & saldo ) ;
}
else
{
set_row ( _i , " @66g%c@69g%3d " , dep , g ) ;
set_row ( _i , " %3d " , c ) ;
set_row ( _i , " %6ld " , s ) ;
set_row ( _i , " @86g%-.30s @117g%r " , desc , & saldo ) ;
}
}
}
print_action TStampaBilanciCDC_application : : postprocess_page ( int file , int counter )
{
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 ;
}
TDate TStampaBilanciCDC_application : : UltimaData ( int g , int c , long s , int anno )
{
TDate uldata ;
TLocalisamfile saldi ( LF_SALDI , FALSE ) ; //il parametro a false permette di usare un record corrente del file saldi differente a quello del file tmp
saldi . zero ( ) ;
if ( _annoes ! = 0 )
saldi . put ( SLD_ANNOES , anno ) ;
saldi . put ( SLD_FLSCA , FALSE ) ; // W96SALDI del 05-06-96
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 ;
}
//Non ho potuto usare quella di TConto!!! Chiedere a me!
const char * TStampaBilanciCDC_application : : DescrizioneConto ( int g , int c , long s ,
char tipocf )
{
TString80 ragsoc ;
const char * desc = NULL ;
TLocalisamfile pconti ( LF_PCON , FALSE ) ;
TLocalisamfile clifo ( LF_CLIFO ) ;
pconti . zero ( ) ;
pconti . put ( PCN_GRUPPO , g ) ;
if ( c ! = 0 )
pconti . put ( PCN_CONTO , c ) ;
if ( s ! = 0 )
pconti . put ( PCN_SOTTOCONTO , s ) ;
pconti . read ( ) ;
if ( pconti . good ( ) )
TMP = pconti . get ( PCN_DESCR ) ;
else
{
clifo . setkey ( 1 ) ; //occorre settare la chiave 1, anche se di solito e' di default, poiche' nella create il file clifo e' stato aperto con la chiave 3
clifo . zero ( ) ;
clifo . put ( CLI_CODCF , s ) ;
clifo . put ( CLI_TIPOCF , tipocf ) ;
if ( clifo . read ( ) = = NOERR )
{
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 " ) ;
TMP = desc ;
}
else
TMP = " " ;
}
return TMP ;
}
bool TStampaBilanciCDC_application : : user_create ( )
{
_stampa_width = 132 ;
_rel = new TRelation ( LF_CLIFO ) ;
_cur = new TCursor ( _rel , " " , 3 ) ;
_mov = new TLocalisamfile ( LF_MOV ) ;
_rmov = new TLocalisamfile ( LF_RMOV ) ;
_clifo = new TLocalisamfile ( LF_CLIFO ) ;
_com = new TLocalisamfile ( LF_COMUNI ) ;
_pcn = new TLocalisamfile ( LF_PCON ) ;
_saldi = new TLocalisamfile ( LF_SALDI ) ;
_nditte = new TLocalisamfile ( LF_NDITTE ) ;
_anag = new TLocalisamfile ( LF_ANAG ) ;
_caus = new TLocalisamfile ( LF_CAUSALI ) ;
_esc = new TTable ( " ESC " ) ;
1998-11-04 18:04:26 +00:00
_cdc_table = new TTable ( " CDC " ) ;
1997-07-22 08:03:29 +00:00
_d = new TParagraph_string ( " " , 30 ) ;
1998-11-04 18:04:26 +00:00
_mask = new TMask ( " cgp1200a " ) ;
_mask - > set_handler ( F_VERIFICA , my_handler ) ;
_mask - > set_handler ( F_BILANCIO , mask_bilancio ) ;
_mask - > set_handler ( F_DATALIM , mask_datalim ) ;
_mask - > set_handler ( F_DATADA , mask_date ) ;
_mask - > set_handler ( F_DATAA , mask_date ) ;
_mask - > set_handler ( F_ANNO , mask_anno ) ;
_mask - > set_handler ( F_CDC_FR , fr_cdc_handler ) ;
_mask - > set_handler ( F_CDC_TO , to_cdc_handler ) ;
_mask - > set_handler ( BUT_SEL , select_button ) ;
_mask - > set_handler ( BUT_ANN , reset_button ) ;
// Compone la lista dei centri di costo
_cdc_sheet = new TArray_sheet ( - 1 , - 1 , - 4 , - 4 , " Selezione Centri di Costo " ,
" @1|Codice@7R|Descrizione@50 " ) ;
1999-07-16 14:59:11 +00:00
// Siccome sulla tabella dei centri di costo i codici sono memorizzati come stringa
// ed allineati a sinistra e siccome la PRASSI (Cinzia) non vuole conversioni
// E' necessario ordinare l'array letto in memoria.
TString_array & ac = _cdc_sheet - > rows_array ( ) ;
1998-11-04 18:04:26 +00:00
for ( _cdc_table - > first ( ) ; ! _cdc_table - > eof ( ) ; _cdc_table - > next ( ) )
{
1999-07-16 14:59:11 +00:00
TToken_string * t = new TToken_string ;
t - > add ( " " ) ;
t - > add ( _cdc_table - > get ( " CODTAB " ) ) ;
t - > add ( _cdc_table - > get ( " S0 " ) ) ;
ac . add ( t ) ;
1998-11-04 18:04:26 +00:00
}
1999-07-16 14:59:11 +00:00
1997-07-22 08:03:29 +00:00
_tmp_saldi_att = NULL ;
_tmp_saldi_pass = NULL ;
_tmp_saldi_costi = NULL ;
_tmp_saldi_ricavi = NULL ;
_tmp_saldi_conti_uno = NULL ;
1999-04-06 15:34:39 +00:00
_tmp_saldi_conti_due = NULL ;
_mvcs = new TExternisamfile ( " $movcas " ) ;
1997-07-22 08:03:29 +00:00
return TRUE ;
}
bool TStampaBilanciCDC_application : : user_destroy ( )
{
delete _rel ;
delete _cur ;
delete _com ;
delete _pcn ;
delete _mov ;
delete _rmov ;
delete _clifo ;
delete _saldi ;
delete _nditte ;
delete _anag ;
delete _caus ;
delete _esc ;
1998-11-04 18:04:26 +00:00
delete _cdc_table ;
1997-07-22 08:03:29 +00:00
delete _d ;
1998-11-04 18:04:26 +00:00
delete _cdc_sheet ;
delete _mask ;
1997-07-22 08:03:29 +00:00
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 ;
1999-04-06 15:34:39 +00:00
if ( _mvcs ) delete _mvcs ;
1997-07-22 08:03:29 +00:00
return TRUE ;
}
void TStampaBilanciCDC_application : : leggi_pcon ( )
{
TLocalisamfile pconti ( LF_PCON ) ;
TToken_string gc ( 10 ) ;
for ( pconti . first ( ) ; ! pconti . eof ( ) ; pconti . next ( ) )
{
gc . restart ( ) ;
int gruppo = pconti . get_int ( PCN_GRUPPO ) ;
int conto = pconti . get_int ( PCN_CONTO ) ;
long sottoconto = pconti . get_long ( PCN_SOTTOCONTO ) ;
if ( ( sottoconto = = 0l ) & & ( conto ! = 0 ) ) //si tratta di un conto
{
char tipocf = pconti . get_char ( PCN_TMCF ) ;
if ( tipocf = = ' C ' & &
( _situazione . empty ( ) | | _situazione = = " C " ) )
{
gc . add ( gruppo , 0 ) ;
gc . add ( conto , 1 ) ;
_clienti . add ( gc ) ;
}
else if ( tipocf = = ' F ' & &
( _situazione . empty ( ) | | _situazione = = " F " ) )
{
gc . add ( gruppo , 0 ) ;
gc . add ( conto , 1 ) ;
_fornitori . add ( gc ) ;
}
}
}
}
bool TStampaBilanciCDC_application : : set_print ( int )
{
1998-11-04 18:04:26 +00:00
TMask & m = * _mask ;
while ( m . run ( ) = = K_ENTER )
1997-07-22 08:03:29 +00:00
{
_annoes = atoi ( m . get ( F_ANNO ) ) ;
_bilancio = atoi ( m . get ( F_BILANCIO ) ) ;
_data = m . get ( F_DATASTAMPA ) ;
_stampa_mov_prov = m . get_int ( F_STAMPAMPROV ) ;
_quadratura = m . get_bool ( F_QUADRATURA ) ;
_movcas_print = m . get_bool ( F_MOVCAS ) ;
1998-11-04 18:04:26 +00:00
const bool no_cdc = _cdc_sheet - > checked ( ) = = 0 ; // Nessun CDC selezionato, stampa normale (con mov cassa...)
const long items = no_cdc ? 1 : _cdc_sheet - > items ( ) ;
for ( long i = 0L ; i < items ; i + + )
1997-07-22 08:03:29 +00:00
{
1998-11-04 18:04:26 +00:00
if ( ! no_cdc & & ! _cdc_sheet - > checked ( i ) ) // Se non e' selezionato, salta questo CDC
continue ;
_cdc_cod = no_cdc ? 0 : _cdc_sheet - > row ( i ) . get_long ( 1 ) ;
_cdc_descr = no_cdc ? " " : _cdc_sheet - > row ( i ) . get ( 2 ) ;
if ( _bilancio = = 1 )
1997-07-22 08:03:29 +00:00
{
1998-11-04 18:04:26 +00:00
_prog = new TProgind ( _pcn - > items ( ) , " Elaborazione in corso... prego attendere " , FALSE ) ;
_totali = ( bool ) ( m . get ( F_TOTALI ) = = " X " ) ;
_codici = ( bool ) ( m . get ( F_CODICI ) = = " X " ) ;
_saldo = ( bool ) ( m . get ( F_SALDO ) = = " X " ) ;
_tipo_stampa = 1 ;
if ( _annoes ! = 0 )
_dataini = InizioEsercizio ( _annoes ) ;
else
_dataini = _inizioEs ;
_datalim = m . get ( F_DATALIM ) ;
bil_sez_contr ( ) ;
1997-07-22 08:03:29 +00:00
}
1998-11-04 18:04:26 +00:00
else
1997-07-22 08:03:29 +00:00
{
1998-11-04 18:04:26 +00:00
printer ( ) . footerlen ( 5 ) ;
_stampa_width = atoi ( m . get ( F_MODULO ) ) ;
if ( _stampa_width = = 1 )
_stampa_width = 132 ;
else _stampa_width = 148 ; //perche' questo e' in realta' il margine dx (vedi es. di stampa AS/400)
_verifica = atoi ( m . get ( F_VERIFICA ) ) ;
if ( ( _verifica = = 1 ) | | ( _verifica = = 2 ) )
_prog = new TProgind ( _pcn - > items ( ) , " Elaborazione in corso... prego attendere " , FALSE ) ;
_tipo_stampa1 = 1 ;
if ( _annoes ! = 0 )
_dataini = InizioEsercizio ( _annoes ) ;
1997-07-22 08:03:29 +00:00
else
1998-11-04 18:04:26 +00:00
_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 ) ) ;
// _cur->setkey(3);
if ( _situazione . not_empty ( ) )
_cur - > setfilter ( format ( " TIPOCF = \" %s \" " , ( const char * ) _situazione ) ) ;
else
_cur - > setfilter ( " " ) ;
//_prog = new TProgind(_cur->items(),"Elaborazione in corso... prego attendere",FALSE);
_clienti . destroy ( ) ;
_fornitori . destroy ( ) ;
leggi_pcon ( ) ;
crea_sort_clifo ( ) ;
_sort - > endsort ( ) ;
delete _cf ;
}
1997-07-22 08:03:29 +00:00
}
1998-11-04 18:04:26 +00:00
delete _prog ;
2001-05-01 08:17:07 +00:00
1998-11-04 18:04:26 +00:00
//stampicchia
print ( ) ;
//return TRUE;
1997-07-22 08:03:29 +00:00
}
}
return FALSE ;
}
TRectype & look_com ( const char * cod , TLocalisamfile * comuni )
{
comuni - > zero ( ) ;
comuni - > put ( COM_COM , cod ) ;
comuni - > read ( ) ;
if ( comuni - > bad ( ) )
comuni - > zero ( ) ;
return comuni - > curr ( ) ;
}
void TStampaBilanciCDC_application : : get_dati_ditta ( )
{
TLocalisamfile nditte ( LF_NDITTE ) ;
TLocalisamfile anag ( LF_ANAG ) ;
TString codanagr ;
TString tipoa ;
nditte . zero ( ) ;
nditte . put ( NDT_CODDITTA , get_firm ( ) ) ;
nditte . read ( ) ;
if ( nditte . bad ( ) ) nditte . zero ( ) ;
codanagr = nditte . get ( NDT_CODANAGR ) ;
tipoa = nditte . get ( NDT_TIPOA ) ;
_ragsoc = nditte . get ( NDT_RAGSOC ) ;
anag . setkey ( 1 ) ;
anag . zero ( ) ;
anag . put ( ANA_TIPOA , tipoa ) ;
anag . put ( ANA_CODANAGR , codanagr ) ;
anag . read ( ) ;
if ( anag . bad ( ) ) anag . zero ( ) ;
_cofi = anag . get ( ANA_COFI ) ;
_paiva = anag . get ( ANA_PAIV ) ;
_comunefis = anag . get ( ANA_COMRF ) ;
if ( _comunefis . empty ( ) )
_comunefis = anag . get ( ANA_COMRES ) ;
TRectype dep = look_com ( _comunefis , _com ) ;
_comunefis = dep . get ( COM_DENCOM ) ;
_provfis = dep . get ( COM_PROVCOM ) ;
_cap = dep . get ( COM_CAPCOM ) ;
if ( _comunefis . empty ( ) )
{
_viafis = anag . get ( ANA_INDRF ) ;
_viafis . rtrim ( ) ;
_viafis < < " " < < anag . get ( ANA_CIVRF ) ;
}
else
{
_viafis = anag . get ( ANA_INDRES ) ;
_viafis . rtrim ( ) ;
_viafis < < " " < < anag . get ( ANA_CIVRES ) ;
}
}
int TStampaBilanciCDC_application : : stampa_intestazione_ditta ( )
{
int r = 1 ;
TString codice_ditta ;
TString riga ( _stampa_width ) ;
//TString riga(132);
get_dati_ditta ( ) ;
codice_ditta < < get_firm ( ) ;
set_header ( r , " Ditta %s %s %s %s %s %s " , ( const char * ) codice_ditta ,
( const char * ) _ragsoc , ( const char * ) _viafis ,
( const char * ) _cap , ( const char * ) _comunefis ,
( const char * ) _provfis ) ;
r + + ;
printer ( ) . setdate ( _data ) ;
riga = " Data @< Pag. @# " ;
riga . right_just ( _stampa_width - 6 ) ;
//riga.right_just(127);
riga . overwrite ( format ( " Partita iva %s Codice fiscale %s " , ( const char * ) _paiva , ( const char * ) _cofi ) ) ;
set_header ( r , " %s " , ( const char * ) riga ) ;
r + + ;
return r ;
}
void TStampaBilanciCDC_application : : preprocess_header ( )
{
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 ( ) ;
set_header ( r , " STAMPA BILANCIO A SEZIONI CONTRAPPOSTE " ) ;
if ( _movcas_print )
set_header ( r , " @38g DI CASSA " ) ;
if ( _tipo_stampa = = 1 )
{
data_da = _dataini . string ( ) ;
data = _datalim . string ( ) ;
set_header ( r , " @48gdalla data %s alla data %s " , ( const char * ) data_da ,
( const char * ) data ) ;
}
else if ( _tipo_stampa = = 2 )
set_header ( r , " @48gall'ultima immissione Es. %d " , _annoes ) ;
//else set_header(r, "@41gall'ultima immissione Es. Precedente");
//modifica del 20/04/1995
{
TString d1 ( InizioEsercizio ( _annoes ) . string ( ) ) ;
TString d2 ( FineEsercizio ( _annoes ) . string ( ) ) ;
set_header ( r , " @95gEsercizio %s %s " , ( const char * ) d1 , ( const char * ) d2 ) ; /**/
}
r + + ;
if ( _cdc_cod ! = 0L )
set_header ( r + + , " CENTRO DI COSTO %ld: %s " , _cdc_cod , ( const char * ) _cdc_descr ) ;
riga . fill ( ' - ' ) ;
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 )
set_header ( r , " STAMPA BILANCIO DI VERIFICA " ) ;
else if ( _verifica = = 2 )
set_header ( r , " STAMPA SALDI DI MASTRO " ) ;
else
{
if ( _situazione = = " C " )
set_header ( r , " SITUAZIONE CONTABILE CLIENTI " ) ;
else if ( _situazione = = " F " )
set_header ( r , " SITUAZIONE CONTABILE FORNITORI " ) ;
else set_header ( r , " SITUAZIONE CLIENTI/FORNITORI " ) ;
}
if ( _movcas_print )
set_header ( r , " @31gDI CASSA " ) ;
if ( _tipo_stampa1 = = 1 )
{
set_header ( r , " @41gdal %s al %s " , ( const char * ) datada ,
( const char * ) dataa ) ;
//modifica del 20/04/1995
if ( _annoes ! = 0 ) //se l'anno e' 0 non si considera la competenza
{
TString d1 ( InizioEsercizio ( _annoes ) . string ( ) ) ;
TString d2 ( FineEsercizio ( _annoes ) . string ( ) ) ;
set_header ( r , " @74gEsercizio %s %s " , ( const char * ) d1 , ( const char * ) d2 ) ; /**/
}
}
else if ( _tipo_stampa1 = = 2 )
{
set_header ( r , " @36gall'ultima immissione Es. %d " , _annoes ) ;
//modifica del 20/04/1995
TString d1 ( InizioEsercizio ( _annoes ) . string ( ) ) ;
TString d2 ( FineEsercizio ( _annoes ) . string ( ) ) ;
set_header ( r , " @72gEsercizio %s %s " , ( const char * ) d1 , ( const char * ) d2 ) ; /**/
}
if ( ( _verifica = = 1 ) | | ( _verifica = = 2 ) )
{
if ( _stampav = = 1 )
set_header ( r , " @107gTutti i conti movimentati " ) ;
else if ( _stampav = = 2 )
set_header ( r , " @107gConti con saldo <> 0 " ) ;
else set_header ( r , " @107gTutti i conti " ) ;
}
else
{
if ( _stampac = = 1 )
set_header ( r , " @107gTutti i conti movimentati " ) ;
else set_header ( r , " @107gConti con saldo <> 0 " ) ;
}
r + + ;
if ( _cdc_cod ! = 0L )
set_header ( r + + , " CENTRO DI COSTO %ld: %s " , _cdc_cod , ( const char * ) _cdc_descr ) ;
riga . fill ( ' - ' ) ;
set_header ( r , ( const char * ) riga ) ;
r + + ;
if ( ( ( _datada = = _dataini ) & & ( _tipo_stampa1 = = 1 ) ) | | ( _tipo_stampa1 ! = 1 ) )
{
//modifica del 21/11/1995
/*
if ( ( _verifica = = 1 ) | | ( _verifica = = 3 ) )
set_header ( r , " @7g!@16g!@49g!@58gSALDO INIZIALE@82g!@88gMOVIMENTI DEL PERIODO " ) ;
else
set_header ( r , " @7g!@49g!@58gSALDO INIZIALE@82g!@88gMOVIMENTI DEL PERIODO " ) ;
*/
if ( _tipo_stampa1 = = 1 & & _datada = = _dataini )
{
if ( ( _verifica = = 1 ) | | ( _verifica = = 3 ) )
set_header ( r , " @7g!@16g!@49g!@55gMOVIMENTI DI APERTURA@82g!@88gMOVIMENTI DEL PERIODO " ) ;
else
set_header ( r , " @7g!@49g!@55gMOVIMENTI DI APERTURA@82g!@88gMOVIMENTI DEL PERIODO " ) ;
}
else
{
if ( ( _verifica = = 1 ) | | ( _verifica = = 3 ) )
set_header ( r , " @7g!@16g!@49g!@58gSALDO INIZIALE@82g!@88gMOVIMENTI DEL PERIODO " ) ;
else
set_header ( r , " @7g!@49g!@58gSALDO INIZIALE@82g!@88gMOVIMENTI DEL PERIODO " ) ;
}
}
else if ( _tipo_stampa1 = = 1 )
if ( ( _verifica = = 1 ) | | ( _verifica = = 3 ) )
set_header ( r , " @7g!@16g!@49g!@55gPROGRESSIVI PRECEDENTI@82g!@88gMOVIMENTI DEL PERIODO " ) ;
else
set_header ( r , " @7g!@49g!@55gPROGRESSIVI PRECEDENTI@82g!@88gMOVIMENTI DEL PERIODO " ) ;
if ( _stampa_width = = 148 )
set_header ( r , " @115g!@130gSALDO@148g! " ) ;
else
set_header ( r , " @114g! " ) ;
r + + ;
if ( ( _verifica = = 1 ) | | ( _verifica = = 3 ) )
{
if ( _stampa_width = = 132 )
{
set_header ( r + + , " @2gcod. ! ultima !@49g!@50g%.32s@82g!@83g%.32s@114g!@121gSALDO " , ( const char * ) riga , ( const char * ) riga ) ;
set_header ( r + + , " @2gconto! data ! denominazione@49g!@57gDare@66g!@73gAvere@82g!@89gDare@98g!@104gAvere@114g! " ) ;
}
else
{
set_header ( r + + , " @2gcod. ! ultima !@49g!@50g%.32s@82g!@83g%.32s@115g!%.32s@148g! " , ( const char * ) riga , ( const char * ) riga , ( const char * ) riga ) ;
set_header ( r + + , " @2gconto! data ! denominazione@49g!@57gDare@66g!@73gAvere@82g!@91gDare@99g!@106gAvere@115g!@124gDare@132g!@139gAvere@148g! " ) ;
}
}
else
{
if ( _stampa_width = = 132 )
{
set_header ( r + + , " @2gcod. !@49g!@50g%.32s@82g!@83g%.32s@114g!@121gSALDO " , ( const char * ) riga , ( const char * ) riga ) ;
set_header ( r + + , " @1gmastro!descrizione@49g!@57gDare@66g!@73gAvere@82g!@89gDare@98g!@104gAvere@114g! " ) ;
}
else
{
set_header ( r + + , " @2gcod. !@49g!@50g%.32s@82g!@83g%.32s@115g!%.32s@148g! " , ( const char * ) riga , ( const char * ) riga , ( const char * ) riga ) ;
set_header ( r + + , " @1gmastro!descrizione@49g!@57gDare@66g!@73gAvere@82g!@91gDare@99g!@106gAvere@115g!@124gDare@132g!@139gAvere@148g! " ) ;
}
}
set_header ( r , ( const char * ) riga ) ;
if ( _stampa_width = = 148 )
set_header ( r , " @148g! " ) ;
}
}
int cgp1200 ( int argc , char * * argv )
{
TStampaBilanciCDC_application a ;
a . run ( argc , argv , " Stampa bilanci " ) ;
return 0 ;
}