campo-sirio/tc/tc0900.cpp
alex 727c7f793b Patch level : 10.0 710
Files correlati     : tc0.exe
Ricompilazione Demo : [ ]
Commento

Convesrione ditte Teamsystem


git-svn-id: svn://10.65.10.50/trunk@20383 c028cbd2-c16b-5b4b-a496-9718f37d4682
2010-04-27 15:11:12 +00:00

1106 lines
29 KiB
C++
Executable File

#include "tc0.h"
#include "tc0900a.h"
#include <applicat.h>
#include <automask.h>
#include <config.h>
#include <defmask.h>
#include <dongle.h>
#include <lffiles.h>
#include <netsock.h>
#include <prefix.h>
#include <progind.h>
#include <relation.h>
#include <reprint.h>
#include <reputils.h>
#include <tabutil.h>
#include <urldefid.h>
#include <utility.h>
#include <statbar.h>
#include <clifo.h>
#include <causali.h>
#include <pconti.h>
#include "tc0701.h"
///////////////////////////////////////////////////////////
// TSel_sheet
///////////////////////////////////////////////////////////
class TSel_sheet : public TArray_sheet
{
public:
TSel_sheet();
};
TSel_sheet::TSel_sheet()
: TArray_sheet(-1, -1, -4, -4, TR("Selezione files"),
HR("@1|N.@5|Nome@20|EOD@7|EOX@7|Lunghezza|Descrizione@43|Flags@7"), 0x8)
{
add_button(-1, "", 0, 1); // Separatore
add_button(DLG_INFO, TR("Info"), K_F2, BMP_INFO);
add_button(DLG_HELP, TR("Help"), K_F1, BMP_HELP);
xvt_toolbar_set_last_tool(toolbar(), DLG_QUIT);
}
///////////////////////////////////////////////////////////
// TConvert_mask
///////////////////////////////////////////////////////////
class TConvert_mask : public TAutomask
{
TSel_sheet* _selsheet;
short _log2row[500];
private:
void serialize(bool bSave);
protected:
bool on_field_event(TOperable_field& o, TField_event e, long jolly);
public:
TSel_sheet& selsheet() { CHECK(_selsheet != NULL, TR("NULL selection mask")); return *_selsheet;}
const bool to_convert(int logicnum) const { return _selsheet->checked(_log2row[logicnum]);}
const bool converted(int logicnum) const { return !to_convert(logicnum);}
void set_to_convert(int logicnum) { _selsheet->check(_log2row[logicnum]);}
void set_converted(int logicnum) { _selsheet->check(_log2row[logicnum], false);}
void build_sheet();
void add_sheet_row(int logicnum);
TConvert_mask();
virtual ~TConvert_mask();
};
const long TGm2ricl(char & t, int gr, int co)
{
long codricl = 0;
if (gr > 0)
{
TLocalisamfile riclpdc(LF_RICLPDC);
riclpdc.put("TIPORIC", "TSCONTI");
riclpdc.put("GRUPPO", gr);
riclpdc.put("CONTO", co);
if (riclpdc.read(_isgteq) == NOERR && riclpdc.get_int("GRUPPO") == gr)
{
if (co == 0)
codricl = atol(riclpdc.get("CODICE").sleft(2)) * 100000L;
else
codricl = atol(riclpdc.get("CODICE").sleft(4)) * 1000;
}
}
return codricl;
}
enum TConv_funcs { _conti, _tabella, _clifor, _contanal } ;
class TField_info : public TObject
{
TToken_string _fieldname;
TConv_funcs _func;
TString8 _table;
TString8 _TStable;
public:
TToken_string & fieldname() { return _fieldname;}
TConv_funcs func() const { return _func;}
const TString & table() const { return _table;}
const TString & TStable() const { return _TStable;}
TField_info(const char * fieldname, TConv_funcs func = _conti, const char * table = "", const char * TStable = "") :
_fieldname(fieldname), _func(func), _table(table), _TStable(TStable) {}
virtual ~TField_info() {}
};
class TConvert_archives : public TSkeleton_application
{
TTSRiclassifica_cache * _tabelle;
TLog_report * _log;
long _offsetcli;
long _offsetfor;
TConvert_mask * _m;
TFilename _srcdir;
TFilename _dstdir;
bool _tabcomconverted;
bool _tabconverted;
virtual bool create();
virtual bool destroy();
void convert(bool comtables);
const TString & scod2ricl(const char* tab, const TString& cod);
const long bill2ricl(char t, int gr, int co, long so) { return TSbill2ricl(t, gr, co, so); }
const long gm2ricl(char t, int gr, int co) { return TGm2ricl(t, gr, co); }
bool convert_clifo(char t, long & codcf);
bool convert_field(TRectype & rec, TField_info & finfo, TString & msg);
void convert_file(int logicnum, TArray & fieldlist);
void convert_table(const char * tablename, TArray & fieldlist, bool first = false);
bool copy_file(const TFilename& src, const TFilename& dst, const int preflen) const;
void save_or_restore_file(int logicnum);
protected:
virtual void main_loop();
public:
TConvert_archives() : _offsetcli(0L), _offsetfor(0L) {}
};
TConvert_archives& app() { return (TConvert_archives&)main_app(); }
///////////////////////////////////////////////////////////
// TConvert_mask
///////////////////////////////////////////////////////////
TConvert_mask::TConvert_mask() : TAutomask("tc0900a")
{
serialize(false);
_selsheet = new TSel_sheet;
build_sheet();
}
void TConvert_mask::add_sheet_row(int logicnum)
{
TToken_string riga;
TDir cdir;
cdir.get(logicnum, _nolock, _nordir, _sysdirop);
riga = " ";
riga.add(logicnum);
riga.add(cdir.name());
riga.add(cdir.eod());
riga.add(cdir.eox());
riga.add((int)cdir.len());
riga.add(cdir.des());
riga.add(cdir.flags());
const int row = _selsheet->add(riga);
_log2row[logicnum]= row;
}
void TConvert_mask::build_sheet()
{
_selsheet->destroy();
add_sheet_row(LF_TABCOM);
add_sheet_row(LF_TAB);
add_sheet_row(LF_NDITTE);
add_sheet_row(LF_INDSP);
add_sheet_row(LF_CFVEN);
add_sheet_row(LF_PCON);
add_sheet_row(LF_CLIFO);
add_sheet_row(LF_SALDI);
add_sheet_row(LF_ALLEG);
add_sheet_row(LF_MOV);
add_sheet_row(LF_RMOV);
add_sheet_row(LF_RMOVIVA);
add_sheet_row(LF_CAUSALI);
add_sheet_row(LF_RCAUSALI);
add_sheet_row(LF_PARTITE);
add_sheet_row(LF_SCADENZE);
add_sheet_row(LF_PAGSCA);
add_sheet_row(LF_EFFETTI);
add_sheet_row(LF_CESS);
add_sheet_row(LF_DOC);
add_sheet_row(LF_RIGHEDOC);
add_sheet_row(LF_ANAMAG);
add_sheet_row(LF_CONDV);
add_sheet_row(LF_RCONDV);
add_sheet_row(LF_TABREG);
add_sheet_row(LF_MOVANA);
add_sheet_row(LF_RMOVANA);
add_sheet_row(LF_MOVMAG);
add_sheet_row(LF_AGENTI);
add_sheet_row(LF_PROVV);
add_sheet_row(LF_INTRA);
add_sheet_row(LF_RIEPRETT);
add_sheet_row(LF_CESPI);
add_sheet_row(LF_COLLCES);
add_sheet_row(LF_RIP);
add_sheet_row(LF_RRIP);
add_sheet_row(LF_SALDANA);
add_sheet_row(LF_LETINT);
add_sheet_row(LF_PANAPDC);
add_sheet_row(LF_RICLPDC);
add_sheet_row(LF_CLIFOGIAC);
const int rows = _selsheet->items();
for (int i = 0; i < rows; i++)
{
TToken_string & row = _selsheet->row(i);
const int logicnum = row.get_int(1);
_selsheet->check(i, ini_get_bool(CONFIG_DITTA, "tc", "file2conv", true, i));
}
}
TConvert_mask::~TConvert_mask()
{
const int rows = _selsheet->items();
for (int i = 0; i < rows; i++)
{
TToken_string & row = _selsheet->row(i);
const int logicnum = row.get_int(1);
ini_set_bool(CONFIG_DITTA, "tc", "file2conv", _selsheet->checked(i), i);
}
delete _selsheet;
serialize(true);
}
bool TConvert_mask::on_field_event(TOperable_field& f, TField_event e, long jolly)
{
switch (f.dlg())
{
//giochetto per avere la lista dei files validi nella directory di trasferimento!
case DLG_SELECT:
if (e == fe_button)
_selsheet->run();
break;
default:
break;
}
return true;
}
void TConvert_mask::serialize(bool bSave)
{
const char* defpar = "tc";
TConfig ini(CONFIG_DITTA, defpar);
for (int i = fields()-1; i >= 0; i--)
{
TMask_field& f = fld(i);
const TFieldref* fr = f.field();
if (fr != NULL)
{
if (bSave)
fr->write(ini, defpar, f.get());
else
f.set(fr->read(ini, defpar));
}
}
}
///////////////////////////////////////////////////////////
// TConvert_archives
///////////////////////////////////////////////////////////
bool TConvert_archives::create()
{
TLocalisamfile clifo(LF_CLIFO);
_tabelle = new TTSRiclassifica_cache ;
clifo.put(CLI_TIPOCF, "C");
clifo.put(CLI_CODCF, 1000000L);
if (clifo.read() == NOERR)
{
_offsetcli = clifo.get_long(CLI_CODCF);
clifo.prev();
long firstcli = clifo.get_long(CLI_CODCF) + 1;
if (firstcli > _offsetcli)
firstcli = 1;
_offsetcli -= firstcli;
}
clifo.put(CLI_TIPOCF, "F");
clifo.put(CLI_CODCF, 1000000L);
if (clifo.read() == NOERR)
{
_offsetfor = clifo.get_long(CLI_CODCF);
clifo.prev();
long firstfor = clifo.get_long(CLI_CODCF) + 1;
if (firstfor > _offsetcli)
firstfor = 1;
_offsetcli -= firstfor;
}
_log = new TLog_report("Conversione Archivi CAMPO");
return TSkeleton_application::create();
}
bool TConvert_archives::destroy()
{
delete _tabelle;
delete _log;
return TSkeleton_application::destroy();
}
const TString & TConvert_archives::scod2ricl(const char* tab, const TString& cod)
{
TString & codricl = get_tmp_string();
if (cod.full())
codricl = _tabelle->sdecode(tab, cod);
return codricl;
}
bool TConvert_archives::convert_clifo(char t, long & codcf)
{
bool converted = false;
if (codcf >= 1000000L)
{
codcf -= t == 'C' ? _offsetcli : _offsetfor;
converted = true;
}
return converted;
}
bool TConvert_archives::convert_field(TRectype & rec, TField_info & finfo, TString & msg)
{
bool converted = false;
if (finfo.fieldname().full())
{
TToken_string & fname = finfo.fieldname();
switch (finfo.func())
{
case _conti :
{
const char * ftipo = fname.get(0);
char t = 'X';
if (ftipo && *ftipo)
t = rec.get(ftipo)[0];
int gr = rec.get_int(fname.get());
if (gr == 0)
return true;
int co = rec.get_int(fname.get());
if (t == 'X')
{
TToken_string key;
key.add(gr);
key.add(co);
t = cache().get(LF_PCON, key, PCN_TMCF)[0];
}
const char * fso = fname.get();
long so = 0L;
if (fso && *fso)
so = rec.get_long(fso);
long ricl = bill2ricl(t, gr, co, so);
if (ricl == 0 && so == 0)
ricl = gm2ricl(t, gr, co);
if (ricl > 0)
{
so = ricl % 1000;
if (fso && *fso)
{
if (t <= ' ' || convert_clifo(t, so))
rec.put(fso, so);
}
if (rec.num() == LF_PCON && so != 0)
{
const TRectype & tab = cache().get("&TCO", format("&07ld", ricl));
if (!tab.empty())
rec.put(PCN_DESCR, tab.get("S0"));
}
ricl /= 1000;
co = ricl % 100;
gr = ricl / 100;
rec.put(fname.get(1), gr);
rec.put(fname.get(), co);
converted = true;
}
else
{
if (msg.full())
_log->log(0, msg);
msg.format(FR("Campi %s - %s - %s : valore %d - %d - %ld decodifica assente"),
(const char *) fname.get(1),
(const char *) fname.get(2),
(const char *) fname.get(3),
gr, co, so);
_log->log(2, msg);
msg.cut(0);
}
}
break;
case _tabella :
{
const TFieldref fr(fname, 0);
const bool subsc = fname == "S3[1,4]";
const bool reg = finfo.table() == "REG";
TString val = fr.read(rec);
if (val.blank())
return true;
if (reg)
{
TString4 v = val.mid(4);
v = scod2ricl(finfo.table(), v);
if (v.full())
{
val = val.left(4);
val << v;
}
else
val.cut(0);
}
else
val = scod2ricl(finfo.table(), val);
if (val.full())
{
fr.write(val, rec);
converted = true;
if (finfo.TStable().full())
{
const TRectype & tab = cache().get(finfo.TStable(), val);
if (!tab.empty())
{
if (rec.num() == LF_CAUSALI)
rec.put(CAU_DESCR, tab.get("S0"));
else
rec.put("S0", tab.get("S0"));
}
}
}
else
{
if (msg.full())
_log->log(0, msg);
TString msg; msg.format(FR("Campo %s : valore %s decodifica assente"), (const char *) fname, fr.read(rec));
_log->log(2, msg);
msg.cut(0);
}
}
break;
case _clifor :
{
char t = ' ';
const TString& ftipo = fname.get(0);
if (ftipo.starts_with("\""))
t = ftipo[1];
else
t = rec.get(ftipo)[0];
const TString & fcod = fname.get(1);
long codcf = rec.get_long(fcod);
if (codcf == 0L)
return true;
const long oldcf = codcf;
converted = true;
if (convert_clifo(t, codcf))
{
rec.put(fcod, codcf);
if (rec.num() == LF_CLIFO)
{
TString msg; msg.format(FR("Convertito il cliente %ld in %ld"), oldcf, codcf);
_log->log(0, msg);
}
}
}
break;
case _contanal :
{
TString val = rec.get(fname);
int gr = atoi(val.left(3));
if (gr == 0)
return true;
int co = atoi(val.mid(3,3));
long so = atol(val.mid(6,6));
char t = ' ';
long ricl = bill2ricl(t, gr, co, so);
if (ricl > 0)
{
so = ricl % 1000;
ricl /= 1000;
co = ricl % 100;
gr = ricl / 100;
val.format("%03d%03d%06ld", gr, co ,so);
rec.put(fname, val);
}
}
break;
default :
break;
}
}
return converted;
}
bool TConvert_archives::copy_file(const TFilename& src, const TFilename& dst, const int preflen) const
{
// Crea la cartella di destinazione se necessario
TFilename dstfile(dst);
TFilename fname = src.mid(preflen);
dstfile << fname;
const char* dstdir = dstfile.path();
if (*dstdir && !xvt_fsys_mkdir(dstdir))
return error_box(FR("Impossibile creare la cartella %s"), dst.path());
// Copia veramente il file
return ::fcopy(src, dstfile);
}
void TConvert_archives::save_or_restore_file(int logicnum)
{
TFilename dst(_dstdir);
TFilename fn(prefix().get_filename(logicnum));
TString_array res;
fn = fn.mid(_srcdir.len());
dst << fn << ".dbf";
if (fexist(dst))
{
dst.ext("*");
list_files(dst, res);
FOR_EACH_ARRAY_ROW(res, r, str)
copy_file(*str, _srcdir, _dstdir.len());
}
else
{
TFilename src(_srcdir);
src << fn;
src.ext("*");
list_files(src, res);
FOR_EACH_ARRAY_ROW(res, r, str)
copy_file(*str, _dstdir, _srcdir.len());
}
}
void TConvert_archives::convert_file(int logicnum, TArray & fieldlist)
{
if (_m->converted(logicnum))
return;
TLocalisamfile f(logicnum);
TCursor c(new TRelation(logicnum));
TRectype rec(c.curr());
TRectype old(rec);
TString key;
TString msg;
msg.format(FR("Conversione file %d - %s"), logicnum, f.description());
save_or_restore_file(logicnum);
_log->log(0, msg);
const int items = c.items();
TProgind p(items, msg);
c.freeze();
for (c = 0L; !p.iscancelled() && c.pos() < items; ++c)
{
p.addstatus(1L);
bool converted = false;
rec = c.curr();
key = rec.key();
msg.format(FR("Record %ld - Chiave %s"), c.relation()->lfile().recno(), (const char *) key);
FOR_EACH_ARRAY_ITEM(fieldlist, r, obj)
{
TField_info & finfo = (TField_info &) *obj;
converted |= convert_field(rec, finfo, msg);
}
if (converted)
{
if (key != c.curr().key())
{
old = c.curr();
f.curr() = rec;
f.write();
f.curr() = old;
f.remove();
}
else
{
f.curr() = rec;
f.rewrite();
}
}
}
_m->set_converted(logicnum);
}
void TConvert_archives::convert_table(const char * tablename, TArray & fieldlist, bool first)
{
TTable t(tablename);
TCursor c(new TRelation(tablename));
TRectype rec(c.curr());
TRectype old(rec);
TString key;
TString msg;
int logicnum = tablename[0]== '%' ? LF_TABCOM : LF_TAB;
if (_m->converted(logicnum))
return;
msg.format(FR("Conversione Tabella %s - %s"), tablename, t.description());
if (first)
save_or_restore_file(logicnum);
_log->log(0, msg);
const int items = c.items();
TProgind p(items, msg);
c.freeze();
for (c = 0L; !p.iscancelled() && c.pos() < items; ++c)
{
p.addstatus(1L);
bool converted = false;
rec = c.curr();
key = rec.key();
msg.format(FR("Record %ld - Chiave %s"), t.recno(), (const char *) key);
FOR_EACH_ARRAY_ITEM(fieldlist, r, obj)
{
TField_info & finfo = (TField_info &) *obj;
converted |= convert_field(rec, finfo, msg);
}
if (converted)
{
if (key != c.curr().key())
{
old = c.curr();
t.curr() = rec;
t.write();
t.curr() = old;
t.remove();
}
else
{
t.curr() = rec;
t.rewrite();
}
}
}
if (logicnum == LF_TABCOM)
_tabcomconverted = true;
else
_tabconverted = true;
}
static void build_xml_filename(TFilename& name, bool remote)
{
const long n = dongle().number();
name.format("tc_%05ld", n);
if (n == 0) // Le chiavi di sviluppo sono tutte 0, uso il nome della stazione
{
char host[80];
xvt_sys_get_host_name(host, sizeof(host));
name << host;
name.replace(' ', '_');
if (remote)
{
TString str;
time_t t; time(&t); str = ctime(&t);
str.rtrim(1);
name << '_' << str;
name.replace(' ', '_');
name.replace(':', '_');
}
}
name.ext("xml");
}
static TXmlItem& find_or_create_child(TXmlItem& root, const char* tag, bool reset = false)
{
TXmlItem* pitem = root.FindFirstChild(tag);
if (pitem == NULL)
pitem = &root.AddChild(tag);
else
{
if (reset)
{
pitem->Destroy();
pitem->SetTag(tag);
}
}
return *pitem;
}
static TXmlItem& set_attr(TXmlItem& root, const char* name, const char* value)
{
TXmlItem& c = root.AddChild("attr");
c.SetAttr("Name", name);
TString str = value; str.trim();
c.SetAttr("Value", str);
return c;
}
static bool save_campo_xml()
{
TFilename filename; build_xml_filename(filename, false);
TXmlItem root;
root.SetTag("Campo");
TXmlItem& system = find_or_create_child(root, "system");
TFilename str;
xvt_sys_get_host_name(str.get_buffer(), str.size());
set_attr(system, "Host", str);
xvt_sys_get_user_name(str.get_buffer(), str.size());
set_attr(system, "User", str);
time_t t; time(&t); str = ctime(&t);
set_attr(system, "Time", str);
xvt_sys_get_version(str.get_buffer(), NULL, str.size());
set_attr(system, "O.S.", str);
TXmlItem& study = find_or_create_child(root, "study", true);
TXmlItem& firm = study.AddChild("firm");
set_attr(study, "DataPath", firm2dir(-1));
set_attr(firm, "Code", format("%ld", prefix().firm().codice()));
set_attr(firm, "RagSoc", prefix().firm().ragione_sociale());
root.Save(filename);
return filename.exist();
}
static bool send_firm_xml()
{
TWait_cursor waiter;
bool ok = save_campo_xml();
if (ok && (xvt_net_get_status() & 0x4) != 0)
{
TSocketClient aga;
CONNID id = aga.QueryConnection("21", "www.aga.it");
if (id > 0)
{
TFilename local, remote;
build_xml_filename(local, false);
build_xml_filename(remote, true);
ok = aga.FtpSendFile(id, remote, local, "attivazioni", "viagra");
aga.RemoveConnection(id);
}
}
return ok;
}
void TConvert_archives::convert(bool comtables)
{
send_firm_xml();
TArray field_infos;
TConfig d(CONFIG_DITTA, "ca");
const bool usepdcc = d.get_bool("UsePdcc");
_srcdir = firm2dir(-1);
if (!isalnum(_srcdir.right(1)[0]))
_srcdir.rtrim(1);
_dstdir = _srcdir;
_dstdir << " tc"; // Lo spazio rende inutilizzabile lo studio
_tabcomconverted = false;
_tabconverted = false;
field_infos.add(new TField_info("VALUTA", _tabella, "TSVAL"));
convert_file(LF_NDITTE, field_infos);
field_infos.destroy();
field_infos.add(new TField_info("TIPOCF|CODCF", _clifor));
convert_file(LF_INDSP, field_infos);
field_infos.destroy();
field_infos.add(new TField_info("TIPOCF|CODCF", _clifor));
field_infos.add(new TField_info("ASSFIS", _tabella, "TSIVA"));
convert_file(LF_CFVEN, field_infos);
field_infos.destroy();
field_infos.add(new TField_info("|GRUPPO|CONTO|SOTTOCONTO"));
convert_file(LF_PCON, field_infos);
field_infos.destroy();
field_infos.add(new TField_info("TIPOCF|CODCF", _clifor));
field_infos.add(new TField_info("|GRUPPO|CONTO"));
field_infos.add(new TField_info("TIPOCF|CODCFASS", _clifor));
field_infos.add(new TField_info("TIPOCF|CODCFFATT", _clifor));
field_infos.add(new TField_info("|GRUPPORIC|CONTORIC|SOTTOCRIC"));
field_infos.add(new TField_info("STATO", _tabella, "TSNAZ"));
field_infos.add(new TField_info("CODVAL", _tabella, "TSVAL"));
field_infos.add(new TField_info("CODPAG", _tabella, "TSCDP"));
convert_file(LF_CLIFO, field_infos);
field_infos.destroy();
field_infos.add(new TField_info("|GRUPPO|CONTO|SOTTOCONTO")); // ???
convert_file(LF_SALDI, field_infos);
field_infos.destroy();
field_infos.add(new TField_info("TIPOCF|CODCF", _clifor));
convert_file(LF_ALLEG, field_infos);
field_infos.destroy();
field_infos.add(new TField_info("CODCAUS", _tabella, "TSCAU"));
field_infos.add(new TField_info("REG", _tabella, "TSREG"));
field_infos.add(new TField_info("TIPO|CODCF", _clifor));
field_infos.add(new TField_info("CODPAG", _tabella, "TSCDP"));
convert_file(LF_MOV, field_infos);
field_infos.destroy();
field_infos.add(new TField_info("TIPOC|GRUPPO|CONTO|SOTTOCONTO"));
field_infos.add(new TField_info("TIPOCC|GRUPPOC|CONTOC|SOTTOCONTC"));
convert_file(LF_RMOV, field_infos);
field_infos.destroy();
field_infos.add(new TField_info("CODIVA", _tabella, "TSIVA"));
field_infos.add(new TField_info("TIPOC|GRUPPO|CONTO|SOTTOCONTO"));
convert_file(LF_RMOVIVA, field_infos);
field_infos.destroy();
field_infos.add(new TField_info("CODCAUS", _tabella, "TSCAU", "&TCA"));
field_infos.add(new TField_info("REG", _tabella, "TSREG"));
convert_file(LF_CAUSALI, field_infos);
field_infos.destroy();
field_infos.add(new TField_info("CODCAUS", _tabella, "TSCAU"));
// field_infos.add(new TField_info("REG", _tabella, "TSREG")); verificare
field_infos.add(new TField_info("TIPOCF|GRUPPO|CONTO|SOTTOCONTO"));
field_infos.add(new TField_info("CODIVA", _tabella, "TSIVA"));
convert_file(LF_RCAUSALI, field_infos);
field_infos.destroy();
field_infos.add(new TField_info("REG", _tabella, "TSREG"));
field_infos.add(new TField_info("CODCAUS", _tabella, "TSCAU"));
field_infos.add(new TField_info("CODVAL", _tabella, "TSVAL"));
field_infos.add(new TField_info("TIPOC|GRUPPO|CONTO|SOTTOCONTO"));
field_infos.add(new TField_info("TIPOC|GRUPPOCL|CONTOCL"));
convert_file(LF_PARTITE, field_infos);
field_infos.destroy();
field_infos.add(new TField_info("CODPAG", _tabella, "TSCDP"));
field_infos.add(new TField_info("TIPOC|GRUPPO|CONTO|SOTTOCONTO"));
convert_file(LF_SCADENZE, field_infos);
field_infos.destroy();
field_infos.add(new TField_info("TIPOC|GRUPPO|CONTO|SOTTOCONTO"));
convert_file(LF_PAGSCA, field_infos);
field_infos.destroy();
field_infos.add(new TField_info("TIPOCF|CODCF", _clifor));
field_infos.add(new TField_info("CODVAL", _tabella, "TSVAL"));
convert_file(LF_EFFETTI, field_infos);
field_infos.destroy();
field_infos.add(new TField_info("STATO", _tabella, "TSNAZ"));
field_infos.add(new TField_info("CODPAG", _tabella, "TSCDP"));
convert_file(LF_CESS, field_infos);
field_infos.destroy();
field_infos.add(new TField_info("TIPOCF|CODCF", _clifor));
field_infos.add(new TField_info("CODVAL", _tabella, "TSVAL"));
field_infos.add(new TField_info("CODPAG", _tabella, "TSCDP"));
field_infos.add(new TField_info("TIPOCF|CODCFFATT", _clifor));
convert_file(LF_DOC, field_infos);
field_infos.destroy();
field_infos.add(new TField_info("CODIVA", _tabella, "TSIVA"));
convert_file(LF_RIGHEDOC, field_infos);
field_infos.destroy();
field_infos.add(new TField_info("|GRUPPOA|CONTOA|SOTTOCA"));
field_infos.add(new TField_info("|GRUPPOV|CONTOV|SOTTOCV"));
field_infos.add(new TField_info("CODIVA", _tabella, "TSIVA"));
field_infos.add(new TField_info("\"F\"|CODFORN", _clifor));
field_infos.add(new TField_info("CODIVAR", _tabella, "TSIVA"));
convert_file(LF_ANAMAG, field_infos);
field_infos.destroy();
field_infos.add(new TField_info("TIPOCF|CODCF", _clifor));
field_infos.add(new TField_info("CODVAL", _tabella, "TSVAL"));
convert_file(LF_CONDV, field_infos);
field_infos.destroy();
field_infos.add(new TField_info("TIPOCF|CODCF", _clifor));
field_infos.add(new TField_info("CODIVA", _tabella, "TSIVA"));
convert_file(LF_RCONDV, field_infos);
field_infos.destroy();
field_infos.add(new TField_info("CODREG", _tabella, "TSREG"));
convert_file(LF_TABREG, field_infos);
field_infos.destroy();
field_infos.add(new TField_info("CODCAUS", _tabella, "TSCAU"));
convert_file(LF_MOVANA, field_infos);
if (usepdcc)
{
field_infos.destroy();
field_infos.add(new TField_info("CODCONTO", _contanal));
field_infos.add(new TField_info("CODCCORI", _contanal));
convert_file(LF_RMOVANA, field_infos);
}
field_infos.destroy();
field_infos.add(new TField_info("TIPOCF|CODFORN", _clifor));
convert_file(LF_MOVMAG, field_infos);
field_infos.destroy();
field_infos.add(new TField_info("\"F\"|CODCF", _clifor));
convert_file(LF_AGENTI, field_infos);
field_infos.destroy();
field_infos.add(new TField_info("\"C\"|CODCLI", _clifor));
convert_file(LF_PROVV, field_infos);
field_infos.destroy();
field_infos.add(new TField_info("TIPOCF|CODCF", _clifor));
field_infos.add(new TField_info("CODVAL", _tabella, "TSVAL"));
convert_file(LF_INTRA, field_infos);
field_infos.destroy();
field_infos.add(new TField_info("CODVAL", _tabella, "TSVAL"));
convert_file(LF_RIEPRETT, field_infos);
field_infos.destroy();
field_infos.add(new TField_info("CODVALUTA", _tabella, "TSVAL"));
convert_file(LF_CESPI, field_infos);
field_infos.destroy();
field_infos.add(new TField_info("|GRUPPO|CONTO|SOTTOC"));
field_infos.add(new TField_info("|GRUPPOQNO|CONTOQNO|SOTTOCQNO"));
field_infos.add(new TField_info("|GRUPPOQAN|CONTOQAN|SOTTOCQAN"));
field_infos.add(new TField_info("|GRUPPOQAC|CONTOQAC|SOTTOCQAC"));
field_infos.add(new TField_info("|GRUPPOQFN|CONTOQFN|SOTTOCQFN"));
field_infos.add(new TField_info("|GRUPPOQFA|CONTOQFA|SOTTOCQFA"));
field_infos.add(new TField_info("|GRUPPOQACC|CONTOQACC|SOTTOCQACC"));
convert_file(LF_COLLCES, field_infos);
field_infos.destroy();
field_infos.add(new TField_info("|GRUPPO|CONTO|SOTTOCONTO"));
convert_file(LF_RIP, field_infos);
if (usepdcc)
{
field_infos.destroy();
field_infos.add(new TField_info("CODCONTO", _contanal));
convert_file(LF_RRIP, field_infos);
field_infos.destroy();
field_infos.add(new TField_info("CONTO", _contanal));
convert_file(LF_SALDANA, field_infos);
}
field_infos.destroy();
field_infos.add(new TField_info("\"C\"|CODCLI", _clifor));
convert_file(LF_LETINT, field_infos);
field_infos.destroy();
field_infos.add(new TField_info("|GRUPPO|CONTO|SOTTOCONTO"));
convert_file(LF_PANAPDC, field_infos);
field_infos.destroy();
field_infos.add(new TField_info("|GRUPPO|CONTO|SOTTOCONTO"));
convert_file(LF_RICLPDC, field_infos);
field_infos.destroy();
field_infos.add(new TField_info("TIPOCF|CODCF", _clifor));
convert_file(LF_CLIFOGIAC, field_infos);
// Tabelle
field_infos.destroy();
field_infos.add(new TField_info("|I0|I1|I2"));
field_infos.add(new TField_info("|I3|I4|I5"));
field_infos.add(new TField_info("S3[1,4]", _tabella, "TSIVA"));
field_infos.add(new TField_info("S4", _tabella, "TSVAL"));
convert_table("SPP", field_infos, true);
field_infos.destroy();
field_infos.add(new TField_info("|I0|I1|I2"));
field_infos.add(new TField_info("|I3|I4|I5"));
field_infos.add(new TField_info("S3[1,4]", _tabella, "TSIVA"));
field_infos.add(new TField_info("S4", _tabella, "TSVAL"));
convert_table("PRS", field_infos);
field_infos.destroy();
field_infos.add(new TField_info("|I3|I4|I5"));
field_infos.add(new TField_info("S3[1,4]", _tabella, "TSIVA"));
field_infos.add(new TField_info("S4", _tabella, "TSVAL"));
convert_table("ATR", field_infos);
field_infos.destroy();
field_infos.add(new TField_info("|I3|I4|I5"));
field_infos.add(new TField_info("S3[1,4]", _tabella, "TSIVA"));
field_infos.add(new TField_info("S4", _tabella, "TSVAL"));
convert_table("RSS", field_infos);
field_infos.destroy();
field_infos.add(new TField_info("|I0|I1|I2"));
field_infos.add(new TField_info("|I3|I4|I5"));
field_infos.add(new TField_info("S7", _tabella, "TSIVA"));
convert_table("GMC", field_infos);
field_infos.destroy();
field_infos.add(new TField_info("|I0|I1|I2"));
field_infos.add(new TField_info("|I3|I4|I5"));
convert_table("RFA", field_infos);
field_infos.destroy();
field_infos.add(new TField_info("|I0|I1|I2"));
convert_table("CFA", field_infos);
field_infos.destroy();
field_infos.add(new TField_info("|I0|I1|I2"));
convert_table("CRA", field_infos); // ???
field_infos.destroy();
field_infos.add(new TField_info("|I0|I1|I2"));
field_infos.add(new TField_info("|I3|I4|I5"));
field_infos.add(new TField_info("|I6|I7|I8"));
field_infos.add(new TField_info("|I9|I10|I11"));
convert_table("BNP", field_infos);
if (comtables)
{
field_infos.destroy();
field_infos.add(new TField_info("CODTAB", _tabella, "TSIVA", "&TIV"));
convert_table("%IVA", field_infos, true);
field_infos.destroy();
field_infos.add(new TField_info("CODTAB", _tabella, "TSNAZ", "&TNA"));
convert_table("%STA", field_infos);
field_infos.destroy();
field_infos.add(new TField_info("CODTAB", _tabella, "TSCDP", "&TPG"));
convert_table("%CPG", field_infos);
field_infos.destroy();
field_infos.add(new TField_info("CODTAB[1,4]", _tabella, "TSCDP"));
convert_table("%RPG", field_infos);
field_infos.destroy();
field_infos.add(new TField_info("CODTAB", _tabella, "TSVAL", "&TVA"));
convert_table("%VAL", field_infos);
}
field_infos.destroy();
field_infos.add(new TField_info("CODTAB", _tabella, "TSREG", "&TRE"));
convert_table("REG", field_infos);
if (_tabcomconverted)
_m->set_converted(LF_TABCOM);
if (_tabconverted)
_m->set_converted(LF_TAB);
TReport_book b;
b.add(*_log);
b.print_or_preview();
}
void TConvert_archives::main_loop()
{
Tdninst d;
_m = new TConvert_mask;
if (_m->run() == K_ENTER && d.can_I_run())
convert(_m->get_bool(F_CONVCOM));
delete _m;
}
int tc0900(int argc, char* argv[])
{
TConvert_archives app;
app.run(argc, argv, "Conversione archivi CAMPO");
return 0;
}