1409 lines
		
	
	
		
			38 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			1409 lines
		
	
	
		
			38 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
// cg3400
 | 
						|
// Stampa libro giornale
 | 
						|
 | 
						|
#include <applicat.h>
 | 
						|
#include <isam.h>
 | 
						|
#include <date.h>
 | 
						|
#include <mask.h>
 | 
						|
#include <lffiles.h>
 | 
						|
#include <utility.h>
 | 
						|
#include <tabutil.h>
 | 
						|
#include <urldefid.h>
 | 
						|
#include <printapp.h>
 | 
						|
#include <config.h>
 | 
						|
#include <progind.h>
 | 
						|
 | 
						|
#include <mov.h>
 | 
						|
#include <rmov.h>
 | 
						|
#include <rmoviva.h>
 | 
						|
#include <nditte.h>
 | 
						|
#include <anagr.h>
 | 
						|
#include <anafis.h>
 | 
						|
#include <anagiu.h>
 | 
						|
#include <causali.h>
 | 
						|
#include <comuni.h>
 | 
						|
#include <pconti.h>
 | 
						|
#include <clifo.h>
 | 
						|
#include <occas.h>
 | 
						|
 | 
						|
#ifndef __CG3401_H
 | 
						|
#include "cg3401.h"  // qui c'e' TRigaiva_array
 | 
						|
#endif
 | 
						|
 | 
						|
#include "cg3400a.h"
 | 
						|
#include "cg3400b.h"
 | 
						|
 | 
						|
#define RIGHE_FOOTER 10
 | 
						|
#define REAL_PICTURE "###.###.###.###"
 | 
						|
 | 
						|
const MAXSTR = 128;
 | 
						|
static char __tmp [MAXSTR];
 | 
						|
static TFixed_string tmp (__tmp, MAXSTR);
 | 
						|
 | 
						|
enum descr { causale, conto, operazione };
 | 
						|
 | 
						|
bool mask_a_cod_reg    (TMask_field& f, KEY k);
 | 
						|
bool mask_a_data       (TMask_field& f, KEY k);
 | 
						|
bool mask_b_ripristina (TMask_field& f, KEY k);
 | 
						|
 | 
						|
class CG3400_application : public TPrintapp
 | 
						|
{
 | 
						|
  friend bool mask_a_cod_reg   (TMask_field& f, KEY k);
 | 
						|
  friend bool mask_a_data      (TMask_field& f, KEY k);
 | 
						|
  friend bool mask_b_ripristina(TMask_field& f, KEY k);
 | 
						|
 | 
						|
  TRigaiva_array  _iva_array;
 | 
						|
  TRelation  * _rel;
 | 
						|
  TCursor    * _cur;
 | 
						|
  TRectype   * _RecPartoDa, *_RecArrivoA;
 | 
						|
 | 
						|
  TString      _reg_cod, _reg_anno, _reg_descr;
 | 
						|
  TDate        _data_da, _data_a, _last_data;
 | 
						|
  bool         _stampa_definitiva;
 | 
						|
  real         _tot_dare, _tot_avere;              // valori di partenza
 | 
						|
  real         _tot_dare_progr, _tot_avere_progr;  // progressivi
 | 
						|
  real         _tot_dare_gg , _tot_avere_gg ;      // giornalieri
 | 
						|
  real         _tot_dare_ac , _tot_avere_ac ;      // anno precedente
 | 
						|
  long         _nprog_da, _nprog_mov;
 | 
						|
  int          _num_rig, _stampa_width, _stampa_len;
 | 
						|
 | 
						|
  TParagraph_string      *_descr_conto;  
 | 
						|
  TParagraph_string      *_descr_causale;  
 | 
						|
  TParagraph_string      *_descr_operazione;  
 | 
						|
 | 
						|
  int          _pagine_stampate, _pagine_numerate, _stampa_ok, _pagina_da;
 | 
						|
  TDate        _data_corr, _data_succ;
 | 
						|
  int          _mese_corr, _mese_succ;
 | 
						|
  int          _last_header;    // prima riga di intestazione "libera"
 | 
						|
 | 
						|
  bool         _libro_giornale_iva_unico, _libro_cronologico, _stampa_intesta;
 | 
						|
  bool         _occas;                  // se e' cliente occasionale
 | 
						|
  bool         _gia_settata_riga_mov;   // per la stampa no iva
 | 
						|
  TString      _viacf, _civcf, _comcf, _capcf, _statocf;        // dati C/F
 | 
						|
  TString      _ragsoc, _paiva, _comunefis, _provfis, _viafis;  // dati ditta
 | 
						|
  TString      _cofi, _cap, _anno_es;
 | 
						|
  TLocalisamfile * _com, *_clifo,*_pconti,*_nditte,*_anag, *_caus;
 | 
						|
  TTable         *_tabreg, *_tabval, *_tabes; 
 | 
						|
 | 
						|
public:
 | 
						|
  virtual void preprocess_header();
 | 
						|
  virtual void preprocess_footer();
 | 
						|
  virtual bool preprocess_page(int, int);
 | 
						|
  virtual print_action postprocess_page(int, int);
 | 
						|
  virtual bool preprocess_print(int, int);
 | 
						|
  virtual print_action postprocess_print(int, int);
 | 
						|
  virtual void postclose_print();
 | 
						|
 | 
						|
  virtual void user_create();
 | 
						|
  virtual void user_destroy();
 | 
						|
 | 
						|
  virtual void set_page    (int, int);
 | 
						|
  void         set_rows (int, int);
 | 
						|
  void         set_page_132(int, int);
 | 
						|
  void         set_page_198(int, int);
 | 
						|
  void         setta_righe_indirizzo();
 | 
						|
  int          setta_righe_iva();
 | 
						|
  void         setta_righe_valuta();
 | 
						|
  void         setta_righe_descr(TParagraph_string*, enum descr);
 | 
						|
  void         calcola_iva();
 | 
						|
  virtual bool cancel_hook();
 | 
						|
  virtual bool set_print(int);
 | 
						|
 | 
						|
  int          stampa_intestazione_ditta();
 | 
						|
  int          set_header_132();
 | 
						|
  int          set_header_198();
 | 
						|
 | 
						|
  bool leggi_tabreg(const char *, const char *);
 | 
						|
  void aggiorna_tabreg(int, int);
 | 
						|
  void aggiorna_mov();
 | 
						|
  void scrivi_numgio(long);
 | 
						|
  void stampa_totali_giorno(TDate, bool);
 | 
						|
  void get_dati_ditta ();
 | 
						|
  TLocalisamfile * get_descr (TLocalisamfile*,TLocalisamfile*,int, int, long);
 | 
						|
 | 
						|
  bool IsInEsercizio (TDate& da, TDate& a, int anno_eser);
 | 
						|
	const char * SimboloValuta (const char * cod);
 | 
						|
  const char * get_descr_caus (const char * codcaus);
 | 
						|
 | 
						|
  CG3400_application() : _reg_cod(3), _reg_anno(4), _tot_dare_progr(0.00),
 | 
						|
                         _tot_avere_progr (0.00), _data_da(""), _data_a("")
 | 
						|
  {};
 | 
						|
  virtual ~CG3400_application() {};
 | 
						|
};
 | 
						|
 | 
						|
//////////////////////////////////////////////////////////////////////////
 | 
						|
// Funzioni legate ai parametri ditta
 | 
						|
//////////////////////////////////////////////////////////////////////////
 | 
						|
bool libro_giornale_iva_unico()
 | 
						|
{
 | 
						|
 	TConfig conf(CONFIG_DITTA);
 | 
						|
 | 
						|
  return conf.get("StLgiU") == "X";
 | 
						|
}
 | 
						|
 | 
						|
bool libro_cronologico()
 | 
						|
{
 | 
						|
 	TConfig conf(CONFIG_DITTA);
 | 
						|
 | 
						|
  return conf.get("GsLbCr") == "X";
 | 
						|
}
 | 
						|
 | 
						|
TRectype& look_com (const char * cod, TLocalisamfile *comuni)
 | 
						|
{
 | 
						|
  comuni->zero();
 | 
						|
  comuni->put(COM_COM, cod);
 | 
						|
  comuni->read();
 | 
						|
  if (comuni->bad())
 | 
						|
    comuni->zero();
 | 
						|
 | 
						|
  return comuni->curr();
 | 
						|
}
 | 
						|
 | 
						|
