diff --git a/src/tc/tc0701.cpp b/src/tc/tc0701.cpp index 394dd28b3..f1461c030 100755 --- a/src/tc/tc0701.cpp +++ b/src/tc/tc0701.cpp @@ -851,7 +851,7 @@ void TTS_sender::add_diversi(const TRecordset& mov, const bool moviva) j++; } else - log(2, "Conto cliente/formitore non trovato per giroconto ritenute o intra o reverse charge"); + log(2, "Conto cliente/fornitore non trovato per giroconto ritenute o intra o reverse charge"); } } else diff --git a/src/tc/tc3100.cpp b/src/tc/tc3100.cpp index ab6ad7cd5..08a25e86e 100644 --- a/src/tc/tc3100.cpp +++ b/src/tc/tc3100.cpp @@ -78,7 +78,7 @@ void TRiclassifica_cache::decode(const char* tab, const TString& cod, int & grup if (ric != NULL) { - gruppo = ric->get_int(); + gruppo = ric->get_int(0); conto = ric->get_int(); sottoconto = ric->get_long(); } @@ -111,7 +111,7 @@ TRecnotype TClifo_recset::new_rec(const char* buf) { bool apici=false; - for (const char* c = buf; *c ; c++) + for (const unsigned char* c = (const unsigned char*) buf; *c ; c++) { if (*c == '"') { @@ -129,10 +129,10 @@ TRecnotype TClifo_recset::new_rec(const char* buf) --c; } else - str << *c; + str << *((const char *) c); } else - str << *c; + str << *((const char *) c); } } @@ -170,12 +170,14 @@ const TString& TClifo_recset::add_stato(TLog_report& log) const if (stati.read(_isequal) != NOERR) { + stati.setkey(1); stati.last(); const int codice = stati.get_int("CODTAB") + 1; stati.zero(); stati.put("CODTAB", format("%03d", codice)); + stati.put("S0", stato); const int err = stati.write(); @@ -221,7 +223,7 @@ public: TRecnotype TPNota_recset::new_rec(const char* buf) { - TToken_string str(256,'|'); //nuovo record tab separator + TToken_string str(2560,'|'); //nuovo record tab separator if(buf && *buf) { @@ -394,7 +396,7 @@ TImportaEricsoft& app() { return (TImportaEricsoft&) main_app(); } //funzione che ricerca un cliente o un fornitore nel file clifo di campo in base al CODCF bool TImportaEricsoft::find_cli(const long cod) const { - TString16 key; key.format("C|%ld", cod); + TString16 key; key.format("C|E%ld", cod); return !cache().get(LF_CLIFO, key).empty(); } @@ -536,17 +538,56 @@ void TImportaEricsoft::upload_cli(const TFilename& file, TLog_report& log) //eseguo tutto SOLO se riesco a riempire la ragione sociale if (ragsoc.full()) { - - const bool var = find_cli(cod); //controllo se il clifo esiste già + TString16 key; key.format("E%ld", cod); + TString40 paiv = s.get(11).as_string(); + TString40 cofi = s.get(14).as_string(); - clifo.zero(); + paiv.strip_spaces(); + cofi.strip_spaces(); + clifo.setkey(6); + clifo.zero(); clifo.put(CLI_TIPOCF, "C"); - - clifo.put(CLI_CODCF,cod); + clifo.put(CLI_RICALT, key); - if (var) - clifo.read(); - + bool found = clifo.read() == NOERR; + + if (!found && paiv.full()) + { + clifo.setkey(5); + clifo.zero(); + clifo.put(CLI_TIPOCF, "C"); + clifo.put(CLI_PAIV, paiv); + + found = clifo.read() == NOERR; + } + + if (!found && cofi.full()) + { + clifo.setkey(4); + clifo.zero(); + clifo.put(CLI_TIPOCF, "C"); + clifo.put(CLI_COFI, cofi); + + found = clifo.read() == NOERR; + } + clifo.setkey(1); + + if (!found) + { + clifo.put(CLI_TIPOCF, "F"); + clifo.put(CLI_CODCF, cofi); + clifo.read(); + if (clifo.get(CLI_TIPOCF) == "F") + clifo.prev(); + const long newcod = clifo.get_long(CLI_CODCF) + 1L; + clifo.zero(); + clifo.put(CLI_TIPOCF, "C"); + clifo.put(CLI_CODCF, newcod); + } + + if (!clifo.get(CLI_RICALT).starts_with("E")) + clifo.put(CLI_RICALT, key); //ragsoc + clifo.put(CLI_RAGSOC, ragsoc); //ragsoc TToken_string & indirizzo = s.indirizzo(); clifo.put(CLI_INDCF, indirizzo.get()); //indirizzo @@ -574,7 +615,7 @@ void TImportaEricsoft::upload_cli(const TFilename& file, TLog_report& log) clifo.put(CLI_COMCF, codcom); //inserisci il codice del comune, recuperato tramite il cap clifo.put(CLI_LOCCF, s.get(20).as_string()); //inserisci la frazione se è indicata } - s.add_stato(log); + clifo.put(CLI_STATOCF, s.add_stato(log)); clifo.put(CLI_REFERENTE, s.get(8).as_string()); //inserisci i numeri di telefono (telefono, altro telefono, fax) for (int i = 9; i < 10; i++) @@ -600,7 +641,6 @@ void TImportaEricsoft::upload_cli(const TFilename& file, TLog_report& log) //inserisci l'indrizzo e-mail - const TString16 paiv = s.get(11).as_string(); clifo.put(CLI_PAIV, paiv); //p.iva const TString codpag = s.get(12).as_string(); // clifo.put(CLI_, riferimento); const TString ricavo = s.get(13).as_string(); @@ -612,13 +652,12 @@ void TImportaEricsoft::upload_cli(const TFilename& file, TLog_report& log) clifo.put(CLI_GRUPPORIC, gruppo); clifo.put(CLI_CONTORIC, conto); clifo.put(CLI_SOTTOCRIC, sottoconto); - const TString40 cofi = s.get(14).as_string(); clifo.put(CLI_COFI, cofi); //cod. fisc. TString str; str << "Il Cliente codice (" << clifo.get(CLI_CODCF) <<") " << ragsoc << " "; - if (var) + if (found) { const int err = clifo.rewrite(); if (err == NOERR) @@ -812,6 +851,7 @@ void TImportaEricsoft::upload_mov(const TFilename& file, TLog_report& log) TArray cods_iva; TISAM_recordset daily_movs("USE " TOSTRING(LF_MOV) " KEY 2\nFROM " MOV_DATAREG "=#DATE"); TProgind pi(s.items(),"Importazione Movimenti in corso...",true,true); + TLocalisamfile clifo(LF_CLIFO); for (bool ok=s.move_first();ok;ok=s.move_next()) { @@ -822,7 +862,7 @@ void TImportaEricsoft::upload_mov(const TFilename& file, TLog_report& log) const long numreg_eric = s.get(1).as_int(); const char sezione = s.get(2).as_int() == 0 ? 'D' : 'A'; _ricl->decode(TAB_RICCONTI, s.get(3).as_string(), gruppo, conto, sottoconto); - const long codcf = s.get(5).as_int(); + long codcf = s.get(5).as_int(); char tipocf= ' '; switch (s.get(4).as_int()) @@ -836,6 +876,19 @@ void TImportaEricsoft::upload_mov(const TFilename& file, TLog_report& log) default: break; } + if (codcf != 0L) + { + TString16 key; key.format("E%ld", codcf); + + clifo.setkey(6); + clifo.zero(); + clifo.put(CLI_TIPOCF, "C"); + clifo.put(CLI_RICALT, key); + if (clifo.read() == NOERR) + codcf = clifo.get_long(CLI_CODCF); + else + log.log(3, format(FR("Codice cliente Ericsoft %ld assente"), codcf)); + } const TDate datacomp = s.get(6).as_date(); const int tiporeg = s.get(7).as_int(); diff --git a/src/tc/tctbriv.uml b/src/tc/tctbriv.uml index 439a44a07..6a4276b29 100644 --- a/src/tc/tctbriv.uml +++ b/src/tc/tctbriv.uml @@ -11,7 +11,7 @@ BEGIN PROMPT 1 1 "Codice IVA Ericsoft" END -NUMBER F_CODTAB 3 +STRING F_CODTAB 3 BEGIN PROMPT 2 2 "Codice " USE &RIV @@ -22,7 +22,6 @@ BEGIN OUTPUT F_DESC S0 CHECKTYPE REQUIRED FIELD CODTAB - FLAGS "Z" KEY 1 END diff --git a/src/tc/tctbrre.uml b/src/tc/tctbrre.uml index a2ada83a5..02f5b8b04 100644 --- a/src/tc/tctbrre.uml +++ b/src/tc/tctbrre.uml @@ -19,9 +19,10 @@ BEGIN ITEM "3|Corrispettivi in scorporo" ITEM "4|Corrispettivi in ventilazione" FIELD CODTAB[1,1] + KEY 1 END -NUMBER F_CODTAB 2 +STRING F_CODTAB 2 BEGIN PROMPT 56 2 "Codice " USE &RRE