1994-12-05 18:54:04 +00:00
|
|
|
|
#include <applicat.h>
|
2009-09-25 13:19:21 +00:00
|
|
|
|
#include <extcdecl.h>
|
1994-12-05 18:54:04 +00:00
|
|
|
|
#include <mailbox.h>
|
|
|
|
|
#include <progind.h>
|
1996-01-09 10:30:18 +00:00
|
|
|
|
#include <relation.h>
|
2008-08-28 11:22:25 +00:00
|
|
|
|
#include <reputils.h>
|
|
|
|
|
#include <sheet.h>
|
1995-02-15 17:00:56 +00:00
|
|
|
|
#include <tabutil.h>
|
1994-12-05 18:54:04 +00:00
|
|
|
|
#include <urldefid.h>
|
|
|
|
|
#include <utility.h>
|
2009-09-25 13:19:21 +00:00
|
|
|
|
#include <varrec.h>
|
1996-01-09 10:30:18 +00:00
|
|
|
|
|
|
|
|
|
#include <causali.h>
|
2005-02-17 18:13:12 +00:00
|
|
|
|
#include <clifo.h>
|
1996-09-05 16:19:36 +00:00
|
|
|
|
#include <mov.h>
|
2005-05-16 23:44:23 +00:00
|
|
|
|
#include <pconti.h>
|
2009-09-25 13:19:21 +00:00
|
|
|
|
#include <rdoc.h>
|
1994-12-05 18:54:04 +00:00
|
|
|
|
#include <rmov.h>
|
1996-09-05 16:19:36 +00:00
|
|
|
|
#include <saldi.h>
|
|
|
|
|
|
1997-06-19 14:50:31 +00:00
|
|
|
|
#include "..\cg\cglib02.h"
|
2009-09-25 13:19:21 +00:00
|
|
|
|
#include "..\ve\velib.h"
|
1996-09-05 16:19:36 +00:00
|
|
|
|
|
2009-09-16 15:03:02 +00:00
|
|
|
|
/*
|
1995-07-03 07:52:10 +00:00
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
// Applicazione di conversione archivi XBase, valida per tutti e 4 i tipi di DLL
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
class TConversione_xbase : public TApplication
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
virtual bool create () ;
|
|
|
|
|
virtual bool destroy();
|
|
|
|
|
void update();
|
|
|
|
|
void convert_dir();
|
|
|
|
|
int convert_file(int logicnum);
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
TConversione_xbase() {}
|
|
|
|
|
~TConversione_xbase() {}
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
bool TConversione_xbase::create() // initvar e arrmask
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
TApplication::create();
|
|
|
|
|
|
|
|
|
|
update();
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TConversione_xbase::destroy() // releasev e arrmask
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
return TApplication::destroy() ;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int TConversione_xbase::convert_file(int logicnum)
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
int err = NOERR;
|
|
|
|
|
TSystemisamfile f(logicnum);
|
|
|
|
|
|
|
|
|
|
err=f.pack(); // Pack data and index, so rebuild indexes according to present DLL, leaving old indexes
|
|
|
|
|
|
|
|
|
|
return err;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TConversione_xbase::convert_dir()
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
const TString pref(prefix().name());
|
|
|
|
|
const bool is_com = prefix().is_com();
|
|
|
|
|
TDir d;
|
|
|
|
|
|
|
|
|
|
d.get(LF_DIR);
|
|
|
|
|
const int items = (int)d.eod();
|
|
|
|
|
TString80 s("Aggiornamento archivi ");
|
|
|
|
|
|
|
|
|
|
if (pref == "com") s << "comuni";
|
|
|
|
|
else s << " della ditta " << atol (pref);
|
|
|
|
|
|
|
|
|
|
TProgind p((long)(items ? items : 1), s, TRUE, TRUE, 70);
|
|
|
|
|
|
|
|
|
|
p.setstatus(1L);
|
|
|
|
|
|
|
|
|
|
for (int i = 2; i <= items; i++)
|
|
|
|
|
{
|
|
|
|
|
p.setstatus((long)(i+1));
|
|
|
|
|
d.get(i, _nolock, _nordir, _sysdirop);
|
|
|
|
|
|
|
|
|
|
const bool to_convert = (is_com ? d.is_com() : d.is_firm());
|
|
|
|
|
|
|
|
|
|
if (to_convert && d.len() > 0)
|
|
|
|
|
convert_file(i);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TConversione_xbase::update()
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
long firm = get_firm();
|
|
|
|
|
TString pref;
|
|
|
|
|
if (firm == 0) pref = prefix().name();
|
|
|
|
|
|
|
|
|
|
do_events();
|
|
|
|
|
begin_wait();
|
|
|
|
|
|
|
|
|
|
prefix().set("com");
|
|
|
|
|
convert_dir();
|
|
|
|
|
|
|
|
|
|
TLocalisamfile ditte(LF_NDITTE);
|
|
|
|
|
|
|
|
|
|
set_autoload_new_files(FALSE);
|
|
|
|
|
for (ditte.first(); !ditte.eof(); ditte.next())
|
|
|
|
|
{
|
|
|
|
|
const long codditta = ditte.get_long("CODDITTA");
|
|
|
|
|
const TRecnotype rec = ditte.recno();
|
|
|
|
|
|
|
|
|
|
if (prefix().exist(codditta))
|
|
|
|
|
{
|
|
|
|
|
set_firm(codditta);
|
|
|
|
|
convert_dir();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (firm > 0) set_firm(firm);
|
|
|
|
|
else prefix().set(pref);
|
|
|
|
|
set_autoload_new_files(TRUE);
|
|
|
|
|
end_wait();
|
|
|
|
|
}
|
2009-09-16 15:03:02 +00:00
|
|
|
|
*/
|
1995-07-03 07:52:10 +00:00
|
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
// Applicazione di conversione archivi
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
2002-05-22 14:41:02 +00:00
|
|
|
|
class TConversione_archivi : public TApplication
|
1994-12-05 18:54:04 +00:00
|
|
|
|
{
|
|
|
|
|
int _nconv;
|
|
|
|
|
long _codditta;
|
|
|
|
|
long _oldditta;
|
|
|
|
|
int _error;
|
|
|
|
|
|
1995-02-15 17:00:56 +00:00
|
|
|
|
protected: // TApplication
|
1994-12-05 18:54:04 +00:00
|
|
|
|
virtual bool create() ;
|
|
|
|
|
virtual bool destroy() ;
|
2002-05-22 14:41:02 +00:00
|
|
|
|
virtual bool menu(MENU_TAG);
|
2008-08-28 11:22:25 +00:00
|
|
|
|
|
|
|
|
|
// Metodi per convert_profile
|
2008-09-16 09:11:02 +00:00
|
|
|
|
bool to_be_converted(TFilename& name) const;
|
2008-08-28 11:22:25 +00:00
|
|
|
|
bool backup_text_file(TFilename& name, TLog_report& log) const;
|
|
|
|
|
bool rinumera_paragrafo(const TFilename& ini, const char* paragrafo,
|
|
|
|
|
const char* contatore, const char* variabile, TLog_report& log) const;
|
|
|
|
|
bool rinumera_maschera(const TFilename& msk, TLog_report& log) const;
|
|
|
|
|
|
1995-02-15 17:00:56 +00:00
|
|
|
|
public:
|
1994-12-05 18:54:04 +00:00
|
|
|
|
bool convert_rmov(TLocalisamfile & rmov, TArray & recs, int nrecs);
|
|
|
|
|
void contropartita_rmov();
|
|
|
|
|
|
1995-02-15 17:00:56 +00:00
|
|
|
|
void liala(const char* table);
|
1995-04-19 13:47:12 +00:00
|
|
|
|
bool patch_uff(TRectype & rec, const char * const fnames[]);
|
|
|
|
|
bool collate(TRectype & rec, const char * f1, const char * f2);
|
1996-01-09 10:30:18 +00:00
|
|
|
|
void patch_com();
|
|
|
|
|
void zero_770();
|
|
|
|
|
void convert_patty();
|
|
|
|
|
void convert_codconc();
|
|
|
|
|
void convert_profili();
|
|
|
|
|
void convert_caus_attiv();
|
|
|
|
|
void rebuild_indexes();
|
|
|
|
|
void rebuild_dir_indexes();
|
1996-03-21 09:21:48 +00:00
|
|
|
|
void convert_codreg() const;
|
1996-04-24 16:43:11 +00:00
|
|
|
|
void convert_lia_pim() const;
|
|
|
|
|
void build_ver_table() const;
|
1996-09-05 16:19:36 +00:00
|
|
|
|
void convert_forms() const;
|
|
|
|
|
void sort_sal(int year) const;
|
|
|
|
|
void convert_saldi() const;
|
1996-09-19 10:59:07 +00:00
|
|
|
|
void convert_ca7_ql() const;
|
1997-02-28 08:36:31 +00:00
|
|
|
|
void convert_enti_m770() const;
|
|
|
|
|
void convert_caaf_m770() const;
|
|
|
|
|
void convert_rver_m770() const;
|
1996-10-04 07:59:19 +00:00
|
|
|
|
void remove_dta_ndx() const;
|
1997-06-05 14:25:34 +00:00
|
|
|
|
void convert_ucs() const;
|
|
|
|
|
void convert_ucc() const;
|
1997-11-20 08:18:05 +00:00
|
|
|
|
void convert_cap() const;
|
|
|
|
|
void convert_uue() const;
|
1998-04-30 14:38:35 +00:00
|
|
|
|
void convert_pim2prm() const;
|
2000-10-03 13:45:12 +00:00
|
|
|
|
void convert_riba_tcf() const;
|
2002-07-02 16:21:23 +00:00
|
|
|
|
void convert_cdc2cms() const;
|
|
|
|
|
void convert_mov2movcms() const;
|
2002-09-13 14:06:05 +00:00
|
|
|
|
void convert_ca7() const;
|
|
|
|
|
void change_ca7(TRectype& rec) const;
|
|
|
|
|
void convert_quadst() const;
|
2005-02-17 18:13:12 +00:00
|
|
|
|
void convert_clifo_privati();
|
2005-05-16 23:44:23 +00:00
|
|
|
|
void convert_pcon_ivd();
|
2005-05-25 11:32:58 +00:00
|
|
|
|
void convert_profile(const char * profile_name);
|
2009-10-14 10:58:30 +00:00
|
|
|
|
//roba per conai
|
|
|
|
|
void convert_conai_anamag();
|
|
|
|
|
void convert_conai_rdoc();
|
2009-09-25 13:19:21 +00:00
|
|
|
|
void convert_conai_righe();
|
1997-11-20 08:18:05 +00:00
|
|
|
|
|
1994-12-05 18:54:04 +00:00
|
|
|
|
TConversione_archivi() : _oldditta(0), _codditta(0), _error(0) {}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
bool TConversione_archivi::create()
|
|
|
|
|
{
|
2002-05-22 14:41:02 +00:00
|
|
|
|
TApplication::create();
|
2005-02-17 18:13:12 +00:00
|
|
|
|
const int args = argc();
|
2002-05-22 14:41:02 +00:00
|
|
|
|
|
2008-08-28 11:22:25 +00:00
|
|
|
|
_nconv = args > 1 ? abs(atoi(argv(1))) : 0;
|
2005-02-17 18:13:12 +00:00
|
|
|
|
if (_nconv > 1)
|
1994-12-05 18:54:04 +00:00
|
|
|
|
{
|
2005-02-17 18:13:12 +00:00
|
|
|
|
_oldditta = get_firm();
|
|
|
|
|
if (args > 2)
|
|
|
|
|
_codditta = atol(argv(args - 1));
|
|
|
|
|
else
|
|
|
|
|
_codditta = -1;
|
|
|
|
|
if (_codditta >= 0 && _codditta != _oldditta)
|
1994-12-05 18:54:04 +00:00
|
|
|
|
{
|
2005-02-17 18:13:12 +00:00
|
|
|
|
if (_codditta == 0) prefix().set("com");
|
|
|
|
|
else set_firm(_codditta);
|
1994-12-05 18:54:04 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2009-02-23 14:48:30 +00:00
|
|
|
|
dispatch_e_menu(MENU_ITEM_ID(1));
|
2005-02-17 18:13:12 +00:00
|
|
|
|
return TRUE;
|
1994-12-05 18:54:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TConversione_archivi::destroy()
|
|
|
|
|
{
|
2005-02-17 18:13:12 +00:00
|
|
|
|
if (_codditta >= 0 && _nconv > 1 && _codditta != _oldditta)
|
1994-12-05 18:54:04 +00:00
|
|
|
|
{
|
1995-03-24 16:49:18 +00:00
|
|
|
|
if (_oldditta == 0) prefix().set("com");
|
1994-12-05 18:54:04 +00:00
|
|
|
|
else set_firm(_oldditta);
|
|
|
|
|
}
|
|
|
|
|
if (_error > 0)
|
|
|
|
|
{
|
|
|
|
|
TMessage msg("ba1100", 0, format("%d", _error));
|
|
|
|
|
msg.send();
|
|
|
|
|
}
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2002-05-22 14:41:02 +00:00
|
|
|
|
bool TConversione_archivi::menu(MENU_TAG)
|
1994-12-05 18:54:04 +00:00
|
|
|
|
{
|
|
|
|
|
switch (_nconv)
|
|
|
|
|
{
|
2002-05-22 14:41:02 +00:00
|
|
|
|
case 1:
|
|
|
|
|
{
|
|
|
|
|
TSystemisamfile f(atoi(argv(2)));
|
|
|
|
|
TFilename lf;
|
|
|
|
|
|
|
|
|
|
lf.format("%sstd/%s", __ptprf, argv(3));
|
|
|
|
|
if (fexist(lf))
|
|
|
|
|
f.load(lf, '|', '\0', '\n', TRUE, TRUE);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 2:
|
|
|
|
|
liala("LIA");
|
|
|
|
|
liala("PLA");
|
|
|
|
|
break;
|
|
|
|
|
case 3:
|
|
|
|
|
if (_codditta == 0)
|
|
|
|
|
patch_com();
|
|
|
|
|
case 4:
|
|
|
|
|
if (_codditta == 0)
|
|
|
|
|
zero_770();
|
|
|
|
|
case 5:
|
|
|
|
|
convert_patty();
|
|
|
|
|
case 6:
|
|
|
|
|
if (_codditta == 0)
|
|
|
|
|
{
|
|
|
|
|
convert_codconc();
|
|
|
|
|
|
|
|
|
|
TSystemisamfile comuni(LF_COMUNI);
|
1995-09-29 11:51:54 +00:00
|
|
|
|
|
2002-05-22 14:41:02 +00:00
|
|
|
|
comuni.load(format("%sstd/ncom02.txt", __ptprf));
|
1995-10-16 14:39:58 +00:00
|
|
|
|
|
|
|
|
|
//Cancella tutti i vecchi profili, sostituendoli con i nuovi
|
1995-10-25 16:15:27 +00:00
|
|
|
|
convert_profili();
|
1996-01-09 10:30:18 +00:00
|
|
|
|
}
|
1995-10-25 16:15:27 +00:00
|
|
|
|
case 7:
|
1996-01-09 10:30:18 +00:00
|
|
|
|
if (_codditta == 0)
|
|
|
|
|
convert_caus_attiv();
|
|
|
|
|
break;
|
1995-11-16 11:38:08 +00:00
|
|
|
|
case 8:
|
1996-01-09 10:30:18 +00:00
|
|
|
|
if (_codditta == 0)
|
1996-03-21 09:21:48 +00:00
|
|
|
|
rebuild_indexes();
|
|
|
|
|
break;
|
1996-01-09 10:30:18 +00:00
|
|
|
|
case 9:
|
1996-03-21 09:21:48 +00:00
|
|
|
|
if (_codditta == 0)
|
|
|
|
|
convert_codreg();
|
1996-04-24 16:43:11 +00:00
|
|
|
|
break;
|
|
|
|
|
case 10:
|
|
|
|
|
convert_lia_pim();
|
|
|
|
|
if (_codditta == 0)
|
|
|
|
|
build_ver_table();
|
1996-01-09 10:30:18 +00:00
|
|
|
|
break;
|
1996-05-31 14:51:12 +00:00
|
|
|
|
case 11:
|
|
|
|
|
if (_codditta == 0)
|
1996-09-19 10:59:07 +00:00
|
|
|
|
convert_ca7_ql();
|
1996-05-31 14:51:12 +00:00
|
|
|
|
break;
|
1996-09-04 07:02:00 +00:00
|
|
|
|
case 12:
|
1996-10-04 07:59:19 +00:00
|
|
|
|
remove_dta_ndx();
|
1996-09-04 07:02:00 +00:00
|
|
|
|
if (_codditta == 0)
|
1996-10-08 17:09:13 +00:00
|
|
|
|
{
|
|
|
|
|
// Rimuove ITALIA dalla tabella stati
|
|
|
|
|
TTable sta("%STA");
|
|
|
|
|
sta.zero();
|
|
|
|
|
if (sta.read() == NOERR) sta.remove();
|
|
|
|
|
// converte i profili
|
1996-09-13 08:56:59 +00:00
|
|
|
|
convert_forms();
|
1996-10-08 17:09:13 +00:00
|
|
|
|
}
|
1996-09-13 08:56:59 +00:00
|
|
|
|
else
|
|
|
|
|
convert_saldi();
|
1996-09-05 16:19:36 +00:00
|
|
|
|
break;
|
1997-02-28 08:36:31 +00:00
|
|
|
|
case 13:
|
|
|
|
|
if (_codditta == 0)
|
1997-02-28 09:18:06 +00:00
|
|
|
|
{
|
1997-02-28 08:36:31 +00:00
|
|
|
|
convert_enti_m770();
|
|
|
|
|
convert_caaf_m770();
|
|
|
|
|
convert_rver_m770();
|
1997-02-28 09:18:06 +00:00
|
|
|
|
}
|
1997-02-28 08:36:31 +00:00
|
|
|
|
break;
|
1997-06-05 14:25:34 +00:00
|
|
|
|
case 14:
|
|
|
|
|
if (_codditta == 0)
|
|
|
|
|
{
|
|
|
|
|
convert_ucs();
|
|
|
|
|
convert_ucc();
|
|
|
|
|
}
|
1997-11-20 08:18:05 +00:00
|
|
|
|
break;
|
1997-11-21 16:40:48 +00:00
|
|
|
|
case 16:
|
1997-11-20 08:18:05 +00:00
|
|
|
|
if (_codditta == 0)
|
|
|
|
|
convert_uue();
|
|
|
|
|
convert_cap();
|
|
|
|
|
break;
|
1998-04-30 14:38:35 +00:00
|
|
|
|
case 17:
|
|
|
|
|
if (_codditta > 0)
|
|
|
|
|
convert_pim2prm();
|
|
|
|
|
break;
|
2000-10-03 13:45:12 +00:00
|
|
|
|
case 18:
|
|
|
|
|
if (_codditta > 0)
|
|
|
|
|
convert_riba_tcf();
|
|
|
|
|
break;
|
2002-07-02 16:21:23 +00:00
|
|
|
|
case 19:
|
|
|
|
|
if (_codditta > 0)
|
|
|
|
|
{
|
|
|
|
|
convert_cdc2cms();
|
|
|
|
|
convert_mov2movcms();
|
|
|
|
|
}
|
|
|
|
|
break;
|
2002-09-13 14:06:05 +00:00
|
|
|
|
case 20:
|
|
|
|
|
if (_codditta == 0)
|
|
|
|
|
{
|
|
|
|
|
convert_ca7();
|
|
|
|
|
convert_quadst();
|
|
|
|
|
}
|
|
|
|
|
break;
|
2005-02-17 18:13:12 +00:00
|
|
|
|
case 21:
|
|
|
|
|
convert_clifo_privati();
|
2005-05-16 23:44:23 +00:00
|
|
|
|
break;
|
|
|
|
|
case 22:
|
|
|
|
|
convert_pcon_ivd();
|
2008-08-28 11:22:25 +00:00
|
|
|
|
break;
|
2005-05-25 11:32:58 +00:00
|
|
|
|
case 23:
|
|
|
|
|
convert_profile(argv(2));
|
2008-08-28 11:22:25 +00:00
|
|
|
|
break;
|
2009-09-25 13:19:21 +00:00
|
|
|
|
case 24:
|
|
|
|
|
convert_conai_righe();
|
|
|
|
|
break;
|
1996-01-09 10:30:18 +00:00
|
|
|
|
default:
|
|
|
|
|
break;
|
2008-08-28 11:22:25 +00:00
|
|
|
|
}
|
2009-09-25 13:19:21 +00:00
|
|
|
|
return false;
|
1994-12-05 18:54:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
1995-02-15 17:00:56 +00:00
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
// Cambia i movimenti contabili in modo che abbiano un
|
|
|
|
|
// conto di contropartita e non una riga di riferimento
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
1994-12-05 18:54:04 +00:00
|
|
|
|
bool TConversione_archivi::convert_rmov(TLocalisamfile & rmov, TArray & recs, int nrecs)
|
|
|
|
|
{
|
|
|
|
|
const TRecnotype pos = rmov.recno();
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < nrecs; i++)
|
|
|
|
|
{
|
|
|
|
|
TRectype & r0 = (TRectype &) recs[i];
|
2002-07-02 16:21:23 +00:00
|
|
|
|
const int rcontr = r0.get_int("RCONTR") - 1;
|
1994-12-05 18:54:04 +00:00
|
|
|
|
|
|
|
|
|
if (rcontr >= 0 && rcontr < nrecs)
|
|
|
|
|
{
|
|
|
|
|
const TRectype & r1 = (const TRectype &) recs[rcontr];
|
|
|
|
|
|
|
|
|
|
r0.put(RMV_TIPOCC, r1.get(RMV_TIPOC));
|
|
|
|
|
r0.put(RMV_GRUPPOC, r1.get_int(RMV_GRUPPO));
|
|
|
|
|
r0.put(RMV_CONTOC, r1.get_int(RMV_CONTO));
|
|
|
|
|
r0.put(RMV_SOTTOCONTOC, r1.get_long(RMV_SOTTOCONTO));
|
|
|
|
|
}
|
2002-07-02 16:21:23 +00:00
|
|
|
|
r0.zero("RCONTR");
|
1994-12-05 18:54:04 +00:00
|
|
|
|
if (rmov.rewrite(r0) != NOERR)
|
|
|
|
|
{
|
|
|
|
|
const long reg = r0.get_long(RMV_NUMREG);
|
|
|
|
|
error_box("Non riesco ad aggiornare la riga contabile %ld / %d\nErrore n. %d", reg, i + 1, rmov.status());
|
|
|
|
|
rmov.readat(pos);
|
|
|
|
|
_error = 102;
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
rmov.readat(pos);
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TConversione_archivi::contropartita_rmov()
|
|
|
|
|
{
|
|
|
|
|
TDir d;
|
|
|
|
|
d.get(LF_RMOV);
|
|
|
|
|
if (d.eox() == 0) return;
|
|
|
|
|
|
|
|
|
|
TLocalisamfile rmov(LF_RMOV);
|
|
|
|
|
const TRecnotype nitems = rmov.items();
|
|
|
|
|
TArray recs;
|
|
|
|
|
long oldreg = -1;
|
|
|
|
|
long reg = -1;
|
|
|
|
|
int nrow = 0;
|
|
|
|
|
TProgind p(nitems ? nitems : 1,
|
|
|
|
|
format("Conversione righe di movimento della ditta %ld", get_firm()),
|
1995-02-15 17:00:56 +00:00
|
|
|
|
FALSE, TRUE, 70);
|
1994-12-05 18:54:04 +00:00
|
|
|
|
for (rmov.first(); rmov.good(); rmov.next())
|
|
|
|
|
{
|
|
|
|
|
p.addstatus(1);
|
|
|
|
|
reg = rmov.get_long(RMV_NUMREG);
|
|
|
|
|
if (oldreg != reg)
|
|
|
|
|
{
|
|
|
|
|
if (oldreg > 0)
|
|
|
|
|
if (convert_rmov(rmov, recs, nrow) == FALSE)
|
|
|
|
|
return;
|
|
|
|
|
oldreg = reg;
|
|
|
|
|
nrow = 0;
|
|
|
|
|
}
|
|
|
|
|
recs.add(rmov.curr(), nrow++);
|
|
|
|
|
CHECKD(nrow == rmov.get_int(RMV_NUMRIG), "Missed row ", nrow);
|
|
|
|
|
}
|
|
|
|
|
if (oldreg > 0)
|
|
|
|
|
if (convert_rmov(rmov, recs, nrow) == FALSE)
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
1995-02-15 17:00:56 +00:00
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
// Passa le tabelle LIA e PLA a %LIA e %PLA
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
void TConversione_archivi::liala(const char* table)
|
|
|
|
|
{
|
1995-09-29 11:51:54 +00:00
|
|
|
|
TString16 tab(table);
|
1995-02-15 17:00:56 +00:00
|
|
|
|
TTable lia(tab);
|
|
|
|
|
tab.insert("%", 0);
|
|
|
|
|
TTable cia(tab);
|
|
|
|
|
|
|
|
|
|
const long n = lia.items()+1;
|
|
|
|
|
TProgind p(n, format("Conversione tabella %s della ditta %ld", table, get_firm()), FALSE, TRUE, 70);
|
|
|
|
|
|
|
|
|
|
TString16 firm; firm.format("%05ld", get_firm());
|
|
|
|
|
TString16 codtab;
|
|
|
|
|
|
|
|
|
|
for (lia.first(); lia.good(); lia.next())
|
|
|
|
|
{
|
|
|
|
|
codtab = lia.get("CODTAB");
|
|
|
|
|
codtab.insert(firm, 0);
|
|
|
|
|
lia.put("CODTAB", codtab);
|
|
|
|
|
cia.write(lia.curr());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (lia.first(); lia.good(); lia.next())
|
|
|
|
|
lia.remove();
|
1994-12-05 18:54:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
1995-04-19 13:47:12 +00:00
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
// Sposta i codici uffici imposte e uffici IVA nei comuni
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
bool TConversione_archivi::collate(TRectype & rec, const char * f1, const char * f2)
|
|
|
|
|
{
|
|
|
|
|
if (rec.get(f1).empty())
|
|
|
|
|
{
|
|
|
|
|
TString16 s(rec.get(f2));
|
|
|
|
|
|
|
|
|
|
if (s.not_empty())
|
|
|
|
|
{
|
|
|
|
|
rec.put(f1, s);
|
|
|
|
|
rec.zero(f2);
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TConversione_archivi::patch_uff(TRectype & rec, const char * const fnames[])
|
|
|
|
|
{
|
|
|
|
|
bool updated = collate(rec, fnames[1], fnames[2]);
|
|
|
|
|
updated |= collate(rec, fnames[0], fnames[1]);
|
|
|
|
|
updated |= collate(rec, fnames[1], fnames[2]);
|
|
|
|
|
return updated;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TConversione_archivi::patch_com()
|
|
|
|
|
{
|
|
|
|
|
TLocalisamfile comuni(LF_COMUNI);
|
|
|
|
|
const char * const uff_iidd[] = {"UFFIIDD1", "UFFIIDD2", "UFFIIDD3"} ;
|
|
|
|
|
const char * const uff_iva[] = {"UFFIVA1", "UFFIVA2", "UFFIVA3"} ;
|
|
|
|
|
const TRecnotype nitems = comuni.items();
|
|
|
|
|
TProgind p(nitems ? nitems : 1, format("Conversione comuni"), FALSE, TRUE, 70);
|
|
|
|
|
|
|
|
|
|
for (comuni.first(); comuni.good(); comuni.next())
|
|
|
|
|
{
|
|
|
|
|
p.addstatus(1);
|
|
|
|
|
bool updated = patch_uff(comuni.curr(), uff_iidd);
|
|
|
|
|
updated = patch_uff(comuni.curr(), uff_iva) || updated;
|
|
|
|
|
if (updated)
|
|
|
|
|
comuni.rewrite();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
1995-04-28 13:21:43 +00:00
|
|
|
|
void TConversione_archivi::zero_770()
|
|
|
|
|
{
|
2008-12-10 16:55:06 +00:00
|
|
|
|
TDir d;
|
1995-04-28 13:21:43 +00:00
|
|
|
|
for (int i = LF_BASE ; i <= LF_DETH; i++)
|
|
|
|
|
{
|
|
|
|
|
d.get(i, _lock, _nordir, _sysdirop);
|
2008-12-10 16:55:06 +00:00
|
|
|
|
d.reset_eox();
|
|
|
|
|
d.put(i, _nordir, _sysdirop);
|
1995-04-28 13:21:43 +00:00
|
|
|
|
}
|
1997-10-09 13:34:15 +00:00
|
|
|
|
|
|
|
|
|
TFilename files;
|
|
|
|
|
TString_array list;
|
1995-04-28 13:21:43 +00:00
|
|
|
|
|
|
|
|
|
if (fexist(format("%scom/770", __ptprf)))
|
|
|
|
|
{
|
|
|
|
|
files.format("%scom/770/%s", __ptprf, "*");
|
1997-10-09 13:34:15 +00:00
|
|
|
|
list_files(files, list);
|
|
|
|
|
for (int i = list.items()-1; i >= 0; i--)
|
|
|
|
|
remove(list.row(i));
|
|
|
|
|
list.destroy();
|
2008-08-28 11:22:25 +00:00
|
|
|
|
xvt_fsys_rmdir(format("%scom/770", __ptprf));
|
1995-04-28 13:21:43 +00:00
|
|
|
|
}
|
|
|
|
|
if (fexist(format("%s770", __ptprf)))
|
|
|
|
|
{
|
|
|
|
|
files.format("%s770/%s", __ptprf, "*");
|
1997-10-09 13:34:15 +00:00
|
|
|
|
list_files(files, list);
|
|
|
|
|
for (int i = list.items()-1; i >= 0; i--)
|
|
|
|
|
remove(list.row(i));
|
|
|
|
|
list.destroy();
|
2008-08-28 11:22:25 +00:00
|
|
|
|
xvt_fsys_rmdir(format("%s770", __ptprf));
|
1995-04-28 13:21:43 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
1995-06-28 12:29:40 +00:00
|
|
|
|
void TConversione_archivi::convert_patty()
|
|
|
|
|
{
|
1995-09-29 11:51:54 +00:00
|
|
|
|
{
|
2008-08-28 11:22:25 +00:00
|
|
|
|
TTable ivd("%IVD");
|
|
|
|
|
ivd.zero();
|
|
|
|
|
ivd.put("CODTAB", "9E0023");
|
|
|
|
|
if (ivd.read(_isequal, _lock) == NOERR)
|
|
|
|
|
ivd.remove();
|
|
|
|
|
ivd.put("CODTAB", "9E 23");
|
|
|
|
|
if (ivd.read(_isequal, _lock) == NOERR)
|
|
|
|
|
ivd.remove();
|
|
|
|
|
ivd.put("CODTAB", "9E 23");
|
|
|
|
|
if (ivd.read(_isequal, _lock) == NOERR)
|
|
|
|
|
ivd.remove();
|
1995-09-29 11:51:54 +00:00
|
|
|
|
}
|
2008-08-28 11:22:25 +00:00
|
|
|
|
{
|
|
|
|
|
TTable doc("%TPD");
|
|
|
|
|
doc.zero();
|
|
|
|
|
doc.put("CODTAB", "AN");
|
|
|
|
|
if (doc.read(_isequal, _lock) == NOERR)
|
|
|
|
|
doc.remove();
|
|
|
|
|
doc.zero();
|
|
|
|
|
doc.put("CODTAB", "IN");
|
|
|
|
|
if (doc.read(_isequal, _lock) == NOERR)
|
|
|
|
|
doc.remove();
|
|
|
|
|
doc.zero();
|
|
|
|
|
doc.put("CODTAB", "PG");
|
|
|
|
|
if (doc.read(_isequal, _lock) == NOERR)
|
|
|
|
|
doc.remove();
|
|
|
|
|
doc.zero();
|
|
|
|
|
doc.put("CODTAB", "NA");
|
|
|
|
|
if (doc.read(_isequal, _lock) == NOERR)
|
|
|
|
|
doc.remove();
|
|
|
|
|
doc.zero();
|
|
|
|
|
doc.put("CODTAB", "NC");
|
|
|
|
|
if (doc.read(_isequal, _lock) == NOERR)
|
|
|
|
|
{
|
|
|
|
|
doc.put("S0", "Nota di credito");
|
|
|
|
|
doc.put("I0", "9");
|
|
|
|
|
doc.rewrite();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
TAssoc_array causarr;
|
1995-06-30 11:06:17 +00:00
|
|
|
|
|
2008-08-28 11:22:25 +00:00
|
|
|
|
TDir d;
|
|
|
|
|
d.get(LF_CAUSALI,_nolock,_nordir,_sysdirop);
|
|
|
|
|
if (d.is_com())
|
|
|
|
|
d.get(LF_CAUSALI,_nolock,_comdir);
|
1995-06-30 11:06:17 +00:00
|
|
|
|
|
2008-08-28 11:22:25 +00:00
|
|
|
|
if (d.eod() > 0L)
|
1995-06-28 12:29:40 +00:00
|
|
|
|
{
|
2008-08-28 11:22:25 +00:00
|
|
|
|
TLocalisamfile caus(LF_CAUSALI);
|
|
|
|
|
for (caus.first(_lock); caus.good(); caus.next(_lock))
|
|
|
|
|
{
|
|
|
|
|
const TString16 tpd(caus.get("TIPODOC"));
|
|
|
|
|
const TString16 incimm(caus.get("CODCAUSIM"));
|
|
|
|
|
|
|
|
|
|
if (incimm.not_empty())
|
|
|
|
|
causarr.add(incimm, incimm);
|
|
|
|
|
if (tpd == "AN") caus.zero("TIPODOC");
|
1995-06-28 12:29:40 +00:00
|
|
|
|
else
|
2008-08-28 11:22:25 +00:00
|
|
|
|
if (tpd == "IN") caus.zero("TIPODOC");
|
1995-06-28 12:29:40 +00:00
|
|
|
|
else
|
2008-08-28 11:22:25 +00:00
|
|
|
|
if (tpd == "PG") caus.zero("TIPODOC");
|
|
|
|
|
else
|
|
|
|
|
if (tpd == "NA") caus.put("TIPODOC","NC");
|
|
|
|
|
|
|
|
|
|
caus.rewrite();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
const bool topatch = causarr.items() > 0;
|
1995-06-30 11:06:17 +00:00
|
|
|
|
|
2008-08-28 11:22:25 +00:00
|
|
|
|
d.get(LF_MOV);
|
|
|
|
|
if (d.eod() > 0L)
|
1995-06-28 12:29:40 +00:00
|
|
|
|
{
|
2008-08-28 11:22:25 +00:00
|
|
|
|
TLocalisamfile mov(LF_MOV);
|
|
|
|
|
|
|
|
|
|
for (mov.first(_lock); mov.good(); mov.next(_lock))
|
1995-06-30 11:06:17 +00:00
|
|
|
|
{
|
2008-08-28 11:22:25 +00:00
|
|
|
|
const TString16 tpd(mov.get("TIPODOC"));
|
|
|
|
|
if (topatch)
|
1995-06-30 11:06:17 +00:00
|
|
|
|
{
|
2008-08-28 11:22:25 +00:00
|
|
|
|
const TString16 codcaus(mov.get("CODCAUS"));
|
|
|
|
|
|
|
|
|
|
if (causarr.objptr(codcaus) != NULL)
|
|
|
|
|
{
|
|
|
|
|
mov.zero("DATA74TER");
|
|
|
|
|
mov.zero("REG");
|
|
|
|
|
mov.zero("PROTIVA");
|
|
|
|
|
mov.zero("UPROTIVA");
|
|
|
|
|
mov.zero("REGST");
|
|
|
|
|
mov.zero("TIPO");
|
|
|
|
|
mov.zero("CODCF");
|
|
|
|
|
mov.zero("TOTDOC");
|
|
|
|
|
mov.zero("RITFIS");
|
|
|
|
|
mov.zero("RITSOC");
|
|
|
|
|
mov.zero("PROVVIS");
|
|
|
|
|
mov.zero("CODVALI");
|
|
|
|
|
mov.zero("CAMBIOI");
|
|
|
|
|
mov.zero("CORRLIRE");
|
|
|
|
|
mov.zero("CORRVALUTA");
|
|
|
|
|
mov.zero("OCFPI");
|
|
|
|
|
mov.zero("CODPAG");
|
|
|
|
|
}
|
1995-06-30 11:06:17 +00:00
|
|
|
|
}
|
2008-08-28 11:22:25 +00:00
|
|
|
|
if (tpd == "AN") mov.zero("TIPODOC");
|
1995-06-28 12:29:40 +00:00
|
|
|
|
else
|
2008-08-28 11:22:25 +00:00
|
|
|
|
if (tpd == "IN") mov.zero("TIPODOC");
|
1995-06-28 12:29:40 +00:00
|
|
|
|
else
|
2008-08-28 11:22:25 +00:00
|
|
|
|
if (tpd == "PG") mov.zero("TIPODOC");
|
|
|
|
|
else
|
|
|
|
|
if (tpd == "NA") mov.put("TIPODOC","NC");
|
|
|
|
|
mov.rewrite();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (_codditta == 0)
|
|
|
|
|
{
|
|
|
|
|
TDir d;
|
|
|
|
|
TSystemisamfile f(LF_FORM);
|
|
|
|
|
TFilename lf;
|
|
|
|
|
|
|
|
|
|
d.get(LF_FORM);
|
|
|
|
|
lf.format("%sstd/lf0054.txt", __ptprf);
|
|
|
|
|
if (fexist(lf) && fexist(d.filename()))
|
|
|
|
|
f.load(lf);
|
1995-06-28 12:29:40 +00:00
|
|
|
|
}
|
1995-10-25 16:15:27 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TConversione_archivi::convert_caus_attiv()
|
|
|
|
|
{
|
|
|
|
|
{
|
|
|
|
|
TLocalisamfile attiv(LF_ATTIV);
|
|
|
|
|
TProgind p(attiv.items(), "Conversione archivio attivita'", FALSE, TRUE,20);
|
|
|
|
|
p.setstatus(1L);
|
|
|
|
|
for (attiv.first(); !attiv.eof(); attiv.next())
|
|
|
|
|
{
|
|
|
|
|
bool val = attiv.get_bool("ART74/4");
|
|
|
|
|
attiv.put("ART74_4", val);
|
|
|
|
|
attiv.rewrite();
|
|
|
|
|
p.addstatus(1L);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
TLocalisamfile ditte(LF_NDITTE);
|
|
|
|
|
TProgind p(ditte.items(), "Conversione archivi causali", FALSE, TRUE,5);
|
|
|
|
|
p.setstatus(1L);
|
|
|
|
|
set_autoload_new_files(FALSE);
|
|
|
|
|
for (ditte.first(); !ditte.eof(); ditte.next())
|
|
|
|
|
{
|
|
|
|
|
const long codditta = ditte.get_long("CODDITTA");
|
|
|
|
|
if (prefix().exist(codditta))
|
|
|
|
|
{
|
|
|
|
|
p.set_text(format("Ditta: %ld",codditta));
|
|
|
|
|
set_firm(codditta);
|
|
|
|
|
TLocalisamfile caus(LF_CAUSALI);
|
|
|
|
|
caus.zero();
|
|
|
|
|
caus.put("CODCAUS","C08");
|
|
|
|
|
if (caus.read() == NOERR)
|
|
|
|
|
caus.put("TIPODOC","FS");
|
|
|
|
|
caus.rewrite();
|
|
|
|
|
}
|
|
|
|
|
p.addstatus(1);
|
|
|
|
|
}
|
|
|
|
|
p.setstatus(ditte.items());
|
|
|
|
|
prefix().set("com");
|
|
|
|
|
set_autoload_new_files(TRUE);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TConversione_archivi::convert_profili()
|
|
|
|
|
{
|
|
|
|
|
TSystemisamfile form(LF_FORM),rform(LF_RFORM);
|
|
|
|
|
TDir d;
|
|
|
|
|
TFilename lf;
|
|
|
|
|
|
|
|
|
|
d.get(LF_FORM, _nolock, _comdir, _sysdirop);
|
2008-12-10 16:55:06 +00:00
|
|
|
|
d.set_eod(0);
|
1995-10-25 16:15:27 +00:00
|
|
|
|
d.put(LF_FORM, _comdir, _sysdirop);
|
|
|
|
|
form.pack();
|
|
|
|
|
lf.format("%sstd/lf0054.txt", __ptprf);
|
|
|
|
|
if (fexist(lf)) form.load(lf);
|
|
|
|
|
d.get(LF_RFORM, _nolock, _comdir, _sysdirop);
|
2008-12-10 16:55:06 +00:00
|
|
|
|
d.set_eod(0);
|
1995-10-25 16:15:27 +00:00
|
|
|
|
d.put(LF_RFORM, _comdir, _sysdirop);
|
|
|
|
|
rform.pack();
|
1995-06-28 12:29:40 +00:00
|
|
|
|
}
|
|
|
|
|
|
1995-08-08 10:11:13 +00:00
|
|
|
|
void TConversione_archivi::convert_codconc()
|
|
|
|
|
{
|
|
|
|
|
// costruisce le tabelle di confronto
|
|
|
|
|
TAssoc_array conc_cessate;
|
|
|
|
|
TScanner oc(format("%sstd/oconc00.txt", __ptprf));
|
|
|
|
|
|
|
|
|
|
for (TString16 s(oc.line()); s.not_empty(); s = oc.line())
|
|
|
|
|
conc_cessate.add(s);
|
|
|
|
|
// (fase 1)
|
|
|
|
|
// scorre il file anagrafica
|
|
|
|
|
TLocalisamfile anagr(LF_ANAG);
|
|
|
|
|
TLocalisamfile comuni(LF_COMUNI);
|
|
|
|
|
int nerr = 0;
|
|
|
|
|
// se il file anagrafica non <20> vuoto
|
1995-09-29 11:51:54 +00:00
|
|
|
|
const long anag_items = anagr.items();
|
1995-08-08 10:11:13 +00:00
|
|
|
|
if (anag_items > 0)
|
|
|
|
|
{
|
|
|
|
|
TProgind p(anag_items, "Conversione archivio anagrafica", FALSE, TRUE, 70);
|
|
|
|
|
|
|
|
|
|
p.setstatus(1L);
|
|
|
|
|
|
|
|
|
|
// per ogni anagrafica blocca il record
|
|
|
|
|
for (anagr.first(_lock); anagr.good(); anagr.next(_lock))
|
|
|
|
|
{
|
|
|
|
|
// legge il codice comune
|
|
|
|
|
TString16 com = anagr.get("COMRF");
|
1995-08-08 13:05:45 +00:00
|
|
|
|
|
|
|
|
|
p.addstatus(1);
|
1995-08-08 10:11:13 +00:00
|
|
|
|
if (com.empty())
|
1995-09-29 11:51:54 +00:00
|
|
|
|
com = anagr.get("COMRES");
|
1995-08-08 10:11:13 +00:00
|
|
|
|
// se il comune non <20> vuoto recupera il comune
|
|
|
|
|
if (com.not_empty())
|
|
|
|
|
{
|
|
|
|
|
comuni.zero();
|
|
|
|
|
comuni.put("COM", com);
|
|
|
|
|
// se non <20> un comune di una nuova provincia e il comune esiste
|
|
|
|
|
if (!conc_cessate.is_key(com))
|
|
|
|
|
{
|
|
|
|
|
if (comuni.read() == NOERR)
|
|
|
|
|
{
|
|
|
|
|
// legge il codice concessione
|
|
|
|
|
TString16 conc(comuni.get("UFFCONC"));
|
|
|
|
|
// se il codice concessione <20> cessato
|
|
|
|
|
if (conc_cessate.is_key(conc))
|
|
|
|
|
{
|
|
|
|
|
// scrive il codice concessione sull' anagrafica
|
|
|
|
|
anagr.put("UFFCONC", conc);
|
|
|
|
|
anagr.rewrite();
|
|
|
|
|
}
|
|
|
|
|
// altrimenti sblocca il record
|
|
|
|
|
else
|
|
|
|
|
anagr.read(_iscurr, _unlock);
|
|
|
|
|
}
|
|
|
|
|
// altrimenti sblocca il record e conteggia l' errore
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
anagr.read(_iscurr, _unlock);
|
|
|
|
|
nerr++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// altrimenti sblocca il record
|
|
|
|
|
else
|
|
|
|
|
anagr.read(_iscurr, _unlock);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// segnala gli errori
|
1995-10-02 11:11:53 +00:00
|
|
|
|
#ifdef DBG
|
1995-08-08 10:11:13 +00:00
|
|
|
|
if (nerr)
|
1995-09-29 11:51:54 +00:00
|
|
|
|
error_box("La conversione della anagrafiche non ha trovato %d comuni", nerr);
|
|
|
|
|
nerr = 0;
|
1995-10-02 11:11:53 +00:00
|
|
|
|
#endif
|
1995-08-08 10:11:13 +00:00
|
|
|
|
|
|
|
|
|
// (fase 2)
|
|
|
|
|
// vuota la tabella concessioni
|
|
|
|
|
{
|
|
|
|
|
TTable uffconc("%UCC");
|
|
|
|
|
|
|
|
|
|
for (uffconc.first(_lock); uffconc.good(); uffconc.next(_lock))
|
|
|
|
|
uffconc.remove();
|
|
|
|
|
}
|
|
|
|
|
// carica la nuova
|
|
|
|
|
{
|
|
|
|
|
TSystemisamfile tabcom(LF_TABCOM);
|
|
|
|
|
|
|
|
|
|
tabcom.load(format("%sstd/nconc00.txt", __ptprf));
|
|
|
|
|
}
|
|
|
|
|
// (fase 3)
|
|
|
|
|
// scorre il file con i codici comuni e le nuove concessioni
|
|
|
|
|
TScanner nc(format("%sstd/ncom00.txt", __ptprf));
|
1995-09-29 11:51:54 +00:00
|
|
|
|
TProgind p(comuni.items(), "Conversione archivio comuni", FALSE, TRUE, 70);
|
|
|
|
|
TToken_string comass;
|
1995-08-08 10:11:13 +00:00
|
|
|
|
#ifdef DBG
|
|
|
|
|
TTable uffconc("%UCC");
|
|
|
|
|
TToken_string concerr;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
p.setstatus(1L);
|
|
|
|
|
// per ogni comune
|
|
|
|
|
for (TToken_string ts(nc.line()); ts.not_empty(); ts = nc.line())
|
|
|
|
|
{
|
|
|
|
|
p.addstatus(1);
|
|
|
|
|
// cerca il comune
|
|
|
|
|
comuni.zero();
|
|
|
|
|
comuni.put("COM", ts.get());
|
|
|
|
|
// se esiste
|
|
|
|
|
if (comuni.read(_isequal, _lock) == NOERR)
|
|
|
|
|
{
|
|
|
|
|
// aggiorna il codice concessione sul comune in oggetto
|
|
|
|
|
comuni.put("UFFCONC", ts.get());
|
|
|
|
|
comuni.rewrite();
|
|
|
|
|
#ifdef DBG
|
|
|
|
|
uffconc.zero();
|
|
|
|
|
uffconc.put("CODTAB", comuni.get("UFFCONC"));
|
|
|
|
|
if (uffconc.read() != NOERR)
|
1995-09-29 11:51:54 +00:00
|
|
|
|
concerr.add(comuni.get("UFFCONC"));
|
1995-08-08 10:11:13 +00:00
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
// altrimenti sblocca il record e conteggia l' errore
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
comuni.read(_iscurr, _unlock);
|
1995-09-29 11:51:54 +00:00
|
|
|
|
comass.add(ts.get(0));
|
1995-08-08 10:11:13 +00:00
|
|
|
|
nerr++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// segnala gli errori
|
1995-10-02 11:11:53 +00:00
|
|
|
|
#ifdef DBG
|
1995-08-08 10:11:13 +00:00
|
|
|
|
if (nerr)
|
1995-09-29 11:51:54 +00:00
|
|
|
|
error_box("La conversione dei comuni non ne ha trovati %d\n Codici : %s", nerr, (const char *) comass);
|
1995-08-08 10:11:13 +00:00
|
|
|
|
if (concerr.not_empty())
|
1995-09-29 11:51:54 +00:00
|
|
|
|
error_box("Le seguenti concessioni sono inesistenti %s", (const char *) concerr);
|
1995-08-08 10:11:13 +00:00
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
1995-11-16 11:38:08 +00:00
|
|
|
|
void TConversione_archivi::rebuild_indexes()
|
|
|
|
|
{
|
|
|
|
|
do_events();
|
|
|
|
|
begin_wait();
|
|
|
|
|
prefix().set("com");
|
|
|
|
|
rebuild_dir_indexes();
|
|
|
|
|
TSystemisamfile ditte(LF_NDITTE);
|
|
|
|
|
ditte.open();
|
|
|
|
|
|
|
|
|
|
for (ditte.first(); !ditte.eof(); ditte.next())
|
|
|
|
|
{
|
|
|
|
|
const long codditta = ditte.get_long("CODDITTA");
|
|
|
|
|
const TRecnotype rec = ditte.recno();
|
|
|
|
|
|
|
|
|
|
if (prefix().exist(codditta))
|
|
|
|
|
{
|
|
|
|
|
ditte.close();
|
|
|
|
|
set_firm(codditta);
|
|
|
|
|
rebuild_dir_indexes();
|
|
|
|
|
ditte.open();
|
|
|
|
|
}
|
|
|
|
|
ditte.readat(rec);
|
|
|
|
|
}
|
|
|
|
|
ditte.close();
|
|
|
|
|
end_wait();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TConversione_archivi::rebuild_dir_indexes()
|
|
|
|
|
{
|
|
|
|
|
const TString pref(prefix().name());
|
|
|
|
|
const bool is_com = prefix().is_com();
|
|
|
|
|
TDir d;
|
|
|
|
|
|
|
|
|
|
d.get(LF_DIR);
|
|
|
|
|
const int items = (int)d.eod();
|
|
|
|
|
TString80 s("Ricostruzione indici ");
|
|
|
|
|
|
|
|
|
|
if (is_com) s << "comuni";
|
|
|
|
|
else s << " della ditta " << atol (pref);
|
|
|
|
|
|
|
|
|
|
TProgind p(items ? items : 1, s, TRUE, TRUE, 70);
|
|
|
|
|
|
|
|
|
|
p.setstatus(1);
|
|
|
|
|
|
|
|
|
|
for (int i = 2; i <= items; i++)
|
|
|
|
|
{
|
|
|
|
|
p.addstatus(1);
|
|
|
|
|
if (d.len() > 0)
|
|
|
|
|
{
|
|
|
|
|
d.get(i, _nolock, _nordir, _sysdirop);
|
|
|
|
|
bool to_create = (is_com ? d.is_com() : d.is_firm());
|
|
|
|
|
|
|
|
|
|
if (to_create)
|
1996-01-29 13:57:00 +00:00
|
|
|
|
{
|
|
|
|
|
TBaseisamfile f(i);
|
1995-11-16 11:38:08 +00:00
|
|
|
|
d.get(i);
|
|
|
|
|
TFilename s(d.name());
|
|
|
|
|
s.ext("dbf");
|
2002-09-13 14:56:23 +00:00
|
|
|
|
if (f.is_valid(true) == NOERR && fexist(s))
|
1995-11-16 11:38:08 +00:00
|
|
|
|
{
|
|
|
|
|
TSystemisamfile f(i);
|
|
|
|
|
f.packindex();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
1996-01-09 10:30:18 +00:00
|
|
|
|
|
1996-03-21 09:21:48 +00:00
|
|
|
|
void TConversione_archivi::convert_codreg() const
|
|
|
|
|
{
|
|
|
|
|
// (fase 1)
|
|
|
|
|
// allinea i comuni alle nuove provincie e carica il codice regione
|
|
|
|
|
// costruisce la tabella comuni -> nuove provincie
|
|
|
|
|
#ifdef DBG
|
|
|
|
|
int nerr = 0;
|
|
|
|
|
#endif
|
|
|
|
|
TAssoc_array compro;
|
1996-01-09 10:30:18 +00:00
|
|
|
|
|
1996-03-21 09:21:48 +00:00
|
|
|
|
{
|
|
|
|
|
TScanner oc(format("%sstd/tbcompro.txt", __ptprf));
|
1996-01-09 10:30:18 +00:00
|
|
|
|
|
1996-03-21 09:21:48 +00:00
|
|
|
|
for (TToken_string s(oc.line()); s.not_empty(); s = oc.line())
|
|
|
|
|
{
|
|
|
|
|
TString16 codcom(s.get(0));
|
|
|
|
|
|
|
|
|
|
compro.add(codcom, s);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// costruisce la tabella provincie -> regioni
|
|
|
|
|
TAssoc_array proreg;
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
TScanner oc(format("%sstd/tbproreg.txt", __ptprf));
|
1996-01-09 10:30:18 +00:00
|
|
|
|
|
1996-03-21 09:21:48 +00:00
|
|
|
|
for (TToken_string s(oc.line()); s.not_empty(); s = oc.line())
|
1996-01-09 10:30:18 +00:00
|
|
|
|
{
|
1996-03-21 09:21:48 +00:00
|
|
|
|
TString16 prov(s.get(0));
|
|
|
|
|
TString16 codreg(s.get());
|
|
|
|
|
|
|
|
|
|
proreg.add(prov, codreg);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// scorre il file comuni
|
|
|
|
|
TLocalisamfile comuni(LF_COMUNI);
|
|
|
|
|
// se il file comuni non <20> vuoto
|
|
|
|
|
const long com_items = comuni.items();
|
|
|
|
|
if (com_items > 0)
|
|
|
|
|
{
|
1996-03-22 15:08:47 +00:00
|
|
|
|
TProgind p(com_items, "Conversione archivio comuni", FALSE, TRUE, 70);
|
1996-03-21 09:21:48 +00:00
|
|
|
|
|
|
|
|
|
p.setstatus(1L);
|
|
|
|
|
|
|
|
|
|
// per ogni comune
|
|
|
|
|
for (comuni.first(); comuni.good(); comuni.next())
|
|
|
|
|
{
|
|
|
|
|
bool rewrite = FALSE;
|
|
|
|
|
|
|
|
|
|
p.addstatus(1);
|
|
|
|
|
const TString & cod = comuni.get("COM");
|
|
|
|
|
TToken_string * t = (TToken_string *) compro.objptr(cod);
|
|
|
|
|
|
|
|
|
|
if (t != NULL)
|
|
|
|
|
{
|
|
|
|
|
comuni.put("PROVCOM", t->get(1));
|
|
|
|
|
comuni.put("CODISTAT", t->get());
|
1996-03-22 15:08:47 +00:00
|
|
|
|
comuni.put("UFFIVA1", t->get());
|
|
|
|
|
comuni.zero("UFFIVA2");
|
|
|
|
|
comuni.zero("UFFIVA3");
|
1996-03-21 09:21:48 +00:00
|
|
|
|
rewrite = TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const TString & prov = comuni.get("PROVCOM");
|
|
|
|
|
TString16 * s = (TString16 *) proreg.objptr(prov);
|
|
|
|
|
|
|
|
|
|
if (s != NULL)
|
|
|
|
|
{
|
|
|
|
|
comuni.put("CODREG", *s);
|
|
|
|
|
rewrite = TRUE;
|
|
|
|
|
}
|
|
|
|
|
#ifdef DBG
|
|
|
|
|
else
|
|
|
|
|
nerr++;
|
|
|
|
|
#endif
|
|
|
|
|
if (rewrite)
|
|
|
|
|
comuni.rewrite();
|
1996-01-09 10:30:18 +00:00
|
|
|
|
}
|
1996-03-21 09:21:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// (fase 2)
|
1996-03-27 11:29:24 +00:00
|
|
|
|
// compatta la tabella
|
|
|
|
|
{
|
|
|
|
|
TSystemisamfile tabcom(LF_TABCOM);
|
|
|
|
|
|
1996-03-28 11:41:01 +00:00
|
|
|
|
tabcom.pack(TRUE,FALSE);
|
1996-03-27 11:29:24 +00:00
|
|
|
|
}
|
1996-03-21 09:21:48 +00:00
|
|
|
|
// vuota la tabella concessioni
|
|
|
|
|
{
|
|
|
|
|
TTable uffconc("%UCC");
|
|
|
|
|
|
|
|
|
|
for (uffconc.first(_lock); uffconc.good(); uffconc.next(_lock))
|
|
|
|
|
uffconc.remove();
|
1996-01-09 10:30:18 +00:00
|
|
|
|
}
|
1996-03-21 09:21:48 +00:00
|
|
|
|
// carica la nuova
|
|
|
|
|
{
|
|
|
|
|
TSystemisamfile tabcom(LF_TABCOM);
|
|
|
|
|
|
|
|
|
|
tabcom.load(format("%sstd/nconc01.txt", __ptprf));
|
|
|
|
|
}
|
|
|
|
|
// (fase 3)
|
|
|
|
|
// vuota la tabella regioni
|
|
|
|
|
{
|
|
|
|
|
TTable regioni("%RGI");
|
|
|
|
|
|
|
|
|
|
for (regioni.first(_lock); regioni.good(); regioni.next(_lock))
|
|
|
|
|
regioni.remove();
|
|
|
|
|
}
|
|
|
|
|
// carica la nuova
|
|
|
|
|
{
|
|
|
|
|
TSystemisamfile tabcom(LF_TABCOM);
|
|
|
|
|
|
|
|
|
|
tabcom.load(format("%sstd/nreg00.txt", __ptprf));
|
1996-04-24 16:43:11 +00:00
|
|
|
|
}
|
1996-01-09 10:30:18 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
1996-04-24 16:43:11 +00:00
|
|
|
|
void TConversione_archivi::convert_lia_pim() const
|
|
|
|
|
{
|
|
|
|
|
// converte le Tokenstring contenute in S1 e S2 di PIM e %LIA, sostituendo | con !
|
|
|
|
|
TString80 s1,s2;
|
|
|
|
|
if (_codditta == 0)
|
|
|
|
|
{
|
|
|
|
|
TProgind p(10, "Conversione tabella LIA", FALSE, FALSE, 10);
|
|
|
|
|
TTable lia("%LIA");
|
|
|
|
|
for (lia.first(); lia.good(); lia.next())
|
|
|
|
|
{
|
|
|
|
|
s1 = lia.get("S1");
|
|
|
|
|
if (s1.not_empty())
|
|
|
|
|
if (s1.replace('|','!') > 0)
|
|
|
|
|
{
|
|
|
|
|
lia.put("S1",s1);
|
|
|
|
|
lia.rewrite();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
TProgind p(10, "Conversione tabella PIM", FALSE, FALSE, 10);
|
|
|
|
|
TTable pim("PIM");
|
|
|
|
|
for (pim.first(); pim.good(); pim.next())
|
|
|
|
|
{
|
|
|
|
|
s1 = pim.get("S1");
|
|
|
|
|
s2 = pim.get("S2");
|
|
|
|
|
if (s1.not_empty() || s2.not_empty())
|
|
|
|
|
if ((s1.replace('|','!')+s2.replace('|','!')) > 0)
|
|
|
|
|
{
|
|
|
|
|
pim.put("S1",s1);
|
|
|
|
|
pim.put("S2",s2);
|
|
|
|
|
pim.rewrite();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TConversione_archivi::build_ver_table() const
|
|
|
|
|
// Costruisce la tabella %VER con i valori in vigore da Gennaio 1993
|
|
|
|
|
{
|
2001-04-30 14:22:43 +00:00
|
|
|
|
/* OB600039
|
1996-04-24 16:43:11 +00:00
|
|
|
|
TProgind p(10, "Creazione tabella VER", FALSE, FALSE, 10);
|
|
|
|
|
TTable ver("%VER");
|
|
|
|
|
|
|
|
|
|
ver.zero();
|
|
|
|
|
// Come chiave si l'inizio del periodo di validita'
|
|
|
|
|
ver.put("CODTAB","199301");
|
|
|
|
|
// Percentuali interessi su versamento IVA per trimestri
|
|
|
|
|
// prima erano memorizzati in prassis.ini, nei parametri studio.
|
|
|
|
|
ver.put("R0","1.5"); ver.put("R1","1.5");
|
|
|
|
|
ver.put("R2","1.5"); ver.put("R3","1.5"); ver.put("R4","1.5");
|
|
|
|
|
// Importi limite versamenti. Prima erano defines all'interno
|
|
|
|
|
// del programma di liquidazione
|
|
|
|
|
ver.put("R5","50500"); ver.put("R7","200000");
|
|
|
|
|
// Percentuale calcolo acconti Base anno precedente
|
|
|
|
|
ver.put("R11","88");ver.put("R12","88");
|
|
|
|
|
|
|
|
|
|
if (ver.write() != NOERR) ver.rewrite();
|
2001-04-30 14:22:43 +00:00
|
|
|
|
*/
|
1996-04-24 16:43:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
1996-09-19 10:59:07 +00:00
|
|
|
|
void TConversione_archivi::convert_ca7_ql() const
|
|
|
|
|
// Converte la tabella %CA7 e QUADROL
|
1996-05-31 14:51:12 +00:00
|
|
|
|
{
|
|
|
|
|
TTable ca7("%CA7");
|
|
|
|
|
|
|
|
|
|
for (ca7.first(); ca7.good(); ca7.next())
|
|
|
|
|
{
|
|
|
|
|
TString s(ca7.get("S1"));
|
|
|
|
|
real i1(ca7.get("I1"));
|
|
|
|
|
ca7.put("R4",i1);
|
|
|
|
|
ca7.zero("I1");
|
|
|
|
|
if (ca7.get_bool("B1"))
|
|
|
|
|
ca7.put("S2","N");
|
|
|
|
|
if (!ca7.get_bool("B0") && s=="D1")
|
|
|
|
|
ca7.put("S3","F");
|
|
|
|
|
ca7.rewrite();
|
|
|
|
|
}
|
1996-09-19 10:59:07 +00:00
|
|
|
|
|
|
|
|
|
// Ora converte il quadro L
|
|
|
|
|
TLocalisamfile quadrol(LF_QUAL);
|
|
|
|
|
TString serie,numero;
|
|
|
|
|
for (quadrol.first(); quadrol.good(); quadrol.next())
|
|
|
|
|
if (quadrol.get_char("QLTV") == 'B')
|
|
|
|
|
{
|
|
|
|
|
TRectype com_rec(quadrol.curr());
|
|
|
|
|
serie.format("%05ld",quadrol.get_long("QLSERIE"));
|
|
|
|
|
numero.format("%05ld",quadrol.get_long("QLNUMERO"));
|
|
|
|
|
com_rec.put("QLSERIE",serie);
|
|
|
|
|
com_rec.put("QLNUMERO",numero);
|
|
|
|
|
quadrol.write(com_rec);
|
|
|
|
|
quadrol.remove();
|
|
|
|
|
}
|
1996-05-31 14:51:12 +00:00
|
|
|
|
}
|
|
|
|
|
|
1997-02-28 08:36:31 +00:00
|
|
|
|
|
|
|
|
|
// conversione in formato numerico del codice ente
|
|
|
|
|
// in modo che i codici inferiori a 10 non siano registrati
|
|
|
|
|
// nella forma "1 ","2 ", ecc.
|
|
|
|
|
// ma nella forma "01","02", ecc.
|
|
|
|
|
void TConversione_archivi::convert_enti_m770() const
|
|
|
|
|
{
|
|
|
|
|
TTable tab("%ENT");
|
|
|
|
|
TString new_cod;
|
|
|
|
|
TString old_cod;
|
|
|
|
|
int err;
|
|
|
|
|
|
|
|
|
|
for (err = tab.first(); err == NOERR; err = tab.next())
|
|
|
|
|
{
|
1997-06-05 14:25:34 +00:00
|
|
|
|
old_cod = tab.get("CODTAB");
|
|
|
|
|
if (old_cod.len() < 2)
|
|
|
|
|
{
|
|
|
|
|
TRectype new_rec(tab.curr());
|
|
|
|
|
new_cod.format("%02d",atoi(old_cod));
|
|
|
|
|
new_rec.put("CODTAB", new_cod);
|
|
|
|
|
tab.write(new_rec);
|
|
|
|
|
tab.remove();
|
|
|
|
|
}
|
1997-02-28 08:36:31 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// conversione in formato numerico del codice caaf
|
|
|
|
|
// in modo che i codici inferiori a 10000 non siano registrati
|
|
|
|
|
// nella forma "1 ","2 ", ecc.
|
|
|
|
|
// ma nella forma "00001","00002", ecc.
|
|
|
|
|
void TConversione_archivi::convert_caaf_m770() const
|
|
|
|
|
{
|
|
|
|
|
TTable tab("%CAF");
|
|
|
|
|
TString old_cod;
|
|
|
|
|
TString new_cod;
|
|
|
|
|
int err;
|
|
|
|
|
|
|
|
|
|
for (err = tab.first(); err == NOERR; err = tab.next())
|
|
|
|
|
{
|
1997-06-05 14:25:34 +00:00
|
|
|
|
old_cod = tab.get("CODTAB");
|
|
|
|
|
if (old_cod.len() < 5)
|
|
|
|
|
{
|
|
|
|
|
TRectype new_rec(tab.curr());
|
|
|
|
|
new_cod.format("%05ld",atol(old_cod));
|
|
|
|
|
new_rec.put("CODTAB", new_cod);
|
|
|
|
|
tab.write(new_rec);
|
|
|
|
|
tab.remove();
|
|
|
|
|
}
|
1997-02-28 08:36:31 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// conversione del numero progressivo banca
|
|
|
|
|
// per renderlo senmpre zerofilled
|
|
|
|
|
void TConversione_archivi::convert_rver_m770() const
|
|
|
|
|
{
|
|
|
|
|
TLocalisamfile lf(LF_RVER);
|
|
|
|
|
long progr_banca;
|
|
|
|
|
int err;
|
|
|
|
|
|
|
|
|
|
for (err = lf.first(); err == NOERR; err = lf.next())
|
|
|
|
|
{
|
1997-06-05 14:25:34 +00:00
|
|
|
|
progr_banca = lf.get_long("PROGBANC");
|
|
|
|
|
lf.put("PROGBANC", progr_banca);
|
|
|
|
|
lf.rewrite();
|
1997-02-28 08:36:31 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
1996-10-04 07:59:19 +00:00
|
|
|
|
void TConversione_archivi::remove_dta_ndx() const
|
|
|
|
|
{
|
1997-10-09 13:34:15 +00:00
|
|
|
|
TFilename s;
|
|
|
|
|
TString_array list;
|
1996-10-04 07:59:19 +00:00
|
|
|
|
|
|
|
|
|
for (int j = 0; j < 2; j++)
|
|
|
|
|
{
|
|
|
|
|
s = firm2dir(_codditta);
|
1997-10-09 13:34:15 +00:00
|
|
|
|
s.add(j == 0 ? "*.dta" : "*.ndx");
|
|
|
|
|
const int items = list_files(s, list);
|
|
|
|
|
for (int i = items-1; i >= 0; i--)
|
|
|
|
|
::remove(list.row(i));
|
|
|
|
|
list.destroy();
|
1996-10-04 07:59:19 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
1996-09-04 07:02:00 +00:00
|
|
|
|
void TConversione_archivi::convert_forms() const
|
|
|
|
|
// Converte i profili, aggiungendo il valore dell'offset verticale. Solo
|
|
|
|
|
// per i forms != PEC
|
|
|
|
|
{
|
|
|
|
|
TLocalisamfile rform(LF_RFORM),form(LF_FORM);
|
|
|
|
|
TString nome,nomeprec,cod,codprec;
|
|
|
|
|
int y,ipy;
|
|
|
|
|
TProgind p(5,"Conversione profili in corso...",FALSE,FALSE);
|
|
|
|
|
for (form.first();form.good();form.next())
|
|
|
|
|
{
|
|
|
|
|
nome = form.get("TIPOPROF");
|
|
|
|
|
cod = form.get("CODPROF");
|
|
|
|
|
ipy = form.get_int("IPY");
|
|
|
|
|
if (nome == "PEC" || ipy == 0) continue;
|
|
|
|
|
rform.put("TIPOPROF",nome);
|
|
|
|
|
rform.put("CODPROF",cod);
|
|
|
|
|
for (rform.read(_isgteq);rform.good();rform.next())
|
|
|
|
|
{
|
|
|
|
|
nomeprec = rform.get("TIPOPROF");
|
|
|
|
|
codprec = rform.get("CODPROF");
|
|
|
|
|
if (nomeprec != nome || codprec != cod) break;
|
|
|
|
|
y = rform.get_int("Y");
|
|
|
|
|
if (y > 0)
|
|
|
|
|
{
|
|
|
|
|
y += ipy;
|
|
|
|
|
rform.put("Y",y);
|
|
|
|
|
rform.rewrite();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
1996-09-05 16:19:36 +00:00
|
|
|
|
void TConversione_archivi::sort_sal(int year) const
|
|
|
|
|
{
|
|
|
|
|
TSystemisamfile saldi(LF_SALDI); saldi.open(_excllock);
|
|
|
|
|
TLocalisamfile rmov(LF_RMOV);
|
|
|
|
|
TLocalisamfile causali(LF_CAUSALI);
|
|
|
|
|
TLocalisamfile mov(LF_MOV);
|
|
|
|
|
TSaldo_agg sal;
|
|
|
|
|
|
|
|
|
|
int gruppo, conto;
|
|
|
|
|
long oldnumreg = 0L, sottoconto;
|
|
|
|
|
TString msg("Riordino archivio saldi ditta ");
|
|
|
|
|
msg << _codditta;
|
|
|
|
|
msg << " in corso\nLettura archivio movimenti...";
|
|
|
|
|
TProgind prnd(rmov.items(),msg, FALSE,TRUE,30);
|
|
|
|
|
|
|
|
|
|
causali.zero();
|
|
|
|
|
mov.setkey(1);
|
|
|
|
|
rmov.first();
|
|
|
|
|
sal.reset();
|
|
|
|
|
sal.set_anno_es(year);
|
|
|
|
|
sal.clear_saldi(year);
|
|
|
|
|
long numreg = 0L;
|
|
|
|
|
tiposal tsal = normale;
|
|
|
|
|
bool provvis = FALSE;
|
|
|
|
|
TDate datareg;
|
|
|
|
|
|
|
|
|
|
while (!rmov.eof())
|
|
|
|
|
{
|
|
|
|
|
if (year == rmov.get_int(RMV_ANNOES))
|
|
|
|
|
{
|
|
|
|
|
numreg = rmov.get_long(RMV_NUMREG);
|
|
|
|
|
|
|
|
|
|
gruppo = rmov.get_int(RMV_GRUPPO);
|
|
|
|
|
conto = rmov.get_int(RMV_CONTO);
|
|
|
|
|
sottoconto = rmov.get_long(RMV_SOTTOCONTO);
|
|
|
|
|
bool scaricato = FALSE;
|
|
|
|
|
|
|
|
|
|
if (numreg != oldnumreg)
|
|
|
|
|
{
|
|
|
|
|
if (oldnumreg !=0)
|
|
|
|
|
{
|
|
|
|
|
if (sal.items() > 0)
|
|
|
|
|
sal.registra();
|
|
|
|
|
}
|
|
|
|
|
oldnumreg = numreg;
|
|
|
|
|
mov.zero();
|
|
|
|
|
mov.put(MOV_NUMREG, numreg);
|
|
|
|
|
mov.read();
|
|
|
|
|
CHECK(mov.good(),"Archivi movimenti e righe inconsistenti");
|
|
|
|
|
|
|
|
|
|
causali.zero();
|
|
|
|
|
const char* codcaus = mov.get(MOV_CODCAUS);
|
|
|
|
|
|
|
|
|
|
tsal = normale;
|
|
|
|
|
if (*codcaus) // cerca causale per determinare il tipoo del saldo
|
|
|
|
|
{
|
|
|
|
|
causali.put(CAU_CODCAUS, codcaus);
|
|
|
|
|
const int err = causali.read();
|
|
|
|
|
if (err == NOERR)
|
|
|
|
|
{
|
|
|
|
|
const char ac = causali.get_char(CAU_MOVAP);
|
|
|
|
|
if (ac == 'A')
|
|
|
|
|
tsal = apertura;
|
|
|
|
|
else
|
|
|
|
|
if (ac == 'C')
|
|
|
|
|
tsal = chiusura;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
scaricato = mov.get_bool(MOV_SCARCON);
|
|
|
|
|
provvis = mov.get(MOV_PROVVIS).not_empty();
|
|
|
|
|
datareg = mov.get_date(MOV_DATAREG);
|
|
|
|
|
|
|
|
|
|
sal.reset();
|
|
|
|
|
sal.set_anno_es(year);
|
|
|
|
|
sal.set_tipo_saldo(tsal);
|
|
|
|
|
sal.set_movprovv(provvis);
|
|
|
|
|
sal.set_data_ulmov(datareg);
|
|
|
|
|
sal.set_num_ulmov(oldnumreg);
|
|
|
|
|
}
|
|
|
|
|
const char sezione = rmov.get(RMV_SEZIONE)[0];
|
|
|
|
|
real importo(rmov.get(RMV_IMPORTO));
|
|
|
|
|
|
|
|
|
|
sal.aggiorna(gruppo, conto, sottoconto, importo, sezione, TRUE, scaricato);
|
|
|
|
|
}
|
|
|
|
|
rmov.next();
|
|
|
|
|
prnd.addstatus(1);
|
|
|
|
|
do_events();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (sal.items() > 0)
|
|
|
|
|
sal.registra();
|
|
|
|
|
|
|
|
|
|
saldi.close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void TConversione_archivi::convert_saldi() const
|
|
|
|
|
// Effettua il ricalcolo saldi per tutti gli esercizi della ditta corrente
|
|
|
|
|
{
|
|
|
|
|
TTable esc("ESC");
|
|
|
|
|
for (esc.first();esc.good();esc.next())
|
|
|
|
|
{
|
|
|
|
|
const int year = atoi(esc.get("CODTAB"));
|
|
|
|
|
if (year == 0) continue;
|
|
|
|
|
sort_sal(year);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
1997-06-05 14:25:34 +00:00
|
|
|
|
// Effettua conversioni per tabella uffici centro servizi
|
|
|
|
|
void TConversione_archivi::convert_ucs() const
|
|
|
|
|
{
|
|
|
|
|
// Carica i Centri Servizi da modificare
|
|
|
|
|
TFilename fn;
|
|
|
|
|
fn.format("%sstd/tbucs00.txt", __ptprf);
|
|
|
|
|
if (fexist(fn))
|
|
|
|
|
{
|
|
|
|
|
TScanner c(fn);
|
|
|
|
|
TToken_string t;
|
|
|
|
|
TTable ucs("%UCS");
|
|
|
|
|
|
|
|
|
|
for (t = c.line(); t.not_empty(); t = c.line())
|
|
|
|
|
{
|
|
|
|
|
ucs.put("CODTAB",t.get(0));
|
|
|
|
|
if (ucs.read() == NOERR)
|
|
|
|
|
if (ucs.get("S1").empty())
|
|
|
|
|
{
|
|
|
|
|
ucs.put("S1",t.get(1));
|
|
|
|
|
ucs.put("S3",t.get(2));
|
|
|
|
|
ucs.put("S7",t.get(3));
|
|
|
|
|
ucs.put("S6",t.get(4));
|
|
|
|
|
ucs.rewrite();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Carica il nuovo centro servizi di Cagliari
|
|
|
|
|
fn.format("%sstd/tbucs01.txt", __ptprf);
|
|
|
|
|
if (fexist(fn))
|
|
|
|
|
{
|
|
|
|
|
TSystemisamfile tabcom(LF_TABCOM);
|
|
|
|
|
tabcom.load(fn);
|
|
|
|
|
// Scorre tutti i comuni della provincia di Cagliari e gli cambia il codice Ufficio Centro Servizi
|
|
|
|
|
TRelation com_rel(LF_COMUNI);
|
|
|
|
|
TCursor cur(&com_rel,"PROVCOM==\"CA\"");
|
|
|
|
|
TRectype& rec = cur.curr();
|
|
|
|
|
const long items = cur.items();
|
|
|
|
|
TProgind p(items,"Conversione comuni in provincia di Cagliari",FALSE,TRUE);
|
|
|
|
|
for (long i = 0; i<items; i++)
|
|
|
|
|
{
|
|
|
|
|
p.addstatus(1L);
|
|
|
|
|
cur = i;
|
|
|
|
|
rec.put("UFFCSERV","104");
|
|
|
|
|
cur.file().rewrite();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Effettua conversioni per uffici concessioni
|
|
|
|
|
void TConversione_archivi::convert_ucc() const
|
|
|
|
|
{
|
|
|
|
|
// Carica le nuove descrizioni per gli Uffici Concessioni
|
|
|
|
|
TFilename fn;
|
|
|
|
|
fn.format("%sstd/tbucc00.txt", __ptprf);
|
|
|
|
|
if (fexist(fn))
|
|
|
|
|
{
|
|
|
|
|
TScanner c(fn);
|
|
|
|
|
TToken_string t;
|
|
|
|
|
TTable ucc("%UCC");
|
|
|
|
|
TProgind p(1,"Conversione tabella Uffici Concessioni",FALSE,FALSE);
|
|
|
|
|
|
|
|
|
|
for (t = c.line(); t.not_empty(); t = c.line())
|
|
|
|
|
{
|
|
|
|
|
ucc.put("CODTAB",t.get(0));
|
|
|
|
|
if (ucc.read() == NOERR)
|
|
|
|
|
{
|
|
|
|
|
ucc.put("S2",t.get(1));
|
|
|
|
|
ucc.rewrite();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
1997-11-20 08:18:05 +00:00
|
|
|
|
|
|
|
|
|
// Effettua conversioni per uffici unici
|
|
|
|
|
void TConversione_archivi::convert_uue() const
|
|
|
|
|
{
|
|
|
|
|
TProgind pi(0, "Caricamento tabella Uffici Unici", FALSE, FALSE);
|
|
|
|
|
TSystemisamfile uue(LF_TABCOM);
|
1997-12-15 15:11:40 +00:00
|
|
|
|
TFilename lf;
|
|
|
|
|
lf = __ptprf;
|
|
|
|
|
lf.add("std/bacnv16a.txt");
|
1997-11-21 16:40:48 +00:00
|
|
|
|
uue.load(lf);
|
1997-11-20 08:18:05 +00:00
|
|
|
|
|
|
|
|
|
pi.set_text("Caricamento Uffici Unici nei comuni");
|
|
|
|
|
|
1997-11-26 12:01:21 +00:00
|
|
|
|
TAssoc_array cod_uue;
|
|
|
|
|
|
|
|
|
|
TSystemisamfile comuni(LF_COMUNI);
|
|
|
|
|
comuni.open(_excllock);
|
|
|
|
|
|
1997-12-15 15:11:40 +00:00
|
|
|
|
lf = __ptprf;
|
|
|
|
|
lf.add("std/bacnv16b.txt");
|
1997-11-21 16:40:48 +00:00
|
|
|
|
TScanner scan16b(lf);
|
1997-11-20 08:18:05 +00:00
|
|
|
|
|
|
|
|
|
TToken_string line;
|
|
|
|
|
TString16 cod, uff;
|
1997-11-21 16:40:48 +00:00
|
|
|
|
for (line = scan16b.line(); line.not_empty(); line = scan16b.line())
|
1997-11-20 08:18:05 +00:00
|
|
|
|
{
|
|
|
|
|
cod = line.get(0);
|
|
|
|
|
comuni.put("COM", cod);
|
1997-11-26 12:01:21 +00:00
|
|
|
|
int err = comuni.read(_isequal);
|
1997-11-20 08:18:05 +00:00
|
|
|
|
if (err == NOERR)
|
|
|
|
|
{
|
|
|
|
|
TString16 fieldname, fieldval;
|
|
|
|
|
uff = line.get(1);
|
|
|
|
|
int first_uue = 0;
|
|
|
|
|
for (int uue = 1; uue <= 10; uue++)
|
1997-11-26 12:01:21 +00:00
|
|
|
|
{
|
1997-11-20 08:18:05 +00:00
|
|
|
|
fieldname = "CODUUE"; fieldname << uue;
|
|
|
|
|
fieldval = comuni.get(fieldname);
|
1997-12-15 15:11:40 +00:00
|
|
|
|
if (first_uue == 0 && atoi(fieldval) == 0)
|
1997-11-20 08:18:05 +00:00
|
|
|
|
first_uue = uue;
|
|
|
|
|
if (fieldval == uff)
|
|
|
|
|
{
|
|
|
|
|
first_uue = 0;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (first_uue > 0)
|
|
|
|
|
{
|
|
|
|
|
fieldname = "CODUUE"; fieldname << first_uue;
|
|
|
|
|
comuni.put(fieldname, uff);
|
|
|
|
|
err = comuni.rewrite();
|
|
|
|
|
}
|
1997-12-15 15:11:40 +00:00
|
|
|
|
cod_uue.add(cod, comuni.get("CODUUE1"));
|
1997-11-20 08:18:05 +00:00
|
|
|
|
}
|
|
|
|
|
if (err != NOERR)
|
|
|
|
|
error_box("Impossibile aggiornare l'ufficio unico del comune %s: errore %d",
|
|
|
|
|
(const char*)cod, err);
|
|
|
|
|
}
|
1997-11-26 12:01:21 +00:00
|
|
|
|
comuni.close();
|
|
|
|
|
|
|
|
|
|
pi.set_text("Caricamento Uffici Unici nelle anagrafiche");
|
|
|
|
|
TSystemisamfile persone(LF_ANAG);
|
|
|
|
|
persone.open(_excllock);
|
|
|
|
|
|
|
|
|
|
for (int err = persone.first(); err == NOERR; err = persone.next())
|
|
|
|
|
{
|
|
|
|
|
if (persone.get("UFFUUE").empty())
|
|
|
|
|
{
|
|
|
|
|
cod = persone.get("COMRF");
|
|
|
|
|
if (cod.empty())
|
|
|
|
|
cod = persone.get("COMRES");
|
|
|
|
|
|
|
|
|
|
const TString* uffuue = (const TString*)cod_uue.objptr(cod);
|
|
|
|
|
if (uffuue)
|
|
|
|
|
{
|
|
|
|
|
persone.put("UFFUUE", *uffuue);
|
|
|
|
|
err = persone.rewrite();
|
|
|
|
|
if (err != NOERR)
|
|
|
|
|
error_box("Impossibile aggiornare l'ufficio unico sulle anagrafiche: errore %d", err);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
persone.close();
|
1997-11-20 08:18:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Effettua conversioni per nuovi cap
|
|
|
|
|
void TConversione_archivi::convert_cap() const
|
1997-11-26 12:01:21 +00:00
|
|
|
|
{
|
|
|
|
|
if (_codditta != 0)
|
|
|
|
|
return;
|
|
|
|
|
|
1997-11-20 08:18:05 +00:00
|
|
|
|
TLocalisamfile comuni(LF_COMUNI);
|
1997-11-21 16:40:48 +00:00
|
|
|
|
TFilename lf;
|
|
|
|
|
|
|
|
|
|
lf.format("%sstd/bacnv16c.txt", __ptprf);
|
1997-11-20 08:18:05 +00:00
|
|
|
|
|
1997-11-21 16:40:48 +00:00
|
|
|
|
TScanner scan16c(lf);
|
1997-11-20 08:18:05 +00:00
|
|
|
|
TToken_string line;
|
|
|
|
|
TString16 cod, oldcod, newcod;
|
|
|
|
|
|
|
|
|
|
TAssoc_array cap;
|
|
|
|
|
|
|
|
|
|
TProgind pi(0, "Aggiornamento CAP sui comuni", FALSE, FALSE);
|
1997-11-21 16:40:48 +00:00
|
|
|
|
for (line = scan16c.line(); line.not_empty(); line = scan16c.line())
|
1997-11-20 08:18:05 +00:00
|
|
|
|
{
|
|
|
|
|
cod = line.get(0);
|
|
|
|
|
oldcod = line.get();
|
|
|
|
|
newcod = line.get();
|
1997-11-26 12:01:21 +00:00
|
|
|
|
|
|
|
|
|
oldcod.insert(cod, 0); // La chiave e' comune+cap
|
1997-11-20 08:18:05 +00:00
|
|
|
|
cap.add(oldcod, newcod);
|
|
|
|
|
|
|
|
|
|
if (_codditta == 0L)
|
|
|
|
|
{
|
|
|
|
|
comuni.put("COM", cod);
|
|
|
|
|
int err = comuni.read(_isequal, _lock);
|
|
|
|
|
if (err == NOERR)
|
|
|
|
|
{
|
|
|
|
|
comuni.put("CAPCOM", newcod);
|
|
|
|
|
err = comuni.rewrite();
|
|
|
|
|
}
|
|
|
|
|
if (err != NOERR)
|
|
|
|
|
error_box("Impossibile aggiornare il cap del comune %s: errore %d",
|
|
|
|
|
(const char*)cod, err);
|
|
|
|
|
}
|
|
|
|
|
}
|
1997-11-21 16:40:48 +00:00
|
|
|
|
scan16c.close();
|
1997-11-20 08:18:05 +00:00
|
|
|
|
|
1997-11-26 12:01:21 +00:00
|
|
|
|
TDir dir;
|
|
|
|
|
|
1997-11-20 08:18:05 +00:00
|
|
|
|
TString msg;
|
1997-11-26 12:01:21 +00:00
|
|
|
|
TToken_string com_cap(15, ',');
|
1997-11-21 16:40:48 +00:00
|
|
|
|
lf.format("%sstd/bacnv16d.txt", __ptprf);
|
|
|
|
|
TScanner scan16d(lf);
|
|
|
|
|
for (line = scan16d.line(); line.not_empty(); line = scan16d.line())
|
1997-11-20 08:18:05 +00:00
|
|
|
|
{
|
1997-11-26 12:01:21 +00:00
|
|
|
|
const TString16 cod = line.get(0);
|
1997-11-20 08:18:05 +00:00
|
|
|
|
const int logicnum = atoi(cod);
|
|
|
|
|
TLocalisamfile* file = NULL;
|
|
|
|
|
if (logicnum > 0)
|
|
|
|
|
file = new TLocalisamfile(logicnum);
|
|
|
|
|
else
|
1997-11-26 12:01:21 +00:00
|
|
|
|
file = new TTable(cod);
|
|
|
|
|
|
|
|
|
|
dir.get(file->num(), _nolock, _nordir, _sysdirop);
|
1999-04-16 12:02:04 +00:00
|
|
|
|
const bool good_file = dir.is_com() ^ (_codditta != 0);
|
1997-11-26 12:01:21 +00:00
|
|
|
|
if (!good_file)
|
1997-11-20 08:18:05 +00:00
|
|
|
|
{
|
1997-11-26 12:01:21 +00:00
|
|
|
|
delete file;
|
|
|
|
|
file = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
1997-11-20 08:18:05 +00:00
|
|
|
|
if (file != NULL)
|
|
|
|
|
{
|
|
|
|
|
msg = "Aggiornamento CAP sul file ";
|
|
|
|
|
msg << cod;
|
|
|
|
|
pi.set_text(msg);
|
|
|
|
|
|
|
|
|
|
for (int err = file->first(); err == NOERR; err = file->next())
|
|
|
|
|
{
|
|
|
|
|
bool dirty = FALSE;
|
1997-11-26 12:01:21 +00:00
|
|
|
|
for (com_cap = line.get(1); com_cap.not_empty(); com_cap = line.get())
|
1997-11-20 08:18:05 +00:00
|
|
|
|
{
|
1997-11-26 12:01:21 +00:00
|
|
|
|
oldcod = file->get(com_cap.get(0));
|
|
|
|
|
const TString16 cap_field = com_cap.get();
|
|
|
|
|
oldcod << file->get(cap_field);
|
1997-11-20 08:18:05 +00:00
|
|
|
|
TString* newcod = (TString*)cap.objptr(oldcod);
|
|
|
|
|
if (newcod)
|
|
|
|
|
{
|
1997-11-26 12:01:21 +00:00
|
|
|
|
file->put(cap_field, *newcod);
|
1997-11-20 08:18:05 +00:00
|
|
|
|
dirty = TRUE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (dirty)
|
|
|
|
|
{
|
|
|
|
|
int err = file->rewrite();
|
|
|
|
|
if (err != NOERR)
|
|
|
|
|
error_box("Errore di aggiornamento %d", err);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
delete file;
|
|
|
|
|
}
|
|
|
|
|
}
|
1997-11-21 16:40:48 +00:00
|
|
|
|
scan16d.close();
|
1997-11-20 08:18:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
1998-04-30 14:38:35 +00:00
|
|
|
|
// Effettua copia dei PIM in PRM, come richiesto dalla PRASSI
|
|
|
|
|
void TConversione_archivi::convert_pim2prm() const
|
|
|
|
|
{
|
|
|
|
|
TTable pim("PIM");
|
|
|
|
|
TTable prm("PRM");
|
|
|
|
|
TString anno;
|
|
|
|
|
|
|
|
|
|
TProgind pi(0, "Copia progressi IVA / progressivi Registri...", FALSE, FALSE);
|
|
|
|
|
for (pim.first(); !pim.eof(); pim.next())
|
|
|
|
|
{
|
|
|
|
|
anno = pim.get("CODTAB").mid(0,4);
|
|
|
|
|
if (atoi(anno) > 1997)
|
|
|
|
|
{
|
|
|
|
|
prm.curr() = pim.curr();
|
|
|
|
|
prm.put("COD", "PRM");
|
|
|
|
|
prm.write(); // Ignora eventuali errori, li scrive solo se non ci sono
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2000-10-03 13:45:12 +00:00
|
|
|
|
// Aggiunge il tipo cliente C alle ricevute bancarie
|
|
|
|
|
void TConversione_archivi::convert_riba_tcf() const
|
|
|
|
|
{
|
|
|
|
|
TLocalisamfile f(LF_EFFETTI);
|
|
|
|
|
TRectype& r = f.curr();
|
|
|
|
|
long n = f.items();
|
|
|
|
|
TProgind p(n, format("Conversione effetti ditta %ld", get_firm()), FALSE, TRUE, 70);
|
|
|
|
|
p.setstatus(1L);
|
|
|
|
|
for (int err = f.first(); err == NOERR; err = f.next())
|
|
|
|
|
{
|
|
|
|
|
p.addstatus(1L);
|
|
|
|
|
if (r.get("TIPOCF").blank())
|
|
|
|
|
{
|
|
|
|
|
r.put("TIPOCF","C");
|
|
|
|
|
f.rewrite();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2002-07-02 16:21:23 +00:00
|
|
|
|
/////////////////////////////////////////////////////////////
|
|
|
|
|
// Effettua copia dei CDC in CMS (commesse)
|
|
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
|
void TConversione_archivi::convert_cdc2cms() const
|
|
|
|
|
{
|
|
|
|
|
TRelation rel(LF_TAB);
|
|
|
|
|
TRectype& curr = rel.curr();
|
|
|
|
|
curr.put("COD", "CDC");
|
|
|
|
|
TCursor cursore(&rel, "", 1, &curr, &curr);
|
|
|
|
|
const long items = cursore.items();
|
|
|
|
|
cursore.freeze();
|
|
|
|
|
|
|
|
|
|
TProgind pi(items, "Conversione tabella da Centri di costo a Commesse...", FALSE, TRUE);
|
|
|
|
|
for (cursore=0; cursore.pos()<items; ++cursore)
|
|
|
|
|
{
|
|
|
|
|
pi.addstatus(1);
|
2002-09-13 14:06:05 +00:00
|
|
|
|
TString80 codcms = curr.get("CODTAB");
|
|
|
|
|
codcms.lpad(20,'0');
|
2002-07-02 16:21:23 +00:00
|
|
|
|
curr.put("COD", "CMS");
|
2002-09-13 14:06:05 +00:00
|
|
|
|
curr.put("CODTAB",codcms);
|
2002-07-02 16:21:23 +00:00
|
|
|
|
cursore.file().write();
|
2002-09-13 14:06:05 +00:00
|
|
|
|
}
|
2002-07-02 16:21:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
// Effettua copia dei mov in movCMS (commesse)
|
|
|
|
|
//Copia il contenuto del campo NUMGIO nel campo CODCMS del file LF_RMOV
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////
|
|
|
|
|
void TConversione_archivi::convert_mov2movcms() const
|
|
|
|
|
{
|
2002-09-13 14:06:05 +00:00
|
|
|
|
TRelation rel(LF_RMOV);
|
2002-07-02 16:21:23 +00:00
|
|
|
|
TRectype& curr = rel.curr();
|
|
|
|
|
TCursor cursore(&rel);
|
|
|
|
|
const long items = cursore.items();
|
|
|
|
|
cursore.freeze();
|
|
|
|
|
|
|
|
|
|
TProgind pi(items, "Conversione movimenti con centro di costo...", FALSE, TRUE);
|
|
|
|
|
|
|
|
|
|
TString80 str;
|
|
|
|
|
for (cursore=0; cursore.pos()<items; ++cursore)
|
|
|
|
|
{
|
|
|
|
|
pi.addstatus(1);
|
|
|
|
|
if (curr.get("CODCMS").empty())
|
|
|
|
|
{
|
|
|
|
|
const long numgio = curr.get_long("NUMGIO");
|
|
|
|
|
if (numgio > 0)
|
|
|
|
|
{
|
|
|
|
|
str.format("%020ld",numgio);
|
|
|
|
|
curr.put("CODCMS", str);
|
|
|
|
|
cursore.file().rewrite();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2002-09-13 14:06:05 +00:00
|
|
|
|
////////////////////////////////////////////////////////////////
|
|
|
|
|
// Effettua conversione campi S1 S2 S3 della tabella comune CA7
|
|
|
|
|
////////////////////////////////////////////////////////////////
|
|
|
|
|
void TConversione_archivi::convert_ca7() const
|
|
|
|
|
{
|
|
|
|
|
TRelation rel(LF_TABCOM);
|
|
|
|
|
TRectype& curr = rel.curr();
|
|
|
|
|
curr.put("COD", "CA7");
|
|
|
|
|
TCursor cursore(&rel, "", 1, &curr, &curr);
|
|
|
|
|
const long items = cursore.items();
|
|
|
|
|
cursore.freeze();
|
|
|
|
|
|
|
|
|
|
TProgind pi(items, "Conversione causali mod.770...", FALSE, TRUE);
|
|
|
|
|
for (cursore=0; cursore.pos()<items; ++cursore)
|
|
|
|
|
{
|
|
|
|
|
pi.addstatus(1);
|
|
|
|
|
const TString& cods1 = curr.get("S1");
|
|
|
|
|
if (cods1 == "SC" || cods1 == "SE")
|
|
|
|
|
{
|
|
|
|
|
change_ca7(curr);
|
|
|
|
|
curr.put("S1", "LA");
|
|
|
|
|
cursore.file().rewrite();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TConversione_archivi::change_ca7(TRectype& rec) const
|
|
|
|
|
{
|
|
|
|
|
const TString& cods1 = rec.get("S1");
|
|
|
|
|
if (cods1 == "SC")
|
|
|
|
|
{
|
|
|
|
|
const TString olds2 = "AGHIKLMNPQRST";
|
|
|
|
|
const char* news2 = "ABCDEFGHILMNZ";
|
|
|
|
|
int pos2 = olds2.find(rec.get_char("S2"));
|
|
|
|
|
if (pos2 >= 0)
|
|
|
|
|
{
|
|
|
|
|
rec.put("S2", news2[pos2]);
|
|
|
|
|
rec.zero("S3");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else // Ex Causale SE
|
|
|
|
|
{
|
|
|
|
|
const TString olds3 = "ABCDEFGT";
|
|
|
|
|
const char* news3 = "QRSTUVWZ";
|
|
|
|
|
int pos3 = olds3.find(rec.get_char("S3"));
|
|
|
|
|
if (pos3 >= 0)
|
|
|
|
|
{
|
|
|
|
|
rec.put("S2", news3[pos3]);
|
|
|
|
|
rec.zero("S3");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////
|
|
|
|
|
// Effettua conversione campo QLCODQUA del file 42 (QUAL)
|
|
|
|
|
////////////////////////////////////////////////////////////////
|
|
|
|
|
void TConversione_archivi::convert_quadst() const
|
|
|
|
|
{
|
|
|
|
|
TRelation rel(LF_QUAL);
|
|
|
|
|
TRectype& curr = rel.curr();
|
|
|
|
|
TCursor cursore(&rel);
|
|
|
|
|
const long items = cursore.items();
|
|
|
|
|
cursore.freeze();
|
|
|
|
|
|
|
|
|
|
TProgind pi(items, "Conversione riepilogo quadro ST..", FALSE, TRUE);
|
|
|
|
|
|
|
|
|
|
for (cursore=0; cursore.pos()<items; ++cursore)
|
|
|
|
|
{
|
|
|
|
|
pi.addstatus(1);
|
|
|
|
|
const TString& riepst = curr.get("QLCODQUA");
|
|
|
|
|
if (riepst == "SC" || riepst == "SE")
|
|
|
|
|
{
|
|
|
|
|
curr.put("QLCODQUA", "LA");
|
|
|
|
|
cursore.file().rewrite();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2005-02-17 18:13:12 +00:00
|
|
|
|
////////////////////////////////////////////////////////////////
|
|
|
|
|
// Effettua conversione campo ALLEG a 6 se il cliente non ha partita IVA
|
|
|
|
|
////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
void TConversione_archivi::convert_clifo_privati()
|
|
|
|
|
{
|
|
|
|
|
long firm = get_firm();
|
|
|
|
|
TString pref;
|
|
|
|
|
|
|
|
|
|
if (firm == 0)
|
|
|
|
|
pref = prefix().name();
|
|
|
|
|
|
|
|
|
|
TLocalisamfile ditte(LF_NDITTE);
|
|
|
|
|
|
|
|
|
|
for (ditte.first(); !ditte.eof(); ditte.next())
|
|
|
|
|
{
|
|
|
|
|
const long codditta = ditte.get_long("CODDITTA");
|
|
|
|
|
|
|
|
|
|
if (prefix().exist(codditta))
|
|
|
|
|
{
|
|
|
|
|
set_firm(codditta);
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
TRelation rel(LF_CLIFO);
|
|
|
|
|
TRectype& curr = rel.curr();
|
|
|
|
|
|
|
|
|
|
curr.put(CLI_TIPOCF, "C");
|
|
|
|
|
|
|
|
|
|
TCursor cursore(&rel, "(PAIV=='')&&(ALLEG!='6')", 1, &curr, &curr);
|
|
|
|
|
const long items = cursore.items();
|
|
|
|
|
cursore.freeze();
|
|
|
|
|
|
|
|
|
|
TProgind pi(items, "Conversione clienti privati..", FALSE, TRUE);
|
|
|
|
|
|
|
|
|
|
for (cursore=0; cursore.pos()<items; ++cursore)
|
|
|
|
|
{
|
|
|
|
|
pi.addstatus(1);
|
|
|
|
|
curr.put(CLI_ALLEG, 6);
|
|
|
|
|
rel.rewrite();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (firm > 0)
|
|
|
|
|
set_firm(firm);
|
|
|
|
|
else
|
|
|
|
|
prefix().set(pref);
|
|
|
|
|
}
|
|
|
|
|
|
2005-05-16 23:44:23 +00:00
|
|
|
|
////////////////////////////////////////////////////////////////
|
|
|
|
|
// Effettua conversione campo NUMIVD E NUMIVDOPP sul piano dei conti
|
|
|
|
|
////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
void TConversione_archivi::convert_pcon_ivd()
|
|
|
|
|
{
|
2009-09-21 13:38:47 +00:00
|
|
|
|
const long firm = get_firm();
|
|
|
|
|
const TString pref = firm == 0 ? prefix().name() : "";
|
2005-05-16 23:44:23 +00:00
|
|
|
|
|
2009-09-21 13:38:47 +00:00
|
|
|
|
TPointer_array firms;
|
|
|
|
|
prefix().firms(firms);
|
2005-05-16 23:44:23 +00:00
|
|
|
|
|
2009-09-21 13:38:47 +00:00
|
|
|
|
TProgind pf(firms.items(), "Conversione Codici IV Direttiva CEE");
|
|
|
|
|
for (int f = 0; f < firms.items(); f++)
|
2005-05-16 23:44:23 +00:00
|
|
|
|
{
|
2009-09-21 13:38:47 +00:00
|
|
|
|
if (!pf.addstatus(1))
|
|
|
|
|
break;
|
|
|
|
|
const long codditta = firms.get_long(f);
|
|
|
|
|
if (set_firm(codditta))
|
|
|
|
|
{
|
|
|
|
|
TRelation rel(LF_PCON);
|
|
|
|
|
TRectype& curr = rel.curr();
|
|
|
|
|
|
|
|
|
|
TCursor cursore(&rel);
|
|
|
|
|
const long items = cursore.items();
|
|
|
|
|
cursore.freeze();
|
|
|
|
|
|
|
|
|
|
TProgind pi(items, "Scansione piano dei conti");
|
|
|
|
|
for (cursore=0; cursore.pos()<items; ++cursore)
|
|
|
|
|
{
|
|
|
|
|
if (!pi.addstatus(1))
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
TString8 numivd = curr.get(PCN_NUMIVD);
|
|
|
|
|
bool rew = false;
|
|
|
|
|
if (numivd.len() == 1)
|
|
|
|
|
{
|
|
|
|
|
numivd.insert("0");
|
|
|
|
|
curr.put(PCN_NUMIVD, numivd);
|
|
|
|
|
rew = true;
|
|
|
|
|
}
|
2005-05-16 23:44:23 +00:00
|
|
|
|
|
2009-09-21 13:38:47 +00:00
|
|
|
|
TString8 numivdopp = curr.get(PCN_NUMIVDOPP);
|
|
|
|
|
if (numivdopp.len() == 1)
|
|
|
|
|
{
|
|
|
|
|
numivdopp.insert("0");
|
|
|
|
|
curr.put(PCN_NUMIVDOPP, numivdopp);
|
|
|
|
|
rew = true;
|
2005-05-16 23:44:23 +00:00
|
|
|
|
}
|
2009-09-21 13:38:47 +00:00
|
|
|
|
if (rew)
|
|
|
|
|
rel.rewrite();
|
2005-05-16 23:44:23 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (firm > 0)
|
|
|
|
|
set_firm(firm);
|
|
|
|
|
else
|
|
|
|
|
prefix().set(pref);
|
|
|
|
|
}
|
|
|
|
|
|
2008-08-28 11:22:25 +00:00
|
|
|
|
bool TConversione_archivi::backup_text_file(TFilename& name, TLog_report& log) const
|
|
|
|
|
{
|
|
|
|
|
TString msg;
|
|
|
|
|
msg << TR("Elaborazione ") << name;
|
|
|
|
|
log.log(0, "");
|
|
|
|
|
log.log(0, msg);
|
2005-05-25 11:32:58 +00:00
|
|
|
|
|
2008-08-28 11:22:25 +00:00
|
|
|
|
if (!name.custom_path())
|
2005-05-25 11:32:58 +00:00
|
|
|
|
{
|
2008-08-28 11:22:25 +00:00
|
|
|
|
log.log_error(TR("Il file non esiste!"));
|
|
|
|
|
return false;
|
2005-05-25 11:32:58 +00:00
|
|
|
|
}
|
2009-09-16 15:03:02 +00:00
|
|
|
|
name.lower();
|
2008-08-28 11:22:25 +00:00
|
|
|
|
if (name.find("custom") < 0)
|
|
|
|
|
{
|
|
|
|
|
log.log_error(TR("Il file non e' in una cartella custom!"));
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2005-05-25 11:32:58 +00:00
|
|
|
|
|
2008-08-28 11:22:25 +00:00
|
|
|
|
TFilename bakname(name);
|
|
|
|
|
bakname << ".bak";
|
|
|
|
|
if (!bakname.exist())
|
2005-05-25 11:32:58 +00:00
|
|
|
|
{
|
2008-08-28 11:22:25 +00:00
|
|
|
|
msg.cut(0) << TR("Copia ") << name << TR(" in ") << bakname;
|
|
|
|
|
log.log(0, msg);
|
|
|
|
|
fcopy(name, bakname);
|
2005-05-25 11:32:58 +00:00
|
|
|
|
}
|
|
|
|
|
|
2008-08-28 11:22:25 +00:00
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TConversione_archivi::rinumera_paragrafo(const TFilename& ininame, const char*paragrafo,
|
|
|
|
|
const char* contatore, const char* variabile,
|
|
|
|
|
TLog_report& log) const
|
|
|
|
|
{
|
|
|
|
|
TConfig p(ininame, paragrafo);
|
|
|
|
|
|
|
|
|
|
TString val = p.get( contatore, paragrafo );
|
|
|
|
|
if (val == "*")
|
|
|
|
|
return true; // Lascia stare tutto!
|
|
|
|
|
|
|
|
|
|
const int ncols = atoi(val);
|
|
|
|
|
const bool ok = p.remove(contatore) || ncols <= 0;
|
|
|
|
|
if (!ok)
|
|
|
|
|
{
|
|
|
|
|
log.log(1, TR("Il file risulta essere gia' stato convertito"));
|
|
|
|
|
return ok;
|
|
|
|
|
}
|
2005-05-25 11:32:58 +00:00
|
|
|
|
|
2009-09-16 15:03:02 +00:00
|
|
|
|
val = TR("Conversione paragrafo");
|
|
|
|
|
val << " [" << paragrafo << ']';
|
|
|
|
|
log.log(0, val);
|
|
|
|
|
|
2008-08-28 11:22:25 +00:00
|
|
|
|
TString4 str;
|
|
|
|
|
for (int i = 1; i <= ncols; i++)
|
2005-05-25 11:32:58 +00:00
|
|
|
|
{
|
|
|
|
|
str.format("%d", i);
|
2008-08-28 11:22:25 +00:00
|
|
|
|
val = p.get(str);
|
|
|
|
|
p.remove(str);
|
|
|
|
|
p.set(variabile, val, NULL, true, i - 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ok;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TConversione_archivi::rinumera_maschera(const TFilename& mskname, TLog_report& log) const
|
|
|
|
|
{
|
|
|
|
|
TFilename temp; temp.temp("msk");
|
|
|
|
|
if (mskname.exist()) // Dummy test
|
|
|
|
|
{
|
|
|
|
|
TString msg;
|
|
|
|
|
|
|
|
|
|
TScanner scan(mskname);
|
|
|
|
|
ofstream output(temp);
|
|
|
|
|
|
2008-09-16 09:11:02 +00:00
|
|
|
|
if (mskname.find("verig") >= 0) // Maschera di riga
|
2008-08-28 11:22:25 +00:00
|
|
|
|
{
|
|
|
|
|
bool killing = false;
|
|
|
|
|
while (!scan.eof())
|
|
|
|
|
{
|
|
|
|
|
TString& line = scan.line();
|
|
|
|
|
if (!killing)
|
|
|
|
|
{
|
|
|
|
|
// Controllo per ammazzare i campi delle vecchie commesse 140,141,260,261
|
|
|
|
|
if (line.match("?? 14[0,1] [1,2]0*") || line.match("?? 26[0,1] *"))
|
|
|
|
|
{
|
|
|
|
|
msg.cut(0) << TR("Eliminazione campo ") << line;
|
|
|
|
|
log.log(1, msg);
|
|
|
|
|
killing = true; // Comincio a saltar righe fino ad EN
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// Controllo se devo rinumerare i vecchi CODAGG da 142,143 a 152,153
|
|
|
|
|
if (line.match("?? 14[2,3] *")) // ST 142 12 -> ST 152 12
|
|
|
|
|
{
|
|
|
|
|
msg.cut(0) << TR("Rinumerazione campo ") << line;
|
|
|
|
|
log.log(1, msg);
|
|
|
|
|
line.overwrite("5", 4);
|
|
|
|
|
} else
|
|
|
|
|
if (line.match("IN * 14[2,3]")) // IN CODART 142 -> IN CODART 152
|
|
|
|
|
{
|
|
|
|
|
msg.cut(0) << TR("Rinumerazione campo ") << line;
|
|
|
|
|
log.log(1, msg);
|
|
|
|
|
line.overwrite("5", line.len()-2);
|
2008-09-16 09:11:02 +00:00
|
|
|
|
} else
|
|
|
|
|
if (line.match("ST 102 *"))
|
|
|
|
|
{
|
|
|
|
|
msg.cut(0) << TR("Trasformazione campo ") << line;
|
|
|
|
|
log.log(1, msg);
|
|
|
|
|
line = "LI 102 2 50\nBE\nPR 2 2 \"Tipo riga \"\nFI TIPORIGA\nEN";
|
|
|
|
|
killing = true; // Elimina contenuto vecchio campo tipo riga
|
2008-08-28 11:22:25 +00:00
|
|
|
|
}
|
|
|
|
|
output << line << endl;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// Finisco di ammazzare quando raggiungo il token EN
|
|
|
|
|
if (line == "EN")
|
|
|
|
|
killing = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else // Maschera di testa
|
|
|
|
|
{
|
|
|
|
|
bool killing = false;
|
2008-09-16 09:11:02 +00:00
|
|
|
|
bool toolbar = false;
|
2008-08-28 11:22:25 +00:00
|
|
|
|
while (!scan.eof())
|
|
|
|
|
{
|
|
|
|
|
TString& line = scan.line();
|
|
|
|
|
if (!killing)
|
|
|
|
|
{
|
|
|
|
|
// Controllo per ammazzare i campi delle vecchie commesse 188,189,190,191
|
|
|
|
|
if (line.match("?? 18[8,9] *") || line.match("?? 19[0,1] *"))
|
|
|
|
|
{
|
|
|
|
|
msg.cut(0) << TR("Eliminazione campo ") << line;
|
|
|
|
|
log.log(1, msg);
|
|
|
|
|
killing = true; // Comincio a saltar righe fino ad EN
|
2008-09-16 09:11:02 +00:00
|
|
|
|
} else
|
|
|
|
|
if (!toolbar && line.match("TOOLBAR \"*\" *")) // Vecchia toolbar
|
|
|
|
|
{
|
|
|
|
|
toolbar = true;
|
|
|
|
|
log.log(1, TR("Conversione TOOLBAR principale"));
|
|
|
|
|
output << "TOOLBAR \"toolbar\" 0 0 2 0" << endl; // nuova toolbar
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
output << line << endl; // Lascia stare la riga cosi' com'e'
|
2008-08-28 11:22:25 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// Finisco di ammazzare quando raggiungo il token EN
|
|
|
|
|
if (line == "EN")
|
|
|
|
|
killing = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
fcopy(temp, mskname);
|
|
|
|
|
temp.fremove();
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2008-09-16 09:11:02 +00:00
|
|
|
|
bool TConversione_archivi::to_be_converted(TFilename& name) const
|
|
|
|
|
{
|
2009-09-16 15:03:02 +00:00
|
|
|
|
if (!name.custom_path()) // Non esiste
|
2008-09-16 09:11:02 +00:00
|
|
|
|
return false;
|
|
|
|
|
name.lower();
|
2009-09-16 15:03:02 +00:00
|
|
|
|
if (name.find("custom") < 0) // Non e' in "CUSTOM"
|
|
|
|
|
return false;
|
2008-09-16 09:11:02 +00:00
|
|
|
|
|
|
|
|
|
if (name.ends_with(".ini"))
|
|
|
|
|
{
|
|
|
|
|
TFilename msk = name.name();
|
|
|
|
|
msk.ext("msk");
|
|
|
|
|
return msk.custom_path(); // Converto un .ini solo se esiste un .msk omonimo
|
|
|
|
|
} else
|
|
|
|
|
if (name.ends_with(".msk"))
|
|
|
|
|
{
|
|
|
|
|
TFilename ini = name.name();
|
|
|
|
|
ini.ext("ini");
|
|
|
|
|
return ini.custom_path(); // Converto un .msk solo se esiste un .ini omonimo
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2008-08-28 11:22:25 +00:00
|
|
|
|
void TConversione_archivi::convert_profile(const char* profile_name)
|
|
|
|
|
{
|
2009-09-16 15:03:02 +00:00
|
|
|
|
TArray_sheet elenco(-1, -1, -4, -6,
|
|
|
|
|
TR("Profili documento da convertire"), HR("@1|Profilo@60"), 0x08);
|
2005-05-25 11:32:58 +00:00
|
|
|
|
|
2008-09-16 09:11:02 +00:00
|
|
|
|
TFilename name;
|
|
|
|
|
TToken_string row;
|
|
|
|
|
|
|
|
|
|
if (profile_name && *profile_name)
|
2008-08-28 11:22:25 +00:00
|
|
|
|
{
|
2008-09-16 09:11:02 +00:00
|
|
|
|
name = profile_name;
|
|
|
|
|
name.ext("ini");
|
|
|
|
|
if (to_be_converted(name))
|
|
|
|
|
{
|
|
|
|
|
row = "X"; // preselezionato!
|
|
|
|
|
row.add(name);
|
|
|
|
|
elenco.add(row);
|
|
|
|
|
}
|
|
|
|
|
name = profile_name;
|
2008-08-28 11:22:25 +00:00
|
|
|
|
name.ext("msk");
|
2008-09-16 09:11:02 +00:00
|
|
|
|
if (to_be_converted(name))
|
2008-08-28 11:22:25 +00:00
|
|
|
|
{
|
2008-09-16 09:11:02 +00:00
|
|
|
|
row = "X"; // preselezionato!
|
2008-08-28 11:22:25 +00:00
|
|
|
|
row.add(name);
|
|
|
|
|
elenco.add(row);
|
|
|
|
|
}
|
2005-05-25 11:32:58 +00:00
|
|
|
|
}
|
2008-09-16 09:11:02 +00:00
|
|
|
|
|
2008-08-28 11:22:25 +00:00
|
|
|
|
if (elenco.items() == 0) // Nessun nome valido specificato sulla riga di comando
|
|
|
|
|
{
|
|
|
|
|
name = prefix().get_studio();
|
|
|
|
|
name.add("custom");
|
2008-09-16 09:11:02 +00:00
|
|
|
|
name.add("*.*");
|
|
|
|
|
TString_array files; list_files(name, files);
|
|
|
|
|
FOR_EACH_ARRAY_ROW(files, i, f)
|
2008-08-28 11:22:25 +00:00
|
|
|
|
{
|
2008-09-16 09:11:02 +00:00
|
|
|
|
name = *f;
|
|
|
|
|
if (to_be_converted(name))
|
2008-08-28 11:22:25 +00:00
|
|
|
|
{
|
2008-09-16 09:11:02 +00:00
|
|
|
|
row = "X"; // preselezionato
|
|
|
|
|
row.add(*f);
|
|
|
|
|
elenco.add(row);
|
2008-08-28 11:22:25 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2005-05-25 11:32:58 +00:00
|
|
|
|
|
2008-08-28 11:22:25 +00:00
|
|
|
|
if (elenco.run() == K_ENTER && elenco.one_checked())
|
2005-05-25 11:32:58 +00:00
|
|
|
|
{
|
2008-08-28 11:22:25 +00:00
|
|
|
|
TLog_report log(TR("Conversione maschere documenti"));
|
|
|
|
|
for (int r = 0; r < elenco.items(); r++) if (elenco.checked(r))
|
|
|
|
|
{
|
|
|
|
|
name = elenco.row(r).get(1);
|
|
|
|
|
if (backup_text_file(name, log))
|
2008-09-16 09:11:02 +00:00
|
|
|
|
{
|
|
|
|
|
if (name.ends_with(".ini"))
|
|
|
|
|
{
|
|
|
|
|
const bool ok = rinumera_paragrafo(name, "SHEET", "NCOLS", "Col", log);
|
|
|
|
|
if (!ok)
|
|
|
|
|
continue; // Gia' elaborato!
|
|
|
|
|
rinumera_paragrafo(name, "RIGHE", "NTIPIRIGA", "Tipo", log);
|
|
|
|
|
rinumera_paragrafo(name, "HANDLERS", "NHANDLER", "Handler", log);
|
|
|
|
|
rinumera_paragrafo(name, "DEFAULT", "NDEFAULTS", "Default", log);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
rinumera_maschera(name, log);
|
|
|
|
|
}
|
2008-08-28 11:22:25 +00:00
|
|
|
|
}
|
|
|
|
|
log.preview();
|
2005-05-25 11:32:58 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-09-25 13:19:21 +00:00
|
|
|
|
|
2009-10-14 10:58:30 +00:00
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
// Converte le righe documento e anamag in modo da riassegnare i campi CONAI
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
void TConversione_archivi::convert_conai_anamag()
|
|
|
|
|
{
|
|
|
|
|
TConfig ditta(CONFIG_DITTA, "ve");
|
|
|
|
|
TString_array conai_default_vals;
|
|
|
|
|
const char* conai_default_names[CONAI_CLASSES] = {"CONAI_DEFAULT_ACC", "CONAI_DEFAULT_ALL", "CONAI_DEFAULT_CAR",
|
|
|
|
|
"CONAI_DEFAULT_LEG", "CONAI_DEFAULT_PLA", "CONAI_DEFAULT_VET"};
|
|
|
|
|
const char* conai_default_values[CONAI_CLASSES] = {"AC99", "AL99", "CA40", "LE99", "PL12", "VE99"};
|
|
|
|
|
|
|
|
|
|
FOR_EACH_CONAI_CLASS(cc)
|
|
|
|
|
{
|
|
|
|
|
const TString& conai_cat = ditta.get(conai_default_names[cc], NULL, -1, conai_default_values[cc]);
|
|
|
|
|
conai_default_vals.add(conai_cat);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//prende solo le righe che hanno un peso conai di carta e/o plastica
|
|
|
|
|
TISAM_recordset anamag("USE ANAMAG\nSELECT (CONCAR>0)||(CONPLA>0)\n");
|
|
|
|
|
const long anamag_items = anamag.items();
|
|
|
|
|
|
|
|
|
|
TProgind pi(anamag_items, "Gestione anagrafica articoli...", false);
|
|
|
|
|
for (bool ok = anamag.move_first(); ok; ok = anamag.move_next())
|
|
|
|
|
{
|
|
|
|
|
if (!pi.addstatus(1))
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
//prende i pesi conai su ciascuna riga
|
|
|
|
|
FOR_EACH_CONAI_CLASS(cc)
|
|
|
|
|
{
|
|
|
|
|
const char* peso_name = conai_peso_name(cc, LF_ANAMAG);
|
|
|
|
|
const real peso = anamag.get(peso_name).as_real();
|
|
|
|
|
//se peso conai > 0, deve scrivere il codice conai nel campo CONAISC
|
|
|
|
|
if (peso > ZERO)
|
|
|
|
|
{
|
|
|
|
|
const char* sottocat = conai_sottocat_name(cc, LF_ANAMAG);
|
|
|
|
|
TFieldref fr(sottocat, LF_ANAMAG);
|
|
|
|
|
fr.write(conai_default_vals.row(cc), anamag.cursor()->curr());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
anamag.cursor()->relation()->rewrite();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void TConversione_archivi::convert_conai_rdoc()
|
2009-09-25 13:19:21 +00:00
|
|
|
|
{
|
|
|
|
|
//deve considerare tutte le righe documento che abbiano almeno uno tra codagg1 e codagg2 compilato
|
|
|
|
|
TString query;
|
|
|
|
|
query << "USE RDOC\n";
|
2009-10-14 10:58:30 +00:00
|
|
|
|
query << "SELECT (BETWEEN(CODAGG1,\"AC\",\"VE\"))||(BETWEEN(CODAGG2,\"AC01\",\"VE99\"))";
|
2009-09-25 13:19:21 +00:00
|
|
|
|
TISAM_recordset righedoc(query);
|
|
|
|
|
const long righedoc_items = righedoc.items();
|
|
|
|
|
|
2009-10-14 10:58:30 +00:00
|
|
|
|
TProgind pi(righedoc_items, "Ricostruzione righe documento...", false);
|
2009-09-25 13:19:21 +00:00
|
|
|
|
|
|
|
|
|
//ci vuole un TVariable_rectype perch<63> il TRectype non ha campi virtuali!
|
|
|
|
|
TVariable_rectype rdoc(LF_RIGHEDOC);
|
|
|
|
|
rdoc.set_memo_fld(RDOC_RG1);
|
|
|
|
|
for (bool ok = righedoc.move_first(); ok; ok = righedoc.move_next())
|
|
|
|
|
{
|
|
|
|
|
//deve prendere dalla riga il valore di codagg2 e confrontarlo con una delle nuove sottocategorie conai
|
2009-10-14 10:58:30 +00:00
|
|
|
|
if (!pi.addstatus(1))
|
|
|
|
|
break;
|
2009-09-25 13:19:21 +00:00
|
|
|
|
rdoc = righedoc.cursor()->curr();
|
|
|
|
|
TString4 codagg2 = rdoc.get(RDOC_CODAGG2);
|
|
|
|
|
TString4 codagg1 = rdoc.get(RDOC_CODAGG1);
|
|
|
|
|
//se codagg2 non <20> 4 caratteri o <20> cazzato (<4) oppure non c'entra un cavolo (>4); quindi deve considerare..
|
|
|
|
|
//..codagg1; se codagg1 <20> lungo 2 va bene lui
|
|
|
|
|
if (codagg2.len() < 4 && codagg1.len() == 2)
|
|
|
|
|
{
|
|
|
|
|
codagg2 = codagg1;
|
|
|
|
|
codagg2 << "99";
|
|
|
|
|
}
|
|
|
|
|
//per prima cosa sistema i codici categoria
|
|
|
|
|
//quale <20> la classe conai? (plastica,carta,vetro,ecc.??)
|
|
|
|
|
const TCONAI_class cc = conai_str2class(codagg2);
|
|
|
|
|
//come si chiama il campo virtuale su rdoc in cui anr<6E> inserito il codice categoria?
|
|
|
|
|
const char* csn = conai_sottocat_name(cc);
|
|
|
|
|
//noto il campo di destinazione ci mette il codice corretto
|
|
|
|
|
rdoc.put(csn, codagg2);
|
|
|
|
|
rdoc.zero(RDOC_CODAGG1);
|
|
|
|
|
rdoc.zero(RDOC_CODAGG2);
|
|
|
|
|
|
|
|
|
|
//adesso tocca ai pesi conai
|
|
|
|
|
real qtagg1 = rdoc.get_real(RDOC_QTAGG1);
|
|
|
|
|
//la classe <20> sempre quella di prima;il campo virtuale no
|
|
|
|
|
const char* cpn = conai_peso_name(cc);
|
|
|
|
|
//noto il campo di destinazione ci mette il peso conai
|
|
|
|
|
rdoc.put(cpn, qtagg1);
|
|
|
|
|
rdoc.zero(RDOC_QTAGG1);
|
|
|
|
|
|
|
|
|
|
//scrittura finale del record
|
|
|
|
|
TLocalisamfile f(LF_RIGHEDOC);
|
|
|
|
|
int err = rdoc.rewrite(f);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-10-14 10:58:30 +00:00
|
|
|
|
void TConversione_archivi::convert_conai_righe()
|
|
|
|
|
{
|
|
|
|
|
//gestione del file anamag
|
|
|
|
|
convert_conai_anamag();
|
|
|
|
|
|
|
|
|
|
//gestione delle righedoc
|
|
|
|
|
convert_conai_rdoc();
|
|
|
|
|
}
|
|
|
|
|
|
2009-09-25 13:19:21 +00:00
|
|
|
|
|
1995-02-15 17:00:56 +00:00
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
// Programma di conversione archivi speciale
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
1994-12-05 18:54:04 +00:00
|
|
|
|
int main(int argc,char** argv)
|
|
|
|
|
{
|
1997-11-20 08:18:05 +00:00
|
|
|
|
const int r = (argc > 1) ? abs(atoi(argv[1])) : 0;
|
2009-09-16 15:03:02 +00:00
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
if (r==0)
|
1994-12-05 18:54:04 +00:00
|
|
|
|
{
|
2009-09-16 15:03:02 +00:00
|
|
|
|
TConversione_xbase a;
|
|
|
|
|
a.run(argc,argv, TR("Conversione archivi di xBase"));
|
1994-12-05 18:54:04 +00:00
|
|
|
|
}
|
1995-07-03 07:52:10 +00:00
|
|
|
|
else
|
2009-09-16 15:03:02 +00:00
|
|
|
|
*/
|
|
|
|
|
{
|
|
|
|
|
TConversione_archivi a ;
|
|
|
|
|
a.run(argc, argv, TR("Conversione archivi"));
|
|
|
|
|
}
|
1995-02-15 17:00:56 +00:00
|
|
|
|
|
1994-12-05 18:54:04 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|