bool CG3400_application::IsInEsercizio (TDate& da, TDate& a, int anno_eser)
 | 
						|
{
 | 
						|
  TTable& TabEs = *_tabes; 
 | 
						|
  TString codtab;
 | 
						|
  TDate   inizio, fine;
 | 
						|
 | 
						|
  if (!da.ok() || !a.ok()) return FALSE;
 | 
						|
 | 
						|
  TabEs.zero();
 | 
						|
 | 
						|
  codtab << format ("%-4d", anno_eser);
 | 
						|
  TabEs.put ("CODTAB", codtab);
 | 
						|
  TabEs.read();
 | 
						|
  if (TabEs.good())
 | 
						|
  {
 | 
						|
    inizio = TabEs.get_date ("D0");
 | 
						|
    fine   = TabEs.get_date ("D1");
 | 
						|
    if ((da >= inizio) && (a <= fine))
 | 
						|
      return TRUE;
 | 
						|
    else
 | 
						|
    {
 | 
						|
      TString da(inizio.string());
 | 
						|
      TString  a(fine.string());
 | 
						|
      warning_box("Le date devono essere comprese tra %s e %s", (const char*)da, (const char*)a);
 | 
						|
      return FALSE;
 | 
						|
    }
 | 
						|
  }
 | 
						|
  return FALSE;
 | 
						|
}
 | 
						|
 | 
						|
const char * CG3400_application::SimboloValuta (const char * cod)
 | 
						|
{
 | 
						|
  TTable& tab_val = *_tabval;
 | 
						|
  TString codtab = format ("%-3s", cod); 
 | 
						|
//  static  char simbolo;
 | 
						|
 | 
						|
  tab_val.zero();
 | 
						|
         
 | 
						|
  tab_val.put("CODTAB", codtab);
 | 
						|
  tab_val.read();
 | 
						|
  if (tab_val.good())
 | 
						|
     tmp = tab_val.get("S7");
 | 
						|
  else 
 | 
						|
     tmp = "";
 | 
						|
 | 
						|
  return __tmp;
 | 
						|
}
 | 
						|
 | 
						|
const char * CG3400_application::get_descr_caus (const char * codcaus)
 | 
						|
{
 | 
						|
  TLocalisamfile& caus = *_caus;
 | 
						|
  
 | 
						|
  caus.zero();
 | 
						|
  caus.put (CAU_CODCAUS, codcaus);
 | 
						|
 | 
						|
  caus.read();
 | 
						|
 | 
						|
  if (caus.bad())
 | 
						|
    caus.zero();
 | 
						|
 | 
						|
  tmp = caus.get(CAU_DESCR);
 | 
						|
  return __tmp;
 | 
						|
}
 | 
						|
 | 
						|
TLocalisamfile * CG3400_application::get_descr (TLocalisamfile *pconti,
 | 
						|
                                                TLocalisamfile *clifo, 
 | 
						|
                                                int g, int c, long s)
 | 
						|
{
 | 
						|
  pconti->zero();
 | 
						|
  pconti->put (PCN_GRUPPO, g);
 | 
						|
  pconti->put (PCN_CONTO , c);
 | 
						|
  pconti->put (PCN_SOTTOCONTO, s);
 | 
						|
 | 
						|
  pconti->read();
 | 
						|
 | 
						|
  if (pconti->good())
 | 
						|
    return pconti;
 | 
						|
 | 
						|
  TString tipocf = pconti->get(PCN_TMCF);
 | 
						|
  long    codcf  = s;
 | 
						|
 | 
						|
  clifo->zero();
 | 
						|
  clifo->put(CLI_CODCF, codcf);
 | 
						|
  clifo->put(CLI_TIPOCF, tipocf);
 | 
						|
 | 
						|
  clifo->read();
 | 
						|
 | 
						|
  if (clifo->good())
 | 
						|
  {
 | 
						|
    _viacf   = clifo->get(CLI_INDCF);
 | 
						|
    _civcf   = clifo->get(CLI_CIVCF);
 | 
						|
    _comcf   = clifo->get(CLI_COMCF);
 | 
						|
    _capcf   = clifo->get(CLI_CAPCF);
 | 
						|
    _statocf = clifo->get(CLI_STATOCF);
 | 
						|
    _occas   = clifo->get_bool(CLI_OCCAS);
 | 
						|
    return clifo;
 | 
						|
  }
 | 
						|
 | 
						|
  return NULL;
 | 
						|
}
 | 
						|
 | 
						|
void CG3400_application::get_dati_ditta ()
 | 
						|
{
 | 
						|
  TString          codanagr;
 | 
						|
  TString          tipoa;
 | 
						|
 | 
						|
  _nditte->zero();
 | 
						|
  _nditte->put(NDT_CODDITTA, get_firm());   
 | 
						|
  _nditte->read();
 | 
						|
 | 
						|
  if (_nditte->bad()) _nditte->zero();
 | 
						|
 | 
						|
  _ragsoc  = _nditte->get(NDT_RAGSOC);
 | 
						|
  codanagr = _nditte->curr().get(NDT_CODANAGR);
 | 
						|
  tipoa    = _nditte->curr().get(NDT_TIPOA);
 | 
						|
 | 
						|
  _anag->setkey(1);
 | 
						|
  _anag->zero();
 | 
						|
  _anag->put (ANA_TIPOA, tipoa);
 | 
						|
  _anag->put (ANA_CODANAGR, codanagr);
 | 
						|
  _anag->read();
 | 
						|
  if (_anag->bad()) _anag->zero();
 | 
						|
 
 | 
						|
  _cofi      = _anag->get(ANA_COFI);
 | 
						|
  _paiva     = _anag->get(ANA_PAIV);
 | 
						|
//  _ragsoc    = _anag->get(ANA_RAGSOC);
 | 
						|
  _comunefis = _anag->get(ANA_COMRF);
 | 
						|
 | 
						|
  if (_comunefis.empty()) 
 | 
						|
    _comunefis   = _anag->get(ANF_COMRES);
 | 
						|
 | 
						|
  TRectype dep = look_com (_comunefis, _com);
 | 
						|
 | 
						|
  _comunefis   = dep.get(COM_DENCOM);
 | 
						|
  _provfis     = dep.get(COM_PROVCOM);
 | 
						|
  _cap         = dep.get(COM_CAPCOM);
 | 
						|
  if (_comunefis.empty()) 
 | 
						|
  {
 | 
						|
    _viafis      = _anag->get(ANA_INDRF);
 | 
						|
    _viafis.rtrim();
 | 
						|
    _viafis << " " << _anag->curr().get (ANA_CIVRF); 
 | 
						|
  }
 | 
						|
  else
 | 
						|
  {
 | 
						|
    _viafis      = _anag->get(ANA_INDRES);
 | 
						|
    _viafis.rtrim();
 | 
						|
    _viafis << " " << _anag->get (ANA_CIVRES); 
 | 
						|
  }
 | 
						|
}
 | 
						|
 | 
						|
void CG3400_application::user_create()
 | 
						|
{
 | 
						|
  _libro_giornale_iva_unico = libro_giornale_iva_unico();
 | 
						|
  _libro_cronologico        = libro_cronologico();
 | 
						|
 | 
						|
  _tabreg = new TTable ("REG");
 | 
						|
  _tabval = new TTable ("%VAL");
 | 
						|
  _tabes  = new TTable ("ESC");
 | 
						|
 | 
						|
  _nditte = new TLocalisamfile(LF_NDITTE); 
 | 
						|
  _anag   = new TLocalisamfile (LF_ANAG); 
 | 
						|
  _com    = new TLocalisamfile(LF_COMUNI);
 | 
						|
  _clifo  = new TLocalisamfile(LF_CLIFO);
 | 
						|
  _pconti = new TLocalisamfile(LF_PCON);
 | 
						|
  _caus   = new TLocalisamfile(LF_CAUSALI);
 | 
						|
 | 
						|
  _descr_conto      = new TParagraph_string ("",10);
 | 
						|
  _descr_operazione = new TParagraph_string ("",10);
 | 
						|
  _descr_causale    = new TParagraph_string ("",10);
 | 
						|
 | 
						|
  disable_print_menu();
 | 
						|
 | 
						|
  _rel = new TRelation (LF_MOV);
 | 
						|
  _rel->add (LF_RMOV,    "NUMREG=NUMREG");
 | 
						|
  _rel->add (LF_RMOVIVA, "NUMREG=NUMREG");
 | 
						|
 | 
						|
  _cur = new TCursor (_rel, "", 2);   // usa la chiave 2 su MOV
 | 
						|
  _RecPartoDa = new TRectype(_cur->file(LF_MOV));
 | 
						|
  _RecArrivoA = new TRectype(_cur->file(LF_MOV));
 | 
						|
 | 
						|
  add_cursor (_cur);
 | 
						|
 | 
						|
  add_file (LF_MOV);
 | 
						|
  add_file (LF_RMOV);
 | 
						|
  add_file (LF_RMOVIVA);
 | 
						|
}
 | 
						|
 | 
						|
