Patch level :
Files correlati : fe0.exe fe0100a.msk Ricompilazione Demo : [ ] Commento : Aggiunto bottone per stampa report del contenuto del file per l'agenzia delle entrate. git-svn-id: svn://10.65.10.50/branches/R_10_00@22468 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
94cf0d05d3
commit
6135d9e03f
464
fe/fe0100.cpp
464
fe/fe0100.cpp
@ -57,7 +57,7 @@ static const TString& provincia_di(const TString& codcom)
|
||||
}
|
||||
|
||||
static real importo_limite(int anno)
|
||||
{ return anno <= 2010 ? 25000 : 3000; }
|
||||
{ return anno > 2010 ? 3000: 25000; }
|
||||
|
||||
static bool is_nota_variazione(const TRectype& mov)
|
||||
{
|
||||
@ -92,6 +92,30 @@ static bool is_nota_variazione(const TRectype& mov)
|
||||
return false;
|
||||
}
|
||||
|
||||
enum TExclusion_mode { em_incluso, em_importo_limite, em_no_allegato,
|
||||
em_fiscalita_agevolata, em_estero, em_intra,
|
||||
em_art8, em_data_limite, em_passaggi_interni,
|
||||
em_inviato, em_altro };
|
||||
|
||||
static const char* mode2string(TExclusion_mode motivo)
|
||||
{
|
||||
const char* msg = "";
|
||||
switch (motivo)
|
||||
{
|
||||
case em_importo_limite : msg = TR("importo inferiore al limite della comunicazione"); break;
|
||||
case em_no_allegato : msg = TR("Soggetto da non inserire in allegato"); break;
|
||||
case em_fiscalita_agevolata: msg = TR("Soggetto residente in stato a fiscalità agevolata"); break;
|
||||
case em_estero : msg = TR("Soggetto residente all'estero"); break;
|
||||
case em_intra : msg = TR("Movimento intra"); break;
|
||||
case em_data_limite : msg = TR("Data fuori dal limite della comunicazione"); break;
|
||||
case em_art8 : msg = TR("Soggetto all'articolo 8 (del dpr 26-10-1972)"); break;
|
||||
case em_passaggi_interni : msg = TR("Passaggi interni"); break;
|
||||
case em_inviato : msg = TR("Inviato l'anno precedente"); break;
|
||||
default : msg = TR("Altri motivi"); break;
|
||||
}
|
||||
return msg;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// TContratto
|
||||
///////////////////////////////////////////////////////////
|
||||
@ -271,7 +295,8 @@ class TAnagrafica : public TObject
|
||||
TDate _data_nasc;
|
||||
int _allegato, _stato_estero;
|
||||
|
||||
TAnagrafica(const TAnagrafica&) { CHECK(false, "Can't copy TAnagrafica"); }
|
||||
TAnagrafica& operator =(const TAnagrafica&) { CHECK(false, "Can't copy TAnagrafica"); }
|
||||
TAnagrafica(const TAnagrafica&) { CHECK(false, "Can't copy TAnagrafica"); }
|
||||
|
||||
public:
|
||||
virtual bool ok() const { return _tipo=='F' || _tipo == 'G'; }
|
||||
@ -606,6 +631,8 @@ class TDati_rilevanti_set : public TAS400_recordset
|
||||
|
||||
protected:
|
||||
virtual bool set_field(const TAS400_column_info& fi, const TVariant& var);
|
||||
virtual const TVariant& get_field(const TAS400_column_info& fi) const;
|
||||
|
||||
void init();
|
||||
bool set_val(int n, const TVariant& v) { return TAS400_recordset::set(n-1, v); }
|
||||
|
||||
@ -618,8 +645,9 @@ public:
|
||||
bool set(unsigned int n, const TDate& v) { return set_val(n, v); }
|
||||
void add_control_rec(int zero_o_nove, int num_inv = 1, int tot_inv = 1);
|
||||
bool split(const TFilename& name, const TRecnotype maxalleg = 15000);
|
||||
|
||||
int anno() const { return _anno; }
|
||||
TDati_rilevanti_set(int anno);
|
||||
TDati_rilevanti_set(const TFilename& file);
|
||||
};
|
||||
|
||||
bool TDati_rilevanti_set::set_field(const TAS400_column_info& fi, const TVariant& var)
|
||||
@ -648,6 +676,29 @@ bool TDati_rilevanti_set::set_field(const TAS400_column_info& fi, const TVariant
|
||||
return TAS400_recordset::set_field(fi, var);
|
||||
}
|
||||
|
||||
const TVariant& TDati_rilevanti_set::get_field(const TAS400_column_info& ci) const
|
||||
{
|
||||
if (ci._type == DT && ci._width == 8)
|
||||
{
|
||||
const TRecnotype n = current_row();
|
||||
if (n >= 0 && n < items())
|
||||
{
|
||||
const TString& str = row(n).mid(ci._pos, ci._width);
|
||||
const int gg = atoi(str.left(2));
|
||||
const int mm = atoi(str.mid(2,2));
|
||||
const int aa = atoi(str.mid(4,4));
|
||||
if (aa > 1800 && aa < 2100)
|
||||
{
|
||||
TVariant& var = get_tmp_var();
|
||||
var.set(TDate(gg, mm, aa));
|
||||
return var;
|
||||
}
|
||||
}
|
||||
return NULL_VARIANT;
|
||||
}
|
||||
return TAS400_recordset::get_field(ci);
|
||||
}
|
||||
|
||||
void TDati_rilevanti_set::add_control_rec(int zon, int num_inv, int tot_inv)
|
||||
{
|
||||
CHECKD(zon == 0 || zon == 9, "Tipo record di testa o coda non valido ", zon);
|
||||
@ -689,56 +740,65 @@ bool TDati_rilevanti_set::split(const TFilename& name, const TRecnotype maxalleg
|
||||
bool done = totrec <= maxalleg;
|
||||
if (!done)
|
||||
{
|
||||
const TRecnotype rows_x_file = maxalleg-2;
|
||||
const int totf = int((totrec-2.0) / rows_x_file + 0.99);
|
||||
|
||||
TString msg;
|
||||
msg.format(FR("Spezzatura del file %s in blocchi da %d righe"), (const char*)name, maxalleg);
|
||||
TProgind pi(totrec, msg);
|
||||
|
||||
move_first();
|
||||
for (int f = 1; f <= totf; f++)
|
||||
TDati_rilevanti_set outset(_anno);
|
||||
int f = 0;
|
||||
for (TRecnotype r = 0; r < totrec; r++)
|
||||
{
|
||||
TDati_rilevanti_set outset(_anno);
|
||||
outset.add_control_rec(0, f, totf);
|
||||
for (TRecnotype sent = 0; sent < rows_x_file && move_next(); sent++)
|
||||
if (!pi.setstatus(r))
|
||||
break; // Procedura interrotta dall'utente
|
||||
outset.new_rec(row(r));
|
||||
if (outset.items() >= maxalleg || r == totrec-1)
|
||||
{
|
||||
const TRecnotype r = current_row();
|
||||
if (!pi.setstatus(r))
|
||||
// Costruisce il nome del file di invio parziale, es: datiril_2.txt
|
||||
TFilename outname = name;
|
||||
const TString8 saved_ext = outname.ext();
|
||||
outname.ext(""); outname << '_' << (++f);
|
||||
outname.ext(saved_ext);
|
||||
done = outset.save_as(outname);
|
||||
if (done)
|
||||
outset.destroy();
|
||||
else
|
||||
{
|
||||
f = totf; // Procedura interrotta dall'utente
|
||||
cantwrite_box(outname);
|
||||
break;
|
||||
}
|
||||
const TString& rec = row(r);
|
||||
if (rec[0] == '0') continue; // Ignora un eventuale record iniziale "spurio"
|
||||
if (rec[0] == '9') break; // Termina quando incontra il record finale
|
||||
outset.new_rec(rec);
|
||||
}
|
||||
outset.add_control_rec(9, f, totf);
|
||||
|
||||
// Costruisce il nome del file di invio parziale, es: datiril_1_3.txt
|
||||
TFilename outname = name;
|
||||
const TString8 saved_ext = outname.ext();
|
||||
outname.ext(""); outname << '_' << f << '_' << totf;
|
||||
outname.ext(saved_ext);
|
||||
done = outset.save_as(outname);
|
||||
if (!done)
|
||||
{
|
||||
cantwrite_box(outname);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (f > 1)
|
||||
warning_box(FR("Sono stati generati %d file nella cartella %s"), name.path());
|
||||
}
|
||||
return done;
|
||||
}
|
||||
|
||||
TDati_rilevanti_set::TDati_rilevanti_set(int anno)
|
||||
: TAS400_recordset("AS400(1800,1)"), _anno(anno)
|
||||
void TDati_rilevanti_set::init()
|
||||
{
|
||||
TDati_rilevanti_trc trc;
|
||||
for (int i = 0; i <= 5; i++)
|
||||
trc.create_fields(i, *this);
|
||||
trc.create_fields(9, *this);
|
||||
|
||||
}
|
||||
|
||||
TDati_rilevanti_set::TDati_rilevanti_set(const TFilename& file)
|
||||
: TAS400_recordset("AS400(1800,1)"), _anno(2010)
|
||||
{
|
||||
init();
|
||||
if (load_file(file) && move_first())
|
||||
{
|
||||
const int anno = get(18).as_int();
|
||||
if (anno > 2010)
|
||||
_anno = anno;
|
||||
}
|
||||
}
|
||||
|
||||
TDati_rilevanti_set::TDati_rilevanti_set(int anno)
|
||||
: TAS400_recordset("AS400(1800,1)"), _anno(anno)
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
@ -749,33 +809,52 @@ class TDati_rilevanti_array : public TObject
|
||||
{
|
||||
TArray _data;
|
||||
|
||||
protected:
|
||||
TExclusion_mode segnala_riga(const TRectype& alleg, TExclusion_mode motivo, TLog_report& log) const;
|
||||
|
||||
public:
|
||||
int items() const { return _data.items(); }
|
||||
const TRectype& operator[](int i) { return (const TRectype&)_data[i]; }
|
||||
bool add(const TRectype& alleg, bool send_all);
|
||||
void add(const TArray& note, bool send_all);
|
||||
TExclusion_mode add(const TRectype& alleg, bool send_all, TLog_report& log);
|
||||
void add(const TArray& note, bool send_all, TLog_report& log);
|
||||
};
|
||||
|
||||
bool TDati_rilevanti_array::add(const TRectype& alleg, bool send_all)
|
||||
TExclusion_mode TDati_rilevanti_array::segnala_riga(const TRectype& alleg, TExclusion_mode motivo, TLog_report& log) const
|
||||
{
|
||||
const long numreg = alleg.get_long(ALL_PROGR);
|
||||
const char* tipocf = alleg.get_char(ALL_TIPOCF) == 'F' ? TR("Fornitore") : TR("Cliente");
|
||||
const long codcf = alleg.get_long(MOV_CODCF);
|
||||
TString msg; msg.format(FR("%s %6ld - Riga %7ld scartata: "), tipocf, codcf, numreg);
|
||||
msg << mode2string(motivo);
|
||||
log.log(1, msg);
|
||||
return motivo;
|
||||
}
|
||||
|
||||
|
||||
TExclusion_mode TDati_rilevanti_array::add(const TRectype& alleg, bool send_all, TLog_report& log)
|
||||
{
|
||||
TExclusion_mode ignora = TExclusion_mode(alleg.get_int(ALL_IGNORA));
|
||||
if (ignora > em_importo_limite)
|
||||
return ignora;
|
||||
|
||||
const real importo = alleg.get_real(ALL_IMPORTO);
|
||||
const real imposta = alleg.get_real(ALL_IMPOSTA);
|
||||
if (importo.is_zero() && imposta.is_zero())
|
||||
return false;
|
||||
return segnala_riga(alleg, em_importo_limite, log);
|
||||
|
||||
const TString80 contratto = alleg.get(ALL_CONTRATTO);
|
||||
const TString8 numrett = alleg.get(ALL_NUMRETT);
|
||||
if (contratto.full() || numrett.full())
|
||||
{
|
||||
const char tipocf = alleg.get_char(ALL_TIPOCF);
|
||||
const char codcf = alleg.get_char(ALL_CODCF);
|
||||
TString16 curr_idcf = alleg.get(ALL_OCFPI);
|
||||
if (curr_idcf.blank()) curr_idcf = alleg.get(ALL_CODCF);
|
||||
TRectype* sum = NULL;
|
||||
for (int i = _data.last(); i >= 0; i--)
|
||||
{
|
||||
TRectype& rec = (TRectype&)_data[i];
|
||||
const char t = rec.get_char(ALL_TIPOCF);
|
||||
const long c = rec.get_long(ALL_CODCF);
|
||||
if (t == tipocf && c == codcf)
|
||||
TString16 idcf = rec.get(ALL_OCFPI);
|
||||
if (idcf.blank()) idcf = rec.get(ALL_CODCF);
|
||||
if (idcf == curr_idcf)
|
||||
{
|
||||
const TString& k = rec.get(ALL_CONTRATTO);
|
||||
const TString& n = rec.get(ALL_NUMDOC);
|
||||
@ -785,6 +864,8 @@ bool TDati_rilevanti_array::add(const TRectype& alleg, bool send_all)
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
if (sum != NULL)
|
||||
{
|
||||
@ -812,39 +893,186 @@ bool TDati_rilevanti_array::add(const TRectype& alleg, bool send_all)
|
||||
if (old_mode != new_mode)
|
||||
sum->put(ALL_IGNORA, new_mode);
|
||||
}
|
||||
return true; // Aggiunto a record preesistente
|
||||
return em_incluso; // Aggiunto a record preesistente
|
||||
}
|
||||
else
|
||||
{
|
||||
// Ignora le note di variazione non collegate e di importo non rilevante
|
||||
if (!send_all && !alleg.get_int(ALL_IGNORA) && is_nota_variazione(alleg))
|
||||
if (!send_all && ignora == em_incluso && is_nota_variazione(alleg))
|
||||
{
|
||||
const int anno = alleg.get_int(ALL_ANNO);
|
||||
const real importo = abs(alleg.get_real(ALL_IMPORTO));
|
||||
if (importo < importo_limite(anno))
|
||||
return false;
|
||||
ignora = segnala_riga(alleg, em_importo_limite, log);
|
||||
else
|
||||
{
|
||||
const TDate datarett = alleg.get(ALL_DATARETT);
|
||||
if (datarett.year() != anno)
|
||||
return segnala_riga(alleg, em_data_limite, log); // Non posso fare la add con DATARETT errata
|
||||
|
||||
const TString& nr = alleg.get(ALL_NUMRETT);
|
||||
if (nr.blank() || nr == INVALID_NUMDOC)
|
||||
return segnala_riga(alleg, em_altro, log); // Non posso fare la add in assenza di NUMRETT
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!send_all)
|
||||
{
|
||||
// Ignora i record solitari non rilevanti
|
||||
const int ignora = alleg.get_int(ALL_IGNORA);
|
||||
if (ignora != 0)
|
||||
return false;
|
||||
}
|
||||
if (!send_all && ignora != em_incluso)
|
||||
return ignora;
|
||||
|
||||
// Creo un nuovo record
|
||||
return _data.add(alleg) >= 0;
|
||||
_data.add(alleg);
|
||||
return em_incluso;
|
||||
}
|
||||
|
||||
void TDati_rilevanti_array::add(const TArray& note, bool send_all)
|
||||
void TDati_rilevanti_array::add(const TArray& note, bool send_all, TLog_report& log)
|
||||
{
|
||||
FOR_EACH_ARRAY_ITEM(note, t, obj)
|
||||
{
|
||||
const TRectype& nota = *(const TRectype*)obj;
|
||||
add(nota, send_all);
|
||||
add(nota, send_all, log);
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// TDati_rilevanti_rep
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
class TDati_rilevanti_rep : public TReport
|
||||
{
|
||||
protected:
|
||||
virtual bool get_usr_val(const TString& name, TVariant& var) const;
|
||||
|
||||
public:
|
||||
TDati_rilevanti_rep(const TFilename& file);
|
||||
};
|
||||
|
||||
bool TDati_rilevanti_rep::get_usr_val(const TString& name, TVariant& var) const
|
||||
{
|
||||
if (name.starts_with("#FLD"))
|
||||
{
|
||||
const char* fld = (const char*)name + 4;
|
||||
const TDati_rilevanti_set& set = *(TDati_rilevanti_set*)recordset();
|
||||
if (fld[1] != '.')
|
||||
{
|
||||
const int t = atoi(set.rec_type());
|
||||
if ((t >= 0 && t <= 5) || t == 9)
|
||||
{
|
||||
TString8 n;
|
||||
n.format("%d.%s", t, fld);
|
||||
var = set.get(n);
|
||||
}
|
||||
else
|
||||
{
|
||||
var.set_null();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
var = set.get(fld);
|
||||
return !var.is_null();
|
||||
} else
|
||||
if (name.starts_with("#ANNO"))
|
||||
{
|
||||
const TDati_rilevanti_set& set = *(TDati_rilevanti_set*)recordset();
|
||||
var.set(set.anno());
|
||||
return true;
|
||||
}
|
||||
return TReport::get_usr_val(name, var);
|
||||
}
|
||||
|
||||
TDati_rilevanti_rep::TDati_rilevanti_rep(const TFilename& file)
|
||||
{
|
||||
TDati_rilevanti_set* set = new TDati_rilevanti_set(file);
|
||||
set_recordset(set);
|
||||
|
||||
TReport_font small_font, big_font;
|
||||
big_font.create(font().name(), font().size()*2, XVT_FS_BOLD);
|
||||
small_font.create(font().name(), font().size()/2, XVT_FS_NONE);
|
||||
|
||||
TReport_section& h2 = section('H', 2);
|
||||
h2.group_by("#FLD1");
|
||||
TReport_field* fld = new TReport_field(&h2);
|
||||
fld->set_type('S');
|
||||
fld->set_horizontal_alignment('C');
|
||||
fld->set_field("\"Operazioni rilevanti \"+ #ANNO + \" Sezione \"+#FLD1");
|
||||
fld->set_pos(100, 50);
|
||||
fld->set_width(92*100);
|
||||
fld->set_height(200);
|
||||
fld->set_border(1);
|
||||
fld->set_font(big_font);
|
||||
h2.add(fld);
|
||||
h2.force_page_break(true);
|
||||
|
||||
TString16 col;
|
||||
for (int t = 0; t <= 6; t++)
|
||||
{
|
||||
TReport_section& b = section('B', t+1);
|
||||
if (t == 6) t = 9;
|
||||
col.format("#FLD1==%d", t);
|
||||
b.set_condition(col);
|
||||
int x = 100, y = 100;
|
||||
for (int f = 1; ; f++)
|
||||
{
|
||||
col.format("%d.%d", t, f);
|
||||
const TRecordset_column_info& info = set->column_info(col);
|
||||
if (info._width > 60)
|
||||
break;
|
||||
const int width = info._type == DT ? 1000 : info._width*100;
|
||||
if ((x+width) > 92*100)
|
||||
{
|
||||
x = 100;
|
||||
y += 100;
|
||||
}
|
||||
|
||||
// Sfondo grigio del campo
|
||||
fld = new TReport_field(&b);
|
||||
fld->set_type('T');
|
||||
fld->set_pos(x-75, y);
|
||||
fld->set_width(width+75);
|
||||
fld->set_height(95);
|
||||
fld->set_pattern(PAT_SOLID);
|
||||
fld->set_back_color(XVT_MAKE_COLOR(240,240,240));
|
||||
fld->set_text_color(COLOR_LTGRAY);
|
||||
fld->set_picture(col.format("%d", f));
|
||||
fld->set_font(small_font);
|
||||
b.add(fld);
|
||||
|
||||
// Campo vero e proprio
|
||||
fld = new TReport_field(&b);
|
||||
fld->set_id(f);
|
||||
col.format("#FLD%d", f);
|
||||
fld->set_field(col);
|
||||
fld->set_pos(x, y);
|
||||
fld->set_width(width);
|
||||
fld->set_height(100);
|
||||
switch (info._type)
|
||||
{
|
||||
case _datefld:
|
||||
fld->set_type('D');
|
||||
break;
|
||||
case _intzerofld:
|
||||
case _longzerofld:
|
||||
{
|
||||
const TString pic(info._width, '@');
|
||||
fld->set_picture(pic);
|
||||
}
|
||||
case _intfld:
|
||||
case _longfld:
|
||||
case _realfld:
|
||||
fld->set_type('N');
|
||||
fld->set_horizontal_alignment('R');
|
||||
break;
|
||||
default:
|
||||
fld->set_type('S');
|
||||
break;
|
||||
}
|
||||
fld->set_vertical_alignment('B');
|
||||
b.add(fld);
|
||||
x += fld->get_rect().width() + 100;
|
||||
}
|
||||
b.set_height(y+100);
|
||||
}
|
||||
}
|
||||
|
||||
@ -853,11 +1081,6 @@ void TDati_rilevanti_array::add(const TArray& note, bool send_all)
|
||||
// TDati_rilevanti_msk
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
enum TExclusion_mode { em_incluso, em_importo_limite, em_no_allegato,
|
||||
em_fiscalita_agevolata, em_estero, em_intra,
|
||||
em_art8, em_data_limite, em_passaggi_interni,
|
||||
em_inviato, em_altro };
|
||||
|
||||
class TDati_rilevanti_msk : public TAutomask
|
||||
{
|
||||
TMaskmode _mode;
|
||||
@ -916,19 +1139,7 @@ TExclusion_mode TDati_rilevanti_msk::segnala_movimento(const TRectype& mov, TExc
|
||||
const char* tipocf = mov.get_char(MOV_TIPO) == 'F' ? TR("Fornitore") : TR("Cliente");
|
||||
const long codcf = mov.get_long(MOV_CODCF);
|
||||
TString msg; msg.format(FR("%s %6ld - Registrazione %7ld scartata: "), tipocf, codcf, numreg);
|
||||
switch (motivo)
|
||||
{
|
||||
case em_importo_limite : msg << TR("importo inferiore al limite della comunicazione"); break;
|
||||
case em_no_allegato : msg << TR("Soggetto da non inserire in allegato"); break;
|
||||
case em_fiscalita_agevolata: msg << TR("Soggetto residente in stato a fiscalità agevolata"); break;
|
||||
case em_estero : msg << TR("Soggetto residente all'estero"); break;
|
||||
case em_intra : msg << TR("Movimento intra"); break;
|
||||
case em_data_limite : msg << TR("Data movimento fuori dal limite della comunicazione"); break;
|
||||
case em_art8 : msg << TR("Soggetto all'articolo 8 (del dpr 26-10-1972)"); break;
|
||||
case em_passaggi_interni : msg << TR("Passaggi interni"); break;
|
||||
case em_inviato : msg << TR("Inviato l'anno precedente"); break;
|
||||
default : msg << TR("Altri motivi"); break;
|
||||
}
|
||||
msg << mode2string(motivo);
|
||||
_why = motivo;
|
||||
if (motivo > em_importo_limite)
|
||||
_log->log(1, msg);
|
||||
@ -1068,17 +1279,11 @@ TExclusion_mode TDati_rilevanti_msk::elabora_movimento(const TRectype& mov, TBas
|
||||
tot_imposta += rmi_imposta;
|
||||
}
|
||||
|
||||
if (tot_imponibile.is_zero() && tot_imposta.is_zero())
|
||||
{
|
||||
segnala_movimento(mov, em_importo_limite);
|
||||
return em_importo_limite;
|
||||
}
|
||||
|
||||
const int modpag = mov.get_int(MOV_MODPAG);
|
||||
if (modpag == 1 && tot_imponibile >= ZERO && _why == em_incluso)
|
||||
if (modpag == 1 && _why == em_incluso)
|
||||
{
|
||||
// Considera solo registrazioni con importo rilevante
|
||||
if (tot_imponibile < importo_limite(anno))
|
||||
if (abs(tot_imponibile) < importo_limite(anno))
|
||||
_why = em_importo_limite; // Non segnalare migliaia di movimenti inutilmente
|
||||
}
|
||||
|
||||
@ -1226,15 +1431,14 @@ bool TDati_rilevanti_msk::azzera_alleg(TAssoc_array& manuali) const
|
||||
const TDate datareg = mrec.get_long(MOV_DATAREG);
|
||||
const int annoiva = mrec.get_long(MOV_ANNOIVA);
|
||||
|
||||
bool kill = numreg != progr || annoiva < 2010;
|
||||
bool kill = numreg != progr || annoiva < anno;
|
||||
if (!kill)
|
||||
{
|
||||
const bool forzata = alleg.get(ALL_FORZATURA).as_bool();
|
||||
const bool forzata = arec.get_bool(ALL_FORZATURA);
|
||||
if (forzata)
|
||||
manuali.add(arec.get(ALL_PROGR));
|
||||
else
|
||||
kill = annoiva == data.year() && datareg > data;
|
||||
|
||||
}
|
||||
if (kill)
|
||||
falleg.remove(); // Riga generata dalla vecchia versione
|
||||
@ -1555,16 +1759,9 @@ bool TDati_rilevanti_msk::send_rec(const TRectype& alleg, TDati_rilevanti_set& o
|
||||
{
|
||||
bool done = false;
|
||||
if (is_nota_variazione(alleg))
|
||||
{
|
||||
const TString& numrett = alleg.get(ALL_NUMRETT);
|
||||
const TDate datarett = alleg.get(ALL_DATARETT);
|
||||
if (numrett.full() && numrett != INVALID_NUMDOC && datarett.year() == alleg.get_int(ALL_ANNO))
|
||||
done = send_nota_variazione(alleg, operaz);
|
||||
}
|
||||
done = send_nota_variazione(alleg, operaz);
|
||||
else
|
||||
{
|
||||
done = send_fatt(alleg, operaz);
|
||||
}
|
||||
return done;
|
||||
}
|
||||
|
||||
@ -1599,7 +1796,8 @@ bool TDati_rilevanti_msk::send_alleg()
|
||||
{
|
||||
const int anno = get_int(F_ANNO);
|
||||
const bool send_all = get_int(F_SENDALL) != 1;
|
||||
|
||||
|
||||
|
||||
TFilename temp = get(F_OUTFOLDER);
|
||||
if (temp.blank())
|
||||
temp.tempdir();
|
||||
@ -1617,6 +1815,10 @@ bool TDati_rilevanti_msk::send_alleg()
|
||||
|
||||
if (tot_alleg > 0)
|
||||
{
|
||||
TString str_pi;
|
||||
str_pi << TR("Generazione file ") << temp;
|
||||
_log = new TLog_report(str_pi);
|
||||
|
||||
const TRectype& rec = alleg.cursor()->curr();
|
||||
|
||||
TString16 last_clifo;
|
||||
@ -1633,16 +1835,21 @@ bool TDati_rilevanti_msk::send_alleg()
|
||||
clifo = rec.get(ALL_CODCF);
|
||||
if (clifo != last_clifo)
|
||||
{
|
||||
data.add(note, send_all);
|
||||
data.add(note, send_all, *_log);
|
||||
note.destroy();
|
||||
last_clifo = clifo;
|
||||
}
|
||||
if (rec.get(ALL_NUMRETT).full())
|
||||
if (is_nota_variazione(rec))
|
||||
note.add(rec);
|
||||
else
|
||||
data.add(rec, send_all);
|
||||
data.add(rec, send_all, *_log);
|
||||
}
|
||||
data.add(note, send_all);
|
||||
data.add(note, send_all, *_log);
|
||||
|
||||
if (_log->recordset()->items())
|
||||
_log->preview();
|
||||
delete _log;
|
||||
_log = NULL;
|
||||
}
|
||||
|
||||
TDati_rilevanti_set recset(anno);
|
||||
@ -1662,6 +1869,7 @@ bool TDati_rilevanti_msk::send_alleg()
|
||||
}
|
||||
|
||||
recset.add_control_rec(9);
|
||||
recset.sort();
|
||||
bool done = recset.save_as(temp);
|
||||
|
||||
const long maxalleg = get_long(F_MAXREC);
|
||||
@ -1677,22 +1885,32 @@ bool TDati_rilevanti_msk::send_alleg()
|
||||
pi.addstatus(1);
|
||||
const TRectype& alleg = data[i];
|
||||
const long numreg = alleg.get_long(ALL_PROGR);
|
||||
if (numreg > 0 && numreg < MANUAL_ROW)
|
||||
const int ignora = alleg.get_int(ALL_IGNORA);
|
||||
if (numreg > 0 && numreg < MANUAL_ROW && !ignora)
|
||||
{
|
||||
mov.put(MOV_NUMREG, numreg);
|
||||
int err = mov.read(_isequal, _lock);
|
||||
if (err == NOERR)
|
||||
{
|
||||
mov.put(MOV_MODPAG, alleg.get(ALL_MODPAG));
|
||||
mov.put(MOV_CONTRATTO, alleg.get(ALL_CONTRATTO));
|
||||
mov.put(MOV_DATARETT, alleg.get(ALL_DATARETT));
|
||||
mov.put(MOV_NUMRETT, alleg.get(ALL_NUMRETT));
|
||||
mov.put(MOV_ANNOFE, anno);
|
||||
const int modpag = alleg.get_int(ALL_MODPAG);
|
||||
mov.put(MOV_MODPAG, modpag);
|
||||
if (modpag < 2)
|
||||
{
|
||||
const TString& nr = alleg.get(ALL_NUMRETT);
|
||||
if (nr.full() && nr != INVALID_NUMDOC)
|
||||
{
|
||||
mov.put(MOV_DATARETT, alleg.get(ALL_DATARETT));
|
||||
mov.put(MOV_NUMRETT, nr);
|
||||
}
|
||||
}
|
||||
else
|
||||
mov.put(MOV_CONTRATTO, alleg.get(ALL_CONTRATTO));
|
||||
mov.put(MOV_ANNOFE, anno);
|
||||
err = mov.rewrite();
|
||||
}
|
||||
if (err != NOERR)
|
||||
{
|
||||
error_box(FR("Impossibile aggiornare il movimento %ld: errore %d.\nSi desidera ritentare?"), numreg, err);
|
||||
error_box(FR("Impossibile aggiornare il movimento %ld: errore %d"), numreg, err);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -1722,7 +1940,7 @@ void TDati_rilevanti_msk::alleg_sort(TSheet_field& s) const
|
||||
for (int i = tot-1; i >= 0; i--)
|
||||
{
|
||||
const TString8 numrett = s.cell(i, c_numrett);
|
||||
if (numrett.full())
|
||||
if (numrett.full() && numrett != INVALID_NUMDOC)
|
||||
{
|
||||
const long codcf_i = atol(s.cell(i, c_codcf));
|
||||
int j = -1;
|
||||
@ -1959,6 +2177,11 @@ void TDati_rilevanti_msk::enable_buttons()
|
||||
enable(DLG_DELREC, one_sent);
|
||||
enable(F_DEFINITIVO, !def);
|
||||
if (def) reset(F_DEFINITIVO);
|
||||
|
||||
TFilename temp = get(F_OUTFOLDER);
|
||||
if (temp.blank()) temp.tempdir();
|
||||
temp.add("datiril.txt");
|
||||
enable(DLG_PREVIEW, temp.exist());
|
||||
}
|
||||
|
||||
bool TDati_rilevanti_msk::on_field_event(TOperable_field& o, TField_event e, long jolly)
|
||||
@ -2018,14 +2241,38 @@ bool TDati_rilevanti_msk::on_field_event(TOperable_field& o, TField_event e, lon
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case DLG_PREVIEW:
|
||||
if (e == fe_button)
|
||||
{
|
||||
TFilename temp = get(F_OUTFOLDER);
|
||||
if (temp.blank()) temp.tempdir();
|
||||
temp.add("datiril.txt");
|
||||
if (temp.exist())
|
||||
{
|
||||
TDati_rilevanti_rep rep(temp);
|
||||
rep.preview();
|
||||
}
|
||||
}
|
||||
break;
|
||||
case F_ANNO:
|
||||
if (e == fe_init || e == fe_modify)
|
||||
{
|
||||
int anno = atoi(o.get());
|
||||
if (anno < 2010)
|
||||
{
|
||||
anno = TDate(TODAY).year()-1;
|
||||
TDate d = get(F_DATA);
|
||||
if (d.year() != anno+1)
|
||||
o.set(anno);
|
||||
}
|
||||
on_field_event(efield(F_DATA), fe_modify, jolly);
|
||||
enable_buttons();
|
||||
}
|
||||
break;
|
||||
case F_DATA:
|
||||
if (e == fe_init || e == fe_modify)
|
||||
{
|
||||
const int anno = max(2010, get_int(F_ANNO));
|
||||
TDate d = o.get();
|
||||
if (d < TDate(31,12,anno) || d > TDate(31,12,anno+1))
|
||||
{
|
||||
if (anno == 2010)
|
||||
d = TDate(31,12,2011);
|
||||
@ -2033,7 +2280,6 @@ bool TDati_rilevanti_msk::on_field_event(TOperable_field& o, TField_event e, lon
|
||||
d = TDate(30,4,anno+1);
|
||||
set(F_DATA, d);
|
||||
}
|
||||
enable_buttons();
|
||||
}
|
||||
break;
|
||||
case F_OUTFOLDER:
|
||||
@ -2122,7 +2368,7 @@ bool TDati_rilevanti_app::create()
|
||||
if (alleg.type(ALL_NUMDOC) == _nullfld)
|
||||
return error_box(TR("Il database non è stato ancora convertito per il modulo FE"));
|
||||
|
||||
// Teoricamente è possibile visulizzare tutti i movimenti di un anno, per cui allargo il numero riga
|
||||
// Teoricamente è possibile visualizzare tutti i movimenti di un anno, per cui allargo il numero riga
|
||||
TSheet_field::set_line_number_width(6);
|
||||
|
||||
return TSkeleton_application::create();
|
||||
|
@ -49,6 +49,12 @@ BEGIN
|
||||
PICTURE TOOL_RESET
|
||||
END
|
||||
|
||||
BUTTON DLG_PREVIEW 2 2
|
||||
BEGIN
|
||||
PROMPT 1 7 "Anteprima"
|
||||
PICTURE TOOL_PREVIEW
|
||||
END
|
||||
|
||||
#include <helpbar.h>
|
||||
|
||||
ENDPAGE
|
||||
@ -74,8 +80,6 @@ DATE F_DATA
|
||||
BEGIN
|
||||
PROMPT 15 1 "Data limite "
|
||||
CHECKTYPE REQUIRED
|
||||
STR_EXPR YEAR(#THIS_FIELD)>#F_ANNO
|
||||
WARNING "La data deve appartenere all'anno successivo"
|
||||
END
|
||||
|
||||
LIST F_SHOWALL 1 13
|
||||
@ -158,7 +162,7 @@ BEGIN
|
||||
ITEM "Occasionale@16F"
|
||||
ITEM "Ragione Sociale@24"
|
||||
ITEM "Data\nOperazione@10"
|
||||
ITEM "Numero\nFattura@7"
|
||||
ITEM "Numero\nDocum.@7"
|
||||
ITEM "Importo\ndovuto@12"
|
||||
ITEM "Imposta@12"
|
||||
ITEM "Mod.\nPag.@4"
|
||||
@ -373,7 +377,7 @@ BEGIN
|
||||
OUTPUT A_DATARETT DATADOC
|
||||
OUTPUT A_NUMRETT NUMDOC
|
||||
ADD RUN cg2 -0
|
||||
NUM_EXPR IF(#A_IMPORTO<0;#A_DATARETT!="";1)
|
||||
NUM_EXPR IF((#A_IMPORTO<0)&&(#A_IGNORA<=0);#A_DATARETT!="";1)
|
||||
WARNING "Inserire la data della fattura rettificata"
|
||||
END
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user