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 2: rt = fp0300(argc, argv); break; // Gestione fatture attive (PAA, Ex Fattura PA)
|
||||||
case 3: rt = fp0400(argc, argv); break; // Monitor fatture passive
|
case 3: rt = fp0400(argc, argv); break; // Monitor fatture passive
|
||||||
case 4: rt = fp0500(argc, argv); break; // Customizzazioni FP per utente
|
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
|
default: rt = fp0100(argc, argv); break; // Configurazione
|
||||||
}
|
}
|
||||||
return rt;
|
return rt;
|
||||||
|
@ -171,6 +171,6 @@ bool TFpcust::user_destroy()
|
|||||||
int fp0500(int argc, char* argv[])
|
int fp0500(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
TFpcust a;
|
TFpcust a;
|
||||||
a.run(argc, argv, TR("Lettere d'intento"));
|
a.run(argc, argv, TR("Personalizzazioni FP"));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
@ -14,6 +14,7 @@ BEGIN
|
|||||||
INPUT CODICE F_CODICE
|
INPUT CODICE F_CODICE
|
||||||
DISPLAY "Codice" CODICE
|
DISPLAY "Codice" CODICE
|
||||||
DISPLAY "Descrizione@50" DESCR
|
DISPLAY "Descrizione@50" DESCR
|
||||||
|
DISPLAY "Globale@7" GLOBAL
|
||||||
OUTPUT F_CODICE CODICE
|
OUTPUT F_CODICE CODICE
|
||||||
OUTPUT F_DESCR DESCR
|
OUTPUT F_DESCR DESCR
|
||||||
CHECKTYPE REQUIRED
|
CHECKTYPE REQUIRED
|
||||||
@ -39,7 +40,7 @@ BEGIN
|
|||||||
FIELD GLOBAL
|
FIELD GLOBAL
|
||||||
END
|
END
|
||||||
|
|
||||||
SPREADSHEET F_CAUSALI 60 6
|
SPREADSHEET F_CAUSALI 0 6
|
||||||
BEGIN
|
BEGIN
|
||||||
PROMPT 1 3 "Causale"
|
PROMPT 1 3 "Causale"
|
||||||
ITEM "Valore@50"
|
ITEM "Valore@50"
|
||||||
|
386
src/fp/fplib.h
386
src/fp/fplib.h
@ -12,69 +12,15 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <cg2103.h>
|
#include <cg2103.h>
|
||||||
|
#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"
|
||||||
|
|
||||||
class TFPRiga_documento;
|
|
||||||
|
|
||||||
// Typedef per aiutare a capire cosa sono le chiavi
|
// Typedef per aiutare a capire cosa sono le chiavi
|
||||||
typedef TString MCodice_riga;
|
typedef TString MCodice_riga;
|
||||||
typedef TString MTipo_documento;
|
typedef TString MTipo_documento;
|
||||||
|
class TDoc_fp;
|
||||||
// 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();
|
|
||||||
};
|
|
||||||
|
|
||||||
enum { no_pdf = -1, pdf_ok = 0, no_alleg = -2};
|
enum { no_pdf = -1, pdf_ok = 0, no_alleg = -2};
|
||||||
|
|
||||||
@ -163,130 +109,25 @@ public:
|
|||||||
TPaf_container();
|
TPaf_container();
|
||||||
};
|
};
|
||||||
|
|
||||||
// Gestione PAF
|
class TFP_nota_piede_f
|
||||||
class TDoc_fp : public TObject
|
|
||||||
{
|
{
|
||||||
private:
|
std::map<TString, TString> _nota_piede_fattura;
|
||||||
TRectype* _doc_rec;
|
bool _loaded;
|
||||||
TRectype _rec_clifo;
|
TToken_string _tipi_doc; // Array di stringhe dei tipi doc caricati (per capire se ne elimino)
|
||||||
TAnagrafica _ditta;
|
const TString _null_string;
|
||||||
TString16 _cofi;
|
static void write_ini_npf(const TString& tipodoc, TToken_string& msg); // Salva sul file ini la n.p.f. di quel tipodoc
|
||||||
TFilename _dbname;
|
static void delete_ini_npf(const TString& tipodoc); // Rimuove i tipidoc in eccesso (quando si modifica lo spreadsheet)
|
||||||
TLog_report* _log;
|
static TString get_ini_npf(const TString& tipodoc); // Legge dal file ini e restituisce la n.p.f. di quel tipodoc
|
||||||
TString _logpaf;
|
void get_load(); // Carica la mappa
|
||||||
bool _gestioneallegati;
|
void save_npf_spredsheet(TSheet_field& sheet_field);
|
||||||
bool _allegafattura;
|
void save_new_tipidoc(TSheet_field& sheet_field);
|
||||||
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);
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
bool doc_to_paf(TDocumentoEsteso& doc);
|
void load_sheet(TSheet_field& sheet_field);
|
||||||
bool doc_to_paf(const TRectype& rec);
|
void save_sheet(TSheet_field& sheet_field);
|
||||||
bool doc_to_paf(const TDoc_key& key);
|
const TString& get_nota_piede(const TString& tipo_doc);
|
||||||
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();
|
TFP_nota_piede_f();
|
||||||
~TDoc_fp();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class TFP_settings : public TObject
|
class TFP_settings : public TObject
|
||||||
@ -354,6 +195,39 @@ inline TFP_settings& fp_settings()
|
|||||||
return *erbuggo;
|
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
|
class TFP_selected_docs : public TObject
|
||||||
{
|
{
|
||||||
TRelation _r_tabmod;
|
TRelation _r_tabmod;
|
||||||
@ -460,8 +334,16 @@ protected:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
bool set_codcust(const char* codcust, const bool to_load) { return to_load ? load(codcust) : _codcust = codcust; }
|
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;
|
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();
|
TFP_custom();
|
||||||
explicit TFP_custom(const TRectype& rec);
|
explicit TFP_custom(const TRectype& rec);
|
||||||
explicit TFP_custom(const char* codcust);
|
explicit TFP_custom(const char* codcust);
|
||||||
@ -479,6 +361,27 @@ public:
|
|||||||
TRecord_array& bodyof##__radg = (__fpcust).body(LF_FPCADG); \
|
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))
|
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
|
class TFP_expression : public TObject
|
||||||
{
|
{
|
||||||
@ -499,10 +402,141 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
static const TVariant parse_expression(const TString& expr, TRiga_documento& rdoc);
|
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, TRiga_documento& rdoc);
|
||||||
|
static bool check_condition(const TString& cond, TDocumento& doc) { return check_condition(cond, doc[1]); }
|
||||||
|
|
||||||
TFP_expression() = default;
|
TFP_expression() = default;
|
||||||
virtual ~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
|
#endif // __FPLIB_H
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
#include "../cg/cfban.h"
|
#include "../cg/cfban.h"
|
||||||
#include <modaut.h>
|
#include <modaut.h>
|
||||||
#include <urldefid.h>
|
#include <urldefid.h>
|
||||||
|
|
||||||
bool set_connection(SSimple_query& s)
|
bool set_connection(SSimple_query& s)
|
||||||
{
|
{
|
||||||
bool ok = true;
|
bool ok = true;
|
||||||
@ -52,7 +51,6 @@ bool set_connection(SSimple_query& s)
|
|||||||
#endif
|
#endif
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
SSimple_query& fp_db()
|
SSimple_query& fp_db()
|
||||||
{
|
{
|
||||||
static SSimple_query* db = nullptr;
|
static SSimple_query* db = nullptr;
|
||||||
@ -65,7 +63,6 @@ SSimple_query& fp_db()
|
|||||||
}
|
}
|
||||||
return *db;
|
return *db;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool run_fp_psw_mask()
|
bool run_fp_psw_mask()
|
||||||
{
|
{
|
||||||
static TMask* m;
|
static TMask* m;
|
||||||
@ -89,7 +86,6 @@ bool run_fp_psw_mask()
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
string getline(ifstream& f)
|
string getline(ifstream& f)
|
||||||
{
|
{
|
||||||
string app;
|
string app;
|
||||||
@ -239,31 +235,25 @@ const TString& tipo_doc_sdi(const TDocumento& doc)
|
|||||||
{
|
{
|
||||||
static TString tipo_doc_sdi;
|
static TString tipo_doc_sdi;
|
||||||
tipo_doc_sdi.cut(0) << doc.get(DOC_TIPODOCSDI);
|
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
|
// 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"))
|
if (tipo_doc_sdi.len() == 4 && tipo_doc_sdi.starts_with("TD"))
|
||||||
{
|
{
|
||||||
return tipo_doc_sdi;
|
return tipo_doc_sdi;
|
||||||
}
|
}
|
||||||
|
|
||||||
return doc.tipo().tipo_doc_sdi();
|
return doc.tipo().tipo_doc_sdi();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool is_fattura(const TRectype& doc)
|
bool is_fattura(const TRectype& doc)
|
||||||
{
|
{
|
||||||
const TTipo_documento& td = cached_tipodoc(doc.get(DOC_TIPODOC));
|
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
|
if (!td.is_fattura()) // Tengo per buone solo le fatture e le note di credito
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
const TCodice_numerazione& cn = cached_numerazione(doc.get(DOC_CODNUM));
|
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.
|
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& add_filter(const TString& field, const TString& from, const TString& to)
|
||||||
{
|
{
|
||||||
TString& query = get_tmp_string();
|
TString& query = get_tmp_string();
|
||||||
const TString qf = field.find('.') < 0 ? field : field.sub(field.find('.') + 1);
|
const TString qf = field.find('.') < 0 ? field : field.sub(field.find('.') + 1);
|
||||||
|
|
||||||
if (from.full() && to.full())
|
if (from.full() && to.full())
|
||||||
{
|
{
|
||||||
query << "&&(BETWEEN(" << field << ", #DA" << qf << ", #A" << qf << "))";
|
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 << ")";
|
query << "&&(" << field << "<=#A" << qf << ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
return query;
|
return query;
|
||||||
}
|
}
|
||||||
|
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
* TPaf_record
|
* 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);
|
CHECKS(!_key.empty_items(), "Invalid primary key for table ", table);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////
|
||||||
// TPaf_container
|
// TPaf_container
|
||||||
////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////
|
||||||
|
|
||||||
bool TPaf_container::clean_and_erase_paf(const TString& hfatt, const TString& bfatt)
|
bool TPaf_container::clean_and_erase_paf(const TString& hfatt, const TString& bfatt)
|
||||||
{
|
{
|
||||||
bool ok = true;
|
bool ok = true;
|
||||||
@ -511,17 +497,14 @@ 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)
|
||||||
paf.reset();
|
paf.reset();
|
||||||
|
|
||||||
const char * prefix = paf_to_prefix(paf.get_table());
|
const char * prefix = paf_to_prefix(paf.get_table());
|
||||||
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;
|
||||||
@ -568,16 +551,16 @@ const char* TPaf_container::paf_to_prefix(const char * paf)
|
|||||||
return "PT";
|
return "PT";
|
||||||
if (paf_name == "PAF3200F")
|
if (paf_name == "PAF3200F")
|
||||||
return "PU";
|
return "PU";
|
||||||
|
if (paf_name == "PAF3400F")
|
||||||
|
return "PZ";
|
||||||
if (paf_name == "PAFW300F")
|
if (paf_name == "PAFW300F")
|
||||||
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")));
|
||||||
@ -621,10 +604,11 @@ TPaf_container::TPaf_container()
|
|||||||
_pafs.insert(std::pair<const char *, TPaf_record>("PAF3000F", TPaf_record("PAF3000F")));
|
_pafs.insert(std::pair<const char *, TPaf_record>("PAF3000F", TPaf_record("PAF3000F")));
|
||||||
// PEC
|
// PEC
|
||||||
_pafs.insert(std::pair<const char *, TPaf_record>("PAF3200F", TPaf_record("PAF3200F")));
|
_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
|
// 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
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
@ -710,7 +694,6 @@ 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;
|
||||||
@ -751,7 +734,6 @@ 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
|
||||||
{
|
{
|
||||||
@ -781,7 +763,6 @@ 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))
|
||||||
@ -801,7 +782,6 @@ 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);
|
||||||
@ -899,38 +879,31 @@ bool TDoc_fp::save_paf()
|
|||||||
}
|
}
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TDoc_fp::check_initial(TDocumentoEsteso& doc)
|
bool TDoc_fp::check_initial(TDocumentoEsteso& doc)
|
||||||
{
|
{
|
||||||
bool ok = true;
|
bool ok = true;
|
||||||
static TString msg;
|
static TString msg;
|
||||||
|
|
||||||
if (_coddest.len() != 6 && _coddest.len() != 7)
|
if (_coddest.len() != 6 && _coddest.len() != 7)
|
||||||
{
|
{
|
||||||
log(1, "Il codice destinatario ha una lunghezza non conforme.");
|
log(1, "Il codice destinatario ha una lunghezza non conforme.");
|
||||||
ok = false;
|
ok = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_rec_clifo.get(CLI_PAIV).empty() && _rec_clifo.get(CLI_COFI).empty())
|
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.");
|
log(1, "Sia la partita IVA che il codice fiscale del cessionario committente sono vuoti, almeno uno dei due deve essere valorizzato.");
|
||||||
ok = false;
|
ok = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
TPagamento& pag = doc.pagamento();
|
TPagamento& pag = doc.pagamento();
|
||||||
if(pag.cond_pag_sdi().empty())
|
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();
|
msg.cut(0) << "Non e' valorizzata la condizione di pagamento SDI (TP01, TP02, TP03) per la condizione di pagamento " << pag.code();
|
||||||
log(1, msg);
|
log(1, msg);
|
||||||
ok = false;
|
ok = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int nr = 0; nr < doc.scadenze().items(); nr++)
|
for (int nr = 0; nr < doc.scadenze().items(); nr++)
|
||||||
{
|
{
|
||||||
const int rp = nr < pag.n_rate() ? nr : 0;
|
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);
|
static TString key_class; key_class.cut(0) << pag.tipo_rata(rp) << pag.ulc_rata(rp);
|
||||||
|
|
||||||
if(cache().get("%CLR", key_class, "S12").empty())
|
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();
|
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;
|
ok = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
||||||
static TString msg;
|
static TString msg;
|
||||||
|
|
||||||
if(rdoc.is_spese())
|
if(rdoc.is_spese())
|
||||||
{
|
{
|
||||||
const TSpesa_prest& spesa = rdoc.spesa();
|
const TSpesa_prest& spesa = rdoc.spesa();
|
||||||
@ -956,7 +926,6 @@ bool TDoc_fp::check_row(const TRiga_documento& rdoc)
|
|||||||
log(1, msg);
|
log(1, msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const TCodiceIVA& codice_iva = rdoc.iva();
|
const TCodiceIVA& codice_iva = rdoc.iva();
|
||||||
if (codice_iva.codice().full() && codice_iva.percentuale() == ZERO && codice_iva.natura().empty())
|
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);
|
log(1, msg);
|
||||||
ok = false;
|
ok = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
||||||
static TString msg;
|
static TString msg;
|
||||||
|
|
||||||
if(*get_esigibilita_iva(doc) == 'S' && riva.cod_iva().natura() == "N6")
|
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();
|
msg.cut(0) << "Impossibile avere un documento con scissione dei pagamenti e natura iva N6, codice: " << riva.cod_iva().codice();
|
||||||
log(1, msg);
|
log(1, msg);
|
||||||
ok = false;
|
ok = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TDoc_fp::initialize(TDocumentoEsteso& doc)
|
bool TDoc_fp::initialize(TDocumentoEsteso& doc)
|
||||||
{
|
{
|
||||||
// Azzero
|
// Azzero
|
||||||
_hfatt.cut(0);
|
_hfatt.cut(0);
|
||||||
_bfatt.cut(0);
|
_bfatt.cut(0);
|
||||||
|
|
||||||
// Preparo il record del cliente
|
// 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
|
// Valorizzo la gestione del cambio
|
||||||
_doc_cambio._cod_val = doc.valuta();
|
_doc_cambio._cod_val = doc.valuta();
|
||||||
_doc_cambio._is_valuta_estera = doc.valuta().full() && !is_euro_value(doc.valuta());
|
_doc_cambio._is_valuta_estera = doc.valuta().full() && !is_euro_value(doc.valuta());
|
||||||
_doc_cambio._cambio = doc.cambio();
|
_doc_cambio._cambio = doc.cambio();
|
||||||
|
|
||||||
// Paese del documento
|
// Paese del documento
|
||||||
_paese = "IT";
|
_paese = "IT";
|
||||||
|
|
||||||
_has_bolla = false;
|
_has_bolla = false;
|
||||||
if (!chiave_paf(doc, _hfatt, _bfatt))
|
if (!chiave_paf(doc, _hfatt, _bfatt))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Preparo il log
|
// Preparo il log
|
||||||
log(-1, _bfatt);
|
log(-1, _bfatt);
|
||||||
|
|
||||||
#ifndef DBG
|
#ifndef DBG
|
||||||
// Controllo se il documento è almeno in stato di stampa
|
// Controllo se il documento è almeno in stato di stampa
|
||||||
if (doc.stato() < doc.tipo().stato_finale_stampa())
|
if (doc.stato() < doc.tipo().stato_finale_stampa())
|
||||||
@ -1015,7 +973,6 @@ bool TDoc_fp::initialize(TDocumentoEsteso& doc)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef DBG
|
#ifndef DBG
|
||||||
_is_pa = doc.clifor().get_int("ALLEG") == 7;
|
_is_pa = doc.clifor().get_int("ALLEG") == 7;
|
||||||
if (!get_coddest(doc.clifor().tipo(), doc.clifor().codice(), _coddest, _pec))
|
if (!get_coddest(doc.clifor().tipo(), doc.clifor().codice(), _coddest, _pec))
|
||||||
@ -1027,12 +984,9 @@ bool TDoc_fp::initialize(TDocumentoEsteso& doc)
|
|||||||
_is_pa = true;
|
_is_pa = true;
|
||||||
_coddest = "WSUHKZ";
|
_coddest = "WSUHKZ";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
_enapec = _coddest == "0000000" && _pec.full();
|
_enapec = _coddest == "0000000" && _pec.full();
|
||||||
_privato = _coddest.len() != 6;
|
_privato = _coddest.len() != 6;
|
||||||
|
|
||||||
_caus = TCausale(doc.tipo().causale(), doc.anno());
|
_caus = TCausale(doc.tipo().causale(), doc.anno());
|
||||||
|
|
||||||
// Preparo il codice iva di default
|
// Preparo il codice iva di default
|
||||||
{
|
{
|
||||||
FOR_EACH_PHYSICAL_RDOC(doc, r, rdoc)
|
FOR_EACH_PHYSICAL_RDOC(doc, r, rdoc)
|
||||||
@ -1042,19 +996,16 @@ bool TDoc_fp::initialize(TDocumentoEsteso& doc)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Azzero indici
|
// Azzero indici
|
||||||
_idx_cassa_previdenziale = 1;
|
_idx_cassa_previdenziale = 1;
|
||||||
|
// Controllo custom
|
||||||
|
_has_cust = cached_custom_fp().has_custom(doc);
|
||||||
if(check_initial(doc) || fp_settings().get_check_not_block())
|
if(check_initial(doc) || fp_settings().get_check_not_block())
|
||||||
{
|
{
|
||||||
return _paf_container.clean_and_erase_paf(_hfatt, _bfatt);
|
return _paf_container.clean_and_erase_paf(_hfatt, _bfatt);
|
||||||
}
|
}
|
||||||
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;
|
||||||
@ -1108,7 +1059,6 @@ bool TDoc_fp::show_log()
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int TDoc_fp::commit()
|
int TDoc_fp::commit()
|
||||||
{
|
{
|
||||||
int r = 0;
|
int r = 0;
|
||||||
@ -1132,7 +1082,6 @@ int TDoc_fp::commit()
|
|||||||
{
|
{
|
||||||
log(2, "Le fatture sono state esportate in stato diagnosticato");
|
log(2, "Le fatture sono state esportate in stato diagnosticato");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(r >= 0 && fp_db().sq_commit())
|
if(r >= 0 && fp_db().sq_commit())
|
||||||
{
|
{
|
||||||
r += 2;
|
r += 2;
|
||||||
@ -1147,18 +1096,15 @@ int TDoc_fp::commit()
|
|||||||
_to_commit = false;
|
_to_commit = false;
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
int TDoc_fp::force_commit()
|
int TDoc_fp::force_commit()
|
||||||
{
|
{
|
||||||
_to_commit = true;
|
_to_commit = true;
|
||||||
return commit();
|
return commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* TDoc_fp::natura(const TString& codiva)
|
const char* TDoc_fp::natura(const TString& codiva)
|
||||||
{
|
{
|
||||||
return cache().get("%IVA", codiva, "S12");
|
return cache().get("%IVA", codiva, "S12");
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
||||||
@ -1167,20 +1113,16 @@ const char* TDoc_fp::get_esigibilita_iva(const TDocumentoEsteso& doc)
|
|||||||
eiva = "S";
|
eiva = "S";
|
||||||
else if (doc.get_bool(DOC_LIQDIFF) || doc.get_bool(DOC_IVAXCASSA))
|
else if (doc.get_bool(DOC_LIQDIFF) || doc.get_bool(DOC_IVAXCASSA))
|
||||||
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())
|
||||||
codiva = _codivadefault;
|
codiva = _codivadefault;
|
||||||
|
|
||||||
// É necessario il cast a real?
|
// É necessario il cast a real?
|
||||||
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);
|
||||||
@ -1228,34 +1170,28 @@ 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
|
||||||
paf1800f.set("PI_UNITAMISURA", rdoc->get(RDOC_UMQTA));
|
paf1800f.set("PI_UNITAMISURA", rdoc->get(RDOC_UMQTA));
|
||||||
|
|
||||||
const real qta = rdoc->quantita();
|
const real qta = rdoc->quantita();
|
||||||
// Prendendo la stringa non ho problemi in scrittura della query, a volte accadono cose stupide
|
// Prendendo la stringa non ho problemi in scrittura della query, a volte accadono cose stupide
|
||||||
TString& qta_string = rdoc->quantita_string();
|
TString& qta_string = rdoc->quantita_string();
|
||||||
real prezzo_unit = rdoc->prezzo(_nascondi_sconti_righe_fatt, false);
|
real prezzo_unit = rdoc->prezzo(_nascondi_sconti_righe_fatt, false);
|
||||||
real prezzo_tot = rdoc->imponibile(false);
|
real prezzo_tot = rdoc->imponibile(false);
|
||||||
|
|
||||||
if(qta < ZERO)
|
if(qta < ZERO)
|
||||||
{
|
{
|
||||||
// Metto la qualità senza il segno
|
// Metto la qualità senza il segno
|
||||||
qta_string = qta_string.mid(1);
|
qta_string = qta_string.mid(1);
|
||||||
|
|
||||||
// E i prezzi in negativo
|
// E i prezzi in negativo
|
||||||
prezzo_unit = -abs(prezzo_unit);
|
prezzo_unit = -abs(prezzo_unit);
|
||||||
prezzo_tot = -abs(prezzo_tot);
|
prezzo_tot = -abs(prezzo_tot);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Salvo tutto
|
// Salvo tutto
|
||||||
paf1800f.set("PI_QUANTITA", qta_string);
|
paf1800f.set("PI_QUANTITA", qta_string);
|
||||||
paf1800f.set("PI_PREZZOUNIT", converti_prezzo(prezzo_unit));
|
paf1800f.set("PI_PREZZOUNIT", converti_prezzo(prezzo_unit));
|
||||||
paf1800f.set("PI_PRZTOTALE", converti_prezzo(prezzo_tot));
|
paf1800f.set("PI_PRZTOTALE", converti_prezzo(prezzo_tot));
|
||||||
}
|
}
|
||||||
|
|
||||||
const real calc_ritenuta(const TDocumento& doc)
|
const real calc_ritenuta(const TDocumento& doc)
|
||||||
{
|
{
|
||||||
real imponibile_prestazioni = ZERO;
|
real imponibile_prestazioni = ZERO;
|
||||||
@ -1275,30 +1211,24 @@ const real calc_ritenuta(const TDocumento& doc)
|
|||||||
imponibile += imponibile * rdoc->spesa().perc() / CENTO;
|
imponibile += imponibile * rdoc->spesa().perc() / CENTO;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return imponibile;
|
return imponibile;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TDoc_fp::add_ritenuta(const TDocumentoEsteso& doc, const TSpesa_prest& sp, TPaf_record& paf0700f) const
|
void TDoc_fp::add_ritenuta(const TDocumentoEsteso& doc, const TSpesa_prest& sp, TPaf_record& paf0700f) const
|
||||||
{
|
{
|
||||||
// <DatiRitenuta>
|
// <DatiRitenuta>
|
||||||
paf0700f.set("P7_TIPORITENUTA", _rec_clifo.get_char(CLI_TIPOPERS) == 'F' ? "RT01" : "RT02");
|
paf0700f.set("P7_TIPORITENUTA", _rec_clifo.get_char(CLI_TIPOPERS) == 'F' ? "RT01" : "RT02");
|
||||||
TString doc_imponibile = doc.imponibile().string();
|
TString doc_imponibile = doc.imponibile().string();
|
||||||
|
|
||||||
paf0700f.set("P7_IMPORTORIT", converti_prezzo(doc.ritenute()));
|
paf0700f.set("P7_IMPORTORIT", converti_prezzo(doc.ritenute()));
|
||||||
paf0700f.set("P7_ALIQUOTARIT", sp.perc());
|
paf0700f.set("P7_ALIQUOTARIT", sp.perc());
|
||||||
static TString caus_la; caus_la.cut(0);
|
static TString caus_la; caus_la.cut(0);
|
||||||
caus_la << sp.get("S14");
|
caus_la << sp.get("S14");
|
||||||
|
|
||||||
if (caus_la.empty())
|
if (caus_la.empty())
|
||||||
{
|
{
|
||||||
caus_la << sp.rec_caus_770().get("S2");
|
caus_la << sp.rec_caus_770().get("S2");
|
||||||
}
|
}
|
||||||
|
|
||||||
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,
|
bool TDoc_fp::add_riepilogo_iva(TPaf_record& paf2200f, const TCodiceIVA& cod_iva, const char* eiva, const real& imponibile,
|
||||||
const real& imposta)
|
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 real aliquota = cod_iva.percentuale();
|
||||||
const TString& cod_aliquota = cod_iva.codice();
|
const TString& cod_aliquota = cod_iva.codice();
|
||||||
TRiepilogo_agg& riepilogo_agg = _riepilogo_agg[cod_aliquota];
|
TRiepilogo_agg& riepilogo_agg = _riepilogo_agg[cod_aliquota];
|
||||||
|
|
||||||
// Aliquota
|
// Aliquota
|
||||||
paf2200f.set("PL_ALIQUOTAIVA", aliquota);
|
paf2200f.set("PL_ALIQUOTAIVA", aliquota);
|
||||||
|
|
||||||
// Natura
|
// Natura
|
||||||
if (aliquota.is_zero())
|
if (aliquota.is_zero())
|
||||||
paf2200f.set("PL_NATURA", natura(cod_aliquota));
|
paf2200f.set("PL_NATURA", natura(cod_aliquota));
|
||||||
|
|
||||||
// Imponibile
|
// Imponibile
|
||||||
paf2200f.set("PL_IMPONIBILE", converti_prezzo(imponibile + riepilogo_agg.imponibile));
|
paf2200f.set("PL_IMPONIBILE", converti_prezzo(imponibile + riepilogo_agg.imponibile));
|
||||||
|
|
||||||
// Imposta
|
// Imposta
|
||||||
paf2200f.set("PL_IMPOSTA", converti_prezzo(imposta + riepilogo_agg.imposta));
|
paf2200f.set("PL_IMPOSTA", converti_prezzo(imposta + riepilogo_agg.imposta));
|
||||||
|
|
||||||
// Esigibilità IVA
|
// Esigibilità IVA
|
||||||
paf2200f.set("PL_ESIGIVA", eiva);
|
paf2200f.set("PL_ESIGIVA", eiva);
|
||||||
if (*eiva == 'S')
|
if (*eiva == 'S')
|
||||||
paf2200f.set("PL_RIFNORMATIVO", "Scissione pagamenti art.17-ter DPR 633/72");
|
paf2200f.set("PL_RIFNORMATIVO", "Scissione pagamenti art.17-ter DPR 633/72");
|
||||||
else
|
else
|
||||||
paf2200f.set("PL_RIFNORMATIVO", cod_iva.descrizione());
|
paf2200f.set("PL_RIFNORMATIVO", cod_iva.descrizione());
|
||||||
|
|
||||||
paf2200f.set("PL_GESTIONE", "D");
|
paf2200f.set("PL_GESTIONE", "D");
|
||||||
|
|
||||||
// Elimino l'oggetto
|
// Elimino l'oggetto
|
||||||
_riepilogo_agg.erase(cod_aliquota);
|
_riepilogo_agg.erase(cod_aliquota);
|
||||||
|
|
||||||
// Inserisco
|
// Inserisco
|
||||||
return insert(paf2200f);
|
return insert(paf2200f);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TDoc_fp::add_cassa_previdenziale(TRiga_documento& rdoc)
|
bool TDoc_fp::add_cassa_previdenziale(TRiga_documento& rdoc)
|
||||||
{
|
{
|
||||||
TPaf_record& paf0800f = _paf_container.get_paf("PAF0800F");
|
TPaf_record& paf0800f = _paf_container.get_paf("PAF0800F");
|
||||||
reset(paf0800f);
|
reset(paf0800f);
|
||||||
paf0800f.set("P8_RIFNUMLINEA", _idx_cassa_previdenziale++);
|
paf0800f.set("P8_RIFNUMLINEA", _idx_cassa_previdenziale++);
|
||||||
|
|
||||||
// Resto
|
// Resto
|
||||||
const TSpesa_prest& sp = rdoc.spesa();
|
const TSpesa_prest& sp = rdoc.spesa();
|
||||||
const real imponibile_ritenuta = rdoc.doc().ritenute();//calc_ritenuta(rdoc.doc());
|
const real imponibile_ritenuta = rdoc.doc().ritenute();//calc_ritenuta(rdoc.doc());
|
||||||
const real importo_cassa = imponibile_ritenuta * sp.perc() / CENTO;
|
const real importo_cassa = imponibile_ritenuta * sp.perc() / CENTO;
|
||||||
|
|
||||||
paf0800f.set("P8_TIPOCASSA", sp.cassa_previdenziale());
|
paf0800f.set("P8_TIPOCASSA", sp.cassa_previdenziale());
|
||||||
// Aliquota della cassa
|
// Aliquota della cassa
|
||||||
paf0800f.set("P8_ALIQCASSA", sp.perc());
|
paf0800f.set("P8_ALIQCASSA", sp.perc());
|
||||||
@ -1360,20 +1280,65 @@ bool TDoc_fp::add_cassa_previdenziale(TRiga_documento& rdoc)
|
|||||||
if(sp.sogg_a_rit())
|
if(sp.sogg_a_rit())
|
||||||
paf0800f.set("P8_RITENUTA", "SI");
|
paf0800f.set("P8_RITENUTA", "SI");
|
||||||
paf0800f.set("P8_NATURA", rdoc.iva().natura());
|
paf0800f.set("P8_NATURA", rdoc.iva().natura());
|
||||||
|
|
||||||
// Inserisco il tutto nei dati riepilogo
|
// Inserisco il tutto nei dati riepilogo
|
||||||
TRiepilogo_agg& pop = _riepilogo_agg[rdoc.iva().codice()];
|
TRiepilogo_agg& pop = _riepilogo_agg[rdoc.iva().codice()];
|
||||||
pop.imponibile += importo_cassa;
|
pop.imponibile += importo_cassa;
|
||||||
pop.imposta += importo_cassa * rdoc.iva().percentuale() / CENTO;
|
pop.imposta += importo_cassa * rdoc.iva().percentuale() / CENTO;
|
||||||
|
|
||||||
return insert(paf0800f);
|
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()
|
const TFirm& TDoc_fp::get_firm()
|
||||||
{
|
{
|
||||||
return prefix().firm();
|
return prefix().firm();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TDoc_fp::export_paf0100f()
|
bool TDoc_fp::export_paf0100f()
|
||||||
{
|
{
|
||||||
// <DatiTrassmissione>
|
// <DatiTrassmissione>
|
||||||
@ -1393,7 +1358,6 @@ 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)
|
||||||
@ -1404,19 +1368,15 @@ bool TDoc_fp::export_paf3200f()
|
|||||||
// </Datipec>
|
// </Datipec>
|
||||||
return insert(paf3200f);
|
return insert(paf3200f);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TDoc_fp::doc_to_paf(TDocumentoEsteso& doc)
|
bool TDoc_fp::doc_to_paf(TDocumentoEsteso& doc)
|
||||||
{
|
{
|
||||||
if (!initialize(doc))
|
if (!initialize(doc))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
bool ok = true;
|
bool ok = true;
|
||||||
|
|
||||||
ok &= export_paf0100f();
|
ok &= export_paf0100f();
|
||||||
|
|
||||||
#ifndef DBG
|
#ifndef DBG
|
||||||
ok &= export_paf3200f();
|
ok &= export_paf3200f();
|
||||||
#endif
|
#endif
|
||||||
@ -1486,10 +1446,15 @@ bool TDoc_fp::doc_to_paf(TDocumentoEsteso& doc)
|
|||||||
// <CessionarioCommittente>
|
// <CessionarioCommittente>
|
||||||
TPaf_record& paf0400f = _paf_container.get_paf("PAF0400F");
|
TPaf_record& paf0400f = _paf_container.get_paf("PAF0400F");
|
||||||
#ifndef DBG
|
#ifndef DBG
|
||||||
|
// Per soggetti non italiani con solo codice fiscale va messo lo stato e il codice fiscale
|
||||||
if (cliente.partita_IVA().full())
|
if (cliente.partita_IVA().full())
|
||||||
{
|
{
|
||||||
paf0400f.set("P4_FISCIVAPAESE", cliente.stato_partita_IVA());
|
paf0400f.set("P4_FISCIVAPAESE", cliente.stato_partita_IVA());
|
||||||
paf0400f.set("P4_FISCIVACOD", cliente.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());
|
paf0400f.set("P4_CODFISC", cliente.codice_fiscale());
|
||||||
#else
|
#else
|
||||||
@ -1505,7 +1470,6 @@ bool TDoc_fp::doc_to_paf(TDocumentoEsteso& doc)
|
|||||||
{
|
{
|
||||||
paf0400f.set("P4_ANADENOM", cliente.ragione_sociale());
|
paf0400f.set("P4_ANADENOM", cliente.ragione_sociale());
|
||||||
}
|
}
|
||||||
|
|
||||||
// DatiSede
|
// DatiSede
|
||||||
paf0400f.set("P4_SEDEIND", cliente.via_residenza());
|
paf0400f.set("P4_SEDEIND", cliente.via_residenza());
|
||||||
paf0400f.set("P4_SEDENRCIVICO", cliente.civico_residenza().left(8));
|
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_SEDECAP", cliente.CAP_residenza());
|
||||||
paf0400f.set("P4_SEDEPROV", cliente.provincia_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");
|
paf0400f.set("P4_GESTIONE", "D");
|
||||||
ok &= insert(paf0400f);
|
ok &= insert(paf0400f);
|
||||||
// </CessionarioCommittente>
|
// </CessionarioCommittente>
|
||||||
@ -1546,34 +1515,39 @@ bool TDoc_fp::doc_to_paf(TDocumentoEsteso& doc)
|
|||||||
// Nel dubbio risetto
|
// Nel dubbio risetto
|
||||||
doc.put("ADDBOLLI", set_bollo);
|
doc.put("ADDBOLLI", set_bollo);
|
||||||
// </DatiBollo>
|
// </DatiBollo>
|
||||||
|
|
||||||
// <DatiCassaPrevidenziale>
|
// <DatiCassaPrevidenziale>
|
||||||
// Non la mettiamo!
|
// Non la mettiamo!
|
||||||
// </DatiCassaPrevidenziale>
|
// </DatiCassaPrevidenziale>
|
||||||
|
|
||||||
// Non inserisco più adesso il paf0700f ma lo faccio alla fine (per inserire le ritenute)
|
// 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
|
* Lo sconto in testata è stato disabilitato in quanto su Campo influenza solo le righe merci mentre dovrebbe modificare tutte le righe
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// <DatiGenerali>
|
// <DatiGenerali>
|
||||||
TPaf_record& paf2700f = _paf_container.get_paf("PAF2700F");
|
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.
|
// 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.
|
// 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());
|
paf2700f.set("PQ_IMPTOTDOC", doc.totale_doc());
|
||||||
const TRectype& cont_conv_off = cco(doc);
|
const TRectype& cont_conv_off = cco(doc);
|
||||||
TString causale = cont_conv_off.get("S1");
|
if(_has_cust)
|
||||||
if (causale.full())
|
|
||||||
{
|
{
|
||||||
|
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("S2");
|
||||||
causale << ' ' << cont_conv_off.get("S3");
|
causale << ' ' << cont_conv_off.get("S3");
|
||||||
causale.strip_double_spaces();
|
causale.strip_double_spaces();
|
||||||
causale.cut(200);
|
causale.cut(200);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
causale = doc.tipo().descrizione();
|
causale = doc.tipo().descrizione();
|
||||||
paf2700f.set("PQ_CAUSALE", causale);
|
paf2700f.set("PQ_CAUSALE", causale);
|
||||||
|
}
|
||||||
// paf2700f.set("PQ_ART73", true);
|
// paf2700f.set("PQ_ART73", true);
|
||||||
paf2700f.set("PQ_GESTIONE", "D");
|
paf2700f.set("PQ_GESTIONE", "D");
|
||||||
ok &= insert(paf2700f);
|
ok &= insert(paf2700f);
|
||||||
@ -1655,16 +1629,12 @@ bool TDoc_fp::doc_to_paf(TDocumentoEsteso& doc)
|
|||||||
TPaf_record& paf3000f = _paf_container.get_paf("PAF3000F");
|
TPaf_record& paf3000f = _paf_container.get_paf("PAF3000F");
|
||||||
long riga = 1;
|
long riga = 1;
|
||||||
|
|
||||||
|
|
||||||
FOR_EACH_PHYSICAL_FPRDOC(doc, r, rdoc)
|
FOR_EACH_PHYSICAL_FPRDOC(doc, r, rdoc)
|
||||||
{
|
{
|
||||||
// Controllo la riga
|
// Controllo la riga
|
||||||
if (check_row(*rdoc) && !fp_settings().get_check_not_block())
|
if (check_row(*rdoc) && !fp_settings().get_check_not_block())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
||||||
_idx_adg_doc_row = 1L;
|
_idx_adg_doc_row = 1L;
|
||||||
|
|
||||||
bool skip_riga = false;
|
bool skip_riga = false;
|
||||||
|
|
||||||
reset(paf1800f);
|
reset(paf1800f);
|
||||||
@ -1672,54 +1642,13 @@ bool TDoc_fp::doc_to_paf(TDocumentoEsteso& doc)
|
|||||||
const TString& descrizione_riga = descrizione(*rdoc);
|
const TString& descrizione_riga = descrizione(*rdoc);
|
||||||
if (descrizione_riga.empty())
|
if (descrizione_riga.empty())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|
||||||
reset(paf3000f);
|
reset(paf3000f);
|
||||||
paf3000f.set("PT_RIFNUMLINEA", riga);
|
paf3000f.set("PT_RIFNUMLINEA", riga);
|
||||||
paf3000f.set("PT_COMMENTO", descrizione_riga);
|
paf3000f.set("PT_COMMENTO", descrizione_riga);
|
||||||
// <CodiceArticolo>
|
// <CodiceArticolo>
|
||||||
if (rdoc->is_articolo())
|
if (rdoc->is_articolo())
|
||||||
{
|
{
|
||||||
|
ok &= export_info_articolo(rdoc, paf1900f, paf2100f, riga, r);
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// </CodiceArticolo>
|
// </CodiceArticolo>
|
||||||
if(rdoc->is_descrizione())
|
if(rdoc->is_descrizione())
|
||||||
@ -1790,7 +1719,6 @@ bool TDoc_fp::doc_to_paf(TDocumentoEsteso& doc)
|
|||||||
else if (rdoc->is_spese())
|
else if (rdoc->is_spese())
|
||||||
{
|
{
|
||||||
const TSpesa_prest& sp = rdoc->spesa();
|
const TSpesa_prest& sp = rdoc->spesa();
|
||||||
|
|
||||||
// Controllo se ha la cassa professionale lo metto in testata
|
// Controllo se ha la cassa professionale lo metto in testata
|
||||||
if (sp.cassa_previdenziale().full())
|
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_PREZZOUNIT", converti_prezzo(qta_inverse ? -abs(prz) : abs(prz)));
|
||||||
paf1800f.set("PI_PRZTOTALE", converti_prezzo(imp));
|
paf1800f.set("PI_PRZTOTALE", converti_prezzo(imp));
|
||||||
set_IVA(*rdoc, paf1800f);
|
set_IVA(*rdoc, paf1800f);
|
||||||
|
|
||||||
// Controllo se è una ritenuta fiscale
|
// Controllo se è una ritenuta fiscale
|
||||||
if (sp.tipo_ritenuta() == 'F')
|
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);
|
msg.format("La riga omaggi %d ha quantità nulla", riga);
|
||||||
log(1, msg);
|
log(1, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
paf1800f.set("PI_TIPOCESSPREST", "AB");
|
paf1800f.set("PI_TIPOCESSPREST", "AB");
|
||||||
set_qta_prezzo(paf1800f, rdoc);
|
set_qta_prezzo(paf1800f, rdoc);
|
||||||
set_IVA(*rdoc, paf1800f);
|
set_IVA(*rdoc, paf1800f);
|
||||||
|
|
||||||
reset(paf2100f);
|
reset(paf2100f);
|
||||||
paf2100f.set("PK_KEYNLINEA", static_cast<long>(r));
|
paf2100f.set("PK_KEYNLINEA", static_cast<long>(r));
|
||||||
paf2100f.set("PK_KEYNLINAR", _idx_adg_doc_row++);
|
paf2100f.set("PK_KEYNLINAR", _idx_adg_doc_row++);
|
||||||
paf2100f.set("PK_TIPODATO", "AswTRiga");
|
paf2100f.set("PK_TIPODATO", "AswTRiga");
|
||||||
|
|
||||||
|
|
||||||
if (rdoc->get_bool(RDOC_ADDIVA))
|
if (rdoc->get_bool(RDOC_ADDIVA))
|
||||||
{
|
{
|
||||||
paf2100f.set("PK_RIFDATO", "Omaggio con rivalsa");
|
paf2100f.set("PK_RIFDATO", "Omaggio con rivalsa");
|
||||||
|
|
||||||
// Metto i dati come si trattasse di una riga normalissima
|
// Metto i dati come si trattasse di una riga normalissima
|
||||||
paf1800f.set("PI_UNITAMISURA", rdoc->get(RDOC_UMQTA));
|
paf1800f.set("PI_UNITAMISURA", rdoc->get(RDOC_UMQTA));
|
||||||
paf1800f.set("PI_QUANTITA", rdoc->get_real(RDOC_QTA).string(0));
|
paf1800f.set("PI_QUANTITA", rdoc->get_real(RDOC_QTA).string(0));
|
||||||
paf1800f.set("PI_PREZZOUNIT", converti_prezzo(rdoc->prezzo(false, false)));
|
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)));
|
paf1800f.set("PI_PRZTOTALE", converti_prezzo(rdoc->prezzo(false, false) * rdoc->get_real(RDOC_QTA)));
|
||||||
|
|
||||||
TRiepilogo_agg& riepilogo_agg = _riepilogo_agg[rdoc->iva().codice()];
|
TRiepilogo_agg& riepilogo_agg = _riepilogo_agg[rdoc->iva().codice()];
|
||||||
riepilogo_agg.imponibile += rdoc->imponibile_omaggio(2);
|
riepilogo_agg.imponibile += rdoc->imponibile_omaggio(2);
|
||||||
// Non metto l'imposta, è già presente nei totali
|
// Non metto l'imposta, è già presente nei totali
|
||||||
@ -1896,7 +1817,6 @@ bool TDoc_fp::doc_to_paf(TDocumentoEsteso& doc)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
paf2100f.set("PK_RIFDATO", "Omaggio senza rivalsa");
|
paf2100f.set("PK_RIFDATO", "Omaggio senza rivalsa");
|
||||||
|
|
||||||
// Aggiungo uno sconto
|
// Aggiungo uno sconto
|
||||||
paf2000f.set("PJ_KEYNLINEA", static_cast<long>(r));
|
paf2000f.set("PJ_KEYNLINEA", static_cast<long>(r));
|
||||||
paf2000f.set("PJ_KEYNLINAR", 1L);
|
paf2000f.set("PJ_KEYNLINAR", 1L);
|
||||||
@ -1907,7 +1827,6 @@ bool TDoc_fp::doc_to_paf(TDocumentoEsteso& doc)
|
|||||||
paf2000f.set("PJ_GESTIONE", "D");
|
paf2000f.set("PJ_GESTIONE", "D");
|
||||||
ok &= insert(paf2000f);
|
ok &= insert(paf2000f);
|
||||||
}
|
}
|
||||||
|
|
||||||
ok &= insert(paf2100f);
|
ok &= insert(paf2100f);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -1915,7 +1834,6 @@ bool TDoc_fp::doc_to_paf(TDocumentoEsteso& doc)
|
|||||||
// Salto tutte le altre righe
|
// Salto tutte le altre righe
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// <ScontoMaggiorazione>
|
// <ScontoMaggiorazione>
|
||||||
TString80 sconto_expr = rdoc->get(RDOC_SCONTO);
|
TString80 sconto_expr = rdoc->get(RDOC_SCONTO);
|
||||||
TToken_string sconti;
|
TToken_string sconti;
|
||||||
@ -1944,10 +1862,14 @@ bool TDoc_fp::doc_to_paf(TDocumentoEsteso& doc)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// </ScontoMaggiorazione>
|
// </ScontoMaggiorazione>
|
||||||
if (!skip_riga)
|
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");
|
paf1800f.set("PI_GESTIONE", "D");
|
||||||
ok &= insert(paf1800f) && insert(paf3000f);
|
ok &= insert(paf1800f) && insert(paf3000f);
|
||||||
riga++;
|
riga++;
|
||||||
@ -1989,6 +1911,7 @@ bool TDoc_fp::doc_to_paf(TDocumentoEsteso& doc)
|
|||||||
ok &= insert(paf1800f) && insert(paf3000f);
|
ok &= insert(paf1800f) && insert(paf3000f);
|
||||||
riga++;
|
riga++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// OMAGGI????
|
// OMAGGI????
|
||||||
// Aggiungo le spese incasso
|
// Aggiungo le spese incasso
|
||||||
if(doc.get_real("SPESINC") > ZERO)
|
if(doc.get_real("SPESINC") > ZERO)
|
||||||
@ -2007,6 +1930,7 @@ bool TDoc_fp::doc_to_paf(TDocumentoEsteso& doc)
|
|||||||
ok &= insert(paf1800f) && insert(paf3000f);
|
ok &= insert(paf1800f) && insert(paf3000f);
|
||||||
riga++;
|
riga++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Conai assolto
|
// Conai assolto
|
||||||
if(doc.clifor().vendite().get_bool("CONAIASS"))
|
if(doc.clifor().vendite().get_bool("CONAIASS"))
|
||||||
{
|
{
|
||||||
@ -2022,7 +1946,6 @@ bool TDoc_fp::doc_to_paf(TDocumentoEsteso& doc)
|
|||||||
ok &= insert(paf1800f) && insert(paf3000f);
|
ok &= insert(paf1800f) && insert(paf3000f);
|
||||||
riga++;
|
riga++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Riga sconto di testata
|
// Riga sconto di testata
|
||||||
// Se è presente uno sconto in testata devo sottrarlo come riga sconto o lo SDI urla
|
// 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")
|
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)
|
FOR_EACH_ASSOC_OBJECT(tiva, obj, key, itm)
|
||||||
{
|
{
|
||||||
const TRiepilogo_iva& riva = *dynamic_cast<const TRiepilogo_iva*>(itm);
|
const TRiepilogo_iva& riva = *dynamic_cast<const TRiepilogo_iva*>(itm);
|
||||||
|
|
||||||
reset(paf1800f);
|
reset(paf1800f);
|
||||||
paf1800f.set("PI_NUMEROLINEA", riga);
|
paf1800f.set("PI_NUMEROLINEA", riga);
|
||||||
reset(paf3000f);
|
reset(paf3000f);
|
||||||
@ -2051,7 +1973,6 @@ bool TDoc_fp::doc_to_paf(TDocumentoEsteso& doc)
|
|||||||
riga++;
|
riga++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const TString& nota_piede_fatt = _riga_npf.get_nota_piede(doc.tipo().codice());
|
const TString& nota_piede_fatt = _riga_npf.get_nota_piede(doc.tipo().codice());
|
||||||
if(nota_piede_fatt.full())
|
if(nota_piede_fatt.full())
|
||||||
{
|
{
|
||||||
@ -2068,6 +1989,27 @@ bool TDoc_fp::doc_to_paf(TDocumentoEsteso& doc)
|
|||||||
riga++;
|
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>
|
// </DatiBeniServizi>
|
||||||
// <DatiDDT>
|
// <DatiDDT>
|
||||||
// Metto qua i dati DDT per capire se la fattura è accompagnatoria o deriva da bolla
|
// 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>
|
// </DatiDDT>
|
||||||
// Salvo la testata
|
// Salvo la testata
|
||||||
ok &= insert(paf0700f);
|
ok &= insert(paf0700f);
|
||||||
|
|
||||||
// <DatiRiepilogo>
|
// <DatiRiepilogo>
|
||||||
TPaf_record& paf2200f = _paf_container.get_paf("PAF2200F");
|
TPaf_record& paf2200f = _paf_container.get_paf("PAF2200F");
|
||||||
const char* eiva = get_esigibilita_iva(doc);
|
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())
|
for(TObject* itm = tiva.first_item(); itm != nullptr; itm = tiva.succ_item())
|
||||||
{
|
{
|
||||||
const TRiepilogo_iva& riva = *dynamic_cast<const TRiepilogo_iva*>(itm);
|
const TRiepilogo_iva& riva = *dynamic_cast<const TRiepilogo_iva*>(itm);
|
||||||
|
|
||||||
if (!check_riepilogo(doc, riva) && !fp_settings().get_check_not_block())
|
if (!check_riepilogo(doc, riva) && !fp_settings().get_check_not_block())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
add_riepilogo_iva(paf2200f, riva.cod_iva(), eiva, riva.imponibile(), riva.imposta());
|
add_riepilogo_iva(paf2200f, riva.cod_iva(), eiva, riva.imponibile(), riva.imposta());
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!_riepilogo_agg.empty())
|
if(!_riepilogo_agg.empty())
|
||||||
{
|
{
|
||||||
for(auto i = _riepilogo_agg.begin(); i != _riepilogo_agg.end(); ++i)
|
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);
|
add_riepilogo_iva(paf2200f, cod_iva, eiva);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// </DatiRiepilogo>
|
// </DatiRiepilogo>
|
||||||
// <DatiPagamento>
|
// <DatiPagamento>
|
||||||
TPaf_record& paf2400f = _paf_container.get_paf("PAF2400F");
|
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
|
long nprogr = 0; // Numero di file allegati
|
||||||
// Se abilitato stampo il documento e lo allego
|
// Se abilitato stampo il documento e lo allego
|
||||||
TFilename rep;
|
TFilename rep;
|
||||||
|
|
||||||
if (_allegafattura)
|
if (_allegafattura)
|
||||||
{
|
{
|
||||||
if (!dongle().active(RSAUT))
|
if (!dongle().active(RSAUT))
|
||||||
@ -2303,12 +2239,10 @@ bool TDoc_fp::doc_to_paf(const TFilename& ini)
|
|||||||
const TDoc_key key(anno, codnum, ndoc);
|
const TDoc_key key(anno, codnum, ndoc);
|
||||||
return doc_to_paf(key);
|
return doc_to_paf(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TDoc_fp::doc_to_paf()
|
bool TDoc_fp::doc_to_paf()
|
||||||
{
|
{
|
||||||
return _doc_rec != nullptr ? doc_to_paf(*_doc_rec) : false;
|
return _doc_rec != nullptr ? doc_to_paf(*_doc_rec) : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
TRectype& TDoc_fp::key_to_doc(const TDoc_key& key)
|
TRectype& TDoc_fp::key_to_doc(const TDoc_key& key)
|
||||||
{
|
{
|
||||||
if(_doc_rec != nullptr)
|
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());
|
_doc_rec->put(DOC_NDOC, key.ndoc());
|
||||||
return *_doc_rec;
|
return *_doc_rec;
|
||||||
}
|
}
|
||||||
|
TDoc_fp::TDoc_fp() : _doc_rec(nullptr), _log(nullptr), _cache_insert(false)
|
||||||
TDoc_fp::TDoc_fp() : _doc_rec(nullptr), _log(nullptr), _cache_insert(false), _rec_clifo(LF_CLIFO)
|
|
||||||
{
|
{
|
||||||
_ditta.init(LF_NDITTE, prefix().get_codditta());
|
_ditta.init(LF_NDITTE, prefix().get_codditta());
|
||||||
_cofi = fp_settings().get_cofi_tras();
|
_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");
|
_conai_str = ini_get_string(CONFIG_DITTA, "ve", "DESCCONAIASS");
|
||||||
if (_conai_str.empty())
|
if (_conai_str.empty())
|
||||||
_conai_str = "Contributo CONAI assolto ove dovuto";
|
_conai_str = "Contributo CONAI assolto ove dovuto";
|
||||||
|
|
||||||
_nascondi_sconti_righe_fatt = fp_settings().get_no_sconti_fatt();
|
_nascondi_sconti_righe_fatt = fp_settings().get_no_sconti_fatt();
|
||||||
}
|
}
|
||||||
|
|
||||||
TDoc_fp::~TDoc_fp()
|
TDoc_fp::~TDoc_fp()
|
||||||
{
|
{
|
||||||
commit();
|
commit();
|
||||||
|
@ -4,6 +4,9 @@
|
|||||||
#include <fpcart.h>
|
#include <fpcart.h>
|
||||||
#include <fpcadg.h>
|
#include <fpcadg.h>
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
* TFP_custom
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
void TFP_custom::init()
|
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)
|
TFP_custom::TFP_custom() : TMultiple_rectype(LF_FPCUST), _codcust(""), _loaded(false)
|
||||||
{
|
{
|
||||||
init();
|
init();
|
||||||
@ -95,7 +170,92 @@ TFP_custom::TFP_custom(const char* codcust) : TFP_custom()
|
|||||||
load(codcust);
|
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:
|
* 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)
|
bool TFP_expression::check_condition(const TString& cond, TRiga_documento& rdoc)
|
||||||
{
|
{
|
||||||
|
// Caso base
|
||||||
|
if (cond.empty())
|
||||||
|
return true;
|
||||||
|
|
||||||
TString cond_sx, cond_dx;
|
TString cond_sx, cond_dx;
|
||||||
TFP_operator symb;
|
TFP_operator symb;
|
||||||
split_condition(cond, cond_sx, cond_dx, symb);
|
split_condition(cond, cond_sx, cond_dx, symb);
|
||||||
|
@ -23,4 +23,5 @@ Picture = <cg01>
|
|||||||
Module = fp
|
Module = fp
|
||||||
Flags = ""
|
Flags = ""
|
||||||
Item_01 = "Configurazione", "fp0 -0", "", 10210
|
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