void CG3400_application::user_destroy()
 | 
						|
{
 | 
						|
  delete _rel;
 | 
						|
  delete _cur;
 | 
						|
  delete _RecPartoDa;
 | 
						|
  delete _RecArrivoA;
 | 
						|
 | 
						|
  delete _com; delete _clifo; delete _caus; delete _pconti;
 | 
						|
  delete _nditte; delete _anag; 
 | 
						|
  delete _tabreg; delete _tabes; delete _tabval;
 | 
						|
 | 
						|
  delete _descr_conto;
 | 
						|
  delete _descr_operazione;
 | 
						|
  delete _descr_causale;
 | 
						|
  delete _nditte;
 | 
						|
  delete _anag;
 | 
						|
}
 | 
						|
 | 
						|
void CG3400_application::aggiorna_mov()
 | 
						|
{
 | 
						|
	TLocalisamfile mov(LF_MOV);
 | 
						|
	TProgind prnd (mov.items(), "Aggiornamento movimenti ...", FALSE, TRUE);
 | 
						|
 | 
						|
	long nprog = _nprog_da;
 | 
						|
 | 
						|
	mov.curr() = *_RecPartoDa;
 | 
						|
 | 
						|
	for (mov.read(_isgteq, _lock); mov.curr() < *_RecArrivoA && !mov.eof(); mov.next(_lock))
 | 
						|
	{
 | 
						|
		const bool gia_stampato = mov.get_bool(MOV_STAMPATO);
 | 
						|
		if (!gia_stampato)
 | 
						|
		{
 | 
						|
			mov.put (MOV_STAMPATO, TRUE);
 | 
						|
			mov.put (MOV_NUMGIO, nprog);
 | 
						|
			mov.rewrite();
 | 
						|
			nprog++;
 | 
						|
		}
 | 
						|
		else
 | 
						|
			mov.reread(_unlock);
 | 
						|
 | 
						|
		prnd.addstatus(1);
 | 
						|
	}
 | 
						|
	mov.reread(_unlock);
 | 
						|
}
 | 
						|
 | 
						|
void CG3400_application::scrivi_numgio(long nprog)
 | 
						|
{
 | 
						|
  TLocalisamfile *mov = current_cursor()->file(LF_MOV);
 | 
						|
 | 
						|
  mov->reread(_lock);
 | 
						|
  mov->put (MOV_NUMGIO, nprog);
 | 
						|
  mov->rewrite();
 | 
						|
}
 | 
						|
 | 
						|
void CG3400_application::stampa_totali_giorno(TDate data, bool ff)
 | 
						|
{
 | 
						|
  TString dep(_stampa_width);
 | 
						|
 | 
						|
  dep = "@10gOperazioni del ";
 | 
						|
  dep << data.string();
 | 
						|
//  dep.center_just();
 | 
						|
 | 
						|
  set_row (1, "%s", (const char *)dep);
 | 
						|
 | 
						|
  if (_stampa_width == 132)
 | 
						|
//  set_row (1, "@94g %15r @112g %15r", &_tot_dare_gg, &_tot_avere_gg );
 | 
						|
  set_row (1, "@94g %r @112g %r", &_tot_dare_gg, &_tot_avere_gg );
 | 
						|
  else
 | 
						|
  set_row (1, "@142g %r @164g %r", &_tot_dare_gg, &_tot_avere_gg );
 | 
						|
 | 
						|
  if ( (_tot_avere_ac != 0) || (_tot_dare_ac != 0) )
 | 
						|
  {
 | 
						|
    dep = "@10gOperazioni del ";
 | 
						|
    dep << data.string() << " " << "Anno precedente";
 | 
						|
//    dep.center_just();
 | 
						|
    set_row (2, "%s", (const char *)dep);
 | 
						|
    if (_stampa_width == 132)
 | 
						|
      set_row (2, "@95g %r @112g %r",  &_tot_dare_ac, 
 | 
						|
                                       &_tot_avere_ac );
 | 
						|
    else
 | 
						|
      set_row (2, "@142g %r @164g %r", &_tot_dare_ac, 
 | 
						|
                                       &_tot_avere_ac );
 | 
						|
    _tot_avere_ac = 0.00;
 | 
						|
    _tot_dare_ac  = 0.00;
 | 
						|
    set_row (3, "");
 | 
						|
  } 
 | 
						|
  else
 | 
						|
    set_row (2, "");      // Lascio una riga vuota dopo il totale
 | 
						|
 | 
						|
  if (ff) set_auto_ff (TRUE);
 | 
						|
  else set_auto_ff (FALSE);
 | 
						|
}
 | 
						|
 | 
						|
// --------------------------------------------------------------------------
 | 
						|
//
 | 
						|
// STAMPA A 132
 | 
						|
//
 | 
						|
// --------------------------------------------------------------------------
 | 
						|
void CG3400_application::set_page_132 (int file, int counter)
 | 
						|
{
 | 
						|
  int r = 1;
 | 
						|
  switch (file)
 | 
						|
  {
 | 
						|
    case LF_MOV:
 | 
						|
      if (_libro_giornale_iva_unico)
 | 
						|
      {
 | 
						|
      if (_stampa_definitiva) 
 | 
						|
        set_row(r,"Registrazione n. #-7ld del @d documento n. @7s del @d @56g@s Anno di competenza %s", 
 | 
						|
                                        &_nprog_mov, 
 | 
						|
                                        FLD(LF_MOV, MOV_DATAREG),
 | 
						|
                                        FLD(LF_MOV, MOV_NUMDOC),
 | 
						|
                                        FLD(LF_MOV, MOV_DATADOC),
 | 
						|
                                        FLD(LF_MOV, MOV_DESCR),
 | 
						|
                                        (const char *)_reg_anno);
 | 
						|
      else
 | 
						|
        set_row(r,"Registrazione n. @7,lpn del @d documento n. @7s del @d @56g@s Anno di competenza %s", 
 | 
						|
                                        FLD(LF_MOV, MOV_NUMREG, "#######"), 
 | 
						|
                                        FLD(LF_MOV, MOV_DATAREG),
 | 
						|
                                        FLD(LF_MOV, MOV_NUMDOC),
 | 
						|
                                        FLD(LF_MOV, MOV_DATADOC),
 | 
						|
                                        FLD(LF_MOV, MOV_DESCR),
 | 
						|
                                        (const char *)_reg_anno);
 | 
						|
 | 
						|
      }
 | 
						|
      else
 | 
						|
        if (!_gia_settata_riga_mov)
 | 
						|
        {
 | 
						|
          set_row (r, "Operazioni del @d", FLD(LF_MOV,MOV_DATAREG));
 | 
						|
          _gia_settata_riga_mov = TRUE;
 | 
						|
        }
 | 
						|
 
 | 
						|
      break;
 | 
						|
 | 
						|
    case LF_RMOV:
 | 
						|
      break;
 | 
						|
    case LF_RMOVIVA:
 | 
						|
      break;
 | 
						|
    default:
 | 
						|
      break;
 | 
						|
  }
 | 
						|
}
 | 
						|
 | 
						|
// --------------------------------------------------------------------------
 | 
						|
//
 | 
						|
// STAMPA A 198
 | 
						|
//
 | 
						|
// --------------------------------------------------------------------------
 | 
						|
void CG3400_application::set_page_198 (int file, int counter)
 | 
						|
{
 | 
						|
  int r = 1;
 | 
						|
  switch (file)
 | 
						|
  {
 | 
						|
    case LF_MOV:
 | 
						|
      break;
 | 
						|
    case LF_RMOV:
 | 
						|
      set_row (r, "@d", FLD(LF_RMOV,RMV_DATAREG));
 | 
						|
      set_row (r, "@10g@pn/@pn", FLD(LF_RMOV,RMV_NUMREG,"####"),
 | 
						|
                                 FLD(LF_RMOV,RMV_NUMRIG,"##"));
 | 
						|
      set_row (r, " @d", FLD(LF_RMOV,MOV_DATADOC));
 | 
						|
      set_row (r, " @pn",FLD(LF_RMOV,MOV_NUMDOC));
 | 
						|
 | 
						|
      set_row (r, "@38g@pn",FLD(LF_RMOV, RMV_GRUPPO, "@@."));
 | 
						|
      set_row (r, "@pn",FLD(LF_RMOV, RMV_CONTO , "@@."));
 | 
						|
      set_row (r, "@pn",FLD(LF_RMOV, RMV_SOTTOCONTO, "@@@@@@"));
 | 
						|
 | 
						|
      set_row (r, "#50t", &_descr_conto);
 | 
						|
      set_row (r, "@80g@3s", FLD(LF_MOV, MOV_CODCAUS));
 | 
						|
      set_row (r, "#50t", &_descr_causale);
 | 
						|
 | 
						|
//      set_row (r, "@50s", FLD(LF_RMOV, RMV_DESCR));
 | 
						|
      set_row (r, "#50t", &_descr_operazione);
 | 
						|
 | 
						|
// Dare e avere sono settati nella preprocess_page
 | 
						|
// Cosi' pure l'indirizzo nel caso di gestione libro cronologico
 | 
						|
// _descr contiene la descrizione conto o la ragione sociale
 | 
						|
// v. preprocess_page
 | 
						|
      break;
 | 
						|
    case LF_RMOVIVA:
 | 
						|
      break;
 | 
						|
    default:
 | 
						|
      break;
 | 
						|
  }
 | 
						|
}
 | 
						|
 | 
						|
