2019-01-02 14:48:09 +01:00
|
|
|
|
#ifndef __FPLIB_H
|
|
|
|
|
#define __FPLIB_H
|
2018-07-06 16:30:37 +02:00
|
|
|
|
|
|
|
|
|
#include <tsdb.h>
|
|
|
|
|
#include <utility.h>
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
2018-07-25 15:53:29 +02:00
|
|
|
|
#include "../ve/velib05.h"
|
|
|
|
|
#include "../fe/felib.h"
|
|
|
|
|
#include <reputils.h>
|
2018-07-31 16:01:13 +02:00
|
|
|
|
#include <vector>
|
2019-01-10 14:16:28 +01:00
|
|
|
|
#include <memory>
|
2019-01-30 13:08:34 +01:00
|
|
|
|
#include <map>
|
2018-07-25 15:53:29 +02:00
|
|
|
|
|
2018-07-06 16:30:37 +02:00
|
|
|
|
#define SQL_FLD "sql/"
|
2018-10-08 10:42:28 +02:00
|
|
|
|
#define CARATTERI_SPECIALI "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'\\"
|
2018-07-06 16:30:37 +02:00
|
|
|
|
|
2018-07-25 15:53:29 +02:00
|
|
|
|
// Ritorna la connessione al DB paf secondo i parametri impostati nel programma di configurazione
|
2018-10-08 11:45:08 +02:00
|
|
|
|
SSimple_query& fp_db();
|
2018-07-25 15:53:29 +02:00
|
|
|
|
// Controlla il livello di patch installato e aggiorna le tabelle se necessario
|
2018-07-06 16:30:37 +02:00
|
|
|
|
bool check_tables();
|
2019-01-17 14:14:09 +01:00
|
|
|
|
// Compila il numero di documento per la scrittura sui paf
|
|
|
|
|
TString& complete_num_fp(const TCodice_numerazione& codnum, const int numdoc);
|
2018-07-25 15:53:29 +02:00
|
|
|
|
// Genera la chiave per i paf
|
|
|
|
|
bool chiave_paf(const TDocumento& doc, TString& hfatt, TString& bfatt);
|
|
|
|
|
bool chiave_paf(const TRectype& doc, TString& hfatt, TString& bfatt);
|
2019-01-02 14:48:09 +01:00
|
|
|
|
// Ritorna cod sdi, pec o vuoto. Chiama get_coddest()
|
|
|
|
|
TString get_dest_sdi(const char tipocf, const long codcf);
|
|
|
|
|
// Valorizza codice sdi e pec in base alle configurazioni del monitor
|
2018-10-04 18:10:17 +02:00
|
|
|
|
bool get_coddest(const char tipocf, const long codcf, TString& coddest, TString& pec);
|
2018-10-08 10:42:28 +02:00
|
|
|
|
inline const TString& no_special(char a);
|
2018-12-04 10:28:27 +01:00
|
|
|
|
const TString& tipo_doc_sdi(const TDocumento& doc);
|
2018-07-25 15:53:29 +02:00
|
|
|
|
|
|
|
|
|
// Contenitore di campi di un record di database MSSQLServer
|
|
|
|
|
class TPaf_record : public TObject
|
|
|
|
|
{
|
2018-07-31 16:01:13 +02:00
|
|
|
|
TString8 _table;
|
|
|
|
|
TToken_string _key;
|
|
|
|
|
TAssoc_array _fields;
|
2018-07-25 15:53:29 +02:00
|
|
|
|
|
|
|
|
|
protected:
|
2018-07-31 16:01:13 +02:00
|
|
|
|
void copy(const TPaf_record& rec)
|
|
|
|
|
{
|
|
|
|
|
_table = rec._table;
|
|
|
|
|
_key = rec._key;
|
|
|
|
|
_fields = rec._fields;
|
|
|
|
|
}
|
2018-07-25 15:53:29 +02:00
|
|
|
|
|
2018-07-31 16:01:13 +02:00
|
|
|
|
const TString& var2str(const TString& fld, const TVariant& var) const;
|
|
|
|
|
const TVariant& get(const char* fld) const;
|
2018-07-25 15:53:29 +02:00
|
|
|
|
|
|
|
|
|
public:
|
2018-07-31 16:01:13 +02:00
|
|
|
|
void reset() { _fields.destroy(); }
|
|
|
|
|
void set(const char* fld, const TVariant& var);
|
|
|
|
|
void set(const char* fld, long var);
|
|
|
|
|
void set(const char* fld, const char* var);
|
|
|
|
|
void set(const char* fld, const real& var);
|
|
|
|
|
void set(const char* fld, const TString& var);
|
|
|
|
|
void set(const char* fld, const TDate& var);
|
|
|
|
|
void set(const char* fld, bool var);
|
|
|
|
|
const TString sq_get(const char* fld) const;
|
|
|
|
|
|
|
|
|
|
TString& insert_string();
|
|
|
|
|
bool insert();
|
2018-10-10 10:09:57 +02:00
|
|
|
|
TString& remove_string(bool id_riga = false);
|
2018-07-31 16:01:13 +02:00
|
|
|
|
bool remove();
|
|
|
|
|
bool search();
|
|
|
|
|
bool search(const char* k1, const char* k2, const char* k3 = NULL);
|
|
|
|
|
|
|
|
|
|
virtual TObject* dup() const { return new TPaf_record(*this); }
|
|
|
|
|
virtual bool ok() const { return _table.not_empty(); }
|
|
|
|
|
|
|
|
|
|
TPaf_record& operator=(const TPaf_record& rec)
|
|
|
|
|
{
|
|
|
|
|
copy(rec);
|
|
|
|
|
return *this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TPaf_record(const TPaf_record& rec) { copy(rec); }
|
|
|
|
|
TPaf_record(const char* table);
|
2018-07-25 15:53:29 +02:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Gestione PAF
|
2019-01-02 14:48:09 +01:00
|
|
|
|
class TDoc_fp : public TObject
|
2018-07-25 15:53:29 +02:00
|
|
|
|
{
|
|
|
|
|
private:
|
2018-12-10 14:23:41 +01:00
|
|
|
|
TRectype* _doc_rec;
|
2018-07-31 16:01:13 +02:00
|
|
|
|
TAnagrafica _ditta;
|
|
|
|
|
TString16 _cofi;
|
|
|
|
|
TFilename _dbname;
|
|
|
|
|
TLog_report* _log;
|
|
|
|
|
TString _logpaf;
|
|
|
|
|
bool _gestioneallegati;
|
|
|
|
|
bool _allegafattura;
|
|
|
|
|
TString _def_fld;
|
|
|
|
|
TString _def_usr_fld;
|
|
|
|
|
bool _to_commit;
|
|
|
|
|
bool _cache_insert;
|
|
|
|
|
vector<TString> _query;
|
2018-10-19 12:20:19 +02:00
|
|
|
|
TString8 _hfatt; // Codice univoco di 6 caratteri dell'ufficio P.A. o di 7 caratteri per un privato
|
2019-01-14 12:00:51 +01:00
|
|
|
|
TString _bfatt; // Codice univoco di 20 caratteri del documento
|
2019-01-02 16:06:29 +01:00
|
|
|
|
TString _conai_str;
|
|
|
|
|
|
2019-01-30 13:08:34 +01:00
|
|
|
|
// Classe interna per gestire gli omaggi
|
|
|
|
|
class TOmaggio_info
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
real imponibile;
|
|
|
|
|
real imposta;
|
|
|
|
|
TOmaggio_info() : imponibile(ZERO), imposta(ZERO){}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
std::map<TString, TOmaggio_info> _omaggi;
|
|
|
|
|
|
2018-12-11 14:21:01 +01:00
|
|
|
|
struct
|
|
|
|
|
{
|
2019-01-30 13:08:34 +01:00
|
|
|
|
bool _is_valuta_estera {false}; // Se il documento <20> in valuta estera
|
2018-12-11 14:21:01 +01:00
|
|
|
|
TString4 _cod_val;
|
|
|
|
|
real _cambio;
|
|
|
|
|
} _doc_cambio;
|
|
|
|
|
|
2018-07-25 15:53:29 +02:00
|
|
|
|
|
|
|
|
|
int parse_line(const TString& line, TString& var, TString& val) const;
|
|
|
|
|
bool create_table(TScanner& paf, const TString& table);
|
|
|
|
|
|
|
|
|
|
const TRectype* find_parent_row(const TRectype& rdoc) const;
|
|
|
|
|
int find_ancestors(const TRiga_documento& rdoc, TArray& ancestors) const;
|
2018-07-31 16:01:13 +02:00
|
|
|
|
bool insert(TPaf_record& p);
|
|
|
|
|
bool remove(TPaf_record& p);
|
|
|
|
|
bool save_paf();
|
2018-12-04 10:28:27 +01:00
|
|
|
|
|
2018-07-25 15:53:29 +02:00
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
bool parse_sconto(const TString& formula, TToken_string& sconti) const;
|
2018-11-28 16:28:33 +01:00
|
|
|
|
static bool get_bnp_iban(const TString& abi, const TString& cab, int prg, TString& iban);
|
2018-07-31 16:01:13 +02:00
|
|
|
|
bool get_bank(const TDocumento& doc, TString& iban, TString& abi, TString& cab, TString& istituto) const;
|
2019-01-25 14:47:19 +01:00
|
|
|
|
const TString& descrizione(const TRiga_documento& rdoc);
|
2018-07-25 15:53:29 +02:00
|
|
|
|
const TRectype& cco(const TRectype& doc) const; // Contratto/Convenzione/Offerta
|
|
|
|
|
|
|
|
|
|
void log(int severity, const char* msg);
|
|
|
|
|
const char* natura(const TString& codiva) const;
|
|
|
|
|
static void set_IVA(const TString& codiva, TPaf_record& paf);
|
|
|
|
|
static void set_IVA(const TRiga_documento& rdoc, TPaf_record& paf);
|
2018-12-14 12:10:42 +01:00
|
|
|
|
bool add_row_art(long& riga_art, const TString codice_tipo, const TString& codice_valore, TPaf_record& paf);
|
2018-07-31 16:01:13 +02:00
|
|
|
|
bool add_row_alleg(TFilename& file, long& nprogr, TPaf_record& paf);
|
2018-12-10 14:23:41 +01:00
|
|
|
|
const TString& converti_prezzo(const real& prezzo) const;
|
2019-01-02 14:48:09 +01:00
|
|
|
|
void set_qta_prezzo(TPaf_record& paf1800f, TRiga_documento* rdoc) const;
|
2018-10-04 18:10:17 +02:00
|
|
|
|
|
2018-07-25 15:53:29 +02:00
|
|
|
|
public:
|
|
|
|
|
bool doc_to_paf(TDocumentoEsteso& doc);
|
|
|
|
|
bool doc_to_paf(const TRectype& rec);
|
|
|
|
|
bool doc_to_paf(const TDoc_key& key);
|
|
|
|
|
bool doc_to_paf(const TFilename& ini);
|
2018-12-04 10:28:27 +01:00
|
|
|
|
bool doc_to_paf();
|
|
|
|
|
TRectype& key_to_doc(const TDoc_key& key);
|
2018-07-25 15:53:29 +02:00
|
|
|
|
// Mostra il log a fine esecuzione
|
|
|
|
|
bool show_log();
|
|
|
|
|
const int commit();
|
2019-01-25 14:47:19 +01:00
|
|
|
|
const int force_commit();
|
2018-07-31 16:01:13 +02:00
|
|
|
|
void set_cache_insert(const bool v) { _cache_insert = v; }
|
2018-12-04 10:28:27 +01:00
|
|
|
|
|
2018-07-25 15:53:29 +02:00
|
|
|
|
|
|
|
|
|
TDoc_fp();
|
|
|
|
|
~TDoc_fp();
|
|
|
|
|
};
|
|
|
|
|
|
2019-01-02 14:48:09 +01:00
|
|
|
|
class TFP_settings : public TObject
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
// Getters
|
|
|
|
|
const TString& get_db_indirizzo() const;
|
|
|
|
|
const TString& get_db_database() const;
|
|
|
|
|
const TString& get_db_str_con() const;
|
|
|
|
|
const TString& get_db_user() const;
|
|
|
|
|
const TString& get_db_password() const;
|
|
|
|
|
const TString& get_fld_dest() const;
|
|
|
|
|
const TString& get_fld_dest_usr() const;
|
|
|
|
|
const TString& get_cofi_tras() const;
|
|
|
|
|
const bool get_gest_alleg() const;
|
|
|
|
|
const bool get_allega_fat() const;
|
|
|
|
|
const bool get_esp_pri_empty() const;
|
|
|
|
|
const bool get_esp_est() const;
|
|
|
|
|
const TString& get_esp_est_cod() const;
|
2019-01-07 18:00:02 +01:00
|
|
|
|
const bool is_f8() const;
|
2019-01-02 14:48:09 +01:00
|
|
|
|
|
|
|
|
|
// Setters
|
|
|
|
|
void set_db_indirizzo(const TString& ind) const;
|
|
|
|
|
void set_db_database(const TString& db) const;
|
|
|
|
|
void set_db_user(const TString& usr) const;
|
|
|
|
|
void set_db_password(const TString& psw) const;
|
|
|
|
|
void set_fld_dest(const TString& fld_dest) const;
|
|
|
|
|
void set_fld_dest_usr(const TString& fld_dest_usr) const;
|
|
|
|
|
void set_cofi_tras(const TString& cofi) const;
|
|
|
|
|
void set_gest_alleg(bool gest_alleg) const;
|
|
|
|
|
void set_allega_fat(bool allega_fatt) const;
|
|
|
|
|
void set_esp_pri_empty(bool esp_pri) const;
|
|
|
|
|
void set_esp_est(bool esp_est) const;
|
|
|
|
|
void set_esp_est_cod(const TString& esp_est_cod) const;
|
2019-01-07 18:00:02 +01:00
|
|
|
|
void set_f8(bool f8) const;
|
2019-01-02 14:48:09 +01:00
|
|
|
|
};
|
2018-07-25 15:53:29 +02:00
|
|
|
|
|
2019-01-02 14:48:09 +01:00
|
|
|
|
inline TFP_settings& fp_settings()
|
|
|
|
|
{
|
|
|
|
|
static TFP_settings* erbuggo = nullptr;
|
|
|
|
|
if(erbuggo == nullptr)
|
|
|
|
|
{
|
|
|
|
|
erbuggo = new TFP_settings();
|
|
|
|
|
}
|
|
|
|
|
return *erbuggo;
|
|
|
|
|
}
|
2018-07-06 16:30:37 +02:00
|
|
|
|
|
2019-01-10 14:11:28 +01:00
|
|
|
|
class TFP_selected_docs : public TObject
|
|
|
|
|
{
|
|
|
|
|
TRelation _r_tabmod;
|
|
|
|
|
TRectype _flt;
|
|
|
|
|
std::unique_ptr<TCursor> _cur;
|
|
|
|
|
TRectype fill_rectype() const;
|
|
|
|
|
|
|
|
|
|
enum { _codnum, _tipodoc, _dastato, _astato, _tiposdi };
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
void fill_sheet(TSheet_field& sheet) const;
|
|
|
|
|
inline bool has_selected_docs() const { return _cur->items() > 0; }
|
|
|
|
|
void save_sheet(const TSheet_field& sheet) const;
|
|
|
|
|
|
|
|
|
|
TFP_selected_docs();
|
|
|
|
|
};
|
|
|
|
|
|
2019-01-02 14:48:09 +01:00
|
|
|
|
#endif // __FPLIB_H
|