Patch level : 12.0 834
Files correlati : fp Commento : - Prima release (da testare) personalizzazioni fatture elettroniche - Modificata esportazione fatture per supportare le personalizzazioni - Aggiornamento DB
This commit is contained in:
parent
44d9f038a4
commit
7b8adafb9a
@ -12,7 +12,7 @@ int main(int argc, char** argv)
|
||||
case 2: rt = fp0300(argc, argv); break; // Gestione fatture attive (PAA, Ex Fattura PA)
|
||||
case 3: rt = fp0400(argc, argv); break; // Monitor fatture passive
|
||||
case 4: rt = fp0500(argc, argv); break; // Customizzazioni FP per utente
|
||||
case 5: rt = fp0600(argc, argv); break; // Customizzazioni FP per utente
|
||||
case 5: rt = fp0600(argc, argv); break; // Da fare
|
||||
default: rt = fp0100(argc, argv); break; // Configurazione
|
||||
}
|
||||
return rt;
|
||||
|
@ -171,6 +171,6 @@ bool TFpcust::user_destroy()
|
||||
int fp0500(int argc, char* argv[])
|
||||
{
|
||||
TFpcust a;
|
||||
a.run(argc, argv, TR("Lettere d'intento"));
|
||||
a.run(argc, argv, TR("Personalizzazioni FP"));
|
||||
return 0;
|
||||
}
|
@ -14,6 +14,7 @@ BEGIN
|
||||
INPUT CODICE F_CODICE
|
||||
DISPLAY "Codice" CODICE
|
||||
DISPLAY "Descrizione@50" DESCR
|
||||
DISPLAY "Globale@7" GLOBAL
|
||||
OUTPUT F_CODICE CODICE
|
||||
OUTPUT F_DESCR DESCR
|
||||
CHECKTYPE REQUIRED
|
||||
@ -39,7 +40,7 @@ BEGIN
|
||||
FIELD GLOBAL
|
||||
END
|
||||
|
||||
SPREADSHEET F_CAUSALI 60 6
|
||||
SPREADSHEET F_CAUSALI 0 6
|
||||
BEGIN
|
||||
PROMPT 1 3 "Causale"
|
||||
ITEM "Valore@50"
|
||||
|
386
src/fp/fplib.h
386
src/fp/fplib.h
@ -12,69 +12,15 @@
|
||||
#include <memory>
|
||||
#include <map>
|
||||
#include <cg2103.h>
|
||||
#include <map>
|
||||
|
||||
#define SQL_FLD "sql/"
|
||||
#define MANCATA_SEND "S" // Se la mail di mancata consegna è già stata inviata P1_ERRINT è segnato con "S"
|
||||
|
||||
class TFPRiga_documento;
|
||||
|
||||
// Typedef per aiutare a capire cosa sono le chiavi
|
||||
typedef TString MCodice_riga;
|
||||
typedef TString MTipo_documento;
|
||||
|
||||
// Mannaggia il fruttivendolo
|
||||
class TFP_righe_custom : public TObject
|
||||
{
|
||||
bool _loaded;
|
||||
|
||||
struct TCustCol
|
||||
{
|
||||
TString _col_qta;
|
||||
// Le colonne prezzo e imp non sono lette se di default
|
||||
TString _col_prezzo;
|
||||
TString _col_imponibile;
|
||||
TString _col_nota_piede;
|
||||
};
|
||||
|
||||
// Mappa con in chiave COD_RIGA, TIPO_DOC
|
||||
std::map<MCodice_riga, std::map<MTipo_documento, TCustCol>> _custom_table;
|
||||
|
||||
void load_map();
|
||||
static TCustCol& get_no_custom();
|
||||
TCustCol& get(const TString& codriga, const TString& tipodoc);
|
||||
|
||||
public:
|
||||
|
||||
static void save_sheet(TSheet_field& sheet_field);
|
||||
static void load_sheet(TSheet_field& sheet_field);
|
||||
|
||||
const TString& get_qta(const TString& codriga, const TString& tipodoc) { return get(codriga, tipodoc)._col_qta; }
|
||||
const TString& get_prezzo(const TString& codriga, const TString& tipodoc) { return get(codriga, tipodoc)._col_prezzo; }
|
||||
const TString& get_imponibile(const TString& codriga, const TString& tipodoc) { return get(codriga, tipodoc)._col_imponibile; }
|
||||
|
||||
TFP_righe_custom();
|
||||
};
|
||||
|
||||
class TFP_nota_piede_f
|
||||
{
|
||||
std::map<TString, TString> _nota_piede_fattura;
|
||||
bool _loaded;
|
||||
TToken_string _tipi_doc; // Array di stringhe dei tipi doc caricati (per capire se ne elimino)
|
||||
const TString _null_string;
|
||||
static void write_ini_npf(const TString& tipodoc, TToken_string& msg); // Salva sul file ini la n.p.f. di quel tipodoc
|
||||
static void delete_ini_npf(const TString& tipodoc); // Rimuove i tipidoc in eccesso (quando si modifica lo spreadsheet)
|
||||
static TString get_ini_npf(const TString& tipodoc); // Legge dal file ini e restituisce la n.p.f. di quel tipodoc
|
||||
void get_load(); // Carica la mappa
|
||||
void save_npf_spredsheet(TSheet_field& sheet_field);
|
||||
void save_new_tipidoc(TSheet_field& sheet_field);
|
||||
|
||||
public:
|
||||
void load_sheet(TSheet_field& sheet_field);
|
||||
void save_sheet(TSheet_field& sheet_field);
|
||||
const TString& get_nota_piede(const TString& tipo_doc);
|
||||
|
||||
TFP_nota_piede_f();
|
||||
};
|
||||
class TDoc_fp;
|
||||
|
||||
enum { no_pdf = -1, pdf_ok = 0, no_alleg = -2};
|
||||
|
||||
@ -163,130 +109,25 @@ public:
|
||||
TPaf_container();
|
||||
};
|
||||
|
||||
// Gestione PAF
|
||||
class TDoc_fp : public TObject
|
||||
class TFP_nota_piede_f
|
||||
{
|
||||
private:
|
||||
TRectype* _doc_rec;
|
||||
TRectype _rec_clifo;
|
||||
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;
|
||||
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 _conai_str;
|
||||
TString _paese;
|
||||
bool _enapec;
|
||||
bool _privato;
|
||||
TString _coddest;
|
||||
TString _pec;
|
||||
TCausale _caus;
|
||||
bool _is_pa;
|
||||
bool _has_bolla;
|
||||
TString _codivadefault;
|
||||
long _idx_cassa_previdenziale;
|
||||
long _idx_adg_doc_row; // Indice per la tabella altri dati gestionali della riga
|
||||
int _num_linea;
|
||||
int _counter;
|
||||
TPaf_container _paf_container;
|
||||
int _count_r_conai;
|
||||
bool _nascondi_sconti_righe_fatt;
|
||||
TFP_nota_piede_f _riga_npf;
|
||||
|
||||
// Classe interna per gestire righe aggiuntive in riepilogo
|
||||
class TRiepilogo_agg
|
||||
{
|
||||
public:
|
||||
real imponibile;
|
||||
real imposta;
|
||||
TRiepilogo_agg() : imponibile(ZERO), imposta(ZERO){}
|
||||
};
|
||||
|
||||
std::map<TString, TRiepilogo_agg> _riepilogo_agg;
|
||||
|
||||
struct
|
||||
{
|
||||
bool _is_valuta_estera {false}; // Se il documento è in valuta estera
|
||||
TString4 _cod_val;
|
||||
real _cambio;
|
||||
} _doc_cambio;
|
||||
|
||||
//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;
|
||||
bool insert(TPaf_record& p);
|
||||
bool remove(TPaf_record& p);
|
||||
void reset(TPaf_record& p) const { TPaf_container::set_keys_paf(p, _hfatt, _bfatt); }
|
||||
bool save_paf();
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
/**< Funzioni di controllo */
|
||||
/**< Controlli di testata, non è const per il calcolo della codizione di pagamento */
|
||||
bool check_initial(TDocumentoEsteso& doc);
|
||||
/**< Controllo di riga */
|
||||
bool check_row(const TRiga_documento& rdoc);
|
||||
/**< Controllo riepilogo IVA */
|
||||
bool check_riepilogo(const TDocumentoEsteso& doc, const TRiepilogo_iva& riva);
|
||||
|
||||
|
||||
bool initialize(TDocumentoEsteso& doc);
|
||||
bool parse_sconto(const TString& formula, TToken_string& sconti) const;
|
||||
static bool get_bnp_iban(const TString& abi, const TString& cab, int prg, TString& iban);
|
||||
bool get_bank(TDocumento& doc, TString& iban, TString& abi, TString& cab, TString& istituto) const;
|
||||
bool get_bank_presentazione(const TDocumento& doc, TString& iban, TString& abi, TString& cab, TString& istituto) const;
|
||||
bool get_bank_appoggio(const TDocumento& doc, TString& iban, TString& abi, TString& cab, TString& istituto) const;
|
||||
const TString& descrizione(const TRiga_documento& rdoc);
|
||||
const TRectype& cco(const TRectype& doc) const; // Contratto/Convenzione/Offerta
|
||||
|
||||
void log(int severity, const char* msg);
|
||||
static const char* natura(const TString& codiva);
|
||||
static const char* get_esigibilita_iva(const TDocumentoEsteso& doc);
|
||||
void set_IVA(TString codiva, TPaf_record& paf) const;
|
||||
void set_IVA(const TRiga_documento& rdoc, TPaf_record& paf) const;
|
||||
bool add_row_art(long& riga_art, const TString& codice_tipo, const TString& codice_valore, TPaf_record& paf);
|
||||
bool add_row_alleg(TFilename& file, long& nprogr, TPaf_record& paf);
|
||||
const TString& converti_prezzo(const real& prezzo) const;
|
||||
void set_qta_prezzo(TPaf_record& paf1800f, TFPRiga_documento* rdoc) const;
|
||||
void add_ritenuta(const TDocumentoEsteso& doc, const TSpesa_prest& sp, TPaf_record& paf0700f) const;
|
||||
bool add_riepilogo_iva(TPaf_record& paf2200f, const TCodiceIVA& cod_iva, const char* eiva, const real& imponibile = ZERO, const real& imposta = ZERO);
|
||||
bool add_cassa_previdenziale(TRiga_documento& rdoc);
|
||||
|
||||
const TFirm& get_firm();
|
||||
|
||||
bool export_paf0100f();
|
||||
bool export_paf3200f();
|
||||
|
||||
// Record clifo
|
||||
//void set_rec_clifo(char tipocf, long codcf);
|
||||
std::map<TString, TString> _nota_piede_fattura;
|
||||
bool _loaded;
|
||||
TToken_string _tipi_doc; // Array di stringhe dei tipi doc caricati (per capire se ne elimino)
|
||||
const TString _null_string;
|
||||
static void write_ini_npf(const TString& tipodoc, TToken_string& msg); // Salva sul file ini la n.p.f. di quel tipodoc
|
||||
static void delete_ini_npf(const TString& tipodoc); // Rimuove i tipidoc in eccesso (quando si modifica lo spreadsheet)
|
||||
static TString get_ini_npf(const TString& tipodoc); // Legge dal file ini e restituisce la n.p.f. di quel tipodoc
|
||||
void get_load(); // Carica la mappa
|
||||
void save_npf_spredsheet(TSheet_field& sheet_field);
|
||||
void save_new_tipidoc(TSheet_field& sheet_field);
|
||||
|
||||
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);
|
||||
bool doc_to_paf();
|
||||
TRectype& key_to_doc(const TDoc_key& key);
|
||||
// Mostra il log a fine esecuzione
|
||||
bool show_log();
|
||||
int commit();
|
||||
int force_commit();
|
||||
void set_cache_insert(const bool v) { _cache_insert = v; }
|
||||
void load_sheet(TSheet_field& sheet_field);
|
||||
void save_sheet(TSheet_field& sheet_field);
|
||||
const TString& get_nota_piede(const TString& tipo_doc);
|
||||
|
||||
TDoc_fp();
|
||||
~TDoc_fp();
|
||||
TFP_nota_piede_f();
|
||||
};
|
||||
|
||||
class TFP_settings : public TObject
|
||||
@ -354,6 +195,39 @@ inline TFP_settings& fp_settings()
|
||||
return *erbuggo;
|
||||
}
|
||||
|
||||
// Mannaggia il fruttivendolo
|
||||
class TFP_righe_custom : public TObject
|
||||
{
|
||||
bool _loaded;
|
||||
|
||||
struct TCustCol
|
||||
{
|
||||
TString _col_qta;
|
||||
// Le colonne prezzo e imp non sono lette se di default
|
||||
TString _col_prezzo;
|
||||
TString _col_imponibile;
|
||||
TString _col_nota_piede;
|
||||
};
|
||||
|
||||
// Mappa con in chiave COD_RIGA, TIPO_DOC
|
||||
std::map<MCodice_riga, std::map<MTipo_documento, TCustCol>> _custom_table;
|
||||
|
||||
void load_map();
|
||||
static TCustCol& get_no_custom();
|
||||
TCustCol& get(const TString& codriga, const TString& tipodoc);
|
||||
|
||||
public:
|
||||
|
||||
static void save_sheet(TSheet_field& sheet_field);
|
||||
static void load_sheet(TSheet_field& sheet_field);
|
||||
|
||||
const TString& get_qta(const TString& codriga, const TString& tipodoc) { return get(codriga, tipodoc)._col_qta; }
|
||||
const TString& get_prezzo(const TString& codriga, const TString& tipodoc) { return get(codriga, tipodoc)._col_prezzo; }
|
||||
const TString& get_imponibile(const TString& codriga, const TString& tipodoc) { return get(codriga, tipodoc)._col_imponibile; }
|
||||
|
||||
TFP_righe_custom();
|
||||
};
|
||||
|
||||
class TFP_selected_docs : public TObject
|
||||
{
|
||||
TRelation _r_tabmod;
|
||||
@ -460,8 +334,16 @@ protected:
|
||||
|
||||
public:
|
||||
bool set_codcust(const char* codcust, const bool to_load) { return to_load ? load(codcust) : _codcust = codcust; }
|
||||
const TString& get_codcust() const { return _codcust; }
|
||||
void autoload(const TSheet_field& sf, const int file) const;
|
||||
|
||||
|
||||
bool load_caus_paf(TPaf_record& paf3400f, TDocumento& doc, TDoc_fp& doc_fp) const;
|
||||
bool load_articolo_paf(TPaf_record& paf1900f, TRiga_documento& rdoc, const long row_num, TDoc_fp& doc_fp) const;
|
||||
bool load_adg_paf(TPaf_record& paf2100f, TRiga_documento& rdoc, TDoc_fp& doc_fp, const long row_num, const bool split = false) const;
|
||||
|
||||
bool has_adg_split();
|
||||
|
||||
TFP_custom();
|
||||
explicit TFP_custom(const TRectype& rec);
|
||||
explicit TFP_custom(const char* codcust);
|
||||
@ -479,6 +361,27 @@ public:
|
||||
TRecord_array& bodyof##__radg = (__fpcust).body(LF_FPCADG); \
|
||||
for (int __r = bodyof##__radg.first_row(); bodyof##__radg.exist(__r) && (__radg=&(TRectype&)bodyof##__radg.row(__r))!=NULL; __r=bodyof##__radg.succ_row(__r))
|
||||
|
||||
class TFP_custom_cache
|
||||
{
|
||||
std::map<TString, TFP_custom> _customs;
|
||||
std::map<long, TString> _cli_custom;
|
||||
std::unique_ptr<TFP_custom> _global_custom;
|
||||
|
||||
public:
|
||||
bool has_custom(const TDocumento& doc);
|
||||
TFP_custom& get_custom(const TDocumento& doc);
|
||||
TFP_custom_cache();
|
||||
};
|
||||
|
||||
inline TFP_custom_cache& cached_custom_fp()
|
||||
{
|
||||
static std::shared_ptr<TFP_custom_cache> carmelo;
|
||||
if(carmelo == nullptr)
|
||||
{
|
||||
carmelo.reset(new TFP_custom_cache);
|
||||
}
|
||||
return *carmelo;
|
||||
}
|
||||
|
||||
class TFP_expression : public TObject
|
||||
{
|
||||
@ -499,10 +402,141 @@ private:
|
||||
|
||||
public:
|
||||
static const TVariant parse_expression(const TString& expr, TRiga_documento& rdoc);
|
||||
static const TVariant parse_expression(const TString& expr, TDocumento& doc) { return parse_expression(expr, doc[1]); }
|
||||
static bool check_condition(const TString& cond, TRiga_documento& rdoc);
|
||||
static bool check_condition(const TString& cond, TDocumento& doc) { return check_condition(cond, doc[1]); }
|
||||
|
||||
TFP_expression() = default;
|
||||
virtual ~TFP_expression() = default;
|
||||
};
|
||||
|
||||
// Gestione PAF
|
||||
class TDoc_fp : public TObject
|
||||
{
|
||||
friend class TFP_custom;
|
||||
|
||||
private:
|
||||
TRectype* _doc_rec;
|
||||
TCli_for _rec_clifo;
|
||||
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;
|
||||
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 _conai_str;
|
||||
TString _paese;
|
||||
bool _enapec;
|
||||
bool _privato;
|
||||
TString _coddest;
|
||||
TString _pec;
|
||||
TCausale _caus;
|
||||
bool _is_pa;
|
||||
bool _has_bolla;
|
||||
TString _codivadefault;
|
||||
long _idx_cassa_previdenziale;
|
||||
long _idx_adg_doc_row; // Indice per la tabella altri dati gestionali della riga
|
||||
int _num_linea;
|
||||
int _counter;
|
||||
TPaf_container _paf_container;
|
||||
int _count_r_conai;
|
||||
bool _nascondi_sconti_righe_fatt;
|
||||
TFP_nota_piede_f _riga_npf;
|
||||
bool _has_cust;
|
||||
|
||||
// Classe interna per gestire righe aggiuntive in riepilogo
|
||||
class TRiepilogo_agg
|
||||
{
|
||||
public:
|
||||
real imponibile;
|
||||
real imposta;
|
||||
TRiepilogo_agg() : imponibile(ZERO), imposta(ZERO) {}
|
||||
};
|
||||
|
||||
std::map<TString, TRiepilogo_agg> _riepilogo_agg;
|
||||
|
||||
struct
|
||||
{
|
||||
bool _is_valuta_estera{ false }; // Se il documento è in valuta estera
|
||||
TString4 _cod_val;
|
||||
real _cambio;
|
||||
} _doc_cambio;
|
||||
|
||||
//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;
|
||||
bool insert(TPaf_record& p);
|
||||
bool remove(TPaf_record& p);
|
||||
void reset(TPaf_record& p) const { TPaf_container::set_keys_paf(p, _hfatt, _bfatt); }
|
||||
bool save_paf();
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
/**< Funzioni di controllo */
|
||||
/**< Controlli di testata, non è const per il calcolo della codizione di pagamento */
|
||||
bool check_initial(TDocumentoEsteso& doc);
|
||||
/**< Controllo di riga */
|
||||
bool check_row(const TRiga_documento& rdoc);
|
||||
/**< Controllo riepilogo IVA */
|
||||
bool check_riepilogo(const TDocumentoEsteso& doc, const TRiepilogo_iva& riva);
|
||||
|
||||
|
||||
bool initialize(TDocumentoEsteso& doc);
|
||||
bool parse_sconto(const TString& formula, TToken_string& sconti) const;
|
||||
static bool get_bnp_iban(const TString& abi, const TString& cab, int prg, TString& iban);
|
||||
bool get_bank(TDocumento& doc, TString& iban, TString& abi, TString& cab, TString& istituto) const;
|
||||
bool get_bank_presentazione(const TDocumento& doc, TString& iban, TString& abi, TString& cab, TString& istituto) const;
|
||||
bool get_bank_appoggio(const TDocumento& doc, TString& iban, TString& abi, TString& cab, TString& istituto) const;
|
||||
const TString& descrizione(const TRiga_documento& rdoc);
|
||||
const TRectype& cco(const TRectype& doc) const; // Contratto/Convenzione/Offerta
|
||||
|
||||
void log(int severity, const char* msg);
|
||||
static const char* natura(const TString& codiva);
|
||||
static const char* get_esigibilita_iva(const TDocumentoEsteso& doc);
|
||||
void set_IVA(TString codiva, TPaf_record& paf) const;
|
||||
void set_IVA(const TRiga_documento& rdoc, TPaf_record& paf) const;
|
||||
bool add_row_art(long& riga_art, const TString& codice_tipo, const TString& codice_valore, TPaf_record& paf);
|
||||
bool add_row_alleg(TFilename& file, long& nprogr, TPaf_record& paf);
|
||||
const TString& converti_prezzo(const real& prezzo) const;
|
||||
void set_qta_prezzo(TPaf_record& paf1800f, TFPRiga_documento* rdoc) const;
|
||||
void add_ritenuta(const TDocumentoEsteso& doc, const TSpesa_prest& sp, TPaf_record& paf0700f) const;
|
||||
bool add_riepilogo_iva(TPaf_record& paf2200f, const TCodiceIVA& cod_iva, const char* eiva, const real& imponibile = ZERO, const real& imposta = ZERO);
|
||||
bool add_cassa_previdenziale(TRiga_documento& rdoc);
|
||||
bool export_info_articolo(TFPRiga_documento* rdoc, TPaf_record& paf1900f, TPaf_record& paf2100f, const long riga_xml, const int riga_doc);
|
||||
const TFirm& get_firm();
|
||||
|
||||
bool export_paf0100f();
|
||||
bool export_paf3200f();
|
||||
|
||||
// Record clifo
|
||||
//void set_rec_clifo(char tipocf, long codcf);
|
||||
|
||||
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);
|
||||
bool doc_to_paf();
|
||||
TRectype& key_to_doc(const TDoc_key& key);
|
||||
// Mostra il log a fine esecuzione
|
||||
bool show_log();
|
||||
int commit();
|
||||
int force_commit();
|
||||
void set_cache_insert(const bool v) { _cache_insert = v; }
|
||||
|
||||
TDoc_fp();
|
||||
~TDoc_fp();
|
||||
};
|
||||
|
||||
#endif // __FPLIB_H
|
||||
|
@ -18,7 +18,6 @@
|
||||
#include "../cg/cfban.h"
|
||||
#include <modaut.h>
|
||||
#include <urldefid.h>
|
||||
|
||||
bool set_connection(SSimple_query& s)
|
||||
{
|
||||
bool ok = true;
|
||||
@ -52,7 +51,6 @@ bool set_connection(SSimple_query& s)
|
||||
#endif
|
||||
return ok;
|
||||
}
|
||||
|
||||
SSimple_query& fp_db()
|
||||
{
|
||||
static SSimple_query* db = nullptr;
|
||||
@ -65,7 +63,6 @@ SSimple_query& fp_db()
|
||||
}
|
||||
return *db;
|
||||
}
|
||||
|
||||
bool run_fp_psw_mask()
|
||||
{
|
||||
static TMask* m;
|
||||
@ -89,7 +86,6 @@ bool run_fp_psw_mask()
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
string getline(ifstream& f)
|
||||
{
|
||||
string app;
|
||||
@ -239,31 +235,25 @@ const TString& tipo_doc_sdi(const TDocumento& doc)
|
||||
{
|
||||
static TString tipo_doc_sdi;
|
||||
tipo_doc_sdi.cut(0) << doc.get(DOC_TIPODOCSDI);
|
||||
|
||||
// Controlli da fare per clienti a cui si fotte la conversione e mi trovo dati sporchi nella colonna
|
||||
if (tipo_doc_sdi.len() == 4 && tipo_doc_sdi.starts_with("TD"))
|
||||
{
|
||||
return tipo_doc_sdi;
|
||||
}
|
||||
|
||||
return doc.tipo().tipo_doc_sdi();
|
||||
}
|
||||
|
||||
bool is_fattura(const TRectype& doc)
|
||||
{
|
||||
const TTipo_documento& td = cached_tipodoc(doc.get(DOC_TIPODOC));
|
||||
if (!td.is_fattura()) // Tengo per buone solo le fatture e le note di credito
|
||||
return false;
|
||||
|
||||
const TCodice_numerazione& cn = cached_numerazione(doc.get(DOC_CODNUM));
|
||||
return cn.tipo() == 2 && !cn.get_bool("B10"); // Controlla se fattura provvisioria esclusa da P.A.
|
||||
}
|
||||
|
||||
TString& add_filter(const TString& field, const TString& from, const TString& to)
|
||||
{
|
||||
TString& query = get_tmp_string();
|
||||
const TString qf = field.find('.') < 0 ? field : field.sub(field.find('.') + 1);
|
||||
|
||||
if (from.full() && to.full())
|
||||
{
|
||||
query << "&&(BETWEEN(" << field << ", #DA" << qf << ", #A" << qf << "))";
|
||||
@ -276,10 +266,8 @@ TString& add_filter(const TString& field, const TString& from, const TString& to
|
||||
{
|
||||
query << "&&(" << field << "<=#A" << qf << ")";
|
||||
}
|
||||
|
||||
return query;
|
||||
}
|
||||
|
||||
/***************************************************************************
|
||||
* TPaf_record
|
||||
***************************************************************************/
|
||||
@ -496,11 +484,9 @@ TPaf_record::TPaf_record(const char* table) : _table(table), _key(15, ',')
|
||||
}
|
||||
CHECKS(!_key.empty_items(), "Invalid primary key for table ", table);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////
|
||||
// TPaf_container
|
||||
////////////////////////////////////////////////////////
|
||||
|
||||
bool TPaf_container::clean_and_erase_paf(const TString& hfatt, const TString& bfatt)
|
||||
{
|
||||
bool ok = true;
|
||||
@ -511,17 +497,14 @@ bool TPaf_container::clean_and_erase_paf(const TString& hfatt, const TString& bf
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
void TPaf_container::set_keys_paf(TPaf_record& paf, const TString& hfatt, const TString& bfatt, const bool reset)
|
||||
{
|
||||
if (reset)
|
||||
paf.reset();
|
||||
|
||||
const char * prefix = paf_to_prefix(paf.get_table());
|
||||
paf.set(TString(prefix) << "_KEYHEADERFATT", hfatt);
|
||||
paf.set(TString(prefix) << "_KEYBODYFATT", bfatt);
|
||||
}
|
||||
|
||||
const char* TPaf_container::paf_to_prefix(const char * paf)
|
||||
{
|
||||
static TString paf_name;
|
||||
@ -568,16 +551,16 @@ const char* TPaf_container::paf_to_prefix(const char * paf)
|
||||
return "PT";
|
||||
if (paf_name == "PAF3200F")
|
||||
return "PU";
|
||||
if (paf_name == "PAF3400F")
|
||||
return "PZ";
|
||||
if (paf_name == "PAFW300F")
|
||||
return "PW";
|
||||
return "ERROR";
|
||||
}
|
||||
|
||||
TPaf_record& TPaf_container::get_paf(const char * paf)
|
||||
{
|
||||
return _pafs[paf];
|
||||
}
|
||||
|
||||
TPaf_container::TPaf_container()
|
||||
{
|
||||
_pafs.insert(std::pair<const char *, TPaf_record>("PAF0100F", TPaf_record("PAF0100F")));
|
||||
@ -621,10 +604,11 @@ TPaf_container::TPaf_container()
|
||||
_pafs.insert(std::pair<const char *, TPaf_record>("PAF3000F", TPaf_record("PAF3000F")));
|
||||
// PEC
|
||||
_pafs.insert(std::pair<const char *, TPaf_record>("PAF3200F", TPaf_record("PAF3200F")));
|
||||
// Causale documento
|
||||
_pafs.insert(std::pair<const char *, TPaf_record>("PAF3400F", TPaf_record("PAF3400F")));
|
||||
// Non invio XML
|
||||
_pafs.insert(std::pair<const char *, TPaf_record>("PAFW300F", TPaf_record("PAFW300F")));
|
||||
}
|
||||
|
||||
/***************************************************************************
|
||||
* TAncestor
|
||||
***************************************************************************/
|
||||
@ -710,7 +694,6 @@ bool TDoc_fp::get_bank(TDocumento& doc, TString& iban, TString& abi, TString& ca
|
||||
}
|
||||
return found;
|
||||
}
|
||||
|
||||
bool TDoc_fp::get_bank_presentazione(const TDocumento& doc, TString& iban, TString& abi, TString& cab, TString& istituto) const
|
||||
{
|
||||
bool found = false;
|
||||
@ -751,7 +734,6 @@ bool TDoc_fp::get_bank_presentazione(const TDocumento& doc, TString& iban, TStri
|
||||
istituto = cache().get("%BAN", abi, "S0");
|
||||
return found;
|
||||
}
|
||||
|
||||
bool TDoc_fp::get_bank_appoggio(const TDocumento& doc, TString& iban, TString& abi, TString& cab,
|
||||
TString& istituto) const
|
||||
{
|
||||
@ -781,7 +763,6 @@ bool TDoc_fp::get_bank_appoggio(const TDocumento& doc, TString& iban, TString& a
|
||||
}
|
||||
return found;
|
||||
}
|
||||
|
||||
const TString& TDoc_fp::descrizione(const TRiga_documento& rdoc)
|
||||
{
|
||||
if (rdoc.get_bool(RDOC_DESCLUNGA))
|
||||
@ -801,7 +782,6 @@ const TString& TDoc_fp::descrizione(const TRiga_documento& rdoc)
|
||||
}
|
||||
return rdoc.get(RDOC_DESCR);
|
||||
}
|
||||
|
||||
const TRectype* TDoc_fp::find_parent_row(const TRectype& rdoc) const
|
||||
{
|
||||
const long id = rdoc.get_long(RDOC_DAIDRIGA);
|
||||
@ -899,38 +879,31 @@ bool TDoc_fp::save_paf()
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool TDoc_fp::check_initial(TDocumentoEsteso& doc)
|
||||
{
|
||||
bool ok = true;
|
||||
static TString msg;
|
||||
|
||||
if (_coddest.len() != 6 && _coddest.len() != 7)
|
||||
{
|
||||
log(1, "Il codice destinatario ha una lunghezza non conforme.");
|
||||
ok = false;
|
||||
}
|
||||
|
||||
if (_rec_clifo.get(CLI_PAIV).empty() && _rec_clifo.get(CLI_COFI).empty())
|
||||
{
|
||||
log(1, "Sia la partita IVA che il codice fiscale del cessionario committente sono vuoti, almeno uno dei due deve essere valorizzato.");
|
||||
ok = false;
|
||||
}
|
||||
|
||||
TPagamento& pag = doc.pagamento();
|
||||
if(pag.cond_pag_sdi().empty())
|
||||
{
|
||||
|
||||
msg.cut(0) << "Non e' valorizzata la condizione di pagamento SDI (TP01, TP02, TP03) per la condizione di pagamento " << pag.code();
|
||||
log(1, msg);
|
||||
ok = false;
|
||||
}
|
||||
|
||||
for (int nr = 0; nr < doc.scadenze().items(); nr++)
|
||||
{
|
||||
const int rp = nr < pag.n_rate() ? nr : 0;
|
||||
static TString key_class; key_class.cut(0) << pag.tipo_rata(rp) << pag.ulc_rata(rp);
|
||||
|
||||
if(cache().get("%CLR", key_class, "S12").empty())
|
||||
{
|
||||
msg.cut(0) << "Non e' valorizzata la tipologia di pagamento SDI (MPXX) per la condizione di pagamento " << pag.code();
|
||||
@ -938,15 +911,12 @@ bool TDoc_fp::check_initial(TDocumentoEsteso& doc)
|
||||
ok = false;
|
||||
}
|
||||
}
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool TDoc_fp::check_row(const TRiga_documento& rdoc)
|
||||
{
|
||||
bool ok = false;
|
||||
static TString msg;
|
||||
|
||||
if(rdoc.is_spese())
|
||||
{
|
||||
const TSpesa_prest& spesa = rdoc.spesa();
|
||||
@ -956,7 +926,6 @@ bool TDoc_fp::check_row(const TRiga_documento& rdoc)
|
||||
log(1, msg);
|
||||
}
|
||||
}
|
||||
|
||||
const TCodiceIVA& codice_iva = rdoc.iva();
|
||||
if (codice_iva.codice().full() && codice_iva.percentuale() == ZERO && codice_iva.natura().empty())
|
||||
{
|
||||
@ -964,49 +933,38 @@ bool TDoc_fp::check_row(const TRiga_documento& rdoc)
|
||||
log(1, msg);
|
||||
ok = false;
|
||||
}
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool TDoc_fp::check_riepilogo(const TDocumentoEsteso& doc, const TRiepilogo_iva& riva)
|
||||
{
|
||||
bool ok = true;
|
||||
static TString msg;
|
||||
|
||||
if(*get_esigibilita_iva(doc) == 'S' && riva.cod_iva().natura() == "N6")
|
||||
{
|
||||
msg.cut(0) << "Impossibile avere un documento con scissione dei pagamenti e natura iva N6, codice: " << riva.cod_iva().codice();
|
||||
log(1, msg);
|
||||
ok = false;
|
||||
}
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool TDoc_fp::initialize(TDocumentoEsteso& doc)
|
||||
{
|
||||
// Azzero
|
||||
_hfatt.cut(0);
|
||||
_bfatt.cut(0);
|
||||
|
||||
// Preparo il record del cliente
|
||||
_rec_clifo = cache().get(LF_CLIFO, TString() << doc.tipocf() << "|" << doc.codcf());
|
||||
|
||||
_rec_clifo = doc.clifor();
|
||||
// Valorizzo la gestione del cambio
|
||||
_doc_cambio._cod_val = doc.valuta();
|
||||
_doc_cambio._is_valuta_estera = doc.valuta().full() && !is_euro_value(doc.valuta());
|
||||
_doc_cambio._cambio = doc.cambio();
|
||||
|
||||
// Paese del documento
|
||||
_paese = "IT";
|
||||
|
||||
_has_bolla = false;
|
||||
if (!chiave_paf(doc, _hfatt, _bfatt))
|
||||
return false;
|
||||
|
||||
// Preparo il log
|
||||
log(-1, _bfatt);
|
||||
|
||||
#ifndef DBG
|
||||
// Controllo se il documento è almeno in stato di stampa
|
||||
if (doc.stato() < doc.tipo().stato_finale_stampa())
|
||||
@ -1015,7 +973,6 @@ bool TDoc_fp::initialize(TDocumentoEsteso& doc)
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef DBG
|
||||
_is_pa = doc.clifor().get_int("ALLEG") == 7;
|
||||
if (!get_coddest(doc.clifor().tipo(), doc.clifor().codice(), _coddest, _pec))
|
||||
@ -1027,12 +984,9 @@ bool TDoc_fp::initialize(TDocumentoEsteso& doc)
|
||||
_is_pa = true;
|
||||
_coddest = "WSUHKZ";
|
||||
#endif
|
||||
|
||||
_enapec = _coddest == "0000000" && _pec.full();
|
||||
_privato = _coddest.len() != 6;
|
||||
|
||||
_caus = TCausale(doc.tipo().causale(), doc.anno());
|
||||
|
||||
// Preparo il codice iva di default
|
||||
{
|
||||
FOR_EACH_PHYSICAL_RDOC(doc, r, rdoc)
|
||||
@ -1042,19 +996,16 @@ bool TDoc_fp::initialize(TDocumentoEsteso& doc)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Azzero indici
|
||||
_idx_cassa_previdenziale = 1;
|
||||
|
||||
// Controllo custom
|
||||
_has_cust = cached_custom_fp().has_custom(doc);
|
||||
if(check_initial(doc) || fp_settings().get_check_not_block())
|
||||
{
|
||||
return _paf_container.clean_and_erase_paf(_hfatt, _bfatt);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
const TRectype& TDoc_fp::cco(const TRectype& doc) const
|
||||
{
|
||||
TString80 conkey;
|
||||
@ -1108,7 +1059,6 @@ bool TDoc_fp::show_log()
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
int TDoc_fp::commit()
|
||||
{
|
||||
int r = 0;
|
||||
@ -1132,7 +1082,6 @@ int TDoc_fp::commit()
|
||||
{
|
||||
log(2, "Le fatture sono state esportate in stato diagnosticato");
|
||||
}
|
||||
|
||||
if(r >= 0 && fp_db().sq_commit())
|
||||
{
|
||||
r += 2;
|
||||
@ -1147,18 +1096,15 @@ int TDoc_fp::commit()
|
||||
_to_commit = false;
|
||||
return r;
|
||||
}
|
||||
|
||||
int TDoc_fp::force_commit()
|
||||
{
|
||||
_to_commit = true;
|
||||
return commit();
|
||||
}
|
||||
|
||||
const char* TDoc_fp::natura(const TString& codiva)
|
||||
{
|
||||
return cache().get("%IVA", codiva, "S12");
|
||||
}
|
||||
|
||||
const char* TDoc_fp::get_esigibilita_iva(const TDocumentoEsteso& doc)
|
||||
{
|
||||
// Esigibilità IVA: Immediata, Differita, Split payment
|
||||
@ -1167,20 +1113,16 @@ const char* TDoc_fp::get_esigibilita_iva(const TDocumentoEsteso& doc)
|
||||
eiva = "S";
|
||||
else if (doc.get_bool(DOC_LIQDIFF) || doc.get_bool(DOC_IVAXCASSA))
|
||||
eiva = "D";
|
||||
|
||||
return eiva;
|
||||
}
|
||||
|
||||
void TDoc_fp::set_IVA(TString codiva, TPaf_record& paf) const
|
||||
{
|
||||
if (codiva.empty())
|
||||
codiva = _codivadefault;
|
||||
|
||||
// É necessario il cast a real?
|
||||
paf.set("PI_ALIQUOTAIVA", static_cast<real>(cache().get("%IVA", codiva, "R0")));
|
||||
paf.set("PI_NATURA", natura(codiva));
|
||||
}
|
||||
|
||||
void TDoc_fp::set_IVA(const TRiga_documento& rdoc, TPaf_record& paf) const
|
||||
{
|
||||
set_IVA(rdoc.get(RDOC_CODIVA), paf);
|
||||
@ -1228,34 +1170,28 @@ const TString& TDoc_fp::converti_prezzo(const real& prezzo) const
|
||||
ret << prezzo;
|
||||
return ret;
|
||||
}
|
||||
|
||||
void TDoc_fp::set_qta_prezzo(TPaf_record& paf1800f, TFPRiga_documento* rdoc) const
|
||||
{
|
||||
// Setto l'unità di misura
|
||||
paf1800f.set("PI_UNITAMISURA", rdoc->get(RDOC_UMQTA));
|
||||
|
||||
const real qta = rdoc->quantita();
|
||||
// Prendendo la stringa non ho problemi in scrittura della query, a volte accadono cose stupide
|
||||
TString& qta_string = rdoc->quantita_string();
|
||||
real prezzo_unit = rdoc->prezzo(_nascondi_sconti_righe_fatt, false);
|
||||
real prezzo_tot = rdoc->imponibile(false);
|
||||
|
||||
if(qta < ZERO)
|
||||
{
|
||||
// Metto la qualità senza il segno
|
||||
qta_string = qta_string.mid(1);
|
||||
|
||||
// E i prezzi in negativo
|
||||
prezzo_unit = -abs(prezzo_unit);
|
||||
prezzo_tot = -abs(prezzo_tot);
|
||||
}
|
||||
|
||||
// Salvo tutto
|
||||
paf1800f.set("PI_QUANTITA", qta_string);
|
||||
paf1800f.set("PI_PREZZOUNIT", converti_prezzo(prezzo_unit));
|
||||
paf1800f.set("PI_PRZTOTALE", converti_prezzo(prezzo_tot));
|
||||
}
|
||||
|
||||
const real calc_ritenuta(const TDocumento& doc)
|
||||
{
|
||||
real imponibile_prestazioni = ZERO;
|
||||
@ -1275,30 +1211,24 @@ const real calc_ritenuta(const TDocumento& doc)
|
||||
imponibile += imponibile * rdoc->spesa().perc() / CENTO;
|
||||
}
|
||||
}
|
||||
|
||||
return imponibile;
|
||||
}
|
||||
|
||||
void TDoc_fp::add_ritenuta(const TDocumentoEsteso& doc, const TSpesa_prest& sp, TPaf_record& paf0700f) const
|
||||
{
|
||||
// <DatiRitenuta>
|
||||
paf0700f.set("P7_TIPORITENUTA", _rec_clifo.get_char(CLI_TIPOPERS) == 'F' ? "RT01" : "RT02");
|
||||
TString doc_imponibile = doc.imponibile().string();
|
||||
|
||||
paf0700f.set("P7_IMPORTORIT", converti_prezzo(doc.ritenute()));
|
||||
paf0700f.set("P7_ALIQUOTARIT", sp.perc());
|
||||
static TString caus_la; caus_la.cut(0);
|
||||
caus_la << sp.get("S14");
|
||||
|
||||
if (caus_la.empty())
|
||||
{
|
||||
caus_la << sp.rec_caus_770().get("S2");
|
||||
}
|
||||
|
||||
paf0700f.set("P7_CAUSPAGAM", caus_la);
|
||||
// </DatiRitenuta>
|
||||
}
|
||||
|
||||
bool TDoc_fp::add_riepilogo_iva(TPaf_record& paf2200f, const TCodiceIVA& cod_iva, const char* eiva, const real& imponibile,
|
||||
const real& imposta)
|
||||
{
|
||||
@ -1307,47 +1237,37 @@ bool TDoc_fp::add_riepilogo_iva(TPaf_record& paf2200f, const TCodiceIVA& cod_iva
|
||||
const real aliquota = cod_iva.percentuale();
|
||||
const TString& cod_aliquota = cod_iva.codice();
|
||||
TRiepilogo_agg& riepilogo_agg = _riepilogo_agg[cod_aliquota];
|
||||
|
||||
// Aliquota
|
||||
paf2200f.set("PL_ALIQUOTAIVA", aliquota);
|
||||
|
||||
// Natura
|
||||
if (aliquota.is_zero())
|
||||
paf2200f.set("PL_NATURA", natura(cod_aliquota));
|
||||
|
||||
// Imponibile
|
||||
paf2200f.set("PL_IMPONIBILE", converti_prezzo(imponibile + riepilogo_agg.imponibile));
|
||||
|
||||
// Imposta
|
||||
paf2200f.set("PL_IMPOSTA", converti_prezzo(imposta + riepilogo_agg.imposta));
|
||||
|
||||
// Esigibilità IVA
|
||||
paf2200f.set("PL_ESIGIVA", eiva);
|
||||
if (*eiva == 'S')
|
||||
paf2200f.set("PL_RIFNORMATIVO", "Scissione pagamenti art.17-ter DPR 633/72");
|
||||
else
|
||||
paf2200f.set("PL_RIFNORMATIVO", cod_iva.descrizione());
|
||||
|
||||
paf2200f.set("PL_GESTIONE", "D");
|
||||
|
||||
// Elimino l'oggetto
|
||||
_riepilogo_agg.erase(cod_aliquota);
|
||||
|
||||
// Inserisco
|
||||
return insert(paf2200f);
|
||||
}
|
||||
|
||||
bool TDoc_fp::add_cassa_previdenziale(TRiga_documento& rdoc)
|
||||
{
|
||||
TPaf_record& paf0800f = _paf_container.get_paf("PAF0800F");
|
||||
reset(paf0800f);
|
||||
paf0800f.set("P8_RIFNUMLINEA", _idx_cassa_previdenziale++);
|
||||
|
||||
// Resto
|
||||
const TSpesa_prest& sp = rdoc.spesa();
|
||||
const real imponibile_ritenuta = rdoc.doc().ritenute();//calc_ritenuta(rdoc.doc());
|
||||
const real importo_cassa = imponibile_ritenuta * sp.perc() / CENTO;
|
||||
|
||||
paf0800f.set("P8_TIPOCASSA", sp.cassa_previdenziale());
|
||||
// Aliquota della cassa
|
||||
paf0800f.set("P8_ALIQCASSA", sp.perc());
|
||||
@ -1360,20 +1280,65 @@ bool TDoc_fp::add_cassa_previdenziale(TRiga_documento& rdoc)
|
||||
if(sp.sogg_a_rit())
|
||||
paf0800f.set("P8_RITENUTA", "SI");
|
||||
paf0800f.set("P8_NATURA", rdoc.iva().natura());
|
||||
|
||||
// Inserisco il tutto nei dati riepilogo
|
||||
TRiepilogo_agg& pop = _riepilogo_agg[rdoc.iva().codice()];
|
||||
pop.imponibile += importo_cassa;
|
||||
pop.imposta += importo_cassa * rdoc.iva().percentuale() / CENTO;
|
||||
|
||||
return insert(paf0800f);
|
||||
}
|
||||
|
||||
bool TDoc_fp::export_info_articolo(TFPRiga_documento* rdoc, TPaf_record& paf1900f, TPaf_record& paf2100f, const long riga_xml, const int riga_doc)
|
||||
{
|
||||
bool ok = true;
|
||||
const TString& codartmag = rdoc->get(RDOC_CODARTMAG);
|
||||
const TString& codart = rdoc->get(RDOC_CODART);
|
||||
long riga_art = 0;
|
||||
if(_has_cust)
|
||||
{
|
||||
cached_custom_fp().get_custom(rdoc->doc()).load_articolo_paf(paf1900f, *rdoc, riga_xml, *this);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (codart.full())
|
||||
{
|
||||
if (codartmag.full())
|
||||
{
|
||||
reset(paf1900f);
|
||||
paf1900f.set("PY_KEYNLINEA", riga_xml);
|
||||
ok &= add_row_art(riga_art, "Codice articolo interno", codartmag, paf1900f);
|
||||
}
|
||||
// Se il codice articolo del magazzino è diverso quello è del cliente
|
||||
if (codart.full() && codart != codartmag)
|
||||
{
|
||||
reset(paf1900f);
|
||||
paf1900f.set("PY_KEYNLINEA", riga_xml);
|
||||
ok &= add_row_art(riga_art, "Codice articolo cliente", codart, paf1900f);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Controllo se ha il CONAI in tal caso aggiungo i dati
|
||||
FOR_EACH_CONFIGURED_CONAI_CLASS(cc)
|
||||
{
|
||||
const TString conai_fld(conai_peso_name(cc, LF_RIGHEDOC));
|
||||
if (rdoc->get(conai_fld).full())
|
||||
{
|
||||
reset(paf2100f);
|
||||
paf2100f.set("PK_KEYNLINEA", static_cast<long>(riga_doc));
|
||||
paf2100f.set("PK_KEYNLINAR", _idx_adg_doc_row++);
|
||||
static TString msg_conai;
|
||||
msg_conai.cut(0) << "Contributo CONAI " << conai_material(cc) << " (KG)";
|
||||
paf2100f.set("PK_TIPODATO", "CONAI");
|
||||
paf2100f.set("PK_RIFDATO", msg_conai);
|
||||
paf2100f.set("PK_RIFNUMERO", rdoc->get_real(conai_fld).string());
|
||||
ok &= insert(paf2100f);
|
||||
}
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
const TFirm& TDoc_fp::get_firm()
|
||||
{
|
||||
return prefix().firm();
|
||||
}
|
||||
|
||||
bool TDoc_fp::export_paf0100f()
|
||||
{
|
||||
// <DatiTrassmissione>
|
||||
@ -1393,7 +1358,6 @@ bool TDoc_fp::export_paf0100f()
|
||||
// </DatiTrassmissione>
|
||||
return insert(paf0100f);
|
||||
}
|
||||
|
||||
bool TDoc_fp::export_paf3200f()
|
||||
{
|
||||
if (_enapec)
|
||||
@ -1404,19 +1368,15 @@ bool TDoc_fp::export_paf3200f()
|
||||
// </Datipec>
|
||||
return insert(paf3200f);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TDoc_fp::doc_to_paf(TDocumentoEsteso& doc)
|
||||
{
|
||||
if (!initialize(doc))
|
||||
return false;
|
||||
|
||||
bool ok = true;
|
||||
|
||||
ok &= export_paf0100f();
|
||||
|
||||
#ifndef DBG
|
||||
ok &= export_paf3200f();
|
||||
#endif
|
||||
@ -1486,10 +1446,15 @@ bool TDoc_fp::doc_to_paf(TDocumentoEsteso& doc)
|
||||
// <CessionarioCommittente>
|
||||
TPaf_record& paf0400f = _paf_container.get_paf("PAF0400F");
|
||||
#ifndef DBG
|
||||
// Per soggetti non italiani con solo codice fiscale va messo lo stato e il codice fiscale
|
||||
if (cliente.partita_IVA().full())
|
||||
{
|
||||
paf0400f.set("P4_FISCIVAPAESE", cliente.stato_partita_IVA());
|
||||
paf0400f.set("P4_FISCIVACOD", cliente.partita_IVA());
|
||||
paf0400f.set("P4_FISCIVAPAESE", cliente.stato_partita_IVA());
|
||||
paf0400f.set("P4_FISCIVACOD", cliente.partita_IVA());
|
||||
}
|
||||
else if(cliente.stato_partita_IVA() != "IT")
|
||||
{
|
||||
paf0400f.set("P4_FISCIVAPAESE", cliente.stato_partita_IVA());
|
||||
}
|
||||
paf0400f.set("P4_CODFISC", cliente.codice_fiscale());
|
||||
#else
|
||||
@ -1505,7 +1470,6 @@ bool TDoc_fp::doc_to_paf(TDocumentoEsteso& doc)
|
||||
{
|
||||
paf0400f.set("P4_ANADENOM", cliente.ragione_sociale());
|
||||
}
|
||||
|
||||
// DatiSede
|
||||
paf0400f.set("P4_SEDEIND", cliente.via_residenza());
|
||||
paf0400f.set("P4_SEDENRCIVICO", cliente.civico_residenza().left(8));
|
||||
@ -1521,6 +1485,11 @@ bool TDoc_fp::doc_to_paf(TDocumentoEsteso& doc)
|
||||
paf0400f.set("P4_SEDECAP", cliente.CAP_residenza());
|
||||
paf0400f.set("P4_SEDEPROV", cliente.provincia_residenza());
|
||||
}
|
||||
// Titolo onorifico!
|
||||
if(_rec_clifo.vendite().get(CFV_TITOLO).full())
|
||||
{
|
||||
paf0400f.set("P4_ANATITOLO", cache().get("TIT", _rec_clifo.vendite().get(CFV_TITOLO), "S0"));
|
||||
}
|
||||
paf0400f.set("P4_GESTIONE", "D");
|
||||
ok &= insert(paf0400f);
|
||||
// </CessionarioCommittente>
|
||||
@ -1546,34 +1515,39 @@ bool TDoc_fp::doc_to_paf(TDocumentoEsteso& doc)
|
||||
// Nel dubbio risetto
|
||||
doc.put("ADDBOLLI", set_bollo);
|
||||
// </DatiBollo>
|
||||
|
||||
// <DatiCassaPrevidenziale>
|
||||
// Non la mettiamo!
|
||||
// </DatiCassaPrevidenziale>
|
||||
|
||||
// Non inserisco più adesso il paf0700f ma lo faccio alla fine (per inserire le ritenute)
|
||||
/*
|
||||
* Lo sconto in testata è stato disabilitato in quanto su Campo influenza solo le righe merci mentre dovrebbe modificare tutte le righe
|
||||
*/
|
||||
|
||||
// <DatiGenerali>
|
||||
TPaf_record& paf2700f = _paf_container.get_paf("PAF2700F");
|
||||
// Disabilitata la scrittura del totale del documento, questo causa problemi se è presente uno sconto in testata e l'addebito del bollo.
|
||||
// Campo calcola prima il totale, poi lo sconta e ci applica il bollo mentre lo SDI sconta a bollo già applicato.
|
||||
|
||||
paf2700f.set("PQ_IMPTOTDOC", doc.totale_doc());
|
||||
const TRectype& cont_conv_off = cco(doc);
|
||||
TString causale = cont_conv_off.get("S1");
|
||||
if (causale.full())
|
||||
if(_has_cust)
|
||||
{
|
||||
TPaf_record& paf3400f = _paf_container.get_paf("PAF3400F");
|
||||
reset(paf3400f);
|
||||
cached_custom_fp().get_custom(doc).load_caus_paf(paf3400f, doc, *this);
|
||||
}
|
||||
else
|
||||
{
|
||||
TString causale = cont_conv_off.get("S1");
|
||||
if (causale.full())
|
||||
{
|
||||
causale << ' ' << cont_conv_off.get("S2");
|
||||
causale << ' ' << cont_conv_off.get("S3");
|
||||
causale.strip_double_spaces();
|
||||
causale.cut(200);
|
||||
}
|
||||
else
|
||||
}
|
||||
else
|
||||
causale = doc.tipo().descrizione();
|
||||
paf2700f.set("PQ_CAUSALE", causale);
|
||||
paf2700f.set("PQ_CAUSALE", causale);
|
||||
}
|
||||
// paf2700f.set("PQ_ART73", true);
|
||||
paf2700f.set("PQ_GESTIONE", "D");
|
||||
ok &= insert(paf2700f);
|
||||
@ -1655,16 +1629,12 @@ bool TDoc_fp::doc_to_paf(TDocumentoEsteso& doc)
|
||||
TPaf_record& paf3000f = _paf_container.get_paf("PAF3000F");
|
||||
long riga = 1;
|
||||
|
||||
|
||||
FOR_EACH_PHYSICAL_FPRDOC(doc, r, rdoc)
|
||||
{
|
||||
// Controllo la riga
|
||||
if (check_row(*rdoc) && !fp_settings().get_check_not_block())
|
||||
return false;
|
||||
|
||||
|
||||
_idx_adg_doc_row = 1L;
|
||||
|
||||
bool skip_riga = false;
|
||||
|
||||
reset(paf1800f);
|
||||
@ -1672,54 +1642,13 @@ bool TDoc_fp::doc_to_paf(TDocumentoEsteso& doc)
|
||||
const TString& descrizione_riga = descrizione(*rdoc);
|
||||
if (descrizione_riga.empty())
|
||||
continue;
|
||||
|
||||
|
||||
reset(paf3000f);
|
||||
paf3000f.set("PT_RIFNUMLINEA", riga);
|
||||
paf3000f.set("PT_COMMENTO", descrizione_riga);
|
||||
// <CodiceArticolo>
|
||||
if (rdoc->is_articolo())
|
||||
{
|
||||
|
||||
const TString& codartmag = rdoc->get(RDOC_CODARTMAG);
|
||||
const TString& codart = rdoc->get(RDOC_CODART);
|
||||
long riga_art = 0;
|
||||
if (codart.full())
|
||||
{
|
||||
if (codartmag.full())
|
||||
{
|
||||
|
||||
reset(paf1900f);
|
||||
paf1900f.set("PY_KEYNLINEA", riga);
|
||||
ok &= add_row_art(riga_art, "Codice articolo interno", codartmag, paf1900f);
|
||||
}
|
||||
// Se il codice articolo del magazzino è diverso quello è del cliente
|
||||
if (codart.full() && codart != codartmag)
|
||||
{
|
||||
|
||||
reset(paf1900f);
|
||||
paf1900f.set("PY_KEYNLINEA", riga);
|
||||
ok &= add_row_art(riga_art, "Codice articolo cliente", codart, paf1900f);
|
||||
}
|
||||
// Controllo se ha il CONAI in tal caso aggiungo i dati
|
||||
FOR_EACH_CONFIGURED_CONAI_CLASS(cc)
|
||||
{
|
||||
const TString conai_fld(conai_peso_name(cc, LF_RIGHEDOC));
|
||||
if(rdoc->get(conai_fld).full())
|
||||
{
|
||||
reset(paf2100f);
|
||||
paf2100f.set("PK_KEYNLINEA", static_cast<long>(r));
|
||||
paf2100f.set("PK_KEYNLINAR", _idx_adg_doc_row++);
|
||||
static TString msg_conai;
|
||||
msg_conai.cut(0) << "Contributo CONAI " << conai_material(cc) << " (KG)";
|
||||
paf2100f.set("PK_TIPODATO", "CONAI");
|
||||
paf2100f.set("PK_RIFDATO", msg_conai);
|
||||
paf2100f.set("PK_RIFNUMERO", rdoc->get_real(conai_fld).string());
|
||||
|
||||
ok &= insert(paf2100f);
|
||||
}
|
||||
}
|
||||
}
|
||||
ok &= export_info_articolo(rdoc, paf1900f, paf2100f, riga, r);
|
||||
}
|
||||
// </CodiceArticolo>
|
||||
if(rdoc->is_descrizione())
|
||||
@ -1790,7 +1719,6 @@ bool TDoc_fp::doc_to_paf(TDocumentoEsteso& doc)
|
||||
else if (rdoc->is_spese())
|
||||
{
|
||||
const TSpesa_prest& sp = rdoc->spesa();
|
||||
|
||||
// Controllo se ha la cassa professionale lo metto in testata
|
||||
if (sp.cassa_previdenziale().full())
|
||||
{
|
||||
@ -1834,7 +1762,6 @@ bool TDoc_fp::doc_to_paf(TDocumentoEsteso& doc)
|
||||
paf1800f.set("PI_PREZZOUNIT", converti_prezzo(qta_inverse ? -abs(prz) : abs(prz)));
|
||||
paf1800f.set("PI_PRZTOTALE", converti_prezzo(imp));
|
||||
set_IVA(*rdoc, paf1800f);
|
||||
|
||||
// Controllo se è una ritenuta fiscale
|
||||
if (sp.tipo_ritenuta() == 'F')
|
||||
{
|
||||
@ -1867,27 +1794,21 @@ bool TDoc_fp::doc_to_paf(TDocumentoEsteso& doc)
|
||||
msg.format("La riga omaggi %d ha quantità nulla", riga);
|
||||
log(1, msg);
|
||||
}
|
||||
|
||||
paf1800f.set("PI_TIPOCESSPREST", "AB");
|
||||
set_qta_prezzo(paf1800f, rdoc);
|
||||
set_IVA(*rdoc, paf1800f);
|
||||
|
||||
reset(paf2100f);
|
||||
paf2100f.set("PK_KEYNLINEA", static_cast<long>(r));
|
||||
paf2100f.set("PK_KEYNLINAR", _idx_adg_doc_row++);
|
||||
paf2100f.set("PK_TIPODATO", "AswTRiga");
|
||||
|
||||
|
||||
if (rdoc->get_bool(RDOC_ADDIVA))
|
||||
{
|
||||
paf2100f.set("PK_RIFDATO", "Omaggio con rivalsa");
|
||||
|
||||
// Metto i dati come si trattasse di una riga normalissima
|
||||
paf1800f.set("PI_UNITAMISURA", rdoc->get(RDOC_UMQTA));
|
||||
paf1800f.set("PI_QUANTITA", rdoc->get_real(RDOC_QTA).string(0));
|
||||
paf1800f.set("PI_PREZZOUNIT", converti_prezzo(rdoc->prezzo(false, false)));
|
||||
paf1800f.set("PI_PRZTOTALE", converti_prezzo(rdoc->prezzo(false, false) * rdoc->get_real(RDOC_QTA)));
|
||||
|
||||
TRiepilogo_agg& riepilogo_agg = _riepilogo_agg[rdoc->iva().codice()];
|
||||
riepilogo_agg.imponibile += rdoc->imponibile_omaggio(2);
|
||||
// Non metto l'imposta, è già presente nei totali
|
||||
@ -1896,7 +1817,6 @@ bool TDoc_fp::doc_to_paf(TDocumentoEsteso& doc)
|
||||
else
|
||||
{
|
||||
paf2100f.set("PK_RIFDATO", "Omaggio senza rivalsa");
|
||||
|
||||
// Aggiungo uno sconto
|
||||
paf2000f.set("PJ_KEYNLINEA", static_cast<long>(r));
|
||||
paf2000f.set("PJ_KEYNLINAR", 1L);
|
||||
@ -1907,7 +1827,6 @@ bool TDoc_fp::doc_to_paf(TDocumentoEsteso& doc)
|
||||
paf2000f.set("PJ_GESTIONE", "D");
|
||||
ok &= insert(paf2000f);
|
||||
}
|
||||
|
||||
ok &= insert(paf2100f);
|
||||
}
|
||||
else
|
||||
@ -1915,7 +1834,6 @@ bool TDoc_fp::doc_to_paf(TDocumentoEsteso& doc)
|
||||
// Salto tutte le altre righe
|
||||
continue;
|
||||
}
|
||||
|
||||
// <ScontoMaggiorazione>
|
||||
TString80 sconto_expr = rdoc->get(RDOC_SCONTO);
|
||||
TToken_string sconti;
|
||||
@ -1944,10 +1862,14 @@ bool TDoc_fp::doc_to_paf(TDocumentoEsteso& doc)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// </ScontoMaggiorazione>
|
||||
if (!skip_riga)
|
||||
{
|
||||
if(_has_cust)
|
||||
{
|
||||
cached_custom_fp().get_custom(doc).load_adg_paf(paf2100f, *rdoc, *this, _idx_adg_doc_row);
|
||||
}
|
||||
|
||||
paf1800f.set("PI_GESTIONE", "D");
|
||||
ok &= insert(paf1800f) && insert(paf3000f);
|
||||
riga++;
|
||||
@ -1989,6 +1911,7 @@ bool TDoc_fp::doc_to_paf(TDocumentoEsteso& doc)
|
||||
ok &= insert(paf1800f) && insert(paf3000f);
|
||||
riga++;
|
||||
}
|
||||
|
||||
// OMAGGI????
|
||||
// Aggiungo le spese incasso
|
||||
if(doc.get_real("SPESINC") > ZERO)
|
||||
@ -2007,6 +1930,7 @@ bool TDoc_fp::doc_to_paf(TDocumentoEsteso& doc)
|
||||
ok &= insert(paf1800f) && insert(paf3000f);
|
||||
riga++;
|
||||
}
|
||||
|
||||
// Conai assolto
|
||||
if(doc.clifor().vendite().get_bool("CONAIASS"))
|
||||
{
|
||||
@ -2022,7 +1946,6 @@ bool TDoc_fp::doc_to_paf(TDocumentoEsteso& doc)
|
||||
ok &= insert(paf1800f) && insert(paf3000f);
|
||||
riga++;
|
||||
}
|
||||
|
||||
// Riga sconto di testata
|
||||
// Se è presente uno sconto in testata devo sottrarlo come riga sconto o lo SDI urla
|
||||
if(doc.get(DOC_SCONTOPERC).full() && doc.get(DOC_SCONTOPERC) != "0")
|
||||
@ -2031,7 +1954,6 @@ bool TDoc_fp::doc_to_paf(TDocumentoEsteso& doc)
|
||||
FOR_EACH_ASSOC_OBJECT(tiva, obj, key, itm)
|
||||
{
|
||||
const TRiepilogo_iva& riva = *dynamic_cast<const TRiepilogo_iva*>(itm);
|
||||
|
||||
reset(paf1800f);
|
||||
paf1800f.set("PI_NUMEROLINEA", riga);
|
||||
reset(paf3000f);
|
||||
@ -2051,7 +1973,6 @@ bool TDoc_fp::doc_to_paf(TDocumentoEsteso& doc)
|
||||
riga++;
|
||||
}
|
||||
}
|
||||
|
||||
const TString& nota_piede_fatt = _riga_npf.get_nota_piede(doc.tipo().codice());
|
||||
if(nota_piede_fatt.full())
|
||||
{
|
||||
@ -2068,6 +1989,27 @@ bool TDoc_fp::doc_to_paf(TDocumentoEsteso& doc)
|
||||
riga++;
|
||||
}
|
||||
|
||||
// Se dopo tutto ha ancora delle righe di altri dati gestionali che vanno messi a parte
|
||||
if(_has_cust && cached_custom_fp().get_custom(doc).has_adg_split())
|
||||
{
|
||||
reset(paf1800f);
|
||||
paf1800f.set("PI_NUMEROLINEA", riga);
|
||||
reset(paf3000f);
|
||||
paf3000f.set("PT_RIFNUMLINEA", riga);
|
||||
paf3000f.set("PT_COMMENTO", "Riga altri dati gestionali");
|
||||
paf1800f.set("PI_QUANTITA", UNO);
|
||||
paf1800f.set("PI_PREZZOUNIT", ZERO);
|
||||
paf1800f.set("PI_PRZTOTALE", ZERO);
|
||||
set_IVA(_codivadefault, paf1800f);
|
||||
|
||||
// Resetto il contatore
|
||||
_idx_adg_doc_row = 1L;
|
||||
ok &= cached_custom_fp().get_custom(doc).load_adg_paf(paf2100f, doc[1], *this, riga, true) &&
|
||||
insert(paf1800f) && insert(paf3000f);
|
||||
|
||||
riga++;
|
||||
}
|
||||
|
||||
// </DatiBeniServizi>
|
||||
// <DatiDDT>
|
||||
// Metto qua i dati DDT per capire se la fattura è accompagnatoria o deriva da bolla
|
||||
@ -2104,7 +2046,6 @@ bool TDoc_fp::doc_to_paf(TDocumentoEsteso& doc)
|
||||
// </DatiDDT>
|
||||
// Salvo la testata
|
||||
ok &= insert(paf0700f);
|
||||
|
||||
// <DatiRiepilogo>
|
||||
TPaf_record& paf2200f = _paf_container.get_paf("PAF2200F");
|
||||
const char* eiva = get_esigibilita_iva(doc);
|
||||
@ -2113,13 +2054,10 @@ bool TDoc_fp::doc_to_paf(TDocumentoEsteso& doc)
|
||||
for(TObject* itm = tiva.first_item(); itm != nullptr; itm = tiva.succ_item())
|
||||
{
|
||||
const TRiepilogo_iva& riva = *dynamic_cast<const TRiepilogo_iva*>(itm);
|
||||
|
||||
if (!check_riepilogo(doc, riva) && !fp_settings().get_check_not_block())
|
||||
return false;
|
||||
|
||||
add_riepilogo_iva(paf2200f, riva.cod_iva(), eiva, riva.imponibile(), riva.imposta());
|
||||
}
|
||||
|
||||
if(!_riepilogo_agg.empty())
|
||||
{
|
||||
for(auto i = _riepilogo_agg.begin(); i != _riepilogo_agg.end(); ++i)
|
||||
@ -2128,7 +2066,6 @@ bool TDoc_fp::doc_to_paf(TDocumentoEsteso& doc)
|
||||
add_riepilogo_iva(paf2200f, cod_iva, eiva);
|
||||
}
|
||||
}
|
||||
|
||||
// </DatiRiepilogo>
|
||||
// <DatiPagamento>
|
||||
TPaf_record& paf2400f = _paf_container.get_paf("PAF2400F");
|
||||
@ -2183,7 +2120,6 @@ bool TDoc_fp::doc_to_paf(TDocumentoEsteso& doc)
|
||||
long nprogr = 0; // Numero di file allegati
|
||||
// Se abilitato stampo il documento e lo allego
|
||||
TFilename rep;
|
||||
|
||||
if (_allegafattura)
|
||||
{
|
||||
if (!dongle().active(RSAUT))
|
||||
@ -2303,12 +2239,10 @@ bool TDoc_fp::doc_to_paf(const TFilename& ini)
|
||||
const TDoc_key key(anno, codnum, ndoc);
|
||||
return doc_to_paf(key);
|
||||
}
|
||||
|
||||
bool TDoc_fp::doc_to_paf()
|
||||
{
|
||||
return _doc_rec != nullptr ? doc_to_paf(*_doc_rec) : false;
|
||||
}
|
||||
|
||||
TRectype& TDoc_fp::key_to_doc(const TDoc_key& key)
|
||||
{
|
||||
if(_doc_rec != nullptr)
|
||||
@ -2320,8 +2254,7 @@ TRectype& TDoc_fp::key_to_doc(const TDoc_key& key)
|
||||
_doc_rec->put(DOC_NDOC, key.ndoc());
|
||||
return *_doc_rec;
|
||||
}
|
||||
|
||||
TDoc_fp::TDoc_fp() : _doc_rec(nullptr), _log(nullptr), _cache_insert(false), _rec_clifo(LF_CLIFO)
|
||||
TDoc_fp::TDoc_fp() : _doc_rec(nullptr), _log(nullptr), _cache_insert(false)
|
||||
{
|
||||
_ditta.init(LF_NDITTE, prefix().get_codditta());
|
||||
_cofi = fp_settings().get_cofi_tras();
|
||||
@ -2352,10 +2285,8 @@ TDoc_fp::TDoc_fp() : _doc_rec(nullptr), _log(nullptr), _cache_insert(false), _re
|
||||
_conai_str = ini_get_string(CONFIG_DITTA, "ve", "DESCCONAIASS");
|
||||
if (_conai_str.empty())
|
||||
_conai_str = "Contributo CONAI assolto ove dovuto";
|
||||
|
||||
_nascondi_sconti_righe_fatt = fp_settings().get_no_sconti_fatt();
|
||||
}
|
||||
|
||||
TDoc_fp::~TDoc_fp()
|
||||
{
|
||||
commit();
|
||||
|
@ -4,6 +4,9 @@
|
||||
#include <fpcart.h>
|
||||
#include <fpcadg.h>
|
||||
|
||||
/******************************************************************************
|
||||
* TFP_custom
|
||||
*******************************************************************************/
|
||||
|
||||
void TFP_custom::init()
|
||||
{
|
||||
@ -77,6 +80,78 @@ void TFP_custom::autoload(const TSheet_field& sf, const int file) const
|
||||
}
|
||||
}
|
||||
|
||||
bool TFP_custom::load_caus_paf(TPaf_record& paf3400f, TDocumento& doc, TDoc_fp& doc_fp) const
|
||||
{
|
||||
long row_paf = 0L;
|
||||
FOR_EACH_FPCAUS_ROW(*this, r, rec_caus)
|
||||
{
|
||||
if (TFP_expression::check_condition(rec_caus->get(FPCCAUS_COND), doc))
|
||||
{
|
||||
// Evito il reset visto che setto sempre i campi
|
||||
paf3400f.set("PZ_LINEA", ++row_paf);
|
||||
paf3400f.set("PZ_CAUSALE", TFP_expression::parse_expression(rec_caus->get(FPCCAUS_VALORE), doc));
|
||||
if (!doc_fp.insert(paf3400f))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TFP_custom::load_articolo_paf(TPaf_record& paf1900f, TRiga_documento& rdoc, const long row_num, TDoc_fp& doc_fp) const
|
||||
{
|
||||
long row_paf = 0L;
|
||||
FOR_EACH_FPART_ROW(*this, r, rec_art)
|
||||
{
|
||||
// Controllo se è abilitato
|
||||
if (TFP_expression::check_condition(rec_art->get(FPCART_COND), rdoc))
|
||||
{
|
||||
doc_fp.reset(paf1900f);
|
||||
paf1900f.set("PY_KEYNLINEA", row_num);
|
||||
paf1900f.set("PY_KEYNLINAR", ++row_paf);
|
||||
paf1900f.set("PY_TIPOARTICOLO", TFP_expression::parse_expression(rec_art->get(FPCART_TIPO), rdoc));
|
||||
paf1900f.set("PY_VALOREARTICOLO", TFP_expression::parse_expression(rec_art->get(FPCART_VALORE), rdoc));
|
||||
if (!doc_fp.insert(paf1900f))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TFP_custom::load_adg_paf(TPaf_record& paf2100f, TRiga_documento& rdoc, TDoc_fp& doc_fp, const long row_num, const bool split) const
|
||||
{
|
||||
FOR_EACH_FPADG_ROW(*this, r, rec_adg)
|
||||
{
|
||||
|
||||
if (split && !rec_adg->get_bool(FPCADG_SPLIT))
|
||||
continue;
|
||||
|
||||
// Controllo che la riga sia uguale e la condizione sia valida
|
||||
if (rdoc.tipo().codice() == rec_adg->get(FPCADG_TIPORIGA) && TFP_expression::check_condition(rec_adg->get(FPCADG_COND), rdoc))
|
||||
{
|
||||
doc_fp.reset(paf2100f);
|
||||
paf2100f.set("PK_KEYNLINEA", static_cast<long>(row_num));
|
||||
paf2100f.set("PK_KEYNLINAR", doc_fp._idx_adg_doc_row++);
|
||||
paf2100f.set("PK_TIPODATO", TFP_expression::parse_expression(rec_adg->get(FPCADG_TIPODATO), rdoc));
|
||||
paf2100f.set("PK_RIFDATO", TFP_expression::parse_expression(rec_adg->get(FPCADG_RTESTO), rdoc));
|
||||
paf2100f.set("PK_RIFDATA", TFP_expression::parse_expression(rec_adg->get(FPCADG_RDATA), rdoc));
|
||||
paf2100f.set("PK_RIFNUMERO", TFP_expression::parse_expression(rec_adg->get(FPCADG_RNUMERO), rdoc));
|
||||
if (!doc_fp.insert(paf2100f))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TFP_custom::has_adg_split()
|
||||
{
|
||||
FOR_EACH_FPADG_ROW(*this, r, rec_adg)
|
||||
{
|
||||
if (rec_adg->get_bool(FPCADG_SPLIT))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
TFP_custom::TFP_custom() : TMultiple_rectype(LF_FPCUST), _codcust(""), _loaded(false)
|
||||
{
|
||||
init();
|
||||
@ -95,7 +170,92 @@ TFP_custom::TFP_custom(const char* codcust) : TFP_custom()
|
||||
load(codcust);
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* TFP_custom_cache
|
||||
*******************************************************************************/
|
||||
|
||||
bool TFP_custom_cache::has_custom(const TDocumento& doc)
|
||||
{
|
||||
const long codcli = doc.clifor().codice();
|
||||
bool found = false;
|
||||
TRectype& rec_cli = doc.clifor();
|
||||
if(_cli_custom.find(codcli) != _cli_custom.end())
|
||||
{
|
||||
found = true;
|
||||
}
|
||||
// Prima cerco sul cliente
|
||||
else if(rec_cli.get(CLI_DISCUSTFP).full())
|
||||
{
|
||||
// Cliente disabilitato
|
||||
_cli_custom.insert(std::pair<long, TString>(codcli, ""));
|
||||
}
|
||||
else if(rec_cli.get(CLI_CODFPCUST).full())
|
||||
{
|
||||
// Cliente con personalizzazione
|
||||
_cli_custom.insert(std::pair<long, TString>(codcli, rec_cli.get(CLI_CODFPCUST)));
|
||||
found = true;
|
||||
}
|
||||
// Cerco nel tipo documento
|
||||
else if(doc.tipo().cod_cust_fp().full())
|
||||
{
|
||||
// Tipo doc personalizzato
|
||||
_cli_custom.insert(std::pair<long, TString>(codcli, doc.tipo().cod_cust_fp()));
|
||||
found = true;
|
||||
}
|
||||
// Customizzazione globale?
|
||||
else if(_global_custom != nullptr)
|
||||
{
|
||||
// Globale
|
||||
_cli_custom.insert(std::pair<long, TString>(codcli, _global_custom->get_codcust()));
|
||||
found = true;
|
||||
}
|
||||
|
||||
return found;
|
||||
}
|
||||
|
||||
TFP_custom& TFP_custom_cache::get_custom(const TDocumento& doc)
|
||||
{
|
||||
if(!has_custom(doc))
|
||||
{
|
||||
static TFP_custom null_cust;
|
||||
return null_cust;
|
||||
}
|
||||
|
||||
const TString& codcust = _cli_custom[doc.clifor().codice()];
|
||||
|
||||
// Provo a vedere se è già presente nella mappa, altrimento lo aggiungo
|
||||
if(_customs.find(codcust) == _customs.end())
|
||||
{
|
||||
TFP_custom custcli(codcust);
|
||||
_customs.insert(std::pair<TString, TFP_custom>(codcust, custcli));
|
||||
}
|
||||
|
||||
return _customs[codcust];
|
||||
}
|
||||
|
||||
TFP_custom_cache::TFP_custom_cache()
|
||||
{
|
||||
_customs.clear();
|
||||
_cli_custom.clear();
|
||||
|
||||
// Cerco se esiste una custom globale
|
||||
TLocalisamfile local_cust(LF_FPCUST);
|
||||
|
||||
for(int ok = local_cust.first(); ok == NOERR; ok = local_cust.next())
|
||||
{
|
||||
if(local_cust.get_bool(FPCUST_GLOBAL))
|
||||
{
|
||||
_global_custom.reset(new TFP_custom(local_cust.curr()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* TFP_expression
|
||||
*******************************************************************************/
|
||||
|
||||
/*
|
||||
* Sintassi:
|
||||
@ -158,6 +318,10 @@ const TVariant TFP_expression::parse_expression(const TString& expr, TRiga_docum
|
||||
|
||||
bool TFP_expression::check_condition(const TString& cond, TRiga_documento& rdoc)
|
||||
{
|
||||
// Caso base
|
||||
if (cond.empty())
|
||||
return true;
|
||||
|
||||
TString cond_sx, cond_dx;
|
||||
TFP_operator symb;
|
||||
split_condition(cond, cond_sx, cond_dx, symb);
|
||||
|
@ -23,4 +23,5 @@ Picture = <cg01>
|
||||
Module = fp
|
||||
Flags = ""
|
||||
Item_01 = "Configurazione", "fp0 -0", "", 10210
|
||||
Item_02 = "Inserimento riferimenti C/F", "fp0 -1", ""
|
||||
Item_02 = "Inserimento riferimenti C/F", "fp0 -1", ""
|
||||
Item_03 = "Personalizzazioni FP", "fp0 -4", ""
|
13
src/fp/sql/fp0110.sql
Normal file
13
src/fp/sql/fp0110.sql
Normal file
@ -0,0 +1,13 @@
|
||||
CREATE TABLE PAF3400F (
|
||||
PZ_KEYPRGINVIO CHAR(10) NOT NULL DEFAULT '' ,
|
||||
PZ_KEYHEADERFATT CHAR(20) NOT NULL DEFAULT '' ,
|
||||
PZ_KEYBODYFATT CHAR(50) NOT NULL DEFAULT '' ,
|
||||
PZ_LINEA NUMERIC(4, 0) NOT NULL DEFAULT 0 ,
|
||||
PZ_CAUSALE CHAR(200) NOT NULL DEFAULT '' ,
|
||||
PZ_DFILL CHAR(512) NOT NULL DEFAULT '' ,
|
||||
PZ_GESTIONE CHAR(1) NOT NULL DEFAULT '' ) ;
|
||||
|
||||
|
||||
CREATE INDEX PAF3400F_KEY
|
||||
ON PAF3400F (PZ_KEYPRGINVIO ASC , PZ_KEYHEADERFATT ASC , PZ_KEYBODYFATT ASC, PZ_LINEA ASC )
|
||||
;
|
Loading…
x
Reference in New Issue
Block a user