void CG3400_application::set_rows(int file, int counter)
 | 
						|
{
 | 
						|
  int r=1;
 | 
						|
  switch (file)
 | 
						|
  {
 | 
						|
    case LF_RMOV:
 | 
						|
      if (_libro_giornale_iva_unico)
 | 
						|
      {
 | 
						|
        if (!_stampa_definitiva) set_row (r, "%3d", _num_rig);
 | 
						|
        set_row (r, "@5g@3s@60g@pn@pn@pn", 
 | 
						|
                   FLD(LF_MOV, MOV_CODCAUS),
 | 
						|
                   FLD(LF_RMOV, RMV_GRUPPO, "@@."), 
 | 
						|
                   FLD(LF_RMOV, RMV_CONTO , "@@."), 
 | 
						|
                   FLD(LF_RMOV, RMV_SOTTOCONTO, "@@@@@@")
 | 
						|
                   );
 | 
						|
      }
 | 
						|
      else   // no libro_giornale_iva_unico
 | 
						|
      {
 | 
						|
        if (_stampa_definitiva) 
 | 
						|
          set_row (r, "#-7ld", &_nprog_mov);
 | 
						|
        else
 | 
						|
          set_row (r, "@7,rn", FLD(LF_RMOV, RMV_NUMREG));
 | 
						|
        set_row (r, "@10g@d@28g@pn@pn@pn", 
 | 
						|
                   FLD(LF_RMOV, RMV_DATAREG),
 | 
						|
                   FLD(LF_RMOV, RMV_GRUPPO, "@@."), 
 | 
						|
                   FLD(LF_RMOV, RMV_CONTO , "@@."), 
 | 
						|
                   FLD(LF_RMOV, RMV_SOTTOCONTO, "@@@@@@")
 | 
						|
                   );
 | 
						|
      }
 | 
						|
    break;
 | 
						|
  default:
 | 
						|
		break;
 | 
						|
	}
 | 
						|
}
 | 
						|
 | 
						|
void CG3400_application::set_page (int file, int counter)
 | 
						|
{
 | 
						|
  if (_libro_giornale_iva_unico)
 | 
						|
    set_page_132(file, counter);
 | 
						|
  else
 | 
						|
    if (_stampa_width == 132)
 | 
						|
      set_page_132(file, counter);
 | 
						|
    else
 | 
						|
      set_page_198(file, counter);
 | 
						|
}
 | 
						|
 | 
						|
print_action CG3400_application::postprocess_print(int file, int counter)
 | 
						|
{
 | 
						|
	switch (file)
 | 
						|
	{
 | 
						|
		case LF_RMOV:
 | 
						|
			break;
 | 
						|
		case LF_MOV:
 | 
						|
			{
 | 
						|
				printer().formfeed();
 | 
						|
				*_RecArrivoA = _cur->file(LF_MOV)->curr();
 | 
						|
			}
 | 
						|
			break;
 | 
						|
		default:
 | 
						|
			break;
 | 
						|
	}
 | 
						|
	return NEXT_PAGE;
 | 
						|
}
 | 
						|
 | 
						|
void CG3400_application::postclose_print()
 | 
						|
{
 | 
						|
		const int ultima_fatta = printer().getcurrentpage();
 | 
						|
		const int stampate = ultima_fatta - _pagina_da + 1;
 | 
						|
		if (yesno_box("La stampa e' corretta ? "))
 | 
						|
		{
 | 
						|
			_pagina_da = -1;
 | 
						|
			aggiorna_mov ();
 | 
						|
		}
 | 
						|
		aggiorna_tabreg (_pagina_da, stampate);
 | 
						|
}
 | 
						|
 | 
						|
void CG3400_application::preprocess_footer()
 | 
						|
{
 | 
						|
  TString dare  = _tot_dare_progr.string("###.###.###.###");
 | 
						|
  TString avere = _tot_dare_progr.string("###.###.###.###");
 | 
						|
  int r=1;
 | 
						|
 | 
						|
  if (_stampa_width == 132)
 | 
						|
  set_footer (r, "@65gTotale progressivi generali: @95g%s @112g%s",
 | 
						|
									(const char *)dare,
 | 
						|
                  (const char *)avere);
 | 
						|
  else
 | 
						|
  set_footer (r, "@100gTotale progressivi generali: %s @164gTotale avere: %s",
 | 
						|
                  (const char *)dare,
 | 
						|
                  (const char *)avere);
 | 
						|
 | 
						|
}
 | 
						|
 | 
						|
int CG3400_application::stampa_intestazione_ditta()
 | 
						|
{
 | 
						|
  int r=1;
 | 
						|
  TString riga(_stampa_width);
 | 
						|
 | 
						|
  get_dati_ditta();
 | 
						|
  set_header (r, "Ditta: %s Via %s %s %s %s", (const char *)_ragsoc, 
 | 
						|
                  (const char *)_viafis, (const char *)_cap, 
 | 
						|
                  (const char *)_comunefis, (const char *)_provfis); 
 | 
						|
  r++;
 | 
						|
  riga = "Data @>";
 | 
						|
  riga.right_just(_stampa_width-15);  // perche' il codice viene espanso nella data con l'anno in 4 caratteri
 | 
						|
  riga.overwrite (format ("Partita iva %s @24gCodice fiscale %s", (const char*)_paiva, (const char*)_cofi));
 | 
						|
  set_header (r, "%s", (const char*) riga);
 | 
						|
  r++;
 | 
						|
 | 
						|
  return r;
 | 
						|
}
 | 
						|
 | 
						|
int CG3400_application::set_header_198()
 | 
						|
{
 | 
						|
  int r=1;
 | 
						|
  TString riga(_stampa_width);
 | 
						|
  TString data_da = _data_da.string();
 | 
						|
  TString data_a  = _data_a.string();
 | 
						|
 | 
						|
  if (_stampa_intesta)
 | 
						|
    r = stampa_intestazione_ditta();
 | 
						|
 | 
						|
  set_header(r, "Codice libro: %s %s @40gdalla data: %s alla data: %s",
 | 
						|
             (const char *) _reg_cod, (const char *) _reg_descr,
 | 
						|
             (const char *) data_da,  (const char *) data_a);
 | 
						|
  r++;
 | 
						|
 | 
						|
  riga.fill('-'); 
 | 
						|
  set_header(r, riga);
 | 
						|
  r++;
 | 
						|
 | 
						|
  set_header(r, " Data    Numero       Documento"); 
 | 
						|
 | 
						|
  riga = "Anno S";
 | 
						|
  riga.right_just(_stampa_width);
 | 
						|
  if (_libro_cronologico)
 | 
						|
      riga.overwrite("    Codice conto Descrizione conto"); 
 | 
						|
  else
 | 
						|
      riga.overwrite("      Codice"); 
 | 
						|
 | 
						|
  set_header(r, "%s", (const char*) riga); 
 | 
						|
  r++;
 | 
						|
 | 
						|
  riga = "Comp B";
 | 
						|
  riga.right_just(_stampa_width);
 | 
						|
  if (_libro_cronologico)
 | 
						|
      riga.overwrite("Registr. Registraz. data e numero             Generalita' cliente/fornitore@82gCod.Causale@102gDescrizionee operazione@142gDARE@164gAVERE");
 | 
						|
  else
 | 
						|
      riga.overwrite("Registr. Registraz. data e numero    Conto     Descrizione conto@82gCod.Causale@102gDescrizionee operazione@142gDARE@164gAVERE");
 | 
						|
 | 
						|
  set_header(r, "%s", (const char*) riga); 
 | 
						|
  r++;
 | 
						|
 | 
						|
  riga.fill('-'); 
 | 
						|
  set_header(r, riga);
 | 
						|
  r++;
 | 
						|
 | 
						|
  return r;
 | 
						|
}
 | 
						|
 | 
						|
