1998-04-30 15:59:34 +00:00
//
1995-07-31 09:49:11 +00:00
// Stampa registri IVA
1999-04-06 15:34:39 +00:00
// Usurpatore di Liberta'...
// Nemico ed Oscuro Messo di Malvagita'...
1999-07-16 14:59:11 +00:00
1995-07-31 09:49:11 +00:00
# include "cg4.h"
# include "cg4400.h"
# include "cg4400a.h"
# include "cg4400b.h"
1997-06-19 14:33:52 +00:00
# include "cglib01.h"
2006-12-13 16:22:33 +00:00
1999-04-16 12:02:04 +00:00
# include <defmask.h>
2012-10-26 09:12:52 +00:00
# include <execp.h>
# include <mailbox.h>
# include <progind.h>
2006-12-13 16:22:33 +00:00
# include <recarray.h>
2012-11-30 14:36:30 +00:00
# include <recset.h>
2012-10-26 09:12:52 +00:00
# include <sheet.h>
# include <utility.h>
1999-04-16 12:02:04 +00:00
2012-10-26 09:12:52 +00:00
# include <anagr.h>
2006-12-13 16:22:33 +00:00
# include <attiv.h>
2012-10-26 09:12:52 +00:00
# include <causali.h>
1999-04-16 12:02:04 +00:00
# include <clifo.h>
2012-10-26 09:12:52 +00:00
# include <comuni.h>
# include <mov.h>
1999-04-16 12:02:04 +00:00
# include <nditte.h>
# include <occas.h>
# include <rmoviva.h>
2012-10-26 09:12:52 +00:00
# include <unloc.h>
1995-07-31 09:49:11 +00:00
1999-04-06 15:34:39 +00:00
static enum tipo_sospensione { nessuna , normale , vol_affari , liquidazione } ;
1998-02-24 10:31:42 +00:00
1998-04-30 15:59:34 +00:00
inline TStampa_registri_app & app ( ) { return ( TStampa_registri_app & ) main_app ( ) ; }
1995-07-31 09:49:11 +00:00
2008-12-03 14:53:51 +00:00
// Righe da saltare nel footer per evitare di scrivere sulla perforazione
# define RIGHE_FOOTER 3
1996-12-12 12:31:36 +00:00
1998-04-30 15:59:34 +00:00
bool TStampa_registri_app : : filter_func ( const TRelation * r )
1995-07-31 09:49:11 +00:00
{
2000-10-03 13:45:12 +00:00
const TRectype & mov = r - > curr ( LF_MOV ) ;
2006-01-09 01:15:53 +00:00
const int annoiva = mov . get_int ( MOV_ANNOIVA ) ;
2008-12-03 14:53:51 +00:00
const TString & codreg = mov . get ( MOV_REG ) ;
1995-07-31 09:49:11 +00:00
if ( codreg ! = ( app ( ) . _codreg ) | | annoiva ! = ( app ( ) . _annoes ) )
2012-10-26 09:12:52 +00:00
return false ;
1995-07-31 09:49:11 +00:00
1998-04-30 15:59:34 +00:00
if ( app ( ) . _tipo_stampa ! = prova ) //stampa di bollato
1999-04-06 15:34:39 +00:00
{
2006-01-09 01:15:53 +00:00
const bool regst = mov . get_bool ( MOV_REGST ) ;
if ( regst ) //il movimento e' gia'
2012-10-26 09:12:52 +00:00
return false ; //stato stampato in forma definitiva
1999-04-06 15:34:39 +00:00
const tipo_sospensione ts = ( tipo_sospensione ) r - > lfile ( " REG " ) . get_int ( " I9 " ) ;
if ( ts = = liquidazione ) // Movimento valido solo ai fini della liquidazione
2012-10-26 09:12:52 +00:00
return false ;
1999-04-06 15:34:39 +00:00
}
2012-10-26 09:12:52 +00:00
const TDate datareg = mov . get ( MOV_DATAREG ) ;
1995-07-31 09:49:11 +00:00
if ( datareg . month ( ) < app ( ) . _stampa_mese )
app ( ) . _stampa_mese = datareg . month ( ) ;
2012-10-26 09:12:52 +00:00
return true ;
1995-07-31 09:49:11 +00:00
}
HIDDEN int compare_rows ( const TObject * * o1 , const TObject * * o2 )
{
2006-12-13 16:22:33 +00:00
const TRiga & r1 = * ( const TRiga * ) * o1 ;
const TRiga & r2 = * ( const TRiga * ) * o2 ;
1995-07-31 09:49:11 +00:00
2006-12-13 16:22:33 +00:00
//return (strcmp((const char*)r1->_codiva, (const char*)r2->_codiva));
return r1 . _codiva . compare ( r2 . _codiva ) ;
1995-07-31 09:49:11 +00:00
}
2006-12-13 16:22:33 +00:00
HIDDEN int compare_righeiva ( const TObject * * o1 , const TObject * * o2 )
1995-07-31 09:49:11 +00:00
{
2006-12-13 16:22:33 +00:00
const TRigaiva & r1 = * ( const TRigaiva * ) * o1 ;
const TRigaiva & r2 = * ( const TRigaiva * ) * o2 ;
2008-12-03 14:53:51 +00:00
int diff = r1 . _tipodet - r2 . _tipodet ; // Confronto il tipo indetraibilita'
2006-12-13 16:22:33 +00:00
if ( diff = = 0 ) // Se ho un uguale indetraibilita' ...
diff = r1 . _codiva . compare ( r2 . _codiva ) ; // ... confronto il codice IVA
return diff ;
1995-07-31 09:49:11 +00:00
}
1996-02-06 16:02:59 +00:00
//********* funzioni accessorie e di ricerca *********//
1998-04-30 15:59:34 +00:00
bool TStampa_registri_app : : stampa_totali_finali ( )
1995-07-31 09:49:11 +00:00
{
2012-10-26 09:12:52 +00:00
//TConfig conf(CONFIG_DITTA);
//return conf.get_bool("StTfFr");
return ini_get_bool ( CONFIG_DITTA , " cg " , " StTfFr " ) ;
1995-07-31 09:49:11 +00:00
}
1998-04-30 15:59:34 +00:00
bool TStampa_registri_app : : stampa_datareg ( )
1995-07-31 09:49:11 +00:00
{
2012-10-26 09:12:52 +00:00
//TConfig conf(CONFIG_STUDIO);
//return conf.get_bool("NoDtRg");
return ini_get_bool ( CONFIG_STUDIO , " cg " , " NoDtRg " ) ;
1995-07-31 09:49:11 +00:00
}
1998-04-30 15:59:34 +00:00
const char * TStampa_registri_app : : descr_doc ( )
2012-10-26 09:12:52 +00:00
{ return cache ( ) . get ( " %TPD " , _tipodoc , " S0 " ) ; }
1996-02-06 16:02:59 +00:00
1998-04-30 15:59:34 +00:00
const char * TStampa_registri_app : : descr_iva ( const char * cod )
2012-10-26 09:12:52 +00:00
{ return cache ( ) . get ( " %IVA " , cod , " S0 " ) ; }
1996-02-06 16:02:59 +00:00
1998-04-30 15:59:34 +00:00
const char * TStampa_registri_app : : tipo_attivita ( )
1995-07-31 09:49:11 +00:00
{
2003-03-25 13:56:11 +00:00
TString16 key ;
key . format ( " %ld|%s " , get_firm ( ) , ( const char * ) _codatt ) ;
2006-12-13 16:22:33 +00:00
return cache ( ) . get ( LF_ATTIV , key , ATT_TIPOATT ) ;
1996-02-06 16:02:59 +00:00
}
1995-07-31 09:49:11 +00:00
1998-04-30 15:59:34 +00:00
const char * TStampa_registri_app : : desc_attivita ( const TString & cod )
1996-02-06 16:02:59 +00:00
{
2003-03-25 13:56:11 +00:00
TString16 key ;
key . format ( " %ld|%s " , get_firm ( ) , ( const char * ) cod ) ;
2006-12-13 16:22:33 +00:00
return cache ( ) . get ( LF_ATTIV , key , ATT_DESCR ) ;
1995-07-31 09:49:11 +00:00
}
2000-10-03 13:45:12 +00:00
const TRectype & TStampa_registri_app : : ricerca_cf ( char tipocf , long codcf )
1995-07-31 09:49:11 +00:00
{
2003-03-25 13:56:11 +00:00
TString16 key ;
key . format ( " %c|%ld " , tipocf , codcf ) ;
return cache ( ) . get ( LF_CLIFO , key ) ;
1995-07-31 09:49:11 +00:00
}
2000-10-03 13:45:12 +00:00
const TRectype & TStampa_registri_app : : ricerca_occ ( const char * occ )
2012-10-26 09:12:52 +00:00
{ return cache ( ) . get ( LF_OCCAS , occ ) ; }
1995-07-31 09:49:11 +00:00
2000-10-03 13:45:12 +00:00
const TRectype & TStampa_registri_app : : look_comuni ( const TString & stato , const TString & cod )
1997-10-22 12:24:43 +00:00
{
2006-12-13 16:22:33 +00:00
TString8 key ;
2000-10-03 13:45:12 +00:00
key < < stato < < ' | ' < < cod ;
return cache ( ) . get ( LF_COMUNI , key ) ;
1997-10-22 12:24:43 +00:00
}
2000-10-03 13:45:12 +00:00
const TRectype & TStampa_registri_app : : look_comuni ( const char * cod )
{
2012-10-26 09:12:52 +00:00
return look_comuni ( EMPTY_STRING , cod ) ;
1995-07-31 09:49:11 +00:00
}
1998-04-30 15:59:34 +00:00
void TStampa_registri_app : : get_dati_ditta ( )
1995-07-31 09:49:11 +00:00
{
2002-12-20 16:15:03 +00:00
const TRectype & nditte = cache ( ) . get ( LF_NDITTE , get_firm ( ) ) ;
1996-02-06 16:02:59 +00:00
_ragsoc = nditte . get ( NDT_RAGSOC ) ;
2002-12-20 16:15:03 +00:00
const char tipoa = nditte . get_char ( NDT_TIPOA ) ;
const long codanagr = nditte . get_long ( NDT_CODANAGR ) ;
const TRectype & anag = cache ( ) . get ( LF_ANAG , format ( " %c|%ld " , tipoa , codanagr ) ) ;
1995-07-31 09:49:11 +00:00
1996-02-06 16:02:59 +00:00
_cofi = anag . get ( ANA_COFI ) ;
_paiva = anag . get ( ANA_PAIV ) ;
_comunefis = anag . get ( ANA_COMRF ) ;
2000-10-03 13:45:12 +00:00
_cap = anag . get ( ANA_CAPRF ) ;
1995-07-31 09:49:11 +00:00
1996-02-06 16:02:59 +00:00
if ( _comunefis . empty ( ) )
_comunefis = anag . get ( ANA_COMRES ) ;
2000-10-03 13:45:12 +00:00
if ( _cap . empty ( ) )
_cap = anag . get ( ANA_CAPRES ) ;
1995-07-31 09:49:11 +00:00
2000-10-03 13:45:12 +00:00
const TRectype & dep = look_comuni ( _comunefis ) ;
1996-02-06 16:02:59 +00:00
_comunefis = dep . get ( COM_DENCOM ) ;
_provfis = dep . get ( COM_PROVCOM ) ;
if ( _comunefis . empty ( ) )
{
_viafis = anag . get ( ANA_INDRF ) ;
_viafis . rtrim ( ) ;
_viafis < < " " < < anag . get ( ANA_CIVRF ) ;
}
else
{
_viafis = anag . get ( ANA_INDRES ) ;
_viafis . rtrim ( ) ;
2000-10-03 13:45:12 +00:00
_viafis < < ' ' < < anag . get ( ANA_CIVRES ) ;
1996-02-06 16:02:59 +00:00
}
1995-07-31 09:49:11 +00:00
1996-02-06 16:02:59 +00:00
if ( _cod_un_loc )
{
2002-12-20 16:15:03 +00:00
const TRectype & unloc = cache ( ) . get ( LF_UNLOC , format ( " %ld|%d " , get_firm ( ) , _cod_un_loc ) ) ;
if ( ! unloc . empty ( ) )
1996-02-06 16:02:59 +00:00
{
2001-05-01 08:17:07 +00:00
const TRectype & dep = look_comuni ( unloc . get ( ULC_COMULC ) ) ;
1996-02-06 16:02:59 +00:00
_comunefis = dep . get ( COM_DENCOM ) ;
_provfis = dep . get ( COM_PROVCOM ) ;
2000-10-03 13:45:12 +00:00
_cap = unloc . get ( ULC_CAPULC ) ;
1996-02-06 16:02:59 +00:00
_viafis = unloc . get ( ULC_INDULC ) ;
_viafis . rtrim ( ) ;
2000-10-03 13:45:12 +00:00
_viafis < < ' ' < < unloc . get ( ULC_CIVULC ) ;
1996-02-06 16:02:59 +00:00
}
}
1995-07-31 09:49:11 +00:00
}
2006-12-13 16:22:33 +00:00
const TRectype & TStampa_registri_app : : look_lia ( long ditta )
1995-07-31 09:49:11 +00:00
{
2012-11-30 14:36:30 +00:00
if ( ditta < = 0 )
ditta = get_firm ( ) ;
1996-02-06 16:02:59 +00:00
2006-12-13 16:22:33 +00:00
TString16 y ; y . format ( " %05ld%04d " , ditta , _annoes ) ;
const TRectype & lia = cache ( ) . get ( " %LIA " , y ) ;
2003-03-25 13:56:11 +00:00
_credito = lia . get_real ( " R0 " ) ;
return lia ;
1996-02-06 16:02:59 +00:00
}
1995-07-31 09:49:11 +00:00
1996-02-06 16:02:59 +00:00
//guarda tutti i mesi a partire da gennaio e controlla
//se ce ne' almeno uno per cui e' necessario rilanciare
//il calcolo (il flag B1 e' invalidato dalla prima nota).
//In tal caso si richiamera' il prg di liquidazione con
//'C' e sara' tale prg che si preoccupera' di ricalcolare
//tutti i mesi a partire dall'inizio dell'anno (e a settare
//B1 nelle lim di tutti i mesi calcolati)
1998-04-30 15:59:34 +00:00
bool TStampa_registri_app : : ricalcola ( int mese )
1996-02-06 16:02:59 +00:00
{
TTable lim ( " LIM " ) ;
//controllo i periodi precedenti al mese passato
for ( int m = 1 ; m < mese ; m + + )
{
//L'if seguente e' necessario perche' se la ditta ha
//_frequiva == 'T' => esiste la lim solo se m == 3/6/9/12
//(no problem: la Prima Nota pensa lei a invalidare B0 e B1
//dei trimestri a cui appartiene il mese modificato)
if ( _frequiva = = ' M ' | |
( m = = 3 | | m = = 6 | | m = = 9 | | m = = 12 ) )
{
2006-12-13 16:22:33 +00:00
TString8 key ; key . format ( " %04d%02d " , _annoes , m ) ;
1996-02-06 16:02:59 +00:00
lim . setkey ( 1 ) ;
lim . put ( " CODTAB " , key ) ;
if ( lim . read ( ) ! = NOERR | | ! lim . get_bool ( " B1 " ) )
2012-10-26 09:12:52 +00:00
return true ;
1996-02-06 16:02:59 +00:00
}
}
//controllo il mese passato
if ( _frequiva = = ' M ' )
{
2006-12-13 16:22:33 +00:00
TString8 key ; key . format ( " %04d%02d " , _annoes , mese ) ;
1996-02-06 16:02:59 +00:00
lim . setkey ( 1 ) ;
lim . put ( " CODTAB " , key ) ;
if ( lim . read ( ) ! = NOERR | | ! lim . get_bool ( " B1 " ) )
2012-10-26 09:12:52 +00:00
return true ;
1996-02-06 16:02:59 +00:00
}
1995-07-31 09:49:11 +00:00
else
1996-02-06 16:02:59 +00:00
{
//aggiusta il mese al trimestre a cui appartiene
mese + = 2 - ( ( mese - 1 ) % 3 ) ;
2006-12-13 16:22:33 +00:00
TString8 key ; key . format ( " %04d%02d " , _annoes , mese ) ;
1996-02-06 16:02:59 +00:00
lim . setkey ( 1 ) ;
lim . put ( " CODTAB " , key ) ;
if ( lim . read ( ) ! = NOERR | | ! lim . get_bool ( " B1 " ) )
2012-10-26 09:12:52 +00:00
return true ;
1996-02-06 16:02:59 +00:00
}
2012-10-26 09:12:52 +00:00
return false ;
1995-07-31 09:49:11 +00:00
}
1998-04-30 15:59:34 +00:00
void TStampa_registri_app : : look_reg ( )
1995-07-31 09:49:11 +00:00
{
1996-02-06 16:02:59 +00:00
_liquidazione = _tabreg - > get_bool ( " B7 " ) ;
_riep_liq = _tabreg - > get_bool ( " B6 " ) ;
_corrispettivi = _tabreg - > get_bool ( " B0 " ) ;
_sosp_imposta = _tabreg - > get_bool ( " B1 " ) ;
_pagine_stampate = _tabreg - > get_long ( " I1 " ) ;
_numini = _pagine_stampate ;
_cod_un_loc = _tabreg - > get_int ( " I7 " ) ;
_mese_ultima_liq = _tabreg - > get_int ( " I4 " ) ;
_mese_credito = _tabreg - > get_int ( " I8 " ) ;
_codatt = _tabreg - > get ( " S8 " ) ;
_tipoatt = tipo_attivita ( ) ;
_attivita = desc_attivita ( _codatt ) ;
_desc_lib = _tabreg - > get ( " S0 " ) ;
_stampa_ind_ditta = _tabreg - > get_bool ( " B9 " ) ;
_stampa_ind_comp = _tabreg - > get_bool ( " B5 " ) ;
_stampa_cred_pre = _tabreg - > get_bool ( " B4 " ) ;
_freq_riepilogo = _tabreg - > get_char ( " S9 " ) ;
1999-04-06 15:34:39 +00:00
_stampa_plafonds = _tabreg - > get_char ( " S10 " ) = = ' X ' ;
2002-12-20 16:15:03 +00:00
_stampa_num_pag = _tabreg - > get_char ( " S11 " ) = = ' X ' ;
1995-07-31 09:49:11 +00:00
}
1998-04-30 15:59:34 +00:00
bool TStampa_registri_app : : compila_reg ( const TMask & m )
1996-02-06 16:02:59 +00:00
{
2006-12-13 16:22:33 +00:00
TString8 cod_lib_un ;
1996-02-06 16:02:59 +00:00
TDate sca_vid ;
1995-07-31 09:49:11 +00:00
1998-04-30 15:59:34 +00:00
_tipo_stampa = ( tipo_stampa ) m . get_int ( TIPO_STAMPA ) ;
if ( _tipo_stampa = = libro_unico ) //stampa su libro unico di studio
1996-02-06 16:02:59 +00:00
_codreg = m . get ( CODICE_LIBRO_IVA ) ;
1998-04-30 15:59:34 +00:00
else if ( _tipo_stampa = = prova ) //stampa di prova
1996-02-06 16:02:59 +00:00
_codreg = m . get ( CODICE_LIBRO_PROVA ) ;
else _codreg = m . get ( CODICE_LIBRO ) ;
if ( _codreg . trim ( ) . empty ( ) )
{
2012-10-26 09:12:52 +00:00
_stampa_tutti_i_registri = true ;
1996-02-06 16:02:59 +00:00
_tabreg - > first ( ) ;
if ( ! _tabreg - > eof ( ) )
{
2006-12-13 16:22:33 +00:00
const TString16 codtab = _tabreg - > get ( " CODTAB " ) ;
2007-01-03 17:07:40 +00:00
const int anno = atoi ( codtab . mid ( 0 , 4 ) ) ;
1996-02-06 16:02:59 +00:00
if ( anno > _annoes )
{
1998-04-30 15:59:34 +00:00
if ( _tipo_stampa ! = libro_unico ) //per il libro unico e' gia' stato controllato nell'handler
2003-03-25 13:56:11 +00:00
warning_box ( FR ( " Non esistono registri IVA della Ditta %ld per l'anno %d " ) ,
1996-02-06 16:02:59 +00:00
_ditta , _annoes ) ;
2012-10-26 09:12:52 +00:00
return false ;
1996-02-06 16:02:59 +00:00
}
}
}
else // stampa un solo registro
{
2012-10-26 09:12:52 +00:00
_stampa_tutti_i_registri = false ;
2006-12-13 16:22:33 +00:00
TString16 codtab ; codtab < < _annoes < < _codreg ;
1996-02-06 16:02:59 +00:00
_tabreg - > zero ( ) ;
_tabreg - > put ( " CODTAB " , codtab ) ;
if ( _tabreg - > read ( ) ! = NOERR )
{
1998-04-30 15:59:34 +00:00
if ( _tipo_stampa ! = libro_unico )
2012-11-30 14:36:30 +00:00
warning_box ( FR ( " Il registro IVA %s della ditta %ld non esiste " ) , ( const char * ) _codreg , _ditta ) ;
2012-10-26 09:12:52 +00:00
return false ;
1996-02-06 16:02:59 +00:00
}
else
{
1998-04-30 15:59:34 +00:00
_tipo_reg = ( tiporeg ) _tabreg - > get_int ( " I0 " ) ;
if ( _tipo_reg = = vendita | | _tipo_reg = = acquisto | | _tipo_reg = = riepilogativo )
1996-02-06 16:02:59 +00:00
{
cod_lib_un = _tabreg - > get ( " S6 " ) ;
sca_vid = _tabreg - > get_date ( " D1 " ) ;
1998-04-30 15:59:34 +00:00
if ( _tipo_stampa ! = prova )
1996-02-06 16:02:59 +00:00
_u_data = _tabreg - > get_date ( " D3 " ) ;
1998-04-30 15:59:34 +00:00
if ( _tipo_stampa = = bollato | | _tipo_stampa = = rif_giornale )
1996-02-06 16:02:59 +00:00
{
if ( cod_lib_un . not_empty ( ) )
{
2003-03-25 13:56:11 +00:00
warning_box ( FR ( " Ditta %ld: sul registro non deve essere indicato il codice del libro unico " ) , _ditta ) ;
2012-10-26 09:12:52 +00:00
return false ;
1996-02-06 16:02:59 +00:00
}
if ( sca_vid . ok ( ) )
if ( sca_vid . month ( ) < _fino_a_mese )
{
2003-03-25 13:56:11 +00:00
warning_box ( FR ( " Ditta %ld: il mese della data scadenza vidimazione riportata sul registro non deve essere inferiore al mese indicato " ) , _ditta ) ;
2012-10-26 09:12:52 +00:00
return false ;
1996-02-06 16:02:59 +00:00
}
if ( _u_data . ok ( ) )
if ( _data_a < _u_data )
{
2003-03-25 13:56:11 +00:00
return warning_box ( FR ( " Ditta %ld: la data specificata non deve essere inferiore al %s (ultima data di stampa specificata sul registro) " ), _ditta, (const char*)_u_data.string()) ;
1996-02-06 16:02:59 +00:00
}
1998-04-30 15:59:34 +00:00
if ( _tipo_stampa = = rif_giornale ) //stampa con riferimenti al libro giornale
1996-02-06 16:02:59 +00:00
{
2000-10-03 13:45:12 +00:00
TDate datas ;
1996-02-06 16:02:59 +00:00
bool good ;
2000-10-03 13:45:12 +00:00
bool found = cerca_libro_gio ( datas , good ) ;
if ( ! found | | ! good )
1996-02-06 16:02:59 +00:00
{
2003-03-25 13:56:11 +00:00
warning_box ( FR ( " Ditta %ld: la data indicata non deve essere superiore al %s (ultima data di stampa del libro giornale) " ) , _ditta , ( const char * ) datas . string ( ) ) ;
2012-10-26 09:12:52 +00:00
return false ;
1996-02-06 16:02:59 +00:00
}
}
}
_pagine_stampate = _tabreg - > get_long ( " I1 " ) ;
_numini = _pagine_stampate ;
_corrispettivi = _tabreg - > get_bool ( " B0 " ) ;
_sosp_imposta = _tabreg - > get_bool ( " B1 " ) ;
_liquidazione = _tabreg - > get_bool ( " B7 " ) ;
_riep_liq = _tabreg - > get_bool ( " B6 " ) ;
_stampa_cred_pre = _tabreg - > get_bool ( " B4 " ) ;
_stampa_ind_ditta = _tabreg - > get_bool ( " B9 " ) ;
_stampa_ind_comp = _tabreg - > get_bool ( " B5 " ) ;
1999-04-06 15:34:39 +00:00
_stampa_plafonds = _tabreg - > get_char ( " S10 " ) = = ' X ' ;
2002-12-20 16:15:03 +00:00
_stampa_num_pag = _tabreg - > get_char ( " S11 " ) = = ' X ' ;
1996-02-06 16:02:59 +00:00
_cod_un_loc = _tabreg - > get_int ( " I7 " ) ;
_mese_credito = _tabreg - > get_int ( " I8 " ) ; //campo nascosto sulla tabella dei registri: mese di stampa credito anno precedente
_mese_ultima_liq = _tabreg - > get_int ( " I4 " ) ;
_codatt = _tabreg - > get ( " S8 " ) ;
_tipoatt = tipo_attivita ( ) ;
_attivita = desc_attivita ( _codatt ) ;
_desc_lib = _tabreg - > get ( " S0 " ) ;
_freq_riepilogo = _tabreg - > get_char ( " S9 " ) ;
}
2012-10-26 09:12:52 +00:00
else return false ;
1996-02-06 16:02:59 +00:00
}
1995-07-31 09:49:11 +00:00
}
2012-10-26 09:12:52 +00:00
return true ;
1996-02-06 16:02:59 +00:00
}
1995-07-31 09:49:11 +00:00
1998-04-30 15:59:34 +00:00
bool TStampa_registri_app : : compila_lib ( )
1996-02-06 16:02:59 +00:00
{
2012-10-26 09:12:52 +00:00
TString8 cod ; cod < < _annoes < < _codlib ;
2006-12-13 16:22:33 +00:00
const TRectype & lib = cache ( ) . get ( " %LBU " , cod ) ;
2003-03-25 13:56:11 +00:00
_stampa_ind_ditta = lib . get_bool ( " B1 " ) ;
return ! lib . empty ( ) ;
1995-07-31 09:49:11 +00:00
}
2000-10-03 13:45:12 +00:00
bool TStampa_registri_app : : cerca_libro_gio ( TDate & datas , bool & good )
{
TRelation reg ( " REG " ) ;
TRectype & curr = reg . curr ( ) ;
TString16 filter ;
filter . format ( " %04d " , _annoes ) ;
curr . put ( " CODTAB " , filter ) ;
filter . format ( " I0=%d " , giornale ) ;
TCursor cur ( & reg , filter , 1 , & curr , & curr ) ;
const bool found = cur . items ( ) > 0 ;
2012-10-26 09:12:52 +00:00
good = false ;
2000-10-03 13:45:12 +00:00
if ( found )
{
cur = 0L ;
datas = curr . get_date ( " D3 " ) ; // Data ultima stampa
good = datas . month ( ) > = _data_a . month ( ) ; // CM000027
}
return found ;
1995-07-31 09:49:11 +00:00
}
1998-04-30 15:59:34 +00:00
bool TStampa_registri_app : : is_mese_ok ( int x , int month )
1996-02-06 16:02:59 +00:00
{
bool ret = x = = month ;
if ( ! ret & & _freq_riepilogo = = ' T ' )
{
month + = 2 - ( ( month - 1 ) % 3 ) ;
ret = x > ( month - 3 ) & & x < = month ;
1995-07-31 09:49:11 +00:00
}
1996-02-06 16:02:59 +00:00
return ret ;
1995-07-31 09:49:11 +00:00
}
1996-02-06 16:02:59 +00:00
//********* handlers *********/
1998-04-30 15:59:34 +00:00
bool TStampa_registri_app : : mask_azzera ( TMask_field & f , KEY k )
1995-07-31 09:49:11 +00:00
{
1996-02-06 16:02:59 +00:00
if ( k = = K_SPACE )
1995-07-31 09:49:11 +00:00
{
1996-02-06 16:02:59 +00:00
app ( ) . _selected . reset ( ) ;
f . mask ( ) . reset ( F_SELECT ) ;
f . mask ( ) . reset ( DA_CODICE ) ;
f . mask ( ) . reset ( A_CODICE ) ;
2012-10-26 09:12:52 +00:00
app ( ) . _ditte - > check ( - 1 , false ) ;
1995-07-31 09:49:11 +00:00
}
2012-10-26 09:12:52 +00:00
return true ;
1995-07-31 09:49:11 +00:00
}
1998-04-30 15:59:34 +00:00
bool TStampa_registri_app : : mask_tipo_stampa ( TMask_field & f , KEY k )
1996-02-06 16:02:59 +00:00
{
if ( k = = K_SPACE )
1995-07-31 09:49:11 +00:00
{
2000-10-03 13:45:12 +00:00
TMask & m = f . mask ( ) ;
2012-10-26 09:12:52 +00:00
const int tipo_stampa = m . get_int ( TIPO_STAMPA ) ;
1996-02-06 16:02:59 +00:00
if ( tipo_stampa = = 3 ) //stampa su libro unico
1995-07-31 09:49:11 +00:00
{
1996-02-06 16:02:59 +00:00
m . enable_page ( 1 ) ;
2012-10-26 09:12:52 +00:00
TMask_field & cc = m . field ( CODICE_LIB_UN ) ;
1996-02-06 16:02:59 +00:00
cc . set_dirty ( ) ;
}
else
m . disable_page ( 1 ) ;
}
2012-10-26 09:12:52 +00:00
return true ;
1996-02-06 16:02:59 +00:00
}
1995-07-31 09:49:11 +00:00
1998-04-30 15:59:34 +00:00
bool TStampa_registri_app : : mask_mese ( TMask_field & f , KEY k )
1996-02-06 16:02:59 +00:00
{
2012-10-26 09:12:52 +00:00
TMask & m = f . mask ( ) ;
1996-02-06 16:02:59 +00:00
if ( k = = K_SPACE )
1995-07-31 09:49:11 +00:00
{
1996-02-06 16:02:59 +00:00
const short id = f . dlg ( ) ;
int mese ;
if ( id = = MESE ) //Per stampa su libro unico
mese = f . mask ( ) . get_int ( MESE ) ;
if ( id = = FINO_A_MESE )
2012-10-26 09:12:52 +00:00
mese = m . get_int ( FINO_A_MESE ) ; //Per stampa su bollato
1996-02-06 16:02:59 +00:00
if ( id = = MESE )
1995-07-31 09:49:11 +00:00
{
1996-02-06 16:02:59 +00:00
if ( mese = = 12 )
{
2012-10-26 09:12:52 +00:00
m . show ( TIPO_RIEPILOGATIVO ) ;
m . show ( RIF_VID ) ;
1996-02-06 16:02:59 +00:00
}
else
{
2012-10-26 09:12:52 +00:00
m . hide ( TIPO_RIEPILOGATIVO ) ;
m . hide ( RIF_VID ) ;
1996-02-06 16:02:59 +00:00
}
}
if ( id = = FINO_A_MESE )
1995-07-31 09:49:11 +00:00
{
1996-02-06 16:02:59 +00:00
if ( mese = = 12 )
2012-10-26 09:12:52 +00:00
m . show ( TIPO_RIEPILOGATIVO ) ;
else m . hide ( TIPO_RIEPILOGATIVO ) ;
1995-07-31 09:49:11 +00:00
}
}
1996-02-06 16:02:59 +00:00
if ( k = = K_TAB & & f . mask ( ) . is_running ( ) )
{
const short id = f . dlg ( ) ;
if ( id = = MESE )
2012-10-26 09:12:52 +00:00
m . send_key ( K_TAB , CODICE_LIBRO_IVA ) ;
1996-02-06 16:02:59 +00:00
}
2012-10-26 09:12:52 +00:00
return true ;
1995-07-31 09:49:11 +00:00
}
1998-04-30 15:59:34 +00:00
bool TStampa_registri_app : : look_reg ( int i , int anno , TString & codlib , int m , const char * cod , int * umese , long ditta )
1995-07-31 09:49:11 +00:00
{
2012-10-26 09:12:52 +00:00
TString8 y ;
1995-07-31 09:49:11 +00:00
1996-02-06 16:02:59 +00:00
y < < anno < < cod ;
_tabreg - > zero ( ) ;
_tabreg - > put ( " CODTAB " , y ) ;
1995-07-31 09:49:11 +00:00
1996-02-06 16:02:59 +00:00
if ( _tabreg - > read ( ) = = NOERR )
1995-07-31 09:49:11 +00:00
{
1998-04-30 15:59:34 +00:00
tiporeg tipo = ( tiporeg ) _tabreg - > get_int ( " I0 " ) ;
if ( tipo = = vendita | | tipo = = acquisto | | tipo = = riepilogativo )
1995-07-31 09:49:11 +00:00
{
1996-02-06 16:02:59 +00:00
TString16 cod_lib_un = _tabreg - > get ( " S6 " ) ;
TDate u_data = _tabreg - > get_date ( " D3 " ) ;
TDate sca_vid = _tabreg - > get_date ( " D1 " ) ;
if ( codlib ! = cod_lib_un )
1995-07-31 09:49:11 +00:00
{
1996-02-06 16:02:59 +00:00
if ( _selected . ones ( ) = = 1L )
if ( _selected [ i ] )
2003-03-25 13:56:11 +00:00
message_box ( FR ( " Ditta %ld: il codice libro unico del registro non e' uguale al codice libro unico indicato " ) , ditta ) ;
2012-10-26 09:12:52 +00:00
return false ;
1995-07-31 09:49:11 +00:00
}
1996-02-06 16:02:59 +00:00
if ( m < * umese )
{
if ( _selected . ones ( ) = = 1L )
if ( _selected [ i ] )
2003-03-25 13:56:11 +00:00
message_box ( FR ( " Ditta %ld: il mese indicato e' inferiore al mese dell'ultima data di stampa del registro " ) , ditta ) ;
2012-10-26 09:12:52 +00:00
return false ;
1996-02-06 16:02:59 +00:00
}
if ( u_data . ok ( ) )
* umese = u_data . month ( ) ;
else * umese = 0 ;
if ( sca_vid . ok ( ) )
if ( sca_vid . month ( ) < m )
{
if ( _selected . ones ( ) = = 1L )
if ( _selected [ i ] )
2003-03-25 13:56:11 +00:00
message_box ( FR ( " Ditta %ld: la data scadenza di vidimazione del registro non deve essere inferiore al mese indicato " ) , ditta ) ;
2012-10-26 09:12:52 +00:00
return false ;
1996-02-06 16:02:59 +00:00
}
}
2012-10-26 09:12:52 +00:00
return true ;
1995-07-31 09:49:11 +00:00
}
2012-10-26 09:12:52 +00:00
return false ;
1996-02-06 16:02:59 +00:00
}
1998-04-30 15:59:34 +00:00
bool TStampa_registri_app : : look_regs ( int anno , TString & codlib , int m , int * umese , long ditta , TProgind * prog )
{
2012-10-26 09:12:52 +00:00
bool ok = false ;
1996-02-06 16:02:59 +00:00
* umese = 13 ;
1995-07-31 09:49:11 +00:00
2012-10-26 09:12:52 +00:00
_tabreg - > zero ( ) ;
_tabreg - > put ( " CODATB " , anno ) ;
for ( int err = _tabreg - > read ( _isgteq ) ; err = = NOERR ; err = _tabreg - > next ( ) )
1996-02-06 16:02:59 +00:00
{
2012-10-26 09:12:52 +00:00
const tiporeg tipo = ( tiporeg ) _tabreg - > get_int ( " I0 " ) ;
const TString16 codtab = _tabreg - > get ( " CODTAB " ) ;
const int a = atoi ( codtab . left ( 4 ) ) ;
if ( a < anno )
continue ; // Should never happen!
1996-02-06 16:02:59 +00:00
if ( a > anno )
break ;
2012-10-26 09:12:52 +00:00
if ( tipo = = vendita | | tipo = = acquisto | | tipo = = riepilogativo ) //registro iva
{
TString16 cod_lib_un = _tabreg - > get ( " S6 " ) ;
TDate sca_vid = _tabreg - > get_date ( " D1 " ) ;
TDate u_data = _tabreg - > get_date ( " D3 " ) ;
if ( codlib ! = cod_lib_un )
continue ;
if ( u_data . ok ( ) )
if ( m < u_data . month ( ) )
1996-02-06 16:02:59 +00:00
continue ;
2012-10-26 09:12:52 +00:00
if ( u_data . ok ( ) )
* umese = ( * umese < u_data . month ( ) ) ? * umese : u_data . month ( ) ;
if ( sca_vid . ok ( ) )
if ( sca_vid . month ( ) < m )
continue ;
int month ;
if ( ! u_data . ok ( ) )
month = 0 ;
else month = u_data . month ( ) ;
if ( month < m - 1 )
{
prog - > addstatus ( 1 ) ;
app ( ) . set_firm ( __firm ) ;
delete prog ;
error_box ( FR ( " Ditta %ld: Stampare i registri dei mesi precedenti " ) , ditta ) ;
app ( ) . stop_run ( ) ;
}
ok = true ;
}
1996-02-06 16:02:59 +00:00
}
return ok ;
}
//funzione di controllo parametri prima di stampare su libro unico
//una fra le cose piu' orrende che mi potessero capitare
1998-04-30 15:59:34 +00:00
bool TStampa_registri_app : : mask_libun ( TMask_field & f , KEY k )
1996-02-06 16:02:59 +00:00
{
if ( k = = K_TAB & & f . mask ( ) . is_running ( ) )
1995-07-31 09:49:11 +00:00
{
1996-02-06 16:02:59 +00:00
TString16 codlib ( f . mask ( ) . get ( CODICE_LIB_UN ) ) ;
if ( codlib . empty ( ) )
1995-07-31 09:49:11 +00:00
{
2012-10-26 09:12:52 +00:00
app ( ) . _test = true ;
return true ;
1996-02-06 16:02:59 +00:00
}
1998-04-30 15:59:34 +00:00
if ( app ( ) . _selected . ones ( ) = = 0l )
2012-10-26 09:12:52 +00:00
return true ;
1996-02-06 16:02:59 +00:00
2012-10-26 09:12:52 +00:00
TProgind * p = new TProgind ( 2 , TR ( " Verifica parametri in corso... " ) , false , true , 30 ) ;
1996-02-06 16:02:59 +00:00
TString16 cod ( f . mask ( ) . get ( CODICE_LIBRO_IVA ) ) ;
int fino_a_mese = f . mask ( ) . get_int ( MESE ) ;
int anno = f . mask ( ) . get_int ( ANNO ) ;
2012-10-26 09:12:52 +00:00
bool ok = false ;
1996-02-06 16:02:59 +00:00
int last_mese = 13 ;
int mese = 0 ;
p - > addstatus ( 1 ) ;
app ( ) . __firm = app ( ) . get_firm ( ) ;
for ( int i = 0 ; i < app ( ) . _ditte - > items ( ) ; i + + )
{
long ditta = app ( ) . _ditte - > row ( i ) . get_long ( 1 ) ;
if ( prefix ( ) . exist ( ditta ) )
1995-07-31 09:49:11 +00:00
{
1996-02-06 16:02:59 +00:00
app ( ) . set_firm ( ditta ) ;
if ( cod . not_empty ( ) )
1995-07-31 09:49:11 +00:00
{
1996-02-06 16:02:59 +00:00
ok = app ( ) . look_reg ( i , anno , codlib , fino_a_mese , cod , & mese , ditta ) ;
if ( ! ok )
continue ;
if ( mese < fino_a_mese - 1 ) //indipendentemente se si tratta di una ditta selezionata oppure no
{
p - > addstatus ( 1 ) ;
app ( ) . set_firm ( app ( ) . __firm ) ;
delete p ;
2003-03-25 13:56:11 +00:00
f . error_box ( FR ( " Ditta %ld: Stampare i registri dei mesi precedenti " ) , ditta ) ;
1996-02-06 16:02:59 +00:00
app ( ) . stop_run ( ) ;
}
}
else
1995-07-31 09:49:11 +00:00
{
1996-02-06 16:02:59 +00:00
ok = app ( ) . look_regs ( anno , codlib , fino_a_mese , & mese , ditta , p ) ;
if ( ! ok )
{
if ( app ( ) . _selected . ones ( ) = = 1L ) //solo se ho selezionato 1 ditta devo dare il messaggio
if ( app ( ) . _selected [ i ] ) //ed e' proprio quella selezionata
{
p - > addstatus ( 1 ) ;
app ( ) . set_firm ( app ( ) . __firm ) ;
delete p ;
2003-03-25 13:56:11 +00:00
f . message_box ( FR ( " Ditta %ld: nessun registro soddisfa i parametri indicati " ) , ditta ) ;
1996-02-06 16:02:59 +00:00
app ( ) . stop_run ( ) ;
}
continue ;
}
1995-07-31 09:49:11 +00:00
}
1996-02-06 16:02:59 +00:00
last_mese = ( last_mese < mese ) ? last_mese : mese ;
}
}
p - > addstatus ( 1 ) ;
app ( ) . set_firm ( app ( ) . __firm ) ;
1995-07-31 09:49:11 +00:00
1996-02-06 16:02:59 +00:00
if ( last_mese = = 13 )
last_mese = 0 ; //l'ultima data di stampa sul/sui registri specificati e' vuota
//(cioe' non sono ancora stati stampati sul libro unico specificato)
1998-02-24 10:31:42 +00:00
TString16 me ;
me . format ( " %02d " , last_mese ) ;
1996-02-06 16:02:59 +00:00
f . mask ( ) . set ( ULTIMO_MESE , me ) ;
delete p ;
}
2012-10-26 09:12:52 +00:00
return true ;
1996-02-06 16:02:59 +00:00
}
1998-04-30 15:59:34 +00:00
bool TStampa_registri_app : : mask_cod ( TMask_field & f , KEY k )
1995-07-31 09:49:11 +00:00
{
1996-02-06 16:02:59 +00:00
if ( k = = K_TAB )
1995-07-31 09:49:11 +00:00
{
1996-02-06 16:02:59 +00:00
TTable TabLbu ( " %LBU " ) ;
TString codtab ;
int anno ;
1995-07-31 09:49:11 +00:00
1996-02-06 16:02:59 +00:00
TString16 codlib ( f . get ( ) ) ;
anno = f . mask ( ) . get_int ( ANNO ) ;
TabLbu . zero ( ) ;
codtab . format ( " %04d%-3s " , anno , ( const char * ) codlib ) ;
TabLbu . put ( " CODTAB " , codtab ) ;
TabLbu . read ( ) ;
if ( TabLbu . good ( ) )
1995-07-31 09:49:11 +00:00
{
1996-02-06 16:02:59 +00:00
f . mask ( ) . set ( ULTIMA_PAGINA , TabLbu . get_long ( " I1 " ) ) ;
app ( ) . _codice_vidi = TabLbu . get ( " S4 " ) ;
1995-07-31 09:49:11 +00:00
}
1996-02-06 16:02:59 +00:00
if ( app ( ) . _test )
{
f . mask ( ) . send_key ( K_TAB , CODICE_LIBRO_IVA ) ;
2012-10-26 09:12:52 +00:00
app ( ) . _test = false ;
1996-02-06 16:02:59 +00:00
}
1995-07-31 09:49:11 +00:00
}
2012-10-26 09:12:52 +00:00
return true ;
1995-07-31 09:49:11 +00:00
}
1998-04-30 15:59:34 +00:00
bool TStampa_registri_app : : mask_data ( TMask_field & f , KEY k )
1995-07-31 09:49:11 +00:00
{
1996-02-06 16:02:59 +00:00
if ( k = = K_TAB & & f . mask ( ) . is_running ( ) )
1995-07-31 09:49:11 +00:00
{
1996-02-06 16:02:59 +00:00
const int anno = f . mask ( ) . get_int ( ANNO ) ;
TDate data ( f . get ( ) ) ;
if ( data . ok ( ) )
if ( data . year ( ) ! = anno )
1995-07-31 09:49:11 +00:00
{
2003-03-25 13:56:11 +00:00
f . warning_box ( TR ( " L'anno delle date limite deve essere uguale all'anno iva specificato " ) ) ;
2012-10-26 09:12:52 +00:00
return false ;
1995-07-31 09:49:11 +00:00
}
1996-02-06 16:02:59 +00:00
if ( f . dlg ( ) = = A_DATA )
1998-09-02 14:33:52 +00:00
if ( data . ok ( ) )
1995-07-31 09:49:11 +00:00
{
1996-02-06 16:02:59 +00:00
if ( data . day ( ) = = 31 & & data . month ( ) = = 12 )
f . mask ( ) . show ( TIPO_RIEPILOGATIVO ) ;
else f . mask ( ) . hide ( TIPO_RIEPILOGATIVO ) ;
1995-07-31 09:49:11 +00:00
}
1996-02-06 16:02:59 +00:00
}
2012-10-26 09:12:52 +00:00
return true ;
1996-02-06 16:02:59 +00:00
}
1998-04-30 15:59:34 +00:00
bool TStampa_registri_app : : year_handler ( TMask_field & f , KEY key )
1996-02-06 16:02:59 +00:00
{
if ( key = = K_TAB & & f . focusdirty ( ) )
{
2002-07-30 14:11:47 +00:00
TWait_cursor hourglass ;
1996-02-06 16:02:59 +00:00
app ( ) . set_year ( atoi ( f . get ( ) ) ) ;
app ( ) . build_nomiditte ( ) ;
app ( ) . build_ditte_sheet ( ) ;
}
2012-10-26 09:12:52 +00:00
return true ;
1996-02-06 16:02:59 +00:00
}
1998-04-30 15:59:34 +00:00
void TStampa_registri_app : : build_ditte_sheet ( )
1996-02-06 16:02:59 +00:00
{
// build sheet
_ditte - > destroy ( ) ;
1996-06-20 16:03:58 +00:00
_ditte - > enable_row ( - 1 ) ;
1996-02-06 16:02:59 +00:00
for ( int i = 0 ; i < _nomiditte . items ( ) ; i + + )
{
2012-10-26 09:12:52 +00:00
TToken_string * d = new TToken_string ( 63 ) ;
* d = ( const TToken_string & ) _nomiditte [ i ] ;
1996-02-06 16:02:59 +00:00
const char vers = d - > get_char ( 2 ) ;
2012-10-26 09:12:52 +00:00
const bool selectable = vers = = ' ? ' ;
1996-02-06 16:02:59 +00:00
d - > insert ( " | " , 0 ) ;
const long pos = _ditte - > add ( d ) ;
if ( selectable )
1996-05-20 14:02:41 +00:00
_ditte - > disable_row ( pos ) ;
1996-02-06 16:02:59 +00:00
else if ( _selected [ i ] )
_ditte - > check ( pos ) ;
}
1995-07-31 09:49:11 +00:00
}
1996-02-06 16:02:59 +00:00
// --------- handlers per selezione ditte
1998-04-30 15:59:34 +00:00
bool TStampa_registri_app : : to_ditt_handler ( TMask_field & f , KEY key )
1995-07-31 09:49:11 +00:00
{
1996-02-06 16:02:59 +00:00
TMask & m = f . mask ( ) ;
if ( key = = K_F9 )
1995-07-31 09:49:11 +00:00
{
1996-02-06 16:02:59 +00:00
TArray_sheet * sh = app ( ) . get_ditte_sheet ( ) ;
TMask & m = f . mask ( ) ;
1995-07-31 09:49:11 +00:00
1996-02-06 16:02:59 +00:00
sh - > disable_check ( ) ;
1996-06-20 16:03:58 +00:00
sh - > disable ( DLG_USER ) ;
1996-02-06 16:02:59 +00:00
if ( sh - > run ( ) = = K_ENTER )
{
app ( ) . select_firm_range ( m . get_long ( DA_CODICE ) , sh - > row ( sh - > selected ( ) ) . get_long ( 1 ) ) ;
app ( ) . set_choice_limits ( m ) ;
1995-07-31 09:49:11 +00:00
}
1996-06-20 16:03:58 +00:00
sh - > enable ( DLG_USER ) ;
1995-07-31 09:49:11 +00:00
}
1996-06-18 08:47:26 +00:00
if ( key = = K_TAB & & f . focusdirty ( ) )
{
const long l = app ( ) . select_firm_range ( m . get_long ( DA_CODICE ) , m . get_long ( A_CODICE ) ) ;
app ( ) . set_choice_limits ( m ) ;
1998-02-24 10:31:42 +00:00
m . set ( F_SELECT , l ) ;
1996-06-18 08:47:26 +00:00
}
2012-10-26 09:12:52 +00:00
return true ;
1995-07-31 09:49:11 +00:00
}
1998-04-30 15:59:34 +00:00
bool TStampa_registri_app : : fr_ditt_handler ( TMask_field & f , KEY key )
1996-06-18 08:47:26 +00:00
{
TMask & m = f . mask ( ) ;
if ( key = = K_F9 )
1995-07-31 09:49:11 +00:00
{
1996-02-06 16:02:59 +00:00
TMask & m = f . mask ( ) ;
TArray_sheet * sh = app ( ) . get_ditte_sheet ( ) ;
1995-07-31 09:49:11 +00:00
1996-02-06 16:02:59 +00:00
sh - > disable_check ( ) ;
1996-06-20 16:03:58 +00:00
sh - > disable ( DLG_USER ) ;
1996-02-06 16:02:59 +00:00
if ( sh - > run ( ) = = K_ENTER )
1995-07-31 09:49:11 +00:00
{
1996-02-06 16:02:59 +00:00
app ( ) . select_firm_range ( sh - > row ( sh - > selected ( ) ) . get_long ( 1 ) , m . get_long ( A_CODICE ) ) ;
app ( ) . set_choice_limits ( m ) ;
1995-07-31 09:49:11 +00:00
}
1996-06-20 16:03:58 +00:00
sh - > enable ( DLG_USER ) ;
}
1996-06-18 08:47:26 +00:00
else if ( key = = K_TAB & & f . focusdirty ( ) )
{
const long l = app ( ) . select_firm_range ( m . get_long ( DA_CODICE ) , m . get_long ( A_CODICE ) ) ;
app ( ) . set_choice_limits ( m ) ;
1998-02-24 10:31:42 +00:00
m . set ( F_SELECT , l ) ;
1996-06-18 08:47:26 +00:00
}
2012-10-26 09:12:52 +00:00
return true ;
1996-02-06 16:02:59 +00:00
}
1998-04-30 15:59:34 +00:00
void TStampa_registri_app : : set_choice_limits ( TMask & m )
1996-02-06 16:02:59 +00:00
{
long first = - 1l , last = - 1l ;
for ( int i = 0 ; i < _ditte - > items ( ) ; i + + )
1995-07-31 09:49:11 +00:00
{
1996-02-06 16:02:59 +00:00
if ( _selected [ i ] )
1995-07-31 09:49:11 +00:00
{
2012-10-26 09:12:52 +00:00
const long dit = _ditte - > row ( i ) . get_long ( 1 ) ;
if ( first < 0 ) first = dit ;
if ( last < dit ) last = dit ;
1995-07-31 09:49:11 +00:00
}
}
2012-10-26 09:12:52 +00:00
if ( first > 0 ) m . set ( DA_CODICE , first ) ;
if ( last > 0 ) m . set ( A_CODICE , last ) ;
1996-02-06 16:02:59 +00:00
m . set ( F_SELECT , _selected . ones ( ) ) ;
2012-10-26 09:12:52 +00:00
if ( m . is_running ( ) & & first > 0 )
app ( ) . set_firm ( first ) ;
1996-02-06 16:02:59 +00:00
}
1995-07-31 09:49:11 +00:00
1998-04-30 15:59:34 +00:00
long TStampa_registri_app : : select_firm_range ( long from , long to )
1995-07-31 09:49:11 +00:00
{
1996-02-06 16:02:59 +00:00
if ( to = = 0l ) to = 99999L ;
for ( int i = 0 ; i < _ditte - > items ( ) ; i + + )
1995-07-31 09:49:11 +00:00
{
1996-05-20 14:02:41 +00:00
if ( _ditte - > row_disabled ( i ) )
1996-02-06 16:02:59 +00:00
continue ;
TToken_string & d = _ditte - > row ( i ) ;
const char vers = d . get_char ( 3 ) ;
if ( vers = = ' ? ' )
continue ;
const long cod = d . get_long ( 1 ) ;
if ( cod > = from & & cod < = to )
1995-07-31 09:49:11 +00:00
{
1996-02-06 16:02:59 +00:00
_selected . set ( i ) ;
_ditte - > check ( i ) ;
1995-07-31 09:49:11 +00:00
}
1996-02-06 16:02:59 +00:00
else
{
2012-10-26 09:12:52 +00:00
_selected . set ( i , false ) ;
1996-02-06 16:02:59 +00:00
_ditte - > uncheck ( i ) ;
1995-07-31 09:49:11 +00:00
}
1996-02-06 16:02:59 +00:00
}
return _selected . ones ( ) ;
1995-07-31 09:49:11 +00:00
}
1998-04-30 15:59:34 +00:00
void TStampa_registri_app : : build_nomiditte ( TProgind * pnd )
1996-02-06 16:02:59 +00:00
{
_nomiditte . destroy ( ) ;
2012-10-26 09:12:52 +00:00
TString_array codes ;
prefix ( ) . firms ( codes ) ;
FOR_EACH_ARRAY_ROW ( codes , i , row )
1996-02-06 16:02:59 +00:00
{
2012-10-26 09:12:52 +00:00
const long cod = atol ( * row ) ;
1996-02-06 16:02:59 +00:00
// check no archivi
2012-10-26 09:12:52 +00:00
TToken_string * d = new TToken_string ( 63 ) ;
d - > add ( cod ) ;
d - > add ( cache ( ) . get ( LF_NDITTE , cod , NDT_RAGSOC ) ) ;
2003-03-25 13:56:11 +00:00
2012-10-26 09:12:52 +00:00
const TRectype & lia = look_lia ( cod ) ;
const TString & freq = lia . get ( " S7 " ) ;
if ( freq . blank ( ) )
2003-03-25 13:56:11 +00:00
d - > add ( " ?? " ) ;
else
d - > add ( freq ) ;
1996-02-06 16:02:59 +00:00
_nomiditte . add ( d ) ;
1995-07-31 09:49:11 +00:00
}
2012-10-26 09:12:52 +00:00
_n_ditte = _nomiditte . items ( ) ;
1995-07-31 09:49:11 +00:00
}
1998-04-30 15:59:34 +00:00
bool TStampa_registri_app : : set_ditte ( TMask & m )
1995-07-31 09:49:11 +00:00
{
1996-02-06 16:02:59 +00:00
m . field ( TIPO_STAMPA ) . set ( " 1 " ) ;
m . field ( DA_DATA ) . set ( " " ) ;
m . field ( A_DATA ) . set ( " " ) ;
m . field ( CODICE_LIBRO_PROVA ) . set ( " " ) ;
1995-07-31 09:49:11 +00:00
1996-06-20 16:03:58 +00:00
KEY tasto ;
do
{
tasto = m . run ( ) ;
if ( tasto = = DLG_SELECT )
{
_ditte - > enable_check ( ) ;
// seleziona e aggiungi alle gia' selezionate
if ( _ditte - > run ( ) = = K_ENTER )
{
2012-10-26 09:12:52 +00:00
for ( long j = 0 ; j < _ditte - > items ( ) ; j + + )
1996-06-20 16:03:58 +00:00
_selected . set ( j , _ditte - > checked ( j ) ) ;
set_choice_limits ( m ) ;
}
}
} while ( tasto ! = K_ENTER & & tasto ! = K_QUIT ) ;
1996-02-06 16:02:59 +00:00
return tasto = = K_ENTER ;
}
1998-04-30 15:59:34 +00:00
bool TStampa_registri_app : : user_create ( )
1996-02-06 16:02:59 +00:00
{
2003-03-25 13:56:11 +00:00
open_files ( LF_TAB , LF_TABCOM , LF_NDITTE , LF_MOV , LF_ATTIV , LF_CLIFO , LF_OCCAS ,
LF_COMUNI , LF_ANAG , LF_UNLOC , LF_CAUSALI , LF_RMOVIVA , LF_INDLIB , 0 ) ;
_tabreg = new TTable ( " REG " ) ;
1996-02-06 16:02:59 +00:00
_nditte = new TRelation ( LF_NDITTE ) ;
_rel = new TRelation ( LF_MOV ) ;
_rel - > add ( LF_CAUSALI , " CODCAUS=CODCAUS " , 1 , LF_MOV ) ;
_rel - > add ( LF_RMOVIVA , " NUMREG=NUMREG " , 1 , LF_MOV ) ;
1999-04-06 15:34:39 +00:00
_rel - > add ( " REG " , " CODTAB[1,4]=ANNOIVA|CODTAB[5,7]=REG " ) ;
1996-03-13 16:02:40 +00:00
_cur = new TSorted_cursor ( _rel , " DATAREG|PROTIVA|NUMREG " , " " , 2 ) ;
2003-03-25 13:56:11 +00:00
_ditte = new TArray_sheet ( - 1 , - 1 , - 4 , - 4 , TR ( " Selezione Ditte " ) ,
HR ( " @1|Cod.@5R|Ragione Sociale@50|Vers. " ) ) ;
1996-02-06 16:02:59 +00:00
_n_ditte = 0l ;
__firm = TApplication : : get_firm ( ) ;
1999-07-16 14:59:11 +00:00
1996-02-06 16:02:59 +00:00
TDate oggi ( TODAY ) ;
_annoes = oggi . year ( ) ;
2012-10-26 09:12:52 +00:00
1996-02-06 16:02:59 +00:00
build_nomiditte ( ) ;
build_ditte_sheet ( ) ;
add_cursor ( _cur ) ;
add_file ( LF_MOV ) ;
add_file ( LF_RMOVIVA ) ;
2012-10-26 09:12:52 +00:00
return true ;
1996-02-06 16:02:59 +00:00
}
1998-04-30 15:59:34 +00:00
bool TStampa_registri_app : : user_destroy ( )
1996-02-06 16:02:59 +00:00
{
delete _ditte ;
delete _nditte ;
2003-03-25 13:56:11 +00:00
delete _tabreg ;
1996-02-06 16:02:59 +00:00
delete _rel ;
2003-03-25 13:56:11 +00:00
2012-10-26 09:12:52 +00:00
return true ;
1996-02-06 16:02:59 +00:00
}
//********* funzioni di calcolo e di controllo *********//
1998-04-30 15:59:34 +00:00
// Questa funzione calcola i progressivi del periodo e totali, oltre a quelli
// del periodo precedente.
void TStampa_registri_app : : calcola_progressivi ( )
1996-02-06 16:02:59 +00:00
{
1998-04-30 15:59:34 +00:00
TString80 chiave , codtab ;
1996-02-06 16:02:59 +00:00
int i , num = 0 ;
1998-04-30 15:59:34 +00:00
if ( _tipo_stampa = = libro_unico )
1996-02-06 16:02:59 +00:00
num = _fino_a_mese ;
1998-04-30 15:59:34 +00:00
if ( _tipo_stampa = = bollato | | _tipo_stampa = = rif_giornale )
1996-02-06 16:02:59 +00:00
num = _datareg . month ( ) ;
1998-04-30 15:59:34 +00:00
// Chiave per selezione records progressivi
1996-02-06 16:02:59 +00:00
chiave < < _annoes < < _codatt ;
1998-04-30 15:59:34 +00:00
1995-07-31 09:49:11 +00:00
1998-04-30 15:59:34 +00:00
//calcolo i totali del periodo; calcola anche i totali da Periodo Precedente (se _annoes > 1997)
//_codatt e' gia' Z perche' lo leggo dal registro
//calcolo i totali progressivi e del periodo (tra questi anche quelli di cui periodo precedente)
1996-02-06 16:02:59 +00:00
for ( i = 1 ; i < = num ; i + + )
1998-04-30 15:59:34 +00:00
{
2012-10-26 09:12:52 +00:00
const int start = 0 , stop = ( i = = num ) ? 1 : 0 ;
1998-04-30 15:59:34 +00:00
for ( int j = start ; j < = stop ; j + + )
1995-07-31 09:49:11 +00:00
{
2012-10-26 09:12:52 +00:00
const bool calc_prp = j = = 1 ; // Calcola progressivi precedenti
2003-03-25 13:56:11 +00:00
TTable tab ( calc_prp ? " PRP " : _tabname ) ;
1998-04-30 15:59:34 +00:00
2003-03-25 13:56:11 +00:00
tab . zero ( ) ;
tab . put ( " CODTAB " , chiave ) ;
const TRectype r ( tab . curr ( ) ) ;
tab . read ( _isgteq ) ;
for ( ; ! tab . eof ( ) & & tab . curr ( ) = = r ; tab . next ( ) )
1995-07-31 09:49:11 +00:00
{
2003-03-25 13:56:11 +00:00
codtab = tab . get ( " CODTAB " ) ;
2006-12-13 16:22:33 +00:00
TString4 codreg = codtab . mid ( 10 , 3 ) ; codreg . trim ( ) ;
const int mese = atoi ( codtab . mid ( 13 , 2 ) ) ;
if ( _codreg = = codreg & & mese = = i )
1996-02-06 16:02:59 +00:00
{
2006-12-13 16:22:33 +00:00
const TString4 codiva = codtab . mid ( 16 , 4 ) ;
const int tipodet = atoi ( codtab . mid ( 20 , 1 ) ) ;
2003-03-25 13:56:11 +00:00
real impo = tab . get_real ( " R0 " ) ;
real impos = tab . get_real ( " R1 " ) ;
real implo = tab . get_real ( " R2 " ) ;
1998-04-30 15:59:34 +00:00
//se il registro e' corrispettivi l'imponibile e l'iva li trovo in S2
if ( _corrispettivi )
{
2003-03-25 13:56:11 +00:00
TToken_string cs ( tab . get ( " S2 " ) , ' ! ' ) ;
1998-04-30 15:59:34 +00:00
impo = cs . get ( 0 ) ;
impos = cs . get ( 1 ) ;
}
//se in sospensione d'imposta l'imponibile e l'iva li trovo in R11 e R12
if ( _sosp_imposta )
{
2003-03-25 13:56:11 +00:00
impo = tab . get_real ( " R11 " ) ;
impos = tab . get_real ( " R12 " ) ;
1998-04-30 15:59:34 +00:00
}
2003-03-25 13:56:11 +00:00
TToken_string fatt_rit ( tab . get ( " S1 " ) , ' ! ' ) ;
1998-04-30 15:59:34 +00:00
real im ( fatt_rit . get ( 0 ) ) ;
real is ( fatt_rit . get ( 1 ) ) ;
impo + = im ;
impos + = is ;
implo + = im + is ;
if ( impo ! = ZERO | | impos ! = ZERO | | implo ! = ZERO )
{
if ( ! calc_prp & & _tipo_stampa ! = prova )
_tot_iva_array . add_riga ( ZERO , ZERO , ZERO , impo , impos , implo , codiva ) ; // progressivi
if ( mese = = num )
if ( calc_prp )
_tot_prec_iva_array . add_riga ( impo , impos , implo , ZERO , ZERO , ZERO , codiva ) ; // periodo prec
else
_tot_iva_array . add_riga ( impo , impos , implo , ZERO , ZERO , ZERO , codiva ) ; // periodo
}
if ( ! calc_prp & & _tipo_reg = = acquisto ) //registro acquisti
2006-12-13 16:22:33 +00:00
{
1998-04-30 15:59:34 +00:00
if ( impo ! = ZERO | | impos ! = ZERO )
{
if ( _tipo_stampa ! = prova )
2006-12-13 16:22:33 +00:00
_iva_array . add_riga ( ZERO , ZERO , impo , impos , codiva , tipodet , 0 , true , 0 ) ; //progressivi
1998-04-30 15:59:34 +00:00
if ( mese = = num )
2006-12-13 16:22:33 +00:00
_iva_array . add_riga ( impo , impos , ZERO , ZERO , codiva , tipodet , 0 , true , 0 ) ; // periodo
1998-04-30 15:59:34 +00:00
}
2006-12-13 16:22:33 +00:00
}
1998-04-30 15:59:34 +00:00
}
} // for table
} // for start to stop
} // for i to num
1995-07-31 09:49:11 +00:00
}
1998-04-30 15:59:34 +00:00
int TStampa_registri_app : : riga_rmoviva ( )
1995-07-31 09:49:11 +00:00
{
2002-02-26 16:20:19 +00:00
TLocalisamfile & rmoviva = _cur - > file ( LF_RMOVIVA ) ;
bool ok = _cur - > is_first_match ( LF_RMOVIVA ) ;
if ( ! ok )
return 0 ;
2012-11-30 14:36:30 +00:00
const TRectype & mov = _cur - > curr ( LF_MOV ) ;
const int mese_liq = mov . get_int ( MOV_MESELIQ ) ;
1996-02-06 16:02:59 +00:00
int nrec = 0 ;
2000-10-03 13:45:12 +00:00
const TRecnotype nr = rmoviva . recno ( ) ;
1996-02-06 16:02:59 +00:00
2006-12-13 16:22:33 +00:00
const TRectype & iva = rmoviva . curr ( ) ;
1996-02-06 16:02:59 +00:00
while ( ok )
1995-07-31 09:49:11 +00:00
{
1996-02-06 16:02:59 +00:00
nrec + + ;
2006-12-13 16:22:33 +00:00
const real impo = iva . get_real ( RMI_IMPONIBILE ) ;
const real impos = iva . get_real ( RMI_IMPOSTA ) ;
const TString4 codiva = iva . get ( RMI_CODIVA ) ;
1996-02-06 16:02:59 +00:00
2006-12-13 16:22:33 +00:00
_riga_rmi . add_riga ( iva ) ;
2012-11-30 14:36:30 +00:00
if ( ! mov . get_bool ( MOV_LIQDIFF ) & & ! ( mov . get_bool ( MOV_IVAXCASSA ) & & mov . get_int ( MOV_TIPOMOV ) > 0 ) )
_riga_prospettoXcassa . add_riga ( impo , impos , ZERO , ZERO , codiva , 0 , 0 , false , 0 ) ;
1996-02-06 16:02:59 +00:00
2006-12-13 16:22:33 +00:00
//stampa di prova, cumula progressivi dai movimenti, anziche' dalle tabelle (solo bollato)
if ( _tipo_stampa = = prova )
1995-07-31 09:49:11 +00:00
{
1996-02-06 16:02:59 +00:00
if ( _tipodoc = = " FS " )
1995-07-31 09:49:11 +00:00
{
2006-12-13 16:22:33 +00:00
const real somma = - ( impo + impos ) ;
1996-02-06 16:02:59 +00:00
_tot_iva_array . add_riga ( ZERO , ZERO , somma , ZERO , ZERO , ZERO , codiva ) ;
1998-04-30 15:59:34 +00:00
if ( mese_liq ! = 0 )
_tot_prec_iva_array . add_riga ( ZERO , ZERO , somma , ZERO , ZERO , ZERO , codiva ) ;
1996-02-06 16:02:59 +00:00
}
else if ( _tipodoc = = " CR " | | _tipodoc = = " RF " | | _tipodoc = = " SC " )
1998-04-30 15:59:34 +00:00
{
1996-02-06 16:02:59 +00:00
_tot_iva_array . add_riga ( ZERO , ZERO , impo + impos , ZERO , ZERO , ZERO , codiva ) ;
1998-04-30 15:59:34 +00:00
if ( mese_liq ! = 0 )
_tot_prec_iva_array . add_riga ( ZERO , ZERO , impo + impos , ZERO , ZERO , ZERO , codiva ) ;
}
1996-02-06 16:02:59 +00:00
if ( _tipodoc ! = " CR " & & _tipodoc ! = " SC " & & _tipodoc ! = " RF " )
1998-04-30 15:59:34 +00:00
{
1996-02-06 16:02:59 +00:00
_tot_iva_array . add_riga ( impo , impos , ZERO , ZERO , ZERO , ZERO , codiva ) ;
1998-04-30 15:59:34 +00:00
if ( mese_liq ! = 0 )
_tot_prec_iva_array . add_riga ( impo , impos , ZERO , ZERO , ZERO , ZERO , codiva ) ;
}
1996-02-06 16:02:59 +00:00
1998-04-30 15:59:34 +00:00
if ( _tipo_reg = = acquisto ) //registro acquisti (non ha senso parlare di importi lordi)
2006-12-13 16:22:33 +00:00
_iva_array . add_riga ( iva ) ;
1995-07-31 09:49:11 +00:00
}
1996-02-06 16:02:59 +00:00
ok = _cur - > next_match ( LF_RMOVIVA ) ;
}
rmoviva . readat ( nr ) ;
return nrec ;
}
1998-04-30 15:59:34 +00:00
int TStampa_registri_app : : setta_riga ( int r , const TRigaiva & riga , real & tot1 ,
2008-12-03 14:53:51 +00:00
real & tot2 , real & tot3 , real & tot4 )
1996-02-06 16:02:59 +00:00
{
2008-12-03 14:53:51 +00:00
set_row ( r , riga . _codiva ) ;
TString descrizione = descr_iva ( riga . _codiva ) ;
if ( riga . _tipocr > 0 )
{
const char * cr = NULL ;
switch ( riga . _tipocr )
{
case 1 : cr = TR ( " Beni per rivendita " ) ; break ;
case 2 : cr = TR ( " Beni ammortizzabili " ) ; break ;
case 3 : cr = TR ( " Beni ammortizzabili con detr. 6% " ) ; break ;
case 4 : cr = TR ( " Beni strumentali art. 17 " ) ; break ;
case 5 : cr = TR ( " Beni per rivendita da non ventilare " ) ; break ;
case 8 : cr = TR ( " Altri beni strumentali in leasing " ) ; break ;
case 9 : cr = TR ( " Spese generali " ) ; break ;
default : break ;
}
if ( cr & & * cr )
descrizione < < " ( " < < cr < < ' ) ' ;
}
if ( descrizione . full ( ) )
{
TParagraph_string descr ( descrizione , 23 ) ;
- - r ;
FOR_EACH_TOKEN ( descr , d )
set_row ( + + r , " @5g%-.23s " , d ) ;
}
if ( ! riga . _imponibile . is_zero ( ) )
1996-02-06 16:02:59 +00:00
set_row ( r , " @29g%r " , & riga . _imponibile ) ;
2008-12-03 14:53:51 +00:00
if ( ! riga . _imposta . is_zero ( ) )
1996-02-06 16:02:59 +00:00
set_row ( r , " @45g%r " , & riga . _imposta ) ;
1998-04-30 15:59:34 +00:00
if ( _tipo_stampa ! = prova )
1996-02-06 16:02:59 +00:00
{
2008-12-03 14:53:51 +00:00
if ( ! riga . _imponibilep . is_zero ( ) )
1996-02-06 16:02:59 +00:00
set_row ( r , " @81g%r " , & riga . _imponibilep ) ;
2008-12-03 14:53:51 +00:00
if ( ! riga . _impostap . is_zero ( ) )
2000-05-05 15:25:49 +00:00
set_row ( r , " @98g%r " , & riga . _impostap ) ;
}
r + + ; // Incrementa sempre: cazzone!
1996-02-06 16:02:59 +00:00
tot1 + = riga . _imponibile ;
tot2 + = riga . _imposta ;
tot3 + = riga . _imponibilep ;
tot4 + = riga . _impostap ;
2008-12-03 14:53:51 +00:00
1995-07-31 09:49:11 +00:00
return r ;
1996-02-06 16:02:59 +00:00
}
1995-07-31 09:49:11 +00:00
1998-04-30 15:59:34 +00:00
messaggio TStampa_registri_app : : controlla_liquidazione ( )
1996-02-06 16:02:59 +00:00
{
2008-12-03 14:53:51 +00:00
TTable lim ( " LIM " ) ;
TString mesi_cal ;
TString8 chiave , ditta ;
bool continua = false ;
1996-02-06 16:02:59 +00:00
ditta < < get_firm ( ) ;
2008-12-03 14:53:51 +00:00
int mese = 0 ;
1998-04-30 15:59:34 +00:00
if ( _tipo_stampa = = prova ) //stampa di prova
1996-02-06 16:02:59 +00:00
mese = _data_a . month ( ) ;
else
mese = _fino_a_mese ;
if ( _tipo_riepilogativo = = ' ' | | _tipo_riepilogativo = = ' P ' )
{
1996-02-20 09:25:35 +00:00
if ( _frequiva = = ' T ' ) //la LIM esiste solo per i mesi 3, 6, 9, 12
1996-02-06 16:02:59 +00:00
{
2008-12-03 14:53:51 +00:00
for ( int i = 3 ; i < = mese ; i + = 3 )
1996-02-06 16:02:59 +00:00
{
2008-12-03 14:53:51 +00:00
chiave . format ( " %04d%02d " , _annoes , i ) ;
1996-12-10 10:42:46 +00:00
lim . put ( " CODTAB " , chiave ) ;
1996-02-20 09:25:35 +00:00
if ( lim . read ( ) ! = NOERR | | ! lim . get_bool ( " B0 " ) )
2008-12-03 14:53:51 +00:00
mesi_cal < < itom ( i ) < < ' \n ' ;
1996-02-06 16:02:59 +00:00
}
2008-12-03 14:53:51 +00:00
} else
1996-02-06 16:02:59 +00:00
if ( _frequiva = = ' M ' )
{
2008-12-03 14:53:51 +00:00
for ( int i = 1 ; i < = mese ; i + + )
1996-02-06 16:02:59 +00:00
{
2008-12-03 14:53:51 +00:00
chiave . format ( " %04d%02d " , _annoes , i ) ;
1996-02-06 16:02:59 +00:00
lim . put ( " CODTAB " , chiave ) ;
1996-02-20 09:25:35 +00:00
if ( lim . read ( ) ! = NOERR | | ! lim . get_bool ( " B0 " ) )
2008-12-03 14:53:51 +00:00
mesi_cal < < itom ( i ) < < ' \n ' ;
1996-02-06 16:02:59 +00:00
}
}
if ( mesi_cal . not_empty ( ) )
{
2003-03-25 13:56:11 +00:00
warning_box ( FR ( " Ditta %s: la liquidazione da stampare sul registro %s relativa ai mesi di \n %s non e' stata ancora calcolata " ) , ( const char * ) ditta , ( const char * ) _codreg , ( const char * ) mesi_cal ) ;
continua = yesno_box ( TR ( " Si desidera ugualmente proseguire? " ) ) ;
1996-02-06 16:02:59 +00:00
if ( ! continua ) return non_proseguire ;
2003-03-25 13:56:11 +00:00
continua = yesno_box ( TR ( " Si desidera proseguire con il calcolo e la stampa di liquidazione? \n (altrimenti si prosegue con la sola stampa liquidazione) " ) ) ;
1996-02-06 16:02:59 +00:00
if ( ! continua ) return prosegui_stampa ;
return prosegui_cal_stampa ;
}
}
else if ( _tipo_riepilogativo = = ' A ' )
1996-02-20 09:25:35 +00:00
{
2008-12-03 14:53:51 +00:00
chiave . format ( " %04d%02d " , _annoes , 13 ) ;
1996-02-20 09:25:35 +00:00
lim . put ( " CODTAB " , chiave ) ;
if ( lim . read ( ) ! = NOERR | | ! lim . get_bool ( " B0 " ) )
1996-02-06 16:02:59 +00:00
{
2003-03-25 13:56:11 +00:00
continua = yesno_box ( FR ( " Ditta %s: non eseguito calcolo liquidazione annuale da stampare sul registro %s. Si desidera ugualmente proseguire? " ) , ( const char * ) ditta , ( const char * ) _codreg ) ;
1996-02-20 09:25:35 +00:00
if ( ! continua ) return non_proseguire ;
2003-03-25 13:56:11 +00:00
continua = yesno_box ( TR ( " Si desidera proseguire con il calcolo e la stampa di liquidazione? \n (altrimenti si prosegue con la sola stampa liquidazione) " ) ) ;
1996-02-20 09:25:35 +00:00
if ( ! continua ) return prosegui_stampa ;
return prosegui_cal_stampa ;
}
else
{
2012-10-26 09:12:52 +00:00
bool need_refresh = false ;
1996-02-20 09:25:35 +00:00
for ( int m = 1 ; m < 13 ; m + + )
if ( _frequiva = = ' M ' | |
( m = = 3 | | m = = 6 | | m = = 9 | | m = = 12 ) )
{
2008-12-03 14:53:51 +00:00
chiave . format ( " %04d%02d " , _annoes , m ) ;
1996-02-20 09:25:35 +00:00
lim . put ( " CODTAB " , chiave ) ;
if ( lim . read ( ) ! = NOERR | | ! lim . get_bool ( " B0 " ) )
{
2012-10-26 09:12:52 +00:00
need_refresh = true ;
1996-02-20 09:25:35 +00:00
break ;
}
}
if ( need_refresh )
1996-02-06 16:02:59 +00:00
{
2003-03-25 13:56:11 +00:00
continua = yesno_box ( FR ( " Ditta %s: la liquidazione di alcuni mesi precedenti deve "
1996-02-20 09:25:35 +00:00
" essere ricalcolata. \n "
2003-03-25 13:56:11 +00:00
" Si desidera ugualmente proseguire? " ) , ( const char * ) ditta ) ;
1996-02-06 16:02:59 +00:00
if ( ! continua ) return non_proseguire ;
2003-03-25 13:56:11 +00:00
continua = yesno_box ( TR ( " Si desidera proseguire con il calcolo e la stampa di liquidazione? \n (altrimenti si prosegue con la sola stampa liquidazione) " ) ) ;
1996-02-06 16:02:59 +00:00
if ( ! continua ) return prosegui_stampa ;
return prosegui_cal_stampa ;
1996-02-20 09:25:35 +00:00
}
}
}
1996-02-06 16:02:59 +00:00
return B0_settato ;
}
//controlla che i movimenti con anno data di registrazione < dell'anno indicato a video siano stati gia' stampati in forma definitiva*/
//questo controllo viene fatto solo per stampa di bollato (non su libro unico)
1998-04-30 15:59:34 +00:00
bool TStampa_registri_app : : controlla_mov ( )
1996-02-06 16:02:59 +00:00
{
TLocalisamfile mov ( LF_MOV ) ;
2012-10-26 09:12:52 +00:00
bool ok = true ;
1998-04-30 15:59:34 +00:00
tiporeg tipo ;
2006-12-13 16:22:33 +00:00
1996-02-06 16:02:59 +00:00
TRecnotype rec = _tabreg - > recno ( ) ;
for ( mov . first ( ) ; ! mov . eof ( ) ; mov . next ( ) )
{
2006-08-03 08:45:50 +00:00
const TString4 reg = mov . get ( MOV_REG ) ;
1996-02-06 16:02:59 +00:00
if ( reg . empty ( ) ) continue ; //non e' un movimento iva
if ( _stampa_tutti_i_registri )
1998-04-30 15:59:34 +00:00
tipo = cerca_reg ( reg ) ;
if ( ( _stampa_tutti_i_registri & & ( tipo = = vendita | | tipo = = acquisto | | tipo = = riepilogativo ) )
1996-02-06 16:02:59 +00:00
| | ( ! _stampa_tutti_i_registri & & reg = = _codreg ) )
{
2006-12-13 16:22:33 +00:00
const TDate datareg = mov . get_date ( MOV_DATAREG ) ;
const bool stampato = mov . get_bool ( MOV_REGST ) ;
1996-02-06 16:02:59 +00:00
if ( datareg . year ( ) < _annoes )
{
2006-12-13 16:22:33 +00:00
const long numreg = mov . get_long ( MOV_NUMREG ) ;
1996-02-06 16:02:59 +00:00
if ( ! stampato )
2012-10-26 09:12:52 +00:00
ok = false ;
1996-02-06 16:02:59 +00:00
}
1995-07-31 09:49:11 +00:00
}
}
1996-02-06 16:02:59 +00:00
_tabreg - > readat ( rec ) ;
return ok ;
1995-07-31 09:49:11 +00:00
}
1998-04-30 15:59:34 +00:00
tiporeg TStampa_registri_app : : cerca_reg ( const TString & c )
1996-02-06 16:02:59 +00:00
{
2012-11-30 14:36:30 +00:00
tiporeg t = vendita ;
TString8 cod ; cod < < _annoes < < c ;
1996-02-06 16:02:59 +00:00
_tabreg - > zero ( ) ;
_tabreg - > put ( " CODTAB " , cod ) ;
if ( _tabreg - > read ( ) = = NOERR )
1998-04-30 15:59:34 +00:00
t = ( tiporeg ) _tabreg - > get_int ( " I0 " ) ;
return t ;
1996-02-06 16:02:59 +00:00
}
1998-04-30 15:59:34 +00:00
int TStampa_registri_app : : stampa_prospetto ( int rr , bool print_prec )
1996-02-06 16:02:59 +00:00
{
TString riga ( _stampa_width ) ;
1998-04-30 15:59:34 +00:00
if ( ! print_prec ) // Stampa il prospetto iniziale per progressivi attuali (periodo)
1996-02-06 16:02:59 +00:00
{
1998-04-30 15:59:34 +00:00
reset_print ( ) ;
riga . fill ( ' - ' ) ;
2012-11-30 14:36:30 +00:00
set_row ( rr + + , riga ) ;
riga = TR ( " Legenda Tipo Operazione: 1=intra; 2=AF art.34 comma 3 " ) ;
1998-04-30 15:59:34 +00:00
if ( _auto_intraf )
2012-11-30 14:36:30 +00:00
riga < < TR ( " ; 3=intra e AF art.34 comma 3 " ) ;
riga < < TR ( " ; 4=liquidazione differita " ) ;
riga < < TR ( " ; 5=IVA per cassa " ) ;
set_row ( rr + + , riga ) ;
1998-04-30 15:59:34 +00:00
_stampa = _st_tot_fin ;
if ( _stampa )
1996-02-06 16:02:59 +00:00
{
2003-03-25 13:56:11 +00:00
set_row ( + + rr , FR ( " Tipo documento@54gTotale documento " ) ) ;
1998-04-30 15:59:34 +00:00
rr + = 2 ;
for ( int j = 0 ; j < _doc_array . items ( ) ; j + + )
{
2012-11-30 14:36:30 +00:00
const TTipodoc & doc = ( TTipodoc & ) _doc_array [ j ] ;
1998-04-30 15:59:34 +00:00
set_row ( rr , " %2s " , ( const char * ) doc . _tipodoc ) ;
set_row ( rr , " @3g%s " , ( const char * ) doc . _descrdoc ) ;
set_row ( rr , " @54g%r " , & doc . _totdoc ) ;
rr + + ;
}
_doc_array . destroy ( ) ;
}
if ( _stampa & & _tipo_reg = = acquisto )
{
if ( _stampa_cred_pre & & _datareg . month ( ) = = 1 & & _credito > ZERO )
{
2003-03-25 13:56:11 +00:00
set_row ( + + rr , FR ( " ** CREDITO INIZIO ANNO @39g%r " ) , & _credito ) ;
1998-04-30 15:59:34 +00:00
rr + + ;
}
1996-02-06 16:02:59 +00:00
}
1995-07-31 09:49:11 +00:00
}
1996-02-06 16:02:59 +00:00
1998-04-30 15:59:34 +00:00
1996-02-06 16:02:59 +00:00
if ( _esiste_riga_iva & & _stampa )
{
1998-04-30 15:59:34 +00:00
if ( print_prec )
2003-03-25 13:56:11 +00:00
set_row ( + + rr , TR ( " DI CUI PERIODO PRECEDENTE " ) ) ;
1998-04-30 15:59:34 +00:00
if ( _tipo_reg = = vendita & & _corrispettivi )
2003-03-25 13:56:11 +00:00
set_row ( + + rr , FR ( " @30g------------------ P E R I O D O ------------------- " ) ) ;
1996-02-06 16:02:59 +00:00
else
2003-03-25 13:56:11 +00:00
set_row ( + + rr , FR ( " @30g---------- P E R I O D O ----------- " ) ) ;
1998-04-30 15:59:34 +00:00
if ( _tipo_stampa ! = prova & & ! print_prec )
1996-02-06 16:02:59 +00:00
{
1998-04-30 15:59:34 +00:00
if ( _tipo_reg = = vendita & & _corrispettivi )
2003-03-25 13:56:11 +00:00
set_row ( rr , FR ( " @84g----------- P R O G R E S S I V I -------------- " ) ) ;
1996-02-06 16:02:59 +00:00
else
2003-03-25 13:56:11 +00:00
set_row ( rr , FR ( " @82g------ P R O G R E S S I V I ------ " ) ) ;
1996-02-06 16:02:59 +00:00
}
rr + + ;
2003-03-25 13:56:11 +00:00
set_row ( rr , TR ( " Cod. " ) ) ;
1998-04-30 15:59:34 +00:00
if ( _tipo_reg = = acquisto )
1996-02-06 16:02:59 +00:00
{
2003-03-25 13:56:11 +00:00
set_row ( rr , FR ( " @40gA C Q U I S T I " ) ) ;
1998-04-30 15:59:34 +00:00
if ( _tipo_stampa ! = prova & & ! print_prec )
2003-03-25 13:56:11 +00:00
set_row ( rr , FR ( " @92gA C Q U I S T I " ) ) ;
1996-02-06 16:02:59 +00:00
}
1998-04-30 15:59:34 +00:00
if ( _tipo_reg = = vendita ) //un registro corrispettivi puo' solo essere un registro vendite
1996-02-06 16:02:59 +00:00
{
2003-03-25 13:56:11 +00:00
set_row ( rr , FR ( " @41gV E N D I T E " ) ) ;
1996-02-06 16:02:59 +00:00
if ( _corrispettivi )
2003-03-25 13:56:11 +00:00
set_row ( rr , FR ( " @67gCORRISPETTIVI " ) ) ;
1998-04-30 15:59:34 +00:00
if ( _tipo_stampa ! = prova & & ! print_prec )
1996-02-06 16:02:59 +00:00
{
if ( _corrispettivi )
2003-03-25 13:56:11 +00:00
set_row ( rr , FR ( " @94gV E N D I T E@118gCORRISPETTIVI " ) ) ;
1996-02-06 16:02:59 +00:00
else
2003-03-25 13:56:11 +00:00
set_row ( rr , FR ( " @93gV E N D I T E " ) ) ;
1996-02-06 16:02:59 +00:00
}
}
rr + + ;
2003-03-25 13:56:11 +00:00
set_row ( rr , FR ( " iva Descrizione@34gImponibile@53gImposta " ) ) ;
1998-04-30 15:59:34 +00:00
if ( _tipo_reg = = vendita & & _corrispettivi )
2003-03-25 13:56:11 +00:00
set_row ( rr , FR ( " @67gImporti lordi " ) ) ;
1998-04-30 15:59:34 +00:00
if ( _tipo_stampa ! = prova & & ! print_prec )
1996-02-06 16:02:59 +00:00
{
1998-04-30 15:59:34 +00:00
if ( _tipo_reg = = vendita & & _corrispettivi )
2003-03-25 13:56:11 +00:00
set_row ( rr + + , FR ( " @87gImponibile@107gImposta@118gImporti lordi " ) ) ;
1996-02-06 16:02:59 +00:00
else
2003-03-25 13:56:11 +00:00
set_row ( rr + + , FR ( " @86gImponibile@106gImposta " ) ) ;
1996-02-06 16:02:59 +00:00
}
2006-12-13 16:22:33 +00:00
else
rr + + ;
1996-02-06 16:02:59 +00:00
rr + + ;
}
return rr ;
}
1995-07-31 09:49:11 +00:00
1996-02-06 16:02:59 +00:00
//*** stampa "tipi di indetraibilita'" : solo per gli acquisti! ***//
1998-04-30 15:59:34 +00:00
int TStampa_registri_app : : stampa_acquisti ( int row )
1996-02-06 16:02:59 +00:00
{
real tot_imponib , tot_imposta , tot_imponibp , tot_impostap ;
row + = 2 ;
int tdetprec = - 1 ;
int rw = row ;
tot_imponib = tot_imposta = tot_imponibp = tot_impostap = ZERO ;
2006-12-13 16:22:33 +00:00
_iva_array . sort ( compare_righeiva ) ;
1996-02-06 16:02:59 +00:00
for ( int s = 0 ; s < _iva_array . items ( ) ; s + + )
1995-07-31 09:49:11 +00:00
{
2006-12-13 16:22:33 +00:00
const TRigaiva & riga = _iva_array . riga ( s ) ;
const int tipodet = riga . _tipodet ;
switch ( tipodet )
1996-02-06 16:02:59 +00:00
{
case 1 :
if ( tdetprec = = 3 | | tdetprec = = 9 )
{
2003-03-25 13:56:11 +00:00
set_row ( + + rw , TR ( " TOTALE " ) ) ;
1996-02-06 16:02:59 +00:00
if ( tot_imponib ! = ZERO )
set_row ( rw , " @29g%r " , & tot_imponib ) ;
if ( tot_imposta ! = ZERO )
set_row ( rw , " @45g%r " , & tot_imposta ) ;
1998-04-30 15:59:34 +00:00
if ( _tipo_stampa ! = prova )
1996-02-06 16:02:59 +00:00
{
if ( tot_imponibp ! = ZERO )
set_row ( rw , " @81g%r " , & tot_imponibp ) ;
if ( tot_impostap ! = ZERO )
set_row ( rw , " @98g%r " , & tot_impostap ) ;
}
1996-02-23 15:27:42 +00:00
tot_imponib = tot_imposta = tot_imponibp = tot_impostap = ZERO ;
1996-02-06 16:02:59 +00:00
rw + = 2 ;
}
2006-12-13 16:22:33 +00:00
if ( tipodet ! = tdetprec )
1996-02-06 16:02:59 +00:00
{
2003-03-25 13:56:11 +00:00
set_row ( rw + + , TR ( " ----- Indetraibile su op.es. ----- " ) ) ;
set_row ( rw , TR ( " Cod. " ) ) ;
1996-02-06 16:02:59 +00:00
rw + + ;
2003-03-25 13:56:11 +00:00
set_row ( rw , FR ( " iva Descrizione@34gImponibile@53gImposta " ) ) ;
if ( _tipo_stampa ! = prova ) set_row ( rw , FR ( " @86gImponibile@106gImposta " ) ) ;
2000-05-05 15:25:49 +00:00
rw + = 2 ;
1996-02-06 16:02:59 +00:00
}
rw = setta_riga ( rw , riga , tot_imponib , tot_imposta , tot_imponibp , tot_impostap ) ;
2006-12-13 16:22:33 +00:00
tdetprec = tipodet ;
1996-02-06 16:02:59 +00:00
break ;
case 3 :
if ( tdetprec = = 1 | | tdetprec = = 9 )
{
2003-03-25 13:56:11 +00:00
set_row ( + + rw , TR ( " TOTALE " ) ) ;
1996-02-06 16:02:59 +00:00
if ( tot_imponib ! = ZERO )
set_row ( rw , " @29g%r " , & tot_imponib ) ;
if ( tot_imposta ! = ZERO )
set_row ( rw , " @45g%r " , & tot_imposta ) ;
1998-04-30 15:59:34 +00:00
if ( _tipo_stampa ! = prova )
1996-02-06 16:02:59 +00:00
{
if ( tot_imponibp ! = ZERO )
set_row ( rw , " @81g%r " , & tot_imponibp ) ;
if ( tot_impostap ! = ZERO )
set_row ( rw , " @98g%r " , & tot_impostap ) ;
}
1996-02-23 15:27:42 +00:00
tot_imponib = tot_imposta = tot_imponibp = tot_impostap = ZERO ;
1996-02-06 16:02:59 +00:00
rw + = 2 ;
}
2006-12-13 16:22:33 +00:00
if ( tipodet ! = tdetprec )
1996-02-06 16:02:59 +00:00
{
2003-03-25 13:56:11 +00:00
set_row ( rw + + , TR ( " ----- Passaggi interni ----- " ) ) ;
set_row ( rw , TR ( " Cod. " ) ) ;
1996-02-06 16:02:59 +00:00
rw + + ;
2003-03-25 13:56:11 +00:00
set_row ( rw , FR ( " iva Descrizione@34gImponibile@53gImposta " ) ) ;
1998-04-30 15:59:34 +00:00
if ( _tipo_stampa ! = prova )
2003-03-25 13:56:11 +00:00
set_row ( rw , FR ( " @86gImponibile@106gImposta " ) ) ;
2000-05-05 15:25:49 +00:00
rw + = 2 ;
1996-02-06 16:02:59 +00:00
}
rw = setta_riga ( rw , riga , tot_imponib , tot_imposta , tot_imponibp , tot_impostap ) ;
2006-12-13 16:22:33 +00:00
tdetprec = tipodet ;
1996-02-06 16:02:59 +00:00
break ;
case 9 :
if ( tdetprec = = 1 | | tdetprec = = 3 )
{
2003-03-25 13:56:11 +00:00
set_row ( + + rw , TR ( " TOTALE " ) ) ;
1996-02-06 16:02:59 +00:00
if ( tot_imponib ! = ZERO )
set_row ( rw , " @29g%r " , & tot_imponib ) ;
if ( tot_imposta ! = ZERO )
set_row ( rw , " @45g%r " , & tot_imposta ) ;
1998-04-30 15:59:34 +00:00
if ( _tipo_stampa ! = prova )
1996-02-06 16:02:59 +00:00
{
if ( tot_imponibp ! = ZERO )
set_row ( rw , " @81g%r " , & tot_imponibp ) ;
if ( tot_impostap ! = ZERO )
set_row ( rw , " @98g%r " , & tot_impostap ) ;
}
1996-02-23 15:27:42 +00:00
tot_imponib = tot_imposta = tot_imponibp = tot_impostap = ZERO ;
1996-02-06 16:02:59 +00:00
rw + = 2 ;
}
2006-12-13 16:22:33 +00:00
if ( tipodet ! = tdetprec )
1996-02-06 16:02:59 +00:00
{
2003-03-25 13:56:11 +00:00
set_row ( rw + + , TR ( " ----- N.D. 9 - acquisti indeducibili per ART.19 ----- " ) ) ;
set_row ( rw , TR ( " Cod. " ) ) ;
1996-02-06 16:02:59 +00:00
rw + + ;
2003-03-25 13:56:11 +00:00
set_row ( rw , FR ( " iva Descrizione@34gImponibile@53gImposta " ) ) ;
1998-04-30 15:59:34 +00:00
if ( _tipo_stampa ! = prova )
2003-03-25 13:56:11 +00:00
set_row ( rw , FR ( " @86gImponibile@106gImposta " ) ) ;
2000-05-05 15:25:49 +00:00
rw + = 2 ;
1996-02-06 16:02:59 +00:00
}
rw = setta_riga ( rw , riga , tot_imponib , tot_imposta , tot_imponibp , tot_impostap ) ;
2006-12-13 16:22:33 +00:00
tdetprec = tipodet ;
1996-02-06 16:02:59 +00:00
break ;
default : break ;
}
}
if ( _iva_array . items ( ) > 0 )
if ( tdetprec = = 1 | | tdetprec = = 3 | | tdetprec = = 9 )
{
2003-03-25 13:56:11 +00:00
set_row ( + + rw , TR ( " TOTALE " ) ) ;
1996-02-06 16:02:59 +00:00
if ( tot_imponib ! = ZERO )
set_row ( rw , " @29g%r " , & tot_imponib ) ;
if ( tot_imposta ! = ZERO )
set_row ( rw , " @45g%r " , & tot_imposta ) ;
1998-04-30 15:59:34 +00:00
if ( _tipo_stampa ! = prova )
1996-02-06 16:02:59 +00:00
{
if ( tot_imponibp ! = ZERO )
set_row ( rw , " @81g%r " , & tot_imponibp ) ;
if ( tot_impostap ! = ZERO )
set_row ( rw , " @98g%r " , & tot_impostap ) ;
}
}
_iva_array . destroy ( ) ;
rw + + ;
return rw ;
}
1995-07-31 09:49:11 +00:00
1998-04-30 15:59:34 +00:00
void TStampa_registri_app : : set_page_tot_reg ( )
1996-02-06 16:02:59 +00:00
{
2012-11-30 14:36:30 +00:00
int rr = 1 ;
2012-10-26 09:12:52 +00:00
rr = stampa_prospetto ( rr , false ) ;
2012-11-30 14:36:30 +00:00
2004-05-12 14:48:33 +00:00
//*****deve azzerare i totali progressivi dei riporti e segnalare all'header di non stampare
//la riga di riporto
_totali_stampati = true ; //siamo in stampa totali, quindi...
_riporti_stampati = false ; //inoltre non deve stapare riporti mentre stampa i totali
_totdoc_prog = 0 ;
_totimpn_prog = 0 ;
_totimps_prog = 0 ;
1996-02-06 16:02:59 +00:00
if ( _esiste_riga_iva & & _stampa )
{
1998-04-30 15:59:34 +00:00
for ( int prospetto = 0 ; prospetto < 2 ; prospetto + + )
1995-07-31 09:49:11 +00:00
{
1998-04-30 15:59:34 +00:00
TRiga_array & array = prospetto = = 0 ? _tot_iva_array : _tot_prec_iva_array ;
real tot_imponib , tot_imposta , tot_lordo , tot_imponibp , tot_impostap , tot_lordop ;
tot_imponib = tot_imposta = tot_lordo = tot_imponibp = tot_impostap = tot_lordop = ZERO ;
array . sort ( compare_rows ) ; //viene ordinato per codice iva
for ( int k = 0 ; k < array . items ( ) ; k + + ) // Mamma mia, mamma mia...
{
TRiga & riga = ( TRiga & ) array [ k ] ;
1999-04-26 15:58:05 +00:00
2012-11-30 14:36:30 +00:00
if ( _tipo_stampa = = prova & & riga . _imponibile . is_zero ( ) & & riga . _imposta . is_zero ( ) & & riga . _implordo . is_zero ( ) )
1999-04-26 15:58:05 +00:00
continue ;
1998-04-30 15:59:34 +00:00
set_row ( rr , " %-4s " , ( const char * ) riga . _codiva ) ;
2006-12-13 16:22:33 +00:00
const TString & descr = descr_iva ( riga . _codiva ) ;
1998-04-30 15:59:34 +00:00
set_row ( rr , " @5g%-.23s " , ( const char * ) descr ) ;
if ( riga . _imponibile ! = ZERO )
set_row ( rr , " @29g%r " , & riga . _imponibile ) ;
if ( riga . _imposta ! = ZERO )
set_row ( rr , " @45g%r " , & riga . _imposta ) ;
if ( _tipo_reg = = vendita & & _corrispettivi )
if ( riga . _implordo ! = ZERO )
set_row ( rr , " @65g%r " , & riga . _implordo ) ;
if ( _tipo_stampa ! = prova )
{
if ( riga . _imponibilep ! = ZERO )
set_row ( rr , " @81g%r " , & riga . _imponibilep ) ;
if ( riga . _impostap ! = ZERO )
set_row ( rr , " @98g%r " , & riga . _impostap ) ;
if ( _tipo_reg = = vendita & & _corrispettivi )
if ( riga . _implordop ! = ZERO )
set_row ( rr , " @116g%r " , & riga . _implordop ) ;
}
rr + + ;
tot_imponib + = riga . _imponibile ;
tot_imposta + = riga . _imposta ;
tot_lordo + = riga . _implordo ;
tot_imponibp + = riga . _imponibilep ;
tot_impostap + = riga . _impostap ;
tot_lordop + = riga . _implordop ;
}
array . destroy ( ) ; // Azzera il marciume
rr + + ;
2003-03-25 13:56:11 +00:00
set_row ( rr , TR ( " TOTALE " ) ) ;
1998-04-30 15:59:34 +00:00
if ( tot_imponib ! = ZERO )
set_row ( rr , " @29g%r " , & tot_imponib ) ;
if ( tot_imposta ! = ZERO )
set_row ( rr , " @45g%r " , & tot_imposta ) ;
if ( _tipo_reg = = vendita & & _corrispettivi )
if ( tot_lordo ! = ZERO )
set_row ( rr , " @65g%r " , & tot_lordo ) ;
if ( _tipo_stampa ! = prova )
{
if ( tot_imponibp ! = ZERO )
set_row ( rr , " @81g%r " , & tot_imponibp ) ;
if ( tot_impostap ! = ZERO )
set_row ( rr , " @98g%r " , & tot_impostap ) ;
if ( _tipo_reg = = vendita & & _corrispettivi )
if ( tot_lordop ! = ZERO )
set_row ( rr , " @116g%r " , & tot_lordop ) ;
}
if ( prospetto = = 0 ) // Solo per il primo prospetto complessivo
{
if ( _tipo_reg = = acquisto )
rr = stampa_acquisti ( rr ) ;
else
rr + = 3 ;
if ( _tot_prec_iva_array . items ( ) > 0 )
2012-10-26 09:12:52 +00:00
rr = stampa_prospetto ( rr , true ) ; // Prospetto per progressivi da periodo precedente
1998-04-30 15:59:34 +00:00
else
break ;
1995-07-31 09:49:11 +00:00
}
1998-04-30 15:59:34 +00:00
} // for
1996-02-06 16:02:59 +00:00
}
2012-11-30 14:36:30 +00:00
1999-04-06 15:34:39 +00:00
if ( _stampa_plafonds )
1996-02-06 16:02:59 +00:00
stampa_plafonds ( rr ) ;
}
1995-07-31 09:49:11 +00:00
1999-07-16 14:59:11 +00:00
HIDDEN void print_real ( TPrintrow & row , const real & num , int pos )
{
const TCurrency cur ( num ) ;
2012-10-26 09:12:52 +00:00
TString80 str = cur . string ( true ) ;
1999-07-16 14:59:11 +00:00
str . right_just ( 15 ) ;
row . put ( str , pos ) ;
}
1999-05-24 13:34:11 +00:00
bool TStampa_registri_app : : stampa_plafonds ( int r , bool test_mode )
1996-02-06 16:02:59 +00:00
{
2012-11-30 14:36:30 +00:00
TTable pla ( " %PLA " ) ;
TTable ppa ( " PPA " ) ;
1996-02-06 16:02:59 +00:00
TString80 chiave ;
int num ;
1999-04-06 15:34:39 +00:00
real r1 , r2 , r3 , r8 , r8b , r9 , disponibile ;
1996-02-06 16:02:59 +00:00
r1 = r2 = r3 = ZERO ;
1998-04-30 15:59:34 +00:00
if ( _tipo_stampa = = libro_unico )
1996-02-06 16:02:59 +00:00
num = _fino_a_mese ;
1999-04-06 15:34:39 +00:00
if ( _tipo_stampa = = bollato | | _tipo_stampa = = prova | | _tipo_stampa = = rif_giornale )
1996-02-06 16:02:59 +00:00
num = _datareg . month ( ) ;
1998-02-24 10:31:42 +00:00
TString16 nm ; nm . format ( " %02d " , num ) ;
1996-02-06 16:02:59 +00:00
// forza il tipoatt a 1
chiave . format ( " %05ld " , get_firm ( ) ) ;
chiave < < _annoes ;
chiave < < _codatt < < " 1 " ;
pla . put ( " CODTAB " , chiave ) ;
1999-04-06 15:34:39 +00:00
const bool print_now = r = = - 1 ;
TPrintrow riga ;
TPrinter & pr = printer ( ) ;
1996-02-06 16:02:59 +00:00
if ( pla . read ( ) = = NOERR )
{
1999-04-06 15:34:39 +00:00
r1 = pla . get_real ( " R5 " ) ; //totali esp. art.8
r2 = pla . get_real ( " R6 " ) ; //totali esp. art.8 bis
r3 = pla . get_real ( " R7 " ) ; //totali esp. art 9
r8 = stampa_valori_plafonds ( r1 , num , ppa , " 1 " ) ; // Disponibile art. 8
r8b = stampa_valori_plafonds ( r2 , num , ppa , " 2 " ) ; // Disponibile art. 8 bis
r9 = stampa_valori_plafonds ( r3 , num , ppa , " 3 " ) ; // Disponibile art. 9
disponibile = r8 + r8b + r9 ;
1996-02-06 16:02:59 +00:00
}
1999-05-24 13:34:11 +00:00
const bool print_prospect = ( r1 > ZERO | | r2 > ZERO | | r3 > ZERO ) & & disponibile > ZERO ;
if ( test_mode )
return print_prospect ;
if ( print_prospect )
1996-02-06 16:02:59 +00:00
{
1999-04-06 15:34:39 +00:00
if ( print_now )
{
riga . reset ( ) ;
pr . print ( riga ) ;
2003-03-25 13:56:11 +00:00
riga . put ( TR ( " QUADRO RELATIVO ALLA DISPONIBILITA' E UTILIZZAZIONE MENSILE DEI PLAFONDS " ) , 0 ) ;
1999-04-06 15:34:39 +00:00
pr . print ( riga ) ;
}
else
{
2003-03-25 13:56:11 +00:00
set_row ( + + r , TR ( " QUADRO RELATIVO ALLA DISPONIBILITA' E UTILIZZAZIONE MENSILE DEI PLAFONDS " ) ) ;
1999-04-06 15:34:39 +00:00
r + + ;
}
1996-02-06 16:02:59 +00:00
TString mese ( 9 ) ;
mese = itom ( num ) ;
mese . right_just ( ) ;
1999-04-06 15:34:39 +00:00
if ( print_now )
{
riga . reset ( ) ;
pr . print ( riga ) ;
riga . put ( ( const char * ) mese , 0 ) ;
2003-03-25 13:56:11 +00:00
riga . put ( TR ( " Disponibile " ) , 35 ) ;
1999-07-16 14:59:11 +00:00
print_real ( riga , disponibile , 55 ) ;
1999-04-06 15:34:39 +00:00
pr . print ( riga ) ;
}
else
{
2003-03-25 13:56:11 +00:00
set_row ( + + r , FR ( " %s@35gDisponibile @55g%r " ) , ( const char * ) mese , & disponibile ) ;
1999-04-06 15:34:39 +00:00
set_row ( + + r , " " ) ;
r + + ;
}
1996-02-06 16:02:59 +00:00
}
1999-04-06 15:34:39 +00:00
else
2012-10-26 09:12:52 +00:00
return false ;
1996-02-06 16:02:59 +00:00
1998-04-30 15:59:34 +00:00
const bool is_bollato = _tipo_stampa = = bollato ;
1996-02-06 16:02:59 +00:00
if ( r1 > ZERO )
{
1998-04-30 15:59:34 +00:00
if ( r8 > ZERO & & is_bollato | | ! is_bollato & & ! r8 . is_zero ( ) )
1996-02-06 16:02:59 +00:00
{
real pri = ZERO ;
real pre = ZERO ;
chiave = " " ;
chiave < < _annoes < < _codatt < < " 1 " < < nm < < " 1 " ;
ppa . put ( " CODTAB " , chiave ) ;
if ( ppa . read ( ) = = NOERR )
{
pri = ppa . get_real ( " R0 " ) ;
pre = ppa . get_real ( " R1 " ) ;
}
chiave = " " ;
chiave < < _annoes < < _codatt < < " 2 " < < nm < < " 1 " ;
ppa . put ( " CODTAB " , chiave ) ;
if ( ppa . read ( ) = = NOERR )
{
pri + = ppa . get_real ( " R0 " ) ;
pre + = ppa . get_real ( " R1 " ) ;
}
1999-04-06 15:34:39 +00:00
disponibile - = pri + pre ;
if ( print_now )
{
riga . reset ( ) ;
pr . print ( riga ) ;
riga . reset ( ) ;
2003-03-25 13:56:11 +00:00
riga . put ( TR ( " ART. 8 1<> comma lettere a-b " ) , 0 ) ;
1999-04-06 15:34:39 +00:00
pr . print ( riga ) ;
riga . reset ( ) ;
2003-03-25 13:56:11 +00:00
riga . put ( TR ( " Utilizzato all'interno " ) , 0 ) ;
1999-07-16 14:59:11 +00:00
print_real ( riga , pri , 55 ) ;
1999-04-06 15:34:39 +00:00
pr . print ( riga ) ;
riga . reset ( ) ;
2003-03-25 13:56:11 +00:00
riga . put ( TR ( " Utilizzato per l'importazione " ) , 0 ) ;
1999-07-16 14:59:11 +00:00
print_real ( riga , pre , 55 ) ;
1999-04-06 15:34:39 +00:00
pr . print ( riga ) ;
}
else
{
2003-03-25 13:56:11 +00:00
set_row ( r + + , TR ( " ART. 8 1<> comma lettere a-b " ) ) ;
set_row ( r + + , FR ( " Utilizzato all'interno@55g%r " ) , & pri ) ;
set_row ( r + + , FR ( " Utilizzato per l'importazione@55g%r " ) , & pre ) ;
1999-04-06 15:34:39 +00:00
}
1996-02-06 16:02:59 +00:00
}
}
if ( r2 > ZERO )
{
1998-04-30 15:59:34 +00:00
if ( r8b > ZERO & & is_bollato | | ! is_bollato & & ! r8b . is_zero ( ) )
1996-02-06 16:02:59 +00:00
{
real pri = ZERO ;
real pre = ZERO ;
chiave = " " ;
chiave < < _annoes < < _codatt < < " 1 " < < nm < < " 2 " ;
ppa . put ( " CODTAB " , chiave ) ;
if ( ppa . read ( ) = = NOERR )
{
pri = ppa . get_real ( " R0 " ) ;
pre = ppa . get_real ( " R1 " ) ;
}
chiave = " " ;
chiave < < _annoes < < _codatt < < " 2 " < < nm < < " 2 " ;
ppa . put ( " CODTAB " , chiave ) ;
if ( ppa . read ( ) = = NOERR )
{
pri + = ppa . get_real ( " R0 " ) ;
pre + = ppa . get_real ( " R1 " ) ;
}
1999-04-06 15:34:39 +00:00
disponibile - = pri + pre ;
1996-02-06 16:02:59 +00:00
r + + ;
1999-04-06 15:34:39 +00:00
if ( print_now )
{
riga . reset ( ) ;
pr . print ( riga ) ; pr . print ( riga ) ;
2003-03-25 13:56:11 +00:00
riga . put ( TR ( " ART. 8 bis 1<> comma " ) , 0 ) ;
1999-04-06 15:34:39 +00:00
pr . print ( riga ) ;
riga . reset ( ) ;
2003-03-25 13:56:11 +00:00
riga . put ( TR ( " Utilizzato all'interno " ) , 0 ) ;
1999-07-16 14:59:11 +00:00
print_real ( riga , pri , 55 ) ;
1999-04-06 15:34:39 +00:00
pr . print ( riga ) ;
riga . reset ( ) ;
2003-03-25 13:56:11 +00:00
riga . put ( TR ( " Utilizzato per l'importazione " ) , 0 ) ;
1999-07-16 14:59:11 +00:00
print_real ( riga , pre , 55 ) ;
1999-04-06 15:34:39 +00:00
pr . print ( riga ) ;
}
else
{
2003-03-25 13:56:11 +00:00
set_row ( r + + , TR ( " ART. 8 bis 1<> comma " ) ) ;
set_row ( r + + , FR ( " Utilizzato all'interno@55g%r " ) , & pri ) ;
set_row ( r + + , FR ( " Utilizzato per l'importazione@55g%r " ) , & pre ) ;
1999-04-06 15:34:39 +00:00
}
1996-02-06 16:02:59 +00:00
}
}
if ( r3 > ZERO )
{
1998-04-30 15:59:34 +00:00
if ( r9 > ZERO & & is_bollato | | ! is_bollato & & ! r9 . is_zero ( ) )
1996-02-06 16:02:59 +00:00
{
real pri = ZERO ;
real pre = ZERO ;
chiave = " " ;
chiave < < _annoes < < _codatt < < " 1 " < < nm < < " 3 " ;
ppa . put ( " CODTAB " , chiave ) ;
if ( ppa . read ( ) = = NOERR )
{
pri = ppa . get_real ( " R0 " ) ;
pre = ppa . get_real ( " R1 " ) ;
}
chiave = " " ;
chiave < < _annoes < < _codatt < < " 2 " < < nm < < " 3 " ;
ppa . put ( " CODTAB " , chiave ) ;
if ( ppa . read ( ) = = NOERR )
{
pri + = ppa . get_real ( " R0 " ) ;
pre + = ppa . get_real ( " R1 " ) ;
}
1999-04-06 15:34:39 +00:00
disponibile - = pri + pre ;
1996-02-06 16:02:59 +00:00
r + + ;
1999-04-06 15:34:39 +00:00
if ( print_now )
{
riga . reset ( ) ;
pr . print ( riga ) ; pr . print ( riga ) ;
2003-03-25 13:56:11 +00:00
riga . put ( TR ( " ART. 9 1<> comma " ) , 0 ) ;
1999-04-06 15:34:39 +00:00
pr . print ( riga ) ;
riga . reset ( ) ;
2003-03-25 13:56:11 +00:00
riga . put ( TR ( " Utilizzato all'interno " ) , 0 ) ;
1999-07-16 14:59:11 +00:00
print_real ( riga , pri , 55 ) ;
1999-04-06 15:34:39 +00:00
pr . print ( riga ) ;
riga . reset ( ) ;
2003-03-25 13:56:11 +00:00
riga . put ( TR ( " Utilizzato per l'importazione " ) , 0 ) ;
1999-07-16 14:59:11 +00:00
print_real ( riga , pre , 55 ) ;
1999-04-06 15:34:39 +00:00
pr . print ( riga ) ;
}
else
{
2003-03-25 13:56:11 +00:00
set_row ( r + + , TR ( " ART. 9 1<> comma " ) ) ;
set_row ( r + + , FR ( " Utilizzato all'interno@55g%r " ) , & pri ) ;
set_row ( r + + , FR ( " Utilizzato per l'importazione@55g%r " ) , & pre ) ;
1999-04-06 15:34:39 +00:00
}
1996-02-06 16:02:59 +00:00
}
}
1999-04-06 15:34:39 +00:00
if ( r1 > ZERO | | r2 > ZERO | | r3 > ZERO )
if ( print_now )
{
riga . reset ( ) ;
pr . print ( riga ) ;
2003-03-25 13:56:11 +00:00
riga . put ( TR ( " Riporto " ) , 35 ) ;
1999-07-16 14:59:11 +00:00
print_real ( riga , disponibile , 55 ) ;
1999-04-06 15:34:39 +00:00
pr . print ( riga ) ;
}
else
2003-03-25 13:56:11 +00:00
set_row ( + + r , FR ( " @35gRiporto @55g%r " ) , & disponibile ) ;
2012-10-26 09:12:52 +00:00
return true ;
1996-02-06 16:02:59 +00:00
}
1998-04-30 15:59:34 +00:00
real TStampa_registri_app : : stampa_valori_plafonds ( const real & r1 , const int mese , TTable & ppa , const char * tipo )
1996-02-06 16:02:59 +00:00
{
real r , si8 , se8 ;
TString80 chiave ;
int i ;
r = r1 ;
si8 = se8 = ZERO ;
if ( mese > 1 )
{
for ( i = 1 ; i < mese ; i + + )
{
chiave = " " ;
1998-02-24 10:31:42 +00:00
TString16 m ; m . format ( " %02d " , i ) ;
1996-02-06 16:02:59 +00:00
chiave < < _annoes < < _codatt < < " 1 " < < m < < tipo ;
ppa . put ( " CODTAB " , chiave ) ;
if ( ppa . read ( ) = = NOERR )
{
si8 + = ppa . get_real ( " R0 " ) ;
se8 + = ppa . get_real ( " R1 " ) ;
}
chiave = " " ;
chiave < < _annoes < < _codatt < < " 2 " < < m < < tipo ;
ppa . put ( " CODTAB " , chiave ) ;
if ( ppa . read ( ) = = NOERR )
{
si8 + = ppa . get_real ( " R0 " ) ;
se8 + = ppa . get_real ( " R1 " ) ;
}
}
r = r1 - si8 - se8 ;
}
return r ;
}
2012-11-30 14:36:30 +00:00
bool TStampa_registri_app : : some_IVAxCassa ( ) const
{
if ( _tipo_reg ! = vendita & & _tipo_reg ! = acquisto )
return false ;
int da_mese = _data_da . month ( ) ;
int a_mese = _data_a . month ( ) ;
if ( _frequiva = = ' T ' )
{
const int dr = da_mese % 3 ;
if ( dr ! = 1 )
da_mese - = ( dr = = 0 ? 2 : 1 ) ;
const int ar = a_mese % 3 ;
if ( ar ! = 0 )
a_mese + = ( ar = = 1 ? 2 : 1 ) ;
}
TString query ;
query = " USE IVADIFF KEY 2 SELECT (TIPOMOV>2) " ;
query < < " \n FROM ANNOLIQ= " < < _data_da . year ( ) < < " MESELIQ= " < < da_mese ;
query < < " \n TO ANNOLIQ= " < < _data_a . year ( ) < < " MESELIQ= " < < a_mese ;
TISAM_recordset id ( query ) ;
return id . items ( ) > 0 ;
}
bool TStampa_registri_app : : print_IVAxCassa ( int month )
{
if ( _tipo_reg ! = vendita & & _tipo_reg ! = acquisto )
return false ;
TPrinter & pr = printer ( ) ;
TPrintrow riga ;
const TString linea ( _stampa_width , ' - ' ) ;
TString query ;
query = " USE IVADIFF SELECT (BETWEEN(DATAREGP,#DAL,#AL))&&(MOV.REG=#REG)&&(TIPOMOV>2)&&(STR(IMPONIBILE>0))&&(STR(MESELIQ==#MON)) " ;
query < < " \n BY DATAREGP DATAREG " ;
query < < " \n JOIN MOV INTO NUMREG==NUMREG " ;
query < < " \n JOIN CLIFO TO MOV INTO TIPOCF==TIPO CODCF==CODCF " ;
TISAM_recordset id ( query ) ;
id . set_var ( " #DAL " , _data_da ) ;
id . set_var ( " #AL " , _data_a ) ;
id . set_var ( " #REG " , _codreg ) ;
id . set_var ( " #MON " , long ( month ) ) ;
// Sporco trucco per evitare intestazioni inutili
const bool il = _intesta_liq ;
_intesta_liq = true ;
if ( id . items ( ) > 0 )
{
riga . reset ( ) ;
riga . put ( linea , 0 ) ;
pr . print ( riga ) ;
riga . reset ( ) ;
if ( _tipo_reg = = vendita )
riga . put ( TR ( " DETTAGLIO INCASSI FATTURE CON IVA DIFFERITA O PER CASSA " ) , 40 ) ;
else
riga . put ( TR ( " DETTAGLIO PAGAMENTI FATTURE CON IVA DIFFERITA O PER CASSA " ) , 40 ) ;
pr . print ( riga ) ;
riga . reset ( ) ; pr . print ( riga ) ;
riga . put ( linea , 0 ) ; pr . print ( riga ) ;
riga . reset ( ) ;
riga . put ( TR ( " Documento " ) , 19 ) ;
riga . put ( TR ( " T Tipo " ) , 66 ) ;
riga . put ( TR ( " Forz " ) , 123 ) ;
riga . put ( TR ( " Num " ) , 128 ) ;
pr . print ( riga ) ;
riga . reset ( ) ;
riga . put ( TR ( " Data pag. prot. " ) , 0 ) ;
riga . put ( TR ( " Data " ) , 17 ) ;
riga . put ( TR ( " Numero Codice Ragione Sociale " ) , 24 ) ;
riga . put ( TR ( " O Doc. " ) , 66 ) ;
riga . put ( TR ( " Importo " ) , 78 ) ;
riga . put ( TR ( " Imponibile " ) , 90 ) ;
riga . put ( TR ( " IVA " ) , 102 ) ;
riga . put ( TR ( " Imposta " ) , 115 ) ;
riga . put ( TR ( " Scad " ) , 123 ) ;
riga . put ( TR ( " Reg " ) , 128 ) ;
pr . print ( riga ) ;
riga . put ( linea , 0 ) ; pr . print ( riga ) ;
const TRectype & rec = id . cursor ( ) - > curr ( ) ;
for ( bool ok = id . move_first ( ) ; ok ; ok = id . move_next ( ) )
{
const TString4 codiva = rec . get ( " CODIVA " ) ;
const real importo = rec . get ( " IMPORTO " ) ;
const real imponibile = rec . get ( " IMPONIBILE " ) ;
const real imposta = rec . get ( " IMPOSTA " ) ;
TParagraph_string clifo ( id . get ( " CLIFO.RAGSOC " ) . as_string ( ) , 27 ) ;
riga . reset ( ) ;
riga . put ( rec . get_date ( " DATAREGP " ) . string ( brief , ' / ' ) , 0 ) ;
riga . put ( format ( " %6ld " , id . get ( " MOV.PROTIVA " ) . as_int ( ) ) , 8 ) ;
riga . put ( rec . get_date ( MOV_DATAREG ) . string ( brief , ' / ' ) , 15 ) ;
riga . put ( id . get ( " MOV.NUMDOC " ) . as_string ( ) , 24 ) ;
riga . put ( format ( " %6ld " , id . get ( " CLIFO.CODCF " ) . as_int ( ) ) , 31 ) ;
riga . put ( clifo . get ( ) , 38 ) ;
riga . put ( rec . get_int ( " TIPODIFF " ) = = 2 ? " 5 " : " 4 " , 66 ) ; // 4 = Differita; 5 = x Cassa
riga . put ( id . get ( " MOV.TIPODOC " ) . as_string ( ) , 68 ) ;
print_real ( riga , importo , 70 ) ;
print_real ( riga , imponibile , 85 ) ;
riga . put ( rec . get ( " CODIVA " ) , 102 ) ;
print_real ( riga , imposta , 107 ) ;
riga . put ( rec . get_int ( " NUMPRO " ) > = 999 ? " X " : " " , 123 ) ;
riga . put ( format ( " %6ld " , rec . get_long ( MOV_NUMREG ) ) , 125 ) ;
pr . print ( riga ) ;
_riga_prospettoXcassa . add_riga ( ZERO , ZERO , imponibile , imposta , codiva , 0 , 0 , false , 0 ) ;
}
}
if ( _riga_prospettoXcassa . items ( ) < = 0 )
return id . items ( ) > 0 ; // Ho stampato qualcosa?
riga . reset ( ) ;
if ( pr . rows_left ( ) < _riga_prospettoXcassa . items ( ) + 5 )
{
pr . formfeed ( ) ;
riga . put ( linea , 0 ) ;
}
pr . print ( riga ) ;
riga . reset ( ) ;
riga . put ( TR ( " PROSPETTO IMPORTI CON IVA ORDINARIA ED IVA DIFFERITA O PER CASSA " ) , 40 ) ;
pr . print ( riga ) ;
riga . reset ( ) ;
pr . print ( riga ) ;
riga . reset ( ) ;
riga . put ( TR ( " IVA Descrizione " ) , 0 ) ;
riga . put ( TR ( " Imponibile " ) , 34 ) ;
riga . put ( TR ( " Imposta " ) , 53 ) ;
riga . put ( TR ( " Imponibile diff. " ) , 84 ) ;
riga . put ( TR ( " Imposta diff. " ) , 109 ) ;
pr . print ( riga ) ;
real tot_imponib , tot_imposta , tot_imponibp , tot_impostap ;
_riga_prospettoXcassa . sort ( compare_righeiva ) ;
for ( int s = 0 ; s < _riga_prospettoXcassa . items ( ) ; s + + )
{
const TRigaiva & ri = _riga_prospettoXcassa . riga ( s ) ;
riga . reset ( ) ;
riga . put ( ri . _codiva , 0 ) ;
riga . put ( descr_iva ( ri . _codiva ) , 5 ) ;
print_real ( riga , ri . _imponibile , 29 ) ;
print_real ( riga , ri . _imposta , 45 ) ;
print_real ( riga , ri . _imponibilep , 85 ) ;
print_real ( riga , ri . _impostap , 107 ) ;
pr . print ( riga ) ;
tot_imponib + = ri . _imponibile ;
tot_imposta + = ri . _imposta ;
tot_imponibp + = ri . _imponibilep ;
tot_impostap + = ri . _impostap ;
}
riga . reset ( ) ;
pr . print ( riga ) ;
riga . put ( TR ( " TOTALE " ) , 0 ) ;
print_real ( riga , tot_imponib , 29 ) ;
print_real ( riga , tot_imposta , 45 ) ;
print_real ( riga , tot_imponibp , 85 ) ;
print_real ( riga , tot_impostap , 107 ) ;
pr . print ( riga ) ;
_riga_prospettoXcassa . destroy ( ) ;
_intesta_liq = il ; // Ripristina flag intestazioni
return true ;
}
1996-02-06 16:02:59 +00:00
//********* PRINT!!! *********//
1998-04-30 15:59:34 +00:00
bool TStampa_registri_app : : preprocess_print ( int file , int counter )
1996-02-06 16:02:59 +00:00
{
if ( file = = LF_MOV )
{
long items = _cur - > items ( ) ;
if ( ! items )
2012-10-26 09:12:52 +00:00
return false ;
1996-02-06 16:02:59 +00:00
_iva_array . destroy ( ) ;
_riga_rmi . destroy ( ) ;
_tot_iva_array . destroy ( ) ;
1998-04-30 15:59:34 +00:00
_tot_prec_iva_array . destroy ( ) ;
1996-02-06 16:02:59 +00:00
_doc_array . destroy ( ) ;
_dataregp = " " ;
2012-10-26 09:12:52 +00:00
_esiste_riga_iva = false ;
_auto_intraf = false ;
_intesta_liq = false ;
1996-02-06 16:02:59 +00:00
set_print_zero ( ) ;
}
2012-10-26 09:12:52 +00:00
return true ;
1996-02-06 16:02:59 +00:00
}
1998-04-30 15:59:34 +00:00
bool TStampa_registri_app : : preprocess_page ( int file , int counter )
1996-02-06 16:02:59 +00:00
{
if ( file = = LF_MOV )
{
2012-10-26 09:12:52 +00:00
if ( counter ) return true ;
1995-07-31 09:49:11 +00:00
1996-02-06 16:02:59 +00:00
reset_print ( ) ;
int rr = 0 , riga = 0 ;
bool intra ;
2002-02-26 16:20:19 +00:00
TString80 comune , prov , comcf , capcf , civcf , stacf ;
TString80 viacf ;
TString ragsoc , codfis , piva ;
2012-11-30 14:36:30 +00:00
TString4 tipo_op = " " ;
1996-02-06 16:02:59 +00:00
TLocalisamfile & mov = _cur - > file ( LF_MOV ) ;
TLocalisamfile & caus = _cur - > file ( LF_CAUSALI ) ;
1995-07-31 09:49:11 +00:00
1996-02-06 16:02:59 +00:00
_datareg = mov . get_date ( MOV_DATAREG ) ;
1995-07-31 09:49:11 +00:00
1998-04-30 15:59:34 +00:00
if ( _tipo_stampa ! = libro_unico & & _liquidazione )
1996-02-06 16:02:59 +00:00
{
2000-10-03 13:45:12 +00:00
const int da = ( _tipo_stampa = = prova ) ? _data_da . month ( ) : 1 ;
const int a = _datareg . month ( ) ;
1996-02-06 16:02:59 +00:00
for ( int m = da ; m < a ; m + + )
{
if ( ! _st_liq [ m ] )
if ( stampo_liquidazione ( m ) )
{
_datareg = TDate ( 1 , m , _annoes ) ; // Meglio cosi'
TFilename t ;
t . temp ( " reg " ) ;
if ( _scelta = = B0_settato | | _scelta = = prosegui_stampa )
{
1998-04-30 15:59:34 +00:00
if ( _tipo_stampa = = prova )
1996-02-06 16:02:59 +00:00
send_message ( ' S ' , t , m ) ;
1998-04-30 15:59:34 +00:00
else
send_message ( ' s ' , t , m ) ;
1996-02-06 16:02:59 +00:00
}
else //_scelta == prosegui_cal_stampa
{
1998-04-30 15:59:34 +00:00
if ( _tipo_stampa = = prova )
1996-02-06 16:02:59 +00:00
send_message ( ' L ' , t , m ) ;
1998-04-30 15:59:34 +00:00
else
send_message ( ' l ' , t , m ) ;
1996-02-06 16:02:59 +00:00
}
1998-02-24 10:31:42 +00:00
if ( t . exist ( ) )
1996-02-06 16:02:59 +00:00
{
2012-10-26 09:12:52 +00:00
_intesta_liq = true ;
1996-02-06 16:02:59 +00:00
if ( ! _mov_empty ) printer ( ) . formfeed ( ) ;
2012-10-26 09:12:52 +00:00
merge_export_file ( t , false , true ) ;
_intesta_liq = false ;
1996-02-06 16:02:59 +00:00
reset_print ( ) ;
remove ( t ) ;
}
}
2012-10-26 09:12:52 +00:00
_st_liq [ m ] = true ;
1996-02-06 16:02:59 +00:00
}
}
_datareg = mov . get_date ( MOV_DATAREG ) ;
2012-10-26 09:12:52 +00:00
_mov_empty = false ;
1996-02-06 16:02:59 +00:00
if ( _datareg . month ( ) ! = _dataregp . month ( ) & & _dataregp . ok ( ) )
{
2012-10-26 09:12:52 +00:00
_auto_intraf = false ;
1996-02-06 16:02:59 +00:00
printer ( ) . formfeed ( ) ;
2004-05-12 14:48:33 +00:00
_totali_stampati = false ; //siamo al cambio periodo (mese/trimestre),quindi resetto il flag di stampa totali
_riporti_stampati = false ; //e pure quello dei riporti,visto che "A Riporto" non va nella prima pagina del mese
1996-02-06 16:02:59 +00:00
}
_dataregp = _datareg ;
TDate datadoc = mov . get_date ( MOV_DATADOC ) ;
long numreg = mov . get_long ( MOV_NUMREG ) ;
long protiva = mov . get_long ( MOV_PROTIVA ) ;
1996-12-11 09:18:21 +00:00
long uprotiva = mov . get_long ( MOV_UPROTIVA ) ;
1996-02-06 16:02:59 +00:00
TString16 numdoc = mov . get ( MOV_NUMDOC ) ;
1998-04-30 15:59:34 +00:00
int meseliq = mov . get_int ( MOV_MESELIQ ) ;
1996-02-06 16:02:59 +00:00
char tipocf = mov . get ( MOV_TIPO ) [ 0 ] ;
TString16 ocfpi = mov . get ( MOV_OCFPI ) ;
long codcf = mov . get_long ( MOV_CODCF ) ;
long numgio = mov . get_long ( MOV_NUMGIO ) ;
bool stampato = mov . get_bool ( MOV_REGST ) ;
2012-11-30 14:36:30 +00:00
TString4 codval = mov . get ( MOV_CODVALI ) ;
1996-02-06 16:02:59 +00:00
real corrval = mov . get_real ( MOV_CORRVALUTA ) ;
2012-11-30 14:36:30 +00:00
const bool autof = caus . get_bool ( CAU_AUTOFATT ) ;
const bool liqdiff = mov . get_bool ( MOV_LIQDIFF ) ;
const bool IVAxcassa = ! liqdiff & & mov . get_bool ( MOV_IVAXCASSA ) ;
1996-02-06 16:02:59 +00:00
TString80 descrcau = caus . get ( CAU_DESCR ) ;
2000-05-05 15:25:49 +00:00
real totdoc = mov . get_real ( MOV_TOTDOC ) ;
real ritsoc = mov . get_real ( MOV_RITSOC ) ;
real ritfis = mov . get_real ( MOV_RITFIS ) ;
if ( totdoc < ZERO ) // Controlla il segno corretto da assegnare alle ritenute
{
ritsoc = - ritsoc ;
ritfis = - ritfis ;
}
1996-02-06 16:02:59 +00:00
if ( _cur - > pos ( ) = = 0 )
_uprotivap = uprotiva ? uprotiva : protiva ;
//aggiornamento di mov
1998-04-30 15:59:34 +00:00
if ( _tipo_stampa ! = prova )
1996-02-06 16:02:59 +00:00
if ( ! stampato )
{
2012-10-26 09:12:52 +00:00
mov . put ( MOV_REGST , true ) ;
1996-02-06 16:02:59 +00:00
mov . rewrite ( ) ;
}
if ( codcf = = 0l )
ragsoc = descrcau ;
else
{
1997-04-02 11:02:16 +00:00
ocfpi . trim ( ) ;
comune = " " ;
prov = " " ;
if ( ocfpi . empty ( ) )
1996-02-06 16:02:59 +00:00
{
TRectype dep = ricerca_cf ( tipocf , codcf ) ;
ragsoc = dep . get ( CLI_RAGSOC ) ;
viacf = dep . get ( CLI_INDCF ) ;
civcf = dep . get ( CLI_CIVCF ) ;
capcf = dep . get ( CLI_CAPCF ) ;
comcf = dep . get ( CLI_COMCF ) ;
1997-04-02 11:02:16 +00:00
comune = dep . get ( CLI_LOCCF ) ;
1997-10-22 12:24:43 +00:00
stacf = dep . get ( CLI_STATOCF ) ;
2002-02-26 16:20:19 +00:00
codfis = dep . get ( CLI_COFI ) ;
piva = dep . get ( CLI_STATOPAIV ) ;
if ( piva . not_empty ( ) )
piva < < ' ' ;
piva < < dep . get ( CLI_PAIV ) ;
1996-02-06 16:02:59 +00:00
char tipoa = dep . get_char ( CLI_TIPOAPER ) ;
if ( tipoa = = ' F ' )
{
TString80 cognome , nome ;
cognome = ragsoc . mid ( 0 , 30 ) ;
nome = ragsoc . mid ( 30 , 20 ) ;
cognome . trim ( ) ; nome . trim ( ) ;
ragsoc = cognome ;
ragsoc < < " " < < nome ;
}
}
else
{
2000-10-03 13:45:12 +00:00
const TRectype & dep = ricerca_occ ( ocfpi ) ;
1996-02-06 16:02:59 +00:00
ragsoc = dep . get ( OCC_RAGSOC ) ;
viacf = dep . get ( OCC_INDIR ) ;
civcf = dep . get ( OCC_CIV ) ;
capcf = dep . get ( OCC_CAP ) ;
comcf = dep . get ( OCC_COM ) ;
1997-10-22 12:24:43 +00:00
stacf = dep . get ( OCC_STATO ) ;
2002-02-26 16:20:19 +00:00
codfis = " " ;
piva = " " ;
1996-02-06 16:02:59 +00:00
}
2000-10-03 13:45:12 +00:00
const TRectype & com = look_comuni ( stacf , comcf ) ;
1997-04-02 11:02:16 +00:00
if ( ! com . empty ( ) )
{
comune = com . get ( COM_DENCOM ) ;
prov = com . get ( COM_PROVCOM ) ;
}
1996-02-06 16:02:59 +00:00
}
_tipodoc = mov . get ( MOV_TIPODOC ) ;
_descr_doc = descr_doc ( ) ;
TString app ( datadoc . string ( brief , ' / ' ) ) ;
1996-12-10 10:42:46 +00:00
totdoc + = ritsoc + ritfis ;
if ( _st_tot_fin )
1996-02-06 16:02:59 +00:00
_doc_array . add_riga ( _tipodoc , _descr_doc , totdoc ) ;
//setto le righe di stampa
_r = 1 ;
2004-05-12 14:48:33 +00:00
1996-02-06 16:02:59 +00:00
if ( ! _stampa_data_reg )
set_row ( _r , " %s " , ( const char * ) _datareg . string ( brief , ' / ' ) ) ;
set_row ( _r , " @9g%5ld " , protiva ) ;
if ( datadoc . ok ( ) )
set_row ( _r , " @15g%s " , ( const char * ) app ) ;
set_row ( _r , " @24g%s " , ( const char * ) numdoc ) ;
if ( codcf ! = 0l )
set_row ( _r , " @31g%6ld " , codcf ) ;
1998-04-30 15:59:34 +00:00
if ( meseliq > 0 )
set_row ( _r , " @62g%02d " , meseliq ) ;
1996-02-06 16:02:59 +00:00
set_row ( _r , " @68g%2s " , ( const char * ) _tipodoc ) ;
if ( _stampa_width = = 132 )
set_row ( _r , " @70g%r " , & totdoc ) ;
2004-05-12 14:48:33 +00:00
else
set_row ( _r , " @78g%r " , & totdoc ) ;
1998-04-30 15:59:34 +00:00
if ( _tipo_stampa = = prova ) //in caso di stampa di prova
2002-02-26 16:20:19 +00:00
{
1998-04-30 15:59:34 +00:00
if ( ! ( _tipo_reg = = vendita & & _corrispettivi ) ) //e se non si tratta di registro vendite corrispettivi
2002-02-26 16:20:19 +00:00
{
if ( _cur - > pos ( ) ! = 0 | | protiva < = 0 ) //il primo movimento non va controllato
1996-02-06 16:02:59 +00:00
{
if ( protiva ! = _uprotivap + 1 )
{
2012-11-30 14:36:30 +00:00
set_row ( _r + 1 , FR ( " @b*** NUM.PROT.FUORI SEQUENZA@r " ) ) ;
1996-02-06 16:02:59 +00:00
riga = _r + 2 ;
}
_uprotivap = uprotiva ? uprotiva : protiva ;
}
2002-02-26 16:20:19 +00:00
}
2012-11-30 14:36:30 +00:00
if ( mov . get_bool ( MOV_IVAXCASSA ) & & mov . get_int ( MOV_TIPOMOV ) < = 0 )
{
set_row ( _r + 1 , FR ( " @b*** IVA PER CASSA SENZA SALDACONTO@r " ) ) ;
riga = _r + 2 ;
}
2002-02-26 16:20:19 +00:00
}
1996-02-06 16:02:59 +00:00
const char * r ;
int i = 1 ;
2003-03-25 13:56:11 +00:00
TParagraph_string desc ( ragsoc , 23 ) ;
while ( ( r = desc . get ( ) ) ! = NULL )
1996-02-06 16:02:59 +00:00
{
set_row ( i , " @38g%s " , r ) ;
i + + ;
}
if ( i > riga ) riga = i ;
if ( codcf ! = 0l & & _stampa_ind_comp )
{
1996-02-23 15:27:42 +00:00
if ( viacf . not_empty ( ) )
1996-02-06 16:02:59 +00:00
{
1998-04-30 15:59:34 +00:00
set_row ( i + + , " @38g%-.23s %-3s " , ( const char * ) viacf , ( const char * ) civcf ) ;
1996-02-23 15:27:42 +00:00
if ( comune . not_empty ( ) )
1998-04-30 15:59:34 +00:00
set_row ( i + + , " @38g%s %-.21s (%2s) " , ( const char * ) capcf , ( const char * ) comune , ( const char * ) prov ) ;
riga = i ;
1996-02-06 16:02:59 +00:00
}
else if ( comune . not_empty ( ) )
{
1998-04-30 15:59:34 +00:00
set_row ( i + + , " @38g%s %-.21s (%2s) " , ( const char * ) capcf , ( const char * ) comune , ( const char * ) prov ) ;
riga = i ;
2002-02-26 16:20:19 +00:00
}
if ( codfis . not_empty ( ) | | piva . not_empty ( ) )
{
if ( codfis . not_empty ( ) & & codfis ! = piva )
2003-03-25 13:56:11 +00:00
set_row ( i + + , FR ( " @38gC.F. %s " ) , ( const char * ) codfis ) ;
2002-02-26 16:20:19 +00:00
if ( piva . not_empty ( ) )
2003-03-25 13:56:11 +00:00
set_row ( i + + , FR ( " @38gP.I. %s " ) , ( const char * ) piva ) ;
2002-02-26 16:20:19 +00:00
riga = i ;
}
1996-02-06 16:02:59 +00:00
}
2004-11-30 22:02:59 +00:00
//progressivi righe iva azzerati
_progr_doc = 0 ;
_progr_impn = 0 ;
_progr_imps = 0 ;
1998-04-30 15:59:34 +00:00
const TRecnotype nrec = riga_rmoviva ( ) ;
if ( nrec > 0L )
1996-02-06 16:02:59 +00:00
{
2012-10-26 09:12:52 +00:00
_esiste_riga_iva = true ;
1996-02-06 16:02:59 +00:00
for ( int j = 0 ; j < _riga_rmi . items ( ) ; j + + )
{
2006-12-13 16:22:33 +00:00
const TRigaiva & riga = _riga_rmi . riga ( j ) ;
2007-01-03 17:07:40 +00:00
const int tipodet = riga . _tipodet ;
1996-02-06 16:02:59 +00:00
rr = _r + j ;
intra = riga . _intra ;
if ( _stampa_width = = 132 )
{
set_row ( rr , " @85g%r " , & riga . _imponibile ) ;
set_row ( rr , " @101g%4s " , ( const char * ) riga . _codiva ) ;
1998-04-30 15:59:34 +00:00
if ( _tipo_reg = = acquisto )
2006-12-13 16:22:33 +00:00
set_row ( rr , " @106g%d " , tipodet ) ;
1996-02-06 16:02:59 +00:00
set_row ( rr , " @107g%r " , & riga . _imposta ) ;
2004-05-12 14:48:33 +00:00
1996-02-06 16:02:59 +00:00
set_row ( rr , " @123g%d " , riga . _tipocr ) ;
1998-04-30 15:59:34 +00:00
if ( _tipoatt = = " E " & & _tipo_reg ! = acquisto )
1996-02-06 16:02:59 +00:00
set_row ( rr , " @125g%d " , riga . _tipoatt ) ;
1998-04-30 15:59:34 +00:00
if ( _tipo_stampa = = rif_giornale ) //stampa con riferimento al libro giornale
1996-02-06 16:02:59 +00:00
set_row ( rr , " @126g%5ld " , numgio ) ;
}
else //stampa a 198
{
set_row ( rr , " @93g%r " , & riga . _imponibile ) ;
2004-05-12 14:48:33 +00:00
1996-02-06 16:02:59 +00:00
set_row ( rr , " @109g%4s " , ( const char * ) riga . _codiva ) ;
1998-04-30 15:59:34 +00:00
if ( _tipo_reg = = acquisto )
2006-12-13 16:22:33 +00:00
set_row ( rr , " @114g%d " , tipodet ) ;
1996-02-06 16:02:59 +00:00
set_row ( rr , " @116g%r " , & riga . _imposta ) ;
2004-05-12 14:48:33 +00:00
1998-04-30 15:59:34 +00:00
if ( _tipoatt = = " E " & & _tipo_reg ! = acquisto )
1996-02-06 16:02:59 +00:00
set_row ( rr , " @132g%d " , riga . _tipoatt ) ;
set_row ( rr , " @134g%d " , riga . _tipocr ) ;
1998-04-30 15:59:34 +00:00
if ( _tipo_stampa = = rif_giornale ) //stampa con riferimento al libro giornale
1996-02-06 16:02:59 +00:00
set_row ( rr , " @136g%7ld " , numgio ) ;
2004-11-30 22:02:59 +00:00
}
//*****Calcolo dei progressivi (un casino mondiale!!!)
_progr_impn + = riga . _imponibile ;
_progr_imps + = riga . _imposta ;
}
//*****aggiornamento del totale documento,imponibile e imposta progressivi
const real totdoc = mov . get_real ( MOV_TOTDOC ) ;
_progr_doc = totdoc ;
if ( _rows_left > 0 )
{
_totdoc_prog + = _progr_doc ; //progressivo totale documento
_totimpn_prog + = _progr_impn ; // " imponibile
_totimps_prog + = _progr_imps ; // " imposta
}
1996-02-06 16:02:59 +00:00
_riga_rmi . destroy ( ) ;
}
2012-11-30 14:36:30 +00:00
if ( intra & & autof )
1996-02-06 16:02:59 +00:00
{
2012-10-26 09:12:52 +00:00
_auto_intraf = true ;
1996-02-06 16:02:59 +00:00
tipo_op = " 3 " ;
}
else if ( intra )
tipo_op = " 1 " ;
else if ( autof )
tipo_op = " 2 " ;
2008-02-05 12:33:52 +00:00
else if ( liqdiff )
tipo_op = " 4 " ;
2012-11-30 14:36:30 +00:00
else if ( IVAxcassa )
tipo_op = " 5 " ;
1996-02-06 16:02:59 +00:00
2012-11-30 14:36:30 +00:00
set_row ( _r , " @66g%s " , ( const char * ) tipo_op ) ;
1996-02-06 16:02:59 +00:00
1998-04-30 15:59:34 +00:00
if ( _tipo_stampa = = prova ) //stampa di prova
1996-02-06 16:02:59 +00:00
{
if ( _stampa_width = = 132 )
{
set_row ( _r , " @126g%5ld " , numreg ) ;
if ( stampato )
set_row ( _r , " @131g* " ) ; //solo in stampa di prova!
}
else //198
{
set_row ( _r , " @136g%7ld " , numreg ) ;
if ( stampato )
set_row ( _r , " @144g* " ) ;
}
}
1998-04-30 15:59:34 +00:00
if ( _tipo_stampa = = rif_giornale & & _stampa_width = = 198 )
1996-02-06 16:02:59 +00:00
{
TLocalisamfile rmoviva ( LF_RMOVIVA ) ;
rmoviva . zero ( ) ;
rmoviva . put ( RMI_NUMREG , numreg ) ;
TRectype rec ( rmoviva . curr ( ) ) ;
rmoviva . read ( _isgteq ) ;
for ( ; ! rmoviva . eof ( ) ; rmoviva . next ( ) )
{
if ( rmoviva . curr ( ) ! = rec ) break ;
int gruppo = rmoviva . get_int ( " GRUPPO " ) ;
int conto = rmoviva . get_int ( " CONTO " ) ;
long sottoc = rmoviva . get_long ( " SOTTOCONTO " ) ;
1997-06-19 14:33:52 +00:00
TBill tc ( gruppo , conto , sottoc ) ;
1996-02-06 16:02:59 +00:00
TString80 descr = tc . descrizione ( ) ;
set_row ( _r , " @144g%3d %3d %6d " , gruppo , conto , sottoc ) ;
set_row ( _r , " @159g%-.39s " , ( const char * ) descr ) ;
break ;
}
}
2012-11-30 14:36:30 +00:00
if ( riga < = rr )
riga = + + rr ;
1996-02-06 16:02:59 +00:00
2012-11-30 14:36:30 +00:00
if ( ! corrval . is_zero ( ) )
1999-07-16 14:59:11 +00:00
{
TCurrency curr ( corrval , codval ) ;
2012-10-26 09:12:52 +00:00
TString80 vall = curr . string ( true ) ;
1999-07-16 14:59:11 +00:00
vall . right_just ( 19 ) ;
2012-11-30 14:36:30 +00:00
set_row ( riga , FR ( " @24gCodice valuta %-3s Corrispettivo in valuta %s " ) , ( const char * ) codval , ( const char * ) vall ) ;
1996-02-06 16:02:59 +00:00
}
}
2012-10-26 09:12:52 +00:00
return true ;
1996-02-06 16:02:59 +00:00
}
1998-04-30 15:59:34 +00:00
print_action TStampa_registri_app : : postprocess_page ( int file , int counter )
1996-02-06 16:02:59 +00:00
{
if ( file = = LF_MOV )
{
if ( counter ) //dopo aver fatto un REPEAT_PAGE (cioe' dopo aver stampato
//le righe settate in set_page_tot_reg()), in pratica a rottura di mese o alla fine
{
2004-05-12 14:48:33 +00:00
reset_print ( ) ;
1999-04-26 15:58:05 +00:00
2012-11-30 14:36:30 +00:00
const TRecnotype pos = _cur - > pos ( ) ;
const TRecnotype items = _cur - > items ( ) ;
1999-04-26 15:58:05 +00:00
const bool last_mov = pos = = items - 1 ;
1999-05-24 13:34:11 +00:00
if ( _stampa_plafonds & & ! last_mov )
1999-04-26 15:58:05 +00:00
{
// Nel caso sia richiesta la stampa prospetto mensile plafond e vi siano mesi
// senza movimenti, <20> necessario forzarne la stampa
2012-11-30 14:36:30 +00:00
const TDate save_date ( _datareg ) ;
1999-04-26 15:58:05 +00:00
// Caso speciale, in cui non vi siano movimenti sull'ultimo mese indicato in stampa
1999-05-24 13:34:11 +00:00
//const bool print_over = last_mov && _dataregp == _dataregs && _dataregp.month() < _data_a.month();
1999-04-26 15:58:05 +00:00
const int m1 = _dataregp . month ( ) + 1 ;
1999-05-24 13:34:11 +00:00
const int m2 = _dataregs . month ( ) ;
1999-04-26 15:58:05 +00:00
for ( int kk = m1 ; kk < m2 ; kk + + )
{
_datareg = TDate ( 1 , kk , _annoes ) ;
2012-10-26 09:12:52 +00:00
if ( stampa_plafonds ( - 1 , true ) )
1999-05-24 13:34:11 +00:00
{
printer ( ) . formfeed ( ) ;
stampa_plafonds ( - 1 ) ;
}
1999-04-26 15:58:05 +00:00
}
_datareg = save_date ;
}
2012-11-30 14:36:30 +00:00
if ( last_mov )
{
printer ( ) . formfeed ( ) ;
print_IVAxCassa ( _datareg . month ( ) ) ;
}
1996-02-06 16:02:59 +00:00
if ( _liquidazione )
2012-11-30 14:36:30 +00:00
{
1996-02-06 16:02:59 +00:00
if ( ! _st_liq [ _datareg . month ( ) ] & & stampo_liquidazione ( _datareg . month ( ) ) )
{
2012-10-26 09:12:52 +00:00
_st_liq [ _datareg . month ( ) ] = true ;
1996-02-06 16:02:59 +00:00
if ( _scelta = = B0_settato )
liq_b0_settato ( ) ;
if ( _scelta = = prosegui_stampa | | _scelta = = prosegui_cal_stampa )
{
1998-02-24 10:31:42 +00:00
if ( _t . exist ( ) )
1996-02-06 16:02:59 +00:00
{
printer ( ) . formfeed ( ) ;
2012-10-26 09:12:52 +00:00
_intesta_liq = true ;
merge_export_file ( _t , false , true ) ;
_intesta_liq = false ;
1996-02-06 16:02:59 +00:00
remove ( _t ) ;
}
}
}
2012-11-30 14:36:30 +00:00
}
1999-04-26 15:58:05 +00:00
if ( last_mov )
1996-02-06 16:02:59 +00:00
{
1999-05-24 13:34:11 +00:00
if ( _stampa_plafonds | | ( _tipo_stampa ! = libro_unico & & _liquidazione ) )
1996-02-06 16:02:59 +00:00
stampa_liq_mesi_succ ( ) ;
1998-04-30 15:59:34 +00:00
if ( _tipo_stampa ! = prova )
1996-02-06 16:02:59 +00:00
{
int da = _datareg . month ( ) + 1 ;
int a = _data_a . month ( ) ;
for ( int m = da ; m < = a ; m + + )
{
TDate data ( 1 , m , _annoes ) ;
data . set_end_month ( ) ;
scrivi_reg ( data ) ;
}
}
}
}
2004-11-30 22:02:59 +00:00
else
1996-02-06 16:02:59 +00:00
{
2004-11-30 22:02:59 +00:00
const TRectype & mov = _cur - > curr ( LF_MOV ) ;
const TRecnotype pos = _cur - > pos ( ) ;
const long items = _cur - > items ( ) ;
const bool FINITO = ( pos = = items - 1 ) ;
1996-02-06 16:02:59 +00:00
if ( FINITO )
{
liq_other_case ( ) ;
1998-04-30 15:59:34 +00:00
if ( _tipo_stampa ! = prova )
1996-02-06 16:02:59 +00:00
calcola_progressivi ( ) ;
set_page_tot_reg ( ) ;
return REPEAT_PAGE ;
}
else
{
_cur - > save_status ( ) ;
+ + ( * _cur ) ;
_dataregs = mov . get_date ( MOV_DATAREG ) ;
- - ( * _cur ) ;
_cur - > restore_status ( ) ;
if ( _dataregs . month ( ) ! = _dataregp . month ( ) )
{
liq_other_case ( ) ;
1998-04-30 15:59:34 +00:00
if ( _tipo_stampa ! = prova )
1996-02-06 16:02:59 +00:00
calcola_progressivi ( ) ;
set_page_tot_reg ( ) ;
return REPEAT_PAGE ;
}
}
2004-11-30 22:02:59 +00:00
}
1996-02-06 16:02:59 +00:00
}
return NEXT_PAGE ;
}
//--------- Intestazione (un casino allucinante!!!) ---------//
1998-04-30 15:59:34 +00:00
int TStampa_registri_app : : stampa_intestazione ( )
1996-02-06 16:02:59 +00:00
{
int r = 1 ;
TString riga ( _stampa_width ) ;
get_dati_ditta ( ) ;
2003-03-25 13:56:11 +00:00
riga . format ( FR ( " Ditta %ld %s %s %s %s %s " ) , get_firm ( ) ,
1996-02-06 16:02:59 +00:00
( const char * ) _ragsoc , ( const char * ) _viafis ,
( const char * ) _cap , ( const char * ) _comunefis ,
( const char * ) _provfis ) ;
2002-12-20 16:15:03 +00:00
set_header ( r + + , riga ) ;
2003-02-25 14:39:02 +00:00
riga . format ( " " ) ;
1998-04-30 15:59:34 +00:00
if ( _tipo_stampa = = prova )
1996-02-06 16:02:59 +00:00
{
2003-03-25 13:56:11 +00:00
riga . format ( FR ( " REGISTRO DI PROVA Data %s " ) , TDate ( TODAY ) . string ( ) ) ;
2002-12-20 16:15:03 +00:00
riga . right_just ( _stampa_width ) ;
1996-02-06 16:02:59 +00:00
}
1998-02-24 10:31:42 +00:00
TString80 tmp ;
2003-03-25 13:56:11 +00:00
tmp . format ( FR ( " Partita iva %s Codice fiscale %s " ) , ( const char * ) _paiva , ( const char * ) _cofi ) ;
1998-02-24 10:31:42 +00:00
riga . overwrite ( tmp ) ;
1996-02-06 16:02:59 +00:00
set_header ( r , riga ) ;
return r ;
}
1998-04-30 15:59:34 +00:00
void TStampa_registri_app : : preprocess_header ( )
1996-02-06 16:02:59 +00:00
{
int r = 1 ;
char cor , nd1 , nd2 ;
char tipo = ' ' ;
char type = ' ' ;
int mese , anno ;
1998-04-30 15:59:34 +00:00
if ( _tipo_stampa ! = libro_unico )
1996-02-06 16:02:59 +00:00
{
mese = _datareg . month ( ) ;
anno = _datareg . year ( ) ;
}
else //se _tipo_stampa == 3 (su libro unico) sto stampando un solo mese
{
mese = _fino_a_mese ;
anno = _annoes ;
}
2012-11-30 14:36:30 +00:00
TString data ;
if ( mese > 0 )
data . format ( FR ( " mese di %s %d " ) , itom ( mese ) , anno ) ;
1996-02-06 16:02:59 +00:00
reset_header ( ) ;
1998-04-30 15:59:34 +00:00
if ( _tipo_stampa = = bollato | | _tipo_stampa = = rif_giornale )
1996-02-06 16:02:59 +00:00
{
if ( _stampa_ind_ditta )
r = stampa_intestazione ( ) ;
1996-09-26 10:59:10 +00:00
else
r + = 2 ;
1996-02-06 16:02:59 +00:00
}
2012-11-30 14:36:30 +00:00
else // se stampa di prova o su libro unico l'intestazione della ditta va sempre stampata
1996-02-06 16:02:59 +00:00
r = stampa_intestazione ( ) ;
2002-12-20 16:15:03 +00:00
if ( _stampa_num_pag ) // Stampa numero di pagina in alto a destra
{
TString16 numpag , riga ;
numpag . format ( " %d/%d " , _annoes , _numini + printer ( ) . getcurrentpage ( ) ) ;
const int tab = _stampa_width - numpag . len ( ) ;
riga . format ( " @%dg%s " , tab , ( const char * ) numpag ) ;
set_header ( 1 , riga ) ; // Sempre sulla prima riga!
}
1998-04-30 15:59:34 +00:00
if ( _tipo_stampa = = libro_unico & & ! _intesta_vidi )
1996-02-06 16:02:59 +00:00
{
+ + _u_stampata ;
+ + _pagine_stampate ;
}
1998-04-30 15:59:34 +00:00
if ( _tipo_stampa = = bollato | | _tipo_stampa = = rif_giornale )
1996-02-06 16:02:59 +00:00
+ + _pagine_stampate ;
1998-04-30 15:59:34 +00:00
if ( _tipo_stampa = = libro_unico )
2003-03-25 13:56:11 +00:00
set_header ( r , FR ( " @94gProgr.Studio %ld@114gProgr.Utente %ld " ) , _u_stampata , _pagine_stampate ) ;
1996-02-06 16:02:59 +00:00
2012-11-30 14:36:30 +00:00
// cosi' sono sicura che l'aggiornamento viene fatto ad ogni salto pagina (cioe' a rottura di mese)
2004-05-12 14:48:33 +00:00
if ( _tipo_stampa ! = prova )
aggiorna_reg ( _ok_vidi ) ;
1996-02-06 16:02:59 +00:00
r + + ;
if ( ! _intesta_vidi )
{
if ( _intesta_liq )
2003-03-25 13:56:11 +00:00
set_header ( r , FR ( " Registro IVA: %s %s %s " ) , ( const char * ) _codreg ,
1996-02-06 16:02:59 +00:00
( const char * ) _desc_lib , ( const char * ) data ) ;
2008-03-11 16:48:19 +00:00
else
{
if ( _annoes > 2007 )
{
TString key ;
key . format ( " %ld|%s " , _ditta , ( const char * ) _codatt ) ;
const TString16 codateco = cache ( ) . get ( LF_ATTIV , key , ATT_CODATECO ) ;
set_header ( r , FR ( " Registro IVA: %s %s %s Attivita \' %s %s " ) ,
( const char * ) _codreg , ( const char * ) _desc_lib ,
( const char * ) data , ( const char * ) codateco ,
( const char * ) _attivita ) ;
}
else
set_header ( r , FR ( " Registro IVA: %s %s %s Attivita \' %s %s " ) ,
( const char * ) _codreg , ( const char * ) _desc_lib ,
( const char * ) data , ( const char * ) _codatt ,
( const char * ) _attivita ) ;
}
1996-02-06 16:02:59 +00:00
}
else
{
2003-03-25 13:56:11 +00:00
set_header ( r + + , FR ( " Registro IVA: %s %s " ) , ( const char * ) _codreg , ( const char * ) _desc_lib ) ;
set_header ( r , TR ( " RIFERIMENTI VIDIMAZIONE " ) ) ;
1996-02-06 16:02:59 +00:00
}
1998-04-30 15:59:34 +00:00
//se sto stampando sul registro la liquidazione
//l'intestazione (piuttosto dettagliata) e' gestita
//dal prg di liquidazione perche' molte info che devono
//comparire in questa intestazione la stampa reg. non le conosce.
2012-11-30 14:36:30 +00:00
const TString riga ( _stampa_width , ' - ' ) ;
1998-04-30 15:59:34 +00:00
//non sto stampando la liquidazione
if ( ! _intesta_liq )
1996-02-06 16:02:59 +00:00
{
r + + ;
2004-05-12 14:48:33 +00:00
set_header ( r + + , riga ) ;
1998-04-30 15:59:34 +00:00
if ( _tipo_reg = = vendita ) //registro vendite
1996-02-06 16:02:59 +00:00
{
2012-11-30 14:36:30 +00:00
cor = ' R ' ; // Ricavi
1996-02-06 16:02:59 +00:00
nd1 = ' ' ;
nd2 = ' ' ;
}
1998-04-30 15:59:34 +00:00
if ( _tipo_reg = = acquisto )
1996-02-06 16:02:59 +00:00
{
2012-11-30 14:36:30 +00:00
cor = ' C ' ; // Cessioni
1996-02-06 16:02:59 +00:00
nd1 = ' N ' ;
nd2 = ' D ' ;
}
if ( _tipoatt = = " E " ) //attivita' mista
{
tipo = ' A ' ;
type = ' T ' ;
}
2012-10-26 09:12:52 +00:00
if ( _tipo_stampa = = prova ) //stampa di prova (_intesta_vidi e' di sicuro false)
1996-02-06 16:02:59 +00:00
{
1998-04-30 15:59:34 +00:00
if ( _tipo_reg = = riepilogativo )
2003-03-25 13:56:11 +00:00
set_header ( r + + , TR ( " RIEPILOGO TOTALI REGISTRI IVA " ) ) ;
1996-02-06 16:02:59 +00:00
else
{
if ( _stampa_width = = 132 )
{
2003-03-25 13:56:11 +00:00
set_header ( r , FR ( " @10gNum.@19gDocumento@61gMese@66gT Tipo@102gCod %c@123gT %c@128gNum " ) , nd1 , tipo ) ;
1996-02-06 16:02:59 +00:00
r + + ;
2003-03-25 13:56:11 +00:00
set_header ( r , FR ( " Data reg. prot.@17gData@24gNumero Codice Ragione sociale/descr. liq.@66gO Doc.@74gTotale doc.@90gImponibile Iva %c@115gImposta@123g%c %c@128gReg " ) , nd2 , cor , type ) ;
1996-02-06 16:02:59 +00:00
r + + ;
}
else //stampa a 198
{
2003-03-25 13:56:11 +00:00
set_header ( r , FR ( " Registrazione Documento@61gMese@66gT Tipo@110gCod %c@132g%c T@139gNum. " ) , nd1 , tipo , cor ) ;
1996-02-06 16:02:59 +00:00
r + + ;
2003-03-25 13:56:11 +00:00
set_header ( r , FR ( " Data Protocollo Data@24gNumero Codice Ragione sociale/descr. liq.@66gO Documento@80gTot.Documento@98gImponibile Iva %c@124gImposta@132g%c %c@139gReg. " ) , nd2 , type , cor ) ;
1996-02-06 16:02:59 +00:00
r + + ;
}
}
}
else if ( ! _intesta_vidi )
1995-07-31 09:49:11 +00:00
{
1998-04-30 15:59:34 +00:00
if ( _tipo_reg = = riepilogativo )
2003-03-25 13:56:11 +00:00
set_header ( r + + , TR ( " RIEPILOGO TOTALI REGISTRI IVA " ) ) ;
1996-02-06 16:02:59 +00:00
else
{
if ( _stampa_width = = 132 )
1995-07-31 09:49:11 +00:00
{
2003-03-25 13:56:11 +00:00
set_header ( r , FR ( " @10gNum.@19gDocumento@61gMese@66gT Tipo@102gCod %c@123gT %c " ) , nd1 , tipo ) ;
1998-04-30 15:59:34 +00:00
if ( _tipo_stampa = = rif_giornale ) //stampa definitiva con rif. al libro giornale
2003-03-25 13:56:11 +00:00
set_header ( r , FR ( " @128gNum. " ) ) ;
1996-02-06 16:02:59 +00:00
r + + ;
2003-03-25 13:56:11 +00:00
set_header ( r , FR ( " Data reg. prot.@17gData@24gNumero Codice Ragione sociale/descr. liq.@66gO Doc.@74gTotale doc.@90gImponibile Iva %c@115gImposta@123g%c %c " ) ,
1996-02-06 16:02:59 +00:00
nd2 , cor , type ) ;
1998-04-30 15:59:34 +00:00
if ( _tipo_stampa = = rif_giornale )
2003-03-25 13:56:11 +00:00
set_header ( r , FR ( " @128gop. " ) ) ;
1996-02-06 16:02:59 +00:00
r + + ;
1995-07-31 09:49:11 +00:00
}
1996-02-06 16:02:59 +00:00
else //stampa a 198
1995-07-31 09:49:11 +00:00
{
2003-03-25 13:56:11 +00:00
set_header ( r , FR ( " Registrazione Documento@61gMese@66gT Tipo@110gCod %c@132g%c T " ) , nd1 , tipo ) ;
1998-04-30 15:59:34 +00:00
if ( _tipo_stampa = = rif_giornale )
2003-03-25 13:56:11 +00:00
set_header ( r , FR ( " @139gNum. " ) ) ;
1996-02-06 16:02:59 +00:00
r + + ;
2003-03-25 13:56:11 +00:00
set_header ( r , FR ( " Data Protocollo Data@24gNumero Codice Ragione sociale/descr. liq.@66gO Documento@80gTot.Documento@98gImponibile Iva %c@124gImposta@132g%c %c " ) , nd2 , type , cor ) ;
1998-04-30 15:59:34 +00:00
if ( _tipo_stampa = = rif_giornale )
2003-03-25 13:56:11 +00:00
set_header ( r , FR ( " @139gop. @144gCodice conto @159gDescrizione sottoconto " ) ) ;
1996-02-06 16:02:59 +00:00
r + + ;
1995-07-31 09:49:11 +00:00
}
1996-02-06 16:02:59 +00:00
}
}
1998-04-30 15:59:34 +00:00
else if ( _tipo_stampa = = libro_unico & & _intesta_vidi )
1996-02-06 16:02:59 +00:00
{
TString tr ( 52 ) ;
tr . fill ( ' - ' ) ;
2003-03-25 13:56:11 +00:00
set_header ( r + + , FR ( " @10gPagine studio Pagine utente ---------------- V I D I M A Z I O N E %s " ) , ( const char * ) tr ) ;
set_header ( r + + , FR ( " Mese@12gda@20ga@27gda@35ga Intestatario@71gN.fogli Pag.in. Pag.fin. Data Ufficio " ) ) ;
1995-07-31 09:49:11 +00:00
}
1998-04-30 15:59:34 +00:00
if ( _tipo_reg ! = riepilogativo )
1996-02-06 16:02:59 +00:00
if ( _stampa_ind_comp & & ! _intesta_vidi )
2003-03-25 13:56:11 +00:00
set_header ( r + + , FR ( " @38gGeneralita' " ) ) ;
2004-05-12 14:48:33 +00:00
set_header ( r + + , riga ) ;
//*****valori della riga Riporto
if ( _riporti_stampati )
{
if ( _stampa_width = = 132 )
2004-11-30 22:02:59 +00:00
set_header ( r + + , FR ( " @0gRiporto progressivi@70g%15s@85g%15s@107g%15s " ) ,
_totdoc_prog . string ( " .2 " ) , _totimpn_prog . string ( " .2 " ) , _totimps_prog . string ( " .2 " ) ) ;
2004-05-12 14:48:33 +00:00
if ( _stampa_width = = 198 )
2004-11-30 22:02:59 +00:00
set_header ( r + + , FR ( " @0gRiporto progressivi@78g%15s@93g%15s@116g%15s " ) ,
_totdoc_prog . string ( " .2 " ) , _totimpn_prog . string ( " .2 " ) , _totimps_prog . string ( " .2 " ) ) ;
2004-05-12 14:48:33 +00:00
2004-11-30 22:02:59 +00:00
if ( _rows_left = = 0 )
{
_totdoc_prog + = _progr_doc ;
_totimpn_prog + = _progr_impn ;
_totimps_prog + = _progr_imps ;
}
2004-05-12 14:48:33 +00:00
set_header ( r + + , riga ) ;
_totali_stampati = false ;
}
1996-02-06 16:02:59 +00:00
}
}
1995-07-31 09:49:11 +00:00
2004-05-12 14:48:33 +00:00
void TStampa_registri_app : : preprocess_footer ( )
{
reset_footer ( ) ;
if ( ! _totali_stampati )
{
int r = 1 ;
TString riga ( _stampa_width ) ;
riga . fill ( ' - ' ) ;
set_footer ( r + + , riga ) ;
2004-11-30 22:02:59 +00:00
2004-05-12 14:48:33 +00:00
if ( _stampa_width = = 132 )
2004-11-30 22:02:59 +00:00
set_footer ( r + + , FR ( " @0gTotale progressivi@70g%15s@85g%15s@107g%15s " ) ,
_totdoc_prog . string ( " .2 " ) , _totimpn_prog . string ( " .2 " ) , _totimps_prog . string ( " .2 " ) ) ;
2004-05-12 14:48:33 +00:00
if ( _stampa_width = = 198 )
2004-11-30 22:02:59 +00:00
set_footer ( r + + , FR ( " @0gTotale progressivi@78g%15s@93g%15s@116g%15s " ) ,
_totdoc_prog . string ( " .2 " ) , _totimpn_prog . string ( " .2 " ) , _totimps_prog . string ( " .2 " ) ) ;
2004-05-12 14:48:33 +00:00
set_footer ( r + + , riga ) ;
_riporti_stampati = true ;
}
else
_riporti_stampati = false ;
}
2004-11-30 22:02:59 +00:00
void TStampa_registri_app : : on_page_printed ( int file )
{
if ( file = = LF_MOV )
{
_rows_left = printer ( ) . rows_left ( ) ;
}
}
1998-04-30 15:59:34 +00:00
bool TStampa_registri_app : : stampo_liquidazione ( int mese )
1996-02-06 16:02:59 +00:00
{
//test tradotti alla lettera da AS/400
//assolutamente incongruenti !!!
1998-04-30 15:59:34 +00:00
const bool trim_month_flag = ( _frequiva = = ' T ' & & ( mese = = 3 | | mese = = 6 | | mese = = 9 | | mese = = 12 ) )
2012-11-30 14:36:30 +00:00
| | _frequiva ! = ' T ' | | ( mese = = 12 & & _tipo_riepilogativo = = ' A ' ) ;
1998-04-30 15:59:34 +00:00
if ( _tipo_stampa = = prova )
1996-02-06 16:02:59 +00:00
{
1998-04-30 15:59:34 +00:00
if ( trim_month_flag )
2012-10-26 09:12:52 +00:00
return true ;
1996-02-06 16:02:59 +00:00
}
else
{
1998-04-30 15:59:34 +00:00
if ( trim_month_flag )
1996-02-06 16:02:59 +00:00
if ( ( mese = = 12 & & _tipo_riepilogativo = = ' A ' & & _mese_ultima_liq ! = 13 )
| | ( mese ! = 12 & & mese > _mese_ultima_liq )
| | ( mese = = 12 & & _tipo_riepilogativo ! = ' A ' & & mese > _mese_ultima_liq ) )
2012-10-26 09:12:52 +00:00
return true ;
1996-02-06 16:02:59 +00:00
}
2012-10-26 09:12:52 +00:00
return false ;
1996-02-06 16:02:59 +00:00
}
1995-07-31 09:49:11 +00:00
1998-04-30 15:59:34 +00:00
void TStampa_registri_app : : liq_b0_settato ( )
1996-02-06 16:02:59 +00:00
{
TFilename f ;
f . temp ( " rg " ) ;
1998-04-30 15:59:34 +00:00
if ( _tipo_stampa = = prova )
1996-02-06 16:02:59 +00:00
send_message ( ' S ' , f , _datareg . month ( ) ) ;
else send_message ( ' s ' , f , _datareg . month ( ) ) ;
2003-03-25 13:56:11 +00:00
1998-02-24 10:31:42 +00:00
if ( f . exist ( ) )
1996-02-06 16:02:59 +00:00
{
printer ( ) . formfeed ( ) ;
2012-10-26 09:12:52 +00:00
_intesta_liq = true ;
merge_export_file ( f , false , true ) ;
_intesta_liq = false ;
1996-02-06 16:02:59 +00:00
remove ( f ) ;
}
}
1998-04-30 15:59:34 +00:00
void TStampa_registri_app : : liq_other_case ( )
1996-02-06 16:02:59 +00:00
{
1998-04-30 15:59:34 +00:00
const bool calc_reg = _annoes > 1997 ; // Flag per effettuare nuovo calcolo registri
char tipo_messaggio ; // Tipo messaggio per chiamata a programma calcolo/stampa liquidazione
switch ( _scelta )
1996-02-06 16:02:59 +00:00
{
2012-11-30 14:36:30 +00:00
case prosegui_cal_stampa :
tipo_messaggio = ' L ' ; // Stampa Liquidazione con ricalcolo
break ;
case prosegui_stampa :
tipo_messaggio = ' S ' ; // Stampa Liquidazione senza ricalcolo
break ;
default :
tipo_messaggio = ' \0 ' ;
break ;
1996-02-06 16:02:59 +00:00
}
1998-04-30 15:59:34 +00:00
if ( _tipo_stampa ! = prova )
tipo_messaggio = tolower ( tipo_messaggio ) ; // Prova o definitiva ?
// Calcolo/Stampa liquidazione
if ( stampo_liquidazione ( _datareg . month ( ) ) & & tipo_messaggio ! = ' \0 ' )
1996-02-06 16:02:59 +00:00
{
1998-04-30 15:59:34 +00:00
_t . temp ( " reg " ) ;
send_message ( tipo_messaggio , _t , _datareg . month ( ) ) ;
1996-02-06 16:02:59 +00:00
}
1998-04-30 15:59:34 +00:00
// Ricalcolo Progressivi Registri. Il vecchio calcolo viene mantenuto. Nel
// caso si tratti di un nuovo anno, chiama il nuovo calcolo specifico per registri.
if ( _tipo_stampa ! = prova )
{ // Se sta stampando i bollati ricalcola sempre (ignorando il flag LIM->B1, a causa delle nuove norme)
// Cio' viene fatto poiche' in caso di ripristino di stampa registro bollato
// sarebbe necessario un ricalcolo progressivi per sicurezza.
if ( ricalcola ( _fino_a_mese ) | | calc_reg )
1996-02-06 16:02:59 +00:00
{
TFilename app ;
1998-04-30 15:59:34 +00:00
app . temp ( ) ;
int mese = _fino_a_mese ;
1996-02-06 16:02:59 +00:00
//se la frequenza e' trimestrale
//aggiusta il mese al trimestre a cui appartiene
if ( _frequiva = = ' T ' )
mese + = 2 - ( ( mese - 1 ) % 3 ) ;
2000-10-03 13:45:12 +00:00
send_message ( calc_reg ? ' R ' : ' C ' , app , calc_reg ? _datareg . month ( ) : mese ) ;
1996-02-06 16:02:59 +00:00
}
1998-04-30 15:59:34 +00:00
}
1996-02-06 16:02:59 +00:00
}
1995-07-31 09:49:11 +00:00
1998-04-30 15:59:34 +00:00
void TStampa_registri_app : : stampa_vidi ( )
1996-02-06 16:02:59 +00:00
{
TLocalisamfile IndBil ( LF_INDLIB ) ;
TTable TabVid ( " %VID " ) ;
TString16 codreg ;
TString16 vid ;
long ditta , pagfin , pagfinut ;
int mese ;
TPrintrow row ;
2012-10-26 09:12:52 +00:00
_ok_vidi = false ;
1996-02-06 16:02:59 +00:00
if ( ! printer ( ) . isopen ( ) )
printer ( ) . open ( ) ;
IndBil . zero ( ) ;
IndBil . put ( " ANNO " , _annoes ) ;
IndBil . put ( " CODLIB " , _codlib ) ;
TRectype rec ( IndBil . curr ( ) ) ;
IndBil . read ( _isgteq ) ;
for ( ; ! IndBil . eof ( ) ; IndBil . next ( ) )
{
if ( IndBil . curr ( ) ! = rec ) break ;
ditta = IndBil . get_long ( " CODDITTA " ) ;
codreg = IndBil . get ( " CODREG " ) ;
if ( ditta = = _ditta & & codreg = = _codreg )
1995-07-31 09:49:11 +00:00
{
1996-02-06 16:02:59 +00:00
if ( ! _ok_vidi )
1995-07-31 09:49:11 +00:00
{
1996-02-06 16:02:59 +00:00
+ + _u_stampata ;
+ + _pagine_stampate ;
2012-10-26 09:12:52 +00:00
_ok_vidi = true ;
1996-02-06 16:02:59 +00:00
}
mese = IndBil . get_int ( " MESEREG " ) ;
pagfin = IndBil . get_long ( " PAGFIN " ) ;
pagfinut = IndBil . get_long ( " PAGFINUT " ) ;
if ( mese = = 12 )
1995-07-31 09:49:11 +00:00
{
1996-02-06 16:02:59 +00:00
+ + pagfin ;
+ + pagfinut ;
TRectype nuovo ( IndBil . curr ( ) ) ;
nuovo . put ( " PAGFIN " , pagfin ) ;
nuovo . put ( " PAGFINUT " , pagfinut ) ;
IndBil . rewrite ( nuovo ) ;
1995-07-31 09:49:11 +00:00
}
1996-02-06 16:02:59 +00:00
row . reset ( ) ;
row . put ( format ( " %s " , itom ( mese ) ) , 0 ) ;
row . put ( format ( " %5ld " , IndBil . get_long ( " PAGINI " ) ) , 10 ) ;
row . put ( format ( " %5ld " , pagfin ) , 17 ) ;
row . put ( format ( " %5ld " , IndBil . get_long ( " PAGINIUT " ) ) , 25 ) ;
row . put ( format ( " %5ld " , pagfinut ) , 32 ) ;
vid = IndBil . get ( " CODVID " ) ;
TabVid . zero ( ) ;
TabVid . put ( " CODTAB " , vid ) ;
if ( TabVid . read ( ) = = NOERR )
{
row . put ( format ( " %-.32s " , ( const char * ) TabVid . get ( " S0 " ) ) , 39 ) ;
row . put ( format ( " %7d " , TabVid . get_long ( " I0 " ) ) , 71 ) ;
row . put ( format ( " %7d " , TabVid . get_long ( " I1 " ) ) , 79 ) ;
row . put ( format ( " %7d " , TabVid . get_long ( " I2 " ) ) , 87 ) ;
TDate d ( TabVid . get_long ( " D0 " ) ) ;
row . put ( format ( " %s " , ( const char * ) d . string ( ) ) , 95 ) ;
row . put ( format ( " %-.26s " , ( const char * ) TabVid . get ( " S1 " ) ) , 106 ) ;
}
printer ( ) . print ( row ) ;
}
1995-07-31 09:49:11 +00:00
}
1996-02-06 16:02:59 +00:00
printer ( ) . close ( ) ;
1995-07-31 09:49:11 +00:00
}
1996-02-06 16:02:59 +00:00
//------ dopo la stampa devo aggiornare i registri, ecc. ------//
1998-04-30 15:59:34 +00:00
void TStampa_registri_app : : scrivi_reg ( const TDate & data )
1995-07-31 09:49:11 +00:00
{
TString16 codtab ;
TTable Tabreg ( " REG " ) ;
codtab < < _annoes < < _codreg ;
Tabreg . zero ( ) ;
Tabreg . put ( " CODTAB " , codtab ) ;
if ( Tabreg . read ( ) = = NOERR )
{
const TDate d = Tabreg . get_date ( " D3 " ) ;
if ( ! _mov_empty ) //cioe' se e' stata stampata almeno una pagina
{
1995-11-17 14:29:24 +00:00
TDate ultima_data ( data ) ;
1995-07-31 09:49:11 +00:00
ultima_data . set_end_month ( ) ; // Meglio cosi'
if ( ultima_data > d )
Tabreg . put ( " D3 " , ultima_data ) ;
}
else if ( _data_a > d )
Tabreg . put ( " D3 " , _data_a ) ;
1998-04-30 15:59:34 +00:00
if ( _tipo_reg = = acquisto & & _stampa_cred_pre )
1995-07-31 09:49:11 +00:00
if ( _mese_credito = = 0 & & _credito > ZERO )
if ( _mov_empty )
Tabreg . put ( " I8 " , ( long ) _fino_a_mese ) ;
else Tabreg . put ( " I8 " , ( long ) _datareg . month ( ) ) ;
1995-11-17 14:29:24 +00:00
1995-07-31 09:49:11 +00:00
Tabreg . rewrite ( ) ;
}
1998-04-30 15:59:34 +00:00
if ( _tipo_stampa = = libro_unico )
1995-07-31 09:49:11 +00:00
{
TString16 cod = " " ;
TTable lbu ( " %LBU " ) ;
cod < < _annoes < < _codlib ;
lbu . zero ( ) ;
lbu . put ( " CODTAB " , cod ) ;
if ( lbu . read ( ) = = NOERR )
{
lbu . put ( " I0 " , ( long ) _fino_a_mese ) ;
lbu . rewrite ( ) ;
}
}
}
1998-04-30 15:59:34 +00:00
void TStampa_registri_app : : aggiorna_reg ( const bool aggiorna_vidi )
1995-07-31 09:49:11 +00:00
{
TString16 codtab ;
TTable Tabreg ( " REG " ) ;
TLocalisamfile IndBil ( LF_INDLIB ) ;
codtab < < _annoes < < _codreg ;
Tabreg . zero ( ) ;
Tabreg . put ( " CODTAB " , codtab ) ;
if ( Tabreg . read ( ) = = NOERR )
{
TDate d = Tabreg . get_date ( " D3 " ) ;
if ( ! _mov_empty ) //cioe' se e' stata stampata almeno una pagina
1995-11-17 14:29:24 +00:00
{ //controllo inutile visto che e' chiamata nella
//preprocess_header
1995-07-31 09:49:11 +00:00
TDate ultima_data ( _datareg ) ;
1995-11-17 14:29:24 +00:00
ultima_data . set_end_month ( ) ;
1995-07-31 09:49:11 +00:00
if ( ultima_data > d )
Tabreg . put ( " D3 " , ultima_data ) ;
}
else if ( _data_a > d )
Tabreg . put ( " D3 " , _data_a ) ;
Tabreg . put ( " I1 " , _pagine_stampate ) ;
if ( _intesta_liq )
if ( _tipo_riepilogativo = = ' A ' )
Tabreg . put ( " I4 " , 13L ) ;
else Tabreg . put ( " I4 " , ( long ) _datareg . month ( ) ) ;
1998-04-30 15:59:34 +00:00
if ( _tipo_reg = = acquisto & & _stampa_cred_pre )
1995-07-31 09:49:11 +00:00
if ( _mese_credito = = 0 & & _credito > ZERO )
if ( _mov_empty )
Tabreg . put ( " I8 " , ( long ) _fino_a_mese ) ;
else Tabreg . put ( " I8 " , ( long ) _datareg . month ( ) ) ;
Tabreg . rewrite ( ) ;
}
1998-04-30 15:59:34 +00:00
if ( _tipo_stampa = = libro_unico ) //stampa su libro unico
1995-07-31 09:49:11 +00:00
// sul file indlib (indice libro unico) devo generare una riga per ogni
// registro stampato (ricordarsi che la stampa su libro unico deve
// avvenire mese per mese!)
// inoltre non posso stampare due volte lo stesso mese perche' la stampa
// avviene a fine mese
{
long numero_riga = 1L ;
if ( ! aggiorna_vidi )
{
2012-10-26 09:12:52 +00:00
bool trovato = false ;
1995-07-31 09:49:11 +00:00
IndBil . zero ( ) ;
2012-11-30 14:36:30 +00:00
TRectype nuovo ( IndBil . curr ( ) ) ;
1995-07-31 09:49:11 +00:00
IndBil . put ( " ANNO " , _annoes ) ;
IndBil . put ( " CODLIB " , _codlib ) ;
TRectype rec ( IndBil . curr ( ) ) ;
for ( IndBil . read ( _isgteq ) ; ! IndBil . eof ( ) ; IndBil . next ( ) )
{
if ( IndBil . curr ( ) ! = rec ) break ;
int annoreg = IndBil . get_int ( " ANNOREG " ) ;
int mesereg = IndBil . get_int ( " MESEREG " ) ;
long cditta = IndBil . get_long ( " CODDITTA " ) ;
TString16 codreg = IndBil . get ( " CODREG " ) ;
TString16 codvid = IndBil . get ( " CODVID " ) ;
if ( _annoes = = annoreg & & _fino_a_mese = = mesereg
& & _ditta = = cditta & & codreg = = _codreg & & _codice_vidi = = codvid )
{
2012-10-26 09:12:52 +00:00
trovato = true ;
1995-07-31 09:49:11 +00:00
numero_riga = IndBil . get_long ( " NUMREG " ) ;
break ;
}
else numero_riga = IndBil . get_long ( " NUMREG " ) + 1 ;
// cosi' mi posiziono su quel mese (altrimenti rischio di generare
// due righe per lo stesso mese e registro => la stampa di vidimazione
1998-04-30 15:59:34 +00:00
// mi sballa!!!,
1995-07-31 09:49:11 +00:00
}
nuovo . put ( " ANNO " , _annoes ) ;
nuovo . put ( " CODLIB " , _codlib ) ;
nuovo . put ( " NUMREG " , numero_riga ) ;
nuovo . put ( " ANNOREG " , _annoes ) ;
nuovo . put ( " MESEREG " , _fino_a_mese ) ; // su libro unico ho un solo mese in gioco!
nuovo . put ( " PAGINI " , _primast + 1 ) ; // numero iniziale pagina libro unico
nuovo . put ( " PAGFIN " , _u_stampata ) ; // numero finale pagina libro unico
nuovo . put ( " CODDITTA " , _ditta ) ;
nuovo . put ( " CODREG " , _codreg ) ;
nuovo . put ( " CODVID " , _codice_vidi ) ;
nuovo . put ( " PAGINIUT " , _numini + 1 ) ;
nuovo . put ( " PAGFINUT " , _pagine_stampate ) ;
if ( ! trovato )
IndBil . write ( nuovo ) ;
else IndBil . rewrite ( nuovo ) ;
}
aggiorna_lib ( ) ;
}
}
1998-04-30 15:59:34 +00:00
void TStampa_registri_app : : aggiorna_lib ( )
1995-07-31 09:49:11 +00:00
{
TString16 cod = " " ;
TTable lbu ( " %LBU " ) ;
cod < < _annoes < < _codlib ;
lbu . zero ( ) ;
lbu . put ( " CODTAB " , cod ) ;
if ( lbu . read ( ) = = NOERR )
{
lbu . put ( " I0 " , ( long ) _fino_a_mese ) ;
lbu . put ( " I1 " , ( long ) _u_stampata ) ;
lbu . rewrite ( ) ;
}
}
1998-04-30 15:59:34 +00:00
void TStampa_registri_app : : clear_stliq ( )
1995-07-31 09:49:11 +00:00
{
1996-02-06 16:02:59 +00:00
for ( int i = 0 ; i < = 12 ; i + + )
2012-10-26 09:12:52 +00:00
_st_liq [ i ] = false ;
1995-07-31 09:49:11 +00:00
}
1998-04-30 15:59:34 +00:00
bool TStampa_registri_app : : setta_mask ( long i )
1995-07-31 09:49:11 +00:00
{
1996-02-06 16:02:59 +00:00
if ( _stampa_mese = = 13 ) _stampa_mese = 0 ;
1998-04-30 15:59:34 +00:00
if ( _tipo_stampa = = bollato | | _tipo_stampa = = rif_giornale )
1995-07-31 09:49:11 +00:00
{
1996-02-06 16:02:59 +00:00
TMask mb ( " cg4400b " ) ;
mb . set ( F_CODDITTA , _ditta ) ;
mb . set ( F_RAGSOC , _ditte - > row ( i ) . get ( 2 ) ) ;
mb . set ( COD_LIB , _codreg ) ;
const char * m = " " ;
m = format ( " %02d " , _stampa_mese ) ;
mb . set ( U_MESE , m ) ;
mb . set ( U_PAGINA , _pagine_stampate ) ;
if ( _u_data . ok ( ) )
mb . set ( U_DATA , _u_data . string ( ) ) ;
KEY tasto = mb . run ( ) ;
2012-10-26 09:12:52 +00:00
if ( tasto ! = K_ENTER ) return false ;
1998-04-30 15:59:34 +00:00
//MI3213
1996-02-06 16:02:59 +00:00
_pagine_stampate = mb . get_long ( U_PAGINA ) ;
2003-02-25 14:39:02 +00:00
_numini = _pagine_stampate ;
1995-07-31 09:49:11 +00:00
}
2012-10-26 09:12:52 +00:00
return true ;
1996-02-06 16:02:59 +00:00
}
1995-07-31 09:49:11 +00:00
1996-02-06 16:02:59 +00:00
//In questa funzione veniva gestita la stampa della liquidazione
//(anche se in un mese non si hanno movimenti occorre comunque
//stampare la liquidazione (se sul registro che sto stampando
//c'e' il flag di stampa liquidazione e, in caso di bollato, non
//era gia' scesa precedentemente)).
1998-04-30 15:59:34 +00:00
//Viene anche gestita la stampa del registro
1996-02-06 16:02:59 +00:00
//RIEPILOGATIVO (essendo un registro su cui non vengono registrati
//movimenti)
1998-04-30 15:59:34 +00:00
void TStampa_registri_app : : no_movimenti ( )
1995-07-31 09:49:11 +00:00
{
1996-02-06 16:02:59 +00:00
TRecnotype rec = _tabreg - > recno ( ) ;
2012-10-26 09:12:52 +00:00
_mov_empty = true ;
1998-04-30 15:59:34 +00:00
int da , a ;
if ( _tipo_stampa = = bollato | | _tipo_stampa = = rif_giornale )
da = 1 ;
if ( _tipo_stampa = = libro_unico )
da = _fino_a_mese ;
if ( _tipo_stampa = = prova )
da = _data_da . month ( ) ;
if ( _tipo_stampa = = prova )
a = _data_a . month ( ) ;
else a = _fino_a_mese ;
1996-02-06 16:02:59 +00:00
1998-04-30 15:59:34 +00:00
//RICALCOLO PROGRESSIVI per registro riepilogativo
//il ricalcolo dei progressivi mensili viene sempre
2012-10-26 09:12:52 +00:00
//fatto, se B1 e' false, anche se poi il riepilogativo
1998-04-30 15:59:34 +00:00
//non verra' stampato (se il mese richiesto non e'
//in accordo con la frequenza di stampa del registro stesso)
1999-04-26 15:58:05 +00:00
//Il ricalcolo nel caso di riepilogativo avviene sempre,
//a causa della separazione dei progressivi per registri, ma
//solo se l'anno in questione e oltre il 1997, cio<69> prima della effettiva
//separazione dei progressivi.
1998-04-30 15:59:34 +00:00
const bool calc = _tipo_reg = = riepilogativo & & _annoes > 1997 ;
1999-04-26 15:58:05 +00:00
if ( ricalcola ( a ) | | calc )
1998-04-30 15:59:34 +00:00
{
TFilename app ;
app . temp ( ) ;
int mese = a ;
//se la frequenza e' trimestrale
//aggiusta il mese al trimestre a cui appartiene
if ( _frequiva = = ' T ' )
2000-10-03 13:45:12 +00:00
{
1998-04-30 15:59:34 +00:00
mese + = 2 - ( ( mese - 1 ) % 3 ) ;
2000-10-03 13:45:12 +00:00
if ( calc )
{
send_message ( ' R ' , app , mese - 2 ) ; // Guy!!!
send_message ( ' R ' , app , mese - 1 ) ; // Guy!!!
}
}
1998-04-30 15:59:34 +00:00
send_message ( calc ? ' R ' : ' C ' , app , calc ? a : mese ) ;
}
1996-02-06 16:02:59 +00:00
2012-11-30 14:36:30 +00:00
if ( some_IVAxCassa ( ) )
{
if ( ! printer ( ) . isopen ( ) )
printer ( ) . open ( ) ;
int mese = a ;
if ( _frequiva = = ' T ' )
mese + = 2 - ( ( mese - 1 ) % 3 ) ;
print_IVAxCassa ( mese ) ;
}
1999-04-06 15:34:39 +00:00
if ( _tipo_reg = = riepilogativo | | _liquidazione | | _stampa_plafonds )
1998-04-30 15:59:34 +00:00
{
2000-10-03 13:45:12 +00:00
for ( int m = da ; m < = a ; m + + )
{
if ( _tipo_reg = = riepilogativo )
{
2012-10-26 09:12:52 +00:00
bool stsbol = false ;
2000-10-03 13:45:12 +00:00
if ( _tipo_stampa ! = prova ) //stampa su bollato
if ( _u_data . ok ( ) )
2012-10-26 09:12:52 +00:00
if ( m < = _u_data . month ( ) ) stsbol = true ;
2000-10-03 13:45:12 +00:00
if ( ! stsbol ) //cioe' se il mese che sto considerando e'
//maggiore dell'ultima data di stampa del registro
{
if ( _freq_riepilogo = = ' M ' | |
( m = = 3 | | m = = 6 | | m = = 9 | | m = = 12 ) )
{
_datareg = TDate ( 1 , m , _annoes ) ;
if ( stampa_riepilogo ( m ) )
printer ( ) . formfeed ( ) ;
}
1998-04-30 15:59:34 +00:00
}
2000-10-03 13:45:12 +00:00
}
1999-04-06 15:34:39 +00:00
2012-11-30 14:36:30 +00:00
// In prova va stampato per ogni mese (sia Mensile che Trimestrale);
2000-10-03 13:45:12 +00:00
// in bollato, solo per i mesi che ancora mancano)
const bool print_plafond_bollato = _tipo_stampa ! = prova & & ( m = = 1 | | m > _u_data . month ( ) ) ;
if ( _stampa_plafonds & & ( _tipo_stampa = = prova | | print_plafond_bollato ) )
1998-04-30 15:59:34 +00:00
{
2000-10-03 13:45:12 +00:00
if ( ! printer ( ) . isopen ( ) )
printer ( ) . open ( ) ;
_datareg = TDate ( 1 , m , _annoes ) ;
if ( stampa_plafonds ( - 1 ) ) // Con -1 compone e stampa printrows all'istante
printer ( ) . formfeed ( ) ;
}
2012-11-30 14:36:30 +00:00
2000-10-03 13:45:12 +00:00
//la funzione stampo_liquidazione non stampera' la liquidazione sul
//registro il cui mese di stampa ultima liq. e' > del mese in esame
//caso a parte il mese 12 (che posso ristampare 2 volte)
2012-11-30 14:36:30 +00:00
if ( _liquidazione & & stampo_liquidazione ( m ) )
{
if ( _tipo_reg = = riepilogativo )
{
if ( ! ( _freq_riepilogo = = ' M ' | |
( m = = 3 | | m = = 6 | | m = = 9 | | m = = 12 ) ) ) continue ;
}
2000-10-03 13:45:12 +00:00
2012-11-30 14:36:30 +00:00
if ( ! printer ( ) . isopen ( ) )
printer ( ) . open ( ) ;
TFilename f ;
f . temp ( " rgp " ) ;
_datareg = TDate ( 1 , m , _annoes ) ; // serve alla preprocess_header
if ( _scelta = = B0_settato | | _scelta = = prosegui_stampa )
{
if ( _tipo_stampa = = prova )
send_message ( ' S ' , f , m ) ;
else
send_message ( ' s ' , f , m ) ;
}
else //_scelta == prosegui_cal_stampa
{
2000-10-03 13:45:12 +00:00
if ( _tipo_stampa = = prova )
send_message ( ' L ' , f , m ) ;
else
send_message ( ' l ' , f , m ) ;
2012-11-30 14:36:30 +00:00
}
if ( f . exist ( ) )
{
_intesta_liq = true ;
merge_export_file ( f , false , true ) ;
printer ( ) . formfeed ( ) ;
_intesta_liq = false ;
remove ( f ) ;
}
1998-04-30 15:59:34 +00:00
}
2000-10-03 13:45:12 +00:00
} //for
1998-04-30 15:59:34 +00:00
}
_tabreg - > readat ( rec ) ;
1996-02-06 16:02:59 +00:00
1998-04-30 15:59:34 +00:00
if ( printer ( ) . isopen ( ) ) printer ( ) . close ( ) ;
1996-02-06 16:02:59 +00:00
//aggiorno il registro anche se non ho stampato proprio nulla per quel mese!
1998-04-30 15:59:34 +00:00
if ( _tipo_stampa ! = prova )
scrivi_reg ( _datareg ) ;
1996-02-06 16:02:59 +00:00
}
1998-04-30 15:59:34 +00:00
void TStampa_registri_app : : stampa_liq_mesi_succ ( )
1996-02-06 16:02:59 +00:00
{
int da = _datareg . month ( ) + 1 ;
int a = _data_a . month ( ) ;
for ( int m = da ; m < = a ; m + + )
{
1999-05-24 13:34:11 +00:00
_datareg = TDate ( 1 , m , _annoes ) ;
2012-10-26 09:12:52 +00:00
if ( _stampa_plafonds & & stampa_plafonds ( - 1 , true ) )
1999-05-24 13:34:11 +00:00
{
printer ( ) . formfeed ( ) ;
stampa_plafonds ( - 1 ) ;
}
1996-02-06 16:02:59 +00:00
if ( stampo_liquidazione ( m ) )
1995-07-31 09:49:11 +00:00
{
1996-02-06 16:02:59 +00:00
TFilename t ;
t . temp ( " iva " ) ;
1995-07-31 09:49:11 +00:00
1996-02-06 16:02:59 +00:00
if ( _scelta = = B0_settato | | _scelta = = prosegui_stampa )
1995-07-31 09:49:11 +00:00
{
1998-04-30 15:59:34 +00:00
if ( _tipo_stampa = = prova )
1996-02-06 16:02:59 +00:00
send_message ( ' S ' , t , m ) ;
1998-04-30 15:59:34 +00:00
else
send_message ( ' s ' , t , m ) ;
1995-07-31 09:49:11 +00:00
}
1996-02-06 16:02:59 +00:00
else //_scelta == prosegui_cal_stampa
1995-07-31 09:49:11 +00:00
{
1998-04-30 15:59:34 +00:00
if ( _tipo_stampa = = prova )
send_message ( ' L ' , t , m ) ;
else
send_message ( ' l ' , t , m ) ;
1995-07-31 09:49:11 +00:00
}
1996-02-06 16:02:59 +00:00
if ( fexist ( t ) )
{
2012-10-26 09:12:52 +00:00
_intesta_liq = true ;
1996-02-06 16:02:59 +00:00
printer ( ) . formfeed ( ) ;
2012-10-26 09:12:52 +00:00
merge_export_file ( t , false , true ) ;
_intesta_liq = false ;
1996-02-06 16:02:59 +00:00
remove ( t ) ;
}
1995-07-31 09:49:11 +00:00
}
1996-02-06 16:02:59 +00:00
}
}
1998-04-30 15:59:34 +00:00
void TStampa_registri_app : : send_message ( char tipo , const TFilename & nome , int mese )
1996-02-06 16:02:59 +00:00
{
const char * app ;
if ( tipo = = ' S ' | | tipo = = ' s ' )
app = " cg4 -2 -S " ;
1998-04-30 15:59:34 +00:00
else if ( tipo = = ' C ' | | tipo = = ' R ' )
1996-02-06 16:02:59 +00:00
app = " cg4 -2 -C " ;
else app = " cg4 -2 " ;
TToken_string ss ( 36 ) ;
ss . add ( _annoes ) ;
if ( _tipo_riepilogativo = = ' A ' & & mese = = 12 )
ss . add ( 13 ) ;
1998-04-30 15:59:34 +00:00
else
ss . add ( mese ) ;
1996-02-06 16:02:59 +00:00
ss . add ( _ditta ) ;
ss . add ( tipo ) ;
ss . add ( _data_stampa . string ( ) ) ;
ss . add ( nome ) ;
if ( _riep_liq )
ss . add ( ' X ' ) ;
else ss . add ( ' ' ) ;
2004-05-12 14:48:33 +00:00
1998-04-30 15:59:34 +00:00
ss . add ( printer ( ) . formlen ( ) - _size_header - RIGHE_FOOTER ) ;
1996-02-06 16:02:59 +00:00
TMessage liq ( app , " RCL " , ss ) ;
liq . send ( ) ;
TExternal_app pn ( app ) ;
pn . run ( ) ;
1999-10-22 10:00:18 +00:00
2003-04-01 09:58:14 +00:00
xvt_sys_sleep ( 1000 ) ;
1995-07-31 09:49:11 +00:00
}
1998-04-30 15:59:34 +00:00
bool TStampa_registri_app : : set_print ( int n )
1995-07-31 09:49:11 +00:00
{
TMask m ( " cg4400a " ) ;
m . set_handler ( TIPO_STAMPA , mask_tipo_stampa ) ;
m . set_handler ( DA_DATA , mask_data ) ;
m . set_handler ( A_DATA , mask_data ) ;
m . set_handler ( MESE , mask_mese ) ;
m . set_handler ( FINO_A_MESE , mask_mese ) ;
m . set_handler ( CODICE_LIB_UN , mask_cod ) ;
m . set_handler ( CODICE_LIBRO_IVA , mask_libun ) ;
m . set_handler ( F_ANNULLA , mask_azzera ) ;
m . set_handler ( A_CODICE , to_ditt_handler ) ;
m . set_handler ( DA_CODICE , fr_ditt_handler ) ;
m . set_handler ( ANNO , year_handler ) ;
2012-10-26 09:12:52 +00:00
m . set ( DA_CODICE , get_firm ( ) ) ;
m . set ( A_CODICE , get_firm ( ) , 0x3 ) ;
1995-07-31 09:49:11 +00:00
m . field ( F_SELECT ) . set ( format ( " %ld " , _selected . ones ( ) ) ) ;
set_choice_limits ( m ) ;
set_real_picture ( " ###.###.###.### " ) ;
2012-10-26 09:12:52 +00:00
set_magic_currency ( true ) ;
1995-07-31 09:49:11 +00:00
2012-10-26 09:12:52 +00:00
bool ok = true ;
1995-07-31 09:49:11 +00:00
while ( ok = set_ditte ( m ) )
{
if ( _selected . ones ( ) > 0l )
{
2004-05-12 14:48:33 +00:00
//*****azzeramento dei totali progressivi e dei flag di controllo della loro stampa
_totdoc_prog = 0 ;
_totimpn_prog = 0 ;
_totimps_prog = 0 ;
2004-11-30 22:02:59 +00:00
_rows_left = 69 ;
2004-05-12 14:48:33 +00:00
_riporti_stampati = false ;
_totali_stampati = false ;
1995-07-31 09:49:11 +00:00
_annoes = m . get_int ( ANNO ) ; //in realta' e' l'anno IVA !!!
1998-04-30 15:59:34 +00:00
_tipo_stampa = ( tipo_stampa ) m . get_int ( TIPO_STAMPA ) ;
1995-07-31 09:49:11 +00:00
_stampa_width = m . get_int ( STAMPA_WIDTH ) ;
_stampa_len = m . get_int ( STAMPA_LEN ) ;
2003-03-25 13:56:11 +00:00
_tabname = ( _annoes > 1997 ) ? " PRM " : " PIM " ; // Dal 1998 in poi utilizza i PRM e non i PIM
1995-07-31 09:49:11 +00:00
if ( _stampa_width = = 1 )
_stampa_width = 132 ;
else _stampa_width = 198 ;
if ( _stampa_len ! = 0 )
printer ( ) . formlen ( _stampa_len ) ;
1996-12-12 12:31:36 +00:00
printer ( ) . footerlen ( RIGHE_FOOTER ) ;
1995-07-31 09:49:11 +00:00
//Se stampa di prova l'utente indica data_da e data_a
1998-04-30 15:59:34 +00:00
if ( _tipo_stampa = = prova )
1995-07-31 09:49:11 +00:00
{
_data_stampa = m . get ( DATA_STAMPA ) ;
_data_da = m . get ( DA_DATA ) ;
_data_a = m . get ( A_DATA ) ;
if ( ! _data_da . ok ( ) )
_data_da = TDate ( 1 , 1 , _annoes ) ; // Meglio cosi'
if ( ! _data_a . ok ( ) )
_data_a = TDate ( 31 , 12 , _annoes ) ; // Meglio cosi'
const TDate d ( 31 , 12 , _annoes ) ;
if ( _data_a = = d )
_tipo_riepilogativo = m . get ( TIPO_RIEPILOGATIVO ) [ 0 ] ;
2012-11-30 14:36:30 +00:00
else
_tipo_riepilogativo = ' ' ;
1995-07-31 09:49:11 +00:00
printer ( ) . setdate ( _data_stampa ) ;
}
else //stampe definitive
{
1998-04-30 15:59:34 +00:00
if ( _tipo_stampa = = bollato | | _tipo_stampa = = rif_giornale )
1995-07-31 09:49:11 +00:00
{
_fino_a_mese = m . get_int ( FINO_A_MESE ) ;
_data_da = TDate ( 1 , 1 , _annoes ) ; // Meglio cosi'
}
else //stampa su libro unico
{
_codlib = m . get ( CODICE_LIB_UN ) ;
_fino_a_mese = m . get_int ( MESE ) ;
_u_stampata = m . get_int ( ULTIMA_PAGINA ) ;
_rif_vid = m . get_bool ( RIF_VID ) ;
_primast = _u_stampata ;
_data_da = TDate ( 1 , _fino_a_mese , _annoes ) ; // Meglio cosi'
}
2012-10-26 09:12:52 +00:00
int giorni_del_mese = 31 ;
1995-07-31 09:49:11 +00:00
if ( _fino_a_mese = = 12 )
{
giorni_del_mese = 31 ;
_tipo_riepilogativo = m . get ( TIPO_RIEPILOGATIVO ) [ 0 ] ;
}
else
{
_tipo_riepilogativo = ' ' ;
TDate primo ( 1 , _fino_a_mese , _annoes ) ;
primo . set_end_month ( ) ; // Meglio cosi'
giorni_del_mese = primo . day ( ) ;
}
1996-02-06 16:02:59 +00:00
_data_a = TDate ( giorni_del_mese , _fino_a_mese , _annoes ) ; // Meglio cosi'
1995-07-31 09:49:11 +00:00
}
1996-02-06 16:02:59 +00:00
_stampa_data_reg = stampa_datareg ( ) ;
1998-04-30 15:59:34 +00:00
if ( _tipo_stampa = = libro_unico )
1996-02-06 16:02:59 +00:00
compila_lib ( ) ;
stampa_registri_IVA ( m ) ;
1995-07-31 09:49:11 +00:00
}
1996-02-06 16:02:59 +00:00
else
{
2003-03-25 13:56:11 +00:00
warning_box ( TR ( " Nessuna ditta selezionata! " ) ) ;
1996-02-06 16:02:59 +00:00
continue ;
}
1995-07-31 09:49:11 +00:00
}
2012-10-26 09:12:52 +00:00
return false ;
1995-07-31 09:49:11 +00:00
}
1996-02-06 16:02:59 +00:00
//********* FUNZIONE PRINCIPALE *********//
1998-04-30 15:59:34 +00:00
bool TStampa_registri_app : : stampa_registri_IVA ( const TMask & m )
1995-07-31 09:49:11 +00:00
{
2012-10-26 09:12:52 +00:00
bool ok = false ;
1999-04-06 15:34:39 +00:00
TRectype mov_from ( LF_MOV ) , mov_to ( LF_MOV ) ;
1995-07-31 09:49:11 +00:00
for ( int i = 0 ; i < _ditte - > items ( ) ; i + + )
{
if ( _selected [ ( long ) i ] )
{
2012-10-26 09:12:52 +00:00
bool msg = true ;
1995-07-31 09:49:11 +00:00
_ditta = _ditte - > row ( i ) . get_long ( 1 ) ;
_frequiva = _ditte - > row ( i ) . get_char ( 3 ) ;
2012-10-26 09:12:52 +00:00
_intesta_liq = false ;
_intesta_vidi = false ;
1995-07-31 09:49:11 +00:00
_primast = _u_stampata ;
2012-10-26 09:12:52 +00:00
_ok_vidi = false ;
1995-07-31 09:49:11 +00:00
_stampa_mese = 13 ;
TApplication : : set_firm ( _ditta ) ;
1996-12-10 10:42:46 +00:00
_st_tot_fin = stampa_totali_finali ( ) ;
1995-07-31 09:49:11 +00:00
look_lia ( ) ;
ok = compila_reg ( m ) ;
if ( ! ok ) continue ;
1998-04-30 15:59:34 +00:00
if ( _tipo_stampa = = bollato | | _tipo_stampa = = rif_giornale )
1995-07-31 09:49:11 +00:00
if ( ! controlla_mov ( ) )
{
TApplication : : set_firm ( __firm ) ;
2003-03-25 13:56:11 +00:00
return error_box ( TR ( " Finire di stampare registri anno precedente " ) ) ;
1995-07-31 09:49:11 +00:00
}
if ( ! _stampa_tutti_i_registri )
{
1996-02-06 16:02:59 +00:00
_scelta = no_liquidazione ;
1999-04-06 15:34:39 +00:00
mov_from . put ( MOV_DATAREG , _data_da ) ;
mov_to . put ( MOV_DATAREG , _data_a ) ;
_cur - > setregion ( mov_from , mov_to ) ;
2012-10-26 09:12:52 +00:00
_cur - > set_filterfunction ( filter_func , true ) ;
1995-11-17 14:29:24 +00:00
//la filter function viene chiamata quando posiziono il cursore
//e' lei che determina _stampa_mese da settare in setta_mask
( * _cur ) = 0L ;
1995-07-31 09:49:11 +00:00
ok = setta_mask ( i ) ;
if ( ! ok ) continue ;
if ( _liquidazione )
{
1996-02-20 09:25:35 +00:00
_size_header = 3 ;
1999-04-06 15:34:39 +00:00
if ( ( _tipo_stampa = = bollato | | _tipo_stampa = = rif_giornale ) & & ! _stampa_ind_ditta ) _size_header + + ;
1996-02-20 09:25:35 +00:00
clear_stliq ( ) ;
//l'inizializzazione di _scelta vale per tutti
//i mesi da stampare di un certo registro (su
//cui c'e' la X di stampa liquidazione). Cio'
//e' molto importante (per capire vedi appunti)
1995-07-31 09:49:11 +00:00
_scelta = controlla_liquidazione ( ) ;
if ( _scelta = = non_proseguire )
2012-10-26 09:12:52 +00:00
return false ;
1995-07-31 09:49:11 +00:00
}
const long item = _cur - > items ( ) ;
// 17.5.95 Leggo parametri di stampa del registro
TString16 config ;
const long codditta = get_firm ( ) ;
const char * reg = ( const char * ) _codreg ;
2001-05-01 08:17:07 +00:00
config . format ( " REG%05ld%s " , codditta , reg ) ;
1995-07-31 09:49:11 +00:00
printer ( ) . read_configuration ( config ) ;
1995-11-17 14:29:24 +00:00
2012-10-26 09:12:52 +00:00
_mov_empty = true ;
1995-11-17 14:29:24 +00:00
1995-07-31 09:49:11 +00:00
if ( item > 0l )
{
print ( ) ;
1998-04-30 15:59:34 +00:00
if ( is_cancelled ( ) )
2012-10-26 09:12:52 +00:00
return false ;
1995-07-31 09:49:11 +00:00
}
//non ci sono movimenti da stampare nel periodo richiesto!
1998-04-30 15:59:34 +00:00
else
no_movimenti ( ) ;
1996-01-03 15:06:24 +00:00
1998-04-30 15:59:34 +00:00
if ( _tipo_stampa = = libro_unico & & _rif_vid )
1995-07-31 09:49:11 +00:00
{
2012-10-26 09:12:52 +00:00
_intesta_vidi = true ;
1995-07-31 09:49:11 +00:00
stampa_vidi ( ) ; //stampa riferimenti vidimazione
1996-02-06 16:02:59 +00:00
}
1995-07-31 09:49:11 +00:00
}
else //stampa tutti i registri
2006-12-13 16:22:33 +00:00
{
1995-07-31 09:49:11 +00:00
TDate sca_vid ;
2012-10-26 09:12:52 +00:00
bool one_printed = false ; // Flag per vedere se ha stampato almeno un registro (solo per rif. al libro giornale)
1995-07-31 09:49:11 +00:00
for ( _tabreg - > first ( ) ; ! _tabreg - > eof ( ) ; _tabreg - > next ( ) )
{
1998-04-30 15:59:34 +00:00
_tipo_reg = ( tiporeg ) _tabreg - > get_int ( " I0 " ) ;
2006-12-13 16:22:33 +00:00
const TString16 codtab = _tabreg - > get ( " CODTAB " ) ;
const int anno = atoi ( codtab . left ( 4 ) ) ;
1995-07-31 09:49:11 +00:00
if ( anno > _annoes )
break ;
1996-02-06 16:02:59 +00:00
if ( anno = = _annoes )
//registro iva
1998-04-30 15:59:34 +00:00
if ( _tipo_reg = = vendita | | _tipo_reg = = acquisto | | _tipo_reg = = riepilogativo )
1995-07-31 09:49:11 +00:00
{
2006-12-13 16:22:33 +00:00
_codreg = codtab . mid ( 4 , 3 ) ;
const TString8 cod_lib_un = _tabreg - > get ( " S6 " ) ;
1995-07-31 09:49:11 +00:00
sca_vid = _tabreg - > get_date ( " D1 " ) ;
1999-04-06 15:34:39 +00:00
_stampa_plafonds = _tabreg - > get_char ( " S10 " ) = = ' X ' ;
2002-12-20 16:15:03 +00:00
_stampa_num_pag = _tabreg - > get_char ( " S11 " ) = = ' X ' ;
1995-07-31 09:49:11 +00:00
_stampa_ind_ditta = _tabreg - > get_bool ( " B9 " ) ;
_liquidazione = _tabreg - > get_bool ( " B7 " ) ;
1998-04-30 15:59:34 +00:00
if ( _tipo_stampa ! = prova )
1995-07-31 09:49:11 +00:00
_u_data = _tabreg - > get_date ( " D3 " ) ;
1998-04-30 15:59:34 +00:00
if ( _tipo_stampa = = bollato | | _tipo_stampa = = rif_giornale )
1995-07-31 09:49:11 +00:00
{
if ( cod_lib_un . not_empty ( ) )
continue ;
if ( sca_vid . ok ( ) )
if ( sca_vid . month ( ) < _fino_a_mese )
continue ;
if ( _u_data . ok ( ) )
if ( _data_a < _u_data ) //e' molto imp. che rimanga < e non <= !!!
{ //(per via del discorso liq. annuale)
2003-03-25 13:56:11 +00:00
message_box ( FR ( " Ditta %ld: Il registro %s e' gia' stato stampato come bollato di %s " ) , _ditta , ( const char * ) _codreg , itom ( _fino_a_mese ) ) ;
1995-07-31 09:49:11 +00:00
continue ;
}
}
1998-04-30 15:59:34 +00:00
if ( _tipo_stampa = = rif_giornale ) //stampa con riferimenti al libro giornale
1995-07-31 09:49:11 +00:00
{
2000-10-03 13:45:12 +00:00
TDate d ;
1995-07-31 09:49:11 +00:00
bool good ;
2000-10-03 13:45:12 +00:00
bool trovato = cerca_libro_gio ( d , good ) ;
if ( trovato )
2012-10-26 09:12:52 +00:00
one_printed = true ;
2000-10-03 13:45:12 +00:00
else
1995-07-31 09:49:11 +00:00
continue ;
}
1998-04-30 15:59:34 +00:00
if ( _tipo_stampa = = libro_unico ) //stampa su libro unico
1995-07-31 09:49:11 +00:00
{
if ( cod_lib_un ! = _codlib )
continue ;
if ( sca_vid . ok ( ) )
if ( sca_vid . month ( ) < _fino_a_mese )
continue ;
if ( _u_data . ok ( ) )
if ( _fino_a_mese < _u_data . month ( ) ) //significa che e' gia'
continue ; //stato stampato
}
2012-10-26 09:12:52 +00:00
msg = false ;
1995-07-31 09:49:11 +00:00
look_reg ( ) ;
2012-10-26 09:12:52 +00:00
_intesta_liq = false ;
_intesta_vidi = false ;
1995-07-31 09:49:11 +00:00
_primast = _u_stampata ; //per la numerazione dei registri successivi
2012-10-26 09:12:52 +00:00
_ok_vidi = false ;
1995-07-31 09:49:11 +00:00
_stampa_mese = 13 ;
1996-02-06 16:02:59 +00:00
_scelta = no_liquidazione ;
1995-11-17 14:29:24 +00:00
//modifica del 09/11/1995
1999-04-06 15:34:39 +00:00
mov_from . put ( MOV_DATAREG , _data_da ) ;
mov_to . put ( MOV_DATAREG , _data_a ) ;
_cur - > setregion ( mov_from , mov_to ) ;
1995-11-17 14:29:24 +00:00
_cur - > set_filterfunction ( NULL ) ;
2012-10-26 09:12:52 +00:00
_cur - > set_filterfunction ( filter_func , true ) ;
1995-11-17 14:29:24 +00:00
( * _cur ) = 0L ;
1995-07-31 09:49:11 +00:00
ok = setta_mask ( i ) ;
1996-02-06 16:02:59 +00:00
if ( ! ok ) continue ;
if ( _liquidazione )
{
1996-02-20 09:25:35 +00:00
_size_header = 3 ;
1999-04-06 15:34:39 +00:00
if ( ( _tipo_stampa = = bollato | | _tipo_stampa = = rif_giornale ) & & ! _stampa_ind_ditta ) _size_header + + ;
1996-02-06 16:02:59 +00:00
clear_stliq ( ) ;
//N.B. E' fondamentale che _scelta venga ri-inizializzata ad ogni
//registro(cioe' dopo la stampa di ciascuno). Infatti il B0 di un
//certo mese puo' essere cambiato durante la stampa di un certo
//registro
_scelta = controlla_liquidazione ( ) ;
if ( _scelta = = non_proseguire )
2012-10-26 09:12:52 +00:00
return false ;
1996-02-06 16:02:59 +00:00
}
// Guardo se ci sono movimenti
const long items = _cur - > items ( ) ;
1998-04-30 15:59:34 +00:00
//Leggo parametri di stampa del registro
1996-02-06 16:02:59 +00:00
TString16 config ;
const long codditta = get_firm ( ) ;
const char * reg = ( const char * ) _codreg ;
2001-05-01 08:17:07 +00:00
config . format ( " REG%05ld%s " , codditta , reg ) ;
1996-02-06 16:02:59 +00:00
printer ( ) . read_configuration ( config ) ;
2012-10-26 09:12:52 +00:00
_mov_empty = true ;
1996-02-06 16:02:59 +00:00
if ( items > 0l )
{
print ( ) ;
1998-04-30 15:59:34 +00:00
if ( is_cancelled ( ) )
2012-10-26 09:12:52 +00:00
return false ;
1996-02-06 16:02:59 +00:00
}
1998-04-30 15:59:34 +00:00
else
no_movimenti ( ) ;
1996-02-06 16:02:59 +00:00
1998-04-30 15:59:34 +00:00
if ( _tipo_stampa = = libro_unico & & _rif_vid )
1996-02-06 16:02:59 +00:00
{
2012-10-26 09:12:52 +00:00
_intesta_vidi = true ;
1996-02-06 16:02:59 +00:00
stampa_vidi ( ) ; //stampa riferimenti vidimazione
}
}
} //for
1996-12-17 16:04:20 +00:00
1998-04-30 15:59:34 +00:00
if ( _tipo_stampa = = rif_giornale & & ! one_printed ) // stampa con rif libro giornale
2003-03-25 13:56:11 +00:00
message_box ( FR ( " Ditta %ld: nessun registro soddisfa i parametri indicati " ) , _ditta ) ;
1996-12-17 16:04:20 +00:00
1996-02-06 16:02:59 +00:00
if ( msg )
1998-04-30 15:59:34 +00:00
if ( _tipo_stampa = = libro_unico & & _fino_a_mese = = 1 & & _selected . ones ( ) = = 1L )
2003-03-25 13:56:11 +00:00
message_box ( FR ( " Ditta %ld: nessun registro soddisfa i parametri indicati " ) , _ditta ) ; //viene gia' dato nell'handler
1996-02-06 16:02:59 +00:00
} //da Gennaio)
1995-07-31 09:49:11 +00:00
}
1996-12-06 10:18:24 +00:00
}
printer ( ) . read_configuration ( ) ;
1996-02-06 16:02:59 +00:00
TApplication : : set_firm ( __firm ) ;
2012-10-26 09:12:52 +00:00
return true ;
1995-07-31 09:49:11 +00:00
}
1998-04-30 15:59:34 +00:00
//Stampa registro riepilogativo
bool TStampa_registri_app : : stampa_riepilogo ( int m )
1995-07-31 09:49:11 +00:00
{
1998-04-30 15:59:34 +00:00
TRiga_array vect , vect_prec ;
1996-02-23 15:27:42 +00:00
TRigaiva_array vect_det ;
2006-12-13 16:22:33 +00:00
bool stampato = false ;
1996-02-06 16:02:59 +00:00
if ( ! printer ( ) . isopen ( ) ) printer ( ) . open ( ) ;
1998-04-30 15:59:34 +00:00
for ( _tabreg - > first ( ) ; ! _tabreg - > eof ( ) ; _tabreg - > next ( ) ) // Scorre i registri
1995-07-31 09:49:11 +00:00
{
2006-12-13 16:22:33 +00:00
const TString8 codtab = _tabreg - > get ( " CODTAB " ) ;
2000-10-03 13:45:12 +00:00
const int a = atoi ( codtab . mid ( 0 , 4 ) ) ;
2006-12-13 16:22:33 +00:00
if ( a > _annoes )
break ;
2000-10-03 13:45:12 +00:00
const tiporeg tipo = ( tiporeg ) _tabreg - > get_int ( " I0 " ) ;
1998-04-30 15:59:34 +00:00
if ( a = = _annoes & & ( tipo = = vendita | | tipo = = acquisto ) )
{
2006-12-13 16:22:33 +00:00
const TString4 codreg = codtab . mid ( 4 , 3 ) ;
const TString8 codatt = _tabreg - > get ( " S8 " ) ;
1998-04-30 15:59:34 +00:00
//devo stampare sul riepilogativo
//solo i registri movimentati!!!
vect . destroy ( ) ;
vect_prec . destroy ( ) ;
vect_det . destroy ( ) ;
2006-12-13 16:22:33 +00:00
TString80 chiave ; chiave < < _annoes < < _tabreg - > get ( " S8 " ) ;
1998-04-30 15:59:34 +00:00
// Calcolo riepilogo del periodo e progressivi in caso di stampa su bollato
for ( int i = 1 ; i < = m ; i + + )
1996-02-06 16:02:59 +00:00
{
1998-04-30 15:59:34 +00:00
int start = 0 , stop = 0 ;
if ( i = = m & & _annoes > 1997 ) // Per il mese attuale
stop = 1 ; // si calcolano anche i progressivi precedenti a questo periodo (PRP)
// solo se siamo oltre il 1997
for ( int j = start ; j < = stop ; j + + )
1996-02-20 09:25:35 +00:00
{
1998-04-30 15:59:34 +00:00
const bool calc_prp = j = = 1 ;
2006-12-13 16:22:33 +00:00
TTable tab ( calc_prp ? " PRP " : _tabname ) ;
2003-03-25 13:56:11 +00:00
tab . put ( " CODTAB " , chiave ) ;
const TRectype r ( tab . curr ( ) ) ;
tab . read ( _isgteq ) ;
for ( ; ! tab . eof ( ) & & tab . curr ( ) = = r ; tab . next ( ) )
1996-02-20 09:25:35 +00:00
{
2006-12-13 16:22:33 +00:00
const TString80 ctab = tab . get ( " CODTAB " ) ;
TString4 creg = ctab . mid ( 10 , 3 ) ; creg . trim ( ) ;
2000-10-03 13:45:12 +00:00
const int mese = atoi ( ctab . mid ( 13 , 2 ) ) ;
if ( codreg = = creg & & mese = = i )
1998-04-30 15:59:34 +00:00
{
2006-12-13 16:22:33 +00:00
const TString4 codiva = ctab . mid ( 16 , 4 ) ;
const int tipodet = atoi ( ctab . mid ( 20 , 1 ) ) ;
2003-03-25 13:56:11 +00:00
real impon = tab . get_real ( " R0 " ) ;
real impos = tab . get_real ( " R1 " ) ;
real impol = tab . get_real ( " R2 " ) ;
1998-04-30 15:59:34 +00:00
if ( _tabreg - > get_bool ( " B0 " ) )
{
2003-03-25 13:56:11 +00:00
TToken_string cs ( tab . get ( " S2 " ) , ' ! ' ) ;
1998-04-30 15:59:34 +00:00
impon = cs . get ( 0 ) ;
impos = cs . get ( 1 ) ;
}
if ( _tabreg - > get_bool ( " B1 " ) )
{
2003-03-25 13:56:11 +00:00
impon = tab . get_real ( " R11 " ) ;
impos = tab . get_real ( " R12 " ) ;
1998-04-30 15:59:34 +00:00
}
2003-03-25 13:56:11 +00:00
TToken_string fatt_rit ( tab . get ( " S1 " ) , ' ! ' ) ;
1998-04-30 15:59:34 +00:00
real im ( fatt_rit . get ( 0 ) ) ;
real is ( fatt_rit . get ( 1 ) ) ;
impon + = im ;
impos + = is ;
impol + = im + is ;
if ( impon ! = ZERO | | impos ! = ZERO | | impol ! = ZERO )
{
if ( ! calc_prp & & _tipo_stampa ! = prova )
vect . add_riga ( ZERO , ZERO , ZERO , impon , impos , impol , codiva ) ;
2000-10-03 13:45:12 +00:00
if ( mese = = m | | ( _frequiva = = ' T ' & & mese > = m - 2 & & mese < = m ) ) // Guy!!!
1998-04-30 15:59:34 +00:00
if ( calc_prp )
vect_prec . add_riga ( impon , impos , impol , ZERO , ZERO , ZERO , codiva ) ;
else
vect . add_riga ( impon , impos , impol , ZERO , ZERO , ZERO , codiva ) ;
}
if ( ! calc_prp & & tipo = = acquisto ) //registro acquisti
if ( impon ! = ZERO | | impos ! = ZERO )
{
if ( _tipo_stampa ! = prova )
2006-12-13 16:22:33 +00:00
vect_det . add_riga ( ZERO , ZERO , impon , impos , codiva , tipodet , 0 , true , 0 ) ;
2000-10-03 13:45:12 +00:00
if ( mese = = m | | ( _frequiva = = ' T ' & & mese > = m - 2 & & mese < = m ) ) // Guy!!!
2006-12-13 16:22:33 +00:00
vect_det . add_riga ( impon , impos , ZERO , ZERO , codiva , tipodet , 0 , true , 0 ) ;
1998-04-30 15:59:34 +00:00
}
}
} // for table
} // for start to stop
} // for i to m
if ( vect . items ( ) > 0 )
{
2006-12-13 16:22:33 +00:00
stampato = true ;
2004-02-18 11:57:28 +00:00
for ( int i = 0 ; i < 2 ; i + + ) // Stampa i progressivi veri poi quelli da periodo prec
1996-02-20 09:25:35 +00:00
{
2006-12-13 16:22:33 +00:00
const bool print_prec = i ! = 0 ;
1998-04-30 15:59:34 +00:00
stampa_prospetto_riepilogo ( tipo , codreg , codatt , print_prec ) ;
stampa_progressivi ( print_prec ? vect_prec : vect , vect_det , tipo , print_prec ) ;
if ( vect_prec . items ( ) = = 0 )
break ;
1996-02-20 09:25:35 +00:00
}
1998-04-30 15:59:34 +00:00
}
}
1996-02-06 16:02:59 +00:00
}
1996-02-20 09:25:35 +00:00
return stampato ;
1995-07-31 09:49:11 +00:00
}
1998-04-30 15:59:34 +00:00
void TStampa_registri_app : : stampa_prospetto_riepilogo ( tiporeg tipo , const TString & codreg , const TString & codatt , const bool print_prec )
{
2008-12-03 14:53:51 +00:00
const TString80 desc ( desc_attivita ( codatt ) ) ;
1998-04-30 15:59:34 +00:00
TPrinter & pr = printer ( ) ;
TPrintrow row ;
row . reset ( ) ;
pr . print ( row ) ;
if ( ! print_prec )
{
2008-12-03 14:53:51 +00:00
row . put ( TR ( " Registro IVA: " ) , 0 ) ;
1998-04-30 15:59:34 +00:00
row . put ( codreg , 14 ) ;
row . put ( format ( " %-.40s " , ( const char * ) _tabreg - > get ( " S0 " ) ) , 18 ) ;
2012-11-30 14:36:30 +00:00
row . put ( TR ( " Attivit<EFBFBD> " ) , 60 ) ;
2008-03-11 16:48:19 +00:00
if ( _annoes > 2007 )
{
2008-12-03 14:53:51 +00:00
TString16 key ;
key . format ( " %ld|%s " , _ditta , ( const char * ) codatt ) ;
const TString & codateco = cache ( ) . get ( LF_ATTIV , key , ATT_CODATECO ) ;
2008-03-11 16:48:19 +00:00
row . put ( codateco , 70 ) ;
}
else
row . put ( codatt , 70 ) ;
row . put ( desc , 77 ) ;
1998-04-30 15:59:34 +00:00
pr . print ( row ) ;
}
else
{
2003-03-25 13:56:11 +00:00
row . put ( TR ( " DI CUI PERIODO PRECEDENTE " ) ) ;
1998-04-30 15:59:34 +00:00
pr . print ( row ) ;
}
row . reset ( ) ;
pr . print ( row ) ;
if ( tipo = = vendita & & _tabreg - > get_bool ( " B0 " ) )
2003-03-25 13:56:11 +00:00
row . put ( TR ( " ------------------ P E R I O D O ------------------- " ) , 30 ) ;
1998-04-30 15:59:34 +00:00
else
2003-03-25 13:56:11 +00:00
row . put ( TR ( " ---------- P E R I O D O ----------- " ) , 30 ) ;
1998-04-30 15:59:34 +00:00
if ( _tipo_stampa ! = prova & & ! print_prec )
{
if ( tipo = = vendita & & _tabreg - > get_bool ( " B0 " ) )
2003-03-25 13:56:11 +00:00
row . put ( TR ( " ----------- P R O G R E S S I V I -------------- " ) , 84 ) ;
1998-04-30 15:59:34 +00:00
else
2003-03-25 13:56:11 +00:00
row . put ( TR ( " ------ P R O G R E S S I V I ------ " ) , 84 ) ;
1998-04-30 15:59:34 +00:00
}
pr . print ( row ) ;
row . reset ( ) ;
2003-03-25 13:56:11 +00:00
row . put ( TR ( " Cod. " ) , 0 ) ;
1998-04-30 15:59:34 +00:00
if ( tipo = = acquisto )
{
2003-03-25 13:56:11 +00:00
row . put ( TR ( " A C Q U I S T I " ) , 40 ) ;
1998-04-30 15:59:34 +00:00
if ( _tipo_stampa ! = prova & & ! print_prec )
2003-03-25 13:56:11 +00:00
row . put ( TR ( " A C Q U I S T I " ) , 94 ) ;
1998-04-30 15:59:34 +00:00
}
if ( tipo = = vendita )
{
2003-03-25 13:56:11 +00:00
row . put ( TR ( " V E N D I T E " ) , 41 ) ;
1998-04-30 15:59:34 +00:00
if ( _tabreg - > get_bool ( " B0 " ) )
2003-03-25 13:56:11 +00:00
row . put ( TR ( " CORRISPETTIVI " ) , 67 ) ;
1998-04-30 15:59:34 +00:00
if ( _tipo_stampa ! = prova & & ! print_prec )
{
if ( _tabreg - > get_bool ( " B0 " ) )
{
2003-03-25 13:56:11 +00:00
row . put ( TR ( " V E N D I T E " ) , 94 ) ;
row . put ( TR ( " CORRISPETTIVI " ) , 118 ) ;
1998-04-30 15:59:34 +00:00
}
2008-12-03 14:53:51 +00:00
else
row . put ( TR ( " V E N D I T E " ) , 95 ) ;
1998-04-30 15:59:34 +00:00
}
}
pr . print ( row ) ;
row . reset ( ) ;
2003-03-25 13:56:11 +00:00
row . put ( TR ( " iva Descrizione " ) , 0 ) ;
row . put ( TR ( " Imponibile " ) , 34 ) ;
row . put ( TR ( " Imposta " ) , 53 ) ;
1998-04-30 15:59:34 +00:00
if ( tipo = = vendita & & _tabreg - > get_bool ( " B0 " ) )
2003-03-25 13:56:11 +00:00
row . put ( TR ( " Importi lordi " ) , 67 ) ;
1998-04-30 15:59:34 +00:00
if ( _tipo_stampa ! = prova & & ! print_prec )
{
2003-03-25 13:56:11 +00:00
row . put ( TR ( " Imponibile " ) , 87 ) ;
row . put ( TR ( " Imposta " ) , 107 ) ;
1998-04-30 15:59:34 +00:00
if ( tipo = = vendita & & _tabreg - > get_bool ( " B0 " ) )
2003-03-25 13:56:11 +00:00
row . put ( TR ( " Importi lordi " ) , 118 ) ;
1998-04-30 15:59:34 +00:00
}
pr . print ( row ) ;
row . reset ( ) ;
pr . print ( row ) ;
}
void TStampa_registri_app : : stampa_progressivi ( TRiga_array & vect ,
2006-12-13 16:22:33 +00:00
TRigaiva_array & vect_det , tiporeg treg , const bool print_prec )
1995-07-31 09:49:11 +00:00
{
1996-02-06 16:02:59 +00:00
real t_impon , t_impos , t_impol , t_imponp , t_imposp , t_impolp ;
2006-12-13 16:22:33 +00:00
1998-04-30 15:59:34 +00:00
TPrintrow riga ;
1996-02-20 09:25:35 +00:00
riga . reset ( ) ;
1996-02-06 16:02:59 +00:00
//ordinamento per codice iva
vect . sort ( compare_rows ) ;
for ( int k = 0 ; k < vect . items ( ) ; k + + )
{
2006-12-13 16:22:33 +00:00
const TRiga & r = ( const TRiga & ) vect [ k ] ;
1996-02-06 16:02:59 +00:00
riga . reset ( ) ;
riga . put ( format ( " %-4s " , ( const char * ) r . _codiva ) , 0 ) ;
2006-12-13 16:22:33 +00:00
const TString & d = descr_iva ( r . _codiva ) ;
1996-02-06 16:02:59 +00:00
riga . put ( format ( " %-.23s " , ( const char * ) d ) , 5 ) ;
if ( r . _imponibile ! = ZERO )
1999-07-16 14:59:11 +00:00
print_real ( riga , r . _imponibile , 29 ) ;
1996-02-06 16:02:59 +00:00
if ( r . _imposta ! = ZERO )
1999-07-16 14:59:11 +00:00
print_real ( riga , r . _imposta , 45 ) ;
1998-04-30 15:59:34 +00:00
if ( treg = = vendita & & _tabreg - > get_bool ( " B0 " ) )
1996-02-06 16:02:59 +00:00
if ( r . _implordo ! = ZERO )
1999-07-16 14:59:11 +00:00
print_real ( riga , r . _implordo , 65 ) ;
1998-04-30 15:59:34 +00:00
if ( _tipo_stampa ! = prova & & ! print_prec )
1995-07-31 09:49:11 +00:00
{
1996-02-06 16:02:59 +00:00
if ( r . _imponibilep ! = ZERO )
1999-07-16 14:59:11 +00:00
print_real ( riga , r . _imponibilep , 82 ) ;
1996-02-06 16:02:59 +00:00
if ( r . _impostap ! = ZERO )
1999-07-16 14:59:11 +00:00
print_real ( riga , r . _impostap , 99 ) ;
1998-04-30 15:59:34 +00:00
if ( treg = = vendita & & _tabreg - > get_bool ( " B0 " ) )
1996-02-06 16:02:59 +00:00
if ( r . _implordop ! = ZERO )
1999-07-16 14:59:11 +00:00
print_real ( riga , r . _implordop , 116 ) ;
1995-07-31 09:49:11 +00:00
}
1996-02-06 16:02:59 +00:00
printer ( ) . print ( riga ) ;
riga . reset ( ) ;
t_impon + = r . _imponibile ;
t_impos + = r . _imposta ;
t_impol + = r . _implordo ;
t_imponp + = r . _imponibilep ;
t_imposp + = r . _impostap ;
t_impolp + = r . _implordop ;
1995-07-31 09:49:11 +00:00
}
1998-04-30 15:59:34 +00:00
1996-02-06 16:02:59 +00:00
printer ( ) . print ( riga ) ;
2003-03-25 13:56:11 +00:00
riga . put ( TR ( " TOTALE " ) , 0 ) ;
1996-02-06 16:02:59 +00:00
if ( t_impon ! = ZERO )
1999-07-16 14:59:11 +00:00
print_real ( riga , t_impon , 29 ) ;
1996-02-06 16:02:59 +00:00
if ( t_impos ! = ZERO )
1999-07-16 14:59:11 +00:00
print_real ( riga , t_impos , 45 ) ;
1998-04-30 15:59:34 +00:00
if ( treg = = vendita & & _tabreg - > get_bool ( " B0 " ) )
1996-02-06 16:02:59 +00:00
if ( t_impol ! = ZERO )
1999-07-16 14:59:11 +00:00
print_real ( riga , t_impol , 65 ) ;
1998-04-30 15:59:34 +00:00
if ( _tipo_stampa ! = prova & & ! print_prec )
1995-07-31 09:49:11 +00:00
{
1996-02-06 16:02:59 +00:00
if ( t_imponp ! = ZERO )
1999-07-16 14:59:11 +00:00
print_real ( riga , t_imponp , 82 ) ;
1996-02-06 16:02:59 +00:00
if ( t_imposp ! = ZERO )
1999-07-16 14:59:11 +00:00
print_real ( riga , t_imposp , 99 ) ;
1998-04-30 15:59:34 +00:00
if ( treg = = vendita & & _tabreg - > get_bool ( " B0 " ) )
1996-02-06 16:02:59 +00:00
if ( t_impolp ! = ZERO )
1999-07-16 14:59:11 +00:00
print_real ( riga , t_impolp , 116 ) ;
1996-02-06 16:02:59 +00:00
}
1996-02-23 15:27:42 +00:00
printer ( ) . print ( riga ) ;
//stampa tipi di indetraibilita' se registro acquisti
1998-04-30 15:59:34 +00:00
if ( treg = = acquisto & & ! print_prec )
1996-02-23 15:27:42 +00:00
{
real tot_imponib , tot_imposta , tot_imponibp , tot_impostap ;
int tdetprec = - 1 ;
tot_imponib = tot_imposta = tot_imponibp = tot_impostap = ZERO ;
2006-12-13 16:22:33 +00:00
vect_det . sort ( compare_righeiva ) ;
1996-02-23 15:27:42 +00:00
for ( int s = 0 ; s < vect_det . items ( ) ; s + + )
{
2006-12-13 16:22:33 +00:00
const TRigaiva & r = vect_det . riga ( s ) ;
const int tipodet = r . _tipodet ;
switch ( tipodet )
1996-02-23 15:27:42 +00:00
{
case 1 :
{
if ( tdetprec = = 3 | | tdetprec = = 9 )
{
riga . reset ( ) ;
printer ( ) . print ( riga ) ;
2003-03-25 13:56:11 +00:00
riga . put ( TR ( " TOTALE " ) , 0 ) ;
1996-02-23 15:27:42 +00:00
if ( tot_imponib ! = ZERO )
1999-07-16 14:59:11 +00:00
print_real ( riga , tot_imponib , 29 ) ;
1996-02-23 15:27:42 +00:00
if ( tot_imposta ! = ZERO )
1999-07-16 14:59:11 +00:00
print_real ( riga , tot_imposta , 45 ) ;
1998-04-30 15:59:34 +00:00
if ( _tipo_stampa ! = prova )
1996-02-23 15:27:42 +00:00
{
if ( tot_imponibp ! = ZERO )
1999-07-16 14:59:11 +00:00
print_real ( riga , tot_imponibp , 82 ) ;
1996-02-23 15:27:42 +00:00
if ( tot_impostap ! = ZERO )
1999-07-16 14:59:11 +00:00
print_real ( riga , tot_impostap , 99 ) ;
1996-02-23 15:27:42 +00:00
}
printer ( ) . print ( riga ) ;
tot_imponib = tot_imposta = tot_imponibp = tot_impostap = ZERO ;
}
2006-12-13 16:22:33 +00:00
if ( tipodet ! = tdetprec )
1996-02-23 15:27:42 +00:00
{
riga . reset ( ) ;
printer ( ) . print ( riga ) ;
2003-03-25 13:56:11 +00:00
riga . put ( TR ( " ----- Indetraibile su op.es. ----- " ) , 0 ) ;
1996-02-23 15:27:42 +00:00
printer ( ) . print ( riga ) ;
riga . reset ( ) ;
2003-03-25 13:56:11 +00:00
riga . put ( TR ( " Cod. " ) , 0 ) ;
1996-02-23 15:27:42 +00:00
printer ( ) . print ( riga ) ;
riga . reset ( ) ;
2003-03-25 13:56:11 +00:00
riga . put ( TR ( " iva Descrizione " ) , 0 ) ;
riga . put ( TR ( " Imponibile " ) , 34 ) ;
riga . put ( TR ( " Imposta " ) , 53 ) ;
1998-04-30 15:59:34 +00:00
if ( _tipo_stampa ! = prova )
1996-02-23 15:27:42 +00:00
{
2003-03-25 13:56:11 +00:00
riga . put ( TR ( " Imponibile " ) , 87 ) ;
riga . put ( TR ( " Imposta " ) , 107 ) ;
1996-02-23 15:27:42 +00:00
}
printer ( ) . print ( riga ) ;
riga . reset ( ) ;
printer ( ) . print ( riga ) ;
}
riga . put ( format ( " %-4s " , ( const char * ) r . _codiva ) , 0 ) ;
2006-12-13 16:22:33 +00:00
const TString & descr = descr_iva ( r . _codiva ) ;
1996-02-23 15:27:42 +00:00
riga . put ( format ( " %-.23s " , ( const char * ) descr ) , 5 ) ;
if ( r . _imponibile ! = ZERO )
1999-07-16 14:59:11 +00:00
print_real ( riga , r . _imponibile , 29 ) ;
1996-02-23 15:27:42 +00:00
if ( r . _imposta ! = ZERO )
1999-07-16 14:59:11 +00:00
print_real ( riga , r . _imposta , 45 ) ;
1998-04-30 15:59:34 +00:00
if ( _tipo_stampa ! = prova )
1996-02-23 15:27:42 +00:00
{
if ( r . _imponibilep ! = ZERO )
1999-07-16 14:59:11 +00:00
print_real ( riga , r . _imponibilep , 82 ) ;
1996-02-23 15:27:42 +00:00
if ( r . _impostap ! = ZERO )
1999-07-16 14:59:11 +00:00
print_real ( riga , r . _impostap , 99 ) ;
1996-02-23 15:27:42 +00:00
}
printer ( ) . print ( riga ) ;
tot_imponib + = r . _imponibile ;
tot_imposta + = r . _imposta ;
tot_imponibp + = r . _imponibilep ;
tot_impostap + = r . _impostap ;
2006-12-13 16:22:33 +00:00
tdetprec = tipodet ;
1996-02-23 15:27:42 +00:00
}
break ;
case 3 :
{
if ( tdetprec = = 1 | | tdetprec = = 9 )
{
riga . reset ( ) ;
printer ( ) . print ( riga ) ;
2003-03-25 13:56:11 +00:00
riga . put ( TR ( " TOTALE " ) , 0 ) ;
1996-02-23 15:27:42 +00:00
if ( tot_imponib ! = ZERO )
1999-07-16 14:59:11 +00:00
print_real ( riga , tot_imponib , 29 ) ;
1996-02-23 15:27:42 +00:00
if ( tot_imposta ! = ZERO )
1999-07-16 14:59:11 +00:00
print_real ( riga , tot_imposta , 45 ) ;
1998-04-30 15:59:34 +00:00
if ( _tipo_stampa ! = prova )
1996-02-23 15:27:42 +00:00
{
if ( tot_imponibp ! = ZERO )
1999-07-16 14:59:11 +00:00
print_real ( riga , tot_imponibp , 82 ) ;
1996-02-23 15:27:42 +00:00
if ( tot_impostap ! = ZERO )
1999-07-16 14:59:11 +00:00
print_real ( riga , tot_impostap , 99 ) ;
1996-02-23 15:27:42 +00:00
}
printer ( ) . print ( riga ) ;
tot_imponib = tot_imposta = tot_imponibp = tot_impostap = ZERO ;
}
2006-12-13 16:22:33 +00:00
if ( tipodet ! = tdetprec )
1996-02-23 15:27:42 +00:00
{
riga . reset ( ) ;
printer ( ) . print ( riga ) ;
2003-03-25 13:56:11 +00:00
riga . put ( TR ( " ----- Passaggi interni ----- " ) , 0 ) ;
1996-02-23 15:27:42 +00:00
printer ( ) . print ( riga ) ;
riga . reset ( ) ;
2003-03-25 13:56:11 +00:00
riga . put ( TR ( " Cod. " ) , 0 ) ;
1996-02-23 15:27:42 +00:00
printer ( ) . print ( riga ) ;
riga . reset ( ) ;
2003-03-25 13:56:11 +00:00
riga . put ( TR ( " iva Descrizione " ) , 0 ) ;
riga . put ( TR ( " Imponibile " ) , 34 ) ;
riga . put ( TR ( " Imposta " ) , 53 ) ;
1998-04-30 15:59:34 +00:00
if ( _tipo_stampa ! = prova )
1996-02-23 15:27:42 +00:00
{
2003-03-25 13:56:11 +00:00
riga . put ( TR ( " Imponibile " ) , 87 ) ;
riga . put ( TR ( " Imposta " ) , 107 ) ;
1996-02-23 15:27:42 +00:00
}
printer ( ) . print ( riga ) ;
riga . reset ( ) ;
printer ( ) . print ( riga ) ;
}
riga . put ( format ( " %-4s " , ( const char * ) r . _codiva ) , 0 ) ;
2006-12-13 16:22:33 +00:00
const TString & descr = descr_iva ( r . _codiva ) ;
1996-02-23 15:27:42 +00:00
riga . put ( format ( " %-.23s " , ( const char * ) descr ) , 5 ) ;
if ( r . _imponibile ! = ZERO )
1999-07-16 14:59:11 +00:00
print_real ( riga , r . _imponibile , 29 ) ;
1996-02-23 15:27:42 +00:00
if ( r . _imposta ! = ZERO )
1999-07-16 14:59:11 +00:00
print_real ( riga , r . _imposta , 45 ) ;
1998-04-30 15:59:34 +00:00
if ( _tipo_stampa ! = prova )
1996-02-23 15:27:42 +00:00
{
if ( r . _imponibilep ! = ZERO )
1999-07-16 14:59:11 +00:00
print_real ( riga , r . _imponibilep , 82 ) ;
1996-02-23 15:27:42 +00:00
if ( r . _impostap ! = ZERO )
1999-07-16 14:59:11 +00:00
print_real ( riga , r . _impostap , 99 ) ;
1996-02-23 15:27:42 +00:00
}
printer ( ) . print ( riga ) ;
tot_imponib + = r . _imponibile ;
tot_imposta + = r . _imposta ;
tot_imponibp + = r . _imponibilep ;
tot_impostap + = r . _impostap ;
2006-12-13 16:22:33 +00:00
tdetprec = tipodet ;
1996-02-23 15:27:42 +00:00
}
break ;
case 9 :
{
if ( tdetprec = = 1 | | tdetprec = = 3 )
{
riga . reset ( ) ;
printer ( ) . print ( riga ) ;
2003-03-25 13:56:11 +00:00
riga . put ( TR ( " TOTALE " ) , 0 ) ;
1996-02-23 15:27:42 +00:00
if ( tot_imponib ! = ZERO )
1999-07-16 14:59:11 +00:00
print_real ( riga , tot_imponib , 29 ) ;
1996-02-23 15:27:42 +00:00
if ( tot_imposta ! = ZERO )
1999-07-16 14:59:11 +00:00
print_real ( riga , tot_imposta , 45 ) ;
1998-04-30 15:59:34 +00:00
if ( _tipo_stampa ! = prova )
1996-02-23 15:27:42 +00:00
{
if ( tot_imponibp ! = ZERO )
1999-07-16 14:59:11 +00:00
print_real ( riga , tot_imponibp , 82 ) ;
1996-02-23 15:27:42 +00:00
if ( tot_impostap ! = ZERO )
1999-07-16 14:59:11 +00:00
print_real ( riga , tot_impostap , 99 ) ;
1996-02-23 15:27:42 +00:00
}
printer ( ) . print ( riga ) ;
tot_imponib = tot_imposta = tot_imponibp = tot_impostap = ZERO ;
}
2006-12-13 16:22:33 +00:00
if ( tipodet ! = tdetprec )
1996-02-23 15:27:42 +00:00
{
riga . reset ( ) ;
printer ( ) . print ( riga ) ;
2003-03-25 13:56:11 +00:00
riga . put ( TR ( " ----- N.D. 9 - acquisti indeducibili per ART.19 ----- " ) , 0 ) ;
1996-02-23 15:27:42 +00:00
printer ( ) . print ( riga ) ;
riga . reset ( ) ;
2003-03-25 13:56:11 +00:00
riga . put ( TR ( " Cod. " ) , 0 ) ;
1996-02-23 15:27:42 +00:00
printer ( ) . print ( riga ) ;
riga . reset ( ) ;
2003-03-25 13:56:11 +00:00
riga . put ( TR ( " iva Descrizione " ) , 0 ) ;
riga . put ( TR ( " Imponibile " ) , 34 ) ;
riga . put ( TR ( " Imposta " ) , 53 ) ;
1998-04-30 15:59:34 +00:00
if ( _tipo_stampa ! = prova )
1996-02-23 15:27:42 +00:00
{
2003-03-25 13:56:11 +00:00
riga . put ( TR ( " Imponibile " ) , 87 ) ;
riga . put ( TR ( " Imposta " ) , 107 ) ;
1996-02-23 15:27:42 +00:00
}
printer ( ) . print ( riga ) ;
riga . reset ( ) ;
printer ( ) . print ( riga ) ;
}
riga . put ( format ( " %-4s " , ( const char * ) r . _codiva ) , 0 ) ;
2006-12-13 16:22:33 +00:00
const TString & descr = descr_iva ( r . _codiva ) ;
1996-02-23 15:27:42 +00:00
riga . put ( format ( " %-.23s " , ( const char * ) descr ) , 5 ) ;
if ( r . _imponibile ! = ZERO )
1999-07-16 14:59:11 +00:00
print_real ( riga , r . _imponibile , 29 ) ;
1996-02-23 15:27:42 +00:00
if ( r . _imposta ! = ZERO )
1999-07-16 14:59:11 +00:00
print_real ( riga , r . _imposta , 45 ) ;
1998-04-30 15:59:34 +00:00
if ( _tipo_stampa ! = prova )
1996-02-23 15:27:42 +00:00
{
if ( r . _imponibilep ! = ZERO )
1999-07-16 14:59:11 +00:00
print_real ( riga , r . _imponibilep , 82 ) ;
1996-02-23 15:27:42 +00:00
if ( r . _impostap ! = ZERO )
1999-07-16 14:59:11 +00:00
print_real ( riga , r . _impostap , 99 ) ;
1996-02-23 15:27:42 +00:00
}
printer ( ) . print ( riga ) ;
tot_imponib + = r . _imponibile ;
tot_imposta + = r . _imposta ;
tot_imponibp + = r . _imponibilep ;
tot_impostap + = r . _impostap ;
2006-12-13 16:22:33 +00:00
tdetprec = tipodet ;
1996-02-23 15:27:42 +00:00
}
break ;
default : break ;
}
}
if ( vect_det . items ( ) > 0 )
if ( tdetprec = = 1 | | tdetprec = = 3 | | tdetprec = = 9 )
{
riga . reset ( ) ;
printer ( ) . print ( riga ) ;
2003-03-25 13:56:11 +00:00
riga . put ( TR ( " TOTALE " ) , 0 ) ;
1996-02-23 15:27:42 +00:00
if ( tot_imponib ! = ZERO )
1999-07-16 14:59:11 +00:00
print_real ( riga , tot_imponib , 29 ) ;
1996-02-23 15:27:42 +00:00
if ( tot_imposta ! = ZERO )
1999-07-16 14:59:11 +00:00
print_real ( riga , tot_imposta , 45 ) ;
1998-04-30 15:59:34 +00:00
if ( _tipo_stampa ! = prova )
1996-02-23 15:27:42 +00:00
{
if ( tot_imponibp ! = ZERO )
1999-07-16 14:59:11 +00:00
print_real ( riga , tot_imponibp , 82 ) ;
1996-02-23 15:27:42 +00:00
if ( tot_impostap ! = ZERO )
1999-07-16 14:59:11 +00:00
print_real ( riga , tot_impostap , 99 ) ;
1996-02-23 15:27:42 +00:00
}
printer ( ) . print ( riga ) ;
}
}
1996-02-06 16:02:59 +00:00
}
1995-07-31 09:49:11 +00:00
2006-12-13 16:22:33 +00:00
int cg4400 ( int argc , char * argv [ ] )
1995-07-31 09:49:11 +00:00
{
2003-03-25 13:56:11 +00:00
TStampa_registri_app a ;
a . run ( argc , argv , TR ( " Stampa registri IVA " ) ) ;
1995-07-31 09:49:11 +00:00
return 0 ;
2008-03-11 15:08:43 +00:00
}