2019-09-10 17:33:59 +02:00
|
|
|
#pragma once
|
|
|
|
#include "applicat.h"
|
|
|
|
#include "f90100a.h"
|
|
|
|
#include <automask.h>
|
2019-09-13 17:06:08 +02:00
|
|
|
#include "execp.h"
|
2019-09-10 17:33:59 +02:00
|
|
|
|
|
|
|
#define PAR_MOD "F9"
|
|
|
|
#define AMBIENTE_F9 "CODSOC" // Codice ambiente (codsoc)
|
|
|
|
#define ADDRCART_F9 "ADDDOC" // Indirizzo documenti cartacei
|
|
|
|
|
|
|
|
TDate today(TODAY);
|
|
|
|
|
|
|
|
enum state_fppro
|
|
|
|
{
|
|
|
|
correct = 1,
|
|
|
|
reg_with_err = -1,
|
|
|
|
not_fa = -10, // Non e' fattura acquisti
|
|
|
|
guessed = 100,
|
|
|
|
no_guessed = 0
|
|
|
|
};
|
|
|
|
|
|
|
|
struct drd
|
|
|
|
{
|
|
|
|
TString cod_soc;
|
|
|
|
TString id_estr;
|
|
|
|
bool flag_prov{ true };
|
|
|
|
TString descr;
|
|
|
|
char tipo_doc{ 'A' };
|
|
|
|
TDate dal;
|
|
|
|
TDate al;
|
|
|
|
TString user;
|
|
|
|
TString timestamp;
|
|
|
|
TString4 stato_estr{ "01" };
|
|
|
|
TString addr_cart;
|
|
|
|
};
|
|
|
|
|
|
|
|
SSimple_query& db();
|
|
|
|
|
|
|
|
class TEstrai_mask : public TMask
|
|
|
|
{
|
|
|
|
TString _descr;
|
|
|
|
|
|
|
|
void enable_fields(bool en = true);
|
|
|
|
|
|
|
|
static bool estrai_handler(TMask_field& f, unsigned short key);
|
|
|
|
static bool enable_handler(TMask_field& f, unsigned short key);
|
|
|
|
static bool dataini_handler(TMask_field& f, unsigned short key);
|
|
|
|
static bool dataend_handler(TMask_field& f, unsigned short key);
|
|
|
|
public:
|
|
|
|
TString& get_descr() { return _descr; }
|
|
|
|
TEstrai_mask();
|
|
|
|
};
|
|
|
|
|
|
|
|
class TEstrai_mask;
|
|
|
|
class TMonitor_mask;
|
|
|
|
class TControllo_mask;
|
|
|
|
class TF9_app : public TSkeleton_application
|
|
|
|
{
|
|
|
|
//friend class TEstrai_mask;
|
|
|
|
friend class TMonitor_mask;
|
|
|
|
friend class TControllo_mask;
|
|
|
|
drd _head;
|
|
|
|
TEstrai_mask* _estr_msk;
|
|
|
|
TMonitor_mask* _msk;
|
|
|
|
//TControllo_mask* _controllo_msk;
|
|
|
|
vector<TToken_string> _movs;
|
|
|
|
vector<TToken_string> _esclusi; // Vettore con i movimenti esclusi
|
2019-09-13 17:06:08 +02:00
|
|
|
vector<TToken_string> _esclusi_vect;
|
2019-09-10 17:33:59 +02:00
|
|
|
TToken_string _mov_escl;
|
|
|
|
int _tot_movs;
|
|
|
|
TString _ambiente; // Codice ambiente (codsoc)
|
|
|
|
TString _addr_doc; // Indirizzo documenti cartacei
|
|
|
|
int _last_estr_p;
|
|
|
|
int _last_estr_d;
|
|
|
|
char _tipodoc_escl;
|
|
|
|
char _flagprov_escl;
|
|
|
|
|
|
|
|
static const char* traduci_stato(const TString& cod);
|
|
|
|
|
|
|
|
state_fppro check_fppro(int numreg) const;
|
|
|
|
const char* prepara_movimenti(TipoIVA tipo);
|
|
|
|
const char* prepara_movimenti_escl(TipoIVA tipo, int numreg, TString& err) const;
|
|
|
|
static bool is_doc_xml(const TLocalisamfile& mov);
|
|
|
|
static bool check_periodo_def(const drd& head);
|
|
|
|
|
|
|
|
static TString& drd_attr();
|
|
|
|
TString& drd_tovalues() const;
|
|
|
|
|
|
|
|
TString next_estr_today(char tipo) const;
|
2019-09-13 17:06:08 +02:00
|
|
|
bool esporta() const;
|
2019-09-10 17:33:59 +02:00
|
|
|
bool new_extr() const;
|
|
|
|
|
|
|
|
TDate get_dataini() const { return _estr_msk->get_date(ES_DATAINI); }
|
|
|
|
TDate get_dataend() const { return _estr_msk->get_date(ES_DATAEND); }
|
|
|
|
char get_tipodoc() const { return _estr_msk->get(ES_TIPODOC)[0]; }
|
|
|
|
char get_tipodoc_escl() const { return _tipodoc_escl; }
|
2019-09-13 17:06:08 +02:00
|
|
|
TipoIVA get_tipoiva() const { return get_tipodoc() == 'A' ? iva_acquisti : iva_vendite; }
|
|
|
|
TipoIVA get_tipoiva_escl() const { return get_tipodoc_escl() == 'A' ? iva_acquisti : iva_vendite; }
|
2019-09-10 17:33:59 +02:00
|
|
|
TString& get_descr() const { return _estr_msk->get_descr(); }
|
|
|
|
bool is_provviso() const { return _estr_msk->get(ES_FLAGPROV)[0] == 'P'; }
|
|
|
|
|
2019-09-13 17:06:08 +02:00
|
|
|
//void fill();
|
2019-09-10 17:33:59 +02:00
|
|
|
void load();
|
|
|
|
|
|
|
|
public:
|
|
|
|
const TString& get_ambiente() const { return _ambiente; };
|
|
|
|
const TString& get_addr_doc() const { return _addr_doc; };
|
|
|
|
|
|
|
|
void set_ambiente(const char* cod) { _ambiente.cut(0) << cod; };
|
|
|
|
void set_addr_doc(const char* add) { _addr_doc.cut(0) << add; };
|
|
|
|
|
|
|
|
void run_estr_msk() const { _estr_msk->run(); }
|
|
|
|
|
|
|
|
static TMask& descr_msk();
|
|
|
|
|
|
|
|
// Estrazione esclusi
|
|
|
|
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);
|
|
|
|
void open_esclusi();
|
2019-09-13 17:06:08 +02:00
|
|
|
static void fill_esclusi();
|
|
|
|
static bool estrai_escl_handler(TMask_field&, KEY key);
|
|
|
|
static bool mov_handler(TMask_field&, KEY key);
|
2019-09-10 17:33:59 +02:00
|
|
|
|
|
|
|
void edit_wa() const;
|
2019-09-13 17:06:08 +02:00
|
|
|
void export_error_list(bool esclusi = false);
|
2019-09-10 17:33:59 +02:00
|
|
|
int estrai(); // Estrazione per pacchetti "normali"
|
2019-09-13 17:06:08 +02:00
|
|
|
int estrai_single(TToken_string& row, char flagprov, char tipodoc); // Estrazione singole per esclusi
|
2019-09-10 17:33:59 +02:00
|
|
|
bool estrazione_iva(bool escluso = false); // Estrazione dati IVA sia per pacch. normali che per esclusi
|
2019-09-13 17:06:08 +02:00
|
|
|
bool segna_estratti(bool escluso = false, int numreg = 0); // Segna su mov che il movimento e' stato estratto
|
2019-09-10 17:33:59 +02:00
|
|
|
void segna_in_errore() const;
|
|
|
|
|
|
|
|
static const char* categoria_doc();
|
|
|
|
static const char* caus_sos(const TLocalisamfile& mov, TipoIVA acquisti);
|
|
|
|
static bool is_autofattura(const TLocalisamfile& mov);
|
|
|
|
|
|
|
|
void main_loop() override;
|
2019-09-13 17:06:08 +02:00
|
|
|
|
|
|
|
// Controllo e aggiornamento tabelle F9
|
|
|
|
|
|
|
|
bool create_tables() const; // Creazione tabelle F9
|
|
|
|
bool check_tabelle_f9(); // 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 .cpp
|
|
|
|
bool check_tab_version() const; // Controllo della versione e in caso aggiorna le tabelle
|
2019-09-16 18:10:27 +02:00
|
|
|
bool check_table() const;
|
2019-09-13 17:06:08 +02:00
|
|
|
TF9_app() : _estr_msk(nullptr), _msk(nullptr), _mov_escl("", '|'), _tot_movs(0), _ambiente(""), _addr_doc(""),
|
|
|
|
_last_estr_p(0), _last_estr_d(0), _tipodoc_escl('A'), _flagprov_escl('P') { }
|
2019-09-10 17:33:59 +02:00
|
|
|
};
|
2019-09-13 17:06:08 +02:00
|
|
|
|
2019-09-10 17:33:59 +02:00
|
|
|
TF9_app& app();
|
|
|
|
|
|
|
|
class TMonitor_mask : public TAutomask
|
|
|
|
{
|
|
|
|
vector<TToken_string> _fppro;
|
2019-09-13 17:06:08 +02:00
|
|
|
friend class TF9_app;
|
2019-09-10 17:33:59 +02:00
|
|
|
|
|
|
|
static bool save_conf_handler(TMask_field& f, unsigned short key);
|
|
|
|
|
2019-09-13 17:06:08 +02:00
|
|
|
void controllo_errori() const;
|
2019-09-10 17:33:59 +02:00
|
|
|
// Riempie sheet per visualizzare le estrazioni
|
|
|
|
bool on_key(KEY key) override;
|
|
|
|
static void open_win_estr();
|
|
|
|
void open_win_conf() const;
|
|
|
|
|
2019-09-13 17:06:08 +02:00
|
|
|
void fill();
|
|
|
|
|
|
|
|
void delete_pack(bool all = false);
|
|
|
|
|
|
|
|
void sel() const;
|
|
|
|
bool on_field_event(TOperable_field& o, TField_event e, long jolly) override;
|
2019-09-10 17:33:59 +02:00
|
|
|
|
|
|
|
public:
|
|
|
|
void disable_controllo_err();
|
|
|
|
TMonitor_mask() : TAutomask("f90100a")
|
|
|
|
{
|
2019-09-13 17:06:08 +02:00
|
|
|
//disable(DLG_FINDREC);
|
2019-09-10 17:33:59 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
class TControllo_mask : public TAutomask
|
|
|
|
{
|
2019-09-13 17:06:08 +02:00
|
|
|
char _ordin;
|
|
|
|
char _verso;
|
|
|
|
int _selected_mov;
|
|
|
|
bool _sel_esclusi;
|
|
|
|
bool _is_escluso;
|
|
|
|
TString _id_estr;
|
|
|
|
char _tipo_doc_err;
|
|
|
|
|
|
|
|
vector<TToken_string>& import_error_list();
|
|
|
|
void fill();
|
2019-09-10 17:33:59 +02:00
|
|
|
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;
|
|
|
|
void conferma_esclusi() const;
|
|
|
|
void associa();
|
|
|
|
|
|
|
|
bool on_field_event(TOperable_field& o, TField_event e, long jolly) override;
|
|
|
|
|
|
|
|
public:
|
2019-09-13 17:06:08 +02:00
|
|
|
TControllo_mask(const char* id_estr, bool esclusi = false);
|
|
|
|
};
|
|
|
|
|
|
|
|
class TF9_dberr
|
|
|
|
{
|
|
|
|
TString _str;
|
|
|
|
TString _insert;
|
|
|
|
|
|
|
|
void add_str(const TString& string);
|
|
|
|
public:
|
|
|
|
void add(const TString& string);
|
|
|
|
void add(const TDate& date) { add(date.date2ansi()); }
|
|
|
|
void add(const char* string) { add(TString(string)); }
|
|
|
|
void add(long num);
|
|
|
|
void add() { add_str("NULL"); }
|
|
|
|
void send();
|
|
|
|
static char get_errori(const TString& id_estr, vector<TToken_string>& movs);
|
|
|
|
TF9_dberr();
|
|
|
|
};
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|