int CG3400_application::set_header_132()
 | 
						|
{
 | 
						|
  int r=1;
 | 
						|
  TString riga(_stampa_width);
 | 
						|
  TString data_da = _data_da.string();
 | 
						|
  TString data_a  = _data_a.string();
 | 
						|
 | 
						|
  if (_stampa_intesta)
 | 
						|
    r = stampa_intestazione_ditta();
 | 
						|
 | 
						|
  set_header(r, "Codice libro: %s %s @50gdalla data: %s alla data: %s",
 | 
						|
             (const char *) _reg_cod, (const char *) _reg_descr,
 | 
						|
             (const char *) data_da,  (const char *) data_a);
 | 
						|
  r++;
 | 
						|
 | 
						|
  riga.fill('-'); 
 | 
						|
  set_header(r, riga);
 | 
						|
  r++;
 | 
						|
 | 
						|
  if (_libro_giornale_iva_unico)
 | 
						|
  {
 | 
						|
    set_header(r, "Ri"); 
 | 
						|
    if (_libro_cronologico)
 | 
						|
      set_header(r, "@60gCodice        Conto"); 
 | 
						|
 | 
						|
    set_header(r, "@113gImporti@131gS");
 | 
						|
    r++;
 | 
						|
 | 
						|
    set_header(r, "ga@6gCod.Causale@34gDescrizione operazione");
 | 
						|
    if (_libro_cronologico)
 | 
						|
      set_header(r, "@60gGeneralita' cliente/fornitore"); 
 | 
						|
    
 | 
						|
    set_header(r, "@106gDARE@122gAVERE@131gB");
 | 
						|
    r++;
 | 
						|
  }
 | 
						|
  else
 | 
						|
////////////////////////////////////////////////////////////////////
 | 
						|
// NO LIBRO GIORNALE IVA UNICO
 | 
						|
////////////////////////////////////////////////////////////////////
 | 
						|
  {
 | 
						|
    set_header(r, "Numero@12gDocumento@28gCodice@115gImporti@127g  A S"); 
 | 
						|
    r++;
 | 
						|
    if (_stampa_definitiva)
 | 
						|
      set_header(r, "Riga"); 
 | 
						|
    else
 | 
						|
      set_header(r, "Regist."); 
 | 
						|
 | 
						|
    set_header(r, "@10gData e numero@28gConto@41gDescrizione conto@68gDescrizione operazione@106gDare@122gAvere@127g  C B");
 | 
						|
    r++;
 | 
						|
  }
 | 
						|
 | 
						|
  riga.fill('-'); 
 | 
						|
  set_header(r, riga);
 | 
						|
  r++;
 | 
						|
  return r;
 | 
						|
}
 | 
						|
 | 
						|
void CG3400_application::preprocess_header()
 | 
						|
{
 | 
						|
  int pag = printer().getcurrentpage();
 | 
						|
  TString dare  = _tot_dare_progr.string(REAL_PICTURE);
 | 
						|
  TString avere = _tot_dare_progr.string(REAL_PICTURE);
 | 
						|
  int r   = _last_header;
 | 
						|
  
 | 
						|
  if (pag > 0)   // Stampa riporti
 | 
						|
  {
 | 
						|
    TString dep (_stampa_width);
 | 
						|
    dare.right_just();
 | 
						|
    avere.right_just();
 | 
						|
    if (_stampa_width == 132)
 | 
						|
      dep = format ("@86gRiporto:@95g %15s @112g %15s", (const char *) dare,
 | 
						|
                                                    (const char *) avere );
 | 
						|
    else
 | 
						|
      dep = format ("@100gRiporto %s @140g %s", (const char *) dare,
 | 
						|
                                                (const char *) avere );
 | 
						|
    set_header (r, "%s", (const char *) dep);
 | 
						|
  }
 | 
						|
}
 | 
						|
 | 
						|
//
 | 
						|
// PREPROCESS_PRINT
 | 
						|
//
 | 
						|
// Se non ci sono items nel cursore (= se non ci sono movimenti) 
 | 
						|
// la stampa e' abortita.
 | 
						|
//
 | 
						|
// stampa_ok = -1  ->  la stampa precedente era OK
 | 
						|
// stampa_ok = x   ->  la stampa precedente non e' andata a buon fine
 | 
						|
//                     ed era partita dalla pagina x.
 | 
						|
//
 | 
						|
// Se la stampa precedente e' andata male, setto la pagina corrente a
 | 
						|
// quella salvata in stampa_ok, e la pagina da cui parte la stampa vera e 
 | 
						|
// propria a quella che mi dice l'utente:
 | 
						|
//
 | 
						|
//           set_page_number (stampa_ok)
 | 
						|
//           setfrompage     (pagina_da)
 | 
						|
//
 | 
						|
bool CG3400_application::preprocess_print(int file, int counter)
 | 
						|
{
 | 
						|
  int i;
 | 
						|
  switch (file)
 | 
						|
  {
 | 
						|
    case LF_MOV:
 | 
						|
      reset_print();
 | 
						|
      reset_header();
 | 
						|
      printer().footerlen(RIGHE_FOOTER);
 | 
						|
      _gia_settata_riga_mov = FALSE;  // Stampa o no la riga di mov (solo se 
 | 
						|
                                      // NO stampa giornale_iva_unico
 | 
						|
      _num_rig = 0;
 | 
						|
      _tot_dare_ac  = 0.00;
 | 
						|
      _tot_avere_ac = 0.00;
 | 
						|
      _tot_dare_gg  = 0.00;
 | 
						|
      _tot_avere_gg = 0.00;
 | 
						|
      _tot_dare_progr  = _tot_dare;
 | 
						|
      _tot_avere_progr = _tot_avere;
 | 
						|
      _iva_array.destroy();
 | 
						|
      if (current_cursor()->items() == 0)
 | 
						|
      {
 | 
						|
        warning_box ("Non ci sono movimenti.\nLa stampa e' annullata");
 | 
						|
        return FALSE;
 | 
						|
      }
 | 
						|
 | 
						|
      _nprog_mov   = _nprog_da;
 | 
						|
 | 
						|
      *_RecPartoDa = _cur->file(LF_MOV)->curr();
 | 
						|
 | 
						|
      for (i=1; i<RIGHE_FOOTER; i++)
 | 
						|
        set_footer(i, "%s", " ");
 | 
						|
 | 
						|
      if (_stampa_width == 132)
 | 
						|
        _last_header = set_header_132();
 | 
						|
      else
 | 
						|
        _last_header = set_header_198();
 | 
						|
 | 
						|
//      set_real_picture ("###.###.###.###");
 | 
						|
      set_real_picture (REAL_PICTURE);
 | 
						|
      set_wait_message ("Stampa in corso");
 | 
						|
      if (_stampa_ok == -1)
 | 
						|
          ;
 | 
						|
//        printer().set_from_page (_pagina_da);
 | 
						|
      else {                      // la stampa precedente era andata male
 | 
						|
        set_page_number (_stampa_ok); 
 | 
						|
        printer().set_from_page (_pagina_da);
 | 
						|
      }
 | 
						|
      break;
 | 
						|
    default:
 | 
						|
      break;
 | 
						|
  }
 | 
						|
  return TRUE;
 | 
						|
}
 | 
						|
 | 
						|
bool CG3400_application::cancel_hook()
 | 
						|
{
 | 
						|
  int ultima_fatta = printer().getcurrentpage();
 | 
						|
  int stampate = ultima_fatta - _pagina_da + 1;
 | 
						|
 | 
						|
  if (yesno_box ("Interrompo la stampa ?"))
 | 
						|
  {
 | 
						|
    aggiorna_tabreg (_pagina_da, stampate);
 | 
						|
    return TRUE;
 | 
						|
  }
 | 
						|
  else
 | 
						|
    return FALSE;
 | 
						|
}
 | 
						|
 | 
						|
