diff --git a/src/bs/bs0200.cpp b/src/bs/bs0200.cpp index e0fd81ff9..deb9e6f7d 100644 --- a/src/bs/bs0200.cpp +++ b/src/bs/bs0200.cpp @@ -1436,7 +1436,7 @@ void TBeeStore_sync::sync_fatbol(const TDate& dal, const TDate& al) str << "<=" << date2sql(al); } } - str << "\nORDER BY NumMov,NumRiga"; + str << "\nORDER BY CodTestata,NumRiga"; TODBC_recordset docs(str); docs.connect(_dsn, _usr, _psw); @@ -1447,6 +1447,8 @@ void TBeeStore_sync::sync_fatbol(const TDate& dal, const TDate& al) TString4 tipocf; TDocumento* doc = nullptr; int contatore = 0; + int eccezioni_errori = 0; + TString codpk = ""; for (bool ok = docs.move_first(); ok; ok = docs.move_next()) { TToken_string test(docs.get("CodTestata").as_string(), '\\'); @@ -1461,6 +1463,7 @@ void TBeeStore_sync::sync_fatbol(const TDate& dal, const TDate& al) codcf = atol(wrk); tipocf = docs.get("TipoIntestatario").as_string(); + if (tipocf != "C") // verificare tipocf = "F"; @@ -1479,46 +1482,65 @@ void TBeeStore_sync::sync_fatbol(const TDate& dal, const TDate& al) TString tre = test_doc.right(3); const TDate datadoc = docs.get("DataMov").as_date(); - TString8 numdoc = docs.get("TipoDocCE").as_string(); + TString cod_pk= docs.get("Cod_PK").as_string(); + TString8 numdoc = docs.get("NumDoc").as_string(); TString8 tipodoc = docs.get("TipoDocCE").as_string(); TString origine_dc = docs.get("Origine").as_string(); - TTipo_documento tipo(tipodoc); - const TString8 codcaus = tipo.caus_mov().blank() ? codcausdef : tipo.caus_mov(); + + if (tipodoc.not_empty() && (tipodoc!=" ")) { - //doc = new TDocumento('D', datadoc.year(), numdoc, nd); //meglio usare TDocumento(char provv, int anno, const char* codnum, long numdoc); - doc = new TDocumento('D', datadoc.year(), numdoc, strtol(tre, nullptr, 0)); + TTipo_documento tipo(tipodoc); + const TString8 codcaus = tipo.caus_mov().blank() ? codcausdef : tipo.caus_mov(); + + //doc = new TDocumento('D', datadoc.year(), numdoc, nd); //meglio usare TDocumento(char provv, int anno, const char* codnum, long numdoc); + doc = new TDocumento('D', datadoc.year(), tipodoc, strtol(numdoc, nullptr, 0)); - doc->put(DOC_DATADOC, datadoc); - doc->put(DOC_TIPODOC, tipodoc); - doc->put(DOC_TIPOCF, tipocf); - doc->put(DOC_CODCF, codcf); - doc->cli2doc(); + doc->put(DOC_DATADOC, datadoc); + doc->put(DOC_TIPODOC, tipodoc); + doc->put(DOC_TIPOCF, tipocf); + doc->put(DOC_CODCF, codcf); + doc->cli2doc(); - const TString8 codval = docs.get("CodValuta").as_string(); - const real cambio = docs.get("CambioValuta").as_real(); - const TString asp = docs.get("AspettoBeni").as_string(); - const int ncolli = docs.get("NumeroColli").as_int(); - - doc->put(DOC_CODVAL, codval); - doc->put(DOC_CAMBIO, cambio); - doc->put(DOC_ASPBENI1, asp.sleft(50)); - doc->put(DOC_ASPBENI2, asp.smid(50)); - doc->put(DOC_NCOLLI, ncolli); - doc->put(DOC_CAUSMAG, codcaus); - contatore++; + const TString8 codval = docs.get("CodValuta").as_string(); + const real cambio = docs.get("CambioValuta").as_real(); + const TString asp = docs.get("AspettoBeni").as_string(); + const int ncolli = docs.get("NumeroColli").as_int(); + // inserire codice pagamento Es. BB02 + doc->put(DOC_CODVAL, codval); + doc->put(DOC_CAMBIO, cambio); + doc->put(DOC_ASPBENI1, asp.sleft(50)); + doc->put(DOC_ASPBENI2, asp.smid(50)); + doc->put(DOC_NCOLLI, ncolli); + doc->put(DOC_CAUSMAG, codcaus); + contatore++; + } + else + { + eccezioni_errori++; + codpk = cod_pk; + TString dserrore = docs.get("DSErrore").as_string(); + dserrore << " TipoDocCe assente o invalido"; + TString update_str = ""; + update_str << "UPDATE tieTBolFat \n SET Errore=1, DSErrore = '" << dserrore << "' \n WHERE cod_pk= '" << codpk << "' "; + TODBC_recordset docs(update_str); + docs.connect(_dsn, _usr, _psw); + docs.exec(update_str); + } } + TString8 tipodoc = docs.get("TipoDocCE").as_string(); + if (tipodoc.not_empty() && (tipodoc != " ")) { const int tipoart = docs.get("TipoArticolo").as_int(); - TString4 tiporiga = tipoart == 2 ? "04" : "02"; + // inutile per noi TString4 tiporiga = tipoart == 2 ? "04" : "02"; TRectype& rdoc = doc->new_row("01"); const TString80 codart = docs.get("CodArticolo").as_string(); rdoc.put(RDOC_CODART, codart); - if (tipoart == 2) + if (tipoart == 2) //righe libere { if (cache().get("SPP", codart).not_empty()) rdoc.put(RDOC_CODARTMAG, codart); } - else + else //spese servizi e articoli { if (cache().get(LF_ANAMAG, codart).not_empty()) rdoc.put(RDOC_CODARTMAG, codart); @@ -1538,8 +1560,9 @@ void TBeeStore_sync::sync_fatbol(const TDate& dal, const TDate& al) rdoc.put(RDOC_CODMAGC, docs.get("CodMagazDest").as_string().left(5)); rdoc.put(RDOC_UMQTA, docs.get("CodUntMis").as_string()); rdoc.put(RDOC_QTA, docs.get("Quantita").as_real()); - rdoc.put(RDOC_PREZZO, docs.get("PrzNettoSede").as_real()); // o PrzNettoValuta ?? + rdoc.put(RDOC_PREZZO, docs.get("PrzNettoNeg").as_real()); // o PrzNettoValuta ?? + /* real valsconto1(docs.get("Sconto1").as_real()); real valsconto2(docs.get("Sconto2").as_real()); real valsconto3(docs.get("Sconto3").as_real()); @@ -1560,18 +1583,24 @@ void TBeeStore_sync::sync_fatbol(const TDate& dal, const TDate& al) sconto << valsconto3.stringa(6, 2); } rdoc.put(RDOC_SCONTO, sconto); + */ rdoc.put(RDOC_CODIVA, docs.get("CodIva").as_string()); - + } if (!pi.add_status()) break; - } save_and_delete_doc(doc); // Salva ultimo documento in sospeso str.cut(0); str.format(TR("Documenti importati %ld record in %s"), contatore, "tieTBolFat"); _log->log(0, ""); _log->log(0, str); + if (eccezioni_errori > 0) + { + str.cut(0); + str.format(TR("Errori in importazione %ld record in %s"), eccezioni_errori, "tieTBolFat"); + _log->log(0, str); + } } bool TBeeStore_sync::create() @@ -1646,8 +1675,12 @@ void TBeeStore_sync::main_loop() sync_carscar(dal, al); if (mask.get_bool("SyncGenerici")) sync_generici(dal, al); + + const TDate dalfat = mask.get_date("SyncDateFromF"); + const TDate alfat = mask.get_date("SyncDateToF"); + if (mask.get_bool("SyncFatBol")) - sync_fatbol(dal, al); + sync_fatbol(dalfat, alfat); _log->preview(); delete _log; diff --git a/src/bs/bs0200a.uml b/src/bs/bs0200a.uml index 7e9421fd7..1bcf848b5 100644 --- a/src/bs/bs0200a.uml +++ b/src/bs/bs0200a.uml @@ -132,7 +132,7 @@ END ENDPAGE -PAGE "BeeStore Import:Fatt/Boll/Scon" 0 2 0 0 +PAGE "Import: Bolle/Fatture/Scontr." 0 2 0 0 GROUPBOX DLG_NULL 78 4 BEGIN diff --git a/src/bs/bsmenu.men b/src/bs/bsmenu.men index 16a087552..f0d2aeeab 100644 --- a/src/bs/bsmenu.men +++ b/src/bs/bsmenu.men @@ -5,9 +5,9 @@ Module = bs Flags = "F" Item_01 = "Configurazione", "bs0 -0", "F", 9015 Item_02 = "Sincronizzazione", "bs0 -1", "F", 9015 -Item_02 = "BeeStore Importazione Fatture", "bs0 -1", "F", 9015 -Item_02 = "SKNET Importer", "bs0 -2", "F", 9015 -Item_03 = "Tabelle di conversione", [BSMENU_002] +Item_03 = "BeeStore Importazione Fatture", "bs0 -1", "F", 9015 +Item_04 = "SKNET Importer", "bs0 -2", "F", 9015 +Item_05 = "Tabelle di conversione", [BSMENU_002] [BSMENU_002] Caption = "Tabelle di conversione"