1995-03-01 16:47:54 +00:00
//
1994-12-05 14:21:36 +00:00
//Lista movimenti
1995-03-01 16:47:54 +00:00
//
2000-10-03 13:45:12 +00:00
# include <currency.h>
1994-12-05 14:21:36 +00:00
# include <mask.h>
2002-07-02 16:21:23 +00:00
# include <modaut.h>
1994-12-05 14:21:36 +00:00
# include <printapp.h>
1999-04-06 15:34:39 +00:00
# include <recarray.h>
1994-12-05 14:21:36 +00:00
# include <tabutil.h>
1995-06-19 14:33:01 +00:00
# include "cg3.h"
# include "cg3100.h"
1996-12-10 08:23:20 +00:00
# include <attiv.h>
# include <causali.h>
# include <clifo.h>
# include <comuni.h>
1994-12-05 14:21:36 +00:00
# include <mov.h>
1996-12-10 08:23:20 +00:00
# include <nditte.h>
# include <pconti.h>
1994-12-05 14:21:36 +00:00
# include <rmov.h>
# include <rmoviva.h>
# include <saldi.h>
1996-12-10 08:23:20 +00:00
1997-06-19 14:33:52 +00:00
# include "cglib01.h"
1994-12-05 14:21:36 +00:00
# include "cglib03.h"
enum liste {
movimenti = 1 ,
fatture = 2 ,
} ;
bool filter_func ( const TRelation * ) ;
bool filter_func_fatture ( const TRelation * ) ;
1996-12-10 08:23:20 +00:00
bool annoes_handler ( TMask_field & , KEY ) ;
1994-12-05 14:21:36 +00:00
bool data_inizio ( TMask_field & , KEY ) ;
bool data_fine ( TMask_field & , KEY ) ;
class TListaMov_application : public TPrintapp
{
friend bool filter_func ( const TRelation * ) ;
friend bool filter_func_fatture ( const TRelation * ) ;
1996-12-10 08:23:20 +00:00
friend bool annoes_handler ( TMask_field & , KEY ) ;
1994-12-05 14:21:36 +00:00
friend bool data_inizio ( TMask_field & , KEY ) ;
friend bool data_fine ( TMask_field & , KEY ) ;
2002-07-02 16:21:23 +00:00
static bool cdc_handler ( TMask_field & f , KEY k ) ;
1996-08-02 12:44:22 +00:00
TRigaiva_array _c ;
1994-12-05 14:21:36 +00:00
TTable * _tabiva , * _tabtpd , * _tabreg , * _tabes ;
1995-03-01 16:47:54 +00:00
TRelation * _relmov1 , * _relmov2 , * _relmov3 ;
1994-12-05 14:21:36 +00:00
TCursor * _curr1 , * _curr2 , * _curr3 ;
TBit_array _err ;
TDate _data_ini , _data_fin , _datareg , _data_prec , _datacomp ;
TString _descr , _descr_doc , _descr_causale ;
1999-04-06 15:34:39 +00:00
TString _tipo_ini , _causale , _app ;
1994-12-05 14:21:36 +00:00
TString _causale_ini , _causale_fin , _registro , _registro_ini , _registro_fin ;
TString _tipoatt , _tipo_elenco , _tipo_clifo_prec , _cod , _tipoelsucc ;
1999-04-06 15:34:39 +00:00
char _appoggio ;
TString16 _tipodoc , _tipodocumento ;
1994-12-05 14:21:36 +00:00
TString _ragsoc , _indcf , _civcf , _paiv , _codcaus , _dencom , _provcom , _cofi ;
TString _capcf , _codval , _simbolo , _statocf , _comcf , _tipo_fin , _reg_causale ;
long _documenti , _codice_ini , _codice_fin , _numero_reg , _codcf ;
long _numreg , _numreg_fin , _numreg_ini , _codalleg , _numeroregp , _codclifosucc ;
long _codcf_prec , _numr , _numero ;
int _ae , _anno , _annoes , _annoeser ;
1997-10-20 14:23:01 +00:00
bool _noseparator ;
1994-12-05 14:21:36 +00:00
real _totdocumenti , _totdoc , _totimponibile , _totimposta , _importo ;
real _op_esenti , _op_non_imp , _impo , _impos ;
real _tot_dare , _tot_avere , _tot_avere_giornaliero ;
real _tot_dare_giornaliero , _tot_dare_generale , _tot_avere_generale ;
1994-12-20 09:36:33 +00:00
bool _intra , _no_preprocess_page , _salto_pagina , _stampa_anno_comp , _esiste_riga_iva , _nonesiste_riga_iva ;
1998-03-30 14:18:57 +00:00
bool _stampa_parte_iva , _alleg_causale , _stampa_mess_alleg_iva , _allegb ;
int _ricser ;
1995-01-13 10:08:02 +00:00
bool _settata_prima_riga , _causale_gia_stampata , _mov_di_sola_iva ;
1994-12-05 14:21:36 +00:00
int _cur1 , _cur2 , _cur2b , _cur3 , _cur4 , _decidi , _tipod , _controllo_mov_errati ;
int _numero_riga , _alleg , _tiporegistro , _tipocr , _scelta_stampa , _nr , _n ;
1995-05-29 16:03:19 +00:00
int _provvis ;
1994-12-05 14:21:36 +00:00
liste _tipo_lista ;
word _flags ;
1995-06-09 15:36:37 +00:00
char _tipoc ;
2002-07-02 16:21:23 +00:00
TString _cdc , _fsc ;
bool _cdc_only , _print_cdc ;
1999-04-06 15:34:39 +00:00
TDecoder _simbval , _descdoc ;
1994-12-05 14:21:36 +00:00
protected :
virtual void preprocess_header ( ) ;
virtual bool preprocess_page ( int , int ) ;
virtual print_action postprocess_page ( int , int ) ;
virtual print_action postprocess_print ( int , int ) ;
virtual void set_page ( int , int ) ;
virtual bool set_print ( int m ) ;
void init_print ( const TMask & m ) ;
2000-10-03 13:45:12 +00:00
void print_intra ( int & rr ) ;
2002-05-08 16:25:49 +00:00
void imposta_parametri_stampa ( const TMask & msk ) ;
void set_cdc_header ( int & soh ) ;
1994-12-05 14:21:36 +00:00
public :
1995-05-29 16:03:19 +00:00
bool user_create ( ) ;
1994-12-05 14:21:36 +00:00
bool user_destroy ( ) ;
bool segnala_errori_primariga ( ) ;
bool segnala_errori_ogniriga ( ) ;
bool segnala_errori_iva ( ) ;
1995-01-31 14:55:09 +00:00
bool contropartita ( int , int , long , char ) ;
1994-12-05 14:21:36 +00:00
void stampa_errori_rmov ( ) ;
void stampa_errori_mov ( ) ;
void stampa_errori_iva ( int * , const char * , const int , const int ) ;
1995-01-31 14:55:09 +00:00
void stampa_errori_contropartita ( int , int , long , char ) ;
1994-12-05 14:21:36 +00:00
void stampa_intestazione ( ) ;
void incrementa_totali ( ) ;
void compila_clifo ( ) ;
void compila_comuni ( ) ;
2003-06-19 11:04:54 +00:00
const char * get_error ( int error ) ;
1994-12-05 14:21:36 +00:00
1999-04-06 15:34:39 +00:00
bool RicercaDoc ( const char * ) ;
const TString & SimboloValuta ( const char * cod ) ;
const TString & DescrDoc ( const char * cod ) ;
2002-05-08 16:25:49 +00:00
const TString & cdc ( ) const { return _cdc ; }
2002-07-02 16:21:23 +00:00
const TString & fsc ( ) const { return _fsc ; }
2002-05-08 16:25:49 +00:00
1999-04-06 15:34:39 +00:00
TListaMov_application ( char tipost ) ;
1994-12-05 14:21:36 +00:00
virtual ~ TListaMov_application ( ) { }
} ;
HIDDEN inline TListaMov_application & app ( )
{ return ( TListaMov_application & ) main_app ( ) ; }
1996-12-10 08:23:20 +00:00
bool annoes_handler ( TMask_field & f , KEY k )
1994-12-05 14:21:36 +00:00
{
2000-10-03 13:45:12 +00:00
if ( k = = K_TAB & & f . focusdirty ( ) )
1994-12-05 14:21:36 +00:00
{
1996-12-10 08:23:20 +00:00
const int anno = atoi ( f . get ( ) ) ;
TEsercizi_contabili esc ;
if ( esc . exist ( anno ) )
1994-12-05 14:21:36 +00:00
{
1996-12-10 08:23:20 +00:00
f . mask ( ) . set ( F_DATAINI , esc [ anno ] . inizio ( ) ) ;
const int prossimo = esc . next ( anno ) ;
const TDate fine = esc [ prossimo > 0 ? prossimo : anno ] . fine ( ) ;
f . mask ( ) . set ( F_DATAFIN , fine ) ;
1994-12-05 14:21:36 +00:00
}
}
return TRUE ;
}
bool data_inizio ( TMask_field & f , KEY k )
{
if ( k = = K_ENTER )
{
int decidi ;
int anno = f . mask ( ) . get_int ( F_ANNO ) ;
TDate data = f . mask ( ) . get ( F_DATAINI ) ;
1999-04-06 15:34:39 +00:00
if ( app ( ) . _tipo_lista = = movimenti )
1994-12-05 14:21:36 +00:00
decidi = f . mask ( ) . get_int ( F_DECIDI ) ;
1996-12-10 08:23:20 +00:00
TEsercizi_contabili esc ;
1999-04-06 15:34:39 +00:00
if ( esc . exist ( anno ) & & ( ( app ( ) . _tipo_lista = = fatture ) | |
( ( app ( ) . _tipo_lista = = movimenti ) & & ( decidi = = 2 ) ) ) )
1994-12-05 14:21:36 +00:00
{
1996-12-10 08:23:20 +00:00
const TDate inizio = esc [ anno ] . inizio ( ) ;
if ( data . ok ( ) )
{
if ( data < inizio )
{
2003-03-14 15:13:36 +00:00
f . error_box ( TR ( " La data indicata non deve essere inferiore alla data di inizio esercizio " ) ) ;
1996-12-10 08:23:20 +00:00
return FALSE ;
}
}
else //se la data e' vuota
f . mask ( ) . field ( F_DATAINI ) . set ( inizio ) ;
1994-12-05 14:21:36 +00:00
}
}
return TRUE ;
}
bool data_fine ( TMask_field & f , KEY k )
{
if ( k = = K_ENTER )
{
int decidi ;
int anno = f . mask ( ) . get_int ( F_ANNO ) ;
TDate dataini = f . mask ( ) . get ( F_DATAINI ) ;
TDate datafin = f . mask ( ) . get ( F_DATAFIN ) ;
1999-04-06 15:34:39 +00:00
if ( app ( ) . _tipo_lista = = movimenti )
1994-12-05 14:21:36 +00:00
decidi = f . mask ( ) . get_int ( F_DECIDI ) ;
1999-04-06 15:34:39 +00:00
if ( ( app ( ) . _tipo_lista = = fatture ) | |
( ( app ( ) . _tipo_lista = = movimenti ) & & ( decidi = = 2 ) ) )
1994-12-05 14:21:36 +00:00
if ( dataini . ok ( ) & & datafin . ok ( ) )
if ( dataini > datafin )
{
2003-03-14 15:13:36 +00:00
f . error_box ( TR ( " La data iniziale non deve essere superiore alla data finale " ) ) ;
1994-12-05 14:21:36 +00:00
return FALSE ;
1996-12-10 08:23:20 +00:00
}
TEsercizi_contabili esc ;
1999-04-06 15:34:39 +00:00
if ( esc . exist ( anno ) & & ( ( app ( ) . _tipo_lista = = fatture ) | | ( ( app ( ) . _tipo_lista = = movimenti ) & & ( decidi = = 2 ) ) ) )
1996-12-10 08:23:20 +00:00
{
const int prossimo = esc . next ( anno ) ;
const TDate fine = esc [ prossimo > 0 ? prossimo : anno ] . fine ( ) ;
if ( datafin . ok ( ) )
{
if ( datafin > fine )
{
2003-03-14 15:13:36 +00:00
f . error_box ( TR ( " La data indicata non deve essere superiore alla data di fine esercizio successivo, oppure, in caso questo non esista, dell'esercizio indicato " ) ) ;
1996-12-10 08:23:20 +00:00
return FALSE ;
}
}
else //se la data e' vuota
f . mask ( ) . set ( F_DATAFIN , fine ) ;
1994-12-05 14:21:36 +00:00
}
}
return TRUE ;
}
2002-07-02 16:21:23 +00:00
bool TListaMov_application : : cdc_handler ( TMask_field & f , KEY k )
{
if ( k = = K_TAB )
{
TMask & m = f . mask ( ) ;
const bool on = ! ( m . field ( F_DACDC ) . empty ( ) & & m . field ( F_ACDC ) . empty ( ) ) ;
if ( ! on )
{
m . reset ( F_DAFASE ) ;
m . reset ( F_AFASE ) ;
m . reset ( F_CDC_ONLY ) ;
}
m . enable ( F_DAFASE , on ) ;
m . enable ( F_AFASE , on ) ;
m . enable ( F_CDC_ONLY , on ) ;
}
return TRUE ;
}
1994-12-05 14:21:36 +00:00
bool TListaMov_application : : RicercaDoc ( const char * tipo )
{
1997-10-20 14:23:01 +00:00
TTable tab_tpd ( TAB_TPD ) ;
1999-04-06 15:34:39 +00:00
TString16 codtab ; codtab . format ( " %-2s " , tipo ) ;
1994-12-05 14:21:36 +00:00
tab_tpd . zero ( ) ;
tab_tpd . put ( " CODTAB " , codtab ) ;
tab_tpd . read ( ) ;
if ( tab_tpd . good ( ) )
return TRUE ;
else
return FALSE ;
}
void TListaMov_application : : compila_clifo ( )
{
2003-03-14 15:13:36 +00:00
TToken_string key ;
key . add ( _tipo_elenco ) ;
key . add ( _codcf ) ;
const TRectype & clifo = cache ( ) . get ( LF_CLIFO , key ) ;
char tipoa = clifo . get_char ( " TIPOAPER " ) ;
_alleg = clifo . get_int ( CLI_ALLEG ) ;
_statocf = clifo . get ( CLI_STATOCF ) ;
_comcf = clifo . get ( CLI_COMCF ) ;
_ragsoc = clifo . get ( CLI_RAGSOC ) ;
if ( tipoa = = ' F ' )
1994-12-05 14:21:36 +00:00
{
2003-03-14 15:13:36 +00:00
TString80 cognome , nome ;
cognome = _ragsoc . mid ( 0 , 30 ) ;
nome = _ragsoc . mid ( 30 , 20 ) ;
cognome . trim ( ) ; nome . trim ( ) ;
_ragsoc = cognome ;
_ragsoc < < " " < < nome ;
1994-12-05 14:21:36 +00:00
}
2003-03-14 15:13:36 +00:00
_indcf = clifo . get ( CLI_INDCF ) ;
_civcf = clifo . get ( CLI_CIVCF ) ;
_paiv = clifo . get ( CLI_PAIV ) ;
_capcf = clifo . get ( CLI_CAPCF ) ;
_dencom = clifo . get ( CLI_LOCCF ) ;
_cofi = clifo . get ( CLI_COFI ) ;
_codalleg = clifo . get_long ( CLI_CODALLEG ) ;
1994-12-05 14:21:36 +00:00
}
void TListaMov_application : : compila_comuni ( )
{
2003-03-14 15:13:36 +00:00
TToken_string key ;
key . add ( _statocf ) ;
key . add ( _comcf ) ;
const TRectype & comuni = cache ( ) . get ( LF_COMUNI , key ) ;
1995-04-28 15:09:49 +00:00
//modifica del 26/04/1995
2003-03-14 15:13:36 +00:00
_dencom = comuni . get ( COM_DENCOM ) ;
1995-04-28 15:09:49 +00:00
if ( ! _dencom . empty ( ) )
_app = " Com " ;
else _app = " Loc " ;
//fine modifica
2003-03-14 15:13:36 +00:00
_provcom = comuni . get ( COM_PROVCOM ) ;
1994-12-05 14:21:36 +00:00
}
2003-06-19 11:04:54 +00:00
const char * TListaMov_application : : get_error ( int err )
{
switch ( err )
{
case 0 :
return TR ( " La data operazione non appartiene a nessun esercizio " ) ;
break ;
case 1 :
return TR ( " Anno IVA non compatibile con data operazione " ) ;
break ;
case 2 :
return TR ( " Data operazione successiva all'esercizio di competenza " ) ;
break ;
case 3 :
return TR ( " Movimento con competenza anno precedente " ) ;
break ;
case 4 :
return TR ( " La data di competenza non appartiene a nessun esercizio " ) ;
break ;
case 5 :
return TR ( " Data competenza incompatibile con data operazione " ) ;
break ;
case 6 :
return TR ( " Esercizio incompatibile con data competenza " ) ;
break ;
case 7 :
return TR ( " Codice causale non presente in tabella " ) ;
break ;
case 8 :
return TR ( " Codice causale sospeso " ) ;
break ;
case 9 :
return TR ( " Nella causale e' stato attivato il segnale non va in allegato " ) ;
break ;
case 10 :
return TR ( " Tipo documento non corrisponde a quello indicato in causale " ) ;
break ;
case 11 :
return TR ( " Tipo documento non presente in tabella " ) ;
break ;
case 12 :
return TR ( " Codice registro non corrisponde a quello indicato in causale " ) ;
break ;
case 13 :
return TR ( " Codice registro non presente in tabella " ) ;
break ;
case 14 :
return TR ( " Codice registro sospeso " ) ;
break ;
case 15 :
return TR ( " Tipo registro incompatibile con tipo documento " ) ;
break ;
case 16 :
return TR ( " Non indicato codice cliente/fornitore " ) ;
break ;
case 17 :
return TR ( " Tipo cliente/fornitore non compatibile con tipo registro " ) ;
break ;
case 18 :
return TR ( " Codice cliente/fornitore sospeso " ) ;
break ;
case 19 :
return TR ( " Nel cliente/fornitore e' stato attivato il segnale: non va in allegato " ) ;
break ;
case 20 :
return TR ( " Indicato codice C/F per allegato che richiama se stesso " ) ;
break ;
case 21 :
return TR ( " Indicato codice C/F per allegato sospeso " ) ;
break ;
case 22 :
return TR ( " C/F per allegato riporta un altro C/F per allegato " ) ;
break ;
case 23 :
return TR ( " Indicato codice C/F per allegato con segnale: non va in allegato " ) ;
break ;
case 24 :
return TR ( " Indicato codice C/F per allegato non presente in anagrafica " ) ;
break ;
case 25 :
return TR ( " Codice cliente/fornitore non presente in anagrafica " ) ;
break ;
case 26 :
return TR ( " Movimento con data competenza diversa da data operazione " ) ;
break ;
default :
return " " ;
break ;
}
}
1994-12-05 14:21:36 +00:00
const int AllegClifo ( int gruppo , int conto , long sottoconto )
{
TLocalisamfile clifo ( LF_CLIFO ) ;
int alleg ;
clifo . setkey ( 3 ) ;
clifo . zero ( ) ;
clifo . put ( CLI_GRUPPO , gruppo ) ;
clifo . put ( CLI_CONTO , conto ) ;
clifo . put ( CLI_CODCF , sottoconto ) ;
clifo . read ( ) ;
if ( clifo . good ( ) )
alleg = clifo . curr ( ) . get_int ( CLI_ALLEG ) ;
else
alleg = 0 ;
return alleg ;
}
const char * DescrConto ( long gruppo , long conto , long sottoconto ,
const char * tipocf )
{
2003-03-14 15:13:36 +00:00
TString key ( 30 ) ;
TString & tmp = get_tmp_string ( 50 ) ;
1994-12-05 14:21:36 +00:00
2003-03-14 15:13:36 +00:00
key < < gruppo ;
1994-12-05 14:21:36 +00:00
if ( conto ! = 0 )
2003-03-14 15:13:36 +00:00
key < < ' | ' < < conto ;
1994-12-05 14:21:36 +00:00
if ( sottoconto ! = 0 )
2003-03-14 15:13:36 +00:00
key < < ' | ' < < sottoconto ;
tmp = cache ( ) . get ( LF_PCON , key , PCN_DESCR ) ;
if ( tmp . empty ( ) )
1994-12-05 14:21:36 +00:00
{
2003-03-14 15:13:36 +00:00
key . format ( " %s|%ld " , tipocf , sottoconto ) ;
const TRectype & clifo = cache ( ) . get ( LF_CLIFO , key ) ;
if ( ! clifo . empty ( ) )
1994-12-05 14:21:36 +00:00
{
char tipoa = clifo . get_char ( " TIPOAPER " ) ;
if ( tipoa = = ' F ' ) //persona fisica
{
2003-03-14 15:13:36 +00:00
const TString & ragsoc = clifo . get ( " RAGSOC " ) ;
tmp = ragsoc . mid ( 0 , 30 ) ;
tmp . trim ( ) ;
tmp < < ' ' < < ragsoc . mid ( 30 ) ;
1994-12-05 14:21:36 +00:00
}
else
2003-03-14 15:13:36 +00:00
tmp = clifo . get ( " RAGSOC " ) ;
1994-12-05 14:21:36 +00:00
}
}
2003-03-14 15:13:36 +00:00
return tmp ;
1994-12-05 14:21:36 +00:00
}
bool CausAlleg ( const char * cod )
{
2003-03-14 15:13:36 +00:00
const TRectype & caus = cache ( ) . get ( LF_CAUSALI , cod ) ;
const bool allegb = caus . get_bool ( CAU_ALLEG ) ;
1994-12-05 14:21:36 +00:00
return allegb ;
}
const char * TipoAttivita ( const char * attreg , long codice_ditta )
{
2003-03-14 15:13:36 +00:00
TToken_string key ;
key . add ( codice_ditta ) ;
key . add ( attreg ) ;
const TRectype & attiv = cache ( ) . get ( LF_ATTIV , key ) ;
1994-12-05 14:21:36 +00:00
2003-03-14 15:13:36 +00:00
return attiv . get ( ATT_TIPOATT ) ;
1994-12-05 14:21:36 +00:00
}
1999-04-06 15:34:39 +00:00
const TString & TListaMov_application : : SimboloValuta ( const char * cod )
{
return _simbval . decode ( cod ) ;
1994-12-05 14:21:36 +00:00
}
1999-04-06 15:34:39 +00:00
const TString & TListaMov_application : : DescrDoc ( const char * tipo )
1994-12-05 14:21:36 +00:00
{
1999-04-06 15:34:39 +00:00
return _descdoc . decode ( tipo ) ;
1994-12-05 14:21:36 +00:00
}
const char * AttivitaRegistro ( const char * cod , int anno )
{
2003-03-14 15:13:36 +00:00
TString16 key ;
key . format ( " %04d%-3s " , anno , cod ) ;
1994-12-05 14:21:36 +00:00
2003-03-14 15:13:36 +00:00
return cache ( ) . get ( " REG " , key , " S8 " ) ;
1994-12-05 14:21:36 +00:00
}
1999-04-06 15:34:39 +00:00
int CodiceRegistro ( const char * cod , int anno )
{
TString16 codtab ; codtab . format ( " %4d%-3s " , anno , cod ) ;
2002-05-08 16:25:49 +00:00
const TString & tipo_reg = cache ( ) . get ( " REG " , codtab , " I0 " ) ;
2003-03-14 15:13:36 +00:00
2002-05-08 16:25:49 +00:00
return atoi ( tipo_reg ) ;
}
// Controlla che il movimento abbia almeno una riga con la commessa voluta
bool cdc_filter ( const TRelation * rel )
{
bool ok = FALSE ;
TLocalisamfile & rmov = rel - > lfile ( LF_RMOV ) ;
const TRecnotype oldpos = rmov . recno ( ) ;
const long numreg = rel - > curr ( LF_MOV ) . get_long ( MOV_NUMREG ) ;
const TString & cdc = app ( ) . cdc ( ) ;
2002-07-02 16:21:23 +00:00
const TString & fsc = app ( ) . fsc ( ) ;
2002-05-08 16:25:49 +00:00
rmov . zero ( ) ;
rmov . put ( RMV_NUMREG , numreg ) ;
rmov . put ( RMV_NUMRIG , 1 ) ;
for ( int err = rmov . read ( _isgteq ) ; err = = NOERR ; err = rmov . next ( ) )
{
if ( rmov . get_long ( RMV_NUMREG ) ! = numreg )
break ;
if ( rmov . get ( RMV_CODCMS ) = = cdc )
2002-07-02 16:21:23 +00:00
{
2002-09-13 14:06:05 +00:00
if ( fsc . not_empty ( ) )
ok = ( rmov . get ( RMV_FASCMS ) = = fsc ) ;
else
ok = TRUE ;
if ( ok )
break ;
2002-05-08 16:25:49 +00:00
}
}
rmov . readat ( oldpos ) ;
return ok ;
1994-12-05 14:21:36 +00:00
}
1998-04-30 15:59:34 +00:00
bool filter_func_fatture ( const TRelation * rel )
1994-12-05 14:21:36 +00:00
{
2002-05-08 16:25:49 +00:00
const TRectype & mov = rel - > curr ( LF_MOV ) ;
1998-04-30 15:59:34 +00:00
// Altrimenti stampa anche i corrispettivi! Pseudo errore MI2396
long codcf = mov . get_long ( MOV_CODCF ) ;
if ( codcf < = 0 )
return FALSE ;
2002-05-08 16:25:49 +00:00
const int ann_reg = mov . get_int ( MOV_ANNOIVA ) ;
const TString16 cod_reg = mov . get ( MOV_REG ) ;
const int tipo_reg = CodiceRegistro ( cod_reg , ann_reg ) ;
1998-04-30 15:59:34 +00:00
// Considera solo iva acquisti o vendite
if ( tipo_reg ! = 1 & & tipo_reg ! = 2 )
return FALSE ;
TRectype from ( LF_MOV ) , to ( LF_MOV ) ;
1994-12-05 14:21:36 +00:00
if ( app ( ) . _annoes ! = 0 ) //anno esercizio specificato nella maschera
{
from . put ( MOV_ANNOES , app ( ) . _annoes ) ;
to . put ( MOV_ANNOES , app ( ) . _annoes ) ;
}
if ( app ( ) . _data_ini . ok ( ) )
from . put ( MOV_DATAREG , app ( ) . _data_ini ) ;
from . put ( MOV_TIPO , app ( ) . _tipo_ini ) ;
if ( app ( ) . _codice_ini ! = 0 )
from . put ( MOV_CODCF , app ( ) . _codice_ini ) ;
if ( app ( ) . _data_fin . ok ( ) )
to . put ( MOV_DATAREG , app ( ) . _data_fin ) ;
to . put ( MOV_TIPO , app ( ) . _tipo_fin ) ;
if ( app ( ) . _codice_fin ! = 0 )
to . put ( MOV_CODCF , app ( ) . _codice_fin ) ;
2002-05-08 16:25:49 +00:00
bool ok = mov > = from & & mov < = to ;
if ( ok & & app ( ) . cdc ( ) . not_empty ( ) )
ok = cdc_filter ( rel ) ;
1994-12-05 14:21:36 +00:00
2002-05-08 16:25:49 +00:00
return ok ;
1994-12-05 14:21:36 +00:00
}
bool filter_func ( const TRelation * rel )
2002-05-08 16:25:49 +00:00
{
bool ok = FALSE ;
1994-12-05 14:21:36 +00:00
int tipo_reg , ann_reg ;
TString cod_reg , causale ;
TLocalisamfile * mov = & ( rel - > lfile ( LF_MOV ) ) ;
TRectype from ( mov - > curr ( ) ) ;
TRectype to ( mov - > curr ( ) ) ;
switch ( app ( ) . _scelta_stampa )
{
case 0 :
ann_reg = mov - > get_int ( MOV_ANNOIVA ) ;
causale = mov - > get ( MOV_CODCAUS ) ;
from . zero ( ) ;
to . zero ( ) ;
if ( ( app ( ) . _decidi = = 2 ) & & ( app ( ) . _annoes ! = 0 ) )
{
from . put ( MOV_ANNOES , app ( ) . _annoes ) ;
to . put ( MOV_ANNOES , app ( ) . _annoes ) ;
}
from . put ( MOV_CODCAUS , app ( ) . _causale_ini ) ;
to . put ( MOV_CODCAUS , app ( ) . _causale_fin ) ;
from . put ( MOV_REG , app ( ) . _registro_ini ) ;
to . put ( MOV_REG , app ( ) . _registro_fin ) ;
2002-05-08 16:25:49 +00:00
ok = ( mov - > curr ( ) > = from ) & & ( mov - > curr ( ) < = to ) ;
1994-12-05 14:21:36 +00:00
break ;
case 1 :
cod_reg = mov - > get ( MOV_REG ) ;
ann_reg = mov - > get_int ( MOV_ANNOIVA ) ;
tipo_reg = CodiceRegistro ( cod_reg , ann_reg ) ;
causale = mov - > get ( MOV_CODCAUS ) ;
from . zero ( ) ;
to . zero ( ) ;
if ( ( app ( ) . _decidi = = 2 ) & & ( app ( ) . _annoes ! = 0 ) )
{
from . put ( MOV_ANNOES , app ( ) . _annoes ) ;
to . put ( MOV_ANNOES , app ( ) . _annoes ) ;
}
from . put ( MOV_CODCAUS , app ( ) . _causale_ini ) ;
to . put ( MOV_CODCAUS , app ( ) . _causale_fin ) ;
2002-05-08 16:25:49 +00:00
ok = ( ( mov - > curr ( ) > = from ) & & ( mov - > curr ( ) < = to ) ) & &
( ( tipo_reg ! = 1 ) & & ( tipo_reg ! = 2 ) ) ;
1994-12-05 14:21:36 +00:00
break ;
default :
break ;
}
2002-05-08 16:25:49 +00:00
if ( ok & & app ( ) . cdc ( ) . not_empty ( ) )
ok = cdc_filter ( rel ) ;
return ok ;
1994-12-05 14:21:36 +00:00
}
void TListaMov_application : : stampa_errori_rmov ( )
{
TRectype rec ( current_cursor ( ) - > file ( LF_RMOV ) . curr ( ) ) ;
int gruppo = rec . get_int ( RMV_GRUPPO ) ;
int conto = rec . get_int ( RMV_CONTO ) ;
1995-01-31 14:55:09 +00:00
long sottoconto = rec . get_long ( RMV_SOTTOCONTO ) ;
int anno = rec . get_int ( RMV_ANNOES ) ;
TDate datareg = rec . get_date ( RMV_DATAREG ) ;
char sez = rec . get_char ( RMV_SEZIONE ) ;
char tipo = rec . get_char ( RMV_TIPOC ) ;
int gruppoc = rec . get_int ( RMV_GRUPPOC ) ;
int contoc = rec . get_int ( RMV_CONTOC ) ;
long sottocontoc = rec . get_long ( RMV_SOTTOCONTOC ) ;
char tipoc = rec . get_char ( RMV_TIPOCC ) ;
1994-12-05 14:21:36 +00:00
bool g = FALSE ;
char t ;
1997-06-19 14:33:52 +00:00
TBill tc ( gruppo , conto , sottoconto ) ;
1994-12-05 14:21:36 +00:00
_nr + + ;
if ( anno ! = _annoeser | | datareg ! = _datareg )
2003-03-14 15:13:36 +00:00
set_row ( _nr + + , FR ( " @11gUno o piu' campi non sono costanti nella riga dell' operazione " ) ) ;
1994-12-05 14:21:36 +00:00
if ( sez ! = ' D ' & & sez ! = ' A ' )
2003-03-14 15:13:36 +00:00
set_row ( _nr + + , FR ( " @11gIndicato tipo movimento Dare/Avere errato " ) ) ;
1994-12-05 14:21:36 +00:00
if ( tc . empty ( ) )
2003-03-14 15:13:36 +00:00
set_row ( _nr + + , FR ( " @11gNon presente codice gruppo/conto/sottoconto " ) ) ;
1994-12-05 14:21:36 +00:00
if ( ! tc . ok ( ) )
2003-03-14 15:13:36 +00:00
set_row ( _nr + + , FR ( " @11gCodice gruppo/conto/sottoconto non corrisponde ad un sottoconto " ) ) ;
1994-12-05 14:21:36 +00:00
2003-03-14 15:13:36 +00:00
TRectype pc ( LF_PCON ) ;
1994-12-05 14:21:36 +00:00
tc . set ( gruppo , 0 , 0l ) ;
if ( ! tc . read ( pc ) )
g = TRUE ;
tc . set ( gruppo , conto , 0l ) ;
if ( ! tc . read ( pc ) )
2003-03-14 15:13:36 +00:00
set_row ( _nr + + , FR ( " @11gCodice gruppo/conto/sottoconto non presente in Piano dei Conti " ) ) ;
1994-12-05 14:21:36 +00:00
else
{
t = pc . get_char ( PCN_TMCF ) ;
if ( t ! = tipo )
2003-03-14 15:13:36 +00:00
set_row ( _nr + + , FR ( " @11gIl tipo C/F indicato non corrisponde a quello presente su Piano dei Conti " ) ) ;
1994-12-05 14:21:36 +00:00
else
{
tc . set ( gruppo , conto , sottoconto ) ;
if ( t ! = ' C ' & & t ! = ' F ' )
{
if ( ! tc . read ( pc ) | | g )
2003-03-14 15:13:36 +00:00
set_row ( _nr + + , FR ( " @11gCodice gruppo/conto/sottoconto non presente in Piano dei Conti " ) ) ;
1994-12-05 14:21:36 +00:00
else
{
bool sosp = tc . sospeso ( ) ;
if ( sosp )
2003-03-14 15:13:36 +00:00
set_row ( _nr + + , FR ( " @11gCodice gruppo/conto/sottoconto sospeso in Piano dei Conti " ) ) ;
1994-12-05 14:21:36 +00:00
}
}
else
{
2003-03-14 15:13:36 +00:00
TToken_string key ;
key . add ( t ) ;
key . add ( sottoconto ) ;
const TRectype & clifo = cache ( ) . get ( LF_CLIFO , key ) ;
if ( ! clifo . empty ( ) )
1994-12-05 14:21:36 +00:00
{
bool sosp = clifo . get_bool ( CLI_SOSPESO ) ;
if ( sosp )
2003-03-14 15:13:36 +00:00
set_row ( _nr + + , FR ( " @11gCodice C/F sospeso in Anagrafica " ) ) ;
1994-12-05 14:21:36 +00:00
}
2003-03-14 15:13:36 +00:00
else set_row ( _nr + + , FR ( " @11gCodice C/F non presente in Anagrafica " ) ) ;
1994-12-05 14:21:36 +00:00
if ( _registro . not_empty ( ) ) //se su mov e' indicato il codice registro
{
TRegistro rg ( _registro , _ae ) ;
const int tiporeg = rg . tipo ( ) ;
if ( ( tiporeg = = 1 & & t ! = ' C ' ) | | ( tiporeg = = 2 & & t ! = ' F ' ) )
2003-03-14 15:13:36 +00:00
set_row ( _nr + + , FR ( " @11gTipo C/F non compatibile con tipo registro " ) ) ;
1994-12-05 14:21:36 +00:00
}
}
}
}
2003-03-14 15:13:36 +00:00
TString key ( 30 ) ;
key . format ( " %d||%d|%d|%ld " , anno , gruppo , conto , sottoconto ) ;
const TRectype & saldi = cache ( ) . get ( LF_SALDI , key ) ;
if ( saldi . empty ( ) )
set_row ( _nr + + , FR ( " @11gCodice gruppo/conto/sottoconto non presente in Saldi p.d.c. " ) ) ;
1994-12-05 14:21:36 +00:00
1995-01-31 14:55:09 +00:00
if ( gruppoc ! = 0 | | contoc ! = 0 | | sottocontoc ! = 0l )
stampa_errori_contropartita ( gruppoc , contoc , sottocontoc , tipoc ) ;
1994-12-05 14:21:36 +00:00
}
1995-01-31 14:55:09 +00:00
void TListaMov_application : : stampa_errori_contropartita ( int gruppo , int conto , long sottoconto , char t )
1994-12-05 14:21:36 +00:00
{
bool g = FALSE ;
1995-01-31 14:55:09 +00:00
1997-06-19 14:33:52 +00:00
TBill tc ;
2003-03-14 15:13:36 +00:00
TRectype pc ( LF_PCON ) ;
1994-12-05 14:21:36 +00:00
tc . set ( gruppo , 0 , 0l ) ;
if ( ! tc . read ( pc ) )
g = TRUE ;
tc . set ( gruppo , conto , 0l ) ;
if ( ! tc . read ( pc ) )
2003-03-14 15:13:36 +00:00
set_row ( _nr + + , FR ( " @11gCodice gruppo/conto/sottoconto di contropartita non presente in Piano dei Conti " ) ) ;
1994-12-05 14:21:36 +00:00
else
{
1995-01-31 14:55:09 +00:00
//t = pc.get_char(PCN_TMCF);
1994-12-05 14:21:36 +00:00
tc . set ( gruppo , conto , sottoconto ) ;
if ( t ! = ' C ' & & t ! = ' F ' )
{
if ( ! tc . read ( pc ) | | g )
2003-03-14 15:13:36 +00:00
set_row ( _nr + + , FR ( " @11gCodice gruppo/conto/sottoconto di contropartita non presente in Piano dei Conti " ) ) ;
1994-12-05 14:21:36 +00:00
else
{
bool sosp = tc . sospeso ( ) ;
if ( sosp )
2003-03-14 15:13:36 +00:00
set_row ( _nr + + , FR ( " @11gCodice gruppo/conto/sottoconto di contropartita sospeso in Piano dei Conti " ) ) ;
1994-12-05 14:21:36 +00:00
}
}
1995-01-31 14:55:09 +00:00
else if ( sottoconto ! = 0l )
1994-12-05 14:21:36 +00:00
{
2003-03-14 15:13:36 +00:00
TToken_string key ;
key . add ( t ) ;
key . add ( sottoconto ) ;
const TRectype & clifo = cache ( ) . get ( LF_CLIFO , key ) ;
if ( ! clifo . empty ( ) )
1994-12-05 14:21:36 +00:00
{
bool sosp = clifo . get_bool ( CLI_SOSPESO ) ;
if ( sosp )
2003-03-14 15:13:36 +00:00
set_row ( _nr + + , FR ( " @11gCodice C/F di contropartita sospeso in Anagrafica " ) ) ;
1994-12-05 14:21:36 +00:00
}
2003-03-14 15:13:36 +00:00
else set_row ( _nr + + , FR ( " @11gCodice C/F di contropartita non presente in Anagrafica " ) ) ;
1994-12-05 14:21:36 +00:00
}
}
}
void TListaMov_application : : stampa_errori_iva ( int * nr , const char * cod , const int tipodet , const int tipocr )
{
TTable tab_iva ( " %IVA " ) ;
tab_iva . zero ( ) ;
tab_iva . put ( " CODTAB " , cod ) ;
if ( tab_iva . read ( ) = = NOERR )
{
int allc = tab_iva . get_int ( " S7 " ) ;
int allf = tab_iva . get_int ( " S8 " ) ;
bool s = tab_iva . get_bool ( " B2 " ) ;
if ( s )
2003-03-14 15:13:36 +00:00
set_row ( + + ( * nr ) , FR ( " @11gCodice IVA sospeso " ) ) ;
1994-12-05 14:21:36 +00:00
if ( _stampa_mess_alleg_iva )
if ( allc = = 0 | | allf = = 0 )
2003-03-14 15:13:36 +00:00
set_row ( + + ( * nr ) , FR ( " @11gSul Codice IVA non e' stato indicato un valore per allegato " ) ) ;
1994-12-05 14:21:36 +00:00
}
else
2003-03-14 15:13:36 +00:00
set_row ( + + ( * nr ) , FR ( " @11gCodice IVA non presente in tabella " ) ) ;
1994-12-05 14:21:36 +00:00
if ( tipodet = = 1 | | tipodet = = 3 | | tipodet = = 5 | | tipodet = = 9 )
if ( _tiporegistro ! = 2 )
2003-03-14 15:13:36 +00:00
set_row ( + + ( * nr ) , FR ( " @11gCodice di indetraibilita' errato " ) ) ;
1994-12-05 14:21:36 +00:00
if ( _tiporegistro = = 1 )
if ( tipocr ! = 0 & & tipocr ! = 1 & & tipocr ! = 4 & & tipocr ! = 9 )
2003-03-14 15:13:36 +00:00
set_row ( + + ( * nr ) , FR ( " @11gTipo costo/ricavo non valido " ) ) ;
1994-12-05 14:21:36 +00:00
if ( _tiporegistro = = 2 )
if ( tipocr ! = 0 & & tipocr ! = 1 & & tipocr ! = 2 & & tipocr ! = 3 & & tipocr ! = 5 & & tipocr ! = 8 & & tipocr ! = 9 )
2003-03-14 15:13:36 +00:00
set_row ( + + ( * nr ) , FR ( " @11gTipo costo/ricavo non valido " ) ) ;
1994-12-05 14:21:36 +00:00
}
void TListaMov_application : : stampa_errori_mov ( )
{
long i = _err . first_one ( ) ;
if ( i ! = - 1 )
{
for ( ; i < = _err . last_one ( ) ; i + + )
if ( _err [ i ] )
2003-06-19 11:04:54 +00:00
set_row ( + + _n , " @11g%s " , ( const char * ) get_error ( i ) ) ;
1994-12-05 14:21:36 +00:00
}
}
void TListaMov_application : : set_page ( int file , int count )
{
switch ( _tipo_lista )
{
case movimenti :
if ( file = = LF_RMOVIVA )
break ;
if ( file = = LF_RMOV )
{
_nr = 1 ;
2002-07-02 16:21:23 +00:00
const TRectype & rec = current_cursor ( ) - > curr ( LF_RMOV ) ;
2002-05-08 16:25:49 +00:00
if ( _cdc . not_empty ( ) )
{
if ( rec . get ( RMV_CODCMS ) = = _cdc )
2002-07-02 16:21:23 +00:00
{
2002-09-13 14:06:05 +00:00
if ( _fsc . not_empty ( ) )
{
if ( rec . get ( RMV_FASCMS ) = = _fsc )
{
if ( ! _cdc_only )
set_row ( _nr , " @0g@b " ) ; // Grassettiamo le righe interessate
}
else
{
if ( _cdc_only )
return ;
}
}
else
if ( ! _cdc_only )
set_row ( _nr , " @0g@b " ) ; // Grassettiamo le righe interessate
2002-05-08 16:25:49 +00:00
}
else
{
if ( _cdc_only )
return ;
}
}
1994-12-05 14:21:36 +00:00
set_row ( _nr , " @3n " , FLD ( LF_RMOV , RMV_NUMRIG ) ) ;
1997-10-20 14:23:01 +00:00
set_row ( _nr , " @30g@22s " , FLD ( LF_RMOV , RMV_DESCR ) ) ;
1999-07-16 14:59:11 +00:00
set_row ( _nr , " @54g@3,rn " , FLD ( LF_RMOV , RMV_GRUPPO ) ) ;
set_row ( _nr , " @58g@3,rn " , FLD ( LF_RMOV , RMV_CONTO ) ) ;
set_row ( _nr , " @62g@6,rn " , FLD ( LF_RMOV , RMV_SOTTOCONTO ) ) ;
1997-10-20 14:23:01 +00:00
set_row ( _nr , " @69g#.20t " , & _descr ) ;
1999-04-06 15:34:39 +00:00
_appoggio = toupper ( current_cursor ( ) - > curr ( LF_RMOV ) . get_char ( RMV_SEZIONE ) ) ;
if ( _appoggio = = ' D ' )
1997-10-20 14:23:01 +00:00
set_row ( _nr , " @90g@n " , FLD ( LF_RMOV , RMV_IMPORTO ) ) ;
1994-12-05 14:21:36 +00:00
else
1997-10-20 14:23:01 +00:00
set_row ( _nr , " @110g@n " , FLD ( LF_RMOV , RMV_IMPORTO ) ) ;
2002-07-02 16:21:23 +00:00
if ( _print_cdc )
{
2002-09-13 14:06:05 +00:00
TString80 cms = rec . get ( RMV_CODCMS ) ;
2002-07-02 16:21:23 +00:00
if ( cms . not_empty ( ) )
{
2002-09-13 14:06:05 +00:00
TString riga_commessa ( 132 ) ;
riga_commessa < < " @0g@b " < < cms ;
riga_commessa < < " @21g " < < cache ( ) . get ( " CMS " , cms , " S0 " ) ;
2002-07-02 16:21:23 +00:00
cms = rec . get ( RMV_FASCMS ) ;
if ( cms . not_empty ( ) )
{
2002-09-13 14:06:05 +00:00
riga_commessa < < " @72g " < < cms ;
riga_commessa < < " @83g " < < cache ( ) . get ( " FSC " , cms , " S0 " ) ;
2002-07-02 16:21:23 +00:00
}
2002-09-13 14:06:05 +00:00
set_row ( _nr + 1 , riga_commessa ) ;
2002-07-02 16:21:23 +00:00
}
2002-09-13 14:06:05 +00:00
}
1994-12-05 14:21:36 +00:00
}
else if ( file = = LF_MOV )
{
_n = 1 ;
1997-10-20 14:23:01 +00:00
set_row ( _n + + , " " ) ;
2003-03-14 15:13:36 +00:00
set_row ( _n , FR ( " Operazione n. @14g@7n " ) , FLD ( LF_MOV , MOV_NUMREG ) ) ;
set_row ( _n , FR ( " @22gdel@26g@d " ) , FLD ( LF_MOV , MOV_DATAREG ) ) ;
1994-12-05 14:21:36 +00:00
set_row ( _n , " @37g@36s " , FLD ( LF_MOV , MOV_DESCR ) ) ;
2003-03-14 15:13:36 +00:00
set_row ( _n , FR ( " @75gdoc. @7s " ) , FLD ( LF_MOV , MOV_NUMDOC ) ) ;
set_row ( _n , FR ( " @88gdel@92g@d " ) , FLD ( LF_MOV , MOV_DATADOC ) ) ;
1994-12-05 14:21:36 +00:00
int annoese = current_cursor ( ) - > curr ( LF_MOV ) . get_int ( MOV_ANNOES ) ;
TDate data = current_cursor ( ) - > curr ( LF_MOV ) . get_date ( MOV_DATAREG ) ;
1996-01-03 15:06:24 +00:00
TDate dcomp = current_cursor ( ) - > curr ( LF_MOV ) . get_date ( MOV_DATACOMP ) ;
1994-12-05 14:21:36 +00:00
TString16 reg = current_cursor ( ) - > curr ( LF_MOV ) . get ( MOV_REG ) ;
int anno = current_cursor ( ) - > curr ( LF_MOV ) . get_int ( MOV_ANNOIVA ) ;
1995-04-19 13:13:21 +00:00
char prov = current_cursor ( ) - > curr ( LF_MOV ) . get_char ( MOV_PROVVIS ) ;
1994-12-05 14:21:36 +00:00
int tipo = CodiceRegistro ( reg , anno ) ;
1996-12-10 08:23:20 +00:00
TEsercizi_contabili esc ;
int ae = esc . date2esc ( data ) ;
1994-12-05 14:21:36 +00:00
if ( ( tipo = = 1 ) | | ( tipo = = 2 ) )
{
2003-03-14 15:13:36 +00:00
set_row ( _n , FR ( " @103greg @3s " ) , FLD ( LF_MOV , MOV_REG ) ) ;
set_row ( _n , FR ( " @111gpr @5n " ) , FLD ( LF_MOV , MOV_PROTIVA ) ) ;
1994-12-05 14:21:36 +00:00
}
1997-06-26 08:37:35 +00:00
else if ( _provvis = = 2 & & prov > = ' ' )
2003-03-14 15:13:36 +00:00
set_row ( _n , FR ( " @103gMov.Provvisorio " ) ) ;
1996-01-03 15:06:24 +00:00
if ( data ! = dcomp )
set_row ( _n , " @119gc.%s " , ( const char * ) dcomp . string ( brief , ' - ' ) ) ;
//fine
1994-12-05 14:21:36 +00:00
set_row ( _n , " @130g@f " , FLD ( LF_MOV , MOV_STAMPATO ) ) ;
}
break ;
default :
break ;
}
}
void TListaMov_application : : stampa_intestazione ( )
{
1997-10-20 14:23:01 +00:00
set_row ( 1 , " " ) ;
1994-12-05 14:21:36 +00:00
if ( _tipo_elenco = = " C " )
2003-03-14 15:13:36 +00:00
set_row ( 2 , FR ( " @bCliente@8g@6n " ) , FLD ( LF_MOV , MOV_CODCF ) ) ;
1994-12-05 14:21:36 +00:00
else
2003-03-14 15:13:36 +00:00
set_row ( 2 , FR ( " @bFornitore@10g@6n " ) , FLD ( LF_MOV , MOV_CODCF ) ) ;
1994-12-20 09:36:33 +00:00
set_row ( 2 , " @b@18g#.35t " , & _ragsoc ) ;
2003-03-14 15:13:36 +00:00
set_row ( 2 , FR ( " @b@54gInd #-.29t #-.10t " ) , & _indcf , & _civcf ) ;
set_row ( 2 , FR ( " @b@98gP.I. #11t " ) , & _paiv ) ;
1994-12-05 14:21:36 +00:00
if ( _alleg = = 0 )
2003-03-14 15:13:36 +00:00
set_row ( 2 , FR ( " @b@121gAllegato SI " ) ) ;
1995-11-17 14:29:24 +00:00
else
2003-03-14 15:13:36 +00:00
set_row ( 2 , FR ( " @b@121gAllegato NO " ) ) ;
set_row ( 3 , FR ( " @b@54gCap #5t " ) , & _capcf ) ;
1995-11-17 14:29:24 +00:00
set_row ( 3 , " @b@64g%s #-.20t Pr #-.5t " ,
( const char * ) _app , & _dencom , & _provcom ) ;
2003-03-14 15:13:36 +00:00
set_row ( 3 , FR ( " @b@98gC.F. #-16t " ) , & _cofi ) ;
1994-12-05 14:21:36 +00:00
if ( _alleg = = 0 )
2003-03-14 15:13:36 +00:00
set_row ( 3 , FR ( " @b@120gRifer@126g#6d " ) , & _codalleg ) ;
1994-12-05 14:21:36 +00:00
}
bool TListaMov_application : : preprocess_page ( int file , int counter )
{
1995-03-01 16:47:54 +00:00
TCursor * cur = current_cursor ( ) ;
1994-12-05 14:21:36 +00:00
if ( counter ) return TRUE ;
switch ( _tipo_lista )
{
case movimenti :
if ( _scelta_stampa = = 0 )
{
if ( file = = LF_MOV )
{
_tot_avere = 0 ;
_tot_dare = 0 ;
_c . destroy ( ) ;
_no_preprocess_page = FALSE ;
_esiste_riga_iva = FALSE ;
_nonesiste_riga_iva = FALSE ;
_annoeser = current_cursor ( ) - > curr ( LF_MOV ) . get_int ( MOV_ANNOES ) ;
_datacomp = current_cursor ( ) - > curr ( LF_MOV ) . get_date ( MOV_DATACOMP ) ;
_causale = current_cursor ( ) - > curr ( LF_MOV ) . get ( MOV_CODCAUS ) ;
_registro = current_cursor ( ) - > curr ( LF_MOV ) . get ( MOV_REG ) ;
1995-01-13 10:08:02 +00:00
_anno = current_cursor ( ) - > curr ( LF_MOV ) . get_int ( MOV_ANNOIVA ) ;
1994-12-05 14:21:36 +00:00
_tipodoc = current_cursor ( ) - > curr ( LF_MOV ) . get ( MOV_TIPODOC ) ;
_datareg = current_cursor ( ) - > file ( LF_MOV ) . get_date ( MOV_DATAREG ) ;
1995-01-13 10:08:02 +00:00
_tipo_elenco = current_cursor ( ) - > file ( LF_MOV ) . get ( MOV_TIPO ) ;
1994-12-05 14:21:36 +00:00
_codcf = current_cursor ( ) - > file ( LF_MOV ) . get_long ( MOV_CODCF ) ;
_numero = current_cursor ( ) - > file ( LF_MOV ) . get_long ( MOV_NUMREG ) ;
1994-12-20 09:36:33 +00:00
_codval = cur - > curr ( LF_MOV ) . get ( MOV_CODVALI ) ;
1994-12-05 14:21:36 +00:00
_tiporegistro = CodiceRegistro ( _registro , _anno ) ;
_causale_gia_stampata = FALSE ;
1996-12-10 08:23:20 +00:00
TEsercizi_contabili esc ;
_ae = esc . date2esc ( _datareg ) ;
1995-01-13 10:08:02 +00:00
if ( _registro . not_empty ( ) ) //si tratta di fattura
if ( current_cursor ( ) - > is_first_match ( LF_RMOV ) )
_mov_di_sola_iva = FALSE ;
else _mov_di_sola_iva = TRUE ;
_descr_doc = DescrDoc ( _tipodoc ) ;
1994-12-05 14:21:36 +00:00
TLocalisamfile & fl = current_cursor ( ) - > file ( LF_MOV ) ;
TRectype da ( fl . curr ( ) ) ;
TRectype a ( fl . curr ( ) ) ;
da . zero ( ) ;
a . zero ( ) ;
if ( _annoes ! = 0 )
{
da . put ( MOV_ANNOES , _annoes ) ;
a . put ( MOV_ANNOES , _annoes ) ;
}
da . put ( MOV_CODCAUS , _causale_ini ) ;
da . put ( MOV_REG , _registro_ini ) ;
a . put ( MOV_CODCAUS , _causale_fin ) ;
a . put ( MOV_REG , _registro_fin ) ;
if ( ( fl . curr ( ) > = da ) & & ( fl . curr ( ) < = a ) )
2003-03-14 15:13:36 +00:00
{
const TRectype & caus = cache ( ) . get ( LF_CAUSALI , _causale ) ;
_reg_causale = caus . get ( CAU_REG ) ;
_descr_causale = caus . get ( CAU_DESCR ) ;
_alleg_causale = caus . get_bool ( CAU_ALLEG ) ;
_tipodocumento = caus . get ( CAU_TIPODOC ) ;
1994-12-05 14:21:36 +00:00
if ( _controllo_mov_errati = = 1 | | _controllo_mov_errati = = 2 )
{
bool controlla = segnala_errori_primariga ( ) ;
bool verifica = ( _stampa_parte_iva & & segnala_errori_iva ( ) ) | | segnala_errori_ogniriga ( ) ;
if ( ( _controllo_mov_errati = = 1 & & controlla )
| | _controllo_mov_errati = = 2 )
{
stampa_errori_mov ( ) ;
return TRUE ;
}
else if ( _controllo_mov_errati = = 1 & & ! verifica )
return FALSE ;
else return TRUE ;
}
else return TRUE ;
}
}
else if ( file = = LF_RMOV )
{
if ( ! _causale_gia_stampata )
{
set_row ( _nr , " @4g%3s " , ( const char * ) _causale ) ;
1995-01-13 10:08:02 +00:00
set_row ( _nr , " @8g%-.20s " , ( const char * ) _descr_causale ) ;
1994-12-05 14:21:36 +00:00
_causale_gia_stampata = TRUE ;
}
int gruppo = current_cursor ( ) - > curr ( LF_RMOV ) . get_int ( RMV_GRUPPO ) ;
int conto = current_cursor ( ) - > curr ( LF_RMOV ) . get_int ( RMV_CONTO ) ;
long sottoconto = current_cursor ( ) - > curr ( LF_RMOV ) . get_long ( RMV_SOTTOCONTO ) ;
TString tipoc = current_cursor ( ) - > curr ( LF_RMOV ) . get ( RMV_TIPOC ) ;
_descr = DescrConto ( gruppo , conto , sottoconto , tipoc ) ;
_alleg = AllegClifo ( gruppo , conto , sottoconto ) ;
_importo = current_cursor ( ) - > file ( LF_RMOV ) . get_real ( RMV_IMPORTO ) ;
1999-04-06 15:34:39 +00:00
_appoggio = toupper ( current_cursor ( ) - > curr ( LF_RMOV ) . get_char ( RMV_SEZIONE ) ) ;
1994-12-05 14:21:36 +00:00
if ( ! _no_preprocess_page )
{
1999-04-06 15:34:39 +00:00
if ( _appoggio = = ' D ' )
1994-12-05 14:21:36 +00:00
{
_tot_dare_generale + = _importo ;
_tot_dare + = _importo ;
}
1999-04-06 15:34:39 +00:00
else
1994-12-05 14:21:36 +00:00
{
_tot_avere + = _importo ;
_tot_avere_generale + = _importo ;
}
if ( _controllo_mov_errati ! = 3 ) stampa_errori_rmov ( ) ;
}
return TRUE ;
}
1994-12-20 09:36:33 +00:00
else if ( _stampa_parte_iva & & file = = LF_RMOVIVA )
1994-12-05 14:21:36 +00:00
{
TRectype iva ( current_cursor ( ) - > file ( LF_RMOVIVA ) . curr ( ) ) ;
_impo = iva . get_real ( RMI_IMPONIBILE ) ;
_impos = iva . get_real ( RMI_IMPOSTA ) ;
_tipocr = iva . get_int ( RMI_TIPOCR ) ;
_tipod = iva . get_int ( RMI_TIPODET ) ;
_cod = iva . get ( RMI_CODIVA ) ;
1994-12-20 09:36:33 +00:00
_intra = iva . get_bool ( RMI_INTRA ) ;
1994-12-05 14:21:36 +00:00
1994-12-20 09:36:33 +00:00
_c . add_riga ( _impo , _impos , ZERO , ZERO , _cod , _tipod , _tipocr , _intra ) ;
1994-12-05 14:21:36 +00:00
return TRUE ;
}
}
else //_scelta_stampa == 1
{
if ( file = = LF_MOV )
{
_tot_avere = 0 ;
_tot_dare = 0 ;
_no_preprocess_page = FALSE ;
_causale = current_cursor ( ) - > curr ( LF_MOV ) . get ( MOV_CODCAUS ) ;
_registro = current_cursor ( ) - > curr ( LF_MOV ) . get ( MOV_REG ) ;
_anno = current_cursor ( ) - > curr ( LF_MOV ) . get_int ( MOV_ANNOES ) ;
_tipodoc = current_cursor ( ) - > curr ( LF_MOV ) . get ( MOV_TIPODOC ) ;
1994-12-20 09:36:33 +00:00
_causale_gia_stampata = FALSE ;
1994-12-05 14:21:36 +00:00
TLocalisamfile * fl = & ( current_cursor ( ) - > file ( LF_MOV ) ) ;
TRectype da ( fl - > curr ( ) ) ;
TRectype a ( fl - > curr ( ) ) ;
da . zero ( ) ;
a . zero ( ) ;
if ( _annoes ! = 0 )
{
da . put ( MOV_ANNOES , _annoes ) ;
a . put ( MOV_ANNOES , _annoes ) ;
}
da . put ( MOV_CODCAUS , _causale_ini ) ;
a . put ( MOV_CODCAUS , _causale_fin ) ;
if ( ( fl - > curr ( ) > = da ) & & ( fl - > curr ( ) < = a ) )
{
2003-03-14 15:13:36 +00:00
const TRectype & caus = cache ( ) . get ( LF_CAUSALI , _causale ) ;
_descr_causale = caus . get ( CAU_DESCR ) ;
_alleg_causale = caus . get_bool ( CAU_ALLEG ) ;
_tipodocumento = caus . get ( CAU_TIPODOC ) ;
1994-12-05 14:21:36 +00:00
_tiporegistro = CodiceRegistro ( _registro , _anno ) ;
if ( ( _tiporegistro ! = 1 ) & & ( _tiporegistro ! = 2 ) ) //se si tratta di un movimento di sola prima nota
return TRUE ;
}
}
else if ( file = = LF_RMOV )
{
1994-12-20 09:36:33 +00:00
if ( ! _causale_gia_stampata )
{
set_row ( _nr , " @4g%3s " , ( const char * ) _causale ) ;
1995-01-13 10:08:02 +00:00
set_row ( _nr , " @8g%-.20s " , ( const char * ) _descr_causale ) ;
1994-12-20 09:36:33 +00:00
_causale_gia_stampata = TRUE ;
}
1994-12-05 14:21:36 +00:00
long gruppo = atol ( current_cursor ( ) - > curr ( LF_RMOV ) . get ( RMV_GRUPPO ) ) ;
long conto = atol ( current_cursor ( ) - > curr ( LF_RMOV ) . get ( RMV_CONTO ) ) ;
long sottoconto = atol ( current_cursor ( ) - > curr ( LF_RMOV ) . get ( RMV_SOTTOCONTO ) ) ;
TString tipoc = current_cursor ( ) - > curr ( LF_RMOV ) . get ( RMV_TIPOC ) ;
_descr = DescrConto ( gruppo , conto , sottoconto , tipoc ) ;
_importo = current_cursor ( ) - > file ( LF_RMOV ) . get_real ( RMV_IMPORTO ) ;
1999-04-06 15:34:39 +00:00
_appoggio = toupper ( current_cursor ( ) - > curr ( LF_RMOV ) . get_char ( RMV_SEZIONE ) ) ;
1994-12-05 14:21:36 +00:00
if ( ! _no_preprocess_page )
{
1999-04-06 15:34:39 +00:00
if ( _appoggio = = ' D ' )
1994-12-05 14:21:36 +00:00
{
_tot_dare_generale + = _importo ;
_tot_dare + = _importo ;
}
1999-04-06 15:34:39 +00:00
else
1994-12-05 14:21:36 +00:00
{
_tot_avere + = _importo ;
_tot_avere_generale + = _importo ;
}
}
return TRUE ;
}
}
break ;
case fatture :
{
if ( file = = LF_MOV )
{
int anno = cur - > curr ( LF_MOV ) . get_int ( MOV_ANNOIVA ) ;
TString codreg = cur - > curr ( LF_MOV ) . get ( MOV_REG ) ;
_numr = current_cursor ( ) - > curr ( LF_MOV ) . get_long ( MOV_NUMREG ) ;
_tipo_elenco = current_cursor ( ) - > curr ( LF_MOV ) . get ( MOV_TIPO ) ;
_codcf = current_cursor ( ) - > curr ( LF_MOV ) . get_long ( MOV_CODCF ) ;
int tiporeg = CodiceRegistro ( codreg , anno ) ;
TString attreg = AttivitaRegistro ( codreg , anno ) ;
if ( tiporeg = = 1 | | tiporeg = = 2 ) //se si tratta di un movimento iva
{
_tipoatt = TipoAttivita ( attreg , get_firm ( ) ) ;
_tipo_elenco = cur - > curr ( LF_MOV ) . get ( MOV_TIPO ) ;
_codcf = cur - > curr ( LF_MOV ) . get_long ( MOV_CODCF ) ;
_codcaus = cur - > curr ( LF_MOV ) . get ( MOV_CODCAUS ) ;
_tipodoc = cur - > curr ( LF_MOV ) . get ( MOV_TIPODOC ) ;
1994-12-20 09:36:33 +00:00
_codval = cur - > curr ( LF_MOV ) . get ( MOV_CODVALI ) ;
1994-12-05 14:21:36 +00:00
_totdoc = cur - > curr ( LF_MOV ) . get_real ( MOV_TOTDOC ) ;
1997-10-20 14:23:01 +00:00
1994-12-05 14:21:36 +00:00
if ( _tipo_elenco ! = _tipo_clifo_prec & & _tipo_clifo_prec ! = " " )
printer ( ) . formfeed ( ) ;
1995-04-28 15:09:49 +00:00
TLocalisamfile & file = cur - > file ( LF_MOV ) ;
1994-12-05 14:21:36 +00:00
TRectype da ( file . curr ( ) ) ;
TRectype a ( file . curr ( ) ) ;
da . zero ( ) ;
a . zero ( ) ;
if ( _annoes ! = 0 ) //anno specificato nella maschera
{
da . put ( MOV_ANNOES , _annoes ) ;
a . put ( MOV_ANNOES , _annoes ) ;
}
2002-12-20 16:15:03 +00:00
da . put ( MOV_CODCAUS , _causale_ini ) ;
a . put ( MOV_CODCAUS , _causale_fin ) ;
1994-12-05 14:21:36 +00:00
if ( _data_ini . ok ( ) )
da . put ( MOV_DATAREG , _data_ini ) ;
da . put ( MOV_TIPO , _tipo_ini ) ;
if ( _codice_ini ! = 0 )
da . put ( MOV_CODCF , _codice_ini ) ;
if ( _data_fin . ok ( ) )
a . put ( MOV_DATAREG , _data_fin ) ;
a . put ( MOV_TIPO , _tipo_fin ) ;
if ( _codice_fin ! = 0 )
a . put ( MOV_CODCF , _codice_fin ) ;
if ( ( file . curr ( ) > = da ) & & ( file . curr ( ) < = a ) )
{
compila_clifo ( ) ;
compila_comuni ( ) ;
if ( ( _tipo_clifo_prec = = " " ) & & ( _codcf_prec = = 0l ) )
{
_tipo_clifo_prec = _tipo_elenco ;
_codcf_prec = _codcf ;
stampa_intestazione ( ) ;
}
else
if ( _tipo_clifo_prec = = _tipo_elenco & & _codcf_prec = = _codcf )
_settata_prima_riga = FALSE ;
else
{
if ( _salto_pagina & & _tipo_clifo_prec = = _tipo_elenco )
printer ( ) . formfeed ( ) ;
stampa_intestazione ( ) ;
_tipo_clifo_prec = _tipo_elenco ;
_codcf_prec = _codcf ;
_settata_prima_riga = FALSE ;
}
return TRUE ;
}
}
}
else if ( file = = LF_RMOVIVA )
{
int gruppo = current_cursor ( ) - > curr ( LF_RMOV ) . get_int ( RMV_GRUPPO ) ;
int conto = current_cursor ( ) - > curr ( LF_RMOV ) . get_int ( RMV_CONTO ) ;
2003-03-14 15:13:36 +00:00
TToken_string key ;
key . add ( gruppo ) ;
key . add ( conto ) ;
key . add ( " " ) ;
const TRectype & pcon = cache ( ) . get ( LF_PCON , key ) ;
1994-12-05 14:21:36 +00:00
2003-03-14 15:13:36 +00:00
_ricser = pcon . get_int ( " RICSER " ) ;
1994-12-05 14:21:36 +00:00
_simbolo = SimboloValuta ( _codval ) ;
_allegb = CausAlleg ( _codcaus ) ;
_descr_doc = DescrDoc ( _tipodoc ) ;
1994-12-20 09:36:33 +00:00
_intra = cur - > curr ( LF_RMOVIVA ) . get_bool ( RMI_INTRA ) ;
1997-10-20 14:23:01 +00:00
1994-12-20 09:36:33 +00:00
if ( ! _settata_prima_riga )
1994-12-05 14:21:36 +00:00
{
1994-12-20 09:36:33 +00:00
reset_print ( ) ;
set_row ( 1 , " " ) ;
1998-04-30 15:59:34 +00:00
set_row ( 2 , " @7,rn " , FLD ( LF_MOV , MOV_NUMREG ) ) ;
1994-12-20 09:36:33 +00:00
set_row ( 2 , " @8g@d " , FLD ( LF_MOV , MOV_DATAREG ) ) ;
set_row ( 2 , " @17g@3,rs " , FLD ( LF_MOV , MOV_REG ) ) ;
1998-04-30 15:59:34 +00:00
set_row ( 2 , " @20g@5,rn " , FLD ( LF_MOV , MOV_PROTIVA ) ) ;
set_row ( 2 , " @26g@2,rn " , FLD ( LF_MOV , MOV_MESELIQ ) ) ;
1994-12-05 14:21:36 +00:00
TString protiva = cur - > curr ( LF_MOV ) . get ( MOV_PROTIVA ) ;
TString uprotiva = cur - > curr ( LF_MOV ) . get ( MOV_UPROTIVA ) ;
if ( uprotiva . not_empty ( ) )
{
for ( int i = 0 ; protiva [ i ] & & ( protiva [ i ] = = uprotiva [ i ] ) ; i + + ) ;
uprotiva = uprotiva . mid ( i ) ;
1994-12-20 09:36:33 +00:00
set_row ( 2 , " @24g/@25g%s " , ( const char * ) uprotiva ) ;
1994-12-05 14:21:36 +00:00
}
1999-07-16 14:59:11 +00:00
set_row ( 2 , " @32g@d " , FLD ( LF_MOV , MOV_DATADOC ) ) ;
set_row ( 2 , " @41g@6,rs " , FLD ( LF_MOV , MOV_NUMDOC ) ) ;
set_row ( 2 , " @48g@3s " , FLD ( LF_MOV , MOV_CODCAUS ) ) ;
set_row ( 2 , " @52g@2s " , FLD ( LF_MOV , MOV_TIPODOC ) ) ;
set_row ( 2 , " @55g%-.12s " , ( const char * ) _descr_doc ) ;
1997-10-20 14:23:01 +00:00
set_row ( 2 , " @67g@n " , FLD ( LF_MOV , MOV_TOTDOC ) ) ;
set_row ( 2 , " @84g@n " , FLD ( LF_RMOVIVA , RMI_IMPONIBILE ) ) ;
1994-12-20 09:36:33 +00:00
set_row ( 2 , " @101g@4s " , FLD ( LF_RMOVIVA , RMI_CODIVA ) ) ;
set_row ( 2 , " @105g@1n " , FLD ( LF_RMOVIVA , RMI_TIPODET ) ) ;
1994-12-05 14:21:36 +00:00
if ( _tipoatt = = " E " )
1998-03-30 14:18:57 +00:00
{
1994-12-05 14:21:36 +00:00
if ( _ricser = = 1 )
1994-12-20 09:36:33 +00:00
set_row ( 2 , " @109g1 " ) ;
1994-12-05 14:21:36 +00:00
else if ( _ricser = = 2 )
1994-12-20 09:36:33 +00:00
set_row ( 2 , " @109g2 " ) ;
1998-03-30 14:18:57 +00:00
}
1994-12-20 09:36:33 +00:00
set_row ( 2 , " @111g@f " , FLD ( LF_RMOVIVA , RMI_INTRA ) ) ;
1997-10-20 14:23:01 +00:00
set_row ( 2 , " @114g@n " , FLD ( LF_RMOVIVA , RMI_IMPOSTA ) ) ;
1995-11-17 14:29:24 +00:00
if ( _allegb )
1994-12-20 09:36:33 +00:00
set_row ( 2 , " @131g* " ) ;
1994-12-05 14:21:36 +00:00
incrementa_totali ( ) ;
_settata_prima_riga = TRUE ;
+ + _documenti ;
}
else if ( _settata_prima_riga )
{
1994-12-20 09:36:33 +00:00
reset_print ( ) ;
1997-10-20 14:23:01 +00:00
set_row ( 1 , " @84g@n " , FLD ( LF_RMOVIVA , RMI_IMPONIBILE ) ) ;
1994-12-20 09:36:33 +00:00
set_row ( 1 , " @101g@4s " , FLD ( LF_RMOVIVA , RMI_CODIVA ) ) ;
1997-05-22 08:45:49 +00:00
set_row ( 1 , " @105g@1n " , FLD ( LF_RMOVIVA , RMI_TIPODET ) ) ;
1997-10-20 14:23:01 +00:00
set_row ( 1 , " @114g@n " , FLD ( LF_RMOVIVA , RMI_IMPOSTA ) ) ;
1994-12-05 14:21:36 +00:00
incrementa_totali ( ) ;
1994-12-20 09:36:33 +00:00
}
1994-12-05 14:21:36 +00:00
return TRUE ;
}
}
break ;
default :
break ;
}
return FALSE ;
}
2000-10-03 13:45:12 +00:00
void TListaMov_application : : print_intra ( int & rr )
{
const TRectype & mov = current_cursor ( ) - > curr ( LF_MOV ) ;
const real corrval = mov . get ( MOV_CORRVALUTA ) ;
if ( corrval ! = ZERO )
{
const TString16 codval = mov . get ( MOV_CODVALI ) ;
TString80 str ;
2001-05-01 08:17:07 +00:00
rr + + ;
2000-10-03 13:45:12 +00:00
const TCurrency cl ( mov . get_real ( MOV_CORRLIRE ) ) ;
str = cl . string ( TRUE ) ; str . right_just ( 19 ) ;
2003-03-14 15:13:36 +00:00
set_row ( rr , FR ( " Corrispettivo@14g%s " ) , ( const char * ) str ) ;
2000-10-03 13:45:12 +00:00
const TCurrency cv ( corrval , codval ) ;
str = cv . string ( TRUE ) ; str . right_just ( 19 ) ;
2003-03-14 15:13:36 +00:00
set_row ( rr , FR ( " @34gCorr.in valuta@49g%s " ) , ( const char * ) str ) ;
2000-10-03 13:45:12 +00:00
2001-05-01 08:17:07 +00:00
set_row ( rr , " @70g%-3s " , ( const char * ) codval ) ;
2000-10-03 13:45:12 +00:00
}
}
1994-12-05 14:21:36 +00:00
print_action TListaMov_application : : postprocess_page ( int file , int count )
{
if ( count )
{
reset_print ( ) ;
return NEXT_PAGE ;
}
switch ( _tipo_lista )
{
case movimenti :
if ( file = = LF_RMOV )
{
force_setpage ( ) ;
break ;
}
if ( file = = LF_MOV )
{
reset_print ( ) ;
_err . reset ( ) ;
int n = 1 ;
1995-01-13 10:08:02 +00:00
int r = 0 ;
if ( _scelta_stampa = = 0 )
if ( _registro . not_empty ( ) & & _mov_di_sola_iva )
{
compila_clifo ( ) ;
1995-03-01 16:47:54 +00:00
set_row ( + + r , " @1g%3s %-50s %6ld %-50s " , ( const char * ) _causale , ( const char * ) _descr_causale , _codcf , ( const char * ) _ragsoc ) ;
1995-01-13 10:08:02 +00:00
}
1994-12-05 14:21:36 +00:00
if ( _scelta_stampa = = 0 & & _stampa_parte_iva )
{
for ( int j = 0 ; j < _c . items ( ) ; j + + )
{
1994-12-20 09:36:33 +00:00
TRigaiva & riga = ( TRigaiva & ) _c [ j ] ;
1994-12-05 14:21:36 +00:00
//r = j+1;
r + + ;
2003-03-14 15:13:36 +00:00
set_row ( r , FR ( " Imponibile@11g%r " ) , & riga . _imponibile ) ;
set_row ( r , FR ( " @31gImposta@38g%r " ) , & riga . _imposta ) ;
set_row ( r , FR ( " @58gCodice Iva@69g%3s " ) , ( const char * ) riga . _codiva ) ;
1994-12-05 14:21:36 +00:00
switch ( riga . _tipodet )
{
2003-03-14 15:13:36 +00:00
case 0 : set_row ( r , FR ( " @76gDetraibile " ) ) ;
1998-04-30 15:59:34 +00:00
break ;
2003-03-14 15:13:36 +00:00
case 1 : set_row ( r , FR ( " @76gIndetraibile su op.es. " ) ) ;
1998-04-30 15:59:34 +00:00
break ;
2003-03-14 15:13:36 +00:00
case 3 : set_row ( r , FR ( " @76gPassaggi interni " ) ) ;
1998-04-30 15:59:34 +00:00
break ;
2003-03-14 15:13:36 +00:00
case 9 : set_row ( r , FR ( " @76gIndetraibile art.19 " ) ) ;
1998-04-30 15:59:34 +00:00
break ;
default : break ;
}
if ( j = = 0 ) // Se e' la prima riga che stampa
{
const int meseliq = current_cursor ( ) - > file ( LF_MOV ) . get_int ( MOV_MESELIQ ) ;
if ( meseliq > 0 ) // Stampa il mese liquidazione
2003-03-14 15:13:36 +00:00
set_row ( r , FR ( " Mese liq. %2d " ) , meseliq ) ;
1998-04-30 15:59:34 +00:00
}
1994-12-20 09:36:33 +00:00
if ( riga . _intra )
2003-03-14 15:13:36 +00:00
set_row ( r , FR ( " @111gOper.intrac. " ) ) ;
1994-12-05 14:21:36 +00:00
if ( _controllo_mov_errati ! = 3 )
if ( ! _esiste_riga_iva & & ! _nonesiste_riga_iva )
stampa_errori_iva ( & r , riga . _codiva , riga . _tipodet , riga . _tipocr ) ;
}
2000-10-03 13:45:12 +00:00
print_intra ( r ) ;
1994-12-05 14:21:36 +00:00
if ( _esiste_riga_iva )
2003-03-14 15:13:36 +00:00
set_row ( + + r , FR ( " @11gPresenti righe IVA in una registrazione senza IVA " ) ) ;
1994-12-05 14:21:36 +00:00
if ( _nonesiste_riga_iva )
2003-03-14 15:13:36 +00:00
set_row ( + + r , FR ( " @11gNon presente alcuna riga IVA in una registrazione con IVA " ) ) ;
1994-12-05 14:21:36 +00:00
_c . destroy ( ) ;
1995-01-13 10:08:02 +00:00
}
if ( r > 0 )
n = + + r ;
1994-12-05 14:21:36 +00:00
TRecnotype pos , items ;
bool FINITO = FALSE ;
if ( ( _scelta_stampa = = 0 ) & & ( _controllo_mov_errati ! = 3 ) & & ( _tot_dare ! = _tot_avere ) )
2003-03-14 15:13:36 +00:00
set_row ( n + + , FR ( " @11gIl movimento risulta sbilanciato " ) ) ;
1994-12-05 14:21:36 +00:00
pos = current_cursor ( ) - > pos ( ) ;
items = current_cursor ( ) - > items ( ) ;
FINITO = ( pos = = items - 1 ) ;
_datareg = current_cursor ( ) - > file ( LF_MOV ) . get_date ( MOV_DATAREG ) ;
_numreg = current_cursor ( ) - > file ( LF_MOV ) . get_long ( MOV_NUMREG ) ;
TDate datarec ( _datareg ) ;
if ( ! FINITO )
{
TCursor * cur = current_cursor ( ) ;
cur - > save_status ( ) ;
+ + ( * cur ) ;
1995-01-13 10:08:02 +00:00
datarec = cur - > file ( LF_MOV ) . get_date ( MOV_DATAREG ) ;
1994-12-05 14:21:36 +00:00
- - ( * cur ) ;
cur - > restore_status ( ) ;
}
_tot_avere_giornaliero + = _tot_avere ;
_tot_dare_giornaliero + = _tot_dare ;
//stampa i totali giornalieri
2002-07-02 16:21:23 +00:00
if ( ! _cdc_only )
1994-12-05 14:21:36 +00:00
{
2002-09-13 14:06:05 +00:00
if ( FINITO | |
( _datareg ! = datarec ) | | ( _numreg = = _numreg_fin ) )
{
if ( ( _scelta_stampa = = 0 & & _controllo_mov_errati ! = 1 & & _decidi = = 2 ) | | ( _scelta_stampa = = 1 & & _decidi = = 2 ) )
{
2003-03-14 15:13:36 +00:00
set_row ( n , FR ( " @b@60gTotali del giorno %s " ) , _datareg . string ( ) ) ;
2002-09-13 14:06:05 +00:00
set_row ( n + + , " @b@90g%r %r " , & _tot_dare_giornaliero , & _tot_avere_giornaliero ) ;
_tot_avere_giornaliero = 0 ;
_tot_dare_giornaliero = 0 ;
}
if ( ( _scelta_stampa = = 0 & & _controllo_mov_errati ! = 1 & & FINITO ) | | ( _scelta_stampa = = 1 & & FINITO ) )
{
set_row ( n + + , " " ) ;
2003-03-14 15:13:36 +00:00
set_row ( n , FR ( " @b@60gTotale generale " ) ) ;
2002-09-13 14:06:05 +00:00
set_row ( n + + , " @b@90g%r %r " , & _tot_dare_generale , & _tot_avere_generale ) ;
}
}
}
1994-12-05 14:21:36 +00:00
if ( n = = 1 )
{
force_setpage ( ) ; //probabilmente e' inutile
return NEXT_PAGE ;
}
else
{
_no_preprocess_page = TRUE ;
force_setpage ( FALSE ) ;
return REPEAT_PAGE ;
}
}
break ;
case fatture :
if ( file = = LF_MOV )
{
1994-12-20 09:36:33 +00:00
reset_print ( ) ;
TCursor * cur = current_cursor ( ) ;
int rr = 1 ;
2000-10-03 13:45:12 +00:00
print_intra ( rr ) ;
1994-12-05 14:21:36 +00:00
_totdocumenti + = _totdoc ;
TRecnotype pos , items ;
bool FINITO = FALSE ;
pos = current_cursor ( ) - > pos ( ) ;
items = current_cursor ( ) - > items ( ) ;
FINITO = ( pos = = items - 1 ) ;
if ( ! FINITO )
{
cur - > save_status ( ) ;
+ + ( * cur ) ;
// long numrsucc = cur->file(LF_MOV).get_long(MOV_NUMREG);
_tipoelsucc = cur - > file ( LF_MOV ) . get ( MOV_TIPO ) ;
_codclifosucc = cur - > file ( LF_MOV ) . get_long ( MOV_CODCF ) ;
- - ( * cur ) ;
cur - > restore_status ( ) ;
}
if ( FINITO | | ( _tipo_elenco ! = _tipoelsucc ) | | ( _codcf ! = _codclifosucc ) )
{
TString blank = " " ;
1994-12-20 09:36:33 +00:00
set_row ( rr + + , ( const char * ) blank ) ;
1994-12-05 14:21:36 +00:00
if ( ( _tipo_elenco = = " C " ) | | ( _tipo_elenco = = " c " ) )
2003-03-14 15:13:36 +00:00
set_row ( rr + + , FR ( " @bTotali Cliente@18gDocumenti Totale documenti@47gAllegati:@63gImponibile@82gImposta@95gop. esenti@110gop. non imp. " ) ) ;
1994-12-05 14:21:36 +00:00
else
2003-03-14 15:13:36 +00:00
set_row ( rr + + , FR ( " @bTotali Fornitore@18gDocumenti Totale documenti@49gAllegati:@63gImponibile@82gImposta@95gop. esenti@110gop. non imp. " ) ) ;
1994-12-20 09:36:33 +00:00
set_row ( rr , " @b@18g%9d " , _documenti ) ;
1997-10-20 14:23:01 +00:00
set_row ( rr , " @b@28g%r " , & _totdocumenti ) ;
2003-03-17 10:53:46 +00:00
set_row ( rr , " @b@57g%r " , & _totimponibile ) ;
set_row ( rr , " @b@73g%r " , & _totimposta ) ;
1997-10-20 14:23:01 +00:00
set_row ( rr , " @b@92g%r " , & _op_esenti ) ;
set_row ( rr , " @b@110g%r " , & _op_non_imp ) ;
1994-12-05 14:21:36 +00:00
_totimposta = 0 ;
_totimponibile = 0 ;
_op_esenti = 0 ;
_op_non_imp = 0 ;
_documenti = 0 ;
_totdocumenti = 0 ;
1994-12-20 09:36:33 +00:00
//return REPEAT_PAGE;
1994-12-05 14:21:36 +00:00
}
1994-12-20 09:36:33 +00:00
if ( rr > 1 )
return REPEAT_PAGE ;
1994-12-05 14:21:36 +00:00
}
break ;
default :
break ;
}
1997-10-20 14:23:01 +00:00
return NEXT_PAGE ;
1994-12-05 14:21:36 +00:00
}
print_action TListaMov_application : : postprocess_print ( int file , int count )
{
if ( count )
{
reset_print ( ) ;
return NEXT_PAGE ;
}
switch ( _tipo_lista )
{
case movimenti :
break ;
case fatture :
break ;
default :
break ;
}
return NEXT_PAGE ;
}
//cerca errori sulla testata (MOV)
bool TListaMov_application : : segnala_errori_primariga ( )
{
1996-12-10 08:23:20 +00:00
TEsercizi_contabili esc ;
const int ae = esc . date2esc ( _datacomp ) ;
1994-12-05 14:21:36 +00:00
if ( _ae = = 0 )
_err . set ( 0l ) ;
if ( _registro . not_empty ( ) ) //si tratta di fattura
if ( _datareg . year ( ) ! = _anno )
_err . set ( 1 ) ;
if ( _scelta_stampa = = 0 & & _stampa_anno_comp )
if ( _ae ! = _annoeser )
1996-03-08 08:09:23 +00:00
{
1994-12-05 14:21:36 +00:00
if ( _annoes ) //specificato l'anno nella maschera
_err . set ( 2 ) ;
1996-03-08 08:09:23 +00:00
else _err . set ( 3 ) ;
}
1997-05-22 08:45:49 +00:00
else
if ( _datacomp ! = _datareg ) // altrimenti se gli esercizi corrispondono controlla datacomp e dataop
_err . set ( 26 ) ;
1994-12-05 14:21:36 +00:00
if ( ae )
1996-12-10 08:23:20 +00:00
{
const int ar = esc . date2esc ( _datareg ) ; // Esercizio in corso
const int pr = esc . pred ( ar ) ; // Esercizio precedente
1994-12-05 14:21:36 +00:00
if ( ae ! = ar & & ae ! = pr )
_err . set ( 4 ) ;
}
1996-12-10 08:23:20 +00:00
else
_err . set ( 5 ) ;
1994-12-05 14:21:36 +00:00
if ( _annoeser ! = ae )
_err . set ( 6 ) ;
1995-01-13 10:08:02 +00:00
if ( _tipodoc ! = " " )
if ( ! RicercaDoc ( _tipodoc ) )
_err . set ( 11 ) ;
1994-12-05 14:21:36 +00:00
if ( _causale . not_empty ( ) ) //se indicata la causale
{
2003-03-14 15:13:36 +00:00
const TRectype & caus = cache ( ) . get ( LF_CAUSALI , _causale ) ;
if ( caus . empty ( ) )
1994-12-05 14:21:36 +00:00
_err . set ( 7 ) ;
else
{
2003-03-14 15:13:36 +00:00
bool sos = caus . get_bool ( CAU_SOSPESO ) ;
1994-12-05 14:21:36 +00:00
if ( sos )
_err . set ( 8 ) ;
if ( _stampa_mess_alleg_iva & & _alleg_causale )
_err . set ( 9 ) ;
}
1995-01-13 10:08:02 +00:00
if ( _tipodoc ! = _tipodocumento )
1994-12-05 14:21:36 +00:00
_err . set ( 10 ) ;
1995-01-13 10:08:02 +00:00
if ( _registro ! = _reg_causale )
1994-12-05 14:21:36 +00:00
_err . set ( 12 ) ;
if ( _registro . not_empty ( ) ) //movimento iva (fatture)
{
TRegistro rg ( _registro , _datareg . year ( ) ) ;
if ( rg . name ( ) . empty ( ) )
_err . set ( 13 ) ;
else
{
const int tipo = rg . tipo ( ) ;
TipoIVA i = nessuna_iva ;
TTable tabtpd ( " %TPD " ) ;
tabtpd . put ( " CODTAB " , _tipodoc ) ;
if ( tabtpd . read ( ) = = NOERR )
{
bool cor = tabtpd . get_bool ( " B0 " ) ;
1997-10-20 14:23:01 +00:00
1994-12-05 14:21:36 +00:00
int i = tabtpd . get_int ( " I0 " ) ;
if ( i = = 1 & & tipo ! = 1 )
_err . set ( 15 ) ;
if ( i = = 2 & & tipo ! = 2 )
_err . set ( 15 ) ;
if ( i = = 9 & & ( tipo ! = 1 & & tipo ! = 2 ) )
_err . set ( 15 ) ;
if ( cor & & ! rg . corrispettivi ( ) )
_err . set ( 15 ) ;
if ( ! cor )
if ( _codcf = = 0l )
_err . set ( 16 ) ;
}
1995-01-24 15:46:03 +00:00
if ( _codcf ! = 0l )
1994-12-05 14:21:36 +00:00
{
1995-01-24 15:46:03 +00:00
if ( ( tipo = = 1 & & _tipo_elenco ! = " C " ) | | ( tipo = = 2 & & _tipo_elenco ! = " F " ) )
_err . set ( 17 ) ;
2003-03-14 15:13:36 +00:00
TToken_string key ;
key . add ( _tipo_elenco ) ;
key . add ( _codcf ) ;
const TRectype & clifo = cache ( ) . get ( LF_CLIFO , key ) ;
if ( ! clifo . empty ( ) )
1995-01-24 15:46:03 +00:00
{
bool sosp = clifo . get_bool ( CLI_SOSPESO ) ;
if ( sosp )
_err . set ( 18 ) ;
bool occ = clifo . get_bool ( CLI_OCCAS ) ;
char alleg = clifo . get_char ( CLI_ALLEG ) ;
long calleg = clifo . get_long ( CLI_CODALLEG ) ;
if ( ! occ )
{
if ( _stampa_mess_alleg_iva & & alleg = = ' 1 ' )
_err . set ( 19 ) ;
if ( calleg ! = 0l )
1995-01-13 10:08:02 +00:00
{
1995-01-24 15:46:03 +00:00
if ( calleg = = _codcf )
_err . set ( 20 ) ;
2003-03-14 15:13:36 +00:00
TToken_string key ;
key . add ( _tipo_elenco ) ;
key . add ( calleg ) ;
const TRectype & clifo = cache ( ) . get ( LF_CLIFO , key ) ;
if ( ! clifo . empty ( ) )
1995-01-24 15:46:03 +00:00
{
bool sospall = clifo . get_bool ( CLI_SOSPESO ) ;
long codall = clifo . get_long ( CLI_CODALLEG ) ;
char alleg = clifo . get_char ( CLI_ALLEG ) ;
if ( sospall )
_err . set ( 21 ) ;
if ( codall ! = 0l )
_err . set ( 22 ) ;
if ( _stampa_mess_alleg_iva & & alleg = = ' 1 ' )
_err . set ( 23 ) ;
}
else _err . set ( 24 ) ;
}
}
}
else _err . set ( 25 ) ;
}
1994-12-05 14:21:36 +00:00
}
}
}
if ( _err . ones ( ) )
return TRUE ;
return FALSE ;
}
//controlli sulla contropartita
1995-01-31 14:55:09 +00:00
bool TListaMov_application : : contropartita ( int gruppo , int conto , long sottoconto , char t )
1994-12-05 14:21:36 +00:00
{
1997-06-19 14:33:52 +00:00
TBill tc ;
2003-03-14 15:13:36 +00:00
TRectype pc ( LF_PCON ) ;
1994-12-05 14:21:36 +00:00
tc . set ( gruppo , 0 , 0l ) ;
if ( ! tc . read ( pc ) )
return TRUE ;
tc . set ( gruppo , conto , 0l ) ;
if ( ! tc . read ( pc ) )
return TRUE ;
1995-01-31 14:55:09 +00:00
//else t = pc.get_char(PCN_TMCF);
1994-12-05 14:21:36 +00:00
tc . set ( gruppo , conto , sottoconto ) ;
if ( t ! = ' C ' & & t ! = ' F ' )
{
if ( ! tc . read ( pc ) )
return TRUE ;
else
{
bool sosp = tc . sospeso ( ) ;
if ( sosp )
return TRUE ;
}
}
1995-01-31 14:55:09 +00:00
else if ( sottoconto ! = 0l )
1994-12-05 14:21:36 +00:00
{
2003-03-14 15:13:36 +00:00
TToken_string key ;
key . add ( t ) ;
key . add ( sottoconto ) ;
const TRectype & clifo = cache ( ) . get ( LF_CLIFO , key ) ;
if ( ! clifo . empty ( ) )
1994-12-05 14:21:36 +00:00
{
bool sosp = clifo . get_bool ( CLI_SOSPESO ) ;
if ( sosp )
return TRUE ;
}
else
return TRUE ;
}
return FALSE ;
}
//guarda se c'e' almeno un errore su almeno una riga (rmov)
bool TListaMov_application : : segnala_errori_ogniriga ( )
{
TLocalisamfile & rmov = current_cursor ( ) - > file ( LF_RMOV ) ;
1995-01-31 14:55:09 +00:00
int gruppo , conto , anno , gruppoc , contoc ;
long sottoconto , sottocontoc ;
1994-12-05 14:21:36 +00:00
TDate datareg ;
1995-03-17 14:31:33 +00:00
char sez , tipo , t , tipoc ;
real importo ;
real dare , avere ;
1994-12-05 14:21:36 +00:00
if ( current_cursor ( ) - > is_first_match ( LF_RMOV ) )
{
1995-03-17 14:31:33 +00:00
dare = avere = ZERO ;
1994-12-05 14:21:36 +00:00
TRecnotype nrec = rmov . recno ( ) ;
rmov . zero ( ) ;
rmov . setkey ( 1 ) ;
rmov . put ( RMV_NUMREG , _numero ) ;
TRectype recc ( rmov . curr ( ) ) ;
for ( rmov . read ( _isgteq ) ; ! rmov . eof ( ) ; rmov . next ( ) )
{
TRectype rec ( rmov . curr ( ) ) ;
if ( rec > recc ) break ;
gruppo = rec . get_int ( RMV_GRUPPO ) ;
conto = rec . get_int ( RMV_CONTO ) ;
sottoconto = rec . get_long ( RMV_SOTTOCONTO ) ;
1995-01-31 14:55:09 +00:00
gruppoc = rec . get_int ( RMV_GRUPPOC ) ;
contoc = rec . get_int ( RMV_CONTOC ) ;
sottocontoc = rec . get_long ( RMV_SOTTOCONTOC ) ;
tipoc = rec . get_char ( RMV_TIPOCC ) ;
1994-12-05 14:21:36 +00:00
anno = rec . get_int ( RMV_ANNOES ) ;
datareg = rec . get_date ( RMV_DATAREG ) ;
sez = rec . get_char ( RMV_SEZIONE ) ;
tipo = rec . get_char ( RMV_TIPOC ) ;
1995-03-17 14:31:33 +00:00
importo = rec . get_real ( RMV_IMPORTO ) ;
if ( sez = = ' D ' )
dare + = importo ;
if ( sez = = ' A ' )
avere + = importo ;
1994-12-05 14:21:36 +00:00
1997-06-19 14:33:52 +00:00
TBill tc ( gruppo , conto , sottoconto ) ;
1994-12-05 14:21:36 +00:00
1995-03-17 14:31:33 +00:00
if ( gruppoc ! = 0 | | contoc ! = 0 | | sottocontoc ! = 0l )
if ( contropartita ( gruppoc , contoc , sottocontoc , tipoc ) )
{
rmov . readat ( nrec ) ;
return TRUE ;
}
1995-01-31 14:55:09 +00:00
1994-12-05 14:21:36 +00:00
if ( anno ! = _annoeser | | datareg ! = _datareg )
{
rmov . readat ( nrec ) ;
return TRUE ;
}
if ( sez ! = ' D ' & & sez ! = ' A ' )
{
rmov . readat ( nrec ) ;
return TRUE ;
}
if ( tc . empty ( ) )
{
rmov . readat ( nrec ) ;
return TRUE ;
}
if ( ! tc . ok ( ) )
{
rmov . readat ( nrec ) ;
return TRUE ;
}
2003-03-14 15:13:36 +00:00
TRectype pc ( LF_PCON ) ;
1994-12-05 14:21:36 +00:00
tc . set ( gruppo , 0 , 0l ) ;
if ( ! tc . read ( pc ) )
{
rmov . readat ( nrec ) ;
return TRUE ;
}
tc . set ( gruppo , conto , 0l ) ;
if ( ! tc . read ( pc ) )
{
rmov . readat ( nrec ) ;
return TRUE ;
}
else t = pc . get_char ( PCN_TMCF ) ;
if ( t ! = tipo )
{
rmov . readat ( nrec ) ;
return TRUE ;
}
tc . set ( gruppo , conto , sottoconto ) ;
if ( t ! = ' C ' & & t ! = ' F ' )
{
if ( ! tc . read ( pc ) )
{
rmov . readat ( nrec ) ;
return TRUE ;
}
else
{
bool sosp = tc . sospeso ( ) ;
if ( sosp )
{
rmov . readat ( nrec ) ;
return TRUE ;
}
}
}
else
{
2003-03-14 15:13:36 +00:00
TToken_string key ;
key . add ( t ) ;
key . add ( sottoconto ) ;
const TRectype & clifo = cache ( ) . get ( LF_CLIFO , key ) ;
if ( ! clifo . empty ( ) )
1994-12-05 14:21:36 +00:00
{
bool sosp = clifo . get_bool ( CLI_SOSPESO ) ;
if ( sosp )
{
rmov . readat ( nrec ) ;
return TRUE ;
}
}
else
{
rmov . readat ( nrec ) ;
return TRUE ;
}
if ( _registro . not_empty ( ) ) //se su mov e' indicato il codice registro
{
TRegistro rg ( _registro , _ae ) ;
const int tiporeg = rg . tipo ( ) ;
if ( ( tiporeg = = 1 & & t ! = ' C ' ) | | ( tiporeg = = 2 & & t ! = ' F ' ) )
{
rmov . readat ( nrec ) ;
return TRUE ;
}
}
}
TLocalisamfile saldi ( LF_SALDI ) ;
saldi . setkey ( 1 ) ;
saldi . zero ( ) ;
saldi . put ( SLD_ANNOES , anno ) ;
saldi . put ( SLD_GRUPPO , gruppo ) ;
saldi . put ( SLD_CONTO , conto ) ;
saldi . put ( SLD_SOTTOCONTO , sottoconto ) ;
1996-06-04 14:18:45 +00:00
saldi . put ( SLD_FLSCA , " " ) ;
1994-12-05 14:21:36 +00:00
if ( saldi . read ( ) ! = NOERR )
{
rmov . readat ( nrec ) ;
return TRUE ;
}
1995-03-17 14:31:33 +00:00
} //for
if ( dare ! = avere )
{
rmov . readat ( nrec ) ;
return TRUE ;
}
1994-12-05 14:21:36 +00:00
rmov . readat ( nrec ) ;
}
return FALSE ;
}
bool TListaMov_application : : segnala_errori_iva ( )
{
TLocalisamfile & rmoviva = current_cursor ( ) - > file ( LF_RMOVIVA ) ;
TTable tab_iva ( " %IVA " ) ;
TString16 cod ;
int tipodet , tipocr ;
if ( current_cursor ( ) - > is_first_match ( LF_RMOVIVA ) )
{
TRecnotype nrec = rmoviva . recno ( ) ;
rmoviva . setkey ( 1 ) ;
rmoviva . zero ( ) ;
rmoviva . put ( RMI_NUMREG , _numero ) ;
TRectype recc ( rmoviva . curr ( ) ) ;
for ( rmoviva . read ( _isgteq ) ; ! rmoviva . eof ( ) ; rmoviva . next ( ) )
{
TRectype rec ( rmoviva . curr ( ) ) ;
if ( rec > recc ) break ;
if ( _registro . empty ( ) )
{
rmoviva . readat ( nrec ) ;
_esiste_riga_iva = TRUE ;
return TRUE ;
}
cod = rec . get ( RMI_CODIVA ) ;
tipodet = rec . get_int ( RMI_TIPODET ) ;
tipocr = rec . get_int ( RMI_TIPOCR ) ;
tab_iva . zero ( ) ;
tab_iva . put ( " CODTAB " , cod ) ;
if ( tab_iva . read ( ) = = NOERR )
{
int allc = tab_iva . get_int ( " S7 " ) ;
int allf = tab_iva . get_int ( " S8 " ) ;
bool s = tab_iva . get_bool ( " B2 " ) ;
if ( s )
{
rmoviva . readat ( nrec ) ;
return TRUE ;
}
if ( _stampa_mess_alleg_iva )
if ( allc = = 0 | | allf = = 0 )
{
rmoviva . readat ( nrec ) ;
return TRUE ;
}
}
else
{
rmoviva . readat ( nrec ) ;
return TRUE ;
}
if ( tipodet = = 1 | | tipodet = = 3 | | tipodet = = 5 | | tipodet = = 9 )
if ( _tiporegistro ! = 2 )
{
rmoviva . readat ( nrec ) ;
return TRUE ;
}
if ( _tiporegistro = = 1 )
if ( tipocr ! = 0 & & tipocr ! = 1 & & tipocr ! = 4 & & tipocr ! = 9 )
{
rmoviva . readat ( nrec ) ;
return TRUE ;
}
if ( _tiporegistro = = 2 )
if ( tipocr ! = 0 & & tipocr ! = 1 & & tipocr ! = 2 & & tipocr ! = 3 & & tipocr ! = 5 & & tipocr ! = 8 & & tipocr ! = 9 )
{
rmoviva . readat ( nrec ) ;
return TRUE ;
}
}
rmoviva . readat ( nrec ) ;
}
else if ( _registro . not_empty ( ) ) //cioe' si tratta di fattura
{
_nonesiste_riga_iva = TRUE ;
return TRUE ;
}
return FALSE ;
}
void TListaMov_application : : incrementa_totali ( )
{
TString dep1 ;
real imponibile , imposta ;
imponibile = current_cursor ( ) - > file ( LF_RMOVIVA ) . get_real ( RMI_IMPONIBILE ) ;
imposta = current_cursor ( ) - > file ( LF_RMOVIVA ) . get_real ( RMI_IMPOSTA ) ;
TString codiva = current_cursor ( ) - > file ( LF_RMOVIVA ) . get ( RMI_CODIVA ) ;
_tabiva - > zero ( ) ;
dep1 . format ( " %-4s " , ( const char * ) codiva ) ;
_tabiva - > put ( " CODTAB " , ( const char * ) dep1 ) ;
_tabiva - > read ( ) ;
if ( _tabiva - > bad ( ) )
_tabiva - > zero ( ) ;
if ( ( _tipo_elenco = = " C " ) | | ( _tipo_elenco = = " c " ) )
{
2002-05-08 16:25:49 +00:00
const int colonna = _tabiva - > get_int ( " S7 " ) ;
if ( ( colonna = = 1 ) | | ( colonna = = 3 ) )
1994-12-05 14:21:36 +00:00
_totimposta + = imposta ;
2002-05-08 16:25:49 +00:00
if ( colonna = = 1 )
1994-12-05 14:21:36 +00:00
_totimponibile + = imponibile ;
else
2002-05-08 16:25:49 +00:00
if ( colonna = = 3 )
1994-12-05 14:21:36 +00:00
_op_esenti + = imponibile ;
}
else
{
2002-05-08 16:25:49 +00:00
const int colonna = _tabiva - > get_int ( " S8 " ) ;
if ( ( colonna = = 1 ) | | ( colonna = = 3 ) | | ( colonna = = 4 ) )
1994-12-05 14:21:36 +00:00
_totimposta + = imposta ;
2002-05-08 16:25:49 +00:00
if ( colonna = = 1 )
1994-12-05 14:21:36 +00:00
_totimponibile + = imponibile ;
else
2002-05-08 16:25:49 +00:00
if ( colonna = = 3 )
1994-12-05 14:21:36 +00:00
_op_esenti + = imponibile ;
else
2002-05-08 16:25:49 +00:00
if ( colonna = = 4 )
1994-12-05 14:21:36 +00:00
_op_non_imp + = imponibile ;
}
}
2002-05-08 16:25:49 +00:00
void TListaMov_application : : imposta_parametri_stampa ( const TMask & msk )
1994-12-05 14:21:36 +00:00
{
1999-04-06 15:34:39 +00:00
set_magic_currency ( TRUE ) ;
2002-05-08 16:25:49 +00:00
1994-12-05 14:21:36 +00:00
reset_files ( ) ;
_curr1 - > set_filterfunction ( filter_func ) ;
_curr2 - > set_filterfunction ( filter_func ) ;
_curr3 - > set_filterfunction ( filter_func_fatture ) ;
switch ( _tipo_lista )
{
case movimenti :
{
_scelta_stampa = atoi ( msk . get ( F_MOVIMENTI ) ) ;
_annoes = msk . get_int ( F_ANNO ) ;
_decidi = msk . get_int ( F_DECIDI ) ;
_causale_ini = msk . get ( F_CAUSALEINI ) ;
_causale_fin = msk . get ( F_CAUSALEFIN ) ;
if ( _scelta_stampa = = 0 )
{
_registro_ini = msk . get ( F_REGISTROINI ) ;
_registro_fin = msk . get ( F_REGISTROFIN ) ;
}
1999-04-26 15:58:05 +00:00
_numreg_ini = msk . get_long ( F_NUMEROINI ) ;
_numreg_fin = msk . get_long ( F_NUMEROFIN ) ;
1994-12-05 14:21:36 +00:00
_data_ini = msk . get ( F_DATAINI ) ;
_data_fin = msk . get ( F_DATAFIN ) ;
1995-05-29 16:03:19 +00:00
_provvis = msk . get_int ( F_STAMPAMOVP ) ;
1994-12-05 14:21:36 +00:00
if ( _decidi = = 1 )
{
select_cursor ( _cur1 ) ;
1995-05-29 16:03:19 +00:00
if ( _provvis = = 1 ) //normale
1994-12-05 14:21:36 +00:00
_curr1 - > setfilter ( " (PROVVIS= \" \" ) " ) ;
1995-05-29 16:03:19 +00:00
else if ( _provvis = = 2 ) //globale
1995-04-19 13:13:21 +00:00
_curr1 - > setfilter ( " " ) ;
1995-05-29 16:03:19 +00:00
else _curr1 - > setfilter ( " (PROVVIS!= \" \" ) " ) ; //solo provvisori
2002-05-08 16:25:49 +00:00
1999-04-26 15:58:05 +00:00
TRectype da ( LF_MOV ) , a ( LF_MOV ) ;
1994-12-05 14:21:36 +00:00
da . put ( MOV_NUMREG , _numreg_ini ) ;
a . put ( MOV_NUMREG , _numreg_fin ) ;
current_cursor ( ) - > setregion ( da , a ) ;
2002-05-08 16:25:49 +00:00
1994-12-05 14:21:36 +00:00
add_file ( LF_MOV ) ;
add_file ( LF_RMOV , LF_MOV ) ;
add_file ( LF_RMOVIVA , LF_MOV ) ;
}
else
{
select_cursor ( _cur2 ) ;
1995-05-29 16:03:19 +00:00
if ( _provvis = = 1 ) //normale
1995-04-19 13:13:21 +00:00
_curr2 - > setfilter ( " (PROVVIS= \" \" ) " ) ;
1995-05-29 16:03:19 +00:00
else if ( _provvis = = 2 ) //globale
1995-04-19 13:13:21 +00:00
_curr2 - > setfilter ( " " ) ;
1999-04-26 15:58:05 +00:00
else
_curr2 - > setfilter ( " (PROVVIS!= \" \" ) " ) ; //solo provvisori
TRectype da ( LF_MOV ) , a ( LF_MOV ) ;
1994-12-05 14:21:36 +00:00
if ( _data_ini . ok ( ) )
da . put ( MOV_DATAREG , _data_ini ) ;
if ( _data_fin . ok ( ) )
a . put ( MOV_DATAREG , _data_fin ) ;
current_cursor ( ) - > setregion ( da , a ) ;
add_file ( LF_MOV ) ;
add_file ( LF_RMOV , LF_MOV ) ;
add_file ( LF_RMOVIVA , LF_MOV ) ;
}
}
break ;
2002-05-08 16:25:49 +00:00
1997-10-20 14:23:01 +00:00
case fatture :
{
1999-04-26 15:58:05 +00:00
_noseparator = msk . get_bool ( F_SEPARATOR ) ;
TString tipo = msk . get ( F_TIPOELENCO ) ;
2002-12-20 16:15:03 +00:00
1999-04-26 15:58:05 +00:00
_data_ini = msk . get ( F_DATAINI ) ;
_data_fin = msk . get ( F_DATAFIN ) ;
_annoes = msk . get_int ( F_ANNO ) ;
2002-12-20 16:15:03 +00:00
_causale_ini = msk . get ( F_DACODCAUS ) ;
_causale_fin = msk . get ( F_ACODCAUS ) ;
1999-04-26 15:58:05 +00:00
if ( tipo = = " C " | | tipo = = " F " )
{
_codice_ini = atol ( msk . get ( F_CODICEINI ) ) ;
_codice_fin = atol ( msk . get ( F_CODICEFIN ) ) ;
}
else
{
_codice_ini = atol ( msk . get ( F_CODICEINI1 ) ) ;
_codice_fin = atol ( msk . get ( F_CODICEFIN1 ) ) ;
}
2002-05-08 16:25:49 +00:00
1999-04-26 15:58:05 +00:00
if ( tipo = = " E " )
{
_tipo_ini = " C " ;
_tipo_fin = " F " ;
}
else
{
_tipo_ini = tipo ;
_tipo_fin = tipo ;
}
select_cursor ( _cur3 ) ;
_curr3 - > setfilter ( " " ) ;
TRectype da ( LF_MOV ) , a ( LF_MOV ) ;
if ( _codice_ini ! = 0 )
da . put ( MOV_CODCF , _codice_ini ) ;
a . put ( MOV_TIPO , _tipo_fin ) ;
if ( _codice_fin ! = 0 )
a . put ( MOV_CODCF , _codice_fin ) ;
da . put ( MOV_TIPO , _tipo_ini ) ;
current_cursor ( ) - > setregion ( da , a ) ;
add_file ( LF_MOV ) ;
add_file ( LF_RMOVIVA , LF_MOV ) ;
1994-12-05 14:21:36 +00:00
}
1999-04-26 15:58:05 +00:00
break ;
2002-05-08 16:25:49 +00:00
1999-04-26 15:58:05 +00:00
default :
break ;
1994-12-05 14:21:36 +00:00
}
1999-04-26 15:58:05 +00:00
init_print ( msk ) ;
2002-05-08 16:25:49 +00:00
}
1994-12-05 14:21:36 +00:00
2002-05-08 16:25:49 +00:00
bool TListaMov_application : : set_print ( int )
{
const char * masc ;
switch ( toupper ( _tipoc ) )
{
case ' C ' :
masc = " cg3100b " ;
_tipo_lista = fatture ;
break ;
case ' M ' :
default :
masc = " cg3100a " ;
_tipo_lista = movimenti ;
break ;
}
TMask msk ( masc ) ;
2002-07-02 16:21:23 +00:00
if ( main_app ( ) . has_module ( CMAUT ) )
msk . show ( - 4 ) ;
else
{
msk . hide ( - 4 ) ;
msk . reset ( - 4 ) ;
}
msk . set_handler ( F_ANNO , annoes_handler ) ;
2002-05-08 16:25:49 +00:00
msk . set_handler ( F_DATAINI , data_inizio ) ;
msk . set_handler ( F_DATAFIN , data_fine ) ;
2002-07-02 16:21:23 +00:00
msk . set_handler ( F_DACDC , cdc_handler ) ;
msk . set_handler ( F_ACDC , cdc_handler ) ;
2002-05-08 16:25:49 +00:00
while ( msk . run ( ) = = K_ENTER )
{
2002-07-02 16:21:23 +00:00
_print_cdc = msk . get_bool ( F_PRINTCDC ) ;
2002-05-08 16:25:49 +00:00
if ( msk . get ( F_DACDC ) . not_empty ( ) | | msk . get ( F_ACDC ) . not_empty ( ) )
{
2002-09-13 14:06:05 +00:00
_cdc_only = msk . get_bool ( F_CDC_ONLY ) ;
2002-05-08 16:25:49 +00:00
TRelation rel ( " CMS " ) ;
TRectype darec ( rel . curr ( ) ) , arec ( rel . curr ( ) ) ;
darec . put ( " CODTAB " , msk . get ( F_DACDC ) ) ;
arec . put ( " CODTAB " , msk . get ( F_ACDC ) ) ;
TCursor cur ( & rel , " " , 1 , & darec , & arec ) ;
const long items = cur . items ( ) ;
cur . freeze ( ) ;
2002-07-02 16:21:23 +00:00
TRelation fscrel ( " FSC " ) ;
TRectype da_fsc ( fscrel . curr ( ) ) , a_fsc ( fscrel . curr ( ) ) ;
da_fsc . put ( " CODTAB " , msk . get ( F_DAFASE ) ) ;
a_fsc . put ( " CODTAB " , msk . get ( F_AFASE ) ) ;
TCursor fsccur ( & fscrel , " " , 1 , & da_fsc , & a_fsc ) ;
const TRecnotype fsc_items = fsccur . items ( ) ;
fsccur . freeze ( ) ;
2002-05-08 16:25:49 +00:00
for ( cur = 0L ; cur . pos ( ) < items ; + + cur )
{
_cdc = rel . curr ( ) . get ( " CODTAB " ) ;
2002-07-02 16:21:23 +00:00
if ( ! da_fsc . empty ( ) | | ! a_fsc . empty ( ) )
{
for ( fsccur = 0L ; fsccur . pos ( ) < fsc_items ; + + fsccur )
{
_fsc = fsccur . curr ( ) . get ( " CODTAB " ) ;
2002-09-13 14:06:05 +00:00
imposta_parametri_stampa ( msk ) ;
print ( ) ;
2002-07-02 16:21:23 +00:00
}
}
else
{
_fsc . cut ( 0 ) ;
2002-09-13 14:06:05 +00:00
imposta_parametri_stampa ( msk ) ;
print ( ) ;
2002-07-02 16:21:23 +00:00
}
2002-05-08 16:25:49 +00:00
}
}
else
{
_cdc_only = FALSE ;
2002-07-02 16:21:23 +00:00
_cdc . cut ( 0 ) ; _fsc . cut ( 0 ) ;
2002-05-08 16:25:49 +00:00
imposta_parametri_stampa ( msk ) ;
print ( ) ;
}
2002-07-02 16:21:23 +00:00
msk . reset ( - 5 ) ;
2002-05-08 16:25:49 +00:00
}
return FALSE ;
1994-12-05 14:21:36 +00:00
}
bool TListaMov_application : : user_create ( )
{
_relmov1 = new TRelation ( LF_MOV ) ;
_relmov1 - > add ( LF_RMOV , " NUMREG=NUMREG " , 1 ) ;
_relmov1 - > add ( LF_RMOVIVA , " NUMREG=NUMREG " , 1 ) ;
1995-01-31 16:13:30 +00:00
_curr1 = new TCursor ( _relmov1 , " " , 1 ) ;
_cur1 = add_cursor ( _curr1 ) ;
1994-12-05 14:21:36 +00:00
1995-01-31 16:13:30 +00:00
_relmov2 = new TRelation ( LF_MOV ) ;
1994-12-05 14:21:36 +00:00
_relmov2 - > add ( LF_RMOV , " NUMREG=NUMREG " , 1 ) ;
_relmov2 - > add ( LF_RMOVIVA , " NUMREG=NUMREG " , 1 ) ;
1995-01-31 16:13:30 +00:00
_curr2 = new TCursor ( _relmov2 , " " , 2 ) ;
_cur2 = add_cursor ( _curr2 ) ;
1994-12-05 14:21:36 +00:00
1995-01-31 16:13:30 +00:00
_relmov3 = new TRelation ( LF_MOV ) ;
1994-12-05 14:21:36 +00:00
_relmov3 - > add ( LF_RMOVIVA , " NUMREG==NUMREG " , 1 ) ;
_relmov3 - > add ( LF_RMOV , " NUMREG==NUMREG " , 1 ) ;
_curr3 = new TCursor ( _relmov3 , " " , 3 ) ;
_cur3 = add_cursor ( _curr3 ) ;
2003-03-14 15:13:36 +00:00
open_files ( LF_TAB , LF_TABCOM , LF_CAUSALI , LF_CLIFO , LF_COMUNI , LF_ATTIV ,
LF_PCON , LF_SALDI , LF_RMOVIVA , LF_NDITTE , 0 ) ;
1994-12-05 14:21:36 +00:00
_tabiva = new TTable ( TAB_IVA ) ;
_tabtpd = new TTable ( TAB_TPD ) ;
_tabreg = new TTable ( " REG " ) ;
_tabes = new TTable ( " ESC " ) ;
return TRUE ;
}
bool TListaMov_application : : user_destroy ( ) // releasev e arrmask
{
1995-03-01 16:47:54 +00:00
delete _relmov1 ;
delete _relmov2 ;
delete _relmov3 ;
1994-12-05 14:21:36 +00:00
delete _tabiva ;
delete _tabreg ;
1995-03-01 16:47:54 +00:00
delete _tabtpd ;
delete _tabes ;
1994-12-05 14:21:36 +00:00
return TRUE ;
}
void TListaMov_application : : init_print ( const TMask & msk )
{
1997-10-20 14:23:01 +00:00
const TDate data ( msk . get ( F_DATASTAMPA ) ) ;
1994-12-05 14:21:36 +00:00
printer ( ) . setdate ( data ) ;
1995-01-31 14:55:09 +00:00
printer ( ) . footerlen ( 5 ) ;
1995-01-31 16:13:30 +00:00
1999-04-06 15:34:39 +00:00
set_magic_currency ( TRUE ) ;
1994-12-05 14:21:36 +00:00
switch ( _tipo_lista )
{
case movimenti :
{
1997-10-20 14:23:01 +00:00
set_real_picture ( " ###.###.###.###.### " ) ;
1994-12-05 14:21:36 +00:00
reset_print ( ) ;
_flags = 0 ;
_err . reset ( ) ;
_tot_dare_giornaliero = 0 ;
_tot_avere_giornaliero = 0 ;
_tot_dare_generale = 0 ;
_tot_avere_generale = 0 ;
if ( _scelta_stampa = = 0 )
{
_annoes = msk . get_int ( F_ANNO ) ;
1995-01-31 16:13:30 +00:00
_stampa_parte_iva = msk . get_bool ( F_STAMPA ) ;
1994-12-05 14:21:36 +00:00
if ( _stampa_parte_iva )
_flags | = ST_DATI_IVA ;
1995-01-31 16:13:30 +00:00
_stampa_mess_alleg_iva = msk . get_bool ( F_ALLEGATO ) ;
1994-12-05 14:21:36 +00:00
if ( _stampa_mess_alleg_iva )
_flags | = ST_MESS_ALLEG ;
1995-01-31 16:13:30 +00:00
_stampa_anno_comp = msk . get_bool ( F_ANNOC ) ;
1994-12-05 14:21:36 +00:00
if ( _stampa_anno_comp )
_flags | = ST_ANNO_COMP ;
1995-01-31 16:13:30 +00:00
_controllo_mov_errati = msk . get_int ( F_CONTROLLO ) ;
1994-12-05 14:21:36 +00:00
if ( _controllo_mov_errati = = 1 )
_flags | = ST_SOLO_MOVERR ;
else if ( _controllo_mov_errati = = 2 )
_flags | = ST_CONTROLLO ;
else _flags | = ST_SENZA_CONTR ;
if ( ( _numreg_ini ! = 0 ) & & ( _decidi = = 1 ) )
_flags | = ST_NUMERO ;
if ( ( _data_ini . ok ( ) ) & & ( _decidi = = 2 ) )
_flags | = ST_DATA ;
_causale_ini = msk . get ( F_CAUSALEINI ) ;
if ( _causale_ini ! = " " )
_flags | = ST_CAUSALE ;
_registro_ini = msk . get ( F_REGISTROINI ) ;
if ( _registro_ini ! = " " )
_flags | = ST_REGISTRO ;
if ( ( _data_fin . ok ( ) ) & & ( _decidi = = 2 ) )
_flags | = ST_DATA ;
if ( ( _numreg_fin ! = 0 ) & & ( _decidi = = 2 ) )
_flags | = ST_NUMERO ;
_causale_fin = msk . get ( F_CAUSALEFIN ) ;
if ( _causale_fin ! = " " )
_flags | = ST_CAUSALE ;
_registro_fin = msk . get ( F_REGISTROFIN ) ;
if ( _registro_fin ! = " " )
_flags | = ST_REGISTRO ;
}
else //_scelta_stampa == 1
{
_annoes = msk . get_int ( F_ANNO ) ;
if ( _numreg_ini ! = 0 )
_flags | = ST_NUMERO ;
if ( _data_ini . ok ( ) )
_flags | = ST_DATA ;
_causale_ini = msk . get ( F_CAUSALEINI ) ;
if ( _causale_ini ! = " " )
_flags | = ST_CAUSALE ;
if ( _data_fin . ok ( ) )
_flags | = ST_DATA ;
if ( _numreg_fin ! = 0 )
_flags | = ST_NUMERO ;
_causale_fin = msk . get ( F_CAUSALEFIN ) ;
if ( _causale_fin ! = " " )
_flags | = ST_CAUSALE ;
}
}
break ;
1997-10-20 14:23:01 +00:00
case fatture :
1994-12-05 14:21:36 +00:00
{
1997-10-20 14:23:01 +00:00
if ( _noseparator )
set_real_picture ( " ################ " ) ;
else
set_real_picture ( " ####.###.###.### " ) ;
_flags = 0 ;
reset_print ( ) ;
_settata_prima_riga = FALSE ;
_tipo_clifo_prec = " " ;
_codcf_prec = 0l ;
_numeroregp = 0 ;
_documenti = 0 ;
_totdocumenti = 0 ;
_totimponibile = 0 ;
_totimposta = 0 ;
_op_esenti = 0 ;
_op_non_imp = 0 ;
_annoes = msk . get_int ( F_ANNO ) ;
_salto_pagina = ( bool ) ( msk . get ( F_CAMBIO ) = = " X " ) ;
_data_ini = msk . get ( F_DATAINI ) ;
if ( _data_ini . ok ( ) )
_flags | = ST_DATA ;
_data_fin = msk . get ( F_DATAFIN ) ;
2002-12-20 16:15:03 +00:00
_causale_ini = msk . get ( F_DACODCAUS ) ;
if ( _causale_ini ! = " " )
_flags | = ST_CAUSALE ;
1997-10-20 14:23:01 +00:00
if ( _data_fin . ok ( ) )
_flags | = ST_DATA ;
2002-12-20 16:15:03 +00:00
_causale_fin = msk . get ( F_ACODCAUS ) ;
if ( _causale_fin ! = " " )
_flags | = ST_CAUSALE ;
1997-10-20 14:23:01 +00:00
TString tipo = msk . get ( F_TIPOELENCO ) ;
if ( ( tipo = = " C " ) | | ( tipo = = " F " ) )
{
2002-05-08 16:25:49 +00:00
_codice_ini = msk . get_long ( F_CODICEINI ) ;
_codice_fin = msk . get_long ( F_CODICEFIN ) ;
1997-10-20 14:23:01 +00:00
}
else
{
2002-05-08 16:25:49 +00:00
_codice_ini = msk . get_long ( F_CODICEINI1 ) ;
_codice_fin = msk . get_long ( F_CODICEFIN1 ) ;
1997-10-20 14:23:01 +00:00
}
if ( _codice_ini ! = 0 )
_flags | = ST_CODICE ;
if ( _codice_fin ! = 0 )
_flags | = ST_CODICE ;
if ( tipo = = " E " )
{
_tipo_ini = " C " ;
_tipo_fin = " F " ;
}
else
{
_tipo_ini = tipo ;
_tipo_fin = tipo ;
}
1994-12-05 14:21:36 +00:00
}
1997-10-20 14:23:01 +00:00
break ;
default :
break ;
1994-12-05 14:21:36 +00:00
}
}
2002-05-08 16:25:49 +00:00
void TListaMov_application : : set_cdc_header ( int & soh )
{
if ( _cdc . not_empty ( ) )
2002-07-02 16:21:23 +00:00
{
const TString & desc_cdc = cache ( ) . get ( " CMS " , _cdc , " S0 " ) ;
if ( _fsc . not_empty ( ) )
{
const TString & desc_fsc = cache ( ) . get ( " FSC " , _fsc , " S0 " ) ;
2003-03-14 15:13:36 +00:00
set_header ( + + soh , FR ( " @bCommessa %s %s - Fase %s %s " ) ,
2002-07-02 16:21:23 +00:00
( const char * ) _cdc , ( const char * ) desc_cdc ,
( const char * ) _fsc , ( const char * ) desc_fsc ) ;
}
else
2003-03-14 15:13:36 +00:00
set_header ( + + soh , FR ( " @bCommessa %s %s " ) , ( const char * ) _cdc , ( const char * ) desc_cdc ) ;
2002-07-02 16:21:23 +00:00
}
2002-05-08 16:25:49 +00:00
}
1994-12-05 14:21:36 +00:00
void TListaMov_application : : preprocess_header ( )
{
int soh ; // riga d'inizio dell'intestazione
2003-03-14 15:13:36 +00:00
TString sep ( 132 ) ;
TString key ; key . format ( " %d " , get_firm ( ) ) ;
const TString & ragsoc = cache ( ) . get ( LF_NDITTE , key , NDT_RAGSOC ) ;
1994-12-05 14:21:36 +00:00
reset_header ( ) ;
soh = 1 ;
2003-03-14 15:13:36 +00:00
sep < < TR ( " Ditta " ) < < get_firm ( ) ;
1994-12-05 14:21:36 +00:00
sep < < " " < < ragsoc ;
sep . left_just ( 132 ) ;
set_header ( soh + + , ( const char * ) sep ) ;
2003-03-14 15:13:36 +00:00
sep . cut ( 0 ) < < FR ( " Data @> Pag. @# " ) ;
2000-10-03 13:45:12 +00:00
sep . right_just ( 122 ) ;
1994-12-05 14:21:36 +00:00
switch ( _tipo_lista )
{
case movimenti :
if ( _scelta_stampa = = 0 )
{
2003-03-14 15:13:36 +00:00
sep . overwrite ( TR ( " Lista movimenti " ) ) ;
1994-12-05 14:21:36 +00:00
set_header ( soh + + , ( const char * ) sep ) ;
if ( _decidi = = 2 ) // se _decidi e' 1 _annoes e' sempre uguale a zero
{
if ( _annoes ! = 0 )
{
2003-03-14 15:13:36 +00:00
set_header ( soh , FR ( " Cod. eserc.%d " ) , _annoes ) ;
1994-12-05 14:21:36 +00:00
if ( _flags & ST_DATA )
{
2003-03-14 15:13:36 +00:00
set_header ( soh , FR ( " @16gda@19g%s " ) , _data_ini . string ( ) ) ;
set_header ( soh , FR ( " @30ga@32g%s " ) , _data_fin . string ( ) ) ;
1994-12-05 14:21:36 +00:00
}
}
else // _annoes == 0
if ( _flags & ST_DATA )
{
2003-03-14 15:13:36 +00:00
set_header ( soh , FR ( " Dalla data@11g%s " ) , _data_ini . string ( ) ) ;
1994-12-05 14:21:36 +00:00
if ( _data_fin . ok ( ) )
2003-03-14 15:13:36 +00:00
set_header ( soh , FR ( " @23galla data@33g%s " ) , _data_fin . string ( ) ) ;
1994-12-05 14:21:36 +00:00
}
else
2003-03-14 15:13:36 +00:00
set_header ( soh , TR ( " Completa in ordine di data " ) ) ;
1994-12-05 14:21:36 +00:00
}
else
if ( _flags & ST_NUMERO )
{
2003-03-14 15:13:36 +00:00
set_header ( soh , FR ( " dal numero@12g%ld " ) , _numreg_ini ) ;
1994-12-05 14:21:36 +00:00
if ( _numreg_fin ! = 0 )
2003-03-14 15:13:36 +00:00
set_header ( soh , FR ( " @20gal numero@30g%ld " ) , _numreg_fin ) ;
1994-12-05 14:21:36 +00:00
}
else
2003-03-14 15:13:36 +00:00
set_header ( soh , TR ( " Completa in ordine di numero " ) ) ;
1994-12-05 14:21:36 +00:00
if ( _flags & ST_CAUSALE )
{
2003-03-14 15:13:36 +00:00
set_header ( soh , FR ( " @46gdalla causale@60g%s " ) , ( const char * ) _causale_ini ) ;
set_header ( soh + + , FR ( " @64galla causale@77g%s " ) , ( const char * ) _causale_fin ) ;
1994-12-05 14:21:36 +00:00
}
else
2003-03-14 15:13:36 +00:00
set_header ( soh + + , TR ( " tutte le causali " ) ) ;
1994-12-05 14:21:36 +00:00
if ( _flags & ST_REGISTRO )
{
2003-03-14 15:13:36 +00:00
set_header ( soh , FR ( " dal registro %s " ) , ( const char * ) _registro_ini ) ;
set_header ( soh , FR ( " @17gal registro %s " ) , ( const char * ) _registro_fin ) ;
1994-12-05 14:21:36 +00:00
}
else
2003-03-14 15:13:36 +00:00
set_header ( soh , TR ( " tutti i registri " ) ) ;
1994-12-05 14:21:36 +00:00
if ( _flags & ST_DATI_IVA )
2003-03-14 15:13:36 +00:00
set_header ( soh , FR ( " @34gstampa dati iva " ) ) ;
1994-12-05 14:21:36 +00:00
if ( _flags & ST_CONTROLLO )
2003-03-14 15:13:36 +00:00
set_header ( soh , FR ( " @50g(controllo movimenti) " ) ) ;
1994-12-05 14:21:36 +00:00
else if ( _flags & ST_SOLO_MOVERR )
2003-03-14 15:13:36 +00:00
set_header ( soh , FR ( " @50g(solo movimenti errati) " ) ) ;
else set_header ( soh , FR ( " @50g(senza controllo movimenti) " )) ;
1994-12-05 14:21:36 +00:00
if ( _flags & ST_MESS_ALLEG )
{
if ( _flags & ST_ANNO_COMP )
2003-03-14 15:13:36 +00:00
set_header ( soh , FR ( " @78gcon messaggi: data competenza, allegato iva " ) ) ;
1994-12-05 14:21:36 +00:00
else
2003-03-14 15:13:36 +00:00
set_header ( soh , FR ( " @78gcon messaggio: allegato iva " ) ) ;
1994-12-05 14:21:36 +00:00
}
else if ( _flags & ST_ANNO_COMP )
{
if ( _flags & ST_MESS_ALLEG )
2003-03-14 15:13:36 +00:00
set_header ( soh , FR ( " @78gcon messaggi: data competenza, allegato iva " ) ) ;
1994-12-05 14:21:36 +00:00
else
2003-03-14 15:13:36 +00:00
set_header ( soh , FR ( " @78gcon messaggio: data competenza " ) ) ;
1994-12-05 14:21:36 +00:00
}
2002-05-08 16:25:49 +00:00
set_cdc_header ( soh ) ;
sep . fill ( ' _ ' ) ;
1994-12-05 14:21:36 +00:00
set_header ( + + soh , ( const char * ) sep ) ;
2003-03-14 15:13:36 +00:00
set_header ( + + soh , FR ( " Rg Cod Causale@30gDescrizione@56gCodice conto@71gDescrizione conto@103gDare@120gAvere@130gSB " ) ) ;
1994-12-05 14:21:36 +00:00
}
else
{
2003-03-14 15:13:36 +00:00
sep . overwrite ( TR ( " Lista movimenti di sola prima nota " ) ) ;
1994-12-05 14:21:36 +00:00
set_header ( soh + + , ( const char * ) sep ) ;
if ( _decidi = = 2 )
{
if ( _annoes ! = 0 )
{
2003-03-14 15:13:36 +00:00
set_header ( soh , FR ( " Cod. comp. %d " ) , _annoes ) ;
1994-12-05 14:21:36 +00:00
if ( _flags & ST_DATA )
{
2003-03-14 15:13:36 +00:00
set_header ( soh , FR ( " @16gda@19g%s " ) , ( const char * ) _data_ini . string ( ) ) ;
set_header ( soh , FR ( " @30ga@32g%s " ) , ( const char * ) _data_fin . string ( ) ) ;
1994-12-05 14:21:36 +00:00
}
}
else
if ( _flags & ST_DATA )
{
2003-03-14 15:13:36 +00:00
set_header ( soh , FR ( " Dalla data@11g%s " ) , ( const char * ) _data_ini . string ( ) ) ;
set_header ( soh , FR ( " @23galla data@33g%s " ) , ( const char * ) _data_fin . string ( ) ) ;
1994-12-05 14:21:36 +00:00
}
else
2003-03-14 15:13:36 +00:00
set_header ( soh , TR ( " Completa in ordine di data " ) ) ;
1994-12-05 14:21:36 +00:00
}
else
if ( _flags & ST_NUMERO )
{
2003-03-14 15:13:36 +00:00
set_header ( soh , FR ( " @46gdal numero@57g%ld " ) , _numreg_ini ) ;
set_header ( soh , FR ( " @65gal numero@75g%ld " ) , _numreg_fin ) ;
1994-12-05 14:21:36 +00:00
}
else
2003-03-14 15:13:36 +00:00
set_header ( soh , FR ( " @46gCompleta in ordine di numero " ) ) ;
1994-12-05 14:21:36 +00:00
if ( _flags & ST_CAUSALE )
{
2003-03-14 15:13:36 +00:00
set_header ( soh , FR ( " @86gdalla causale@100g%3s " ) , ( const char * ) _causale_ini ) ;
set_header ( soh + + , FR ( " @104galla causale@117g%3s " ) , ( const char * ) _causale_fin ) ;
1994-12-05 14:21:36 +00:00
}
else
2003-03-14 15:13:36 +00:00
set_header ( soh + + , TR ( " @86gtutte le causali " ) ) ;
2002-05-08 16:25:49 +00:00
set_cdc_header ( soh ) ;
2002-07-02 16:21:23 +00:00
soh + + ;
2002-05-08 16:25:49 +00:00
sep . fill ( ' _ ' ) ;
1994-12-05 14:21:36 +00:00
set_header ( soh + + , ( const char * ) sep ) ;
2003-03-14 15:13:36 +00:00
set_header ( soh , FR ( " Rg Cod Causale@30gDescrizione@56gCodice conto@71gDescrizione conto@103gDare@120gAvere@130gSB " ) ) ;
1994-12-05 14:21:36 +00:00
}
break ;
case fatture :
2003-03-14 15:13:36 +00:00
sep . overwrite ( TR ( " Lista fatture " ) ) ;
1994-12-05 14:21:36 +00:00
set_header ( soh , ( const char * ) sep ) ;
if ( _annoes ! = 0 )
{
2003-03-14 15:13:36 +00:00
set_header ( soh , FR ( " @15gCod. comp %d " ) , _annoes ) ;
1994-12-05 14:21:36 +00:00
if ( _flags & ST_DATA )
{
2003-03-14 15:13:36 +00:00
set_header ( soh , FR ( " @30gdalla data@41g%s " ) , ( const char * ) _data_ini . string ( ) ) ;
set_header ( soh , FR ( " @52galla data@62g%s " ) , ( const char * ) _data_fin . string ( ) ) ;
1994-12-05 14:21:36 +00:00
}
}
else
if ( _flags & ST_DATA )
{
2003-03-14 15:13:36 +00:00
set_header ( soh , FR ( " @15gdalla data %s " ) , ( const char * ) _data_ini . string ( ) ) ;
set_header ( soh , FR ( " @37galla data %s " ) , ( const char * ) _data_fin . string ( ) ) ;
1994-12-05 14:21:36 +00:00
}
else
2003-03-14 15:13:36 +00:00
set_header ( soh , TR ( " @15gcompleta in ordine di data " ) ) ;
1994-12-05 14:21:36 +00:00
if ( _flags & ST_CODICE )
{
2003-03-14 15:13:36 +00:00
set_header ( soh , FR ( " @74gdal codice %ld " ) , _codice_ini ) ;
set_header ( soh , FR ( " @92gal codice %ld " ) , _codice_fin ) ;
1994-12-05 14:21:36 +00:00
}
2002-05-08 16:25:49 +00:00
set_cdc_header ( soh ) ;
sep . fill ( ' _ ' ) ;
1994-12-05 14:21:36 +00:00
set_header ( + + soh , ( const char * ) sep ) ;
2003-03-14 15:13:36 +00:00
set_header ( + + soh , FR ( " Numero Data Cod Prot. M Documento@48gCod Tp @75gTotale@101gCd Tp T O@129gNo " ) ) ;
set_header ( + + soh , FR ( " Regis. Operaz. Reg Num. L Data@41gNumero@48gCau Dc @55gDescrizione@75gDocumento@90gImponibile@101gIv Det A I@121gImposta@129gAll " ) ) ;
1994-12-05 14:21:36 +00:00
break ;
default :
break ;
2002-05-08 16:25:49 +00:00
}
1994-12-05 14:21:36 +00:00
set_header ( + + soh , ( const char * ) sep ) ;
}
1999-04-06 15:34:39 +00:00
TListaMov_application : : TListaMov_application ( char tipost )
: _tipoc ( tipost ) , _err ( 80 ) ,
_simbval ( TAB_VAL , " S7 " ) , _descdoc ( TAB_TPD , " S0 " )
{ }
1994-12-05 14:21:36 +00:00
int cg3100 ( int argc , char * argv [ ] )
{
1999-04-06 15:34:39 +00:00
const char tipo = argc > 2 ? * argv [ 2 ] : ' M ' ;
1995-06-09 15:36:37 +00:00
TListaMov_application a ( tipo ) ;
1997-10-20 14:23:01 +00:00
const char * title ;
1995-06-09 15:36:37 +00:00
switch ( tipo )
{
case ' C ' :
2003-03-14 15:13:36 +00:00
title = TR ( " Lista fatture clienti/fornitori " ) ;
1995-06-09 15:36:37 +00:00
break ;
default :
2003-03-14 15:13:36 +00:00
title = TR ( " Lista movimenti " ) ;
1995-06-09 15:36:37 +00:00
break ;
}
a . run ( argc , argv , title ) ;
return TRUE ;
1994-12-05 14:21:36 +00:00
}