Importazione fatture e clienti

git-svn-id: svn://10.65.10.50/branches/R_10_00@23149 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 2015-12-16 15:50:05 +00:00
parent ed68f81ed7
commit 664a73da35

View File

@ -20,6 +20,8 @@
#include <clifo.h>
#include <cfven.h>
#define BS_DTULTAGG "DtUltAgg"
///////////////////////////////////////////////////////////
// TBeeStore_cache
///////////////////////////////////////////////////////////
@ -288,8 +290,8 @@ void TBeeStore_sync::load_origine_1(TISAM_recordset& out_set, const char* in_tab
if (err == NOERR)
{
bool dirty = false;
const TDate dataagg = file.get("DATAAGG");
TDate dtultagg = odbc.get("DtUltAgg").as_date();
const TDate dataagg = file.get(CLI_DATAAGG);
TDate dtultagg = odbc.get(BS_DTULTAGG).as_date();
if (!dtultagg.ok()) dtultagg = TODAY;
str = "record";
@ -317,9 +319,11 @@ void TBeeStore_sync::load_origine_1(TISAM_recordset& out_set, const char* in_tab
}
if (dirty)
{
if (file.curr().exist("UTENTE"))
file.put("UTENTE", "BEESTORE");
file.put("DATAAGG", dtultagg);
TRectype& rec = file.curr();
if (rec.exist(CLI_UTENTE))
rec.put(CLI_UTENTE, "BEESTORE");
if (rec.exist(CLI_DATAAGG))
rec.put(CLI_DATAAGG, dtultagg);
}
else
str << " Nessuna variazione pertinente";
@ -395,7 +399,7 @@ void TBeeStore_sync::save_origine_2(TISAM_recordset& in_set, const char* out_tab
str.cut(0) << "INSERT INTO " << out_table << "\n(";
FOR_EACH_ARRAY_ROW(fields, sr, srow)
str << (sr ? ", " : "") << srow->get(0);
str << ", Origine, Errore, DTUltAgg";
str << ", Origine, Errore, "BS_DTULTAGG;
str << ")\nVALUES (";
FOR_EACH_ARRAY_ROW(fields, ir, irow)
@ -403,8 +407,8 @@ void TBeeStore_sync::save_origine_2(TISAM_recordset& in_set, const char* out_tab
if (ir) str << ", ";
if (fval)
{
const char* fname = irow->get(0);
const char* fexpr = irow->get();
const char* fname = irow->get(0); // BeeStore field name
const char* fexpr = irow->get(); // Campo expression
TVariant var;
if (fval(in_set, fname, fexpr, var))
{
@ -496,10 +500,10 @@ static TString& build_query(const int logicnum, const TDate& dal, const TDate& a
TString& q = get_tmp_string();
q << "USE " << logicnum;
if (rec.exist("UTENTE"))
if (rec.exist(CLI_UTENTE))
q << " SELECT (UTENTE!=\"BEESTORE\")";
if ((dal.ok() || al.ok()) && rec.exist("DATAAGG"))
if ((dal.ok() || al.ok()) && rec.exist(CLI_DATAAGG))
{
if (q.find(" SELECT ") < 0)
q << " SELECT ";
@ -795,7 +799,10 @@ bool TBeeStore_sync::split_phone(const TRecordset& odbc, const char* number, TIs
clifo.put(num, pn.mid(split+1));
}
else
{
clifo.put(pre, "");
clifo.put(num, pn);
}
}
return pn.full();
}
@ -864,14 +871,14 @@ void TBeeStore_sync::load_clifo(char tipocf)
cfv.put(CFV_CODPRCF, codprcf);
cfv.write();
}
clifo.put(CLI_RAGSOC, odbc.get("RagioneSociale").as_string());
clifo.put(CLI_RAGSOC, odbc.get("RagSoc").as_string());
const int tipo = odbc.get("Tipo").as_int(); // 1=Fisica; 2=Giuridica; 3=Aaltro
const int tipo = odbc.get("Tipo").as_int(); // 1=Fisica; 2=Giuridica; 3=Altro
if (tipo == 1)
{
clifo.put(CLI_SESSO, odbc.get("Sesso").as_string());
clifo.put(CLI_SESSO, odbc.get("Sesso").as_string());
clifo.put(CLI_DATANASC, odbc.get("DTNascita").as_date());
clifo.put(CLI_COMNASC, comune(odbc, "", "ComuneNascita"));
clifo.put(CLI_COMNASC, comune(odbc, "", "ComuneNascita"));
clifo.put(CLI_TIPOPERS, 'F');
}
else
@ -891,12 +898,13 @@ void TBeeStore_sync::load_clifo(char tipocf)
}
clifo.put(CLI_INDCF, ind.left(50));
split_phone(odbc, "Telefono", clifo, CLI_TEL, CLI_PTEL);
split_phone(odbc, "Cellulare", clifo, CLI_TEL2, CLI_PTEL2);
split_phone(odbc, "CellulareSMS", clifo, CLI_TEL3, CLI_PTEL3);
split_phone(odbc, "Telefono", clifo, CLI_PTEL, CLI_TEL);
split_phone(odbc, "Cellulare", clifo, CLI_PTEL2, CLI_TEL2);
split_phone(odbc, "CellulareSMS", clifo, CLI_PTEL3, CLI_TEL3);
clifo.put(CLI_MAIL, odbc.get("EMail").as_string());
clifo.put(CLI_UTENTE, "BEESTORE");
TDate dua = odbc.get("DtUltAgg").as_date();
TDate dua = odbc.get(BS_DTULTAGG).as_date();
if (!dua.ok()) dua = TDate(TODAY);
clifo.put(CLI_DATAAGG, dua);
@ -918,9 +926,9 @@ void TBeeStore_sync::save_clifo(const TDate& dal, const TDate& al)
fields.add("Citta|"CLI_COMCF);
fields.add("Cap|"CLI_CAPCF);
fields.add("Provincia|");
fields.add("Telefono|TEL");
fields.add("Cellulare|TEL2");
fields.add("CellulareSMS|TEL3");
fields.add("Telefono|PTEL+TEL");
fields.add("Cellulare|PTEL2+TEL2");
fields.add("CellulareSMS|PTEL3+TEL3");
fields.add("EMail|"CLI_MAIL);
fields.add("PartitaIva|"CLI_PAIV);
fields.add("CodFiscale|"CLI_COFI);
@ -950,6 +958,13 @@ void TBeeStore_sync::sync_clifo(const TDate& dal, const TDate& al)
{
load_clifo('C');
load_clifo('F');
TString str(255);
str << "ODBC(" << _dsn << ")\n";
TODBC_recordset clifo(str);
str << "DELETE FROM tieAnagCFP WHERE Origine=1;";
clifo.exec(str); // Elimina tutte le anagrafiche importate da BeeStore
save_clifo(dal, al);
}
@ -1067,12 +1082,12 @@ void TBeeStore_sync::sync_scontrini(const TDate& dal, const TDate& al)
TODBC_recordset mov(str);
TProgress_monitor pi(mov.items(), str);
TString num_mov;
TString num_mov, nm;
TMov_mag* doc = NULL;
for (bool ok = mov.move_first(); ok; ok = mov.move_next())
{
const TString80 nm = mov.get("NumMov").as_string();
nm = mov.get("NumMov").as_string();
if (nm != num_mov)
{
if (!save_and_delete_doc(doc))