print_action CG3400_application::postprocess_page(int file, int counter)
 | 
						|
{
 | 
						|
  int r=0;
 | 
						|
  bool nuovo_mese = FALSE;
 | 
						|
 | 
						|
  set_auto_ff (FALSE);
 | 
						|
  if (counter) 
 | 
						|
  {
 | 
						|
    if (nuovo_mese)
 | 
						|
    {
 | 
						|
      nuovo_mese = FALSE;
 | 
						|
    }
 | 
						|
    return NEXT_PAGE;
 | 
						|
  }
 | 
						|
 | 
						|
  switch (file)
 | 
						|
  {
 | 
						|
    case LF_MOV:
 | 
						|
      if (_libro_giornale_iva_unico)
 | 
						|
      {
 | 
						|
         r = setta_righe_iva();
 | 
						|
         if (r > 0)
 | 
						|
            return REPEAT_PAGE;  
 | 
						|
//         else 
 | 
						|
//            return NEXT_PAGE;
 | 
						|
      }
 | 
						|
      _cur->save_status();
 | 
						|
      ++(*_cur);
 | 
						|
      _data_succ = _cur->file(LF_MOV)->get_date(MOV_DATAREG);
 | 
						|
      _mese_succ = _data_succ.month();
 | 
						|
      --(*_cur);
 | 
						|
      _cur->restore_status();
 | 
						|
      if (_data_corr != _data_succ)
 | 
						|
      {
 | 
						|
        reset_print();
 | 
						|
        if (_mese_succ != _mese_corr) nuovo_mese = TRUE;
 | 
						|
        else nuovo_mese = FALSE;
 | 
						|
        stampa_totali_giorno(_data_corr, nuovo_mese);
 | 
						|
        _tot_dare_gg  = 0.00;
 | 
						|
        _tot_avere_gg = 0.00;
 | 
						|
        _gia_settata_riga_mov = FALSE;
 | 
						|
        return REPEAT_PAGE;
 | 
						|
      }
 | 
						|
      else
 | 
						|
        _gia_settata_riga_mov = TRUE;
 | 
						|
      break;
 | 
						|
 | 
						|
    case LF_RMOVIVA:
 | 
						|
    default:
 | 
						|
      set_auto_ff(FALSE); // ff gia' fatto prima
 | 
						|
      break;
 | 
						|
  }
 | 
						|
  return NEXT_PAGE;
 | 
						|
}
 | 
						|
 | 
						|
//
 | 
						|
// PREPROCESS_PAGE
 | 
						|
//
 | 
						|
// Non stampo niente se:
 | 
						|
//
 | 
						|
// 1. STAMPATO = TRUE     
 | 
						|
//       OPPURE
 | 
						|
// 2. non ci sono righe di RMOV
 | 
						|
//
 | 
						|
bool CG3400_application::preprocess_page(int file, int counter)
 | 
						|
{
 | 
						|
  TLocalisamfile   * boh;
 | 
						|
  int g, c;
 | 
						|
  long s;
 | 
						|
  bool gia_stampato=FALSE;
 | 
						|
  TString sezione, caus, rmv_descr;
 | 
						|
  real    importo;
 | 
						|
 | 
						|
  if (counter) return TRUE;
 | 
						|
 | 
						|
  switch (file)
 | 
						|
  {
 | 
						|
    case LF_MOV:
 | 
						|
      _num_rig=0;
 | 
						|
      _iva_array.destroy();
 | 
						|
 | 
						|
      if (!current_cursor()->is_first_match(LF_RMOV))
 | 
						|
        return FALSE;
 | 
						|
 | 
						|
      gia_stampato = current_cursor()->file(LF_MOV)->get_bool(MOV_STAMPATO);
 | 
						|
      if (gia_stampato)
 | 
						|
        if (_stampa_definitiva)
 | 
						|
          return FALSE;
 | 
						|
        else 
 | 
						|
          set_row (1, "@131g*");  // stampo un * se mov. gia stampato
 | 
						|
 | 
						|
      if (_libro_giornale_iva_unico)
 | 
						|
        _nprog_mov++; 
 | 
						|
 | 
						|
      _data_corr   = _cur->file(LF_MOV)->get_date(MOV_DATAREG);
 | 
						|
      _mese_corr   = _data_corr.month();
 | 
						|
      _anno_es     = _cur->file(LF_MOV)->get(MOV_ANNOES);
 | 
						|
      caus         = _cur->file(LF_MOV)->get(MOV_CODCAUS);  
 | 
						|
      break;
 | 
						|
    case LF_RMOV: 
 | 
						|
      set_auto_ff(FALSE);
 | 
						|
      _num_rig++;
 | 
						|
      reset_print();
 | 
						|
      set_rows(file, counter);
 | 
						|
      if (_stampa_width == 132)
 | 
						|
      {
 | 
						|
        *_descr_causale = get_descr_caus(caus);
 | 
						|
        _descr_causale->set_width(10);
 | 
						|
      }
 | 
						|
      else
 | 
						|
      {
 | 
						|
        *_descr_causale = get_descr_caus(caus);
 | 
						|
        _descr_causale->set_width(198);
 | 
						|
      }
 | 
						|
      setta_righe_descr(_descr_causale, causale);
 | 
						|
      rmv_descr = current_cursor()->file(LF_RMOV)->get(RMV_DESCR);
 | 
						|
      if (_stampa_width == 132)
 | 
						|
      {
 | 
						|
        *_descr_operazione = (const char *)rmv_descr;
 | 
						|
        _descr_operazione->set_width(10);
 | 
						|
      }
 | 
						|
      else
 | 
						|
      {
 | 
						|
        *_descr_operazione = (const char *)rmv_descr;
 | 
						|
        _descr_operazione->set_width(198);
 | 
						|
      }
 | 
						|
      setta_righe_descr(_descr_operazione, operazione);
 | 
						|
      if (!_libro_giornale_iva_unico)
 | 
						|
        _nprog_mov++; 
 | 
						|
      g = current_cursor()->curr(LF_RMOV).get_int(RMV_GRUPPO);
 | 
						|
      c = current_cursor()->curr(LF_RMOV).get_int(RMV_CONTO);
 | 
						|
      s = current_cursor()->curr(LF_RMOV).get_long(RMV_SOTTOCONTO);
 | 
						|
//      _descr = get_descr (g,c,s);
 | 
						|
      boh = get_descr (_pconti, _clifo, g,c,s);
 | 
						|
 | 
						|
      if (boh!=NULL)
 | 
						|
      {
 | 
						|
        if (boh->num() == LF_PCON)
 | 
						|
        {
 | 
						|
          if (_stampa_width == 132)
 | 
						|
          {
 | 
						|
            *_descr_conto = (const char*)boh->get(PCN_DESCR); 
 | 
						|
            _descr_conto->set_width(10);
 | 
						|
          }
 | 
						|
          else
 | 
						|
          {
 | 
						|
            *_descr_conto = (const char*)boh->get(PCN_DESCR); 
 | 
						|
            _descr_conto->set_width(198);
 | 
						|
          }
 | 
						|
          setta_righe_descr(_descr_conto, conto);
 | 
						|
        }
 | 
						|
        else    
 | 
						|
          if (boh->num() == LF_CLIFO)
 | 
						|
          {
 | 
						|
            if (_stampa_width == 132)
 | 
						|
            {
 | 
						|
              *_descr_conto = (const char*)boh->get(CLI_RAGSOC); 
 | 
						|
              _descr_conto->set_width(10);
 | 
						|
            }
 | 
						|
            else
 | 
						|
            {
 | 
						|
              *_descr_conto = (const char*)boh->get(CLI_RAGSOC); 
 | 
						|
              _descr_conto->set_width(198);
 | 
						|
            }
 | 
						|
            setta_righe_descr(_descr_conto, conto);
 | 
						|
            if (_libro_cronologico)
 | 
						|
              setta_righe_indirizzo();
 | 
						|
          }
 | 
						|
      }
 | 
						|
      sezione = _cur->file(LF_RMOV)->get (RMV_SEZIONE);
 | 
						|
      importo = _cur->file(LF_RMOV)->get_real (RMV_IMPORTO);
 | 
						|
 | 
						|
//      imp = importo.string ("######");
 | 
						|
      if (sezione == "D")
 | 
						|
      {
 | 
						|
        _tot_dare_progr += importo;      // prog. generali
 | 
						|
        if (_anno_es != _reg_anno)
 | 
						|
          _tot_dare_ac    += importo;    // prog. anno precedente
 | 
						|
        else
 | 
						|
          _tot_dare_gg    += importo;    // prog. giornalieri
 | 
						|
        
 | 
						|
        if (_stampa_width == 132)
 | 
						|
          set_row (1, "@95g%r", &importo);
 | 
						|
        else
 | 
						|
          set_row (1, "@142g%r", &importo);
 | 
						|
      }
 | 
						|
      else
 | 
						|
      {
 | 
						|
        _tot_avere_progr += importo;
 | 
						|
        if (_anno_es != _reg_anno)
 | 
						|
          _tot_avere_ac    += importo;
 | 
						|
        else
 | 
						|
          _tot_avere_gg    += importo;
 | 
						|
        if (_stampa_width == 132)
 | 
						|
          set_row (1, "@112g%r", &importo);
 | 
						|
        else
 | 
						|
          set_row (1, "@164g%r", &importo);
 | 
						|
      }
 | 
						|
      break;
 | 
						|
    case LF_RMOVIVA: 
 | 
						|
      set_auto_ff(FALSE);
 | 
						|
      if (_libro_giornale_iva_unico)
 | 
						|
      {
 | 
						|
        calcola_iva ();
 | 
						|
        setta_righe_valuta();
 | 
						|
      }
 | 
						|
      break;
 | 
						|
    default: 
 | 
						|
      set_auto_ff(FALSE);
 | 
						|
      break;
 | 
						|
  }
 | 
						|
  return TRUE;
 | 
						|
}
 | 
						|
 | 
						|
