From fb9f970441f2c6b76784143a28d94882013c135a Mon Sep 17 00:00:00 2001 From: Simone Palacino Date: Tue, 28 Jul 2020 11:28:43 +0200 Subject: [PATCH] Patch level : 12.0 982 Files correlati : bs0.exe Commento : Modifica per importazione sknet nuovabienne vecchi codici pack --- src/bs/bs0200.cpp | 3 +-- src/bs/bs0300.cpp | 66 ++++++++++++++++++++++++++++++++++++++++++----- src/bs/bs0300b.h | 1 - 3 files changed, 60 insertions(+), 10 deletions(-) diff --git a/src/bs/bs0200.cpp b/src/bs/bs0200.cpp index ea3691f57..4fea0c22b 100644 --- a/src/bs/bs0200.cpp +++ b/src/bs/bs0200.cpp @@ -8,8 +8,7 @@ #include #include "../mg/mglib.h" -#include "../cg/cglib01.h" -#include "../cg/cg2101.h" +#include "../cg/cglib.h" #include "../ve/velib.h" #include #include diff --git a/src/bs/bs0300.cpp b/src/bs/bs0300.cpp index b3b535172..7d8d1662b 100644 --- a/src/bs/bs0300.cpp +++ b/src/bs/bs0300.cpp @@ -10,7 +10,7 @@ #include #include "../mg/mglib.h" -#include "../cg/cglib01.h" +#include "../cg/cglib.h" #include "../ve/velib.h" #include @@ -1412,6 +1412,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; nd = docs.get("NumRif").as_int(); TString wrk = docs.get("CodCliente").as_string(); @@ -1423,7 +1425,7 @@ void TSknet_sync::sync_doc() if ((tipocf != "C" && tipocf != "F") || codcf == 0) { - TString msg; msg.format("Attenzione! Per il doc n.%d č presente il tipo C/F = '%s' con cod = %d \nIl documento verrā saltato.", nd, tipocf, codcf); + TString msg; msg.format("Attenzione! Per il doc n.%d e' presente il tipo C/F = '%s' con cod = %d \nIl documento verra' saltato.", nd, (const char*)tipocf, codcf); _log->log(1, msg); continue; } @@ -1464,7 +1466,7 @@ void TSknet_sync::sync_doc() tipodoc = ini_get_string(CONFIG_DITTA, "BS", "SKTIPODOCORC"); break; default: - warning_box("Attenzione! Per il doc con codice: %s č presente un tipo documento non supportato.\nIl documento saltato", keyDoc); + warning_box("Attenzione! Per il doc con codice: %s e' presente un tipo documento non supportato.\nIl documento saltato", (const char*)keyDoc); } } else @@ -1578,16 +1580,65 @@ void TSknet_sync::sync_doc() } } - const TString80 codart = docs.get("CodArticolo").as_string(); - const TString descr = docs.get("DSRiga").as_string(); + const TString80 codart = docs.get("CodArticolo").as_string(); + TString80 codartmag = codart; + 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; + } + } + } tiporiga = ini_get_string(CONFIG_DITTA, "BS", "SKNumCustomRiga", "14"); + } } TRectype& rdoc = doc->new_row(tiporiga); @@ -1608,8 +1659,9 @@ void TSknet_sync::sync_doc() rdoc.put(RDOC_CODARTMAG, codart); } - rdoc.put(RDOC_CODARTMAG, codart); - // rdoc.check_row(); + //rdoc.put(RDOC_CODARTMAG, codart); + rdoc.put(RDOC_CODARTMAG, codartmag); + rdoc.put(RDOC_CHECKED, checked); rdoc.put(RDOC_DESCR, descr.sleft(50)); if (descr.len() > 50) diff --git a/src/bs/bs0300b.h b/src/bs/bs0300b.h index d951e5182..83eba17df 100644 --- a/src/bs/bs0300b.h +++ b/src/bs/bs0300b.h @@ -4,7 +4,6 @@ #include #include #include "../mg/mglib.h" -#include "../cg/cg2101.h" #include "../ve/velib.h" #include "../fe/felib.h" #include