diff --git a/src/tc/tc3100.cpp b/src/tc/tc3100.cpp index 08a25e86e..c42cfc016 100644 --- a/src/tc/tc3100.cpp +++ b/src/tc/tc3100.cpp @@ -858,6 +858,9 @@ void TImportaEricsoft::upload_mov(const TFilename& file, TLog_report& log) if (!pi.addstatus(1)) break; + if (s.get(1).as_int() == 0L) + continue; + const TDate datareg = s.get(0).as_date(); const long numreg_eric = s.get(1).as_int(); const char sezione = s.get(2).as_int() == 0 ? 'D' : 'A'; @@ -876,19 +879,19 @@ void TImportaEricsoft::upload_mov(const TFilename& file, TLog_report& log) default: break; } - if (codcf != 0L) - { - TString16 key; key.format("E%ld", codcf); + 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)); - } + 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(); @@ -936,7 +939,7 @@ void TImportaEricsoft::upload_mov(const TFilename& file, TLog_report& log) cods_iva.destroy(); numreg = numreg_eric; nriga = 0; - nrigaIVA = 0; + nrigaIVA = 0L; ini_file.temp("eric", "ini"); ini = new TConfig(ini_file, "Transaction"); @@ -944,18 +947,18 @@ void TImportaEricsoft::upload_mov(const TFilename& file, TLog_report& log) long nreg = 0; daily_movs.set_var("#DATE", datareg.stringa()); - for (bool ok = daily_movs.move_first(); ok; ok = daily_movs.move_next()) + for (bool ok = daily_movs.move_first(); ok && nreg == 0L; ok = daily_movs.move_next()) if (numreg == daily_movs.get(MOV_TNUMREG).as_int()) nreg = daily_movs.get(MOV_NUMREG).as_int(); + if (nreg == 0L) ini->set("Action", TRANSACTION_INSERT); else - { ini->set("Action", TRANSACTION_MODIFY); - ini->set(MOV_NUMREG, nreg); - } ini->set("Mode", mode); ini->set_paragraph(LF_MOV); + if (nreg != 0L) + ini->set(MOV_NUMREG, nreg); ini->set(MOV_DATAREG, datareg); ini->set(MOV_ANNOIVA, datareg.year()); ini->set(MOV_ANNOES, _esc.esercizio(datacomp).codice()); @@ -1036,6 +1039,13 @@ void TImportaEricsoft::upload_mov(const TFilename& file, TLog_report& log) } } } + if (numreg > 0L) + { + delete ini; + ini = NULL; + skip |= (nriga == 0) && (nrigaIVA == 0); + save_mov(log, ini_file, skip); + } } bool TImportaEricsoft::transfer()