2001-04-30 14:22:43 +00:00
|
|
|
|
#include <applicat.h>
|
|
|
|
|
#include <automask.h>
|
2001-06-25 10:41:20 +00:00
|
|
|
|
#include <execp.h>
|
2001-04-30 14:22:43 +00:00
|
|
|
|
#include <printer.h>
|
|
|
|
|
#include <recarray.h>
|
2002-02-26 16:20:19 +00:00
|
|
|
|
#include <tabutil.h>
|
2001-04-30 14:22:43 +00:00
|
|
|
|
#include <utility.h>
|
|
|
|
|
|
|
|
|
|
#include "ce3.h"
|
|
|
|
|
#include "ammce.h"
|
|
|
|
|
#include "ammmv.h"
|
|
|
|
|
#include "cespi.h"
|
|
|
|
|
#include "movam.h"
|
|
|
|
|
#include "movce.h"
|
|
|
|
|
#include "salce.h"
|
2002-02-26 16:20:19 +00:00
|
|
|
|
#include "ce2101.h"
|
2001-04-30 14:22:43 +00:00
|
|
|
|
#include "ce3100a.h"
|
|
|
|
|
#include "ce3100.h"
|
|
|
|
|
|
|
|
|
|
#include "celib.h"
|
2004-03-16 20:40:21 +00:00
|
|
|
|
#include "../cg/cglib01.h"
|
2001-04-30 14:22:43 +00:00
|
|
|
|
|
|
|
|
|
class TForm_registroce : public TForm_cespiti
|
|
|
|
|
{
|
|
|
|
|
TRelation* _newrelation;
|
|
|
|
|
TCursor* _newcursor;
|
2003-07-22 13:22:11 +00:00
|
|
|
|
unsigned int _pag_ini;
|
2001-04-30 14:22:43 +00:00
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
virtual bool validate(TForm_item& fld, TToken_string& val);
|
|
|
|
|
TForm_registroce(const char *name);
|
|
|
|
|
virtual ~TForm_registroce();
|
2002-02-26 16:20:19 +00:00
|
|
|
|
void set_testata() { set_header(1, TRUE); set_background(1, TRUE); }
|
|
|
|
|
void set_piede() { set_footer(0,FALSE); set_footer(0, TRUE);}
|
2003-07-22 13:22:11 +00:00
|
|
|
|
void set_pagina();
|
|
|
|
|
void set_numero_prima_pagina(unsigned int np) { _pag_ini = np; }
|
2002-02-26 16:20:19 +00:00
|
|
|
|
TPrint_section& get_testata_cespite() { return section('H', odd_page); }
|
|
|
|
|
TPrint_section& get_testata_categoria() { return section('H', even_page); }
|
|
|
|
|
TPrint_section& get_piede_categoria() { return section('F', even_page); }
|
|
|
|
|
TPrint_section& get_piede_registro() { return section('F', odd_page); }
|
|
|
|
|
TPrint_section& get_saldiiniziali() { return section('H', last_page); }
|
|
|
|
|
TPrint_section& get_movimenti() { return section('B', first_page); }
|
|
|
|
|
TPrint_section& get_valorifinali() { return section('B', even_page); }
|
|
|
|
|
TPrint_section& get_totali() { return section('B', odd_page); }
|
|
|
|
|
virtual TCursor* cursor() const {return _newcursor; }
|
|
|
|
|
virtual TRelation* relation() const {return _newrelation; }
|
2001-04-30 14:22:43 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
TForm_registroce::TForm_registroce(const char *name):
|
2003-07-22 13:22:11 +00:00
|
|
|
|
TForm_cespiti(name), _pag_ini(0)
|
2001-04-30 14:22:43 +00:00
|
|
|
|
{
|
|
|
|
|
_newrelation = new TRelation(LF_CESPI);
|
|
|
|
|
_newrelation->add("%CAC","CODTAB[1,2]==CODCGRA|CODTAB[3,6]==CODSPA|CODTAB[7,8]==CODCAT",1,0,101);
|
|
|
|
|
_newrelation->add(LF_SALCE,"IDCESPITE==IDCESPITE",1,0,102);
|
|
|
|
|
_newrelation->add("ESC","CODTAB==CODES",1,LF_SALCE,103);
|
|
|
|
|
_newrelation->add(LF_AMMCE,"IDCESPITE==IDCESPITE|CODES==CODES|TPSALDO==TPSALDO",1,LF_SALCE,104);
|
|
|
|
|
_newrelation->add(LF_MOVCE,"IDCESPITE==IDCESPITE",2,0,105);
|
|
|
|
|
_newrelation->add(LF_MOVAM,"IDCESPITE==IDCESPITE|IDMOV==IDMOV",1,LF_MOVCE,106);
|
|
|
|
|
_newrelation->add(LF_AMMMV,"IDCESPITE==IDCESPITE|IDMOV==IDMOV",1,LF_MOVCE,107);
|
|
|
|
|
_newrelation->add("%TMC","CODTAB==CODMOV",1,LF_MOVCE,108);
|
|
|
|
|
_newcursor = new TCursor(_newrelation,"",2);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TForm_registroce::~TForm_registroce()
|
|
|
|
|
{
|
|
|
|
|
delete _newrelation;
|
|
|
|
|
delete _newcursor;
|
|
|
|
|
}
|
2003-07-22 13:22:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void TForm_registroce::set_pagina()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
TString16 numpag, riga;
|
|
|
|
|
numpag.format("%d", _pag_ini+printer().getcurrentpage());
|
|
|
|
|
find_field('F', last_page, FR_PAGINA).set(numpag);
|
|
|
|
|
|
|
|
|
|
set_footer(0, TRUE);
|
|
|
|
|
}
|
|
|
|
|
|
2001-04-30 14:22:43 +00:00
|
|
|
|
|
|
|
|
|
bool TForm_registroce::validate(TForm_item& fld, TToken_string& val)
|
|
|
|
|
{
|
|
|
|
|
return TForm_cespiti::validate(fld, val);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////
|
|
|
|
|
// Applicazione
|
|
|
|
|
/////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
class TRegistro_cespiti : public TSkeleton_application
|
|
|
|
|
{
|
|
|
|
|
TMask* _mask;
|
|
|
|
|
TForm_registroce* _form;
|
|
|
|
|
TDitta_cespiti* _dittace;
|
|
|
|
|
int _tipoamm;
|
|
|
|
|
bool _bollato;
|
|
|
|
|
TEsercizi_contabili _esc;
|
2007-09-17 15:33:04 +00:00
|
|
|
|
TString16 _idspese5, _idspese25;
|
2001-04-30 14:22:43 +00:00
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
virtual bool create();
|
|
|
|
|
virtual bool destroy();
|
|
|
|
|
virtual void main_loop();
|
|
|
|
|
static bool attivita_handler(TMask_field& f, KEY k);
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
void header_registro();
|
|
|
|
|
void footer_registro();
|
|
|
|
|
void footer_categoria();
|
|
|
|
|
void header_categoria(const int categoria);
|
|
|
|
|
void print_cespite();
|
|
|
|
|
void header_cespite();
|
|
|
|
|
void print_saldiiniziali();
|
|
|
|
|
void print_movimenti();
|
|
|
|
|
void print_valorifinali();
|
|
|
|
|
void aggiorna_bollato();
|
2002-02-26 16:20:19 +00:00
|
|
|
|
void crea_cespite_man();
|
|
|
|
|
void distruggi_cespite_man();
|
|
|
|
|
void costruisci_cespite(int cat, const real& spese);
|
2001-04-30 14:22:43 +00:00
|
|
|
|
void stampa_movimento(TRectype& removce, TRectype& removam, TRectype& recammmv);
|
|
|
|
|
void stampa_sezione(TPrint_section& section);
|
|
|
|
|
TRegistro_cespiti() {}
|
|
|
|
|
virtual ~TRegistro_cespiti() {};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
bool TRegistro_cespiti::create()
|
|
|
|
|
{
|
|
|
|
|
open_files(LF_CESPI,0);
|
|
|
|
|
_mask = new TMask("ce3100a");
|
2002-02-26 16:20:19 +00:00
|
|
|
|
_mask->set_handler(F_ESERCIZIO,attivita_handler);
|
2001-04-30 14:22:43 +00:00
|
|
|
|
_mask->set_handler(F_SPECIE,attivita_handler);
|
|
|
|
|
_dittace = new TDitta_cespiti();
|
|
|
|
|
_dittace->init_mask(*_mask);
|
|
|
|
|
_form = new TForm_registroce("ce3100a");
|
|
|
|
|
return TSkeleton_application::create();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TRegistro_cespiti::destroy()
|
|
|
|
|
{
|
|
|
|
|
delete _form;
|
|
|
|
|
delete _dittace;
|
|
|
|
|
delete _mask;
|
|
|
|
|
return TSkeleton_application::destroy();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TRegistro_cespiti::attivita_handler(TMask_field& f, KEY k)
|
|
|
|
|
{
|
|
|
|
|
TMask& m = f.mask();
|
2003-07-22 13:22:11 +00:00
|
|
|
|
if (f.to_check(k) || (k == K_TAB && !m.is_running()) || k == K_ENTER)
|
2001-04-30 14:22:43 +00:00
|
|
|
|
{
|
|
|
|
|
const int esercizio = m.get_int(F_ESERCIZIO);
|
2001-06-25 10:41:20 +00:00
|
|
|
|
const int gruppo = m.get_int(F_GRUPPO);
|
2001-04-30 14:22:43 +00:00
|
|
|
|
const TString16 specie = m.get(F_SPECIE);
|
2003-07-22 13:22:11 +00:00
|
|
|
|
TString16 key; key.format("%4d%02d%s",esercizio, gruppo, (const char*) specie);
|
2001-04-30 14:22:43 +00:00
|
|
|
|
const TRectype& ccb = cache().get("CCB", key);
|
2002-02-26 16:20:19 +00:00
|
|
|
|
const TDate dataultcalc = ccb.get_date("D0");
|
2001-04-30 14:22:43 +00:00
|
|
|
|
m.set(F_DATAULTCALC, dataultcalc);
|
2003-07-22 13:22:11 +00:00
|
|
|
|
|
2002-02-26 16:20:19 +00:00
|
|
|
|
bool calc_on = TRUE, reg_on = TRUE;
|
|
|
|
|
if (dataultcalc.empty())
|
|
|
|
|
{
|
|
|
|
|
calc_on = FALSE;
|
|
|
|
|
m.set(F_CALCOLO,"X");
|
2001-04-30 14:22:43 +00:00
|
|
|
|
}
|
2002-02-26 16:20:19 +00:00
|
|
|
|
if (ccb.get_bool("B2"))
|
|
|
|
|
{
|
|
|
|
|
calc_on = reg_on = FALSE;
|
|
|
|
|
m.reset(F_CALCOLO);
|
2005-10-05 16:54:32 +00:00
|
|
|
|
xvtil_statbar_set(TR("L'esercizio <20> stato chiuso"));
|
2002-02-26 16:20:19 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
2001-04-30 14:22:43 +00:00
|
|
|
|
if (ccb.get_bool("B1"))
|
|
|
|
|
{
|
2002-02-26 16:20:19 +00:00
|
|
|
|
calc_on = reg_on = FALSE;
|
|
|
|
|
m.set(F_CALCOLO,"X");
|
2005-10-05 16:54:32 +00:00
|
|
|
|
xvtil_statbar_set(TR("Il bollato dell'esercizio <20> stato stampato"));
|
2003-07-22 13:22:11 +00:00
|
|
|
|
|
2001-04-30 14:22:43 +00:00
|
|
|
|
}
|
2002-02-26 16:20:19 +00:00
|
|
|
|
else
|
2005-10-05 16:54:32 +00:00
|
|
|
|
xvtil_statbar_set("");
|
2002-02-26 16:20:19 +00:00
|
|
|
|
|
|
|
|
|
m.enable(F_TIPOREGISTRO, reg_on);
|
|
|
|
|
m.enable(F_CALCOLO, calc_on);
|
|
|
|
|
if (!reg_on)
|
|
|
|
|
m.set(F_TIPOREGISTRO,"1");
|
|
|
|
|
|
2003-07-22 13:22:11 +00:00
|
|
|
|
if (k == K_ENTER)
|
|
|
|
|
{
|
|
|
|
|
if (m.get_int(F_TIPOREGISTRO) == 2)
|
|
|
|
|
{
|
|
|
|
|
if (ccb.get_bool("B2"))
|
|
|
|
|
return f.error_box(TR("Attenzione! Esercizio chiuso.\nNon <20> possibile stampare il registro bollato."));
|
|
|
|
|
|
|
|
|
|
if (m.get(F_CODREG).empty())
|
|
|
|
|
return f.error_box(TR("Attenzione! E' necessario specificare il registro cespiti sull'attivita corrente."));
|
|
|
|
|
}
|
|
|
|
|
|
2001-04-30 14:22:43 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2003-07-22 13:22:11 +00:00
|
|
|
|
|
2001-04-30 14:22:43 +00:00
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TRegistro_cespiti::main_loop()
|
|
|
|
|
{
|
|
|
|
|
while (_mask->run() == K_ENTER)
|
2001-06-25 10:41:20 +00:00
|
|
|
|
{
|
2002-02-26 16:20:19 +00:00
|
|
|
|
// Esecuzione calcolo globale
|
2001-06-25 10:41:20 +00:00
|
|
|
|
if (_mask->get_bool(F_CALCOLO))
|
|
|
|
|
{
|
|
|
|
|
const int es = _mask->get_int(F_ESERCIZIO);
|
|
|
|
|
const int gr = _mask->get_int(F_GRUPPO);
|
|
|
|
|
const TString& sp = _mask->get(F_SPECIE);
|
|
|
|
|
ditta_cespiti().set_attivita(es, gr, sp); // Fissa attivit<69> per calcolo
|
|
|
|
|
TExternal_app cal("ce2 -0 A");
|
|
|
|
|
cal.run(); // Esegue programma di calcolo in batch
|
2002-02-26 16:20:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// flag bollato per aggiornamenti
|
2003-07-22 13:22:11 +00:00
|
|
|
|
_bollato = _mask->get_int(F_TIPOREGISTRO)==2;
|
2002-02-26 16:20:19 +00:00
|
|
|
|
if (_bollato)
|
|
|
|
|
crea_cespite_man(); //crea il cespite della manutenzione per cespiti materiali nell'esercizio selezionato
|
2003-07-22 13:22:11 +00:00
|
|
|
|
|
2001-04-30 14:22:43 +00:00
|
|
|
|
TRectype darec(LF_CESPI),arec(LF_CESPI);
|
|
|
|
|
TString filtro;
|
|
|
|
|
// filtro sulla attivit<69> e categorie
|
2001-06-25 10:41:20 +00:00
|
|
|
|
const TString4 catini = _mask->get(F_CATINI);
|
|
|
|
|
const TString4 catfin = _mask->get(F_CATFIN);
|
|
|
|
|
darec.put(CESPI_CODCGRA, _mask->get(F_GRUPPO));
|
2001-04-30 14:22:43 +00:00
|
|
|
|
darec.put(CESPI_CODSPA, _mask->get(F_SPECIE));
|
2001-06-25 10:41:20 +00:00
|
|
|
|
darec.put(CESPI_CODCAT, catini);
|
|
|
|
|
arec.put(CESPI_CODCGRA, _mask->get(F_GRUPPO));
|
2001-04-30 14:22:43 +00:00
|
|
|
|
arec.put(CESPI_CODSPA, _mask->get(F_SPECIE));
|
2001-06-25 10:41:20 +00:00
|
|
|
|
arec.put(CESPI_CODCAT, catfin);
|
2001-04-30 14:22:43 +00:00
|
|
|
|
// filtro sulle date di acquisizione e alienazione
|
2004-03-16 20:40:21 +00:00
|
|
|
|
const TDate datainizio(_mask->get(F_DATAINIZIO));
|
|
|
|
|
const TDate datafine(_mask->get(F_DATAFINE));
|
2001-04-30 14:22:43 +00:00
|
|
|
|
filtro.format("(ANSI(%d->DTCOMP)<=\"",LF_CESPI) << datafine.string(ANSI) << "\")";
|
|
|
|
|
filtro << format(" && ((ANSI(%d->DTALIEN)>=\"",LF_CESPI) << datainizio.string(ANSI);
|
|
|
|
|
filtro << format("\") || (%d->DTALIEN==\"\"))",LF_CESPI);
|
2003-07-22 13:22:11 +00:00
|
|
|
|
|
|
|
|
|
bool show_head = TRUE; // Abilita testata
|
|
|
|
|
bool show_pages = TRUE; // Abilita numerazione pagine
|
|
|
|
|
|
|
|
|
|
TString16 codtab;
|
2004-11-30 22:02:59 +00:00
|
|
|
|
codtab.format("%4d%s", datainizio.year(), (const char*)_mask->get(F_CODREG));
|
2003-07-22 13:22:11 +00:00
|
|
|
|
const TRectype& registro = cache().get("REG", codtab);
|
|
|
|
|
if (!registro.empty())
|
|
|
|
|
{
|
|
|
|
|
show_head = registro.get_bool("B9");
|
|
|
|
|
show_pages = registro.get_bool("S11");
|
|
|
|
|
if (show_pages)
|
|
|
|
|
{
|
|
|
|
|
const int frompage = registro.get_int("I1");
|
|
|
|
|
_form->set_numero_prima_pagina(frompage);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
_form->find_field('H', first_page, FR_CODDITTA).enable(show_head);
|
|
|
|
|
_form->find_field('H', first_page, FR_RAGSOC).enable(show_head);
|
2004-05-21 10:33:54 +00:00
|
|
|
|
_form->find_field('F', last_page, FR_ESERCIZIO).enable(show_pages);
|
2003-07-22 13:22:11 +00:00
|
|
|
|
_form->find_field('F', last_page, FR_PAGINA).enable(show_pages);
|
2004-05-21 10:33:54 +00:00
|
|
|
|
//scrive l'anno inizio esercizio prima del numero pagina
|
|
|
|
|
if (show_pages)
|
|
|
|
|
{
|
|
|
|
|
TString4 annoinizio;
|
|
|
|
|
annoinizio << datainizio.year();
|
|
|
|
|
_form->find_field('F', last_page, FR_ESERCIZIO).set(annoinizio);
|
|
|
|
|
}
|
2001-04-30 14:22:43 +00:00
|
|
|
|
|
|
|
|
|
// filtro su ammortamenti fiscali o civilistici
|
|
|
|
|
_tipoamm = _mask->get_int(F_AMMORTAMENTI);
|
|
|
|
|
_form->find_field('H', last_page, FR_SI_RIVGF).enable(_tipoamm==1);
|
|
|
|
|
_form->find_field('H', last_page, FR_SI_RIVGC).enable(_tipoamm==2);
|
|
|
|
|
_form->find_field('B', first_page, FR_MV_RIVGF).enable(_tipoamm==1);
|
|
|
|
|
_form->find_field('B', first_page, FR_MV_RIVGC).enable(_tipoamm==2);
|
|
|
|
|
_form->find_field('B', even_page, FR_FE_RIVGF).enable(_tipoamm==1);
|
|
|
|
|
_form->find_field('B', even_page, FR_FE_RIVGC).enable(_tipoamm==2);
|
|
|
|
|
_form->find_field('H', last_page, FR_SI_RIVGF).hide();
|
|
|
|
|
_form->find_field('H', last_page, FR_SI_RIVGC).hide();
|
|
|
|
|
_form->find_field('B', first_page, FR_MV_RIVGF).hide();
|
|
|
|
|
_form->find_field('B', first_page, FR_MV_RIVGC).hide();
|
|
|
|
|
_form->find_field('B', even_page, FR_FE_RIVGF).hide();
|
|
|
|
|
_form->find_field('B', even_page, FR_FE_RIVGC).hide();
|
2002-02-26 16:20:19 +00:00
|
|
|
|
// scrive sull'intestazione del form il tipo di situazione da stampare
|
|
|
|
|
if (_tipoamm == 1)
|
|
|
|
|
_form->find_field('H', first_page, FR_SITUAZIONE).set("@bSituazione Fiscale@r");
|
|
|
|
|
if (_tipoamm == 2)
|
|
|
|
|
_form->find_field('H', first_page, FR_SITUAZIONE).set("@bSituazione Civilistica@r");
|
|
|
|
|
|
|
|
|
|
TCursor& cur = *_form->cursor();
|
|
|
|
|
cur.setregion(darec,arec);
|
|
|
|
|
cur.setfilter(filtro,TRUE);
|
|
|
|
|
|
2003-07-22 13:22:11 +00:00
|
|
|
|
const TRecnotype num = cur.items();
|
2002-02-26 16:20:19 +00:00
|
|
|
|
cur.freeze();
|
|
|
|
|
|
2001-04-30 14:22:43 +00:00
|
|
|
|
printer().open();
|
|
|
|
|
header_registro();
|
2002-02-26 16:20:19 +00:00
|
|
|
|
|
|
|
|
|
const TRectype& reccesp = cur.curr();
|
|
|
|
|
int catatt = -1; // Memorizza ultima categoria stampata (inizialmente nessuna)
|
|
|
|
|
for (cur=0; cur.pos()<num; ++cur)
|
2003-07-22 13:22:11 +00:00
|
|
|
|
{
|
|
|
|
|
if (printer().frozen())
|
|
|
|
|
break;
|
2001-04-30 14:22:43 +00:00
|
|
|
|
if (catatt != reccesp.get_int(CESPI_CODCAT))
|
|
|
|
|
{
|
|
|
|
|
if (catatt != -1)
|
|
|
|
|
footer_categoria();
|
|
|
|
|
catatt = reccesp.get_int(CESPI_CODCAT);
|
|
|
|
|
header_categoria(catatt);
|
|
|
|
|
}
|
|
|
|
|
print_cespite();
|
|
|
|
|
}
|
|
|
|
|
if (catatt != -1)
|
|
|
|
|
{
|
|
|
|
|
footer_categoria();
|
2002-02-26 16:20:19 +00:00
|
|
|
|
_form->set_pagina();
|
2001-04-30 14:22:43 +00:00
|
|
|
|
footer_registro();
|
2002-02-26 16:20:19 +00:00
|
|
|
|
_form->set_pagina();
|
2001-04-30 14:22:43 +00:00
|
|
|
|
}
|
2002-02-26 16:20:19 +00:00
|
|
|
|
cur.freeze(FALSE);
|
|
|
|
|
printer().close();
|
|
|
|
|
//trattazione del bollato: aggiorna i campi su files e tab solo dopo conferma, in caso contrario distrugge il cespite
|
|
|
|
|
//della manutenzione creato precedentemente
|
|
|
|
|
if (_bollato)
|
|
|
|
|
{
|
2003-05-13 14:55:32 +00:00
|
|
|
|
if (yesno_box(TR("Bollato stampato in modo corretto ?")))
|
2002-02-26 16:20:19 +00:00
|
|
|
|
aggiorna_bollato();
|
|
|
|
|
else
|
|
|
|
|
distruggi_cespite_man();
|
|
|
|
|
}
|
2001-04-30 14:22:43 +00:00
|
|
|
|
}
|
2002-02-26 16:20:19 +00:00
|
|
|
|
return;
|
2001-04-30 14:22:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-02-26 16:20:19 +00:00
|
|
|
|
void TRegistro_cespiti::costruisci_cespite(int cat, const real& spese)
|
|
|
|
|
{
|
|
|
|
|
int es;
|
|
|
|
|
TString4 gr, sp;
|
|
|
|
|
ditta_cespiti().get_attivita(es, gr, sp);
|
2004-03-16 20:40:21 +00:00
|
|
|
|
const TDate datafine(_mask->get(F_DATAFINE));
|
2002-02-26 16:20:19 +00:00
|
|
|
|
|
|
|
|
|
TString& idcespite = (cat == 91) ? _idspese5 : _idspese25;
|
|
|
|
|
|
|
|
|
|
{ // Scrittura anagrafica cespite
|
|
|
|
|
TLocalisamfile cespi(LF_CESPI);
|
|
|
|
|
cespi.last();
|
|
|
|
|
const real num = cespi.get_real(CESPI_IDCESPITE) + 1;
|
|
|
|
|
idcespite = num.string("@@@@@@@@@@");
|
|
|
|
|
|
|
|
|
|
cespi.zero();
|
|
|
|
|
cespi.put(CESPI_IDCESPITE, idcespite); //zero filled field!
|
|
|
|
|
cespi.put(CESPI_CODCGRA, gr);
|
|
|
|
|
cespi.put(CESPI_CODSPA, sp);
|
|
|
|
|
cespi.put(CESPI_CODCAT, cat);
|
|
|
|
|
cespi.put(CESPI_DTCOMP, datafine);
|
|
|
|
|
cespi.put(CESPI_DTFUNZ, datafine);
|
|
|
|
|
cespi.put(CESPI_AMMPROP, "X");
|
|
|
|
|
cespi.put(CESPI_TUIR, "X");
|
|
|
|
|
cespi.put(CESPI_USOPROM, 1);
|
|
|
|
|
cespi.put(CESPI_FLGTPVEI, 1);
|
|
|
|
|
cespi.put(CESPI_TPSPEMAN, 1);
|
|
|
|
|
|
2003-05-13 14:55:32 +00:00
|
|
|
|
TString desc = TR("Importo spese di manutenzione sostenute - beni materiali ");
|
2002-02-26 16:20:19 +00:00
|
|
|
|
desc << (cat == 91 ? 5 : 25) << '%';
|
|
|
|
|
cespi.put(CESPI_DESC, desc);
|
|
|
|
|
|
|
|
|
|
const TRectype& cac = ditta_cespiti().categoria(0, NULL, cat);
|
|
|
|
|
cespi.put(CESPI_VINCOLO, cac.get("I2"));
|
|
|
|
|
cespi.put(CESPI_ANNIRIC, cac.get("I3"));
|
|
|
|
|
cespi.put(CESPI_PMINP, cac.get("R14"));
|
|
|
|
|
cespi.put(CESPI_PMAXP, cac.get("R15"));
|
|
|
|
|
|
|
|
|
|
cespi.write(); //abbiamo creato il cespite su CESPI!
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
{ // Scrittura saldo iniziale
|
|
|
|
|
TLocalisamfile salce(LF_SALCE);
|
|
|
|
|
salce.put(SALCE_IDCESPITE, idcespite);
|
|
|
|
|
salce.put(SALCE_CODES, es);
|
|
|
|
|
salce.put(SALCE_TPSALDO, 1);
|
|
|
|
|
salce.put(SALCE_NUMELE, 1);
|
|
|
|
|
salce.put(SALCE_CSTO, spese);
|
|
|
|
|
salce.write(); //abbiamo creato il cespite su SALCE!
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Calcola ammortamenti per cespite (creando anche salce 2 e i 6 ammce)
|
|
|
|
|
TCespite ces(idcespite);
|
2007-09-17 15:33:04 +00:00
|
|
|
|
for (int sit = 1; sit <= 3; sit++)
|
|
|
|
|
ces.calc_amm(sit, datafine);
|
2002-02-26 16:20:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TRegistro_cespiti::crea_cespite_man()
|
|
|
|
|
{
|
|
|
|
|
_idspese5 = _idspese25 = "";
|
|
|
|
|
const TRectype& ccb = ditta_cespiti().get_attivita();
|
2002-07-02 16:21:23 +00:00
|
|
|
|
const real speseman_5 = ccb.get_real("R0") - ccb.get_real("R2");
|
|
|
|
|
if (speseman_5 > ZERO)
|
2002-02-26 16:20:19 +00:00
|
|
|
|
costruisci_cespite(91, speseman_5);
|
|
|
|
|
|
2002-07-02 16:21:23 +00:00
|
|
|
|
const real speseman_25 = ccb.get_real("R1") - ccb.get_real("R3");
|
|
|
|
|
if (speseman_25 > ZERO)
|
2002-02-26 16:20:19 +00:00
|
|
|
|
costruisci_cespite(92, speseman_25);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
HIDDEN void kill_rec(TLocalisamfile& f)
|
2001-04-30 14:22:43 +00:00
|
|
|
|
{
|
2002-02-26 16:20:19 +00:00
|
|
|
|
int err = f.read();
|
|
|
|
|
if (err == NOERR)
|
|
|
|
|
{
|
|
|
|
|
err = f.remove();
|
|
|
|
|
if (err == NOERR && f.read() == NOERR)
|
|
|
|
|
err = _iskeyerr;
|
|
|
|
|
}
|
|
|
|
|
if (err != NOERR)
|
2003-05-13 14:55:32 +00:00
|
|
|
|
error_box(FR("Errore %d durante la cancellazione del cespite %s dal file: %d"),
|
2002-02-26 16:20:19 +00:00
|
|
|
|
err, (const char*)f.get("IDCESPITE"), f.num());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TRegistro_cespiti::distruggi_cespite_man()
|
|
|
|
|
{
|
|
|
|
|
TLocalisamfile cespi(LF_CESPI);
|
|
|
|
|
TLocalisamfile salce(LF_SALCE);
|
|
|
|
|
TLocalisamfile ammce(LF_AMMCE);
|
|
|
|
|
const int es = _mask->get_int(F_ESERCIZIO);
|
|
|
|
|
|
|
|
|
|
for (int cat = 91; cat <= 92; cat++)
|
|
|
|
|
{
|
|
|
|
|
TString& idcespite = (cat == 91) ? _idspese5 : _idspese25;
|
|
|
|
|
if (idcespite.not_empty())
|
|
|
|
|
{
|
|
|
|
|
cespi.zero();
|
|
|
|
|
cespi.put(CESPI_IDCESPITE, idcespite);
|
|
|
|
|
kill_rec(cespi);
|
|
|
|
|
|
|
|
|
|
for (int tpsaldo = 1; tpsaldo <= 2; tpsaldo++)
|
|
|
|
|
{
|
|
|
|
|
salce.zero();
|
|
|
|
|
salce.put(SALCE_IDCESPITE, idcespite);
|
|
|
|
|
salce.put(SALCE_CODES, es);
|
|
|
|
|
salce.put(SALCE_TPSALDO, tpsaldo);
|
|
|
|
|
kill_rec(salce);
|
|
|
|
|
for (int tpamm = 1; tpamm <= 3; tpamm++)
|
|
|
|
|
{
|
|
|
|
|
ammce.zero();
|
|
|
|
|
ammce.put(AMMCE_IDCESPITE, idcespite);
|
|
|
|
|
ammce.put(AMMCE_CODES, es);
|
|
|
|
|
ammce.put(AMMCE_TPSALDO, tpsaldo);
|
|
|
|
|
ammce.put(AMMCE_TPAMM, tpamm);
|
|
|
|
|
kill_rec(ammce);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
idcespite.cut(0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TRegistro_cespiti::aggiorna_bollato()
|
|
|
|
|
{
|
2003-07-22 13:22:11 +00:00
|
|
|
|
const TDate oggi(TODAY);
|
|
|
|
|
|
2002-02-26 16:20:19 +00:00
|
|
|
|
{ //aggiorna la tabella CCB
|
|
|
|
|
TTable ccb("CCB");
|
|
|
|
|
ccb.curr() = ditta_cespiti().get_attivita();
|
|
|
|
|
ccb.put("B1", "X"); //bollato stampato
|
|
|
|
|
ccb.rewrite();
|
|
|
|
|
}
|
2003-07-22 13:22:11 +00:00
|
|
|
|
|
|
|
|
|
//aggiorna la tabella REG (registro cespiti)
|
|
|
|
|
{
|
2004-03-16 20:40:21 +00:00
|
|
|
|
const TDate datafine(_mask->get(F_DATAFINE));
|
2003-07-22 13:22:11 +00:00
|
|
|
|
TString16 codtab;
|
|
|
|
|
codtab.format("%4d%s", datafine.year(), (const char*)_mask->get(F_CODREG));
|
|
|
|
|
TTable reg("REG");
|
|
|
|
|
reg.put("CODTAB", codtab);
|
|
|
|
|
if (reg.read() == NOERR)
|
|
|
|
|
{
|
|
|
|
|
long pagine = reg.get_int("I1");
|
2004-11-30 22:02:59 +00:00
|
|
|
|
pagine += printer().getcurrentpage() - 1; //correzione necessaria perche' questa istruzione aggiunge
|
|
|
|
|
//una pagina (e' quella su cui sarebbe pronta a stampare)
|
2003-07-22 13:22:11 +00:00
|
|
|
|
reg.put("I1", pagine); // Aggiorna pagine stampate
|
|
|
|
|
reg.put("D3", oggi); // Aggiorna data di stampa
|
|
|
|
|
reg.rewrite();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2002-02-26 16:20:19 +00:00
|
|
|
|
{ //aggiorna il file SALCE
|
|
|
|
|
TRelation rel (LF_SALCE);
|
|
|
|
|
TString expr = "CODES=";
|
|
|
|
|
expr << _mask->get(F_ESERCIZIO);
|
|
|
|
|
TCursor cursor(&rel, expr);
|
2003-07-22 13:22:11 +00:00
|
|
|
|
const TRecnotype items = cursor.items();
|
2002-02-26 16:20:19 +00:00
|
|
|
|
cursor.freeze();
|
|
|
|
|
|
|
|
|
|
TRectype& curr = cursor.curr();
|
|
|
|
|
for (cursor = 0; cursor.pos() < items; ++cursor)
|
|
|
|
|
{
|
|
|
|
|
const TString16 idcespite = curr.get(SALCE_IDCESPITE); //controlla che il cespite appartenga all'attivit<69> selezionata
|
|
|
|
|
const TRectype& ces = cache().get(LF_CESPI, idcespite);
|
|
|
|
|
if (ces.get_int(CESPI_CODCGRA) != _mask->get_int(F_GRUPPO))
|
|
|
|
|
continue;
|
|
|
|
|
if (ces.get(CESPI_CODSPA) != _mask->get(F_SPECIE))
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
curr.put(SALCE_DTSTBOLL, oggi);
|
|
|
|
|
rel.rewrite();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
{ //aggiorna il file MOVCE
|
|
|
|
|
TRelation rel (LF_MOVCE);
|
|
|
|
|
TString expr;
|
|
|
|
|
expr << "(ANSI(DTMOV)>=\""<<_mask->get_date(F_DATAINIZIO).string(ANSI)<<"\")&&";
|
|
|
|
|
expr << "(ANSI(DTMOV)<=\""<<_mask->get_date(F_DATAFINE).string(ANSI)<<"\")";
|
|
|
|
|
TCursor cursor(&rel, expr);
|
|
|
|
|
TRectype& curr = cursor.curr();
|
2003-07-22 13:22:11 +00:00
|
|
|
|
const TRecnotype items = cursor.items();
|
2002-02-26 16:20:19 +00:00
|
|
|
|
cursor.freeze();
|
|
|
|
|
for (cursor = 0; cursor.pos() < items; ++cursor)
|
|
|
|
|
{
|
2002-12-20 16:15:03 +00:00
|
|
|
|
const TString16 idcespite = curr.get(MOVCE_IDCESPITE); //controlla che il cespite appartenga all'attivit<69> selezionata
|
2002-02-26 16:20:19 +00:00
|
|
|
|
const TRectype& ces = cache().get(LF_CESPI, idcespite);
|
|
|
|
|
if (ces.get_int(CESPI_CODCGRA) != _mask->get_int(F_GRUPPO))
|
|
|
|
|
continue;
|
|
|
|
|
if (ces.get(CESPI_CODSPA) != _mask->get(F_SPECIE))
|
|
|
|
|
continue;
|
|
|
|
|
curr.put(MOVCE_STAMPATO, "X");
|
|
|
|
|
rel.rewrite();
|
|
|
|
|
}
|
|
|
|
|
}
|
2001-04-30 14:22:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TRegistro_cespiti::header_registro()
|
2003-07-22 13:22:11 +00:00
|
|
|
|
{
|
2001-04-30 14:22:43 +00:00
|
|
|
|
_form->find_field('H', first_page, FR_CODDITTA).set(_mask->get(F_CODDITTA));
|
|
|
|
|
_form->find_field('H', first_page, FR_RAGSOC).set(_mask->get(F_RAGSOC));
|
|
|
|
|
_form->find_field('H', first_page, FR_GRUPPO).set(_mask->get(F_GRUPPO));
|
|
|
|
|
_form->find_field('H', first_page, FR_D_GRUPPO).set(_mask->get(F_D_GRUPPO));
|
|
|
|
|
_form->find_field('H', first_page, FR_SPECIE).set(_mask->get(F_SPECIE));
|
|
|
|
|
_form->find_field('H', first_page, FR_D_SPECIE).set(_mask->get(F_D_SPECIE));
|
|
|
|
|
_form->find_field('H', first_page, FR_DATAINIZIO).set(_mask->get(F_DATAINIZIO));
|
|
|
|
|
_form->find_field('H', first_page, FR_DATAFINE).set(_mask->get(F_DATAFINE));
|
2002-02-26 16:20:19 +00:00
|
|
|
|
TString key; key.format("%04d",_mask->get_int(F_ESERCIZIO));
|
2001-06-25 10:41:20 +00:00
|
|
|
|
|
2001-04-30 14:22:43 +00:00
|
|
|
|
const TRectype& cce = cache().get("CCE", key);
|
2001-06-25 10:41:20 +00:00
|
|
|
|
_form->find_field('H', first_page, FR_NUMGIOSOL).set(cce.get("I3"));
|
2002-02-26 16:20:19 +00:00
|
|
|
|
const int giorni = int(_mask->get_date(F_DATAFINE) - _mask->get_date(F_DATAINIZIO) + 1);
|
2001-04-30 14:22:43 +00:00
|
|
|
|
key.format("%3d",giorni);
|
2001-06-25 10:41:20 +00:00
|
|
|
|
_form->find_field('H', first_page, FR_NUMGIORNI).set(key);
|
|
|
|
|
|
2002-02-26 16:20:19 +00:00
|
|
|
|
_form->find_field('H', first_page, FR_LIBROCESPITI); // .enable(_bollato);
|
2001-04-30 14:22:43 +00:00
|
|
|
|
_form->set_testata();
|
2002-02-26 16:20:19 +00:00
|
|
|
|
|
|
|
|
|
//se stampa bollato -> nascondi data stampa
|
2004-05-21 10:33:54 +00:00
|
|
|
|
_form->find_field('F', last_page, FR_DATASTAMPA).show(_mask->get_int(F_TIPOREGISTRO) != 2);
|
2005-06-01 11:20:06 +00:00
|
|
|
|
|
|
|
|
|
//azzera i campi dei totali generali
|
|
|
|
|
TPrint_section& totgen = _form->get_piede_registro();
|
|
|
|
|
for(word t = 0; t < totgen.fields(); t++)
|
|
|
|
|
totgen.field(t).set("");
|
|
|
|
|
|
2001-04-30 14:22:43 +00:00
|
|
|
|
_form->set_piede();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void TRegistro_cespiti::print_cespite()
|
|
|
|
|
{
|
|
|
|
|
// stampa i dati del cespite
|
2003-07-22 13:22:11 +00:00
|
|
|
|
const TRecnotype pos = _form->cursor()->pos(); //memorizza posizione cursore
|
2001-04-30 14:22:43 +00:00
|
|
|
|
|
|
|
|
|
header_cespite();
|
|
|
|
|
print_saldiiniziali();
|
|
|
|
|
print_movimenti();
|
|
|
|
|
print_valorifinali();
|
|
|
|
|
|
|
|
|
|
*_form->cursor() = pos; //riposiziona il cursore
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TRegistro_cespiti::header_cespite()
|
|
|
|
|
{
|
|
|
|
|
// intestazione cespite
|
|
|
|
|
TPrint_section& section = _form->get_testata_cespite();
|
|
|
|
|
section.update();
|
|
|
|
|
_form->set_pagina();
|
|
|
|
|
for (word i = 0; i < section.height(); i++)
|
|
|
|
|
printer().print(section.row(i));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TRegistro_cespiti::print_saldiiniziali()
|
|
|
|
|
{
|
|
|
|
|
// saldi iniziali cespite (da salce e ammce con tpsaldo=1(saldo iniziale) ed esercizio = esercizio selezionato)
|
|
|
|
|
const int esercizio = _mask->get_int(F_ESERCIZIO);
|
|
|
|
|
TRectype& recsalce = _form->cursor()->curr(LF_SALCE);
|
|
|
|
|
bool continua = _form->cursor()->is_first_match(LF_SALCE);
|
|
|
|
|
while (continua && (recsalce.get_int(SALCE_TPSALDO) != 1 || recsalce.get_int(SALCE_CODES) != esercizio))
|
|
|
|
|
continua = _form->cursor()->next_match(LF_SALCE);
|
|
|
|
|
if (!continua)
|
|
|
|
|
recsalce.zero();
|
|
|
|
|
|
|
|
|
|
TRectype& recammce = _form->cursor()->curr(LF_AMMCE);
|
|
|
|
|
continua = _form->cursor()->is_first_match(LF_AMMCE);
|
|
|
|
|
while (continua && recammce.get_int(AMMCE_TPAMM)!= _tipoamm) //l'esercizio <20> quello selezionato poich<63> <20> nella chiave
|
|
|
|
|
continua = _form->cursor()->next_match(LF_AMMCE);
|
|
|
|
|
if (!continua)
|
|
|
|
|
_form->cursor()->curr(LF_AMMCE).zero();
|
|
|
|
|
|
|
|
|
|
TPrint_section& section = _form->get_saldiiniziali();
|
|
|
|
|
section.update();
|
|
|
|
|
_form->set_pagina();
|
|
|
|
|
for (word i = 0; i < section.height(); i++)
|
|
|
|
|
printer().print(section.row(i));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void TRegistro_cespiti::stampa_sezione(TPrint_section& section)
|
|
|
|
|
{
|
|
|
|
|
section.update();
|
|
|
|
|
_form->set_pagina();
|
|
|
|
|
word y1 = section.find_field(FR_MV_QNOR).y();
|
|
|
|
|
word y2 = section.find_field(FR_MV_QANT).y();
|
|
|
|
|
for (word i = 0; i < section.height(); i++)
|
|
|
|
|
{
|
2002-02-26 16:20:19 +00:00
|
|
|
|
if (i>=y1-1 && i<= y2-1)
|
2001-04-30 14:22:43 +00:00
|
|
|
|
{
|
|
|
|
|
TPrintrow& row = section.row(i);
|
|
|
|
|
TString rowstr = row.row();
|
2002-02-26 16:20:19 +00:00
|
|
|
|
if (!rowstr.blank()) //se almeno 1 valore della riga <20> <> 0 allora la riga viene stampata, in caso contrario viene saltata
|
2001-04-30 14:22:43 +00:00
|
|
|
|
printer().print(section.row(i));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
printer().print(section.row(i));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void TRegistro_cespiti::stampa_movimento(TRectype& recmovce, TRectype& recmovam, TRectype& recammmv)
|
|
|
|
|
{
|
|
|
|
|
TPrint_section& section = _form->get_movimenti();
|
|
|
|
|
_form->cursor()->curr(LF_MOVCE) = recmovce; //
|
|
|
|
|
_form->cursor()->curr(LF_MOVAM) = recmovam; //copia il record del cursore che scannerizza movimenti e rettifiche nel
|
|
|
|
|
_form->cursor()->curr(LF_AMMMV) = recammmv; //cursore principale del form
|
|
|
|
|
|
|
|
|
|
if (recmovce.get_char(MOVCE_SEGNO)=='-')
|
|
|
|
|
{
|
|
|
|
|
section.find_field(FR_MV_SEGNO).set("-1");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
section.find_field(FR_MV_SEGNO).set("1");
|
|
|
|
|
}
|
|
|
|
|
|
2002-02-26 16:20:19 +00:00
|
|
|
|
section.update();
|
|
|
|
|
_form->set_pagina();
|
2001-04-30 14:22:43 +00:00
|
|
|
|
|
2002-02-26 16:20:19 +00:00
|
|
|
|
for (word i = 0; i < section.height(); i++)
|
|
|
|
|
{
|
|
|
|
|
TPrintrow& row = section.row(i);
|
|
|
|
|
TString rowstr = row.row();
|
|
|
|
|
if (!rowstr.blank())
|
|
|
|
|
printer().print(row);
|
|
|
|
|
}
|
2001-04-30 14:22:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TRegistro_cespiti::print_movimenti()
|
|
|
|
|
{
|
|
|
|
|
TPrint_section& totali = _form->get_totali();
|
|
|
|
|
// movimenti
|
|
|
|
|
for (bool ok=_form->cursor()->is_first_match(LF_MOVCE); ok; ok=_form->cursor()->next_match(LF_MOVCE))
|
|
|
|
|
{
|
|
|
|
|
TRectype& recmovce = _form->cursor()->curr(LF_MOVCE);
|
|
|
|
|
const TString16 idret = recmovce.get(MOVCE_IDRET);
|
|
|
|
|
if (idret.not_empty())
|
|
|
|
|
continue;
|
|
|
|
|
|
2004-03-16 20:40:21 +00:00
|
|
|
|
const TDate dtmov = recmovce.get_date(MOVCE_DTMOV);
|
2001-04-30 14:22:43 +00:00
|
|
|
|
const int esmov = _esc.date2esc(dtmov);
|
|
|
|
|
if (_mask->get_int(F_ESERCIZIO) != esmov)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
for(word t = 0; t < totali.fields(); t++) //azzera i campi dei totali
|
|
|
|
|
totali.field(t).set("");
|
|
|
|
|
|
|
|
|
|
TRectype& recmovam = _form->cursor()->curr(LF_MOVAM);
|
|
|
|
|
bool continua = _form->cursor()->is_first_match(LF_MOVAM);
|
|
|
|
|
while (recmovam.get_int(MOVAM_TPAMM) != _tipoamm && continua)
|
|
|
|
|
continua = _form->cursor()->next_match(LF_MOVAM);
|
|
|
|
|
if (!continua) recmovam.zero();
|
|
|
|
|
TRectype& recammmv = _form->cursor()->curr(LF_AMMMV);
|
|
|
|
|
continua = _form->cursor()->is_first_match(LF_AMMMV);
|
|
|
|
|
while (recammmv.get_int(AMMMV_TPAMM) != _tipoamm && continua)
|
|
|
|
|
continua = _form->cursor()->next_match(LF_AMMMV);
|
|
|
|
|
if (!continua) recammmv.zero();
|
|
|
|
|
|
|
|
|
|
stampa_movimento(recmovce,recmovam,recammmv); //stampa i movimenti SENZA rettifiche
|
|
|
|
|
|
|
|
|
|
// rettifiche (<28> necessario utilizzare un nuovo cursore, quindi si comincia con la relazione...)
|
|
|
|
|
TRelation rel_rettif(LF_MOVCE);
|
|
|
|
|
TString expr; expr << "IDCESPITE==IDCESPITE|IDMOV==IDMOV|TPAMM==\"" << _tipoamm << '"';
|
|
|
|
|
rel_rettif.add(LF_MOVAM, expr);
|
|
|
|
|
rel_rettif.add(LF_AMMMV, expr);
|
|
|
|
|
const TString16 id = recmovce.get(MOVCE_IDCESPITE);
|
|
|
|
|
|
|
|
|
|
// e quindi si passa al cursore...; notare che il cursore delle rettifiche usa la chiave 2: IDCESPITE+IDMOV;
|
|
|
|
|
// per cui parte per selezionare le possibili rettifiche del movimento da rettificare da lui...
|
|
|
|
|
TRectype fromret(LF_MOVCE);
|
|
|
|
|
fromret.put(MOVCE_IDCESPITE, id); //IDCESPITE della chiave 2
|
|
|
|
|
fromret.put(MOVCE_IDMOV, recmovce.get(MOVCE_IDMOV)); //IDMOV della chiave 2
|
|
|
|
|
//...in poi
|
|
|
|
|
TRectype toret(LF_MOVCE);
|
|
|
|
|
toret.put(MOVCE_IDCESPITE, id);
|
|
|
|
|
|
|
|
|
|
TString filtro;
|
2002-02-26 16:20:19 +00:00
|
|
|
|
filtro << MOVCE_IDRET << "==\"" << recmovce.get(MOVCE_IDMOV) << '"'; //confronta numericamente IDRET e IDMOV
|
2001-04-30 14:22:43 +00:00
|
|
|
|
//ed ecco il cursore!
|
|
|
|
|
TCursor rettcur(&rel_rettif, filtro, 2, &fromret, &toret);
|
|
|
|
|
const long items = rettcur.items();
|
|
|
|
|
if (items > 0)
|
|
|
|
|
{
|
2002-02-26 16:20:19 +00:00
|
|
|
|
_form->cursor()->relation()->save_status(); //salva posizione di tutti i files del cursore
|
|
|
|
|
//(serve per rettifiche "staccate" dai loro movimenti)
|
2001-04-30 14:22:43 +00:00
|
|
|
|
rettcur.freeze();
|
|
|
|
|
for (rettcur = 0l ; rettcur.pos()<items; ++rettcur)
|
|
|
|
|
stampa_movimento(rettcur.curr(LF_MOVCE), rettcur.curr(LF_MOVAM), rettcur.curr(LF_AMMMV));
|
2002-02-26 16:20:19 +00:00
|
|
|
|
|
|
|
|
|
_form->cursor()->relation()->restore_status(); //ripristina la posizione di tutti i files del cursore
|
2001-04-30 14:22:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
stampa_sezione(totali);
|
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TRegistro_cespiti::print_valorifinali()
|
|
|
|
|
{
|
|
|
|
|
// valori a fine esercizio cespite (da salce e ammce con tpsaldo=2)
|
|
|
|
|
const int esercizio = _mask->get_int(F_ESERCIZIO);
|
|
|
|
|
|
|
|
|
|
TRectype& recsalce = _form->cursor()->curr(LF_SALCE);
|
|
|
|
|
const TString16 idcespite = _form->cursor()->curr().get(CESPI_IDCESPITE);
|
|
|
|
|
bool continua = recsalce.get(SALCE_IDCESPITE) == idcespite;
|
|
|
|
|
while (continua && (recsalce.get_int(SALCE_TPSALDO) !=2 || recsalce.get_int(SALCE_CODES) != esercizio))
|
|
|
|
|
continua = _form->cursor()->next_match(LF_SALCE);
|
|
|
|
|
if (!continua)
|
|
|
|
|
recsalce.zero();
|
|
|
|
|
|
|
|
|
|
TRectype& recammce = _form->cursor()->curr(LF_AMMCE);
|
|
|
|
|
continua = recammce.get(AMMCE_IDCESPITE) == idcespite;
|
|
|
|
|
while (recammce.get_int(AMMCE_TPAMM) != _tipoamm && continua)
|
|
|
|
|
continua = _form->cursor()->next_match(LF_AMMCE);
|
|
|
|
|
if (!continua)
|
|
|
|
|
recammce.zero();
|
|
|
|
|
|
|
|
|
|
TPrint_section& section = _form->get_valorifinali();
|
|
|
|
|
|
2009-01-14 09:51:53 +00:00
|
|
|
|
bool msg = recammce.get_bool(AMMCE_MSG01);
|
2001-04-30 14:22:43 +00:00
|
|
|
|
section.find_field(FR_FE_MSG1).enable(msg);
|
2009-01-14 09:51:53 +00:00
|
|
|
|
msg = recammce.get_bool(AMMCE_MSG02);
|
|
|
|
|
TString key; key.format("%04d",_mask->get_int(F_ESERCIZIO));
|
2001-04-30 14:22:43 +00:00
|
|
|
|
const TRectype& cce = cache().get("CCE", key);
|
2009-01-14 09:51:53 +00:00
|
|
|
|
const long giorni = (_mask->get_date(F_DATAFINE) - _mask->get_date(F_DATAINIZIO) + 1);
|
|
|
|
|
key.format(FR("Amm.to ragguagliato all'esercizio di %3d giorni su %3d"), giorni, cce.get_int("I3"));
|
2001-04-30 14:22:43 +00:00
|
|
|
|
section.find_field(FR_FE_MSG2).set(key);
|
|
|
|
|
section.find_field(FR_FE_MSG2).enable(msg);
|
2009-01-14 09:51:53 +00:00
|
|
|
|
msg = recammce.get_bool(AMMCE_MSG03);
|
2001-04-30 14:22:43 +00:00
|
|
|
|
const int usoprom = _form->cursor()->curr().get_int(CESPI_USOPROM);
|
2009-01-14 09:51:53 +00:00
|
|
|
|
switch (usoprom)
|
|
|
|
|
{
|
|
|
|
|
case 2: key=TR("Ammortamento ridotto al 50% per bene in uso promiscuo"); break;
|
|
|
|
|
case 3: key=TR("Ammortamento ridotto all'80% per bene in uso promiscuo agenti/rappresentanti"); break;
|
|
|
|
|
case 4: key=TR("Ammortamento ridotto al 40% per auto in uso promiscuo"); break;
|
|
|
|
|
case 5: key=TR("Ammortamento ridotto al 90% per auto in fringe benefit"); break;
|
|
|
|
|
case 6: key=TR("Ammortamento ridotto all'80% per cellulari in uso promiscuo"); break;
|
|
|
|
|
default: break;
|
|
|
|
|
}
|
2001-04-30 14:22:43 +00:00
|
|
|
|
section.find_field(FR_FE_MSG3).set(key);
|
|
|
|
|
section.find_field(FR_FE_MSG3).enable(msg);
|
2009-01-14 09:51:53 +00:00
|
|
|
|
msg = recammce.get_bool(AMMCE_MSG04);
|
2001-04-30 14:22:43 +00:00
|
|
|
|
section.find_field(FR_FE_MSG4).enable(msg);
|
2009-01-14 09:51:53 +00:00
|
|
|
|
msg = recammce.get_bool(AMMCE_MSG05);
|
2001-04-30 14:22:43 +00:00
|
|
|
|
section.find_field(FR_FE_MSG5).enable(msg);
|
2009-01-14 09:51:53 +00:00
|
|
|
|
msg = recammce.get_bool(AMMCE_MSG06);
|
2001-04-30 14:22:43 +00:00
|
|
|
|
section.find_field(FR_FE_MSG6).enable(msg);
|
|
|
|
|
section.update();
|
|
|
|
|
_form->set_pagina();
|
2009-01-14 09:51:53 +00:00
|
|
|
|
const word y1 = section.find_field(FR_FE_QNOR).y();
|
|
|
|
|
const word y2 = section.find_field(FR_FE_MSG6).y();
|
2001-04-30 14:22:43 +00:00
|
|
|
|
for (word i = 0; i < section.height(); i++)
|
|
|
|
|
{
|
2009-01-14 09:51:53 +00:00
|
|
|
|
TPrintrow& row = section.row(i);
|
2001-04-30 14:22:43 +00:00
|
|
|
|
if (i+1>=y1 && i+1<= y2)
|
|
|
|
|
{
|
2009-01-14 09:51:53 +00:00
|
|
|
|
const TFixed_string rowstr(row.row());
|
|
|
|
|
if (rowstr.blank())
|
|
|
|
|
continue;
|
2001-04-30 14:22:43 +00:00
|
|
|
|
}
|
2009-01-14 09:51:53 +00:00
|
|
|
|
printer().print(row);
|
2001-04-30 14:22:43 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TRegistro_cespiti::header_categoria(const int categoria)
|
|
|
|
|
{
|
|
|
|
|
// intestazione della categoria
|
2004-02-02 14:25:16 +00:00
|
|
|
|
if ((_mask->get_bool(F_JUMPCAT)) && (printer().current_row() > 1)) //caso di salto pagina al cambio categoria
|
|
|
|
|
printer().formfeed();
|
|
|
|
|
|
2001-04-30 14:22:43 +00:00
|
|
|
|
TPrint_section& section = _form->get_testata_categoria();
|
|
|
|
|
section.update();
|
|
|
|
|
_form->set_pagina();
|
|
|
|
|
for (word i = 0; i < section.height(); i++)
|
|
|
|
|
printer().print(section.row(i));
|
|
|
|
|
return ;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TRegistro_cespiti::footer_categoria()
|
|
|
|
|
{
|
|
|
|
|
// stampa il footer della categoria
|
|
|
|
|
TPrint_section& section = _form->get_piede_categoria();
|
|
|
|
|
section.update();
|
|
|
|
|
_form->set_pagina();
|
|
|
|
|
for (word i = 0; i < section.height(); i++)
|
|
|
|
|
printer().print(section.row(i));
|
|
|
|
|
return ;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TRegistro_cespiti::footer_registro()
|
|
|
|
|
{
|
|
|
|
|
// stampa il footer del registro (totali generali)
|
|
|
|
|
TPrint_section& section = _form->get_piede_registro();
|
|
|
|
|
section.update();
|
|
|
|
|
_form->set_pagina();
|
|
|
|
|
for (word i = 0; i < section.height(); i++)
|
|
|
|
|
printer().print(section.row(i));
|
|
|
|
|
return ;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int ce3100(int argc, char* argv[])
|
|
|
|
|
{
|
|
|
|
|
TRegistro_cespiti a;
|
2003-05-13 14:55:32 +00:00
|
|
|
|
a.run(argc,argv,TR("Stampa registro cespiti"));
|
2001-04-30 14:22:43 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|