Patch level : 10.0

Files correlati     : fe0.exe fetbcon.msk
Ricompilazione Demo : [ ]
Commento            :


git-svn-id: svn://10.65.10.50/branches/R_10_00@22347 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 2011-06-29 08:39:08 +00:00
parent 5c556f4fea
commit f2b9e296c9
3 changed files with 49 additions and 115 deletions

View File

@ -26,75 +26,33 @@
// Data limite da cui si cominciano a dichiarare anche gli scontrini // Data limite da cui si cominciano a dichiarare anche gli scontrini
const TDate data_limite_scontrini(1,7,2011); const TDate data_limite_scontrini(1,7,2011);
///////////////////////////////////////////////////////////
// Utilities
///////////////////////////////////////////////////////////
// Classe per estrarre il codice attività di un movimento di prima nota
class TAttivita_cache : public TAssoc_array
{
public:
const TString& mov2att(const TRectype& mov);
const TString& att2ateco(const TString& att) const;
} _att_cache;
const TString& TAttivita_cache::mov2att(const TRectype& mov)
{
const TString& reg = mov.get(MOV_REG);
if (reg.blank())
return EMPTY_STRING;
TString8 key;
key << mov.get(MOV_ANNOIVA) << reg;
TString* codatt = (TString*)objptr(key);
if (codatt == NULL)
{
codatt = new TString8(cache().get("REG", key, "S8"));
add(key, codatt);
}
return *codatt;
}
const TString& TAttivita_cache::att2ateco(const TString& att) const
{
TToken_string key;
key.add(prefix().get_codditta());
key.add(att);
const TRectype& attiv = cache().get(LF_ATTIV, key);
if (!attiv.empty() && attiv.exist(ATT_CODATECO)) // Non e' detto che il campo esista sempre
return attiv.get(ATT_CODATECO);
return att;
}
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
// Utility // Utility
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
static bool comune_di(const TString& codcom, TString& den, TString& prov) static const TString& comune_di(const TString& codcom)
{ {
if (codcom.blank() || codcom.len() != 4) if (codcom.blank() || codcom.len() != 4)
return false; return EMPTY_STRING;
TString8 key; key << " |" << codcom; TString8 key; key << " |" << codcom;
const TRectype& rec = cache().get(LF_COMUNI, key); TString& den = get_tmp_string();
if (rec.empty()) den = cache().get(LF_COMUNI, key, COM_DENCOM);
{ den.cut(40);
den = prov = ""; den.upper();
}
else return den;
{
den = rec.get(COM_DENCOM); den.cut(40);
den.upper();
prov = rec.get(COM_PROVCOM);
prov.upper();
if (codcom[0] == 'Z' && prov.blank())
prov = "EE";
}
return den.not_empty();
} }
static const TString& provincia_di(const TString& codcom)
{
if (codcom.blank() || codcom.len() != 4)
return EMPTY_STRING;
TString8 key; key << '|' << codcom;
return cache().get(LF_COMUNI, key, COM_PROVCOM);
}
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
// TAnagrafica // TAnagrafica
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
@ -104,8 +62,7 @@ class TAnagrafica : public TObject
char _tipo; // F o G char _tipo; // F o G
TString16 _cofi, _paiv; TString16 _cofi, _paiv;
TString80 _key, _ragsoc; TString80 _key, _ragsoc;
TString80 _com_nasc, _com_res; TString4 _com_nasc, _com_res;
TString4 _prov_nasc, _prov_res;
TDate _data_nasc; TDate _data_nasc;
TAnagrafica(const TAnagrafica&) { CHECK(false, "Can't copy TAnagrafica"); } TAnagrafica(const TAnagrafica&) { CHECK(false, "Can't copy TAnagrafica"); }
@ -125,10 +82,10 @@ public:
char sesso() const { return (_cofi[9] >= '4') ? 'F' : 'M'; } char sesso() const { return (_cofi[9] >= '4') ? 'F' : 'M'; }
const TDate& data_nascita() const { return _data_nasc; } const TDate& data_nascita() const { return _data_nasc; }
const TString& comune_nascita() const { return _com_nasc; } const TString& comune_nascita() const { return comune_di(_com_nasc); }
const TString& provincia_nascita() const { return _prov_nasc; } const TString& provincia_nascita() const { return provincia_di(_com_nasc); }
const TString& comune_residenza() const { return _com_res; } const TString& comune_residenza() const { return comune_di(_com_res); }
const TString& provincia_residenza() const { return _prov_res; } const TString& provincia_residenza() const { return provincia_di(_com_res); }
bool init(const TRectype& rec); bool init(const TRectype& rec);
bool init(int num, const char* codice) { return init(cache().get(num, codice)); } bool init(int num, const char* codice) { return init(cache().get(num, codice)); }
@ -166,8 +123,8 @@ bool TAnagrafica::init(const TRectype& rec)
} }
_ragsoc = rec.get(OCC_RAGSOC); _ragsoc.upper(); _ragsoc = rec.get(OCC_RAGSOC); _ragsoc.upper();
_data_nasc = rec.get(OCC_DNASC); _data_nasc = rec.get(OCC_DNASC);
comune_di(rec.get(OCC_COMNASC), _com_nasc, _prov_nasc); _com_nasc = rec.get(OCC_COMNASC);
comune_di(rec.get(OCC_COM), _com_res, _prov_res); _com_res = rec.get(OCC_COM);
break; break;
case LF_ANAG: case LF_ANAG:
_tipo = rec.get_char(ANA_TIPOA); _tipo = rec.get_char(ANA_TIPOA);
@ -176,15 +133,16 @@ bool TAnagrafica::init(const TRectype& rec)
_paiv = rec.get(ANA_PAIV); _paiv = rec.get(ANA_PAIV);
// Comune di residenza fiscale o domicilio // Comune di residenza fiscale o domicilio
if (!comune_di(rec.get(ANA_COMRF), _com_res, _prov_res)) _com_res = rec.get(ANA_COMRF);
comune_di(rec.get(ANA_COMRES), _com_res, _prov_res); if (_com_res.empty())
_com_res = rec.get(ANA_COMRES);
// Dati di nascita persone fisiche // Dati di nascita persone fisiche
if (_tipo == 'F') if (_tipo == 'F')
{ {
const TRectype& anafis = cache().get(LF_ANAGFIS, rec.get_long(ANA_CODANAGR)); const TRectype& anafis = cache().get(LF_ANAGFIS, rec.get_long(ANA_CODANAGR));
_data_nasc = anafis.get(ANF_DATANASC); _data_nasc = anafis.get(ANF_DATANASC);
comune_di(rec.get(ANF_COMNASC), _com_nasc, _prov_nasc); _com_nasc = rec.get(ANF_COMNASC);
} }
break; break;
case LF_NDITTE: case LF_NDITTE:
@ -410,7 +368,6 @@ void TDati_rilevanti_trc::create_fields(int tipo, TAS400_recordset& recset)
class TDati_rilevanti_set : public TAS400_recordset class TDati_rilevanti_set : public TAS400_recordset
{ {
int _anno; int _anno;
TString8 _codatt;
protected: protected:
virtual bool set_field(const TAS400_column_info& fi, const TVariant& var); virtual bool set_field(const TAS400_column_info& fi, const TVariant& var);
@ -423,7 +380,7 @@ public:
void set(unsigned int n, const real& v) { TAS400_recordset::set(n-1, v.integer()); } void set(unsigned int n, const real& v) { TAS400_recordset::set(n-1, v.integer()); }
void set(unsigned int n, const TDate& v) { TAS400_recordset::set(n-1, TVariant(v)); } void set(unsigned int n, const TDate& v) { TAS400_recordset::set(n-1, TVariant(v)); }
void add_control_rec(int zero_o_nove); void add_control_rec(int zero_o_nove);
TDati_rilevanti_set(int anno, const TString& codatt); TDati_rilevanti_set(int anno);
}; };
bool TDati_rilevanti_set::set_field(const TAS400_column_info& fi, const TVariant& var) bool TDati_rilevanti_set::set_field(const TAS400_column_info& fi, const TVariant& var)
@ -469,9 +426,8 @@ void TDati_rilevanti_set::add_control_rec(int zon)
set(17, _anno); set(17, _anno);
} }
TDati_rilevanti_set::TDati_rilevanti_set(int anno, const TString& codatt) TDati_rilevanti_set::TDati_rilevanti_set(int anno)
: TAS400_recordset("AS400(1800,1)"), : TAS400_recordset("AS400(1800,1)"), _anno(anno)
_anno(anno), _codatt(codatt)
{ {
TDati_rilevanti_trc trc; TDati_rilevanti_trc trc;
for (int i = 0; i <= 5; i++) for (int i = 0; i <= 5; i++)
@ -499,7 +455,6 @@ protected:
void set_dirty(bool d = true); void set_dirty(bool d = true);
protected: protected:
const TString& mov2att(const TRectype& mov) const { return _att_cache.mov2att(mov); }
TRecnotype last_user_progr() const; TRecnotype last_user_progr() const;
TRecnotype nuovo_progr() const; TRecnotype nuovo_progr() const;
bool check_rows(bool show_error); bool check_rows(bool show_error);
@ -550,11 +505,8 @@ bool TDati_rilevanti_msk::convalida_clifo(const TRectype& mov, TLog_report& log)
const TRectype& rec_clifo = cache().get(LF_CLIFO, key); const TRectype& rec_clifo = cache().get(LF_CLIFO, key);
stato = rec_clifo.get(CLI_STATOCF); stato = rec_clifo.get(CLI_STATOCF);
const int alleg = rec_clifo.get_int(CLI_ALLEG);
if (alleg == 1)
return ignora_movimento(mov, TR("Soggetto escluso da comunicazione (Stato, Regioni, Province,...)"), log);
// tutti i fornitori esteri vanno esclusi (importazioni) // tutti i fornitori esteri vanno esclusi (importazioni)
const int alleg = rec_clifo.get_int(CLI_ALLEG);
if (tipocf == 'F' && alleg == 5) if (tipocf == 'F' && alleg == 5)
return ignora_movimento(mov, TR("Importazione da fornitore estero"), log); return ignora_movimento(mov, TR("Importazione da fornitore estero"), log);
} }
@ -618,7 +570,6 @@ bool TDati_rilevanti_msk::salva_allegato(const TRectype& mov, TFast_isamfile& fa
falleg.zero(); falleg.zero();
TRectype& alleg = falleg.curr(); TRectype& alleg = falleg.curr();
alleg.put(ALL_ANNO, mov.get(MOV_ANNOIVA)); alleg.put(ALL_ANNO, mov.get(MOV_ANNOIVA));
alleg.put(ALL_CODATT, mov2att(mov));
alleg.put(ALL_PROGR, progr); alleg.put(ALL_PROGR, progr);
TString80 contratto = mov.get(MOV_CONTRATTO); TString80 contratto = mov.get(MOV_CONTRATTO);
@ -821,14 +772,12 @@ bool TDati_rilevanti_msk::elabora_movimento(const TRectype& mov, TFast_isamfile&
bool TDati_rilevanti_msk::azzera_alleg(bool manual, TRecnotype first) const bool TDati_rilevanti_msk::azzera_alleg(bool manual, TRecnotype first) const
{ {
const int anno = get_int(F_ANNO); const int anno = get_int(F_ANNO);
const TString& codatt = get(F_CODATT);
TFast_isamfile falleg(LF_ALLEG); TFast_isamfile falleg(LF_ALLEG);
// Azzeramento anno/attività selezionati // Azzeramento anno/attività selezionati
TString limit; TString limit;
limit << ALL_ANNO << '=' << anno << ' ' limit << ALL_ANNO << '=' << anno << ' '
<< ALL_CODATT << '=' << codatt
<< ' ' << ALL_PROGR << '='; << ' ' << ALL_PROGR << '=';
TRecnotype daprog = manual ? MANUAL_ROW : first; TRecnotype daprog = manual ? MANUAL_ROW : first;
@ -847,7 +796,7 @@ bool TDati_rilevanti_msk::azzera_alleg(bool manual, TRecnotype first) const
const TRecnotype items = alleg.items(); const TRecnotype items = alleg.items();
TString str_pi; TString str_pi;
str_pi << TR("Compattazione dati rilevanti ") << anno << TR(" attività ") << codatt; str_pi << TR("Compattazione dati rilevanti ") << anno;
TProgind pi(items, str_pi); TProgind pi(items, str_pi);
const TRectype& rec = alleg.cursor()->curr(); const TRectype& rec = alleg.cursor()->curr();
@ -866,12 +815,10 @@ bool TDati_rilevanti_msk::azzera_alleg(bool manual, TRecnotype first) const
TRecnotype TDati_rilevanti_msk::last_user_progr() const TRecnotype TDati_rilevanti_msk::last_user_progr() const
{ {
const int anno = get_int(F_ANNO); const int anno = get_int(F_ANNO);
const TString& codatt = get(F_CODATT);
TString limit; TString limit;
limit << ALL_ANNO << '=' << anno << ' ' limit << ALL_ANNO << '=' << anno << ' '
<< ALL_CODATT << '=' << codatt << ALL_PROGR << '=';
<< ' ' << ALL_PROGR << '=';
TRecnotype progr = MANUAL_ROW; TRecnotype progr = MANUAL_ROW;
TString query; TString query;
@ -887,12 +834,10 @@ TRecnotype TDati_rilevanti_msk::last_user_progr() const
TRecnotype TDati_rilevanti_msk::nuovo_progr() const TRecnotype TDati_rilevanti_msk::nuovo_progr() const
{ {
const int anno = get_int(F_ANNO); const int anno = get_int(F_ANNO);
const TString& codatt = get(F_CODATT);
TString limit; TString limit;
limit << ALL_ANNO << '=' << anno << ' ' limit << ALL_ANNO << '=' << anno << ' '
<< ALL_CODATT << '=' << codatt << ALL_PROGR << '=';
<< ' ' << ALL_PROGR << '=';
TRecnotype progr = last_user_progr(); TRecnotype progr = last_user_progr();
@ -919,10 +864,9 @@ TRecnotype TDati_rilevanti_msk::nuovo_progr() const
TRecnotype TDati_rilevanti_msk::genera_alleg() TRecnotype TDati_rilevanti_msk::genera_alleg()
{ {
const int anno = get_int(F_ANNO); const int anno = get_int(F_ANNO);
const TString& codatt = get(F_CODATT);
TString str_pi; TString str_pi;
str_pi << TR("Movimenti ") << anno << TR(" attività ") << codatt; str_pi << TR("Movimenti ") << anno;
TLog_report log(str_pi); TLog_report log(str_pi);
TFast_isamfile falleg(LF_ALLEG); TFast_isamfile falleg(LF_ALLEG);
@ -945,8 +889,7 @@ TRecnotype TDati_rilevanti_msk::genera_alleg()
{ {
if (!pi.addstatus(1)) if (!pi.addstatus(1))
break; break;
if (codatt == mov2att(mov_rec)) elabora_movimento(mov_rec, falleg, nprog, log);
elabora_movimento(mov_rec, falleg, nprog, log);
} }
log.preview(); log.preview();
@ -973,7 +916,7 @@ bool TDati_rilevanti_msk::send_alleg()
TFilename temp; temp.tempdir(); TFilename temp; temp.tempdir();
temp.add("datiril.txt"); temp.add("datiril.txt");
TDati_rilevanti_set recset(get_int(F_ANNO), get(F_CODATT)); TDati_rilevanti_set recset(get_int(F_ANNO));
recset.add_control_rec(0); recset.add_control_rec(0);
TISAM_recordset alleg(""); TISAM_recordset alleg("");
@ -991,9 +934,7 @@ void TDati_rilevanti_msk::set_dirty(bool d)
void TDati_rilevanti_msk::load_sheet() void TDati_rilevanti_msk::load_sheet()
{ {
const int anno = get_int(F_ANNO); const int anno = get_int(F_ANNO);
const TString& codatt = get(F_CODATT); TString16 limit; limit << ALL_ANNO << '=' << anno;
TString limit;
limit << ALL_ANNO << '=' << anno << ' ' << ALL_CODATT << '=' << codatt;
const char tipocf = get(F_TIPOCF)[0]; const char tipocf = get(F_TIPOCF)[0];
const long codcf = get_long(F_CODCF); const long codcf = get_long(F_CODCF);
@ -1015,7 +956,7 @@ void TDati_rilevanti_msk::load_sheet()
const TRecnotype items = alleg.items(); const TRecnotype items = alleg.items();
if (items > 0) if (items > 0)
{ {
TString pi_str; pi_str << TR("Caricamento ") << anno << TR(" attività ") << codatt; TString pi_str; pi_str << TR("Caricamento ") << anno;
TProgind pi(items, pi_str); TProgind pi(items, pi_str);
const TRectype& curr = alleg.cursor()->curr(); const TRectype& curr = alleg.cursor()->curr();
int rec = 0; int rec = 0;
@ -1049,7 +990,6 @@ bool TDati_rilevanti_msk::save_sheet()
bool done = true; bool done = true;
const int anno = get_int(F_ANNO); const int anno = get_int(F_ANNO);
const TString& codatt = get(F_CODATT);
TSheet_field& s = sfield(F_RIGHE); TSheet_field& s = sfield(F_RIGHE);
const TRecnotype items = s.items(); const TRecnotype items = s.items();
@ -1064,7 +1004,6 @@ bool TDati_rilevanti_msk::save_sheet()
alleg.zero(); alleg.zero();
rec.put(ALL_ANNO, anno); rec.put(ALL_ANNO, anno);
rec.put(ALL_CODATT, codatt);
s.autosave_line(r+1, rec); s.autosave_line(r+1, rec);
const int err = alleg.rewrite_write(); const int err = alleg.rewrite_write();
if (err != NOERR) if (err != NOERR)
@ -1088,9 +1027,7 @@ bool TDati_rilevanti_msk::check_rows(bool show_error)
TSheet_field& s = sfield(F_RIGHE); TSheet_field& s = sfield(F_RIGHE);
const int anno = get_int(F_ANNO); const int anno = get_int(F_ANNO);
const TString& codatt = get(F_CODATT); bool ok = anno >= 2010;
bool ok = anno >= 2010 && codatt.full();
if (!ok) if (!ok)
{ {
if (show_error) if (show_error)
@ -1130,14 +1067,6 @@ bool TDati_rilevanti_msk::on_field_event(TOperable_field& o, TField_event e, lon
{ {
switch (o.dlg()) switch (o.dlg())
{ {
case F_CODATT:
if (e == fe_init)
{
TBrowse& b = *((TEdit_field&)o).browse();
*b.cursor() = 0L;
b.do_output();
}
break;
case DLG_OK: // Salva case DLG_OK: // Salva
if (e == fe_button && jolly == 0) // Selezione su maschera principale if (e == fe_button && jolly == 0) // Selezione su maschera principale
{ {

View File

@ -2,7 +2,6 @@
#define F_RAGSOCD 202 #define F_RAGSOCD 202
#define F_ANNO 203 #define F_ANNO 203
#define F_CODATT 204
#define F_DESCATT 205 #define F_DESCATT 205
#define F_SENDALL 206 #define F_SENDALL 206

View File

@ -1,2 +1,8 @@
#define F_CODICE 101 #define F_TIPOCF 101
#define F_DESCRIZIONE 102 #define F_CODCF 102
#define F_RAGSOC 103
#define F_CONTRATTO 104
#define F_DESCRIZIONE 105
#define F_INIZIO 106
#define F_FINE 107
#define F_IMPORTO 108