1998-09-01 14:39:37 +00:00
|
|
|
|
#include <applicat.h>
|
|
|
|
|
#include <form.h>
|
|
|
|
|
#include <automask.h>
|
|
|
|
|
#include <progind.h>
|
2006-12-13 16:22:33 +00:00
|
|
|
|
#include <recset.h>
|
1998-09-01 14:39:37 +00:00
|
|
|
|
#include <recarray.h>
|
|
|
|
|
#include <utility.h>
|
|
|
|
|
|
|
|
|
|
#include "777.h"
|
2015-02-24 08:35:08 +00:00
|
|
|
|
#include "777lib.h"
|
1998-09-01 14:39:37 +00:00
|
|
|
|
#include "777100a.h"
|
|
|
|
|
|
2015-04-29 10:05:31 +00:00
|
|
|
|
#include "../fe/felib.h"
|
2015-02-24 08:35:08 +00:00
|
|
|
|
|
1998-09-01 14:39:37 +00:00
|
|
|
|
#include <anagr.h>
|
|
|
|
|
#include <anafis.h>
|
|
|
|
|
#include <anagiu.h>
|
2008-03-11 15:50:42 +00:00
|
|
|
|
#include <attiv.h>
|
1998-09-01 14:39:37 +00:00
|
|
|
|
#include <comuni.h>
|
|
|
|
|
#include <nditte.h>
|
|
|
|
|
#include "base.h"
|
|
|
|
|
#include "quadroc.h"
|
|
|
|
|
|
2010-04-29 15:59:14 +00:00
|
|
|
|
// Il nuovo quadro ST e' il vecchio quadro L
|
|
|
|
|
#define LF_QUADRO_ST LF_QUAL
|
|
|
|
|
|
1998-09-01 14:39:37 +00:00
|
|
|
|
///////////////////////////////////////////////////////////
|
2002-09-13 14:06:05 +00:00
|
|
|
|
// Utility
|
1998-09-01 14:39:37 +00:00
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
2016-02-25 11:33:25 +00:00
|
|
|
|
const int ANNO_PAG = 2015;
|
2010-04-29 15:59:14 +00:00
|
|
|
|
|
1998-09-01 14:39:37 +00:00
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
// TForm770
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
class TTrasferimento770;
|
|
|
|
|
|
|
|
|
|
class TForm770 : public TForm
|
|
|
|
|
{
|
|
|
|
|
TCursor* _sortedcur;
|
|
|
|
|
|
|
|
|
|
int _index;
|
|
|
|
|
TArray _records;
|
|
|
|
|
TPointer_array _positions;
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
bool compatible(const TRectype& r1, const TRectype& r2);
|
|
|
|
|
void add_rec(TRectype& r1, const TRectype& r2);
|
|
|
|
|
|
|
|
|
|
long raggruppa_c();
|
|
|
|
|
int first();
|
|
|
|
|
int next();
|
|
|
|
|
|
|
|
|
|
void transfer_section(TPrint_section& body, int rigo,
|
|
|
|
|
TRecord770& rec, TTrasferimento770& file);
|
|
|
|
|
char log2rec(int num, int& rpm) const;
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
|
|
virtual TCursor* cursor() { return _sortedcur ? _sortedcur : TForm::cursor(); }
|
2002-09-13 14:06:05 +00:00
|
|
|
|
virtual bool validate(TForm_item &cf, TToken_string &s);
|
1998-09-01 14:39:37 +00:00
|
|
|
|
|
|
|
|
|
public:
|
2010-04-29 15:59:14 +00:00
|
|
|
|
TRecnotype trasfer(long codditta, TTrasferimento770& file, char tipo, int rpm);
|
1998-09-01 14:39:37 +00:00
|
|
|
|
|
|
|
|
|
TForm770(const char* name);
|
|
|
|
|
virtual ~TForm770();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class TTrasferimento770 : public TObject
|
|
|
|
|
{
|
|
|
|
|
TFilename _name;
|
|
|
|
|
ifstream* _in_stream;
|
|
|
|
|
ofstream* _out_stream;
|
2006-12-13 16:22:33 +00:00
|
|
|
|
|
|
|
|
|
long _cod_ditta, _codan_dic;
|
|
|
|
|
TString8 _codatt_dic;
|
|
|
|
|
char _tipoa_dic;
|
|
|
|
|
TString16 _codfis_dic;
|
|
|
|
|
bool _save_headers;
|
2015-02-24 08:35:08 +00:00
|
|
|
|
bool _centesimi; // Salva importi in centesimi invece che in euro
|
|
|
|
|
|
|
|
|
|
TAssoc_array _form;
|
2002-09-13 14:06:05 +00:00
|
|
|
|
|
2008-03-11 15:50:42 +00:00
|
|
|
|
protected:
|
2014-07-30 12:58:29 +00:00
|
|
|
|
void riepiloga_ss(const TRecord770& rec, TArray& riep_ss) const;
|
|
|
|
|
void riepiloga_sx(const TRecord770& rec, TArray& riep_sx) const;
|
2015-02-24 08:35:08 +00:00
|
|
|
|
TForm770& form(const char* quadro, char& tiporec, int& rpm);
|
|
|
|
|
|
1998-09-01 14:39:37 +00:00
|
|
|
|
public:
|
2015-02-24 08:35:08 +00:00
|
|
|
|
const char* default_name() const;
|
|
|
|
|
|
2007-09-17 15:33:04 +00:00
|
|
|
|
bool open(const char* path = "", char mode = 'r', int volume = 0);
|
1998-09-01 14:39:37 +00:00
|
|
|
|
bool close();
|
|
|
|
|
bool write(const TRecord770& rec);
|
|
|
|
|
bool read(TRecord770& rec);
|
|
|
|
|
bool eof() const { return _in_stream && _in_stream->eof(); }
|
|
|
|
|
|
2015-02-24 08:35:08 +00:00
|
|
|
|
void set_cent_mode(bool cb) { _centesimi = cb; }
|
|
|
|
|
bool importi_in_centesimi() const { return _centesimi; }
|
|
|
|
|
bool importi_in_euro() const { return !_centesimi; }
|
1998-09-01 14:39:37 +00:00
|
|
|
|
|
|
|
|
|
TTrasferimento770& operator<<(const TRecord770& rec)
|
|
|
|
|
{ write(rec); return *this; }
|
|
|
|
|
TTrasferimento770& operator>>(TRecord770& rec)
|
|
|
|
|
{ read(rec); return *this; }
|
|
|
|
|
|
2002-09-13 14:06:05 +00:00
|
|
|
|
const TString& read_codfis_dic(const TRectype& rec);
|
2006-12-13 16:22:33 +00:00
|
|
|
|
const TString& cod_fis_dic() const { return _codfis_dic; }
|
|
|
|
|
|
2010-04-29 15:59:14 +00:00
|
|
|
|
TRecnotype conta_certificazioni() const;
|
2006-12-13 16:22:33 +00:00
|
|
|
|
bool casella_prospetto_st() const;
|
2013-06-20 13:23:00 +00:00
|
|
|
|
bool casella_prospetto_sx() const;
|
2006-12-13 16:22:33 +00:00
|
|
|
|
bool append_record_b();
|
2015-02-24 08:35:08 +00:00
|
|
|
|
long append_quadro(const char* quadro, long codditta, TProgress_monitor& pi);
|
1998-09-01 14:39:37 +00:00
|
|
|
|
|
|
|
|
|
bool split(const char* dest_path);
|
|
|
|
|
void remove();
|
|
|
|
|
|
2006-12-13 16:22:33 +00:00
|
|
|
|
void save_headers(bool s) { _save_headers = s; }
|
|
|
|
|
bool save_headers() const { return _save_headers; }
|
|
|
|
|
|
2007-09-17 15:33:04 +00:00
|
|
|
|
TTrasferimento770(const char* name = "", char mode = 'r', int volume = 0);
|
1998-09-01 14:39:37 +00:00
|
|
|
|
virtual ~TTrasferimento770();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
// TForm770
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
2002-09-13 14:06:05 +00:00
|
|
|
|
bool TForm770::validate(TForm_item &cf, TToken_string &s)
|
|
|
|
|
{
|
2015-05-25 15:29:42 +00:00
|
|
|
|
const TFixed_string code = s.get(0); // prende il primo parametro, il codice del messaggio
|
2002-09-13 14:06:05 +00:00
|
|
|
|
if (code == "_PERIODO_RIF")
|
|
|
|
|
{
|
|
|
|
|
const TRectype& curr = relation()->curr();
|
2010-05-04 09:11:39 +00:00
|
|
|
|
const int anno = curr.get_int("QLAP");
|
|
|
|
|
const int mese = curr.get_int("QLMP");
|
2015-05-25 15:29:42 +00:00
|
|
|
|
TString8 str; str.format("%02d%04d", mese, anno);
|
2002-09-13 14:06:05 +00:00
|
|
|
|
cf.set(str);
|
2004-07-28 08:34:44 +00:00
|
|
|
|
return true;
|
2002-09-13 14:06:05 +00:00
|
|
|
|
}
|
2010-05-04 09:11:39 +00:00
|
|
|
|
if (code == "_PROVINCIA")
|
|
|
|
|
{
|
2015-05-25 15:29:42 +00:00
|
|
|
|
const TFixed_string prov = cf.get();
|
2010-05-04 09:11:39 +00:00
|
|
|
|
if (prov == "EE") // Il 770 non gradisce la provincia EE associata agli stati esteri
|
2014-07-30 12:58:29 +00:00
|
|
|
|
cf.set(""); else
|
|
|
|
|
if (prov == "FO") // Ci sono ancora vecchie province :-(
|
|
|
|
|
cf.set("FC");
|
2010-05-04 09:11:39 +00:00
|
|
|
|
return true;
|
|
|
|
|
}
|
2015-05-25 15:29:42 +00:00
|
|
|
|
if (code == "_SOLO_CAUS_M")
|
|
|
|
|
{
|
|
|
|
|
const TRectype& curr = relation()->curr();
|
|
|
|
|
if (!curr.get("CAUSALE").starts_with("M") || curr.get_real("IMPONIBILE") <= 5000)
|
|
|
|
|
cf.set("");
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
if (code == "_SOLO_CAUS_N")
|
|
|
|
|
{
|
|
|
|
|
const TRectype& curr = relation()->curr();
|
|
|
|
|
if (curr.get("CAUSALE") != "N")
|
|
|
|
|
cf.set("");
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2010-05-04 09:11:39 +00:00
|
|
|
|
|
2002-09-13 14:06:05 +00:00
|
|
|
|
return TForm::validate(cf, s);
|
|
|
|
|
}
|
|
|
|
|
|
1998-09-01 14:39:37 +00:00
|
|
|
|
void TForm770::transfer_section(TPrint_section& body, int rigo,
|
|
|
|
|
TRecord770& rec, TTrasferimento770& file)
|
|
|
|
|
{
|
2002-09-13 14:06:05 +00:00
|
|
|
|
TString8 basecode, code, type;
|
|
|
|
|
TString str;
|
1998-09-01 14:39:37 +00:00
|
|
|
|
|
|
|
|
|
body.update();
|
|
|
|
|
for (word f = 0; f < body.fields(); f++)
|
|
|
|
|
{
|
|
|
|
|
TForm_item& fi = body.field(f);
|
|
|
|
|
str = fi.get(); str.trim();
|
|
|
|
|
if (fi.shown() && str.not_empty())
|
|
|
|
|
{
|
|
|
|
|
basecode = fi.get_special_value("TRASFER");
|
|
|
|
|
if (basecode.not_empty())
|
|
|
|
|
{
|
2002-09-13 14:06:05 +00:00
|
|
|
|
type = fi.get_special_desc("TRASFER");
|
2013-07-02 15:10:33 +00:00
|
|
|
|
if (type.full())
|
1998-09-01 14:39:37 +00:00
|
|
|
|
{
|
2010-04-29 15:59:14 +00:00
|
|
|
|
if (type == "CB") // Casella Barrata
|
1998-09-01 14:39:37 +00:00
|
|
|
|
{
|
2010-04-29 15:59:14 +00:00
|
|
|
|
if (str == "1" || str == "X")
|
|
|
|
|
{
|
|
|
|
|
str = "1";
|
|
|
|
|
str.right_just(16);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
str.cut(0);
|
2005-10-17 10:15:01 +00:00
|
|
|
|
} else
|
2013-07-02 15:10:33 +00:00
|
|
|
|
if (type == "NP" || type == "NU" || type == "VP" || type == "VN") // Numero Positivo, NUmero, Valuta positiva o libera
|
2010-04-29 15:59:14 +00:00
|
|
|
|
{
|
2002-09-13 14:06:05 +00:00
|
|
|
|
if (real::is_null(str))
|
|
|
|
|
str.cut(0);
|
2010-04-29 15:59:14 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// Trattamento a parte degli importi cho possono essere in Euro o Eurocent
|
|
|
|
|
if (xvt_str_compare_ignoring_case(fi.class_name(), "VALUTA") == 0)
|
|
|
|
|
{
|
|
|
|
|
real val = str;
|
2015-02-24 08:35:08 +00:00
|
|
|
|
if (file.importi_in_centesimi())
|
2013-07-02 15:10:33 +00:00
|
|
|
|
{
|
2010-04-29 15:59:14 +00:00
|
|
|
|
val *= CENTO;
|
2013-07-02 15:10:33 +00:00
|
|
|
|
str = val.stringa(16, 0);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
str = val.stringa(16, 2);
|
2010-04-29 15:59:14 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
str.right_just(16);
|
|
|
|
|
}
|
2005-10-17 10:15:01 +00:00
|
|
|
|
} else
|
|
|
|
|
if (type == "DT")
|
|
|
|
|
{
|
|
|
|
|
str.strip("-");
|
|
|
|
|
str.right_just(16);
|
2010-04-29 15:59:14 +00:00
|
|
|
|
}
|
2002-09-13 14:06:05 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (fi.fields() > 0)
|
|
|
|
|
{
|
|
|
|
|
const TFieldref& fr = ((TForm_string&)fi).field(0);
|
|
|
|
|
const int num = fr.file();
|
|
|
|
|
const char* fn = fr.name();
|
2005-10-17 10:15:01 +00:00
|
|
|
|
const TFieldtypes ft = cursor()->curr(num).type(fn);
|
2002-09-13 14:06:05 +00:00
|
|
|
|
switch (ft)
|
|
|
|
|
{
|
|
|
|
|
case _boolfld:
|
2010-04-29 15:59:14 +00:00
|
|
|
|
str = str.full() ? "1" : "0";
|
2002-09-13 14:06:05 +00:00
|
|
|
|
str.right_just(16);
|
|
|
|
|
break;
|
|
|
|
|
case _datefld:
|
|
|
|
|
if (str.len() == 10 && str[2] == '-' && str[5] == '-')
|
|
|
|
|
{
|
|
|
|
|
str.strip("-");
|
|
|
|
|
str.right_just(16);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case _realfld:
|
2010-04-29 15:59:14 +00:00
|
|
|
|
if (real::is_null(str))
|
|
|
|
|
str.cut(0);
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// Trattamento a parte degli importi cho possono essere in Euro o Eurocent
|
|
|
|
|
if (xvt_str_compare_ignoring_case(fi.class_name(), "VALUTA") == 0)
|
|
|
|
|
{
|
|
|
|
|
real val = str;
|
2015-02-24 08:35:08 +00:00
|
|
|
|
if (file.importi_in_centesimi())
|
2010-04-29 15:59:14 +00:00
|
|
|
|
val *= CENTO;
|
|
|
|
|
str = val.string(16, 0);
|
|
|
|
|
}
|
2002-09-13 14:06:05 +00:00
|
|
|
|
else
|
|
|
|
|
str.right_just(16);
|
|
|
|
|
}
|
2010-04-29 15:59:14 +00:00
|
|
|
|
break;
|
2002-09-13 14:06:05 +00:00
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
1998-09-01 14:39:37 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2002-09-13 14:06:05 +00:00
|
|
|
|
|
|
|
|
|
if (str.not_empty())
|
1998-09-01 14:39:37 +00:00
|
|
|
|
{
|
2002-09-13 14:06:05 +00:00
|
|
|
|
const int vero_rigo = atoi(basecode.mid(2, 3)) - 1 + rigo;
|
|
|
|
|
code.format("%c%c%03d%c%c%c",
|
|
|
|
|
basecode[0], basecode[1], vero_rigo,
|
|
|
|
|
basecode[5], basecode[6], basecode[7]);
|
2010-04-29 15:59:14 +00:00
|
|
|
|
if (!rec.np_put(code, str))
|
2002-09-13 14:06:05 +00:00
|
|
|
|
{
|
|
|
|
|
file << rec;
|
|
|
|
|
rec.azzera_campi_non_posizionali();
|
2010-04-29 15:59:14 +00:00
|
|
|
|
rec.np_put(code, str);
|
2002-09-13 14:06:05 +00:00
|
|
|
|
}
|
1998-09-01 14:39:37 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TForm770::compatible(const TRectype& r1, const TRectype& r2)
|
|
|
|
|
{
|
|
|
|
|
if (r1.empty() || r2.empty())
|
2004-07-28 08:34:44 +00:00
|
|
|
|
return true;
|
1998-09-01 14:39:37 +00:00
|
|
|
|
|
|
|
|
|
if (r1.get_long(QUC_CODDITTA) != r2.get_long(QUC_CODDITTA))
|
2004-07-28 08:34:44 +00:00
|
|
|
|
return false;
|
1998-09-01 14:39:37 +00:00
|
|
|
|
if (r1.get_char(QUC_TIPOA) != r2.get_char(QUC_TIPOA))
|
2004-07-28 08:34:44 +00:00
|
|
|
|
return false;
|
1998-09-01 14:39:37 +00:00
|
|
|
|
if (r1.get_long(QUC_CODANAGR) != r2.get_long(QUC_CODANAGR))
|
2004-07-28 08:34:44 +00:00
|
|
|
|
return false;
|
1998-09-01 14:39:37 +00:00
|
|
|
|
if (r1.get_char(QUC_CAUSALE) != r2.get_char(QUC_CAUSALE))
|
2004-07-28 08:34:44 +00:00
|
|
|
|
return false;
|
1998-09-01 14:39:37 +00:00
|
|
|
|
if (r1.get_int(QUC_TASSAZIONE) != r2.get_int(QUC_TASSAZIONE))
|
2004-07-28 08:34:44 +00:00
|
|
|
|
return false;
|
1998-09-01 14:39:37 +00:00
|
|
|
|
|
|
|
|
|
const real p1 = r1.get_real(QUC_PERC);
|
|
|
|
|
const real p2 = r2.get_real(QUC_PERC);
|
|
|
|
|
bool yes = (p1 == ZERO && p2 != ZERO) || (p1 == p2);
|
|
|
|
|
return yes;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TForm770::add_rec(TRectype& r1, const TRectype& r2)
|
|
|
|
|
{
|
|
|
|
|
if (r1.empty())
|
|
|
|
|
r1 = r2;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
for (int f = r1.items()-1; f >= 0; f--)
|
|
|
|
|
{
|
|
|
|
|
const char* name = r1.fieldname(f);
|
|
|
|
|
if (r1.type(name) == _realfld)
|
|
|
|
|
{
|
|
|
|
|
real val = r1.get_real(name);
|
|
|
|
|
val += r2.get_real(name);
|
|
|
|
|
r1.put(name, val);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
r1.put(QUC_PERC, r2.get(QUC_PERC));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
long TForm770::raggruppa_c()
|
|
|
|
|
{
|
|
|
|
|
TCursor& cur = *cursor();
|
|
|
|
|
TRectype& rc = cur.curr();
|
|
|
|
|
_records.destroy();
|
|
|
|
|
for (cur = 0; cur.ok(); ++cur)
|
|
|
|
|
{
|
2004-07-28 08:34:44 +00:00
|
|
|
|
bool append = true;
|
1998-09-01 14:39:37 +00:00
|
|
|
|
const int last = _records.items()-1;
|
|
|
|
|
if (last >= 0)
|
|
|
|
|
{
|
|
|
|
|
TRectype& sum = (TRectype&)_records[last];
|
|
|
|
|
if (compatible(sum, rc))
|
|
|
|
|
{
|
|
|
|
|
add_rec(sum, rc);
|
2004-07-28 08:34:44 +00:00
|
|
|
|
append = false;
|
1998-09-01 14:39:37 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (append)
|
|
|
|
|
{
|
|
|
|
|
_records.add(rc);
|
|
|
|
|
_positions.add_long(cur.pos()+1);
|
|
|
|
|
}
|
|
|
|
|
}
|
1998-10-06 10:51:26 +00:00
|
|
|
|
|
1998-09-01 14:39:37 +00:00
|
|
|
|
return _records.items();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int TForm770::first()
|
|
|
|
|
{
|
|
|
|
|
TCursor& cur = *cursor();
|
|
|
|
|
|
|
|
|
|
cur = 0;
|
|
|
|
|
bool ok = cur.ok();
|
|
|
|
|
|
|
|
|
|
if (cur.file().num() == LF_QUAC)
|
|
|
|
|
{
|
|
|
|
|
if (ok)
|
|
|
|
|
{
|
|
|
|
|
raggruppa_c();
|
|
|
|
|
_index = 0;
|
|
|
|
|
cur.curr() = (TRectype&)_records[0];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ok ? NOERR : _iseof;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int TForm770::next()
|
|
|
|
|
{
|
|
|
|
|
TCursor& cur = *cursor();
|
|
|
|
|
|
|
|
|
|
bool ok;
|
|
|
|
|
if (cur.file().num() == LF_QUAC)
|
|
|
|
|
{
|
|
|
|
|
_index++;
|
|
|
|
|
ok = _index < _records.items();
|
|
|
|
|
if (ok)
|
|
|
|
|
{
|
|
|
|
|
cur = _positions.get_long(_index) - 1;
|
|
|
|
|
cur.curr() = (TRectype&)_records[_index];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
++cur;
|
|
|
|
|
ok = cur.ok();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ok ? NOERR : _iseof;
|
|
|
|
|
}
|
|
|
|
|
|
2010-04-29 15:59:14 +00:00
|
|
|
|
TRecnotype TForm770::trasfer(long codditta, TTrasferimento770& file, char rectype, int rpm)
|
1998-09-01 14:39:37 +00:00
|
|
|
|
{
|
|
|
|
|
TCursor& cur = *cursor();
|
|
|
|
|
|
|
|
|
|
// Filtra il cursore sulla ditta corrente
|
2010-04-29 15:59:14 +00:00
|
|
|
|
TRectype region(cur.curr());
|
|
|
|
|
region.zero();
|
|
|
|
|
region.put(BSE_CODDITTA, codditta);
|
|
|
|
|
cur.setregion(region, region);
|
|
|
|
|
|
2015-05-25 15:29:42 +00:00
|
|
|
|
TString16 filter;
|
|
|
|
|
switch (region.num())
|
2010-04-29 15:59:14 +00:00
|
|
|
|
{
|
2015-05-25 15:29:42 +00:00
|
|
|
|
case LF_QUADRO_ST: filter.format("QLAP=%d", ANNO_PAG); break;
|
|
|
|
|
case LF_QUALA : filter.format("ANNO=%d", ANNO_PAG); break;
|
|
|
|
|
default: break;
|
2010-04-29 15:59:14 +00:00
|
|
|
|
}
|
2015-05-25 15:29:42 +00:00
|
|
|
|
cur.setfilter(filter);
|
2010-04-29 15:59:14 +00:00
|
|
|
|
|
|
|
|
|
const TRecnotype items = cur.items();
|
1998-09-01 14:39:37 +00:00
|
|
|
|
if (items > 0) // Se c'e almeno un record ...
|
|
|
|
|
{
|
2004-07-28 08:34:44 +00:00
|
|
|
|
cur.freeze(true); // Per efficienza congela il cursore
|
1998-09-01 14:39:37 +00:00
|
|
|
|
|
|
|
|
|
// Inizializza record col primo modulo
|
|
|
|
|
TRecord770 rec(rectype);
|
|
|
|
|
int modulo = 1;
|
2002-09-13 14:06:05 +00:00
|
|
|
|
int rigo = 1;
|
|
|
|
|
|
|
|
|
|
rec.set(2, file.cod_fis_dic());
|
|
|
|
|
rec.set(3, modulo);
|
|
|
|
|
|
2006-12-13 16:22:33 +00:00
|
|
|
|
switch (rectype)
|
|
|
|
|
{
|
|
|
|
|
case 'E': rec.set(8, CF_PRODUTTORE); break;
|
|
|
|
|
case 'H': rec.set(9, CF_PRODUTTORE); break;
|
|
|
|
|
default : break;
|
|
|
|
|
}
|
|
|
|
|
|
2002-09-13 14:06:05 +00:00
|
|
|
|
TPrint_section& body = section('B', odd_page);
|
1998-09-01 14:39:37 +00:00
|
|
|
|
|
|
|
|
|
int err = first(); // Deve sempre tornare NOERR
|
|
|
|
|
for (; err == NOERR; err = next())
|
|
|
|
|
{
|
2014-07-30 12:58:29 +00:00
|
|
|
|
// Normalizza cognome e nome delle persone fisiche
|
|
|
|
|
if (cur.relation()->log2ind(LF_ANAG) > 0)
|
|
|
|
|
{
|
|
|
|
|
TLocalisamfile& anag = cur.file(-216); // Anagrafica percipiente
|
|
|
|
|
const TString& ragsoc = anag.get(ANA_RAGSOC);
|
|
|
|
|
const TString& nome = ragsoc.mid(30);
|
|
|
|
|
if (nome.blank() && anag.get_char(ANA_TIPOA) == 'F')
|
|
|
|
|
{
|
|
|
|
|
TToken_string rs(ragsoc, ' '); rs.strip_double_spaces();
|
|
|
|
|
const int pezzi = rs.items();
|
|
|
|
|
|
|
|
|
|
int spc = 0;
|
|
|
|
|
if (pezzi >= 4)
|
|
|
|
|
{
|
|
|
|
|
int spc = rs.find(' ', 0);
|
|
|
|
|
spc = rs.find(' ', spc+1);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
spc = rs.find(' ', 3);
|
|
|
|
|
if (spc <= 5 && rs.starts_with("DE", true) && pezzi >= 3)
|
|
|
|
|
spc = rs.find(' ', spc+1);
|
|
|
|
|
if (spc < 0)
|
|
|
|
|
spc = rs.find(' ', 0);
|
|
|
|
|
}
|
|
|
|
|
if (spc >= 2)
|
|
|
|
|
{
|
|
|
|
|
const TString80 nome = rs.mid(spc+1);
|
|
|
|
|
rs.cut(spc); rs.overwrite(nome, 30, 20);
|
|
|
|
|
anag.put(ANA_RAGSOC, rs);
|
|
|
|
|
if (pezzi == 2) // Salvo solo quando sono sicuro!
|
|
|
|
|
anag.rewrite();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
1998-09-01 14:39:37 +00:00
|
|
|
|
transfer_section(body, rigo, rec, file);
|
|
|
|
|
rigo++;
|
2002-09-13 14:06:05 +00:00
|
|
|
|
if (rigo > rpm)
|
1998-09-01 14:39:37 +00:00
|
|
|
|
{
|
|
|
|
|
// Scrivi record se non vuoto
|
2002-09-13 14:06:05 +00:00
|
|
|
|
if (rec.ha_campi_non_posizionali_compilati())
|
1998-09-01 14:39:37 +00:00
|
|
|
|
file << rec;
|
|
|
|
|
|
2002-09-13 14:06:05 +00:00
|
|
|
|
// Avanza al prossimo modulo ed azzera la riga
|
|
|
|
|
rigo = 1;
|
1998-09-01 14:39:37 +00:00
|
|
|
|
modulo++;
|
|
|
|
|
|
|
|
|
|
rec.azzera_campi_non_posizionali();
|
2002-09-13 14:06:05 +00:00
|
|
|
|
rec.set(3, modulo);
|
1998-09-01 14:39:37 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Ultimo record parzialmente compilato
|
2002-09-13 14:06:05 +00:00
|
|
|
|
if (rec.ha_campi_non_posizionali_compilati())
|
1998-09-01 14:39:37 +00:00
|
|
|
|
file << rec;
|
|
|
|
|
|
2004-07-28 08:34:44 +00:00
|
|
|
|
cur.freeze(false);
|
1998-09-01 14:39:37 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return items;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TForm770::TForm770(const char* name)
|
2008-03-11 15:50:42 +00:00
|
|
|
|
: TForm(name), _sortedcur(NULL)
|
1998-09-01 14:39:37 +00:00
|
|
|
|
{
|
|
|
|
|
const char* key = NULL;
|
|
|
|
|
|
|
|
|
|
switch (TForm::cursor()->file().num())
|
|
|
|
|
{
|
2002-09-13 14:06:05 +00:00
|
|
|
|
case LF_QUALA: key = "CODDITTA|216@->RAGSOC|TIPOA|CODANAGR"; break;
|
1998-09-01 14:39:37 +00:00
|
|
|
|
default : break;
|
|
|
|
|
}
|
|
|
|
|
if (key)
|
|
|
|
|
_sortedcur = new TSorted_cursor(TForm::relation(), key);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TForm770::~TForm770()
|
|
|
|
|
{
|
|
|
|
|
if (_sortedcur)
|
|
|
|
|
delete _sortedcur;
|
|
|
|
|
}
|
|
|
|
|
|
2015-02-24 08:35:08 +00:00
|
|
|
|
class TCache770 : public TObject
|
1998-09-01 14:39:37 +00:00
|
|
|
|
{
|
2015-02-24 08:35:08 +00:00
|
|
|
|
TArray _files;
|
|
|
|
|
TAssoc_array _tables;
|
1998-09-01 14:39:37 +00:00
|
|
|
|
|
2015-02-24 08:35:08 +00:00
|
|
|
|
public:
|
|
|
|
|
const TRectype& get(int num, const char* key);
|
|
|
|
|
const TRectype& get(int num, long key);
|
|
|
|
|
void destroy();
|
|
|
|
|
} _cache770;
|
1998-09-01 14:39:37 +00:00
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
// TCache770
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
const TRectype& TCache770::get(int num, const char* key)
|
|
|
|
|
{
|
|
|
|
|
TRecord_cache* rc = (TRecord_cache*)_files.objptr(num);
|
|
|
|
|
if (rc == NULL)
|
|
|
|
|
{
|
|
|
|
|
rc = new TRecord_cache(num);
|
|
|
|
|
_files.add(rc, num);
|
|
|
|
|
}
|
|
|
|
|
return rc->get(key);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const TRectype& TCache770::get(int num, long key)
|
|
|
|
|
{
|
|
|
|
|
TString16 str; str << key;
|
|
|
|
|
return get(num, str);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TCache770::destroy()
|
|
|
|
|
{
|
|
|
|
|
_files.destroy();
|
|
|
|
|
_tables.destroy();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
// TTrasferimento770
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
2002-09-13 14:06:05 +00:00
|
|
|
|
const char* TTrasferimento770::default_name() const
|
2015-04-29 10:05:31 +00:00
|
|
|
|
{ return "MOD77015"; }
|
2002-09-13 14:06:05 +00:00
|
|
|
|
|
2007-09-17 15:33:04 +00:00
|
|
|
|
bool TTrasferimento770::open(const char* path, char mode, int volume)
|
1998-09-01 14:39:37 +00:00
|
|
|
|
{
|
|
|
|
|
CHECK(mode == 'r' || mode == 'w', "Invalid open mode");
|
|
|
|
|
close();
|
|
|
|
|
|
|
|
|
|
if (path && *path)
|
|
|
|
|
{
|
|
|
|
|
_name = path;
|
|
|
|
|
_name.add(default_name());
|
2007-09-17 15:33:04 +00:00
|
|
|
|
if (volume > 0)
|
|
|
|
|
_name << '_' << volume;
|
1998-09-01 14:39:37 +00:00
|
|
|
|
}
|
|
|
|
|
if (_name.empty())
|
2007-09-17 15:33:04 +00:00
|
|
|
|
{
|
1998-09-01 14:39:37 +00:00
|
|
|
|
_name = default_name();
|
2007-09-17 15:33:04 +00:00
|
|
|
|
if (volume > 0)
|
|
|
|
|
_name << '_' << volume;
|
|
|
|
|
}
|
1998-09-01 14:39:37 +00:00
|
|
|
|
if (mode == 'r')
|
2008-03-26 10:35:00 +00:00
|
|
|
|
_in_stream = new ifstream(_name, ios::in | ios::binary);
|
1998-09-01 14:39:37 +00:00
|
|
|
|
else
|
|
|
|
|
_out_stream = new ofstream(_name, ios::out | ios::binary);
|
|
|
|
|
|
2004-07-28 08:34:44 +00:00
|
|
|
|
return true;
|
1998-09-01 14:39:37 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TTrasferimento770::close()
|
|
|
|
|
{
|
|
|
|
|
if (_in_stream)
|
|
|
|
|
{
|
|
|
|
|
delete _in_stream;
|
|
|
|
|
_in_stream = NULL;
|
|
|
|
|
}
|
|
|
|
|
if (_out_stream)
|
|
|
|
|
{
|
|
|
|
|
delete _out_stream;
|
|
|
|
|
_out_stream = NULL;
|
|
|
|
|
}
|
2004-07-28 08:34:44 +00:00
|
|
|
|
return true;
|
1998-09-01 14:39:37 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TTrasferimento770::write(const TRecord770& rec)
|
|
|
|
|
{
|
|
|
|
|
bool ok = _out_stream != NULL;
|
|
|
|
|
if (ok)
|
|
|
|
|
(*_out_stream) << rec;
|
|
|
|
|
return ok;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TTrasferimento770::read(TRecord770& rec)
|
|
|
|
|
{
|
|
|
|
|
bool ok = _in_stream != NULL && !_in_stream->eof();
|
|
|
|
|
if (ok)
|
|
|
|
|
{
|
|
|
|
|
(*_in_stream) >> rec;
|
|
|
|
|
ok = rec.valid();
|
|
|
|
|
}
|
|
|
|
|
return ok;
|
|
|
|
|
}
|
|
|
|
|
|
2002-09-13 14:06:05 +00:00
|
|
|
|
const TString& TTrasferimento770::read_codfis_dic(const TRectype& rec)
|
|
|
|
|
{
|
2008-03-11 15:50:42 +00:00
|
|
|
|
TToken_string key; // Stringa multiuso
|
2002-09-13 14:06:05 +00:00
|
|
|
|
|
|
|
|
|
key = rec.get(BSE_CODDIC);
|
|
|
|
|
if (key.empty())
|
|
|
|
|
key = rec.get(BSE_CODDITTA);
|
|
|
|
|
|
|
|
|
|
const TRectype& rec_nditte = _cache770.get(LF_NDITTE, key);
|
2002-10-24 10:47:49 +00:00
|
|
|
|
if (rec_nditte.empty())
|
|
|
|
|
{
|
2008-03-11 15:50:42 +00:00
|
|
|
|
error_box(FR("Non esiste la ditta %s"), (const char*)key);
|
2006-12-13 16:22:33 +00:00
|
|
|
|
return EMPTY_STRING;
|
2002-10-24 10:47:49 +00:00
|
|
|
|
}
|
2006-12-13 16:22:33 +00:00
|
|
|
|
_cod_ditta = atol(key);
|
|
|
|
|
_tipoa_dic = rec_nditte.get_char(NDT_TIPOA);
|
|
|
|
|
_codan_dic = rec_nditte.get_long(NDT_CODANAGR);
|
2002-09-13 14:06:05 +00:00
|
|
|
|
|
2008-03-11 15:50:42 +00:00
|
|
|
|
_codatt_dic = rec_nditte.get(NDT_CODATTPREV); // Codice attivita' prevalente
|
|
|
|
|
key.add(_codatt_dic); // key = CODDITTA|CODATTPREV
|
|
|
|
|
const TRectype& attiv = _cache770.get(LF_ATTIV, key);
|
2015-05-25 15:29:42 +00:00
|
|
|
|
const TString& codateco = attiv.get(ATT_CODATECO);
|
|
|
|
|
if (codateco.full())
|
|
|
|
|
_codatt_dic = codateco;
|
|
|
|
|
else
|
|
|
|
|
error_box(TR("Non esiste il codice attivit<69> ATECO"));
|
2008-03-11 15:50:42 +00:00
|
|
|
|
|
2015-04-29 10:05:31 +00:00
|
|
|
|
const TAnagrafica dich(LF_ANAG, _tipoa_dic, _codan_dic);
|
|
|
|
|
if (!dich.ok())
|
2002-10-24 10:47:49 +00:00
|
|
|
|
{
|
2015-04-29 10:05:31 +00:00
|
|
|
|
error_box(TR("Non esiste l'anagrafica del dichiarante"));
|
2006-12-13 16:22:33 +00:00
|
|
|
|
return EMPTY_STRING;
|
2002-10-24 10:47:49 +00:00
|
|
|
|
}
|
2015-04-29 10:05:31 +00:00
|
|
|
|
_codfis_dic = dich.codice_fiscale(); // Codice fiscale del dichiarante
|
2002-09-13 14:06:05 +00:00
|
|
|
|
|
2006-12-13 16:22:33 +00:00
|
|
|
|
return _codfis_dic;
|
|
|
|
|
}
|
|
|
|
|
|
2010-04-29 15:59:14 +00:00
|
|
|
|
TRecnotype TTrasferimento770::conta_certificazioni() const
|
2006-12-13 16:22:33 +00:00
|
|
|
|
{
|
|
|
|
|
TString query;
|
2015-05-25 15:29:42 +00:00
|
|
|
|
query.format("USE %d SELECT ANNO=%d\nFROM CODDITTA=%ld\nTO CODDITTA=%ld",
|
|
|
|
|
LF_QUALA, ANNO_PAG,_cod_ditta, _cod_ditta);
|
2006-12-13 16:22:33 +00:00
|
|
|
|
TISAM_recordset recset(query);
|
2010-04-29 15:59:14 +00:00
|
|
|
|
const TRecnotype nc = recset.items();
|
|
|
|
|
return nc;
|
2006-12-13 16:22:33 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TTrasferimento770::casella_prospetto_st() const
|
|
|
|
|
{
|
|
|
|
|
// Il quadro ST e' il "vecchio" quadro L
|
|
|
|
|
TString query;
|
2010-04-29 15:59:14 +00:00
|
|
|
|
query.format("USE %d\nSELECT QLAP=%d\nFROM CODDITTA=%ld\nTO CODDITTA=%ld",
|
2015-05-25 15:29:42 +00:00
|
|
|
|
LF_QUADRO_ST, ANNO_PAG, _cod_ditta, _cod_ditta);
|
2006-12-13 16:22:33 +00:00
|
|
|
|
TISAM_recordset recset(query);
|
2010-04-29 15:59:14 +00:00
|
|
|
|
const TRecnotype nr = recset.items();
|
|
|
|
|
return nr > 0;
|
2006-12-13 16:22:33 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-06-20 13:23:00 +00:00
|
|
|
|
bool TTrasferimento770::casella_prospetto_sx() const
|
|
|
|
|
{
|
|
|
|
|
// Il quadro SX sono le ritenute versate in eccesso
|
|
|
|
|
TString query;
|
|
|
|
|
query.format("USE %d\nSELECT QLAP=%d\nFROM CODDITTA=%ld\nTO CODDITTA=%ld",
|
2015-05-25 15:29:42 +00:00
|
|
|
|
LF_QUADRO_ST, ANNO_PAG, _cod_ditta, _cod_ditta);
|
2013-06-20 13:23:00 +00:00
|
|
|
|
TISAM_recordset recset(query);
|
|
|
|
|
bool found = false;
|
|
|
|
|
for (bool ok = recset.move_first(); ok && !found; ok = recset.move_next())
|
|
|
|
|
{
|
|
|
|
|
const real verecc = recset.get("QLRITVEREC").as_real();
|
|
|
|
|
found = !verecc.is_zero();
|
|
|
|
|
}
|
|
|
|
|
return found;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-12-13 16:22:33 +00:00
|
|
|
|
bool TTrasferimento770::append_record_b()
|
|
|
|
|
{
|
|
|
|
|
bool ok = false;
|
|
|
|
|
if (save_headers())
|
|
|
|
|
{
|
2010-04-29 15:59:14 +00:00
|
|
|
|
TRecord770 rec('B'); // Compila record di testata B
|
2006-12-13 16:22:33 +00:00
|
|
|
|
rec.set(2, cod_fis_dic());
|
|
|
|
|
rec.set(3, 1); // Modulo (deve essere sempre 1)
|
2010-04-29 15:59:14 +00:00
|
|
|
|
rec.set(7, CF_PRODUTTORE); // CF del produttore Sirio
|
2011-06-28 14:41:29 +00:00
|
|
|
|
|
2015-04-29 10:05:31 +00:00
|
|
|
|
const TAnagrafica dich(LF_ANAG, _tipoa_dic, _codan_dic);
|
|
|
|
|
if (dich.fisica())
|
2006-12-13 16:22:33 +00:00
|
|
|
|
{
|
2015-04-29 10:05:31 +00:00
|
|
|
|
rec.set(13, dich.cognome());
|
|
|
|
|
rec.set(14, dich.nome());
|
|
|
|
|
rec.set(23, dich.comune_nascita());
|
|
|
|
|
rec.set(24, dich.provincia_nascita());
|
|
|
|
|
rec.set(25, dich.data_nascita());
|
|
|
|
|
rec.set(26, dich.sesso());
|
|
|
|
|
rec.set(27, dich.comune_residenza());
|
|
|
|
|
rec.set(28, dich.provincia_residenza());
|
|
|
|
|
rec.set(29, dich.CAP_residenza());
|
|
|
|
|
if (!dich.estero())
|
|
|
|
|
rec.set(30, dich.codice_comune_residenza());
|
|
|
|
|
rec.set(31, dich.indirizzo_residenza());
|
2006-12-13 16:22:33 +00:00
|
|
|
|
}
|
|
|
|
|
|
2015-04-29 10:05:31 +00:00
|
|
|
|
rec.set(19, _codatt_dic);
|
|
|
|
|
|
|
|
|
|
if (dich.giuridica())
|
2006-12-13 16:22:33 +00:00
|
|
|
|
{
|
2015-04-29 10:05:31 +00:00
|
|
|
|
rec.set(15, dich.ragione_sociale());
|
|
|
|
|
|
2006-12-13 16:22:33 +00:00
|
|
|
|
const TRectype& rec_anagiu = _cache770.get(LF_ANAGGIU, _codan_dic);
|
2007-09-17 15:33:04 +00:00
|
|
|
|
rec.set(33, rec_anagiu.get(ANG_NATGIU));
|
|
|
|
|
|
2015-04-29 10:05:31 +00:00
|
|
|
|
rec.set(35, dich.comune_residenza());
|
|
|
|
|
rec.set(36, dich.provincia_residenza());
|
|
|
|
|
rec.set(37, dich.CAP_residenza());
|
|
|
|
|
rec.set(38, dich.codice_comune_residenza());
|
|
|
|
|
rec.set(39, dich.indirizzo_residenza());
|
2007-09-17 15:33:04 +00:00
|
|
|
|
|
|
|
|
|
rec.set(46, rec_anagiu.get(ANG_STATOSOC));
|
|
|
|
|
rec.set(47, rec_anagiu.get(ANG_SITSOC));
|
2006-12-13 16:22:33 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-07-30 12:58:29 +00:00
|
|
|
|
rec.set(75, 1); // Redazione della dichiarazione (sezione I)
|
2010-04-29 15:59:14 +00:00
|
|
|
|
rec.set(76, 0); // Comunicazioni relative a certificazioni lavoro dipendente
|
2008-03-11 15:50:42 +00:00
|
|
|
|
const int autonomi = conta_certificazioni();
|
2013-06-20 13:23:00 +00:00
|
|
|
|
const bool prosp_st = casella_prospetto_st();
|
|
|
|
|
const bool prosp_sx = casella_prospetto_sx();
|
2010-04-29 15:59:14 +00:00
|
|
|
|
rec.set(77, autonomi);
|
|
|
|
|
rec.set(78, autonomi > 0); // casella prospetto SS
|
2013-06-20 13:23:00 +00:00
|
|
|
|
rec.set(79, prosp_st); // casella prospetto ST
|
2010-04-29 15:59:14 +00:00
|
|
|
|
rec.set(80, false); // casella prospetto SV
|
2013-06-20 13:23:00 +00:00
|
|
|
|
rec.set(81, prosp_sx); // casella prospetto SX
|
2011-06-28 14:41:29 +00:00
|
|
|
|
rec.set(82, false); // casella prospetto SY
|
2013-05-27 12:04:47 +00:00
|
|
|
|
|
2015-04-29 10:05:31 +00:00
|
|
|
|
rec.set(94, true); // Firma del dichiarante
|
2011-06-28 14:41:29 +00:00
|
|
|
|
|
2015-04-29 10:05:31 +00:00
|
|
|
|
rec.set(116, 0); // situazioni particolari: vale sempre 0
|
2011-06-28 14:41:29 +00:00
|
|
|
|
|
2007-09-17 15:33:04 +00:00
|
|
|
|
const TRectype& rec_nditte = _cache770.get(LF_NDITTE, _cod_ditta);
|
2015-04-29 10:05:31 +00:00
|
|
|
|
const TAnagrafica rec_rap(LF_ANAG, 'F', rec_nditte.get_long(NDT_RAPPR));
|
|
|
|
|
if (rec_rap.ok())
|
2014-07-30 12:58:29 +00:00
|
|
|
|
{
|
2015-04-29 10:05:31 +00:00
|
|
|
|
rec.set(126, rec_rap.codice_fiscale());
|
2014-07-30 12:58:29 +00:00
|
|
|
|
rec.set(127, rec_nditte.get(NDT_CARRAPP));
|
2015-04-29 10:05:31 +00:00
|
|
|
|
rec.set(131, rec_rap.cognome());
|
|
|
|
|
rec.set(132, rec_rap.nome());
|
|
|
|
|
rec.set(133, rec_rap.sesso());
|
|
|
|
|
rec.set(134, rec_rap.data_nascita());
|
|
|
|
|
rec.set(135, rec_rap.comune_nascita());
|
|
|
|
|
rec.set(136, rec_rap.provincia_nascita());
|
2015-05-25 15:29:42 +00:00
|
|
|
|
|
|
|
|
|
if (rec_rap.comune_nascita().blank())
|
|
|
|
|
cantread_box("dati nascita legale rappresentante");
|
2014-07-30 12:58:29 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
cantread_box("dati del legale rappresentante");
|
2010-04-29 15:59:14 +00:00
|
|
|
|
|
|
|
|
|
// Ignoro la parte "estera"
|
2007-09-17 15:33:04 +00:00
|
|
|
|
|
2006-12-13 16:22:33 +00:00
|
|
|
|
ok = write(rec);
|
|
|
|
|
}
|
|
|
|
|
return ok;
|
2002-09-13 14:06:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
2015-02-24 08:35:08 +00:00
|
|
|
|
// Determina a partire dal codice quadro (LA o ST) il tipo record (H o E) ed il numero di record per modulo (1 o 12)
|
|
|
|
|
// Ritorna il form da cui prelevare i codici (come AUXXX010) da inserire nei tracciati
|
|
|
|
|
TForm770& TTrasferimento770::form(const char* quadro, char& tiporec, int& rpm)
|
|
|
|
|
{
|
2016-02-25 11:33:25 +00:00
|
|
|
|
CHECK(quadro && *quadro != '\0' && quadro[1] != '\0', "Codice quadro non valido");
|
2015-02-24 08:35:08 +00:00
|
|
|
|
|
|
|
|
|
const char* name = NULL;
|
|
|
|
|
switch(quadro[1])
|
|
|
|
|
{
|
|
|
|
|
case 'A': name = "77qla"; tiporec = 'H'; rpm = 1; break;
|
|
|
|
|
case 'T': name = "77qst"; tiporec = 'E'; rpm = 12; break;
|
|
|
|
|
default : name = NULL; break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TForm770* frm = (TForm770*)_form.objptr(name);
|
|
|
|
|
if (frm == NULL)
|
|
|
|
|
{
|
|
|
|
|
frm = new TForm770(name);
|
|
|
|
|
_form.add(name, frm);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return *frm;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
long TTrasferimento770::append_quadro(const char* quadro, long codditta, TProgress_monitor& pi)
|
1998-09-01 14:39:37 +00:00
|
|
|
|
{
|
2002-09-13 14:06:05 +00:00
|
|
|
|
TString str;
|
2008-03-11 15:50:42 +00:00
|
|
|
|
str << TR("Trasferimento quadro ") << quadro << TR(" ditta ") << codditta;
|
1998-09-01 14:39:37 +00:00
|
|
|
|
pi.set_text(str);
|
|
|
|
|
|
|
|
|
|
char tipo;
|
|
|
|
|
int rpm;
|
2015-02-24 08:35:08 +00:00
|
|
|
|
TForm770& frm = form(quadro, tipo, rpm);
|
1998-09-01 14:39:37 +00:00
|
|
|
|
long items = frm.trasfer(codditta, *this, tipo, rpm);
|
|
|
|
|
return items;
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-30 12:58:29 +00:00
|
|
|
|
static real& real_at(TArray& riep, int idx)
|
|
|
|
|
{
|
|
|
|
|
real* r = (real*)riep.objptr(idx);
|
|
|
|
|
if (r == NULL)
|
|
|
|
|
riep.add(r = new real, idx);
|
|
|
|
|
return *r;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TTrasferimento770::riepiloga_ss(const TRecord770& rec, TArray& riep_ss) const
|
2008-03-11 15:50:42 +00:00
|
|
|
|
{
|
|
|
|
|
TString8 code;
|
|
|
|
|
real val;
|
2015-05-25 15:29:42 +00:00
|
|
|
|
for (int i = 0; rec.np_get_real(i, code, val); i++) if (code.starts_with("AU") && code[5] != 'A' && !val.is_zero())
|
2008-03-11 15:50:42 +00:00
|
|
|
|
{
|
|
|
|
|
const TString& key = code.right(3);
|
|
|
|
|
const int num = atoi(key);
|
2015-05-25 15:29:42 +00:00
|
|
|
|
if (num >= 9 && num <= 17)
|
2008-03-11 15:50:42 +00:00
|
|
|
|
{
|
2015-05-25 15:29:42 +00:00
|
|
|
|
real& r = real_at(riep_ss, num-9); // AU_9 -AU_54 -> SS003001
|
|
|
|
|
r += val; // AU_10-AU_55 -> SS003002
|
2013-07-26 15:45:39 +00:00
|
|
|
|
} else
|
2015-05-25 15:29:42 +00:00
|
|
|
|
if (num >= 54 && num <= 62)
|
2013-07-26 15:45:39 +00:00
|
|
|
|
{
|
2015-05-25 15:29:42 +00:00
|
|
|
|
real& r = real_at(riep_ss, num-54);
|
2014-07-30 12:58:29 +00:00
|
|
|
|
r -= val;
|
2008-03-11 15:50:42 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-30 12:58:29 +00:00
|
|
|
|
void TTrasferimento770::riepiloga_sx(const TRecord770& rec, TArray& riep_sx) const
|
2010-04-29 15:59:14 +00:00
|
|
|
|
{
|
|
|
|
|
TString8 code;
|
|
|
|
|
real val;
|
2013-06-20 13:23:00 +00:00
|
|
|
|
for (int i = 0; rec.np_get_real(i, code, val); i++) if (code.starts_with("ST") && !val.is_zero())
|
2010-04-29 15:59:14 +00:00
|
|
|
|
{
|
|
|
|
|
const int rig = atoi(code.mid(2,3));
|
|
|
|
|
const int col = atoi(code.mid(5,3));
|
|
|
|
|
if (rig >= 2 && rig <= 25 && col >= 4 && col <= 5)
|
|
|
|
|
{
|
2014-07-30 12:58:29 +00:00
|
|
|
|
real& r = real_at(riep_sx, 5); // SX004005
|
|
|
|
|
r += val;
|
2010-04-29 15:59:14 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
1998-09-01 14:39:37 +00:00
|
|
|
|
bool TTrasferimento770::split(const char* path)
|
|
|
|
|
{
|
|
|
|
|
close();
|
|
|
|
|
|
2002-09-13 14:06:05 +00:00
|
|
|
|
const long records = fsize(_name) / TOTAL_SIZE;
|
2008-03-11 15:50:42 +00:00
|
|
|
|
TRecnotype totale[26]; memset(totale, 0, sizeof(totale));
|
1998-09-01 14:39:37 +00:00
|
|
|
|
|
|
|
|
|
TRecord770 rec;
|
2007-09-17 15:33:04 +00:00
|
|
|
|
|
|
|
|
|
unsigned long disk_size = 15*1024*1024; // Max 15 Mb per fornitura
|
2015-05-25 15:29:42 +00:00
|
|
|
|
const bool magnetic = ::xvt_fsys_is_floppy_drive(path)!=0;
|
1998-09-01 14:39:37 +00:00
|
|
|
|
if (magnetic)
|
|
|
|
|
{
|
2015-05-25 15:29:42 +00:00
|
|
|
|
if (!yesno_box(FR("Inserire il primo disco del trasferimento nell'unit<69> %s\n"
|
1998-09-01 14:39:37 +00:00
|
|
|
|
"Tutti i dischi devono essere vuoti ed avere la stesso formato.\n"
|
2010-04-29 15:59:14 +00:00
|
|
|
|
"Si desidera iniziare il trasferimento?"), path))
|
2004-07-28 08:34:44 +00:00
|
|
|
|
return false;
|
1998-09-01 14:39:37 +00:00
|
|
|
|
|
2007-09-17 15:33:04 +00:00
|
|
|
|
disk_size = ::xvt_fsys_get_disk_size(path, 'b');
|
1998-09-01 14:39:37 +00:00
|
|
|
|
}
|
2007-09-17 15:33:04 +00:00
|
|
|
|
const long records_per_disk = long(disk_size / TOTAL_SIZE) - 3; // Tolgo A,B,Z
|
|
|
|
|
const int volumes = int((records-1)/records_per_disk)+1;
|
1998-09-01 14:39:37 +00:00
|
|
|
|
|
2015-05-25 15:29:42 +00:00
|
|
|
|
TProgress_monitor pi(records, TR("Generazione file trasferimento"));
|
2002-09-13 14:06:05 +00:00
|
|
|
|
|
1998-09-01 14:39:37 +00:00
|
|
|
|
// Read from start
|
|
|
|
|
open("", 'r');
|
2002-09-13 14:06:05 +00:00
|
|
|
|
|
1998-09-01 14:39:37 +00:00
|
|
|
|
for (int volume = 1; volume <= volumes; volume++)
|
|
|
|
|
{
|
|
|
|
|
if (magnetic && volume > 1)
|
|
|
|
|
{
|
2010-04-29 15:59:14 +00:00
|
|
|
|
if (!yesno_box(FR("Inserire il disco %d di %d:\nSi desidera proseguire il trasferimento?"),
|
1998-09-01 14:39:37 +00:00
|
|
|
|
volume, volumes))
|
|
|
|
|
break;
|
|
|
|
|
}
|
2007-09-17 15:33:04 +00:00
|
|
|
|
|
|
|
|
|
// Specifica volume solo se necessario
|
|
|
|
|
const int v = (volumes > 1 && !magnetic) ? volume : 0;
|
|
|
|
|
TTrasferimento770 outfile(path, 'w', v);
|
2002-09-13 14:06:05 +00:00
|
|
|
|
|
2006-12-13 16:22:33 +00:00
|
|
|
|
if (_save_headers)
|
2010-04-29 15:59:14 +00:00
|
|
|
|
{
|
|
|
|
|
rec.tipo_record('A'); // Compila record di testata A
|
2016-02-25 11:33:25 +00:00
|
|
|
|
rec.set(3, "77S16"); // Codice fornitura
|
2010-04-29 15:59:14 +00:00
|
|
|
|
rec.set(4, 1); // Tipo fornitore 01 = Soggetto che invia la propria dichiarazione
|
|
|
|
|
rec.set(5, cod_fis_dic()); // Codice fiscale del fornitore
|
2007-09-17 15:33:04 +00:00
|
|
|
|
if (volumes > 1)
|
2006-12-13 16:22:33 +00:00
|
|
|
|
{
|
|
|
|
|
rec.set(7, volume);
|
|
|
|
|
rec.set(8, volumes);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
rec.set(7, 0);
|
|
|
|
|
rec.set(8, 0);
|
|
|
|
|
}
|
2002-09-13 14:06:05 +00:00
|
|
|
|
|
2006-12-13 16:22:33 +00:00
|
|
|
|
outfile << rec; // Scrive record testata
|
|
|
|
|
}
|
|
|
|
|
|
1998-09-01 14:39:37 +00:00
|
|
|
|
long written = 0;
|
2002-09-13 14:06:05 +00:00
|
|
|
|
|
2010-04-29 15:59:14 +00:00
|
|
|
|
TArray riep_ss, riep_sx;
|
2008-03-11 15:50:42 +00:00
|
|
|
|
|
2002-09-13 14:06:05 +00:00
|
|
|
|
if (records > 0)
|
1998-09-01 14:39:37 +00:00
|
|
|
|
{
|
2002-09-13 14:06:05 +00:00
|
|
|
|
while (read(rec))
|
1998-09-01 14:39:37 +00:00
|
|
|
|
{
|
2015-05-25 15:29:42 +00:00
|
|
|
|
pi.add_status();
|
2002-09-13 14:06:05 +00:00
|
|
|
|
|
|
|
|
|
const char tipo_rec = rec.tipo_record();
|
2010-04-29 15:59:14 +00:00
|
|
|
|
if (tipo_rec <= 'A' || tipo_rec == 'F' || tipo_rec == 'J' || tipo_rec >= 'Z')
|
2002-09-13 14:06:05 +00:00
|
|
|
|
continue;
|
2010-04-29 15:59:14 +00:00
|
|
|
|
|
|
|
|
|
if (_save_headers && tipo_rec > 'E' && riep_sx.items() > 0)
|
|
|
|
|
{
|
|
|
|
|
TRecord770 recf('F');
|
|
|
|
|
recf.set(2, cod_fis_dic());
|
|
|
|
|
recf.set(3, 1);
|
|
|
|
|
recf.set(8, CF_PRODUTTORE);
|
|
|
|
|
FOR_EACH_ARRAY_ITEM(riep_sx, i, obj)
|
|
|
|
|
{
|
|
|
|
|
const real* val = (const real*)obj;
|
|
|
|
|
if (val != NULL)
|
|
|
|
|
{
|
|
|
|
|
TString8 code;
|
|
|
|
|
code.format("SX004%03d", i);
|
|
|
|
|
recf.np_put(code, *val);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
outfile << recf;
|
|
|
|
|
totale['F'-'A']++; // Praticamente vale sempre 1
|
2014-07-30 12:58:29 +00:00
|
|
|
|
riep_sx.destroy(); // La prossima volta non deve salvare nulla
|
2010-04-29 15:59:14 +00:00
|
|
|
|
}
|
2002-09-13 14:06:05 +00:00
|
|
|
|
|
1998-09-01 14:39:37 +00:00
|
|
|
|
outfile << rec;
|
|
|
|
|
written++;
|
2002-09-13 14:06:05 +00:00
|
|
|
|
|
2014-07-30 12:58:29 +00:00
|
|
|
|
// Tengo traccia degli eventuali riepiloghi
|
2008-03-11 15:50:42 +00:00
|
|
|
|
if (_save_headers)
|
|
|
|
|
{
|
|
|
|
|
totale[tipo_rec - 'A']++;
|
2014-07-30 12:58:29 +00:00
|
|
|
|
switch (tipo_rec)
|
|
|
|
|
{
|
|
|
|
|
case 'E': riepiloga_sx(rec, riep_sx); break;
|
|
|
|
|
case 'H': riepiloga_ss(rec, riep_ss); break;
|
|
|
|
|
default : break;
|
|
|
|
|
}
|
2008-03-11 15:50:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-09-17 15:33:04 +00:00
|
|
|
|
if (written >= records_per_disk)
|
2002-09-13 14:06:05 +00:00
|
|
|
|
break;
|
1998-09-01 14:39:37 +00:00
|
|
|
|
}
|
2002-09-13 14:06:05 +00:00
|
|
|
|
}
|
2006-12-13 16:22:33 +00:00
|
|
|
|
|
|
|
|
|
if (_save_headers)
|
|
|
|
|
{
|
2008-03-11 15:50:42 +00:00
|
|
|
|
// Compila record di riepilogo SS
|
2014-07-30 12:58:29 +00:00
|
|
|
|
if (!riep_ss.empty())
|
2008-03-11 15:50:42 +00:00
|
|
|
|
{
|
|
|
|
|
rec.tipo_record('J');
|
|
|
|
|
rec.set(2, cod_fis_dic());
|
|
|
|
|
rec.set(3, 1);
|
|
|
|
|
rec.set(8, CF_PRODUTTORE);
|
|
|
|
|
FOR_EACH_ARRAY_ITEM(riep_ss, i, obj)
|
|
|
|
|
{
|
|
|
|
|
const real* val = (const real*)obj;
|
2014-07-30 12:58:29 +00:00
|
|
|
|
if (val != NULL && !val->is_zero())
|
2008-03-11 15:50:42 +00:00
|
|
|
|
{
|
|
|
|
|
TString8 code;
|
2014-07-30 12:58:29 +00:00
|
|
|
|
code.format("SS003%03d", i+1); // i=0 -> SS0003001 -> AUXXX027-AUXXX047
|
2010-04-29 15:59:14 +00:00
|
|
|
|
rec.np_put(code, *val);
|
2008-03-11 15:50:42 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
outfile << rec;
|
2010-04-29 15:59:14 +00:00
|
|
|
|
totale['J'-'A']++; // Praticamente vale sempre 1
|
2008-03-11 15:50:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
2006-12-13 16:22:33 +00:00
|
|
|
|
// Compila record di coda
|
|
|
|
|
rec.tipo_record('Z');
|
|
|
|
|
rec.set(3, totale['B'-'A']); // Totale B
|
2012-06-07 16:00:00 +00:00
|
|
|
|
rec.set(4, totale['D'-'A']); // Totale D
|
2010-04-29 15:59:14 +00:00
|
|
|
|
rec.set(5, totale['E'-'A']); // Totale E
|
|
|
|
|
rec.set(6, totale['F'-'A']); // Totale F
|
|
|
|
|
rec.set(7, totale['G'-'A']); // Totale G
|
|
|
|
|
rec.set(8, totale['H'-'A']); // Totale H
|
2012-06-07 16:00:00 +00:00
|
|
|
|
rec.set(9, totale['I'-'A']); // Totale I
|
|
|
|
|
rec.set(10,totale['J'-'A']); // Totale J
|
2002-09-13 14:06:05 +00:00
|
|
|
|
|
2006-12-13 16:22:33 +00:00
|
|
|
|
// Scrive record di coda
|
|
|
|
|
outfile << rec;
|
|
|
|
|
}
|
2002-09-13 14:06:05 +00:00
|
|
|
|
}
|
2004-07-28 08:34:44 +00:00
|
|
|
|
return true;
|
1998-09-01 14:39:37 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Cancella il file
|
|
|
|
|
void TTrasferimento770::remove()
|
|
|
|
|
{
|
|
|
|
|
close();
|
|
|
|
|
::remove(_name);
|
|
|
|
|
}
|
|
|
|
|
|
2007-09-17 15:33:04 +00:00
|
|
|
|
TTrasferimento770::TTrasferimento770(const char* path, char mode, int volume)
|
2015-05-25 15:29:42 +00:00
|
|
|
|
: _in_stream(NULL), _out_stream(NULL), _save_headers(false), _centesimi(false)
|
1998-09-01 14:39:37 +00:00
|
|
|
|
{
|
2007-09-17 15:33:04 +00:00
|
|
|
|
open(path, mode, volume);
|
1998-09-01 14:39:37 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TTrasferimento770::~TTrasferimento770()
|
|
|
|
|
{
|
|
|
|
|
close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
// main
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
class TTransfer770_msk : public TAutomask
|
|
|
|
|
{
|
|
|
|
|
protected:
|
|
|
|
|
virtual bool on_field_event(TOperable_field& of, TField_event fe, long jolly);
|
|
|
|
|
|
2002-09-13 14:06:05 +00:00
|
|
|
|
public:
|
1998-09-16 10:07:53 +00:00
|
|
|
|
TTransfer770_msk();
|
2015-05-25 15:29:42 +00:00
|
|
|
|
~TTransfer770_msk();
|
1998-09-01 14:39:37 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
bool TTransfer770_msk::on_field_event(TOperable_field& of, TField_event fe, long jolly)
|
|
|
|
|
{
|
|
|
|
|
switch (of.dlg())
|
|
|
|
|
{
|
|
|
|
|
case F_PATH:
|
|
|
|
|
if (fe == fe_modify || fe == fe_close)
|
|
|
|
|
{
|
|
|
|
|
TFilename name = of.get();
|
|
|
|
|
if (!name.exist())
|
2014-07-30 12:58:29 +00:00
|
|
|
|
return cantread_box(name);
|
1998-09-01 14:39:37 +00:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
2004-07-28 08:34:44 +00:00
|
|
|
|
return true;
|
1998-09-01 14:39:37 +00:00
|
|
|
|
}
|
|
|
|
|
|
1998-09-16 10:07:53 +00:00
|
|
|
|
TTransfer770_msk::TTransfer770_msk() : TAutomask("777100a")
|
|
|
|
|
{
|
2015-05-25 15:29:42 +00:00
|
|
|
|
set(F_ANNOPAG, ANNO_PAG);
|
|
|
|
|
set(F_ANNODIC, ANNO_PAG+1);
|
|
|
|
|
set(F_NOHEADERS,ini_get_bool(CONFIG_STUDIO, "77", "SaveDataOnly", false));
|
|
|
|
|
set(F_PATH, ini_get_string(CONFIG_STUDIO, "77", "SavePath"));
|
|
|
|
|
long ditta1 = ini_get_int (CONFIG_STUDIO, "77", "SaveFirm1", 0);
|
|
|
|
|
long ditta2 = ini_get_int (CONFIG_STUDIO, "77", "SaveFirm2", 0);
|
|
|
|
|
if (ditta1 <= 0 || ditta2 <= 0)
|
2010-04-29 15:59:14 +00:00
|
|
|
|
{
|
2015-05-25 15:29:42 +00:00
|
|
|
|
TPointer_array d;
|
|
|
|
|
prefix().firms(d);
|
|
|
|
|
if (!d.empty())
|
|
|
|
|
{
|
|
|
|
|
if (ditta1 <= 0)
|
|
|
|
|
ditta1 = d.get_long(0);
|
|
|
|
|
if (ditta2 < ditta1)
|
|
|
|
|
ditta2 = d.get_long(d.last());
|
|
|
|
|
}
|
2010-04-29 15:59:14 +00:00
|
|
|
|
}
|
2015-05-25 15:29:42 +00:00
|
|
|
|
set(F_DADITTA, ditta1);
|
|
|
|
|
set(F_ADITTA, ditta2);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TTransfer770_msk::~TTransfer770_msk()
|
|
|
|
|
{
|
|
|
|
|
ini_set_bool (CONFIG_STUDIO, "77", "SaveDataOnly",get_bool(F_NOHEADERS));
|
|
|
|
|
ini_set_string(CONFIG_STUDIO, "77", "SavePath", get(F_PATH));
|
|
|
|
|
ini_set_int (CONFIG_STUDIO, "77", "SaveFirm1", get_long(F_DADITTA));
|
|
|
|
|
ini_set_int (CONFIG_STUDIO, "77", "SaveFirm2", get_long(F_ADITTA));
|
1998-09-16 10:07:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
1998-09-01 14:39:37 +00:00
|
|
|
|
class TTransfer770_app : public TSkeleton_application
|
|
|
|
|
{
|
|
|
|
|
protected:
|
|
|
|
|
virtual void main_loop();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
void TTransfer770_app::main_loop()
|
|
|
|
|
{
|
|
|
|
|
TTransfer770_msk m;
|
|
|
|
|
|
|
|
|
|
while (m.run() == K_ENTER)
|
|
|
|
|
{
|
|
|
|
|
TFilename tmp; tmp.tempdir();
|
|
|
|
|
TTrasferimento770 t(tmp, 'w');
|
2015-05-25 15:29:42 +00:00
|
|
|
|
t.save_headers(!m.get_bool(F_NOHEADERS));
|
2015-02-24 08:35:08 +00:00
|
|
|
|
t.set_cent_mode(m.get_bool(F_CENT));
|
1998-09-01 14:39:37 +00:00
|
|
|
|
|
|
|
|
|
TRelation rel_base(LF_BASE);
|
|
|
|
|
TRectype da_rec(LF_BASE), a_rec(LF_BASE);
|
|
|
|
|
da_rec.put(BSE_CODDITTA, m.get(F_DADITTA));
|
|
|
|
|
a_rec.put(BSE_CODDITTA, m.get(F_ADITTA));
|
1998-09-16 10:07:53 +00:00
|
|
|
|
|
2008-03-11 15:50:42 +00:00
|
|
|
|
TString16 filter;
|
2010-04-29 15:59:14 +00:00
|
|
|
|
/*
|
|
|
|
|
filter << '(' << BSE_ANNODIC << '=' << m.get(F_ANNO) << ")||"
|
|
|
|
|
<< '(' << BSE_ANNODIC << "=0)";
|
|
|
|
|
*/
|
1998-09-16 10:07:53 +00:00
|
|
|
|
TCursor cur_base(&rel_base, filter, 1, &da_rec, &a_rec);
|
2010-04-29 15:59:14 +00:00
|
|
|
|
const TRecnotype items = cur_base.items();
|
1998-09-01 14:39:37 +00:00
|
|
|
|
cur_base.freeze();
|
2010-04-29 15:59:14 +00:00
|
|
|
|
|
2015-02-24 08:35:08 +00:00
|
|
|
|
if (items > 0)
|
1998-09-01 14:39:37 +00:00
|
|
|
|
{
|
2015-02-24 08:35:08 +00:00
|
|
|
|
TProgress_monitor pi(items, TR("Generazione file di trasferimento"));
|
|
|
|
|
for (cur_base = 0; cur_base.ok(); ++cur_base)
|
|
|
|
|
{
|
|
|
|
|
const TRectype& base = cur_base.curr();
|
|
|
|
|
const long codditta = base.get_long(BSE_CODDITTA);
|
|
|
|
|
t.read_codfis_dic(base);
|
1998-09-01 14:39:37 +00:00
|
|
|
|
|
2015-02-24 08:35:08 +00:00
|
|
|
|
t.append_record_b();
|
|
|
|
|
t.append_quadro("ST", codditta, pi);
|
|
|
|
|
t.append_quadro("LA", codditta, pi);
|
2015-04-29 10:05:31 +00:00
|
|
|
|
if (!pi.add_status())
|
|
|
|
|
break;
|
2015-02-24 08:35:08 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
1998-09-01 14:39:37 +00:00
|
|
|
|
|
2015-02-24 08:35:08 +00:00
|
|
|
|
tmp = m.get(F_PATH);
|
2014-07-30 12:58:29 +00:00
|
|
|
|
if (t.split(tmp))
|
|
|
|
|
{
|
|
|
|
|
tmp.add(t.default_name());
|
|
|
|
|
TString msg; msg << TR("E' stato generato il file ") << tmp;
|
|
|
|
|
xvt_dm_popup_message(msg);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
tmp.add(t.default_name());
|
|
|
|
|
cantwrite_box(tmp);
|
|
|
|
|
}
|
1998-09-01 14:39:37 +00:00
|
|
|
|
t.remove();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int m777100(int argc, char* argv[])
|
|
|
|
|
{
|
|
|
|
|
TTransfer770_app app;
|
2015-02-24 08:35:08 +00:00
|
|
|
|
app.run(argc, argv, TR("Invio 770"));
|
1998-09-01 14:39:37 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|