1998-05-04 10:01:02 +00:00
|
|
|
|
#include <relapp.h>
|
|
|
|
|
|
1997-06-27 09:22:18 +00:00
|
|
|
|
#include "../ve/velib.h"
|
1998-05-04 10:01:02 +00:00
|
|
|
|
|
1996-10-21 14:34:51 +00:00
|
|
|
|
#include "ef0.h"
|
|
|
|
|
#include "ef0100.h"
|
1997-04-29 13:11:17 +00:00
|
|
|
|
#include "ef0101.h"
|
1996-12-06 15:50:15 +00:00
|
|
|
|
|
1998-05-04 10:01:02 +00:00
|
|
|
|
#include <comuni.h>
|
1999-10-22 10:00:18 +00:00
|
|
|
|
#include <doc.h>
|
1998-05-04 10:01:02 +00:00
|
|
|
|
|
1997-02-18 15:10:08 +00:00
|
|
|
|
///////////////////////////////////////////////////////////////
|
1997-01-15 16:00:56 +00:00
|
|
|
|
// Classe per la gestione di effetti con metodi standard di: //
|
1997-02-18 15:10:08 +00:00
|
|
|
|
// inserimento, modifica, cancellazione. //
|
|
|
|
|
///////////////////////////////////////////////////////////////
|
1996-12-06 15:50:15 +00:00
|
|
|
|
|
1996-11-05 14:24:56 +00:00
|
|
|
|
class TVariazione_effetti: public TRelation_application
|
1996-10-21 14:34:51 +00:00
|
|
|
|
{
|
1996-11-05 14:24:56 +00:00
|
|
|
|
TMask *_msk;
|
|
|
|
|
TEffetto *_effetto;
|
1997-04-29 13:11:17 +00:00
|
|
|
|
TRelation *_rel;
|
1999-04-06 15:34:39 +00:00
|
|
|
|
|
1997-04-29 13:11:17 +00:00
|
|
|
|
protected:
|
|
|
|
|
virtual void init_query_mode(TMask&);
|
1996-11-05 14:24:56 +00:00
|
|
|
|
virtual void init_insert_mode(TMask&);
|
1998-05-04 10:01:02 +00:00
|
|
|
|
virtual bool get_next_key(TToken_string& key);
|
1999-04-06 15:34:39 +00:00
|
|
|
|
virtual void init_modify_mode(TMask&);
|
2003-11-10 15:01:25 +00:00
|
|
|
|
static bool clifo_handler(TMask_field& f, KEY k);
|
2002-05-08 16:25:49 +00:00
|
|
|
|
static bool datascad_handler(TMask_field& f, KEY k);
|
1996-11-05 14:24:56 +00:00
|
|
|
|
static bool handle_sheet(TMask_field& f, KEY);
|
2000-10-03 13:45:12 +00:00
|
|
|
|
static bool cambio_handler(TMask_field& f, KEY k);
|
1996-11-05 14:24:56 +00:00
|
|
|
|
static bool codval_handler(TMask_field& f, KEY k);
|
1997-05-05 10:38:42 +00:00
|
|
|
|
static bool contab_handler(TMask_field& f, KEY k);
|
1997-05-21 10:55:09 +00:00
|
|
|
|
static bool fatt_handler(TMask_field& f, KEY k);
|
1996-11-05 14:24:56 +00:00
|
|
|
|
static bool impeff_notify(TSheet_field& s, int r, KEY key);
|
1997-04-29 13:11:17 +00:00
|
|
|
|
TSheet_field& cess_sheet() const;
|
1996-11-05 14:24:56 +00:00
|
|
|
|
TSheet_field& righe_sheet() const;
|
1996-10-21 14:34:51 +00:00
|
|
|
|
void common_f(const TMask& m);
|
1996-11-05 14:24:56 +00:00
|
|
|
|
static void calcola_totali();
|
1996-10-21 14:34:51 +00:00
|
|
|
|
virtual int read(TMask& m);
|
|
|
|
|
virtual int rewrite(const TMask& m);
|
|
|
|
|
virtual int write(const TMask& m);
|
1996-11-05 14:24:56 +00:00
|
|
|
|
virtual bool remove();
|
1996-10-21 14:34:51 +00:00
|
|
|
|
bool user_create();
|
|
|
|
|
bool user_destroy();
|
1996-11-05 14:24:56 +00:00
|
|
|
|
virtual TMask* get_mask(int mode) {return _msk;}
|
|
|
|
|
virtual bool changing_mask(int mode) {return FALSE;}
|
2001-06-25 10:41:20 +00:00
|
|
|
|
void enable_controeuro();
|
|
|
|
|
|
1996-10-21 14:34:51 +00:00
|
|
|
|
public:
|
2004-04-26 09:49:26 +00:00
|
|
|
|
virtual bool protected_record(TRectype&);
|
1996-10-21 14:34:51 +00:00
|
|
|
|
virtual TRelation* get_relation() const {return _rel;}
|
1996-11-05 14:24:56 +00:00
|
|
|
|
TVariazione_effetti() {};
|
|
|
|
|
virtual ~TVariazione_effetti() {};
|
1996-10-21 14:34:51 +00:00
|
|
|
|
};
|
|
|
|
|
|
1996-11-22 17:17:26 +00:00
|
|
|
|
// restituisce un riferimento all' applicazione
|
1996-11-05 14:24:56 +00:00
|
|
|
|
inline TVariazione_effetti& app() {return (TVariazione_effetti&)main_app();}
|
1996-11-27 14:11:39 +00:00
|
|
|
|
|
2001-06-25 10:41:20 +00:00
|
|
|
|
void TVariazione_effetti::enable_controeuro()
|
|
|
|
|
{
|
|
|
|
|
static int ce = -1;
|
|
|
|
|
if (ce < 0)
|
|
|
|
|
{
|
|
|
|
|
TConfig ini(CONFIG_DITTA, "ve");
|
|
|
|
|
ce = ini.get_bool("CONTROEURO");
|
|
|
|
|
}
|
2002-12-17 12:06:01 +00:00
|
|
|
|
_msk->enable(F_CONTROEURO, ce != 0);
|
2001-06-25 10:41:20 +00:00
|
|
|
|
}
|
|
|
|
|
|
1997-02-18 15:10:08 +00:00
|
|
|
|
// quando si va in query mode resetta i due campi della maschera
|
|
|
|
|
// relativi ai totali
|
1997-04-29 13:11:17 +00:00
|
|
|
|
void TVariazione_effetti::init_query_mode(TMask&)
|
|
|
|
|
{
|
1996-11-05 14:24:56 +00:00
|
|
|
|
_msk->reset(F_TOTIMP);
|
1999-04-06 15:34:39 +00:00
|
|
|
|
_msk->reset(F_TOTIMPVAL);
|
|
|
|
|
_msk->enable(F_TIPOCF);
|
2001-06-25 10:41:20 +00:00
|
|
|
|
enable_controeuro();
|
1997-04-29 13:11:17 +00:00
|
|
|
|
}
|
1996-11-27 14:11:39 +00:00
|
|
|
|
|
2004-04-26 09:49:26 +00:00
|
|
|
|
bool TVariazione_effetti::protected_record(TRectype& rec)
|
|
|
|
|
{
|
|
|
|
|
return rec.get("TIPODIST").not_empty() || rec.get("NDIST").not_empty() || rec.get("NRIGADIST").not_empty();
|
|
|
|
|
}
|
|
|
|
|
|
1997-04-29 13:11:17 +00:00
|
|
|
|
// quando si va in insert mode resetta i due campi della maschera relativi
|
|
|
|
|
// ai totali, inserisce una riga vuota nello sheet e setta il flag dirty
|
|
|
|
|
// dello sheet per forzare l'utente all'inserimento di una riga
|
1996-11-05 14:24:56 +00:00
|
|
|
|
void TVariazione_effetti::init_insert_mode(TMask&)
|
1997-04-29 13:11:17 +00:00
|
|
|
|
{
|
1996-11-05 14:24:56 +00:00
|
|
|
|
_msk->reset(F_TOTIMP);
|
|
|
|
|
_msk->reset(F_TOTIMPVAL);
|
|
|
|
|
TToken_string riga("|||||||||");
|
1996-12-06 15:50:15 +00:00
|
|
|
|
righe_sheet().row(0) = riga;
|
1996-11-05 14:24:56 +00:00
|
|
|
|
righe_sheet().set_dirty();
|
1999-04-06 15:34:39 +00:00
|
|
|
|
_msk->enable(F_TIPOCF);
|
2001-06-25 10:41:20 +00:00
|
|
|
|
enable_controeuro();
|
1996-11-27 14:11:39 +00:00
|
|
|
|
}
|
1997-04-29 13:11:17 +00:00
|
|
|
|
|
2003-11-10 15:01:25 +00:00
|
|
|
|
void TVariazione_effetti::init_modify_mode(TMask& m)
|
1999-04-06 15:34:39 +00:00
|
|
|
|
{
|
2003-11-10 15:01:25 +00:00
|
|
|
|
m.disable(F_TIPOCF);
|
2001-06-25 10:41:20 +00:00
|
|
|
|
enable_controeuro();
|
2003-11-10 15:01:25 +00:00
|
|
|
|
m.efield(F_IBAN_STATO).validate(K_TAB);
|
1999-04-06 15:34:39 +00:00
|
|
|
|
}
|
1999-10-22 10:00:18 +00:00
|
|
|
|
|
1997-04-29 13:11:17 +00:00
|
|
|
|
// ritorna il prossimo numero valido di chiave
|
1998-05-04 10:01:02 +00:00
|
|
|
|
bool TVariazione_effetti::get_next_key(TToken_string& key)
|
1996-10-21 14:34:51 +00:00
|
|
|
|
{
|
1996-12-06 15:50:15 +00:00
|
|
|
|
TLocalisamfile& effetti = _rel->lfile();
|
|
|
|
|
long nprogtr = 1L;
|
1996-11-05 14:24:56 +00:00
|
|
|
|
if ( !effetti.empty() )
|
1996-10-21 14:34:51 +00:00
|
|
|
|
{
|
|
|
|
|
effetti.zero();
|
|
|
|
|
effetti.setkey(1);
|
|
|
|
|
effetti.last();
|
1996-11-05 14:24:56 +00:00
|
|
|
|
if ( effetti.good() )
|
1996-12-06 15:50:15 +00:00
|
|
|
|
nprogtr += effetti.get_long(EFF_NPROGTR);
|
1996-10-21 14:34:51 +00:00
|
|
|
|
}
|
1998-05-04 10:01:02 +00:00
|
|
|
|
key.format("%d|%ld",F_NPROGTR,nprogtr);
|
|
|
|
|
return TRUE;
|
1996-10-21 14:34:51 +00:00
|
|
|
|
}
|
1996-11-27 14:11:39 +00:00
|
|
|
|
|
1996-11-22 17:17:26 +00:00
|
|
|
|
// ritorna un riferimento allo sheet dei cessionari
|
1996-11-05 14:24:56 +00:00
|
|
|
|
TSheet_field& TVariazione_effetti::cess_sheet() const
|
1996-10-21 14:34:51 +00:00
|
|
|
|
{
|
2002-05-08 16:25:49 +00:00
|
|
|
|
return _msk->sfield(F_SHEET_EFF);
|
1996-10-21 14:34:51 +00:00
|
|
|
|
}
|
1996-11-27 14:11:39 +00:00
|
|
|
|
|
1997-04-29 13:11:17 +00:00
|
|
|
|
// ritorna un riferimento allo sheet delle righe
|
1996-11-05 14:24:56 +00:00
|
|
|
|
TSheet_field& TVariazione_effetti::righe_sheet() const
|
1996-10-21 14:34:51 +00:00
|
|
|
|
{
|
2002-05-08 16:25:49 +00:00
|
|
|
|
return _msk->sfield(F_SHEET_RIGHE);
|
1996-10-21 14:34:51 +00:00
|
|
|
|
}
|
1996-11-27 14:11:39 +00:00
|
|
|
|
|
1996-11-22 17:17:26 +00:00
|
|
|
|
// metodo che permette di scivere su file i dati inseriti nella maschera;
|
1997-04-29 13:11:17 +00:00
|
|
|
|
// comune alla write e alla rewrite
|
1996-11-05 14:24:56 +00:00
|
|
|
|
void TVariazione_effetti::common_f(const TMask& m)
|
1996-10-21 14:34:51 +00:00
|
|
|
|
{
|
1999-04-26 15:58:05 +00:00
|
|
|
|
const long nprogtr = m.get_long(F_NPROGTR);
|
1996-10-23 17:18:20 +00:00
|
|
|
|
m.autosave(*_rel);
|
1997-04-29 13:11:17 +00:00
|
|
|
|
_effetto->head() = _rel->curr();
|
1996-11-05 14:24:56 +00:00
|
|
|
|
TSheet_field& shcess = cess_sheet();
|
|
|
|
|
TSheet_field& shrighe = righe_sheet();
|
|
|
|
|
int items = shcess.items();
|
1997-04-29 13:11:17 +00:00
|
|
|
|
_effetto->destroy_rows_c();
|
1996-12-06 15:50:15 +00:00
|
|
|
|
int ii = 1;
|
2006-12-29 14:16:28 +00:00
|
|
|
|
int i;
|
1996-12-06 15:50:15 +00:00
|
|
|
|
// scarico tutte le righe dei cessionari dallo sheet sul file
|
2006-12-29 14:16:28 +00:00
|
|
|
|
for (i = 0; i < items; i++)
|
1997-04-29 13:11:17 +00:00
|
|
|
|
{
|
1996-11-05 14:24:56 +00:00
|
|
|
|
TToken_string& row = shcess.row(i);
|
1996-12-06 15:50:15 +00:00
|
|
|
|
if ( row.items()== 0 ) continue; // salta le righe vuote
|
|
|
|
|
TRectype& rec = _effetto->row_c(ii, TRUE);
|
1997-04-29 13:11:17 +00:00
|
|
|
|
row.restart();
|
1996-11-14 17:36:49 +00:00
|
|
|
|
rec.zero();
|
|
|
|
|
rec.put(CES_NPROGTR, nprogtr);
|
1996-12-06 15:50:15 +00:00
|
|
|
|
rec.put(CES_NRIGA, ii);
|
1996-11-14 17:36:49 +00:00
|
|
|
|
rec.put(CES_RAGSOC, row.get());
|
|
|
|
|
rec.put(CES_LOCALITA, row.get());
|
|
|
|
|
rec.put(CES_STATO, row.get_int());
|
|
|
|
|
rec.put(CES_COM, row.get());
|
|
|
|
|
ii++;
|
1997-04-29 13:11:17 +00:00
|
|
|
|
}
|
1996-11-05 14:24:56 +00:00
|
|
|
|
items = shrighe.items();
|
1997-04-29 13:11:17 +00:00
|
|
|
|
_effetto->destroy_rows_r();
|
|
|
|
|
ii = 1;
|
1996-12-06 15:50:15 +00:00
|
|
|
|
// scarico tutte le righe dell'effetto dallo sheet sul file
|
1996-11-05 14:24:56 +00:00
|
|
|
|
for (i = 0; i < items; i++)
|
1997-04-29 13:11:17 +00:00
|
|
|
|
{
|
|
|
|
|
TToken_string& row = shrighe.row(i);
|
1997-05-02 15:37:37 +00:00
|
|
|
|
real imp_eff(row.get(shrighe.cid2index(F_IMPEFF)));
|
1997-04-29 13:11:17 +00:00
|
|
|
|
if (imp_eff == 0.0) continue; // salta le righe con importo nullo
|
1996-10-21 14:34:51 +00:00
|
|
|
|
row.restart();
|
1996-12-06 15:50:15 +00:00
|
|
|
|
TRectype& rec = _effetto->row_r(ii, TRUE);
|
1997-04-29 16:33:20 +00:00
|
|
|
|
rec.zero();
|
1996-11-05 14:24:56 +00:00
|
|
|
|
rec.put(REFF_NPROGTR, nprogtr);
|
1996-12-06 15:50:15 +00:00
|
|
|
|
rec.put(REFF_NRIGATR, ii);
|
1996-11-05 14:24:56 +00:00
|
|
|
|
rec.put(REFF_IMPORTO, row.get());
|
|
|
|
|
rec.put(REFF_IMPORTOVAL, row.get());
|
1997-02-24 15:40:06 +00:00
|
|
|
|
rec.put(REFF_CODNUM, row.get());
|
1997-04-29 16:33:20 +00:00
|
|
|
|
rec.put(REFF_PROVV, row.get()[0]);
|
1997-02-24 15:40:06 +00:00
|
|
|
|
rec.put(REFF_ANNODOC, row.get_int());
|
1996-11-05 14:24:56 +00:00
|
|
|
|
rec.put(REFF_NFATT, row.get());
|
|
|
|
|
rec.put(REFF_DATAFATT, row.get());
|
1997-04-29 16:33:20 +00:00
|
|
|
|
rec.put(REFF_IMPFATT, row.get());
|
|
|
|
|
rec.put(REFF_IMPFATTVAL, row.get());
|
|
|
|
|
rec.put(REFF_ANNO, row.get_int());
|
|
|
|
|
rec.put(REFF_NUMPART, row.get());
|
|
|
|
|
rec.put(REFF_NRIGA, row.get_int());
|
|
|
|
|
rec.put(REFF_NRATA, row.get_int());
|
1996-11-05 14:24:56 +00:00
|
|
|
|
ii++;
|
1996-10-21 14:34:51 +00:00
|
|
|
|
}
|
1996-11-05 14:24:56 +00:00
|
|
|
|
_effetto->renum(_effetto->numero());
|
1996-10-21 14:34:51 +00:00
|
|
|
|
}
|
1996-11-27 14:11:39 +00:00
|
|
|
|
|
1997-04-29 13:11:17 +00:00
|
|
|
|
// carica nella maschera i dati dai files
|
1996-11-05 14:24:56 +00:00
|
|
|
|
int TVariazione_effetti::read(TMask& m)
|
1996-10-21 14:34:51 +00:00
|
|
|
|
{
|
1996-10-23 17:18:20 +00:00
|
|
|
|
m.autoload(*_rel);
|
1996-11-05 14:24:56 +00:00
|
|
|
|
int err = _rel->status();
|
|
|
|
|
if (err == NOERR)
|
1996-10-21 14:34:51 +00:00
|
|
|
|
{
|
2000-05-05 15:25:49 +00:00
|
|
|
|
TLocalisamfile& f = _rel->lfile(LF_EFFETTI);
|
1997-02-18 15:10:08 +00:00
|
|
|
|
// legge l'effetto dal record corrente della relazione
|
1997-04-29 13:11:17 +00:00
|
|
|
|
err = _effetto->read(f, _rel->curr());
|
1996-11-05 14:24:56 +00:00
|
|
|
|
if (err == NOERR)
|
1997-04-29 13:11:17 +00:00
|
|
|
|
{
|
1996-11-05 14:24:56 +00:00
|
|
|
|
TString16 codcom(3);
|
|
|
|
|
TToken_string riga(80);
|
|
|
|
|
TSheet_field& shcess = cess_sheet();
|
1997-04-29 13:11:17 +00:00
|
|
|
|
shcess.reset();
|
1996-11-05 14:24:56 +00:00
|
|
|
|
TSheet_field& shrighe = righe_sheet();
|
1997-04-29 13:11:17 +00:00
|
|
|
|
shrighe.reset();
|
|
|
|
|
int items = _effetto->rows_c();
|
2006-12-29 14:16:28 +00:00
|
|
|
|
int i;
|
1996-12-06 15:50:15 +00:00
|
|
|
|
// carica tutti i cessionari nello sheet dal file
|
2006-12-29 14:16:28 +00:00
|
|
|
|
for (i = 1; i <= items; i++)
|
1996-11-05 14:24:56 +00:00
|
|
|
|
{
|
|
|
|
|
const TRectype& rec = _effetto->row_c(i);
|
|
|
|
|
riga.cut(0);
|
|
|
|
|
riga.add(rec.get(CES_RAGSOC));
|
|
|
|
|
riga.add(rec.get(CES_LOCALITA));
|
1997-04-29 13:11:17 +00:00
|
|
|
|
// per caricare nello sheet dei cessionari la denominazione
|
1997-02-18 15:10:08 +00:00
|
|
|
|
// del comune di cui si conosce il codice
|
1999-04-06 15:34:39 +00:00
|
|
|
|
codcom = rec.get(CES_STATO);
|
|
|
|
|
codcom << '|' << rec.get(CES_COM);
|
1997-04-29 13:11:17 +00:00
|
|
|
|
riga.add(codcom);
|
1999-04-06 15:34:39 +00:00
|
|
|
|
|
|
|
|
|
const TRectype& com = cache().get(LF_COMUNI, codcom);
|
|
|
|
|
riga.add(com.get(COM_DENCOM));
|
|
|
|
|
|
1996-11-05 14:24:56 +00:00
|
|
|
|
shcess.row(i-1)=riga;
|
1997-04-29 13:11:17 +00:00
|
|
|
|
}
|
|
|
|
|
items = _effetto->rows_r();
|
1996-12-06 15:50:15 +00:00
|
|
|
|
// carica tutte le righe dell'effetto nello sheet dal file
|
1997-05-21 10:55:09 +00:00
|
|
|
|
// TEdit_field & e = (TEdit_field &) shrighe.sheet_mask().field(F_NUMFATT);
|
|
|
|
|
// CheckType c = e.check_type();
|
|
|
|
|
|
|
|
|
|
// e.check_type(CHECK_REQUIRED);
|
1996-11-05 14:24:56 +00:00
|
|
|
|
for (i = 1; i <= items; i++)
|
|
|
|
|
{
|
|
|
|
|
const TRectype& rec = _effetto->row_r(i);
|
|
|
|
|
riga.cut(0);
|
|
|
|
|
riga.add(rec.get(REFF_IMPORTO));
|
|
|
|
|
riga.add(rec.get(REFF_IMPORTOVAL));
|
1997-04-29 16:33:20 +00:00
|
|
|
|
riga.add(rec.get(REFF_CODNUM));
|
1997-05-02 15:37:37 +00:00
|
|
|
|
riga.add(rec.get(REFF_PROVV));
|
1997-02-24 15:40:06 +00:00
|
|
|
|
riga.add(rec.get(REFF_ANNODOC));
|
1996-11-05 14:24:56 +00:00
|
|
|
|
riga.add(rec.get(REFF_NFATT));
|
|
|
|
|
riga.add(rec.get(REFF_DATAFATT));
|
1997-04-29 16:33:20 +00:00
|
|
|
|
riga.add(rec.get(REFF_IMPFATT));
|
|
|
|
|
riga.add(rec.get(REFF_IMPFATTVAL));
|
|
|
|
|
riga.add(rec.get(REFF_ANNO));
|
|
|
|
|
riga.add(rec.get(REFF_NUMPART));
|
|
|
|
|
riga.add(rec.get(REFF_NRIGA));
|
|
|
|
|
riga.add(rec.get(REFF_NRATA));
|
1997-05-21 10:55:09 +00:00
|
|
|
|
shrighe.row(i - 1) = riga;
|
|
|
|
|
shrighe.check_row(i - 1);
|
1996-11-05 14:24:56 +00:00
|
|
|
|
}
|
1997-05-21 10:55:09 +00:00
|
|
|
|
// e.check_type(c);
|
1996-11-05 14:24:56 +00:00
|
|
|
|
}
|
1996-10-21 14:34:51 +00:00
|
|
|
|
}
|
1996-11-05 14:24:56 +00:00
|
|
|
|
return err;
|
1996-10-21 14:34:51 +00:00
|
|
|
|
}
|
1996-11-27 14:11:39 +00:00
|
|
|
|
|
1996-12-06 15:50:15 +00:00
|
|
|
|
// riscrive effetto
|
1996-11-05 14:24:56 +00:00
|
|
|
|
int TVariazione_effetti::rewrite(const TMask& m)
|
1996-10-21 14:34:51 +00:00
|
|
|
|
{
|
1997-04-29 13:11:17 +00:00
|
|
|
|
common_f(m);// scarica i dati dalla maschera
|
2000-05-05 15:25:49 +00:00
|
|
|
|
TLocalisamfile& f = _rel->lfile(LF_EFFETTI);
|
1996-11-22 17:17:26 +00:00
|
|
|
|
return _effetto->rewrite(f);
|
1996-10-21 14:34:51 +00:00
|
|
|
|
}
|
1996-11-27 14:11:39 +00:00
|
|
|
|
|
1996-11-22 17:17:26 +00:00
|
|
|
|
// scrive i dati su file
|
1996-11-05 14:24:56 +00:00
|
|
|
|
int TVariazione_effetti::write(const TMask& m)
|
1996-10-21 14:34:51 +00:00
|
|
|
|
{
|
1997-04-29 13:11:17 +00:00
|
|
|
|
common_f(m);// scarica i dati dalla maschera
|
2000-05-05 15:25:49 +00:00
|
|
|
|
TLocalisamfile& f = _rel->lfile(LF_EFFETTI);
|
1996-11-22 17:17:26 +00:00
|
|
|
|
int err = _effetto->write(f);
|
1997-04-29 13:11:17 +00:00
|
|
|
|
if (err == NOERR)
|
1996-11-22 17:17:26 +00:00
|
|
|
|
_rel->read();// rilegge per posizionare correttamente la relazione
|
1996-11-05 14:24:56 +00:00
|
|
|
|
return err;
|
|
|
|
|
}
|
1996-11-27 14:11:39 +00:00
|
|
|
|
|
1997-04-29 13:11:17 +00:00
|
|
|
|
// rimuove l'effetto
|
|
|
|
|
bool TVariazione_effetti::remove()
|
|
|
|
|
{
|
2000-05-05 15:25:49 +00:00
|
|
|
|
TLocalisamfile& f = _rel->lfile(LF_EFFETTI);
|
|
|
|
|
int err = _effetto->remove(f);
|
|
|
|
|
return err == NOERR;
|
1996-10-21 14:34:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
1996-12-06 15:50:15 +00:00
|
|
|
|
// crea la relap
|
1996-11-05 14:24:56 +00:00
|
|
|
|
bool TVariazione_effetti::user_create()
|
1999-04-06 15:34:39 +00:00
|
|
|
|
{
|
|
|
|
|
open_files(LF_TAB, LF_TABCOM, LF_EFFETTI, LF_REFFETTI, LF_CESS,
|
|
|
|
|
LF_COMUNI, LF_DOC, LF_RIGHEDOC,
|
|
|
|
|
LF_CLIFO, LF_CFVEN, LF_OCCAS, 0);
|
1997-04-29 13:11:17 +00:00
|
|
|
|
_rel = new TRelation(LF_EFFETTI);
|
|
|
|
|
_effetto = new TEffetto;
|
2003-11-10 15:01:25 +00:00
|
|
|
|
_msk = new TMask("ef0100a") ;
|
|
|
|
|
_msk->set_handler(F_CODCF, clifo_handler);
|
2002-05-08 16:25:49 +00:00
|
|
|
|
_msk->set_handler(F_DATASCAD, datascad_handler);
|
1997-04-29 13:11:17 +00:00
|
|
|
|
_msk->set_handler(F_CODVAL, codval_handler);
|
2000-10-03 13:45:12 +00:00
|
|
|
|
_msk->set_handler(F_CAMBIO, cambio_handler);
|
1997-05-05 10:38:42 +00:00
|
|
|
|
_msk->set_handler(F_EFFCONT, contab_handler);
|
1996-11-05 14:24:56 +00:00
|
|
|
|
_msk->set_handler(F_SHEET_RIGHE, handle_sheet);
|
1997-03-25 16:05:38 +00:00
|
|
|
|
righe_sheet().set_append(TRUE);
|
1996-11-05 14:24:56 +00:00
|
|
|
|
righe_sheet().set_notify(impeff_notify);
|
2002-05-08 16:25:49 +00:00
|
|
|
|
_msk->sfield(F_SHEET_RIGHE).sheet_mask().set_handler(F_NUMFATT, fatt_handler);
|
1996-10-21 14:34:51 +00:00
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
1996-11-27 14:11:39 +00:00
|
|
|
|
|
1996-12-06 15:50:15 +00:00
|
|
|
|
// distrugge la relap
|
1996-11-05 14:24:56 +00:00
|
|
|
|
bool TVariazione_effetti::user_destroy()
|
1996-10-21 14:34:51 +00:00
|
|
|
|
{
|
|
|
|
|
delete _msk;
|
1996-11-05 14:24:56 +00:00
|
|
|
|
delete _effetto;
|
2003-11-10 15:01:25 +00:00
|
|
|
|
delete _rel;
|
1996-10-21 14:34:51 +00:00
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
1996-11-27 14:11:39 +00:00
|
|
|
|
|
1997-02-18 15:10:08 +00:00
|
|
|
|
// handler che permette di effettuare il controllo sul fatto
|
|
|
|
|
// che venga inserita almeno una riga per un effetto
|
1996-11-05 14:24:56 +00:00
|
|
|
|
bool TVariazione_effetti::handle_sheet(TMask_field &f, KEY k)
|
1996-10-21 14:34:51 +00:00
|
|
|
|
{
|
2003-11-10 15:01:25 +00:00
|
|
|
|
TMask& m = f.mask();
|
|
|
|
|
const int mode = m.mode();
|
1997-04-29 13:11:17 +00:00
|
|
|
|
// se si vuole salvare e si <20> in uno dei due modi di funzionamento
|
|
|
|
|
if ( k == K_ENTER && (mode == MODE_INS || mode == MODE_MOD) )
|
|
|
|
|
{ // si controllano le righe del effetto nello sheet
|
2002-05-08 16:25:49 +00:00
|
|
|
|
TSheet_field& sf = m.sfield(F_SHEET_RIGHE);
|
1996-11-05 14:24:56 +00:00
|
|
|
|
int items = sf.items();
|
1996-12-06 15:50:15 +00:00
|
|
|
|
bool found = FALSE;
|
|
|
|
|
for (int i = 0; i < items && !found; i++)// scandisco tutte le righe dello sheet
|
1997-04-29 13:11:17 +00:00
|
|
|
|
{
|
1996-12-06 15:50:15 +00:00
|
|
|
|
TToken_string& row = sf.row(i);
|
1997-05-02 15:37:37 +00:00
|
|
|
|
real imp_eff(row.get(sf.cid2index(F_IMPEFF)));
|
1997-04-29 13:11:17 +00:00
|
|
|
|
// controlla che le righe abbiano un importo
|
1997-02-18 15:10:08 +00:00
|
|
|
|
if (imp_eff != 0.0) found = TRUE;
|
1996-10-21 14:34:51 +00:00
|
|
|
|
}
|
1997-02-18 15:10:08 +00:00
|
|
|
|
// se non ha trovato righe nello sheet oppure se quelle che ci sono non
|
|
|
|
|
// hanno importo
|
|
|
|
|
if (!found)
|
|
|
|
|
{ // non permetto di salvare l'effetto
|
2003-05-19 14:15:13 +00:00
|
|
|
|
error_box(TR("L'effetto non pu<70> contenere righe con importo nullo!"));
|
1996-11-05 14:24:56 +00:00
|
|
|
|
return FALSE;
|
1996-10-21 14:34:51 +00:00
|
|
|
|
}
|
1997-04-29 13:11:17 +00:00
|
|
|
|
}
|
1996-10-21 14:34:51 +00:00
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
1996-11-27 14:11:39 +00:00
|
|
|
|
|
2003-11-10 15:01:25 +00:00
|
|
|
|
bool TVariazione_effetti::clifo_handler(TMask_field& f, KEY k)
|
|
|
|
|
{
|
|
|
|
|
if (k == K_TAB && f.to_check(k))
|
|
|
|
|
{
|
|
|
|
|
TMask& m = f.mask();
|
|
|
|
|
TString8 str;
|
|
|
|
|
str << m.get(F_TIPOCF) << '|' << m.get(F_CODCF);
|
|
|
|
|
const TString& iban = cache().get(LF_CFVEN, str, "IBAN");
|
|
|
|
|
if (iban.not_empty())
|
|
|
|
|
{
|
|
|
|
|
m.set(F_IBAN, iban);
|
|
|
|
|
m.set(F_IBAN_STATO, iban.left(2));
|
|
|
|
|
m.set(F_IBAN_CHECK, iban.mid(2,2));
|
|
|
|
|
m.set(F_BBAN, iban.mid(4));
|
|
|
|
|
m.set(F_BBAN_CIN, iban.mid(4,1));
|
|
|
|
|
m.set(F_BBAN_ABI, iban.mid(5,5));
|
|
|
|
|
m.set(F_BBAN_CAB, iban.mid(10,5));
|
|
|
|
|
m.set(F_BBAN_CONTO, iban.mid(15));
|
|
|
|
|
m.efield(F_IBAN_STATO).validate(K_TAB);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2002-05-08 16:25:49 +00:00
|
|
|
|
bool TVariazione_effetti::datascad_handler(TMask_field& f, KEY k)
|
|
|
|
|
{
|
|
|
|
|
if (k == K_ENTER)
|
|
|
|
|
{
|
|
|
|
|
const TDate datascad = f.get();
|
|
|
|
|
TSheet_field& sf = f.mask().sfield(F_SHEET_RIGHE);
|
|
|
|
|
FOR_EACH_SHEET_ROW(sf, r, row)
|
|
|
|
|
{
|
|
|
|
|
TDate datafat = row->get(F_DATAFATT-FIRST_FIELD);
|
|
|
|
|
if (datascad < datafat)
|
2003-05-19 14:15:13 +00:00
|
|
|
|
return f.error_box(FR("La data fattura della riga %d <20> successiva alla data di scadenza"), r+1);
|
2002-05-08 16:25:49 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
1997-04-29 13:11:17 +00:00
|
|
|
|
// handler che permette il controllo sulla abilitazione dei campi collegati
|
1996-11-22 17:17:26 +00:00
|
|
|
|
// al codice valuta
|
1996-11-05 14:24:56 +00:00
|
|
|
|
bool TVariazione_effetti::codval_handler(TMask_field& f, KEY k)
|
1997-04-29 13:11:17 +00:00
|
|
|
|
{
|
2000-10-03 13:45:12 +00:00
|
|
|
|
if (f.to_check(k, TRUE))
|
1996-11-05 14:24:56 +00:00
|
|
|
|
{
|
2002-05-08 16:25:49 +00:00
|
|
|
|
TMask& m = f.mask();
|
|
|
|
|
const TString& val = f.get();
|
|
|
|
|
// se non c'e valuta o se <20> lire disabilitato i campi collegati
|
2000-10-03 13:45:12 +00:00
|
|
|
|
const bool valuta = (val.not_empty() && val != TCurrency::get_firm_val());
|
1997-05-05 10:38:42 +00:00
|
|
|
|
m.enable(-1,valuta);
|
2002-05-08 16:25:49 +00:00
|
|
|
|
TSheet_field& sf = m.sfield(F_SHEET_RIGHE);
|
1997-05-05 10:38:42 +00:00
|
|
|
|
if (!valuta)
|
1997-04-29 13:11:17 +00:00
|
|
|
|
{
|
1996-11-05 14:24:56 +00:00
|
|
|
|
m.reset(-1);
|
|
|
|
|
m.reset(F_TOTIMPVAL);
|
1997-05-05 10:38:42 +00:00
|
|
|
|
for (int i = sf.items() - 1; i >= 0; i--)
|
1996-11-22 17:17:26 +00:00
|
|
|
|
{
|
1997-04-29 13:11:17 +00:00
|
|
|
|
TToken_string& row = sf.row(i);
|
1997-05-05 10:38:42 +00:00
|
|
|
|
row.add(" ", sf.cid2index(F_IMPEFFVAL));
|
|
|
|
|
row.add(" ", sf.cid2index(F_IMPFATTVAL));
|
1997-04-29 13:11:17 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
1997-05-05 10:38:42 +00:00
|
|
|
|
sf.enable_column(F_IMPEFFVAL, valuta);
|
1997-05-12 15:31:33 +00:00
|
|
|
|
if (f.focusdirty())
|
|
|
|
|
sf.force_update();
|
1997-04-29 13:11:17 +00:00
|
|
|
|
}
|
1996-11-05 14:24:56 +00:00
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
1996-11-27 14:11:39 +00:00
|
|
|
|
|
2000-10-03 13:45:12 +00:00
|
|
|
|
// handler che gestisce la modifica del cambio
|
|
|
|
|
bool TVariazione_effetti::cambio_handler(TMask_field& f, KEY k)
|
|
|
|
|
{
|
|
|
|
|
TMask &m = f.mask();
|
|
|
|
|
//if (k == K_TAB && f.to_check(k, TRUE))
|
|
|
|
|
if (k == K_TAB && f.focusdirty())
|
|
|
|
|
{
|
|
|
|
|
const real cambio = f.get();
|
|
|
|
|
const TString& valuta = m.get(F_CODVAL);
|
2002-05-08 16:25:49 +00:00
|
|
|
|
TSheet_field& sf = m.sfield(F_SHEET_RIGHE);
|
2000-10-03 13:45:12 +00:00
|
|
|
|
int items = sf.items();
|
|
|
|
|
real imp, impval;
|
|
|
|
|
// scandisco tutte le righe dello sheet e modifico gli importi in lire
|
|
|
|
|
for (int i = 0; i < items; i++)
|
|
|
|
|
{
|
|
|
|
|
TToken_string& row = sf.row(i);
|
|
|
|
|
impval = row.get(sf.cid2index(F_IMPEFFVAL));
|
|
|
|
|
TCurrency val(impval, valuta, cambio);
|
|
|
|
|
val.change_to_firm_val();
|
|
|
|
|
imp = val.get_num();
|
|
|
|
|
row.add(imp.string(), sf.cid2index(F_IMPEFF));
|
|
|
|
|
}
|
|
|
|
|
if (f.focusdirty())
|
|
|
|
|
sf.force_update();
|
|
|
|
|
}
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
1997-05-21 10:55:09 +00:00
|
|
|
|
// handler che permette il controllo sulla abilitazione dei campi collegati
|
|
|
|
|
// al codice valuta
|
|
|
|
|
bool TVariazione_effetti::fatt_handler(TMask_field& f, KEY k)
|
|
|
|
|
{
|
|
|
|
|
TMask &m = f.mask();
|
|
|
|
|
if (k == K_TAB && f.focusdirty() || !app().get_mask(MODE_MOD)->is_running())
|
|
|
|
|
{
|
|
|
|
|
TEdit_field & e = (TEdit_field &) f;
|
|
|
|
|
CheckType c = e.check_type();
|
|
|
|
|
|
|
|
|
|
e.check_type(CHECK_REQUIRED);
|
|
|
|
|
const bool ok = e.check();
|
|
|
|
|
e.check_type(c);
|
|
|
|
|
m.enable(F_DATAFATT, !ok);
|
|
|
|
|
m.enable(F_IMPFATT, !ok);
|
|
|
|
|
m.enable(F_IMPFATTVAL, !ok && app().get_mask(MODE_MOD)->get(F_CODVAL).not_empty());
|
|
|
|
|
if (app().get_mask(MODE_MOD)->is_running() && ok && k == K_TAB && f.focusdirty())
|
|
|
|
|
{
|
1999-10-22 10:00:18 +00:00
|
|
|
|
const TDocumento d(e.browse()->cursor()->curr());
|
1997-05-21 10:55:09 +00:00
|
|
|
|
m.set(F_DATAFATT, d.get("DATADOC"));
|
|
|
|
|
const real imp = d.totale_doc();
|
|
|
|
|
if (d.in_valuta())
|
|
|
|
|
{
|
1999-10-22 10:00:18 +00:00
|
|
|
|
const TString16 codval = d.get(DOC_CODVAL);
|
|
|
|
|
TCurrency val(imp, codval, d.get_real(DOC_CAMBIO));
|
|
|
|
|
val.change_to_firm_val();
|
|
|
|
|
const real& lit = val.get_num();
|
|
|
|
|
|
1997-05-21 10:55:09 +00:00
|
|
|
|
m.set(F_IMPFATT, lit);
|
|
|
|
|
m.set(F_IMPFATTVAL, imp);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
m.set(F_IMPFATT, imp);
|
|
|
|
|
m.reset(F_IMPFATTVAL);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
1997-05-05 10:38:42 +00:00
|
|
|
|
bool TVariazione_effetti::contab_handler(TMask_field& f, KEY k)
|
|
|
|
|
{
|
|
|
|
|
if (k == K_SPACE)
|
|
|
|
|
{
|
|
|
|
|
TMask &m = f.mask();
|
|
|
|
|
const bool da_contab = f.get().empty();
|
2002-05-08 16:25:49 +00:00
|
|
|
|
TSheet_field& sf = m.sfield(F_SHEET_RIGHE);
|
1997-05-05 10:38:42 +00:00
|
|
|
|
sf.enable_column(F_ANNO, da_contab);
|
|
|
|
|
sf.enable_column(F_NUMPART, da_contab);
|
1999-07-16 14:59:11 +00:00
|
|
|
|
sf.force_update();
|
1997-05-05 10:38:42 +00:00
|
|
|
|
}
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
1997-02-18 15:10:08 +00:00
|
|
|
|
// funzione chiamata dal notify dello sheet per effettuare il calcolo degli
|
|
|
|
|
// importi totali (in lire ed in valuta) dell'effetto
|
1996-11-05 14:24:56 +00:00
|
|
|
|
void TVariazione_effetti::calcola_totali()
|
1997-04-29 13:11:17 +00:00
|
|
|
|
{
|
1996-11-05 14:24:56 +00:00
|
|
|
|
TMask* m = app()._msk;
|
2002-05-08 16:25:49 +00:00
|
|
|
|
TSheet_field& sf = m->sfield(F_SHEET_RIGHE);
|
1997-04-29 13:11:17 +00:00
|
|
|
|
int items = sf.items();
|
|
|
|
|
real imp, impval, impeff, impeffval;
|
1997-02-18 15:10:08 +00:00
|
|
|
|
// scandisco tutte le righe dello sheet e ne prendo gli importi
|
|
|
|
|
// (in lire ed in valuta) e li sommo al totale
|
|
|
|
|
for (int i = 0; i < items; i++)
|
1997-04-29 13:11:17 +00:00
|
|
|
|
{
|
1999-07-16 14:59:11 +00:00
|
|
|
|
TToken_string& row = sf.row(i);
|
|
|
|
|
imp = row.get(sf.cid2index(F_IMPEFF));
|
|
|
|
|
impeff += imp;
|
|
|
|
|
impval = row.get(sf.cid2index(F_IMPEFFVAL));
|
|
|
|
|
impeffval += impval;
|
1996-11-05 14:24:56 +00:00
|
|
|
|
}
|
|
|
|
|
m->set(F_TOTIMP, impeff);
|
1997-04-29 13:11:17 +00:00
|
|
|
|
m->set(F_TOTIMPVAL, impeffval);
|
|
|
|
|
}
|
1996-11-27 14:11:39 +00:00
|
|
|
|
|
1997-02-18 15:10:08 +00:00
|
|
|
|
// notify per il calcolo dei totali dell'effetto e per il controllo che non
|
|
|
|
|
// vengano eliminate tutte le righe dell'effetto, almeno una deve rimanere
|
1996-11-05 14:24:56 +00:00
|
|
|
|
bool TVariazione_effetti::impeff_notify(TSheet_field& s, int r, KEY key)
|
1997-04-29 13:11:17 +00:00
|
|
|
|
{
|
|
|
|
|
if (s.to_check(key, TRUE))
|
1997-02-24 15:40:06 +00:00
|
|
|
|
{
|
1999-07-16 14:59:11 +00:00
|
|
|
|
calcola_totali();
|
1997-04-29 13:11:17 +00:00
|
|
|
|
}
|
1997-02-18 15:10:08 +00:00
|
|
|
|
//se rimane una sola riga nello sheet non la si pu<70> cancellare
|
|
|
|
|
if (key == K_DEL && s.items() == 1)
|
2003-05-19 14:15:13 +00:00
|
|
|
|
return s.error_box(TR("IMPOSSIBILE CANCELLARE: L'effetto deve contenere almeno una riga!"));
|
1996-10-21 14:34:51 +00:00
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int ef0100(int argc, char* argv[])
|
|
|
|
|
{
|
1996-11-05 14:24:56 +00:00
|
|
|
|
TVariazione_effetti a ;
|
2003-05-19 14:15:13 +00:00
|
|
|
|
a.run(argc, argv, TR("Effetti"));
|
1996-10-21 14:34:51 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|