2020-05-18 11:00:06 +02:00
|
|
|
#ifndef _F90100_H_
|
|
|
|
#define _F90100_H_
|
2019-09-10 17:33:59 +02:00
|
|
|
|
2020-04-01 21:26:49 +02:00
|
|
|
#include "execp.h"
|
|
|
|
#include "f90100a.h"
|
|
|
|
#include "mov.h"
|
2020-05-14 23:38:30 +02:00
|
|
|
#include "automask.h"
|
2020-04-01 21:26:49 +02:00
|
|
|
#include "applicat.h"
|
2019-09-10 17:33:59 +02:00
|
|
|
|
2020-07-07 11:07:44 +02:00
|
|
|
#include "f9lib.h"
|
|
|
|
|
2020-04-01 21:26:49 +02:00
|
|
|
/** class TEstrai_mask
|
2021-04-13 22:16:04 +02:00
|
|
|
* \brief Piccola maschera "creata a runtime" per avviare l'estrazione.
|
2020-04-01 21:26:49 +02:00
|
|
|
*/
|
2019-09-10 17:33:59 +02:00
|
|
|
class TEstrai_mask : public TMask
|
|
|
|
{
|
2021-04-13 22:16:04 +02:00
|
|
|
unique_ptr<TEstrazione> _estrazione; // Oggetto estrazione in corso di elaborazione
|
2019-09-10 17:33:59 +02:00
|
|
|
|
2020-05-16 02:12:25 +02:00
|
|
|
void enable_fields(bool en = true);
|
|
|
|
|
|
|
|
TDate get_dataini() const { return get_date(ES_DATAINI); }
|
|
|
|
TDate get_dataend() const { return get_date(ES_DATAEND); }
|
|
|
|
char get_tipodoc() const { return get(ES_TIPODOC)[0]; }
|
|
|
|
TipoIVA get_tipoiva() const { return get_tipodoc() == 'A' ? iva_acquisti : iva_vendite; }
|
|
|
|
TString get_descr() const { return get(ES_DESCR); }
|
|
|
|
bool is_provviso() const { return get(ES_FLAGPROV)[0] == 'P'; }
|
|
|
|
|
|
|
|
/* Prepara l'estrazione caricando tutti i movimenti dato un periodo (data registrazione),
|
|
|
|
* e avvia la procedura di estrazione.
|
|
|
|
* [See TEstrazione::estrai()].
|
|
|
|
*/
|
|
|
|
int estrai();
|
|
|
|
/** Segna su DRD che l'estrazione e' in errore diag. gestionale. */
|
|
|
|
void segna_in_errore() const;
|
2019-09-10 17:33:59 +02:00
|
|
|
|
2020-07-09 16:02:43 +02:00
|
|
|
static bool estrai_handler(TMask_field& f, KEY key);
|
|
|
|
static bool enable_handler(TMask_field& f, KEY key);
|
2020-04-01 21:26:49 +02:00
|
|
|
static bool dataini_handler(TMask_field& f, KEY key);
|
|
|
|
static bool dataend_handler(TMask_field& f, KEY key);
|
2020-05-16 02:12:25 +02:00
|
|
|
|
2019-09-10 17:33:59 +02:00
|
|
|
public:
|
2020-07-09 16:27:30 +02:00
|
|
|
static TString get_numdoc_exp_fp(int numreg);
|
2020-04-01 21:26:49 +02:00
|
|
|
TEstrai_mask();
|
2019-09-10 17:33:59 +02:00
|
|
|
};
|
|
|
|
|
2020-05-14 23:38:30 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
2019-09-10 17:33:59 +02:00
|
|
|
class TF9_app : public TSkeleton_application
|
|
|
|
{
|
2021-04-13 22:16:04 +02:00
|
|
|
//friend class TEstrai_mask;
|
2020-04-01 21:26:49 +02:00
|
|
|
friend class TMonitor_mask;
|
2020-07-08 16:26:30 +02:00
|
|
|
friend class TEstrai_mask;
|
2020-04-01 21:26:49 +02:00
|
|
|
friend class TControllo_mask;
|
2020-06-29 17:09:43 +02:00
|
|
|
friend class TApri_estr_msk;
|
2020-04-01 21:26:49 +02:00
|
|
|
friend class TEstrazione;
|
2021-04-13 22:16:04 +02:00
|
|
|
|
|
|
|
|
|
|
|
unique_ptr<TEstrai_mask> _estr_msk;
|
|
|
|
unique_ptr<TMonitor_mask> _msk;
|
2020-04-01 21:26:49 +02:00
|
|
|
vector<movimento_t> _movs;
|
2021-04-13 22:16:04 +02:00
|
|
|
vector<TToken_string> _esclusi; // Vettore con i movimenti esclusi
|
|
|
|
vector<TToken_string> _esclusi_vect;
|
2020-04-01 21:26:49 +02:00
|
|
|
TToken_string _mov_escl;
|
|
|
|
char _tipodoc_escl;
|
|
|
|
char _flagprov_escl;
|
|
|
|
TString _log;
|
2021-04-13 22:16:04 +02:00
|
|
|
|
2020-04-01 21:26:49 +02:00
|
|
|
TEstrazione* _estr_escluso;
|
2021-04-13 22:16:04 +02:00
|
|
|
|
2020-05-16 02:12:25 +02:00
|
|
|
|
2020-05-14 23:38:30 +02:00
|
|
|
char get_tipodoc_escl() const { return _tipodoc_escl; }
|
|
|
|
TipoIVA get_tipoiva_escl() const { return get_tipodoc_escl() == 'A' ? iva_acquisti : iva_vendite; }
|
2019-09-10 17:33:59 +02:00
|
|
|
|
2020-05-16 02:12:25 +02:00
|
|
|
// Dato il codice stato estrazione (es. "01") viene restituito il suo significato a parole (es. "in diagnostica").
|
|
|
|
static const char* traduci_stato(const TString& cod);
|
2020-06-29 17:09:43 +02:00
|
|
|
static bool is_stato_errore(const TString& stato_etr);
|
2019-09-10 17:33:59 +02:00
|
|
|
|
|
|
|
public:
|
2020-05-16 02:12:25 +02:00
|
|
|
/** Mostra la finestrella per l'inserimento delle opzioni per l'estrazione e avviarla. */
|
2020-04-01 21:26:49 +02:00
|
|
|
void run_estr_msk() const { _estr_msk->run(); }
|
2020-05-16 02:12:25 +02:00
|
|
|
void notify_estraction() const;
|
2019-09-10 17:33:59 +02:00
|
|
|
|
2020-05-14 23:38:30 +02:00
|
|
|
// Estrazione esclusi - handlers
|
|
|
|
|
2019-09-10 17:33:59 +02:00
|
|
|
static bool select_escl_notify(TSheet_field& s, int row, KEY key);
|
|
|
|
static bool controllo_escl_handler(TMask_field& field, KEY key);
|
|
|
|
static bool year_handler(TMask_field& field, KEY key);
|
2020-05-14 23:38:30 +02:00
|
|
|
static bool estrai_escl_handler(TMask_field&, KEY key);
|
|
|
|
|
2019-09-10 17:33:59 +02:00
|
|
|
void open_esclusi();
|
2019-09-13 17:06:08 +02:00
|
|
|
static void fill_esclusi();
|
2020-05-14 23:38:30 +02:00
|
|
|
|
2020-04-01 21:26:49 +02:00
|
|
|
static movimento_t escl2mov(TToken_string* row);
|
2020-05-14 23:38:30 +02:00
|
|
|
|
2019-10-28 12:31:23 +01:00
|
|
|
static bool mov_handler_escl(TMask_field&, KEY key);
|
2019-09-10 17:33:59 +02:00
|
|
|
|
2020-05-14 23:38:30 +02:00
|
|
|
/** Aggiorna tabella F9WA. */
|
2020-04-18 16:00:37 +02:00
|
|
|
void edit_wa(TString& old_codsoc) const;
|
2019-10-28 12:31:23 +01:00
|
|
|
|
|
|
|
// logs
|
|
|
|
|
|
|
|
void print_log();
|
|
|
|
void add_msg_log(const char* msg);
|
|
|
|
void add_sqlerror_msg_log(const char* query);
|
|
|
|
|
2020-04-01 21:26:49 +02:00
|
|
|
static bool is_autofattura(const TLocalisamfile& mov);
|
2019-09-10 17:33:59 +02:00
|
|
|
|
2020-05-14 23:38:30 +02:00
|
|
|
/** Segna su mov che il movimento e' stato estratto. */
|
|
|
|
bool segna_estratti(bool escluso = false, int numreg = 0);
|
2019-09-13 17:06:08 +02:00
|
|
|
|
2021-04-13 22:16:04 +02:00
|
|
|
// Controllo e aggiornamento tabelle F9
|
|
|
|
private:
|
|
|
|
bool create_tables() const; // Creazione tabelle F9.
|
|
|
|
bool check_tabelle_f9() const; // Controllo esistenza delle tabelle e in caso le crea.
|
|
|
|
bool aggiorna_tab_f9(int version) const; // Aggiorna modifiche alle tabelle F9 come descritto in cima al file f90100.cpp.
|
|
|
|
bool check_tab_version() const; // Controllo della versione e in caso aggiorna le tabelle.
|
|
|
|
bool check_table() const; // Controllo e aggiornamento versione sql. Chiamata in main_loop.
|
|
|
|
|
2020-05-14 23:38:30 +02:00
|
|
|
public:
|
|
|
|
void main_loop() override;
|
|
|
|
|
|
|
|
TF9_app();
|
2019-09-10 17:33:59 +02:00
|
|
|
};
|
2020-05-14 23:38:30 +02:00
|
|
|
|
2021-04-13 22:16:04 +02:00
|
|
|
inline TF9_app& f9_app()
|
|
|
|
{
|
|
|
|
static TF9_app* app = nullptr;
|
|
|
|
if (app == nullptr)
|
|
|
|
app = (TF9_app*)&main_app();
|
|
|
|
return *app;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class TApri_estr_msk;
|
|
|
|
class TMonitor_mask : public TAutomask
|
|
|
|
{
|
|
|
|
friend class TF9_app;
|
|
|
|
vector<TToken_string> _fppro;
|
|
|
|
std::unique_ptr<TApri_estr_msk> _inclusi_mask;
|
|
|
|
|
|
|
|
// Configurazione mask
|
|
|
|
static bool save_conf_handler(TMask_field& f, KEY key);
|
|
|
|
|
|
|
|
// Metodi per la maschera 'Apri Estr.'
|
|
|
|
|
|
|
|
void open_apri_estr_win();
|
|
|
|
|
|
|
|
// Controllo estr. mask
|
|
|
|
void controllo_errori() const;
|
|
|
|
static void delete_estr_fld(const TString& idestr);
|
|
|
|
void delete_pack(bool all = false) const;
|
|
|
|
|
|
|
|
// Riempie sheet per visualizzare le estrazioni
|
|
|
|
void fill() const;
|
|
|
|
|
|
|
|
bool on_field_event(TOperable_field& o, TField_event e, long jolly) override;
|
|
|
|
static void open_win_estr();
|
|
|
|
static void open_win_conf();
|
|
|
|
void sel() const;
|
|
|
|
|
|
|
|
public:
|
|
|
|
TMonitor_mask();
|
|
|
|
};
|
|
|
|
|
|
|
|
class TControllo_mask : public TAutomask
|
|
|
|
{
|
|
|
|
vector<TToken_string> _controllo_mov; // Usare import_error_list().
|
|
|
|
char _ordin;
|
|
|
|
char _verso;
|
|
|
|
int _selected_mov;
|
|
|
|
bool _sel_esclusi;
|
|
|
|
bool _is_escluso;
|
|
|
|
TString _cod_soc;
|
|
|
|
TString _id_estr;
|
|
|
|
char _tipo_doc_err{};
|
|
|
|
TDate _datada;
|
|
|
|
TDate _dataa;
|
|
|
|
|
|
|
|
void associa();
|
|
|
|
void conferma_esclusi() const;
|
|
|
|
|
|
|
|
vector<TToken_string>& import_error_list();
|
|
|
|
void fill();
|
|
|
|
void fill_fppro_sheet() const;
|
|
|
|
TMask& get_win_order();
|
|
|
|
void open_win_order();
|
|
|
|
|
|
|
|
TToken_string* selected_mov();
|
|
|
|
TToken_string* selected_fat() const;
|
|
|
|
|
|
|
|
/** Gestisce la selezione multipla negli sheet di controllo movimenti */
|
|
|
|
void selfatt(TOperable_field& o, long jolly) const;
|
|
|
|
|
|
|
|
bool on_field_event(TOperable_field& o, TField_event e, long jolly) override;
|
|
|
|
public:
|
|
|
|
TControllo_mask(const char* codsoc, const char* id_estr, bool esclusi = false);
|
|
|
|
};
|
|
|
|
|
|
|
|
class TApri_estr_msk : public TAutomask
|
|
|
|
{
|
|
|
|
TString _idestr;
|
|
|
|
TDate _dataestr;
|
|
|
|
bool _provv;
|
|
|
|
char _tipodoc;
|
|
|
|
TString _statoestr;
|
|
|
|
TDate _datadal;
|
|
|
|
TDate _dataal;
|
|
|
|
|
|
|
|
bool on_field_event(TOperable_field& o, TField_event e, long jolly) override;
|
|
|
|
|
|
|
|
bool inall_handler() const;
|
|
|
|
bool inescludi_handler() const;
|
|
|
|
bool inselect_handler() const;
|
|
|
|
void conferma_esclusi() const;
|
|
|
|
public:
|
|
|
|
void fill_estr() const;
|
|
|
|
void fill_res() const;
|
|
|
|
void set_from_row_estrazione(TToken_string& row_estrazione);
|
|
|
|
|
|
|
|
TApri_estr_msk();
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-06-29 17:09:43 +02:00
|
|
|
|
2019-09-13 17:06:08 +02:00
|
|
|
inline bool open_mov(const TRectype& mov)
|
|
|
|
{
|
|
|
|
TFilename ininame; ininame.temp("lnk", "ini");
|
|
|
|
{
|
|
|
|
TConfig ini(ininame, "Transaction");
|
|
|
|
ini.set("Action", "LINK");
|
|
|
|
ini.set_paragraph("23");
|
|
|
|
ini.set("NUMREG", mov.get(MOV_NUMREG));
|
|
|
|
}
|
|
|
|
TString app;
|
|
|
|
app << "cg2.exe -0 -i" << ininame;
|
|
|
|
TExternal_app a(app);
|
|
|
|
bool ok = a.run() == 0;
|
|
|
|
|
|
|
|
if (ok)
|
|
|
|
{
|
|
|
|
xvt_sys_sleep(500);
|
|
|
|
const TString& result = ini_get_string(ininame, "Transaction", "Result");
|
|
|
|
ok = result == "OK";
|
|
|
|
}
|
|
|
|
xvt_fsys_remove_file(ininame);
|
|
|
|
return ok;
|
2019-10-16 14:23:36 +02:00
|
|
|
}
|
|
|
|
|
2020-07-07 11:07:44 +02:00
|
|
|
#endif //_F90100_H_
|