diff --git a/build/f90.vcxproj b/build/f90.vcxproj index 2d070b287..e0bf92062 100644 --- a/build/f90.vcxproj +++ b/build/f90.vcxproj @@ -246,7 +246,7 @@ - + diff --git a/build/f90.vcxproj.filters b/build/f90.vcxproj.filters index 73e22f80a..c56b6e838 100644 --- a/build/f90.vcxproj.filters +++ b/build/f90.vcxproj.filters @@ -146,7 +146,7 @@ - + Rep diff --git a/src/f9/f90100.h b/src/f9/f90100.h index 424c7fa02..88d2052e0 100644 --- a/src/f9/f90100.h +++ b/src/f9/f90100.h @@ -13,7 +13,6 @@ */ class TEstrai_mask : public TMask { - TString _descr; unique_ptr _estrazione; // Oggetto estrazione in corso di elaborazione void enable_fields(bool en = true); @@ -39,7 +38,6 @@ class TEstrai_mask : public TMask static bool dataend_handler(TMask_field& f, KEY key); public: - TString& get_descr() { return _descr; } TEstrai_mask(); }; diff --git a/src/f9/f90400.cpp b/src/f9/f90400.cpp index b1d8a41b9..39a12c6bf 100644 --- a/src/f9/f90400.cpp +++ b/src/f9/f90400.cpp @@ -12,18 +12,6 @@ #include "mov.h" #include "anagr.h" -class TReport_prosp : public TReport -{ -public: - bool print(TReport_book& book) - { - set_copy(0, 1); - return book.add(*this); - } - TReport_prosp(const char* name) { load(name); } -}; - - /** * \brief Some test for F9 classes */ @@ -185,18 +173,19 @@ void TF9_test_app::main_loop() annesso.obblig = true; TEstrazione::make_prosp_int_revc(96951, annesso);*/ - - TF9Prospetto_integr prosp; - if(prosp("96951", "96952")) { - TFilename tmp; tmp.tempdir(); - tmp.add(prosp.filename().name()); - tmp.ext("pdf"); + TF9Prospetto_integr prosp; + if (prosp("96951", "96952")) + { + TFilename tmp; tmp.tempdir(); + tmp.add(prosp.filename().name()); + tmp.ext("pdf"); #ifndef DBG - bool exp = prosp.export_pdf(tmp); + bool exp = prosp.export_pdf(tmp); #else - bool exp = prosp.preview(); + bool exp = prosp.preview(); #endif + } } message_box("TESTS COMPLETELY SUCCESSFUL"); diff --git a/src/f9/f9lib01.cpp b/src/f9/f9lib01.cpp index 511621907..365e421e1 100644 --- a/src/f9/f9lib01.cpp +++ b/src/f9/f9lib01.cpp @@ -10,7 +10,6 @@ #include "mov.h" #include "../fp/fplib.h" #include "annessif9.h" -#include "printer.h" #define MODE_SHEETS 0xC @@ -101,7 +100,7 @@ bool TEstrazione::check_annessi_oblig(const TString& catdoc, const int numreg, _ else if(ok_cat && annesso.opcee == "RC") { // Generazione prospetto integrativo. - make_prosp_int_revc(numreg, annesso); + ok_ann &= make_prosp_int_revc(numreg, annesso); } } return ok_ann; @@ -258,18 +257,45 @@ bool TEstrazione::is_doc_xml(const TLocalisamfile& mov) bool TEstrazione::is_integr_rev(const int numreg, _Out_ TString& numreg_rev_vend) { TLocalisamfile mov(LF_MOV); - TLocalisamfile mov_rev(LF_MOV); + //TLocalisamfile mov_rev(LF_MOV); mov.put(MOV_NUMREG, numreg); - mov_rev.put(MOV_NUMREG, numreg + 1); + /*mov_rev.put(MOV_NUMREG, numreg + 1); if(mov.read() == NOERR && mov_rev.read() == NOERR) { if(mov.get(MOV_DATADOC) == mov_rev.get(MOV_DATADOC) && (mov.get(MOV_NUMDOCEXT).full() && mov_rev.get(MOV_NUMDOCEXT).full() ? mov.get(MOV_NUMDOCEXT) == mov_rev.get(MOV_NUMDOCEXT) : mov.get(MOV_NUMDOC) == mov_rev.get(MOV_NUMDOC))) numreg_rev_vend = mov_rev.get(MOV_NUMREG); - return numreg_rev_vend.full(); + if(numreg_rev_vend.full()) return true; + }*/ + mov.read(); + + const TCausale& cau = cached_causale(mov.get(MOV_CODCAUS), mov.get_int(MOV_ANNOES)); + const TString4 cau_reg = cau.causale_reg_iva(); + TToken_string key(mov.get(MOV_TIPO)); key.add(mov.get_long(MOV_CODCF)); + const long codcli = cache().get(LF_CLIFO, key).get_long(CLI_CODCFASS); + TString query("USE "); + + query << LF_MOV << " KEY 1 SELECT " << MOV_CODCAUS << "==\"" << cau_reg << "\"\nFROM " << MOV_NUMREG << "==" << numreg; + TISAM_recordset mov_rs(query); + long movcoll = 0L; + + for (bool ok = mov_rs.move_first(); ok; ok = mov_rs.move_next()) + { + TRectype& curr = (TRectype&)mov_rs.cursor()->curr(); + const long movcoll_found = curr.get_long(MOV_MOVCOLL); + + if ((curr.get_long(MOV_CODCF) == codcli) && ((movcoll_found == 0L) || (movcoll_found == numreg))) + { + movcoll = mov_rs.get(MOV_NUMREG).as_int(); + curr.put(MOV_MOVCOLL, numreg); + TLocalisamfile& f = TLocalisamfile(LF_MOV); + curr.rewrite(f); + break; + } } - return false; + numreg_rev_vend.cut(0) << movcoll; + return numreg_rev_vend.full(); } bool TEstrazione::load_annessi(movimento_t& movimento) @@ -287,63 +313,61 @@ bool TEstrazione::make_prosp_int_revc(const int numreg, TCategorie_doc::annesso& TString rev_vend = mov.get(MOV_MOVCOLL); if(rev_vend.full() || is_integr_rev(numreg, rev_vend)) { - /* todo */ - ////////////////// - // Genero file /// todo - ////////////////// todo - - // [ NUMREG][ CAT.ANN.].pdf - // [0000000][AAAAAAAAAA].pdf - TFilename fileorig; // Nella temp - fileorig.tempdir().slash_terminate(); - fileorig << format("%07d", numreg); - for(int i = 0; i < 10 - annesso.catdoc.len(); ++i) - fileorig << "_"; - fileorig << annesso.catdoc << ".pdf"; - - - - - - - // Testo che abbia scritto il file - if (!fileorig.exist()) - bool simo = true; - - // Sposto il file nella cartella dei documenti cartacei. - const TFilename newfile(TF9_doccart::get_full_path_file_cartaceo(fileorig.name())); - if(!newfile.exist()) - CopyFile(fileorig, newfile, false); - else + TF9Prospetto_integr prosp; + if (prosp(TString(numreg), rev_vend)) { - // Rimpiazzo il file - DeleteFile(newfile); - CopyFile(fileorig, newfile, false); + // [ NUMREG][ CAT.ANN.].pdf + // [0000000][AAAAAAAAAA].pdf + TFilename tmp_file; tmp_file.tempdir(); + TString name; name << format("%07d%10s", numreg, (const char*)annesso.catdoc); + name.replace(' ', '_'); + tmp_file.add(name); + tmp_file.ext("pdf"); + if(prosp.export_pdf(tmp_file)) + { + if (!tmp_file.exist()) + bool simo = true; + + // Sposto il file nella cartella dei documenti cartacei. + const TFilename newfile(TF9_doccart::get_full_path_file_cartaceo(tmp_file.name())); + if (!newfile.exist()) + CopyFile(tmp_file, newfile, false); + else + { + // Rimpiazzo il file + DeleteFile(newfile); + CopyFile(tmp_file, newfile, false); + } + + // Controllo che non esista gia' altrimenti elimino il record + TF9_doccart doccart; + bool a; + TString numreg_old; + if (doccart.doc_already_exists(newfile, numreg_old, a)) + { + TLocalisamfile lf_ann(LF_F9ANNESSI); + lf_ann.setkey(2); + lf_ann.put(F9A_FILENAME, newfile.name()); + lf_ann.read(); + lf_ann.remove(); + lf_ann.zero(); + } + + // Registro il file come annesso RC + TLocalisamfile lf_ann(LF_F9ANNESSI); + lf_ann.put(F9A_NUMREG, numreg); + lf_ann.put(F9A_FILENAME, newfile.name()); + lf_ann.put(F9A_CATDOCPAD, annesso.catdocpadre); + lf_ann.put(F9A_CATDOCANN, annesso.catdoc); + lf_ann.put(F9A_LOADDATE, TDate(TODAY)); + lf_ann.put(F9A_USER, user()); + bool ok = lf_ann.write() == NOERR; + ok &= lf_ann.rewrite() == NOERR; + if (!ok) + ok = yesno_box("Impossibile creare il prospetto integrativo per la registrazione n. %s.\nContinuare con l'estrazione?", (const char*)numreg); + return ok; + } } - // Controllo che non esista gia' altrimenti elimino il record - TF9_doccart doccart; - bool a; - TString numreg_old; - if (doccart.doc_already_exists(newfile, numreg_old, a)) - { - TLocalisamfile lf_ann(LF_F9ANNESSI); - lf_ann.put(F9A_FILENAME, newfile.name()); - lf_ann.read(); - lf_ann.remove(); - lf_ann.zero(); - } - // Registro il file come annesso RC - TLocalisamfile lf_ann(LF_F9ANNESSI); - lf_ann.put(F9A_NUMREG, numreg); - lf_ann.put(F9A_FILENAME, newfile.name()); - lf_ann.put(F9A_CATDOCPAD, annesso.catdocpadre); - lf_ann.put(F9A_CATDOCANN, annesso.catdoc); - lf_ann.put(F9A_LOADDATE, TDate(TODAY)); - lf_ann.put(F9A_USER, user()); - bool ok = lf_ann.write() == NOERR; - ok &= lf_ann.rewrite() == NOERR; - if(!ok) - return yesno_box("Impossibile creare il prospetto integrativo per la registrazione n. %s.\nContinuare con l'estrazione?", (const char*)numreg); } return false; } diff --git a/src/f9/f9lib01.h b/src/f9/f9lib01.h index d69db0399..4c98bf978 100644 --- a/src/f9/f9lib01.h +++ b/src/f9/f9lib01.h @@ -543,7 +543,7 @@ public: class TF9Prospetto_integr { - static constexpr const char* _name = "prosp"; + static constexpr const char* _name = "f9ProspIntegr"; TReport_book _book; const TFilename _f_report; diff --git a/src/f9/f9lib02.cpp b/src/f9/f9lib02.cpp index 4010e7872..39feae066 100644 --- a/src/f9/f9lib02.cpp +++ b/src/f9/f9lib02.cpp @@ -448,11 +448,11 @@ bool TF9Prospetto_integr::operator()(const char* numreg_acq, const char* numreg_ { if (_rep.load(_f_report)) { - TFilename fprosp; fprosp.tempdir().slash_terminate() << make_name_rep(); - TProspetto_recset prosp_rs(numreg_acq, numreg_ven); - _items = prosp_rs.items(); + TFilename fprosp; fprosp.tempdir().slash_terminate() << make_name_rep(); + TProspetto_recset* _prosp_rs = new TProspetto_recset(numreg_acq, numreg_ven); + _items = _prosp_rs->items(); - _rep.set_recordset(&prosp_rs); + _rep.set_recordset(&*_prosp_rs); _book.add(_rep); } else