void CG3400_application::calcola_iva()
 | 
						|
{
 | 
						|
	TString  codiva;
 | 
						|
	int      tipocr, tipodet;
 | 
						|
	real     impo, impos;
 | 
						|
	TRectype iva (_cur->file(LF_RMOVIVA)->curr());
 | 
						|
 | 
						|
	if (!iva.empty())
 | 
						|
	{
 | 
						|
		impo    = iva.get_real (RMI_IMPONIBILE);
 | 
						|
		impos   = iva.get_real (RMI_IMPOSTA);
 | 
						|
		tipocr  = iva.get_int (RMI_TIPOCR);
 | 
						|
		tipodet = iva.get_int (RMI_TIPODET);
 | 
						|
		codiva  = iva.get (RMI_CODIVA);
 | 
						|
		_iva_array.add_riga(impo,impos,codiva,tipodet,0.00,0.00);
 | 
						|
	}
 | 
						|
}
 | 
						|
 | 
						|
void CG3400_application::setta_righe_descr(TParagraph_string* str, enum descr des)
 | 
						|
{
 | 
						|
  const char * r;
 | 
						|
  int   i = 1;
 | 
						|
  TString frm;
 | 
						|
 | 
						|
  switch (des)
 | 
						|
  {
 | 
						|
    case causale:
 | 
						|
      if (_libro_giornale_iva_unico)
 | 
						|
        frm = "@8g%s";
 | 
						|
      else
 | 
						|
        frm = "@57g%s";
 | 
						|
      break;
 | 
						|
    case conto:
 | 
						|
      if (_libro_giornale_iva_unico)
 | 
						|
        frm = "@73g%s";
 | 
						|
      else
 | 
						|
        frm = "@41g%s";
 | 
						|
      break;
 | 
						|
    case operazione:
 | 
						|
      if (_libro_giornale_iva_unico)
 | 
						|
        frm = "@34g%s";
 | 
						|
      else
 | 
						|
        frm = "@68g%s";
 | 
						|
      break;
 | 
						|
    default:
 | 
						|
      break;
 | 
						|
  }
 | 
						|
  while ((r = str->get()) != NULL)
 | 
						|
  {
 | 
						|
//    reset_row(i);
 | 
						|
    set_row (i, (const char*)frm, r);
 | 
						|
    i++;
 | 
						|
  }
 | 
						|
}
 | 
						|
 | 
						|
int CG3400_application::setta_righe_iva()
 | 
						|
{
 | 
						|
  int r=0;
 | 
						|
 | 
						|
  for (int j = 0; j < _iva_array.items(); j++)
 | 
						|
  {
 | 
						|
    TRigaiva& riga = (TRigaiva&)_iva_array[j];
 | 
						|
    r = j+1;
 | 
						|
    set_row(r, "Imponibile@12g%r",    &riga._imponibile);
 | 
						|
    set_row(r, "@31gImposta@39g%r",   &riga._imposta);
 | 
						|
    set_row(r, "@58gCodice Iva@68g%3s", (const char*)riga._codiva);
 | 
						|
    switch (riga._tipodet)
 | 
						|
    {
 | 
						|
	   case 0 : set_row(r, "@73gDetraibile");
 | 
						|
                      break;
 | 
						|
	   case 1 : set_row(r, "@73gIndetraibile su op.es.");
 | 
						|
                      break;
 | 
						|
	   case 3 : set_row(r, "@73gPassaggi interni");
 | 
						|
                      break;
 | 
						|
	   case 9 : set_row(r, "@73gIndetraibile art.19");
 | 
						|
                      break;
 | 
						|
           default: break;   
 | 
						|
    } 
 | 
						|
  } 
 | 
						|
  _iva_array.destroy();
 | 
						|
  return r; 
 | 
						|
}
 | 
						|
 | 
						|
void CG3400_application::setta_righe_valuta()
 | 
						|
{      
 | 
						|
  TString  simbolo, codval;
 | 
						|
  bool     intracom;
 | 
						|
 | 
						|
  codval    = current_cursor()->file(LF_MOV)->get(MOV_CODVAL);
 | 
						|
  intracom  = current_cursor()->curr(LF_RMOVIVA).get_bool(RMI_INTRA); 
 | 
						|
  simbolo   = SimboloValuta(codval);
 | 
						|
 | 
						|
//      _allegb    = CausAlleg(_codcaus);
 | 
						|
//      _descr_doc = DescrDoc(_tipodoc);
 | 
						|
//      _totdocumenti += _totdoc;
 | 
						|
//      _ricser    = current_cursor()->curr(LF_RMOVIVA).get_int(RMI_RICSER);
 | 
						|
// long numeroreg = cur->curr(LF_RMOVIVA).get_long(RMI_NUMREG);
 | 
						|
         
 | 
						|
  if ((codval != "LIT") && intracom)
 | 
						|
  {
 | 
						|
    reset_row(1);
 | 
						|
    set_row(1,"Corr.in lire@14g@pN",
 | 
						|
                   FLD(LF_RMOVIVA,RMI_CORRLIRE,"###.###.###.###.###"));
 | 
						|
    set_row(1,"@34gCorr.in valuta@49g@pN",
 | 
						|
                   FLD(LF_RMOVIVA,RMI_CORRVALUTA,"###.###.###.###.###"));
 | 
						|
    if (simbolo.not_empty())
 | 
						|
      set_row(1,"@53g%.5s", (const char *)simbolo);
 | 
						|
    else
 | 
						|
      set_row(1,"@53g%.3s", (const char *)codval);
 | 
						|
  }
 | 
						|
}
 | 
						|
 | 
						|
void CG3400_application::setta_righe_indirizzo()
 | 
						|
{
 | 
						|
  TString comune, prov;
 | 
						|
 | 
						|
// Se e' un cliente occasionale leggo indirizzo da mov, senno' e' stato
 | 
						|
// gia' letto da clifo nella get_descr, richiamata nella preprocess_page
 | 
						|
  if (_occas)
 | 
						|
  {
 | 
						|
    TCursor        * cur = current_cursor();
 | 
						|
    TLocalisamfile * occ = cur->file(LF_OCCAS);
 | 
						|
 | 
						|
    _viacf = occ->get (OCC_INDIR);
 | 
						|
    _civcf = occ->get (OCC_CIV);
 | 
						|
    _capcf = occ->get (OCC_CAP);
 | 
						|
    _comcf = occ->get (OCC_COM);
 | 
						|
 | 
						|
/******
 | 
						|
    _viacf = cur->file(LF_MOV)->get (MOV_OCINDIR);
 | 
						|
    _civcf = cur->file(LF_MOV)->get (MOV_OCCIV);
 | 
						|
    _capcf = cur->file(LF_MOV)->get (MOV_OCCAP);
 | 
						|
    _comcf = cur->file(LF_MOV)->get (MOV_OCCOM);
 | 
						|
********/
 | 
						|
  } 
 | 
						|
 | 
						|
  TRectype dep = look_com (_comcf, _com);
 | 
						|
  comune       = dep.get(COM_DENCOM);
 | 
						|
  prov         = dep.get(COM_PROVCOM);
 | 
						|
  if (_libro_giornale_iva_unico)
 | 
						|
  {
 | 
						|
    set_row (2, "@64g%s %s", (const char *)_viacf, (const char *)_civcf);
 | 
						|
    set_row (3, "@64g%s %s %s", (const char *)_capcf, (const char *)comune,
 | 
						|
                                (const char *) prov);
 | 
						|
  }
 | 
						|
  else  // no libro iva unico. Cambia la colonna di inizio
 | 
						|
  {
 | 
						|
    set_row (2, "@31g%s %s", (const char *)_viacf, (const char *)_civcf);
 | 
						|
    set_row (3, "@31g%s %s %s", (const char *)_capcf, (const char *)comune,
 | 
						|
                                (const char *) prov);
 | 
						|
  }
 | 
						|
}
 | 
						|
 | 
						|
//
 | 
						|
// Lettura/aggiornamento tabella registri
 | 
						|
//
 | 
						|
void CG3400_application::aggiorna_tabreg(int partito_da, int stampate)
 | 
						|
{
 | 
						|
  TString codtab = format ("%4s%-3s", (const char*) _reg_anno,
 | 
						|
																			(const char*) _reg_cod);
 | 
						|
  _tabreg->zero();
 | 
						|
  _tabreg->put("CODTAB", codtab);
 | 
						|
  _tabreg->read();
 | 
						|
 | 
						|
  if (_tabreg->good())
 | 
						|
  {
 | 
						|
    _tabreg->put ("I1", _pagine_stampate + stampate);
 | 
						|
    _tabreg->put ("I7", partito_da);   // partito_da = -1 se stampa OK
 | 
						|
    _tabreg->put ("I6", _nprog_mov);
 | 
						|
    _tabreg->put ("R1", _tot_dare_progr);
 | 
						|
    _tabreg->put ("R2", _tot_avere_progr);
 | 
						|
    _tabreg->put ("D3", _data_a);
 | 
						|
    _tabreg->rewrite();
 | 
						|
  }
 | 
						|
}
 | 
						|
 | 
						|
