Patch level : 12.0 592

Files correlati     : bs
Commento            : Corretto controllo clifo_has_conai e importazione codici varianti


git-svn-id: svn://10.65.10.50/branches/R_10_00@24513 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
mtollari 2018-06-07 12:25:24 +00:00
parent 81f839eafa
commit 13650d7166
5 changed files with 174 additions and 161 deletions

View File

@ -181,7 +181,7 @@ void TSknet_sync::load_their_origine(TISAM_recordset& out_set, const char* in_ta
str << row->get(0) << ',';
str.rtrim(1); // toglie ultima virgola
str << "\nFROM " << in_table << " WHERE (Origine=" << their_origin() << ") AND " << where_time_import() << ";";
//_log->log(0, str);
TODBC_recordset odbc(str);
odbc.connect(_dsn, _usr, _psw);
const TRecnotype n = odbc.items();
@ -415,6 +415,7 @@ void TSknet_sync::sync_anamag()
// Sincronizzo le unità di misura
{
query.cut(0) << "SELECT * from tieArticoli where Origine=" << their_origin() << " AND " << where_time_import() << ";";
//_log->log(0, query);
TODBC_recordset odbcunit(query);
odbcunit.connect(_dsn, _usr, _psw);
TProgress_monitor p(odbcunit.items(), "Aggiornamento unità di misura");
@ -444,6 +445,7 @@ void TSknet_sync::sync_anamag()
{
// Controllo se esistono varianti e le aggiungo
query.cut(0) << "SELECT * FROM tieArtVarianti where origine=" << their_origin() << " AND " << where_time_import() << ";";
//_log->log(0, query);
TODBC_recordset odbc(query);
odbc.connect(_dsn, _usr, _psw);
@ -477,7 +479,7 @@ void TSknet_sync::sync_anamag()
// Azzero
ccor.first(); // Useless??
rccor.zero();
bool add = false;
bool add = true;
int riga = 1;
const TString& codpadre = odbc.get("CodPadre").as_string();
const TString& codarticolo = odbc.get("CodArticolo").as_string();
@ -485,7 +487,6 @@ void TSknet_sync::sync_anamag()
rccor.put(CODCORR_NRIGA, riga);
if (codpadre != codarticolo && ccor.read(rccor, _isequal) == NOERR)
{
add = true;
while (add && rccor.get(CODCORR_CODART) == codpadre)
{
riga = rccor.get_int(CODCORR_NRIGA);
@ -512,6 +513,7 @@ void TSknet_sync::sync_anamag()
TLocalisamfile art(LF_ANAMAG);
TRectype rart(LF_ANAMAG);
query.cut(0) << "SELECT * FROM tieArtCONAI where origine=" << their_origin() << " AND " << where_time_import() << ";";
//_log->log(0, query);
TODBC_recordset odbc(query);
odbc.connect(_dsn, _usr, _psw);
TProgress_monitor p(odbc.items(), "Aggiornamento CONAI");
@ -727,6 +729,7 @@ void TSknet_sync::load_clifo(const char tipocf)
TFast_isamfile clifo(LF_CLIFO);
//_log->log(0, str);
TODBC_recordset odbc(str);
odbc.connect(_dsn, _usr, _psw);
const TRecnotype n = odbc.items();
@ -862,7 +865,7 @@ void TSknet_sync::load_clifo(const char tipocf)
split_phone(odbc, "CellulareSMS", clifo, CLI_PTEL3, CLI_TEL3);
split_phone(odbc, "Fax", clifo, CLI_PFAX, CLI_FAX);
clifo.put(CLI_MAIL, odbc.get("EMail").as_string());
clifo.put(CLI_CODPAG, odbc.get("Cli_CodPagamento").as_string());
clifo.put(CLI_CODPAG, odbc.get(tipocf == 'F' ? "For_CodPagamento" : "Cli_CodPagamento").as_string());
if (_hasConai)
{
@ -916,7 +919,7 @@ void TSknet_sync::load_clifo(const char tipocf)
cab = odbc.get("For_Cab").as_string();
contcor = odbc.get("For_ContoCorr").as_string();
}
if (!abi.blank() && !cab.blank() && !contcor.blank())
if (!abi.blank() && !cab.blank())
{
int err = 1;
// Calcolo il CIN
@ -958,13 +961,15 @@ void TSknet_sync::load_clifo(const char tipocf)
cfb.put("NUMCC", contcor);
cfb.put("IBAN", iban);
}
else if (!odbc.get("Cli_ContoCorr").as_string().blank())
else
{
TString msg; msg << "L'IBAN del contatto " << tipocf << " " << codcf << "non è corretto, non ho sovrascritto nulla";
TString msg; msg << "L'IBAN del contatto " << tipocf << " " << codcf << "non è corretto, verranno importati solo ABI e CAB";
cfb.put("NUMCC", "");
cfb.put("IBAN", "");
_log->log(1, msg);
}
else
cfb.write_rewrite();
cfb.write_rewrite();
}
// Always true
cfv.put(CFV_RAGGEFF, true);
@ -1131,6 +1136,7 @@ void TSknet_sync::clean()
if (ini_get_bool(CONFIG_DITTA, "BS", "SKSyncUMS"))
str << "DELETE FROM tieUntMisura WHERE Origine=" << their_origin() << " AND " << where_time_delete() << ";\n";
//_log->log(0, str);
voldemort.exec(str); // Elimina tutte le anagrafiche importate da BeeStore
voldemort.commit();
}
@ -1139,14 +1145,14 @@ void TSknet_sync::clean()
void TSknet_sync::set_time()
{
// Prelevo il tempo dell'ultima importazione
sprintf_s(_lastUpdate, sizeof(_lastUpdate), ini_get_string(CONFIG_DITTA, "BS", "LAST_IMPORT", "1990-01-01 00:00:00.000"));
sprintf_s(_lastUpdate, sizeof(_lastUpdate), ini_get_string(CONFIG_DITTA, "BS", "LAST_IMPORT", "19900101 00:00:00.000"));
// Preparo il tempo attuale
time_t rt = time(NULL);
struct tm * now = localtime(&rt);
sprintf_s(_thisUpdate, sizeof(_thisUpdate),
"%d-%02d-%02d %02d:%02d:%02d.999",
"%d%02d%02d %02d:%02d:%02d.999",
now->tm_year + 1900,
now->tm_mon + 1,
now->tm_mday,
@ -1169,6 +1175,13 @@ const TString TSknet_sync::where_time_delete()
return time_delete;
}
const bool TSknet_sync::clifo_has_conai(const TString4& tipocf, const long codcf)
{
TString keyCli; keyCli << tipocf << "|" << codcf;
TRectype clifo = cache().get(LF_CFVEN, keyCli);
return clifo.get_bool("ADDCONAI") || !clifo.get("PRODCONAI").blank();
}
bool TSknet_sync::save_and_delete_movmag(TMov_mag*& doc) const
{
int err = 0;
@ -1248,7 +1261,7 @@ void TSknet_sync::sync_doc()
str << "WHERE tieTBolFat.Origine = " << their_origin() << " AND tieTBolFat." << where_time_import();
//str << "WHERE tieDMovMag.Origine = " << their_origin() << " AND tieDMovMag.TipoTestata = 2"; // verificare
str << "\nORDER BY tieTBolFat.Cod_PK,tieDMovMag.NumRiga";
//_log->log(0, str);
TODBC_recordset docs(str);
docs.connect(_dsn, _usr, _psw);
TProgress_monitor pi(docs.items(), str);
@ -1513,8 +1526,7 @@ void TSknet_sync::sync_doc()
// "CONSCACC", "CONSCALL", "CONSCCAR", "CONSCPLA", "CONSCLEG", "CONSCVET"
TString keyCli; keyCli << tipocf << "|" << codcf;
if (_hasConai && cache().get(LF_CFVEN, keyCli, "ADDCONAI") == "X")
if (_hasConai && clifo_has_conai(tipocf, codcf))
{
// In base al conai che ha abilitato controllo
if (ini_get_bool(CONFIG_DITTA, "ve", "CONFACC")) // Acciaio

View File

@ -97,6 +97,7 @@ private:
void set_time();
const TString where_time_import();
const TString where_time_delete();
const bool clifo_has_conai(const TString4& tipocf, const long codcf);
protected:
bool save_and_delete_movmag(TMov_mag*& doc) const;