Patch level : 12.0 984
Files correlati : bs0.exe Commento : Modifica per importazione sknet nuovabienne vecchi codici pack: lettura da db codice articolo giusto.
This commit is contained in:
parent
b6d68418e4
commit
296f3136af
@ -1358,7 +1358,7 @@ bool TSknet_sync::save_and_delete_doc(TDocumento*& doc) const
|
||||
{
|
||||
TString msg;
|
||||
|
||||
msg.format(FR("Errore %d in registrazione dcoumento %s/%ld del %s"), err,
|
||||
msg.format(FR("Errore %d in registrazione documento %s/%ld del %s"), err,
|
||||
(const char *)doc->get(DOC_CODNUM), doc->get_long(DOC_NDOC), (const char*)doc->get(DOC_DATADOC));
|
||||
_log->log(2, msg);
|
||||
msg << TR("\nSi desidera proseguire ugualmente?");
|
||||
@ -1381,6 +1381,55 @@ void TSknet_sync::sync_val()
|
||||
sync_table("%VAL", "tieValute", fields);
|
||||
}
|
||||
|
||||
//auto find_codalt_sknet = [](TRectype& rcodcor, TLocalisamfile& codcor, const TString& tipocf, long codcf, const TString& codart, TString& codartmag, bool& checked)
|
||||
//{
|
||||
// // Testo quanti sono. Non ho altro modo?
|
||||
// const bool items = rcodcor.next(codcor) == NOERR && rcodcor.get(CODCORR_CODARTALT) == codart;
|
||||
// if (items)
|
||||
// {
|
||||
// rcodcor.prev(codcor);
|
||||
// // Prima cerco subito se ho un codice per questo cliente.
|
||||
// // Altrimenti prendo quello che non e' un codice di pack, se c'e' altrimenti riprendo sempre il primo.
|
||||
// TSQL_recordset codici(TString() << "SELECT * FROM CODCORR WHERE CODARTALT = '" << codart << "' AND TIPOCF = '" << tipocf << "' AND CODCF = '" << codcf << "'");
|
||||
// if (codici.items() == 1)
|
||||
// {
|
||||
// codartmag = codici.get(codici.find_column(CODCORR_CODART)).as_string();
|
||||
// checked = true;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// TString last_cod = rcodcor.get(CODCORR_CODART);
|
||||
//
|
||||
// // Codice di PACK di cinque cifre.
|
||||
// static auto is_pack_code = [&]()
|
||||
// {
|
||||
// bool flag = last_cod.len() == 5;
|
||||
// for (int i = 0; i < 5 && flag; ++i) flag &= xvt_chr_is_digit(last_cod[i]);
|
||||
// return flag;
|
||||
// };
|
||||
//
|
||||
// checked = true; // Se va tutto bene ho il nuovo codartmag.
|
||||
// while (is_pack_code())
|
||||
// {
|
||||
// if (rcodcor.next(codcor) == NOERR && rcodcor.get(CODCORR_CODARTALT) == codart)
|
||||
// {
|
||||
// last_cod = rcodcor.get(CODCORR_CODART);
|
||||
// continue;
|
||||
// }
|
||||
// checked = false;
|
||||
// break;
|
||||
// }
|
||||
// if (checked)
|
||||
// {
|
||||
// if (rcodcor.next(codcor) != NOERR || rcodcor.get(CODCORR_CODARTALT) != codart) // Controllo che sia effettivamente l'unico altrimenenti ciaone.
|
||||
// codartmag = last_cod;
|
||||
// else
|
||||
// checked = false;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//};
|
||||
|
||||
void TSknet_sync::sync_doc()
|
||||
{
|
||||
const TString8 codcausdef = ini_get_string(CONFIG_DITTA, "bs", MOVMAG_CODCAUS, "", 2);
|
||||
@ -1412,8 +1461,8 @@ void TSknet_sync::sync_doc()
|
||||
{
|
||||
//TToken_string test(docs.get("CodTestata").as_string(), '\\');
|
||||
const TString keyDoc = docs.get("CodTestata").as_string();
|
||||
//if (keyDoc.starts_with("1-2020-01-09-16"))
|
||||
// bool simo = true;
|
||||
/*if (keyDoc.starts_with("1-2020-01-09-16"))
|
||||
bool simo = true;*/
|
||||
nd = docs.get("NumRif").as_int();
|
||||
TString wrk = docs.get("CodCliente").as_string();
|
||||
|
||||
@ -1582,63 +1631,31 @@ void TSknet_sync::sync_doc()
|
||||
|
||||
const TString80 codart = docs.get("CodArticolo").as_string();
|
||||
TString80 codartmag = codart;
|
||||
const TString descr = docs.get("DSRiga").as_string();
|
||||
bool checked = false;
|
||||
{
|
||||
TString query; query << "SELECT * FROM tieArtVarianti WHERE origine=" << their_origin() << " AND " << where_time_import() <<
|
||||
" AND CodArticolo='" << codart << "';";
|
||||
TODBC_recordset codarticoli(query);
|
||||
codarticoli.connect(_dsn, _usr, _psw);
|
||||
if (codarticoli.items() > 0)
|
||||
{
|
||||
codarticoli.move_first();
|
||||
const TString& padre = codarticoli.get("CodPadre").as_string();
|
||||
if (!padre.empty())
|
||||
{
|
||||
codartmag = padre;
|
||||
checked = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
const TString descr = docs.get("DSRiga").as_string();
|
||||
|
||||
bool checked = false;
|
||||
|
||||
if (tiporiga == "01" && ini_get_bool(CONFIG_DITTA, "BS", "SKUseCustomRiga", false))
|
||||
{
|
||||
TLocalisamfile codcor(LF_CODCORR); codcor.setkey(2);
|
||||
TRectype rcodcor(LF_CODCORR);
|
||||
rcodcor.put(CODCORR_CODARTALT, codart);
|
||||
if (codcor.read(rcodcor, _isequal) == NOERR)
|
||||
{
|
||||
// Testo quanti sono. Non ho altro modo?
|
||||
const bool items = rcodcor.next(codcor) == NOERR && rcodcor.get(CODCORR_CODARTALT) == codart;
|
||||
if(items)
|
||||
{
|
||||
rcodcor.prev(codcor);
|
||||
// Prima cerco subito se ho un codice per questo cliente.
|
||||
// Altrimenti prendo quello che non e' un codice di pack, se c'e' altrimenti riprendo sempre il primo.
|
||||
TSQL_recordset codici(TString() << "SELECT * FROM CODCORR WHERE CODARTALT = '" << codart << "' AND TIPOCF = '" << tipocf << "' AND CODCF = '" << codcf << "'");
|
||||
if (codici.items() == 1)
|
||||
{
|
||||
codartmag = codici.get(codici.find_column(CODCORR_CODART)).as_string();
|
||||
checked = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
TString last_cod = rcodcor.get(CODCORR_CODART);
|
||||
|
||||
// Codice di PACK di cinque cifre.
|
||||
static auto is_pack_code = [&]()
|
||||
{
|
||||
bool flag = last_cod.len() == 5;
|
||||
for (int i = 0; i < 5 && flag; ++i) flag &= xvt_chr_is_digit(last_cod[i]);
|
||||
return flag;
|
||||
};
|
||||
|
||||
checked = true; // Se va tutto bene ho il nuovo codartmag.
|
||||
while (is_pack_code())
|
||||
{
|
||||
if (rcodcor.next(codcor) == NOERR && rcodcor.get(CODCORR_CODARTALT) == codart)
|
||||
{
|
||||
last_cod = rcodcor.get(CODCORR_CODART);
|
||||
continue;
|
||||
}
|
||||
checked = false;
|
||||
break;
|
||||
}
|
||||
if(checked)
|
||||
{
|
||||
if (rcodcor.next(codcor) != NOERR || rcodcor.get(CODCORR_CODARTALT) != codart) // Controllo che sia effettivamente l'unico altrimenenti ciaone.
|
||||
codartmag = last_cod;
|
||||
else
|
||||
checked = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
TSQL_recordset codcor(TString() << "SELECT * FROM CODCORR WHERE CODARTALT = '" << codart << "' AND CODART = '" << codartmag << "';");
|
||||
if (codcor.items() > 0)
|
||||
tiporiga = ini_get_string(CONFIG_DITTA, "BS", "SKNumCustomRiga", "14");
|
||||
}
|
||||
}
|
||||
|
||||
TRectype& rdoc = doc->new_row(tiporiga);
|
||||
|
Loading…
x
Reference in New Issue
Block a user