2001-04-30 14:22:43 +00:00
# include <applicat.h>
# include <printer.h>
# include <recarray.h>
# include "ce3.h"
2001-06-25 10:41:20 +00:00
# include "celib.h"
2004-03-16 20:40:21 +00:00
# include "../cg/cglib01.h"
2001-06-25 10:41:20 +00:00
# include "ce2101.h"
2001-04-30 14:22:43 +00:00
# include "ce3300a.h"
# include "ce3300.h"
2001-06-25 10:41:20 +00:00
# include "ammce.h"
# include "ammmv.h"
# include "cespi.h"
# include "movam.h"
# include "movce.h"
# include "salce.h"
2001-04-30 14:22:43 +00:00
2001-06-25 10:41:20 +00:00
//===============================================================================================//
//-----FORM--------------------------------------------------------------------------------------//
2001-04-30 14:22:43 +00:00
class TForm_prospettocesp : public TForm_cespiti
2001-06-25 10:41:20 +00:00
{
2001-04-30 14:22:43 +00:00
public :
virtual bool validate ( TForm_item & cf , TToken_string & s ) ;
void set_testata ( ) { set_header ( 1 , TRUE ) ; }
void set_pedata ( ) { set_footer ( 1 , FALSE ) ; set_footer ( 1 , TRUE ) ; }
2001-06-25 10:41:20 +00:00
TPrint_section & get_body ( ) { return section ( ' B ' , odd_page ) ; }
2001-04-30 14:22:43 +00:00
TForm_prospettocesp ( ) ;
virtual ~ TForm_prospettocesp ( ) ;
} ;
TForm_prospettocesp : : TForm_prospettocesp ( ) : TForm_cespiti ( " ce3300a " ) //costruttore
{
}
TForm_prospettocesp : : ~ TForm_prospettocesp ( )
{
}
bool TForm_prospettocesp : : validate ( TForm_item & cf , TToken_string & s )
{
return TForm_cespiti : : validate ( cf , s ) ; //richiama la validate standard della classe genitore (TForm_cespiti)
}
2001-06-25 10:41:20 +00:00
//==============================================================================================//
//-----AUTOMASK---------------------------------------------------------------------------------//
2001-04-30 14:22:43 +00:00
class TStampaprospetto_mask : public TAutomask
{
TRelation * _rel ;
TCursor * _cur ;
protected :
bool on_field_event ( TOperable_field & o , TField_event e , long jolly ) ;
public :
TStampaprospetto_mask ( ) ;
virtual ~ TStampaprospetto_mask ( ) { } ;
} ;
TStampaprospetto_mask : : TStampaprospetto_mask ( ) : TAutomask ( " ce3300a " )
{
ditta_cespiti ( ) . init_mask ( * this ) ;
}
bool TStampaprospetto_mask : : on_field_event ( TOperable_field & o , TField_event e , long jolly )
{
switch ( o . dlg ( ) )
{
case F_SITFISC :
if ( e = = fe_close )
{
if ( ! get_bool ( F_SITFISC ) & & ! get_bool ( F_SITCIV ) & & ! get_bool ( F_SITGEST ) ) //deve essere selezionata almeno 1 situaz.
2003-05-12 15:03:40 +00:00
return error_box ( TR ( " Selezionare almeno una delle Situazioni da stampare " ) ) ;
2001-04-30 14:22:43 +00:00
}
break ;
default : break ;
}
return TRUE ;
}
2001-06-25 10:41:20 +00:00
//=======================================================================================================================//
struct TTotali : public TObject
{
real _tot_csto ;
real _tot_riv ;
real _tot_riveser ;
real _tot_acqincr ;
real _tot_cesselim2 ;
real _tot_fondinieser ;
real _tot_incr ;
real _tot_cesselim3 ;
real _tot_reinplus ;
real _tot_ammnor ;
real _tot_ammacc ;
real _tot_ammant ;
void azzera ( ) ;
TTotali & operator + = ( const TTotali & t ) ;
} ;
void TTotali : : azzera ( )
{
_tot_csto = 0 ;
_tot_riv = 0 ;
_tot_riveser = 0 ;
_tot_acqincr = 0 ;
_tot_cesselim2 = 0 ;
_tot_fondinieser = 0 ;
_tot_incr = 0 ;
_tot_cesselim3 = 0 ;
_tot_reinplus = 0 ;
_tot_ammnor = 0 ;
_tot_ammacc = 0 ;
_tot_ammant = 0 ;
}
//-----------------------------------------------------------------------------------------------------------------------//
TTotali & TTotali : : operator + = ( const TTotali & t )
{
_tot_csto + = t . _tot_csto ;
_tot_riv + = t . _tot_riv ;
_tot_riveser + = t . _tot_riveser ;
_tot_acqincr + = t . _tot_acqincr ;
_tot_cesselim2 + = t . _tot_cesselim2 ;
_tot_fondinieser + = t . _tot_fondinieser ;
_tot_incr + = t . _tot_incr ;
_tot_cesselim3 + = t . _tot_cesselim3 ;
_tot_reinplus + = t . _tot_reinplus ;
_tot_ammnor + = t . _tot_ammnor ;
_tot_ammacc + = t . _tot_ammacc ;
_tot_ammant + = t . _tot_ammant ;
return * this ; //ritorna se stesso, quindi i valori dei totali
}
2001-04-30 14:22:43 +00:00
2001-06-25 10:41:20 +00:00
//=======================================================================================================================//
//-----SKELETON APPLICATION----------------------------------------------------------------------------------------------//
2001-04-30 14:22:43 +00:00
class TStampa_prospetto : public TSkeleton_application
{
TStampaprospetto_mask * _mask ;
TForm_prospettocesp * _form ;
protected :
virtual bool create ( ) ;
virtual bool destroy ( ) ;
virtual void main_loop ( ) ;
2001-06-25 10:41:20 +00:00
void set_intestazione ( const int tipo , const int ordinamento ) ;
void set_pavimentazione ( ) ;
void stampa_totali_cat ( const TString & codicecat , const TString & descrcat ) ; //stampa sul form i valori totali per categoria
void stampa_totali_tipo ( TTipo_cespite tcesp ) ; //stampa sul form i valori totali per tipo cespite (materiale, immateriale, pluriennale)
void stampa_totali_generali ( ) ; //stampa sul form i valori totali per tutti i cespiti
void fill_body ( const TTotali & tot ) ; //riempie il campo body con tutti i totali
void print_body ( ) ; //stampa effettivamente il body
void set_field ( int id , const real & val ) ; //mette in un campo del body odd un valore numerico
void set_field ( int id , const char * val ) ; //mette in un campo del body odd una stringa
void aggiorna_totali ( TCursor & cur , const int tipo , TTipo_cespite tcesp ) ; //calcola effettivamente i totali di ciascuna categoria
2001-04-30 14:22:43 +00:00
public :
TStampa_prospetto ( ) { }
2001-06-25 10:41:20 +00:00
private :
TDate _dataini ;
TDate _datafine ;
TTotali _cat , _mtr , _gen ; //sono i tre set di totali (categoria, materiali, generali)
2001-04-30 14:22:43 +00:00
} ;
bool TStampa_prospetto : : create ( )
{
open_files ( LF_CESPI , LF_SALCE , LF_AMMCE , LF_MOVCE , LF_AMMMV , 0 ) ;
_mask = new TStampaprospetto_mask ;
2001-06-25 10:41:20 +00:00
_form = new TForm_prospettocesp ;
2001-04-30 14:22:43 +00:00
return TSkeleton_application : : create ( ) ;
}
bool TStampa_prospetto : : destroy ( )
{
delete _mask ;
delete _form ;
return TSkeleton_application : : destroy ( ) ;
}
2001-06-25 10:41:20 +00:00
//------------------------------------------------------------------------------------------------------------------------//
void TStampa_prospetto : : set_intestazione ( const int tipo , const int ordinamento )
2001-04-30 14:22:43 +00:00
{
2001-06-25 10:41:20 +00:00
// scrive l'header first, contenente i dati della ditta e dell'esercizio
_form - > find_field ( ' H ' , first_page , FR_CODDITTA ) . set ( _mask - > get ( F_CODDITTA ) ) ;
_form - > find_field ( ' H ' , first_page , FR_RAGSOC ) . set ( _mask - > get ( F_DESCRDITTA ) ) ;
_form - > find_field ( ' H ' , first_page , FR_GRUPPO ) . set ( _mask - > get ( F_GRUPPO ) ) ;
_form - > find_field ( ' H ' , first_page , FR_D_GRUPPO ) . set ( _mask - > get ( F_D_GRUPPO ) ) ;
_form - > find_field ( ' H ' , first_page , FR_SPECIE ) . set ( _mask - > get ( F_SPECIE ) ) ;
_form - > find_field ( ' H ' , first_page , FR_D_SPECIE ) . set ( _mask - > get ( F_D_SPECIE ) ) ;
_form - > find_field ( ' H ' , first_page , FR_DATAINIZIO ) . set ( _dataini ) ;
_form - > find_field ( ' H ' , first_page , FR_DATAFINE ) . set ( _datafine ) ;
// in base all'ordinamento (per categoria o per impianto) scrive la riga con codice e descrizione
if ( ordinamento = = 0 )
{
2003-05-12 15:03:40 +00:00
_form - > find_field ( ' H ' , first_page , FR_INT_COD ) . set ( FR ( " @bCat.@r " ) ) ;
_form - > find_field ( ' H ' , first_page , FR_INT_DESC ) . set ( FR ( " @bDescrizione categoria@r " ) ) ;
2001-06-25 10:41:20 +00:00
}
else
{
2003-05-12 15:03:40 +00:00
_form - > find_field ( ' H ' , first_page , FR_INT_COD ) . set ( TR ( " Imp. " ) ) ;
_form - > find_field ( ' H ' , first_page , FR_INT_DESC ) . set ( TR ( " Descr. impianto " ) ) ;
2001-06-25 10:41:20 +00:00
}
//in base al(ai) tipo(i) di situazione cambia una riga dell'header
switch ( tipo )
2001-04-30 14:22:43 +00:00
{
case 1 :
2003-05-12 15:03:40 +00:00
_form - > find_field ( ' H ' , first_page , FR_SITUAZIONE ) . set ( TR ( " fiscale " ) ) ;
2001-04-30 14:22:43 +00:00
break ;
case 2 :
2003-05-12 15:03:40 +00:00
_form - > find_field ( ' H ' , first_page , FR_SITUAZIONE ) . set ( TR ( " civilistica " ) ) ;
2001-04-30 14:22:43 +00:00
break ;
case 3 :
2003-05-12 15:03:40 +00:00
_form - > find_field ( ' H ' , first_page , FR_SITUAZIONE ) . set ( TR ( " gestionale " ) ) ;
2001-04-30 14:22:43 +00:00
break ;
}
_form - > set_testata ( ) ;
}
2001-06-25 10:41:20 +00:00
//-----------------------------------------------------------------------------------------------------------------------//
void TStampa_prospetto : : set_pavimentazione ( )
2001-04-30 14:22:43 +00:00
{
_form - > set_pedata ( ) ;
}
2001-06-25 10:41:20 +00:00
//-----------------------------------------------------------------------------------------------------------------------//
void TStampa_prospetto : : print_body ( )
{
set_pavimentazione ( ) ; // stampa il fondo pagina
TPrint_section & body = _form - > get_body ( ) ;
body . update ( ) ;
if ( body . height ( ) > printer ( ) . rows_left ( ) )
printer ( ) . formfeed ( ) ;
for ( word i = 0 ; i < body . height ( ) ; i + + ) // stampa le righe del body
printer ( ) . print ( body . row ( i ) ) ;
}
//-----------------------------------------------------------------------------------------------------------------------//
void TStampa_prospetto : : stampa_totali_cat ( const TString & codicecat , const TString & descrcat )
{
// scrive codice e descrizione della categoria di cui stampa i valori
set_field ( FR_TC_CAT , codicecat ) ;
set_field ( FR_TC_D_CAT , descrcat ) ;
// riempie il body con i totali per categoria
fill_body ( _cat ) ;
// stampa effettivamente il body sul form
print_body ( ) ;
// somma sui totali materiali
_mtr + = _cat ;
_gen + = _cat ;
}
//-------------------------------------------------------------------------------------------------------------------------//
void TStampa_prospetto : : stampa_totali_tipo ( TTipo_cespite tcesp )
{
// scrive il tipo di cespiti di cui calcola il totale
set_field ( FR_TC_CAT , " " ) ;
2008-03-11 16:59:33 +00:00
TString80 tipodescr ;
tipodescr < < TR ( " TOTALI BENI " ) < < ' ' ;
2001-06-25 10:41:20 +00:00
switch ( tcesp )
{
2008-03-11 16:59:33 +00:00
case tc_pluriennale : tipodescr < < TR ( " PLURIENNALI " ) ; break ;
case tc_immateriale : tipodescr < < TR ( " IMMATERIALI " ) ; break ;
default : tipodescr < < TR ( " MATERIALI " ) ; break ;
2001-06-25 10:41:20 +00:00
}
set_field ( FR_TC_D_CAT , tipodescr ) ;
// riempie il body con i totali per tipologia cespite (per situazione)
fill_body ( _mtr ) ;
2001-04-30 14:22:43 +00:00
2001-06-25 10:41:20 +00:00
// stampa effettivamente il body sul form
print_body ( ) ;
}
//-------------------------------------------------------------------------------------------------------------------------//
void TStampa_prospetto : : stampa_totali_generali ( )
{
// scrive TOTALI GENERALI
set_field ( FR_TC_CAT , " " ) ;
2003-05-12 15:03:40 +00:00
set_field ( FR_TC_D_CAT , TR ( " TOTALI GENERALI " ) ) ;
2001-06-25 10:41:20 +00:00
// riempie il body con i totali generali per situazione selezionata
fill_body ( _gen ) ;
2001-04-30 14:22:43 +00:00
2001-06-25 10:41:20 +00:00
// stampa effettivamente il body sul form
print_body ( ) ;
}
//-------------------------------------------------------------------------------------------------------------------------//
void TStampa_prospetto : : set_field ( int id , const real & val )
{
_form - > find_field ( ' B ' , odd_page , id ) . set ( val . string ( ) ) ;
}
//-------------------------------------------------------------------------------------------------------------------------//
void TStampa_prospetto : : set_field ( int id , const char * val )
{
_form - > find_field ( ' B ' , odd_page , id ) . set ( val ) ;
}
//-------------------------------------------------------------------------------------------------------------------------//
void TStampa_prospetto : : fill_body ( const TTotali & tot )
{
// riempie il body odd, contenente i totali; lo fa chiamando la set_field per ogni campo
set_field ( FR_TC_CSTO , tot . _tot_csto ) ;
set_field ( FR_TC_TOTRIV , tot . _tot_riv ) ;
real tempval1 = tot . _tot_csto + tot . _tot_riv ;
set_field ( FR_TC_VALINIES , tempval1 ) ;
set_field ( FR_TC_RIVALES , tot . _tot_riveser ) ;
set_field ( FR_TC_ACQINCR , tot . _tot_acqincr ) ;
set_field ( FR_TC_CESSELIM2 , tot . _tot_cesselim2 ) ;
tempval1 + = tot . _tot_riveser + tot . _tot_acqincr - tot . _tot_cesselim2 ;
set_field ( FR_TC_VALBIL , tempval1 ) ;
set_field ( FR_TC_FONDINIES , tot . _tot_fondinieser ) ;
set_field ( FR_TC_INCR , tot . _tot_incr ) ;
set_field ( FR_TC_CESSELIM3 , tot . _tot_cesselim3 ) ;
set_field ( FR_TC_REINPLUS , tot . _tot_reinplus ) ;
set_field ( FR_TC_AMMNOR , tot . _tot_ammnor ) ;
set_field ( FR_TC_AMMACC , tot . _tot_ammacc ) ;
set_field ( FR_TC_AMMANT , tot . _tot_ammant ) ;
real tempval2 = tot . _tot_fondinieser + tot . _tot_incr - tot . _tot_cesselim3 + tot . _tot_reinplus + tot . _tot_ammnor + tot . _tot_ammacc + tot . _tot_ammant ;
set_field ( FR_TC_FONDBIL , tempval2 ) ;
tempval2 = tempval1 - tempval2 ;
2008-06-11 11:19:53 +00:00
if ( tempval2 < ZERO )
tempval2 = ZERO ;
2001-06-25 10:41:20 +00:00
set_field ( FR_TC_RESBIL , tempval2 ) ;
}
//-------------------------------------------------------------------------------------------------------------------------//
2008-03-11 16:59:33 +00:00
void TStampa_prospetto : : aggiorna_totali ( TCursor & curcespi , const int tipo , TTipo_cespite tcesp )
2001-06-25 10:41:20 +00:00
{
// valori della riga 1 (dipendenti da tipo solo le rivgf/rivgc)
2008-03-11 16:59:33 +00:00
const TRectype & recsalce = curcespi . curr ( LF_SALCE ) ;
2008-05-05 14:41:32 +00:00
const real csto1 = recsalce . get_real ( SALCE_CSTO ) ;
2008-03-11 16:59:33 +00:00
const TRectype & cespi = curcespi . curr ( ) ;
const bool leasing = cespi . get_bool ( CESPI_LEASING ) ;
2001-06-25 10:41:20 +00:00
2008-05-05 14:41:32 +00:00
_cat . _tot_csto + = csto1 ;
2007-09-17 15:33:04 +00:00
if ( tipo = = 2 )
_cat . _tot_csto - = recsalce . get_real ( SALCE_VNONAMMC ) ;
2001-06-25 10:41:20 +00:00
else
2007-09-17 15:33:04 +00:00
_cat . _tot_csto - = recsalce . get_real ( SALCE_VNONAMM ) ;
_cat . _tot_csto - = recsalce . get_real ( SALCE_VNONAMM06 ) ;
2008-03-11 16:59:33 +00:00
real rivsalce = recsalce . get_real ( SALCE_RIV75 ) ;
2007-09-17 15:33:04 +00:00
rivsalce + = recsalce . get_real ( SALCE_RIV83 ) ;
rivsalce + = recsalce . get_real ( SALCE_RIV90 ) ;
rivsalce + = recsalce . get_real ( SALCE_RIV91 ) ;
2001-06-25 10:41:20 +00:00
2008-03-11 16:59:33 +00:00
_cat . _tot_riv + = rivsalce ;
if ( tipo = = 1 | | leasing )
_cat . _tot_riv + = recsalce . get_real ( SALCE_RIVGF ) ; else
if ( tipo = = 2 & & ! leasing )
2007-09-17 15:33:04 +00:00
_cat . _tot_riv + = recsalce . get_real ( SALCE_RIVGC ) ;
2001-06-25 10:41:20 +00:00
// valori della riga 2 (e, gi<67> che si fa la scansione dei movimenti, anche i valori dei movam della riga 3)
// (i valori della riga 2 non dipendono da tipo, mentre quelli della riga 3 si, in quanto hanno movam)
TRectype recmovce ( LF_MOVCE ) ;
2008-03-11 16:59:33 +00:00
const TString16 idcespite = cespi . get ( CESPI_IDCESPITE ) ;
recmovce . put ( MOVCE_IDCESPITE , idcespite ) ;
real amv_ammnor , amv_ammacc , amv_ammant ;
2001-06-25 10:41:20 +00:00
TRelation relmovce ( LF_MOVCE ) ;
// viene aggiunta la relazione su movam (che contiene il filtro su tpamm dovuto al tipo di situazione scelto nella maschera)..
TString expr ;
expr < < " IDCESPITE==IDCESPITE|IDMOV==IDMOV|TPAMM== " < < tipo ;
relmovce . add ( LF_MOVAM , expr ) ;
//.. e quindi viene aggiunta la relazione su ammmv (che contiene il filtro su tpamm dovuto al tipo di situazione scelto nella
// maschera) utilizzando la stessa espressione di filtro, in quanto la chiave di ammmv <20> identica a quella di movam (ol<6F> !)
relmovce . add ( LF_AMMMV , expr ) ;
2008-03-11 16:59:33 +00:00
// Scansione movimenti in base alla chiave IDCESPITE+IDMOV
2001-06-25 10:41:20 +00:00
TCursor curmovce ( & relmovce , " " , 2 , & recmovce , & recmovce ) ;
2008-03-11 16:59:33 +00:00
const TRecnotype num1 = curmovce . items ( ) ;
2001-06-25 10:41:20 +00:00
2008-03-11 16:59:33 +00:00
if ( num1 > 0 )
{
curmovce . freeze ( ) ;
2001-06-25 10:41:20 +00:00
2008-03-11 16:59:33 +00:00
const TRectype & movce = curmovce . curr ( ) ;
const TRectype & movam = curmovce . curr ( LF_MOVAM ) ;
const TRectype & ammmv = curmovce . curr ( LF_AMMMV ) ;
for ( curmovce = 0 ; curmovce . pos ( ) < num1 ; + + curmovce )
2001-06-25 10:41:20 +00:00
{
2008-03-11 16:59:33 +00:00
const TDate dtmov = movce . get_date ( MOVCE_DTMOV ) ;
if ( dtmov > = _dataini & & dtmov < = _datafine )
{
const TString4 codmov = movce . get ( MOVCE_CODMOV ) ;
const char tmc = cache ( ) . get ( " %TMC " , codmov , " S6 " ) [ 0 ] ; //prende il valore del campo S6 nella tabella tipi movimento
const char segno = movce . get_char ( MOVCE_SEGNO ) ;
const real signum = segno = = ' - ' ? - UNO : UNO ; //serve per sommare i movimenti con il loro segno effettivo
real rivmovce = movce . get_real ( MOVCE_RIV75 ) ;
rivmovce + = movce . get_real ( MOVCE_RIV83 ) ;
rivmovce + = movce . get_real ( MOVCE_RIV90 ) ;
rivmovce + = movce . get_real ( MOVCE_RIV91 ) ;
2008-05-05 14:41:32 +00:00
const real csto2 = movce . get_real ( MOVCE_CSTO ) ;
2008-03-11 16:59:33 +00:00
// inquietante modo di selezionare la rivg (rivgf o rivgc) in base al tipo senza usare una if else!
real rivg ;
if ( tipo = = 1 | | leasing )
rivg = movce . get_real ( MOVCE_RIVGF ) ; else
if ( tipo = = 2 & & ! leasing )
rivg = movce . get_real ( MOVCE_RIVGC ) ;
real qmovam = movam . get_real ( MOVAM_QNOR ) ;
qmovam + = movam . get_real ( MOVAM_QACC ) ;
qmovam + = movam . get_real ( MOVAM_QANT ) ;
2008-06-11 11:19:53 +00:00
real qammmv ;
qammmv + = ammmv . get_real ( AMMMV_QNOR ) ;
qammmv + = ammmv . get_real ( AMMMV_QACC ) ;
qammmv + = ammmv . get_real ( AMMMV_QANT ) ;
2008-03-11 16:59:33 +00:00
if ( tmc = = ' R ' )
_cat . _tot_riveser + = ( rivmovce + rivg ) * signum ; else
if ( tmc = = ' P ' )
_cat . _tot_reinplus + = movce . get_real ( MOVCE_PLUSREIN ) * signum ; else
if ( tmc = = ' I ' | | ( tmc < = ' ' & & segno = = ' + ' ) )
{
2008-05-05 14:41:32 +00:00
_cat . _tot_acqincr + = ( csto2 + rivmovce + rivg ) * signum ;
2008-03-11 16:59:33 +00:00
_cat . _tot_incr + = qmovam * signum ;
} else
if ( tmc = = ' E ' | | ( tmc < = ' ' & & segno = = ' - ' ) )
{
2008-05-05 14:41:32 +00:00
_cat . _tot_cesselim2 + = ( csto2 + rivmovce + rivg ) * ( - signum ) ;
2008-03-11 16:59:33 +00:00
_cat . _tot_cesselim3 + = qmovam * ( - signum ) ;
2008-06-11 11:19:53 +00:00
_cat . _tot_cesselim3 + = qammmv * ( - signum ) ; // Aggiunto il 04/05/2008
2008-03-11 16:59:33 +00:00
}
2008-06-11 11:19:53 +00:00
// viene preso l'ammortamento da ammmv (che verr<72> poi sommato nella riga 4, pi<70> sotto, a quello
// preso da ammce); l'ammortamento viene preso qui in quanto <20> relativo ai movimenti che vengono qui scanditi
amv_ammnor + = qammmv ;
2008-03-11 16:59:33 +00:00
} //fine controllo sulle date
} //fine scansione sui movimenti
}
2001-06-25 10:41:20 +00:00
// valori delle righe 3 e 4 di ammce (questi valori dipendono dal tipo di situazione selezionato nella maschera)
// record con chiave idcespite,codes,tpamm
TRectype recammce ( LF_AMMCE ) ;
2008-03-11 16:59:33 +00:00
recammce . put ( AMMCE_IDCESPITE , idcespite ) ;
2001-06-25 10:41:20 +00:00
recammce . put ( AMMCE_CODES , _mask - > get ( F_ESERCIZIO ) ) ;
// filtro sul tpamm (va messo per non prendere tutti gli ammortamenti (dei 3 tipi) assieme)
2008-03-11 16:59:33 +00:00
expr . cut ( 0 ) < < AMMCE_TPAMM < < " = " < < tipo ;
2001-06-25 10:41:20 +00:00
TRelation relammce ( LF_AMMCE ) ;
TCursor curammce ( & relammce , expr , 1 , & recammce , & recammce ) ;
2008-03-11 16:59:33 +00:00
const TRecnotype num2 = curammce . items ( ) ;
2001-06-25 10:41:20 +00:00
curammce . freeze ( ) ;
2008-03-11 16:59:33 +00:00
const TRectype & ammce = curammce . curr ( ) ;
// scandisce gli ammce del cespite (al massimo 2 per ogni codes, ovvero iniziale e finale)
2001-06-25 10:41:20 +00:00
for ( curammce = 0 ; curammce . pos ( ) < num2 ; + + curammce )
{
// se tpsaldo = 1 (inizio) gli ammortamenti sono....
2008-03-11 16:59:33 +00:00
if ( ammce . get_int ( AMMCE_TPSALDO ) = = 1 )
2001-06-25 10:41:20 +00:00
{
2008-03-11 16:59:33 +00:00
_cat . _tot_fondinieser + = ammce . get_real ( AMMCE_QNOR ) ;
_cat . _tot_fondinieser + = ammce . get_real ( AMMCE_QACC ) ;
_cat . _tot_fondinieser + = ammce . get_real ( AMMCE_QANT ) ;
2001-06-25 10:41:20 +00:00
}
// se invece tpsaldo = 2 (fine) gli ammortamenti sono....
else
{
2008-03-11 16:59:33 +00:00
_cat . _tot_ammnor + = ammce . get_real ( AMMCE_QNOR ) ;
_cat . _tot_ammacc + = ammce . get_real ( AMMCE_QACC ) ;
_cat . _tot_ammant + = ammce . get_real ( AMMCE_QANT ) ;
2008-05-05 14:41:32 +00:00
2008-03-11 16:59:33 +00:00
// gli ammortamenti devono tenere conto anche di quelli sui movimenti, calcolati
2001-06-25 10:41:20 +00:00
// durante la scansione dei movimenti
2008-05-05 14:41:32 +00:00
_cat . _tot_ammnor + = amv_ammnor ;
_cat . _tot_ammacc + = amv_ammacc ;
_cat . _tot_ammant + = amv_ammant ;
2001-06-25 10:41:20 +00:00
}
} // fine scansione sugli ammce
} // fine routine
//-----------------------------------------------------------------------------------------------------------------------//
2001-04-30 14:22:43 +00:00
void TStampa_prospetto : : main_loop ( )
{
_mask - > set ( F_SITFISC , " X " ) ;
while ( _mask - > run ( ) = = K_ENTER )
2001-06-25 10:41:20 +00:00
{
2008-06-11 11:19:53 +00:00
const int esercizio = _mask - > get_int ( F_ESERCIZIO ) ;
const int gru = _mask - > get_int ( F_GRUPPO ) ;
const TString4 spe = _mask - > get ( F_SPECIE ) ;
ditta_cespiti ( ) . set_attivita ( esercizio , gru , spe ) ;
2001-06-25 10:41:20 +00:00
// record su esercizio,gruppo,specie
TRectype rec ( LF_CESPI ) ;
2008-06-11 11:19:53 +00:00
rec . put ( CESPI_CODCGRA , gru ) ;
rec . put ( CESPI_CODSPA , spe ) ;
2001-06-25 10:41:20 +00:00
// relazione su lf_cespi e lf_salce
TRelation relcespi ( LF_CESPI ) ;
TString espr ;
espr < < " IDCESPITE==IDCESPITE|CODES== " < < esercizio ;
relcespi . add ( LF_SALCE , espr ) ;
2008-05-06 14:07:08 +00:00
// vanno esclusi i cespiti alienati?
const bool exclude_aliens = _mask - > get_bool ( F_EXCLUDE_ALIENS ) ;
2001-06-25 10:41:20 +00:00
// filtro su esercizio gruppo specie e data acquisto cespite sia <= alla data fine esercizio selezionato
TString filtro ;
_dataini = _mask - > get_date ( F_INIZIO_ES ) ;
_datafine = _mask - > get_date ( F_FINE_ES ) ;
2002-07-02 16:21:23 +00:00
filtro < < " (CODCGRA= \" " < < _mask - > get_int ( F_GRUPPO ) < < " \" )&& " ;
2001-06-25 10:41:20 +00:00
filtro < < " (CODSPA= \" " < < _mask - > get ( F_SPECIE ) < < " \" )&& " ;
filtro < < " ( " < < LF_SALCE < < " ->CODES= " < < esercizio < < " )&& " ;
2008-06-11 11:19:53 +00:00
filtro < < " (ANSI( " < < LF_CESPI < < " ->DTCOMP)<= " < < _datafine . date2ansi ( ) < < " ) " ;
2008-05-06 14:07:08 +00:00
if ( exclude_aliens )
2008-06-11 11:19:53 +00:00
filtro < < " &&((ANSI( " < < LF_CESPI < < " ->DTALIEN)='')||(ANSI( " < < LF_CESPI < < " ->DTALIEN)>= " < < _dataini . date2ansi ( ) < < " )) " ;
2001-06-25 10:41:20 +00:00
// prepara il cursore di tipo sorted perch<63> ho due tipi di ordinamento possibili: per categoria e per impianto
const int ordinamento = _mask - > get_int ( F_ORDINA ) ;
2008-03-11 16:59:33 +00:00
TString16 ordin = ordinamento = = 0 ? CESPI_CODCAT : CESPI_CODIMP ;
2008-06-11 11:19:53 +00:00
ordin < < ' | ' < < CESPI_IDCESPITE ;
2001-06-25 10:41:20 +00:00
TSorted_cursor sortcur ( & relcespi , ordin , filtro , 1 , & rec , & rec ) ;
2008-06-11 11:19:53 +00:00
//sortcur.setregion(rec,rec);
//sortcur.setfilter(filtro,TRUE);
2001-04-30 14:22:43 +00:00
2003-07-22 13:22:11 +00:00
const TRecnotype num = sortcur . items ( ) ;
2001-06-25 10:41:20 +00:00
sortcur . freeze ( ) ;
2001-04-30 14:22:43 +00:00
printer ( ) . open ( ) ;
2008-03-11 16:59:33 +00:00
// scansione sulle 3 possibili situazioni stampabili: 1=fiscale; 2=civilistica; 3=gestionale.
for ( int sit = 1 ; sit < = 3 ; sit + + )
2001-04-30 14:22:43 +00:00
{
2001-06-25 10:41:20 +00:00
// stampa solo le situazioni selezionate
2008-03-11 16:59:33 +00:00
if ( sit = = 1 & & ! _mask - > get_bool ( F_SITFISC ) )
2001-06-25 10:41:20 +00:00
continue ;
2008-03-11 16:59:33 +00:00
if ( sit = = 2 & & ! _mask - > get_bool ( F_SITCIV ) )
2001-06-25 10:41:20 +00:00
continue ;
2008-03-11 16:59:33 +00:00
if ( sit = = 3 & & ! _mask - > get_bool ( F_SITGEST ) )
2001-06-25 10:41:20 +00:00
continue ;
// setta l'intestazione del form...
2008-03-11 16:59:33 +00:00
set_intestazione ( sit , ordinamento ) ;
2001-06-25 10:41:20 +00:00
// ed il fondo pagina
set_pavimentazione ( ) ;
// gestione categorie ed effettivo main loop di stampa
// azzera i totali generali (se mai non lo fossero)
_gen . azzera ( ) ;
// scansiona sui 3 tipi di cespite (materiale, immateriale, pluriennale)
for ( int i = 0 ; i < = 2 ; i + + )
{
const TTipo_cespite tipocespite = ( TTipo_cespite ) i ; // trasforma l'intero i in un tipo cespite
2008-03-11 16:59:33 +00:00
TString8 currcodcat = " @@ " ; //codice categoria iniziale (non si pu<70> metterlo nullo perch<63> potrebbe esistere)
2001-06-25 10:41:20 +00:00
TString80 currdescat = " " ;
_mtr . azzera ( ) ; // azzeratore tipi cespite (materiali, immateriali, pluriennali)
for ( sortcur = 0 ; sortcur . pos ( ) < num ; + + sortcur ) //scansione su tutti i cespiti della categoria indicata in precedenza
{
const TCespite ces ( sortcur . curr ( ) ) ;
if ( ces . tipo ( ) = = tipocespite ) //considera solo i cespiti del tipo attualmente selezionato
{
2008-03-11 16:59:33 +00:00
const TString8 codcat = sortcur . curr ( ) . get ( ordinamento = = 0 ? CESPI_CODCAT : CESPI_CODIMP ) ;
2001-06-25 10:41:20 +00:00
if ( codcat ! = currcodcat ) //cambia categoria
{
if ( currcodcat ! = " @@ " )
stampa_totali_cat ( currcodcat , currdescat ) ; //serve per stampare l'ultima categoria (perch<63> ogni categoria viene stampata quando inizia la scansione della successiva)
_cat . azzera ( ) ;
currcodcat = codcat ;
if ( ordinamento = = 0 ) //se ordinato (ed aggregato) per categoria...
currdescat = ces . categoria ( ) . get ( " S0 " ) ;
else //se ordinato (ed aggregato) per impianto...
currdescat = cache ( ) . get ( " CIM " , currcodcat , " S0 " ) ;
}
2008-03-11 16:59:33 +00:00
aggiorna_totali ( sortcur , sit , tipocespite ) ;
2001-06-25 10:41:20 +00:00
}
} // fine scansione cespiti della categoria selezionata
if ( currcodcat ! = " @@ " )
stampa_totali_cat ( currcodcat , currdescat ) ;
stampa_totali_tipo ( tipocespite ) ;
} // fine scansione tipi cespite
stampa_totali_generali ( ) ;
// salta una pagina al termine della situazione stampata
printer ( ) . formfeed ( ) ;
} // fine scansione su situazione da stampare (civilistica,fiscale,gestionale)
2001-04-30 14:22:43 +00:00
printer ( ) . close ( ) ;
2001-06-25 10:41:20 +00:00
}
2001-04-30 14:22:43 +00:00
}
int ce3300 ( int argc , char * argv [ ] )
{
TStampa_prospetto a ;
2003-05-12 15:03:40 +00:00
a . run ( argc , argv , TR ( " Stampa prospetto cespiti " ) ) ;
2001-04-30 14:22:43 +00:00
return 0 ;
2004-03-16 20:40:21 +00:00
}