2018-07-06 16:30:37 +02:00
|
|
|
|
#ifndef __FPLIB01_H
|
|
|
|
|
#define __FPLIB01_H
|
|
|
|
|
|
|
|
|
|
#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>
|
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();
|
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);
|
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
|
|
|
|
|
class TDoc_fp
|
|
|
|
|
{
|
|
|
|
|
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
|
|
|
|
|
TString20 _bfatt; // Codice univoco di 20 caratteri del documento
|
2018-12-11 14:21:01 +01:00
|
|
|
|
struct
|
|
|
|
|
{
|
|
|
|
|
bool _is_valuta_estera; // Se il documento <20> in valuta estera
|
|
|
|
|
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;
|
2018-10-08 10:42:28 +02:00
|
|
|
|
const TString& descrizione(const TRiga_documento& rdoc) const;
|
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;
|
2018-12-18 10:56:26 +01:00
|
|
|
|
void set_qta_prezzo(TPaf_record& paf1800f, TRiga_documento* rdoc);
|
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();
|
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();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2018-07-06 16:30:37 +02:00
|
|
|
|
|
|
|
|
|
#endif // __FPLIB01_H
|