Patch level : 12.0 nopatch

Files correlati     : f9

Commento:
Iniziata la modifica del modulo f9 per prendere da FPPRO il tipodocsdi
This commit is contained in:
Alessandro Bonazzi 2022-05-08 23:23:20 +02:00
parent d0e06a5d6f
commit 87409cc88b
3 changed files with 79 additions and 108 deletions

View File

@ -9,15 +9,14 @@
#include "../fe/felib.h" #include "../fe/felib.h"
#include <reprint.h> #include <reprint.h>
#include <reputils.h> #include <reputils.h>
#include <vector> //#include <vector>
#include <memory>
#include "../cg/cglib.h" #include "../cg/cglib.h"
#include <map> #include <map>
#define SQL_FLD "sql/" #define SQL_FLD "sql/"
#define MANCATA_SEND "S" // Se la mail di mancata consegna gi stata inviata P1_ERRINT segnato con "S" #define MANCATA_SEND "S" // Se la mail di mancata consegna gi stata inviata P1_ERRINT segnato con "S"
// Typedef per aiutare a capire cosa sono le chiavi // Typedef per aiutare a capire cosa sono le chiavi grande cazzata
typedef TString MCodice_riga; typedef TString MCodice_riga;
typedef TString MTipo_documento; typedef TString MTipo_documento;
class TDoc_fp; class TDoc_fp;
@ -349,28 +348,6 @@ inline bool operator==(const TFPBuono_di_consegna& l, const TFPBuono_di_consegna
* PERSONALIZZAZIONI FP * PERSONALIZZAZIONI FP
***********************************************************************************************************************************************************************/ ***********************************************************************************************************************************************************************/
struct TFP_row_art
{
TString _codice_tipo;
TString _codice_valore;
TFP_row_art(const TString& codice_tipo, const TString& codice_valore) : _codice_tipo(codice_tipo), _codice_valore(codice_valore) {}
};
struct TFP_adg
{
TString _tipo_dato;
TString _riferimento_testo;
int _riferimento_numero;
TDate _riferimento_data;
TFP_adg(const TString& tipo_dato, const TString& riferimento_testo, const int riferimento_numero,
const TDate& riferimento_data)
: _tipo_dato(tipo_dato),
_riferimento_testo(riferimento_testo),
_riferimento_numero(riferimento_numero),
_riferimento_data(riferimento_data) {}
};
/**< /**<
* Classe per la gestione di personalizzazioni FP * Classe per la gestione di personalizzazioni FP
*/ */
@ -379,8 +356,6 @@ class TFP_custom : public TMultiple_rectype
protected: protected:
TString _codcust; TString _codcust;
TString_array _causale; TString_array _causale;
vector<TFP_row_art> _articoli;
vector<TFP_adg> _altri_dati_gestionali;
bool _loaded; bool _loaded;
void init(); void init();
int write_rewrite(TBaseisamfile& f, bool re = FALSE) const override; int write_rewrite(TBaseisamfile& f, bool re = FALSE) const override;
@ -419,7 +394,7 @@ class TFP_custom_cache
{ {
std::map<TString, TFP_custom> _customs; std::map<TString, TFP_custom> _customs;
std::map<long, TString> _cli_custom; std::map<long, TString> _cli_custom;
std::unique_ptr<TFP_custom> _global_custom; TFP_custom * _global_custom;
public: public:
bool has_custom(const TDocumento& doc); bool has_custom(const TDocumento& doc);
@ -494,7 +469,7 @@ private:
TString _def_usr_fld; TString _def_usr_fld;
bool _to_commit; bool _to_commit;
bool _cache_insert; bool _cache_insert;
vector<TString> _query; TString_array _query;
TString8 _hfatt; // Codice univoco di 6 caratteri dell'ufficio P.A. o di 7 caratteri per un privato TString8 _hfatt; // Codice univoco di 6 caratteri dell'ufficio P.A. o di 7 caratteri per un privato
TString _bfatt; // Codice univoco di 20 caratteri del documento TString _bfatt; // Codice univoco di 20 caratteri del documento
TString _conai_str; TString _conai_str;
@ -640,7 +615,7 @@ private:
TString _def_usr_fld; TString _def_usr_fld;
bool _to_commit; bool _to_commit;
bool _cache_insert; bool _cache_insert;
vector<TString> _query; TString_array _query;
TString8 _hfatt; // Codice univoco di 6 caratteri dell'ufficio P.A. o di 7 caratteri per un privato TString8 _hfatt; // Codice univoco di 6 caratteri dell'ufficio P.A. o di 7 caratteri per un privato
TString _bfatt; // Codice univoco di 20 caratteri del Regumento TString _bfatt; // Codice univoco di 20 caratteri del Regumento
TString _paese; TString _paese;

View File

@ -71,12 +71,14 @@ bool run_fp_psw_mask()
} }
return false; return false;
} }
string getline(ifstream& f) string getline(ifstream& f)
{ {
string app; string app;
getline(f, app); getline(f, app);
return app; return app;
} }
bool check_tables() bool check_tables()
{ {
/* /*
@ -144,6 +146,7 @@ bool check_tables()
} }
return true; return true;
} }
TString& complete_num_fp(const TCodice_numerazione& codnum, const int numdoc) TString& complete_num_fp(const TCodice_numerazione& codnum, const int numdoc)
{ {
static const int len_num_doc = TRectype(LF_DOC).length(DOC_NDOC); static const int len_num_doc = TRectype(LF_DOC).length(DOC_NDOC);
@ -241,7 +244,6 @@ bool chiave_paf_mov(const TRectype& mov, const char* tipo_doc_sdi, TString& hfat
return hfatt.full() && bfatt.full(); return hfatt.full() && bfatt.full();
} }
bool chiave_paf_doc(const TDocumento& doc, TString& hfatt, TString& bfatt) bool chiave_paf_doc(const TDocumento& doc, TString& hfatt, TString& bfatt)
{ {
hfatt.cut(0); hfatt.cut(0);
@ -518,6 +520,7 @@ const TString& TPaf_record::var2str(const TString& fldname, const TVariant& var)
} }
return tmp; return tmp;
} }
TString& TPaf_record::remove_string(const bool id_riga) TString& TPaf_record::remove_string(const bool id_riga)
{ {
TString& query = get_tmp_string().cut(0); TString& query = get_tmp_string().cut(0);
@ -546,6 +549,7 @@ TString& TPaf_record::remove_string(const bool id_riga)
query.cut(0); // Crea una query sbagliata "WHERE AND": "DELETE FROM [table] WHERE AND [prefix]_KEYPRGINVIO != '';" query.cut(0); // Crea una query sbagliata "WHERE AND": "DELETE FROM [table] WHERE AND [prefix]_KEYPRGINVIO != '';"
return query; return query;
} }
// Elimina il record in base ai campi chiave // Elimina il record in base ai campi chiave
bool TPaf_record::remove() bool TPaf_record::remove()
{ {
@ -755,6 +759,7 @@ TPaf_record::TPaf_record(const char* table) : _table(table), _key(15, ',')
} }
CHECKS(!_key.empty_items(), "Invalid primary key for table ", table); CHECKS(!_key.empty_items(), "Invalid primary key for table ", table);
} }
//////////////////////////////////////////////////////// ////////////////////////////////////////////////////////
// TPaf_container // TPaf_container
//////////////////////////////////////////////////////// ////////////////////////////////////////////////////////
@ -768,6 +773,7 @@ bool TPaf_container::clean_and_erase_paf(const TString& hfatt, const TString& bf
} }
return ok; return ok;
} }
void TPaf_container::set_keys_paf(TPaf_record& paf, const TString& hfatt, const TString& bfatt, const bool reset) void TPaf_container::set_keys_paf(TPaf_record& paf, const TString& hfatt, const TString& bfatt, const bool reset)
{ {
if (reset) if (reset)
@ -776,6 +782,7 @@ void TPaf_container::set_keys_paf(TPaf_record& paf, const TString& hfatt, const
paf.set(TString(prefix) << "_KEYHEADERFATT", hfatt); paf.set(TString(prefix) << "_KEYHEADERFATT", hfatt);
paf.set(TString(prefix) << "_KEYBODYFATT", bfatt); paf.set(TString(prefix) << "_KEYBODYFATT", bfatt);
} }
const char* TPaf_container::paf_to_prefix(const char * paf) const char* TPaf_container::paf_to_prefix(const char * paf)
{ {
static TString paf_name; static TString paf_name;
@ -832,10 +839,12 @@ const char* TPaf_container::paf_to_prefix(const char * paf)
return "PW"; return "PW";
return "ERROR"; return "ERROR";
} }
TPaf_record& TPaf_container::get_paf(const char * paf) TPaf_record& TPaf_container::get_paf(const char * paf)
{ {
return _pafs[paf]; return _pafs[paf];
} }
TPaf_container::TPaf_container() TPaf_container::TPaf_container()
{ {
_pafs.insert(std::pair<const char *, TPaf_record>("PAF0100F", TPaf_record("PAF0100F"))); _pafs.insert(std::pair<const char *, TPaf_record>("PAF0100F", TPaf_record("PAF0100F")));
@ -886,15 +895,20 @@ TPaf_container::TPaf_container()
// Non invio XML // Non invio XML
_pafs.insert(std::pair<const char *, TPaf_record>("PAFW300F", TPaf_record("PAFW300F"))); _pafs.insert(std::pair<const char *, TPaf_record>("PAFW300F", TPaf_record("PAFW300F")));
} }
/*************************************************************************** /***************************************************************************
* TAncestor * TAncestor
***************************************************************************/ ***************************************************************************/
struct TAncestor : public TObject class TAncestor : public TObject
{ {
TString20 _numdoc; TString20 _numdoc;
TDate _datadoc; TDate _datadoc;
public:
const TString & numdoc() const { return _numdoc; }
const TDate & datadoc() const { return _datadoc; }
TAncestor(const TRectype& rdoc); TAncestor(const TRectype& rdoc);
}; };
TAncestor::TAncestor(const TRectype& rdoc) TAncestor::TAncestor(const TRectype& rdoc)
{ {
const int anno = rdoc.get_int(RDOC_ANNO); const int anno = rdoc.get_int(RDOC_ANNO);
@ -912,6 +926,7 @@ TAncestor::TAncestor(const TRectype& rdoc)
_numdoc.format("%d/%s/%s", anno, static_cast<const char*>(codnum), static_cast<const char*>(numdoc)); _numdoc.format("%d/%s/%s", anno, static_cast<const char*>(codnum), static_cast<const char*>(numdoc));
_datadoc = doc.get_date(DOC_DATADOC); _datadoc = doc.get_date(DOC_DATADOC);
} }
/*************************************************************************** /***************************************************************************
* TFPBuono_di_consegna * TFPBuono_di_consegna
***************************************************************************/ ***************************************************************************/
@ -960,6 +975,7 @@ bool TDoc_fp::parse_sconto(const TString& formula, TToken_string& sconti) const
} }
return sconti.full(); return sconti.full();
} }
bool TDoc_fp::get_bnp_iban(const TString& abi, const TString& cab, int nprog, TString& iban) bool TDoc_fp::get_bnp_iban(const TString& abi, const TString& cab, int nprog, TString& iban)
{ {
TTable bnp("BNP"); TTable bnp("BNP");
@ -979,6 +995,7 @@ bool TDoc_fp::get_bnp_iban(const TString& abi, const TString& cab, int nprog, TS
iban = bnp.get("S3"); iban = bnp.get("S3");
return err == NOERR; return err == NOERR;
} }
bool TDoc_fp::get_bank(TDocumento& doc, TString& iban, TString& abi, TString& cab, TString& istituto) const bool TDoc_fp::get_bank(TDocumento& doc, TString& iban, TString& abi, TString& cab, TString& istituto) const
{ {
bool found = false; bool found = false;
@ -992,6 +1009,7 @@ bool TDoc_fp::get_bank(TDocumento& doc, TString& iban, TString& abi, TString& ca
} }
return found; return found;
} }
bool TDoc_fp::get_bank_presentazione(const TDocumento& doc, TString& iban, TString& abi, TString& cab, TString& istituto) const bool TDoc_fp::get_bank_presentazione(const TDocumento& doc, TString& iban, TString& abi, TString& cab, TString& istituto) const
{ {
bool found = false; bool found = false;
@ -1032,6 +1050,7 @@ bool TDoc_fp::get_bank_presentazione(const TDocumento& doc, TString& iban, TStri
istituto = cache().get("%BAN", abi, "S0"); istituto = cache().get("%BAN", abi, "S0");
return found; return found;
} }
bool TDoc_fp::get_bank_appoggio(const TDocumento& doc, TString& iban, TString& abi, TString& cab, bool TDoc_fp::get_bank_appoggio(const TDocumento& doc, TString& iban, TString& abi, TString& cab,
TString& istituto) const TString& istituto) const
{ {
@ -1061,6 +1080,7 @@ bool TDoc_fp::get_bank_appoggio(const TDocumento& doc, TString& iban, TString& a
} }
return found; return found;
} }
const TString& TDoc_fp::descrizione(const TRiga_documento& rdoc) const TString& TDoc_fp::descrizione(const TRiga_documento& rdoc)
{ {
if (rdoc.get_bool(RDOC_DESCLUNGA)) if (rdoc.get_bool(RDOC_DESCLUNGA))
@ -1080,6 +1100,7 @@ const TString& TDoc_fp::descrizione(const TRiga_documento& rdoc)
} }
return rdoc.get(RDOC_DESCR); return rdoc.get(RDOC_DESCR);
} }
const TRectype* TDoc_fp::find_parent_row(const TRectype& rdoc) const const TRectype* TDoc_fp::find_parent_row(const TRectype& rdoc) const
{ {
const long id = rdoc.get_long(RDOC_DAIDRIGA); const long id = rdoc.get_long(RDOC_DAIDRIGA);
@ -1108,6 +1129,7 @@ const TRectype* TDoc_fp::find_parent_row(const TRectype& rdoc) const
} }
return NULL; return NULL;
} }
int TDoc_fp::find_ancestors(const TRiga_documento& rdoc, TArray& ancestors) const int TDoc_fp::find_ancestors(const TRiga_documento& rdoc, TArray& ancestors) const
{ {
if (rdoc.is_articolo()) if (rdoc.is_articolo())
@ -1122,14 +1144,13 @@ int TDoc_fp::find_ancestors(const TRiga_documento& rdoc, TArray& ancestors) cons
} }
return ancestors.items(); return ancestors.items();
} }
bool TDoc_fp::insert(TPaf_record& p) bool TDoc_fp::insert(TPaf_record& p)
{ {
bool ok; bool ok = true;
if (_cache_insert) if (_cache_insert)
{ _query.add(p.insert_string());
_query.push_back(p.insert_string());
ok = true;
}
else else
{ {
ok = p.insert(); ok = p.insert();
@ -1141,14 +1162,13 @@ bool TDoc_fp::insert(TPaf_record& p)
} }
return ok; return ok;
} }
bool TDoc_fp::remove(TPaf_record& p) bool TDoc_fp::remove(TPaf_record& p)
{ {
bool ok; bool ok = true;
if (_cache_insert) if (_cache_insert)
{ _query.add(p.remove_string());
_query.push_back(p.remove_string());
ok = true;
}
else else
{ {
ok = p.remove(); ok = p.remove();
@ -1160,23 +1180,26 @@ bool TDoc_fp::remove(TPaf_record& p)
} }
return ok; return ok;
} }
bool TDoc_fp::save_paf() bool TDoc_fp::save_paf()
{ {
bool ok = true; bool ok = true;
if (_cache_insert) if (_cache_insert)
{ {
string query; TString query;
for (auto i = _query.begin(); i != _query.end(); ++i)
query += *i; FOR_EACH_ARRAY_ROW(_query, r, row)
query << *row;
ok = fp_db().sq_set_exec(query); ok = fp_db().sq_set_exec(query);
if (!ok) if (!ok)
{ {
_log.log(2, fp_db().sq_get_token_text_error(1)); _log.log(2, fp_db().sq_get_token_text_error(1));
_log.log(2, query.c_str()); _log.log(2, query);
} }
} }
return ok; return ok;
} }
bool TDoc_fp::check_initial(TDocumentoEsteso& doc) bool TDoc_fp::check_initial(TDocumentoEsteso& doc)
{ {
bool ok = true; bool ok = true;
@ -1218,6 +1241,7 @@ bool TDoc_fp::check_initial(TDocumentoEsteso& doc)
} }
return ok; return ok;
} }
bool TDoc_fp::check_row(const TRiga_documento& rdoc) bool TDoc_fp::check_row(const TRiga_documento& rdoc)
{ {
bool ok = false; bool ok = false;
@ -1240,6 +1264,7 @@ bool TDoc_fp::check_row(const TRiga_documento& rdoc)
} }
return ok; return ok;
} }
bool TDoc_fp::check_riepilogo(const TDocumentoEsteso& doc, const TRiepilogo_iva& riva) bool TDoc_fp::check_riepilogo(const TDocumentoEsteso& doc, const TRiepilogo_iva& riva)
{ {
bool ok = true; bool ok = true;
@ -1252,6 +1277,7 @@ bool TDoc_fp::check_riepilogo(const TDocumentoEsteso& doc, const TRiepilogo_iva&
} }
return ok; return ok;
} }
bool TDoc_fp::initialize(TDocumentoEsteso& doc) bool TDoc_fp::initialize(TDocumentoEsteso& doc)
{ {
// Azzero // Azzero
@ -1304,6 +1330,7 @@ bool TDoc_fp::initialize(TDocumentoEsteso& doc)
} }
return false; return false;
} }
const TRectype& TDoc_fp::cco(const TRectype& doc) const const TRectype& TDoc_fp::cco(const TRectype& doc) const
{ {
TString80 conkey; TString80 conkey;
@ -1330,7 +1357,8 @@ const TRectype& TDoc_fp::cco(const TRectype& doc) const
return tabmod.curr(); return tabmod.curr();
} }
const char* TDoc_fp::stato_paf() { const char* TDoc_fp::stato_paf()
{
if (get_no_export_pronto()) if (get_no_export_pronto())
{ {
_diagn = true; _diagn = true;
@ -1377,49 +1405,10 @@ int TDoc_fp::commit()
{ {
r = -1; r = -1;
_log.log(2, fp_db().sq_get_token_text_error(1)); _log.log(2, fp_db().sq_get_token_text_error(1));
//_log.log(2, "UPDATE PAF0100F SET P1_GESTIONE = 'P' WHERE P1_GESTIONE = 'D'");
} }
} }
_to_commit = false; _to_commit = false;
return r; return r;
/*
int r = 0;
if (_to_commit)
{
// Controllo stato diagnosticato
if (!get_no_export_pronto())
{
if (fp_db().sq_set_exec("UPDATE PAF0100F SET P1_GESTIONE = 'P' WHERE P1_GESTIONE = 'D'AND "))
{
r += 1;
_log.log(2, "Le fatture sono state esportate correttamente in stato pronto");
}
else
{
r = -1;
_log.log(2, fp_db().sq_get_token_text_error(1));
}
}
else
{
_log.log(2, "Le fatture sono state esportate in stato diagnosticato");
}
if (r >= 0 && fp_db().sq_commit())
{
r += 2;
}
else
{
r = -1;
_log.log(2, fp_db().sq_get_token_text_error(1));
_log.log(2, "UPDATE PAF0100F SET P1_GESTIONE = 'P' WHERE P1_GESTIONE = 'D'");
}
}
_to_commit = false;
return r;
*/
} }
int TDoc_fp::force_commit() int TDoc_fp::force_commit()
@ -1438,6 +1427,7 @@ const TString & TDoc_fp::natura(const char* codiva) const
natura = natura.sleft(2); natura = natura.sleft(2);
return natura; return natura;
} }
const char* TDoc_fp::get_esigibilita_iva(const TDocumentoEsteso& doc) const char* TDoc_fp::get_esigibilita_iva(const TDocumentoEsteso& doc)
{ {
// Esigibilit IVA: Immediata, Differita, Split payment // Esigibilit IVA: Immediata, Differita, Split payment
@ -1448,6 +1438,7 @@ const char* TDoc_fp::get_esigibilita_iva(const TDocumentoEsteso& doc)
eiva = "D"; eiva = "D";
return eiva; return eiva;
} }
void TDoc_fp::set_IVA(TString codiva, TPaf_record& paf) const void TDoc_fp::set_IVA(TString codiva, TPaf_record& paf) const
{ {
if (codiva.empty()) if (codiva.empty())
@ -1456,10 +1447,12 @@ void TDoc_fp::set_IVA(TString codiva, TPaf_record& paf) const
paf.set("PI_ALIQUOTAIVA", static_cast<real>(cache().get("%IVA", codiva, "R0"))); paf.set("PI_ALIQUOTAIVA", static_cast<real>(cache().get("%IVA", codiva, "R0")));
paf.set("PI_NATURA", natura(codiva)); paf.set("PI_NATURA", natura(codiva));
} }
void TDoc_fp::set_IVA(const TRiga_documento& rdoc, TPaf_record& paf) const void TDoc_fp::set_IVA(const TRiga_documento& rdoc, TPaf_record& paf) const
{ {
set_IVA(rdoc.get(RDOC_CODIVA), paf); set_IVA(rdoc.get(RDOC_CODIVA), paf);
} }
bool TDoc_fp::add_row_art(long& riga_art, const TString& codice_tipo, const TString& codice_valore, TPaf_record& paf) bool TDoc_fp::add_row_art(long& riga_art, const TString& codice_tipo, const TString& codice_valore, TPaf_record& paf)
{ {
paf.set("PY_KEYNLINAR", ++riga_art); paf.set("PY_KEYNLINAR", ++riga_art);
@ -1467,6 +1460,7 @@ bool TDoc_fp::add_row_art(long& riga_art, const TString& codice_tipo, const TStr
paf.set("PY_VALOREARTICOLO", codice_valore); paf.set("PY_VALOREARTICOLO", codice_valore);
return insert(paf); return insert(paf);
} }
bool TDoc_fp::add_row_alleg(TFilename& file, long& nprogr, TPaf_record& paf) bool TDoc_fp::add_row_alleg(TFilename& file, long& nprogr, TPaf_record& paf)
{ {
static TString dest_path; static TString dest_path;
@ -1489,6 +1483,7 @@ bool TDoc_fp::add_row_alleg(TFilename& file, long& nprogr, TPaf_record& paf)
return ok; return ok;
} }
const TString& TDoc_fp::converti_prezzo(const real& prezzo) const const TString& TDoc_fp::converti_prezzo(const real& prezzo) const
{ {
TString& ret = get_tmp_string(); TString& ret = get_tmp_string();
@ -1505,6 +1500,7 @@ const TString& TDoc_fp::converti_prezzo(const real& prezzo) const
ret << prezzo; ret << prezzo;
return ret; return ret;
} }
void TDoc_fp::set_qta_prezzo(TPaf_record& paf1800f, TFPRiga_documento* rdoc) const void TDoc_fp::set_qta_prezzo(TPaf_record& paf1800f, TFPRiga_documento* rdoc) const
{ {
// Setto l'unit di misura // Setto l'unit di misura
@ -1549,6 +1545,7 @@ const real calc_ritenuta(const TDocumento& doc)
} }
return imponibile; return imponibile;
} }
void TDoc_fp::add_ritenuta(const TRiga_documento & rdoc, TPaf_record& paf0700f) const void TDoc_fp::add_ritenuta(const TRiga_documento & rdoc, TPaf_record& paf0700f) const
{ {
// <DatiRitenuta> // <DatiRitenuta>
@ -1571,6 +1568,7 @@ void TDoc_fp::add_ritenuta(const TRiga_documento & rdoc, TPaf_record& paf0700f)
paf0700f.set("P7_CAUSPAGAM", caus_la); paf0700f.set("P7_CAUSPAGAM", caus_la);
// </DatiRitenuta> // </DatiRitenuta>
} }
bool TDoc_fp::add_riepilogo_iva(TPaf_record& paf2200f, const TCodiceIVA& cod_iva, const char* eiva, const real& imponibile, const real& imposta) bool TDoc_fp::add_riepilogo_iva(TPaf_record& paf2200f, const TCodiceIVA& cod_iva, const char* eiva, const real& imponibile, const real& imposta)
{ {
reset(paf2200f); reset(paf2200f);
@ -1710,10 +1708,12 @@ bool TDoc_fp::export_info_articolo(TFPRiga_documento* rdoc, TPaf_record& paf1900
} }
return ok; return ok;
} }
const TFirm& TDoc_fp::get_firm() const TFirm& TDoc_fp::get_firm()
{ {
return prefix().firm(); return prefix().firm();
} }
bool TDoc_fp::export_paf0100f() bool TDoc_fp::export_paf0100f()
{ {
// <DatiTrassmissione> // <DatiTrassmissione>
@ -1733,6 +1733,7 @@ bool TDoc_fp::export_paf0100f()
// </DatiTrassmissione> // </DatiTrassmissione>
return insert(paf0100f); return insert(paf0100f);
} }
bool TDoc_fp::export_paf3200f() bool TDoc_fp::export_paf3200f()
{ {
if (_enapec) if (_enapec)
@ -2240,15 +2241,15 @@ bool TDoc_fp::doc_to_paf(TDocumentoEsteso& doc)
_has_bolla |= true; _has_bolla |= true;
const TAncestor& a = dynamic_cast<const TAncestor&>(ancestors[i]); const TAncestor& a = dynamic_cast<const TAncestor&>(ancestors[i]);
ancestors_s.insert({ a._numdoc, a._datadoc }); // Per i buoni di consegna lavanderie ancestors_s.insert({ a.numdoc(), a.datadoc() }); // Per i buoni di consegna lavanderie
if (i == 1) if (i == 1)
{ {
// <DatiDDT> // <DatiDDT>
reset(paf1600f); reset(paf1600f);
ddt_linee.set(r); ddt_linee.set(r);
paf1600f.set("PF_RIFNUMLINEA", static_cast<long>(r)); paf1600f.set("PF_RIFNUMLINEA", static_cast<long>(r));
paf1600f.set("PF_NUMDDDT", a._numdoc); paf1600f.set("PF_NUMDDDT", a.numdoc());
paf1600f.set("PF_DATADDT", a._datadoc); paf1600f.set("PF_DATADDT", a.datadoc());
paf1600f.set("PF_GESTIONE", stato_paf()); paf1600f.set("PF_GESTIONE", stato_paf());
ok &= insert(paf1600f); ok &= insert(paf1600f);
// </DatiDDT> // </DatiDDT>
@ -2259,8 +2260,8 @@ bool TDoc_fp::doc_to_paf(TDocumentoEsteso& doc)
paf1000f.set("P0_KEYHEADERFATT", _hfatt); paf1000f.set("P0_KEYHEADERFATT", _hfatt);
paf1000f.set("P0_KEYBODYFATT", _bfatt); paf1000f.set("P0_KEYBODYFATT", _bfatt);
paf1000f.set("P0_RIFNUMLINEA", static_cast<long>(r)); paf1000f.set("P0_RIFNUMLINEA", static_cast<long>(r));
paf1000f.set("P0_IDDOC", a._numdoc); paf1000f.set("P0_IDDOC", a.numdoc());
paf1000f.set("P0_DATADOC", a._datadoc); paf1000f.set("P0_DATADOC", a.datadoc());
paf1000f.set("P0_COMMESSACONV", com); paf1000f.set("P0_COMMESSACONV", com);
paf1000f.set("P0_CODCUP", cup); paf1000f.set("P0_CODCUP", cup);
paf1000f.set("P0_CODCIG", cig); paf1000f.set("P0_CODCIG", cig);
@ -2940,13 +2941,10 @@ TDoc_fp::~TDoc_fp()
bool TReg_fp::insert(TPaf_record& p) bool TReg_fp::insert(TPaf_record& p)
{ {
bool ok; bool ok = true;
if (_cache_insert) if (_cache_insert)
{ _query.add(p.insert_string());
_query.push_back(p.insert_string());
ok = true;
}
else else
{ {
ok = p.insert(); ok = p.insert();
@ -2961,13 +2959,10 @@ bool TReg_fp::insert(TPaf_record& p)
bool TReg_fp::remove(TPaf_record& p) bool TReg_fp::remove(TPaf_record& p)
{ {
bool ok; bool ok = true;
if (_cache_insert) if (_cache_insert)
{ _query.add(p.remove_string());
_query.push_back(p.remove_string());
ok = true;
}
else else
{ {
ok = p.remove(); ok = p.remove();
@ -2986,14 +2981,15 @@ bool TReg_fp::save_paf()
if (_cache_insert) if (_cache_insert)
{ {
string query; TString query;
for (auto i = _query.begin(); i != _query.end(); ++i)
query += *i; FOR_EACH_ARRAY_ROW(_query, r, row)
query << *row;
ok = fp_db().sq_set_exec(query); ok = fp_db().sq_set_exec(query);
if (!ok) if (!ok)
{ {
_log.log(2, fp_db().sq_get_token_text_error(1)); _log.log(2, fp_db().sq_get_token_text_error(1));
_log.log(2, query.c_str()); _log.log(2, query);
} }
} }
return ok; return ok;

View File

@ -237,7 +237,7 @@ TFP_custom& TFP_custom_cache::get_custom(const TDocumento& doc)
return _customs[codcust]; return _customs[codcust];
} }
TFP_custom_cache::TFP_custom_cache() TFP_custom_cache::TFP_custom_cache() : _global_custom(nullptr)
{ {
_customs.clear(); _customs.clear();
_cli_custom.clear(); _cli_custom.clear();
@ -247,9 +247,9 @@ TFP_custom_cache::TFP_custom_cache()
for(int ok = local_cust.first(); ok == NOERR; ok = local_cust.next()) for(int ok = local_cust.first(); ok == NOERR; ok = local_cust.next())
{ {
if(local_cust.get_bool(FPCUST_GLOBAL)) if (local_cust.get_bool(FPCUST_GLOBAL))
{ {
_global_custom.reset(new TFP_custom(local_cust.curr())); _global_custom = new TFP_custom(local_cust.curr());
break; break;
} }
} }