bool CG3400_application::leggi_tabreg(const char * reg_cod, 
 | 
						|
                                      const char * reg_anno)
 | 
						|
{
 | 
						|
  TString codtab = format ("%4s%-3s", reg_anno, reg_cod);
 | 
						|
 | 
						|
  _tabreg->zero();
 | 
						|
  _tabreg->put("CODTAB", codtab);
 | 
						|
  _tabreg->read();
 | 
						|
 | 
						|
  if (_tabreg->good())
 | 
						|
  {
 | 
						|
    _pagine_stampate = _tabreg->get_int("I1");
 | 
						|
    _pagine_numerate = _tabreg->get_int("I2");
 | 
						|
    _stampa_ok       = _tabreg->get_int("I7");
 | 
						|
    _nprog_da        = _tabreg->get_long ("I6");
 | 
						|
    _tot_dare        = _tabreg->get_real ("R1");
 | 
						|
    _tot_avere       = _tabreg->get_real ("R2");
 | 
						|
    _last_data       = _tabreg->get_date ("D3");
 | 
						|
    _stampa_intesta  = _tabreg->get_bool ("B9");
 | 
						|
    _reg_descr       = _tabreg->get ("S0");
 | 
						|
  }
 | 
						|
  return TRUE;
 | 
						|
}
 | 
						|
 | 
						|
//-----------------------------------------------------------------------
 | 
						|
//
 | 
						|
// MASCHERE
 | 
						|
//
 | 
						|
//-----------------------------------------------------------------------
 | 
						|
 | 
						|
bool mask_a_data (TMask_field& f, KEY k)
 | 
						|
{
 | 
						|
  CG3400_application * app = (CG3400_application*) MainApp();    
 | 
						|
  if (k == K_ENTER)
 | 
						|
  {
 | 
						|
    TDate da(f.mask().get(DATA_DA)); 
 | 
						|
    TDate  a(f.mask().get(DATA_A)); 
 | 
						|
    int   anno = atoi(f.mask().field(ANNO_ESER).get()); 
 | 
						|
    if ( (f.dlg() == DATA_DA) && (anno == 0 ) )
 | 
						|
      f.mask().field(ANNO_ESER).set (format ("%4d",da.year()));
 | 
						|
    if (!app->IsInEsercizio(da,a,anno))
 | 
						|
      return FALSE;
 | 
						|
  }
 | 
						|
  return TRUE;
 | 
						|
}
 | 
						|
 | 
						|
//
 | 
						|
// MASK_A_COD_REG
 | 
						|
// 
 | 
						|
// Aggiorna il campo PAGINA_DA della maschera
 | 
						|
//
 | 
						|
// Legge la tabella dei registri e controlla se la stampa precedente
 | 
						|
// era andata a buon fine.  
 | 
						|
// Se no, riempie il campo PAGINA_DA con il valore precedente.
 | 
						|
// Se si', mette semplicemente l'ultimo numero di pagina precedente + 1
 | 
						|
//
 | 
						|
bool mask_a_cod_reg (TMask_field& f, KEY k)
 | 
						|
{
 | 
						|
  TString reg_cod(""),reg_anno("");
 | 
						|
 | 
						|
  if (k == K_TAB)
 | 
						|
  {
 | 
						|
    CG3400_application * a = (CG3400_application*) MainApp();    
 | 
						|
 | 
						|
    reg_cod  = f.mask().field(REG_COD).get(); 
 | 
						|
    reg_anno = f.mask().field(ANNO_ESER).get(); 
 | 
						|
 | 
						|
    a->leggi_tabreg(reg_cod, reg_anno);
 | 
						|
 | 
						|
		TString pag(8), stok(8);
 | 
						|
		pag  << (a->_pagine_stampate+1);
 | 
						|
    stok << a->_stampa_ok;
 | 
						|
    if (a->_stampa_ok == -1)     // stampa precedente andata bene
 | 
						|
      f.mask().field(PAGINA_DA).set(pag);
 | 
						|
    else
 | 
						|
      f.mask().field(PAGINA_DA).set(stok);
 | 
						|
 | 
						|
    f.mask().field(DATA_DA).set (a->_last_data.string());
 | 
						|
 | 
						|
  }
 | 
						|
  return TRUE;
 | 
						|
}
 | 
						|
 | 
						|
//
 | 
						|
// mask_b_ripristina
 | 
						|
//
 | 
						|
// Se premo il bottone <Ripristina> rimetto i valori precedenti
 | 
						|
// dentro ai campi (per ripetere la stampa)
 | 
						|
//
 | 
						|
bool mask_b_ripristina (TMask_field& f, KEY k)
 | 
						|
{
 | 
						|
  CG3400_application * a = (CG3400_application*) MainApp();    
 | 
						|
 | 
						|
  if (k == K_TAB) 
 | 
						|
  {
 | 
						|
    f.mask().field(PROGR_DARE).set(a->_tot_dare.string());
 | 
						|
    f.mask().field(ULTIMA_DATA).set(a->_last_data.string());
 | 
						|
    f.mask().field(N_RIGA_STAMPATO).set(format ("%6d", a->_nprog_da));
 | 
						|
  }
 | 
						|
  return TRUE; 
 | 
						|
}
 | 
						|
 | 
						|
bool CG3400_application::set_print(int)
 | 
						|
{
 | 
						|
  TMask ma ("cg3400a");
 | 
						|
  TMask mb ("cg3400b");
 | 
						|
  KEY   tasto;
 | 
						|
 | 
						|
  ma.set_handler (REG_COD, mask_a_cod_reg);
 | 
						|
  ma.set_handler (DATA_DA, mask_a_data);
 | 
						|
  ma.set_handler (DATA_A,  mask_a_data);
 | 
						|
  mb.set_handler (DLG_RIPRISTINA, mask_b_ripristina);
 | 
						|
 | 
						|
//  m.set_handler (REG_ANNO, mask_set_pagina_da);
 | 
						|
//  m.set_handler (REG_DESC, mask_set_pagina_da);
 | 
						|
 | 
						|
  tasto = ma.run();
 | 
						|
 | 
						|
  if (tasto == K_ENTER)
 | 
						|
  {
 | 
						|
    _reg_cod           = ma.get(REG_COD);
 | 
						|
    _reg_anno          = ma.get(ANNO_ESER);  
 | 
						|
    _stampa_definitiva = (bool) (ma.get(STAMPA_DEF) == "X");
 | 
						|
    _data_da           = ma.get(DATA_DA);
 | 
						|
    _data_a            = ma.get(DATA_A);
 | 
						|
    _pagina_da         = atoi(ma.get(PAGINA_DA));
 | 
						|
		_stampa_width      = (int)ma.get_long(STAMPA_WIDTH);
 | 
						|
		_stampa_len        = (int)ma.get_long(STAMPA_LEN);
 | 
						|
 | 
						|
    if (_stampa_len) printer().formlen(_stampa_len);
 | 
						|
    if (_stampa_width == 1) _stampa_width = 132;
 | 
						|
    else _stampa_width = 198;
 | 
						|
 | 
						|
    TRectype da (_cur->file(LF_MOV));
 | 
						|
    TRectype a  (_cur->file(LF_MOV));
 | 
						|
 | 
						|
    da.zero();
 | 
						|
    a.zero();
 | 
						|
    da.put(MOV_DATAREG, _data_da);
 | 
						|
    a.put (MOV_DATAREG, _data_a);
 | 
						|
 | 
						|
    _cur->setregion (&da, &a);
 | 
						|
 | 
						|
    mb.set (PROGR_DARE,      _tot_dare.string());
 | 
						|
    mb.set (N_RIGA_STAMPATO, _nprog_da);
 | 
						|
    mb.set (ULTIMA_DATA,     _last_data.string());
 | 
						|
    tasto = mb.run();
 | 
						|
    if (tasto == K_ENTER)
 | 
						|
      return TRUE;
 | 
						|
    else 
 | 
						|
      return FALSE;
 | 
						|
  }
 | 
						|
  return FALSE;
 | 
						|
}
 | 
						|
 | 
						|
int  cg3400  (int argc, char * argv[])
 | 
						|
{
 | 
						|
  CG3400_application app;
 | 
						|
  app.run(argc, argv, "Stampa libro giornale");
 | 
						|
  return TRUE;
 | 
						|
}
 | 
						|
 |