Patch level : 12.0 694
Files correlati : fp Commento : - Sistemato caricamento con più di 10 tipi doc_to_paf - Sistemati calcoli con 3 o più cifre decimali nel prezzo o quantità - Allineato un po' il codice con funzione che inizializza a ogni giro - Workaround per bolli - Sistemata ritenuta con calcoli nuovi - Sistemato codice IVA per assoggettamento fiscale - Messi log specifici se non riesce a generare PDF
This commit is contained in:
parent
b37bc98218
commit
11e3c141de
@ -11,9 +11,13 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
#include <cg2103.h>
|
||||||
|
|
||||||
#define SQL_FLD "sql/"
|
#define SQL_FLD "sql/"
|
||||||
#define CARATTERI_SPECIALI "àèéìòù°'\\"
|
|
||||||
|
#ifndef CARATTERI_SPECIALI
|
||||||
|
#define CARATTERI_SPECIALI "àèéìòù°"
|
||||||
|
#endif
|
||||||
|
|
||||||
// Ritorna la connessione al DB paf secondo i parametri impostati nel programma di configurazione
|
// Ritorna la connessione al DB paf secondo i parametri impostati nel programma di configurazione
|
||||||
SSimple_query& fp_db();
|
SSimple_query& fp_db();
|
||||||
@ -85,6 +89,7 @@ class TDoc_fp : public TObject
|
|||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
TRectype* _doc_rec;
|
TRectype* _doc_rec;
|
||||||
|
TRectype _rec_clifo;
|
||||||
TAnagrafica _ditta;
|
TAnagrafica _ditta;
|
||||||
TString16 _cofi;
|
TString16 _cofi;
|
||||||
TFilename _dbname;
|
TFilename _dbname;
|
||||||
@ -100,6 +105,14 @@ private:
|
|||||||
TString8 _hfatt; // Codice univoco di 6 caratteri dell'ufficio P.A. o di 7 caratteri per un privato
|
TString8 _hfatt; // Codice univoco di 6 caratteri dell'ufficio P.A. o di 7 caratteri per un privato
|
||||||
TString _bfatt; // Codice univoco di 20 caratteri del documento
|
TString _bfatt; // Codice univoco di 20 caratteri del documento
|
||||||
TString _conai_str;
|
TString _conai_str;
|
||||||
|
TString _paese;
|
||||||
|
bool _enapec;
|
||||||
|
bool _privato;
|
||||||
|
TString _coddest;
|
||||||
|
TString _pec;
|
||||||
|
TCausale _caus;
|
||||||
|
bool _is_pa;
|
||||||
|
bool _has_bolla;
|
||||||
|
|
||||||
// Classe interna per gestire gli omaggi
|
// Classe interna per gestire gli omaggi
|
||||||
class TOmaggio_info
|
class TOmaggio_info
|
||||||
@ -131,6 +144,7 @@ private:
|
|||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
bool initialize(const TDocumentoEsteso& doc);
|
||||||
bool parse_sconto(const TString& formula, TToken_string& sconti) const;
|
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);
|
static bool get_bnp_iban(const TString& abi, const TString& cab, int prg, TString& iban);
|
||||||
bool get_bank(const TDocumento& doc, TString& iban, TString& abi, TString& cab, TString& istituto) const;
|
bool get_bank(const TDocumento& doc, TString& iban, TString& abi, TString& cab, TString& istituto) const;
|
||||||
@ -141,12 +155,22 @@ protected:
|
|||||||
const char* natura(const TString& codiva) const;
|
const char* natura(const TString& codiva) const;
|
||||||
static void set_IVA(const TString& codiva, TPaf_record& paf);
|
static void set_IVA(const TString& codiva, TPaf_record& paf);
|
||||||
static void set_IVA(const TRiga_documento& rdoc, TPaf_record& paf);
|
static void set_IVA(const TRiga_documento& rdoc, TPaf_record& paf);
|
||||||
bool add_row_art(long& riga_art, const TString codice_tipo, const TString& codice_valore, TPaf_record& paf);
|
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);
|
bool add_row_alleg(TFilename& file, long& nprogr, TPaf_record& paf);
|
||||||
const TString& converti_prezzo(const real& prezzo) const;
|
const TString& converti_prezzo(const real& prezzo) const;
|
||||||
void set_qta_prezzo(TPaf_record& paf1800f, TRiga_documento* rdoc) const;
|
void set_qta_prezzo(TPaf_record& paf1800f, TRiga_documento* rdoc) const;
|
||||||
|
void add_ritenuta(const TDocumentoEsteso& doc, const TSpesa_prest& sp, TPaf_record& paf0700f) const;
|
||||||
|
|
||||||
|
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);
|
bool doc_to_paf(TDocumentoEsteso& doc);
|
||||||
bool doc_to_paf(const TRectype& rec);
|
bool doc_to_paf(const TRectype& rec);
|
||||||
bool doc_to_paf(const TDoc_key& key);
|
bool doc_to_paf(const TDoc_key& key);
|
||||||
|
@ -671,6 +671,57 @@ bool TDoc_fp::save_paf()
|
|||||||
}
|
}
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool TDoc_fp::initialize(const 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());
|
||||||
|
|
||||||
|
// 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())
|
||||||
|
{
|
||||||
|
log(3, "Il documento non è stato ancora stampato, verrà saltato");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef DBG
|
||||||
|
_is_pa = doc.clifor().get_int("ALLEG") == 7;
|
||||||
|
if (!get_coddest(doc.clifor().tipo(), doc.clifor().codice(), _coddest, _pec))
|
||||||
|
return false;
|
||||||
|
#else
|
||||||
|
_is_pa = true;
|
||||||
|
_coddest = "WSUHKZ";
|
||||||
|
#endif
|
||||||
|
|
||||||
|
_enapec = _coddest == "0000000" && _pec.full();
|
||||||
|
_privato = _coddest.len() != 6;
|
||||||
|
|
||||||
|
_caus = TCausale(doc.tipo().causale(), doc.anno());
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
const TRectype& TDoc_fp::cco(const TRectype& doc) const
|
const TRectype& TDoc_fp::cco(const TRectype& doc) const
|
||||||
{
|
{
|
||||||
TString80 conkey;
|
TString80 conkey;
|
||||||
@ -767,7 +818,7 @@ void TDoc_fp::set_IVA(const TRiga_documento& rdoc, TPaf_record& paf)
|
|||||||
{
|
{
|
||||||
set_IVA(rdoc.get(RDOC_CODIVA), paf);
|
set_IVA(rdoc.get(RDOC_CODIVA), paf);
|
||||||
}
|
}
|
||||||
bool TDoc_fp::add_row_art(long& riga_art, const TString codice_tipo, const TString& codice_valore, TPaf_record& paf)
|
bool TDoc_fp::add_row_art(long& riga_art, const TString& codice_tipo, const TString& codice_valore, TPaf_record& paf)
|
||||||
{
|
{
|
||||||
paf.set("PY_KEYNLINAR", ++riga_art);
|
paf.set("PY_KEYNLINAR", ++riga_art);
|
||||||
paf.set("PY_TIPOARTICOLO", codice_tipo);
|
paf.set("PY_TIPOARTICOLO", codice_tipo);
|
||||||
@ -825,7 +876,7 @@ void TDoc_fp::set_qta_prezzo(TPaf_record& paf1800f, TRiga_documento* rdoc) const
|
|||||||
if (qta == ZERO)
|
if (qta == ZERO)
|
||||||
qta = UNO;
|
qta = UNO;
|
||||||
paf1800f.set("PI_QUANTITA", qta_string);
|
paf1800f.set("PI_QUANTITA", qta_string);
|
||||||
prezzo_unit = rdoc->prezzo(false, false);
|
prezzo_unit = rdoc->prezzo(false, false, 8);
|
||||||
prezzo_tot = rdoc->importo(true, false);
|
prezzo_tot = rdoc->importo(true, false);
|
||||||
}
|
}
|
||||||
else if(qta < ZERO)
|
else if(qta < ZERO)
|
||||||
@ -833,84 +884,110 @@ void TDoc_fp::set_qta_prezzo(TPaf_record& paf1800f, TRiga_documento* rdoc) const
|
|||||||
// Metto la qualità senza il segno
|
// Metto la qualità senza il segno
|
||||||
paf1800f.set("PI_QUANTITA", qta_string.mid(1));
|
paf1800f.set("PI_QUANTITA", qta_string.mid(1));
|
||||||
// E i prezzi in negativo, perchè l'importo non ha lo stesso segno del prezzo?
|
// E i prezzi in negativo, perchè l'importo non ha lo stesso segno del prezzo?
|
||||||
prezzo_unit = -abs(rdoc->prezzo(false, false));
|
prezzo_unit = -abs(rdoc->prezzo(false, false, 8));
|
||||||
prezzo_tot = -abs(rdoc->importo(true, false));
|
prezzo_tot = -abs(rdoc->importo(true, false));
|
||||||
}
|
}
|
||||||
// Salvo tutto
|
// Salvo tutto
|
||||||
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));
|
||||||
}
|
}
|
||||||
bool TDoc_fp::doc_to_paf(TDocumentoEsteso& doc)
|
|
||||||
|
void TDoc_fp::add_ritenuta(const TDocumentoEsteso& doc, const TSpesa_prest& sp, TPaf_record& paf0700f) const
|
||||||
{
|
{
|
||||||
// Azzero
|
// <DatiRitenuta>
|
||||||
_hfatt.cut(0);
|
paf0700f.set("P7_TIPORITENUTA", _rec_clifo.get_char(CLI_TIPOPERS) == 'F' ? "RT01" : "RT02");
|
||||||
_bfatt.cut(0);
|
TString doc_imponibile = doc.imponibile().string();
|
||||||
bool has_bolla = false;
|
|
||||||
if (!chiave_paf(doc, _hfatt, _bfatt))
|
real imponibile_prestazioni = ZERO;
|
||||||
return false;
|
|
||||||
log(-1, _bfatt);
|
|
||||||
#ifndef DBG
|
|
||||||
// Controllo se il documento è almeno in stato di stampa
|
|
||||||
if (doc.stato() < doc.tipo().stato_finale_stampa())
|
|
||||||
{
|
{
|
||||||
log(3, "Il documento non è stato ancora stampato, verrà saltato");
|
FOR_EACH_PHYSICAL_RDOC(doc, r, rdoc)
|
||||||
return false;
|
{
|
||||||
|
if (rdoc->is_prestazione())
|
||||||
|
imponibile_prestazioni += rdoc->imponibile();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
real imponibile = imponibile_prestazioni;
|
||||||
TAnagrafica clifo(doc.clifor().tipo(), doc.clifor().codice());
|
{
|
||||||
TRectype rec_clifo(LF_CLIFO);
|
// Riciclo per sommare la % delle spese da sommare
|
||||||
rec_clifo.put(CLI_TIPOCF, doc.clifor().tipo());
|
FOR_EACH_PHYSICAL_RDOC(doc, r, rdoc)
|
||||||
rec_clifo.put(CLI_CODCF, doc.clifor().codice());
|
{
|
||||||
rec_clifo.read(TLocalisamfile(LF_CLIFO));
|
if (rdoc->is_spese() && rdoc->spesa().get_bool("B1"))
|
||||||
TString8 coddest;
|
imponibile += imponibile * rdoc->spesa().perc() / CENTO;
|
||||||
TString pec;
|
}
|
||||||
#ifndef DBG
|
}
|
||||||
const bool is_pa = doc.clifor().get_int("ALLEG") == 7;
|
|
||||||
if (!get_coddest(doc.clifor().tipo(), doc.clifor().codice(), coddest, pec))
|
paf0700f.set("P7_IMPORTORIT", converti_prezzo(imponibile * sp.perc() / CENTO));
|
||||||
return false;
|
paf0700f.set("P7_ALIQUOTARIT", sp.perc());
|
||||||
#else
|
static TString caus_la; caus_la.cut(0);
|
||||||
const bool is_pa = true;
|
caus_la << sp.get("S14");
|
||||||
coddest = "WSUHKZ";
|
|
||||||
#endif
|
if (caus_la.empty())
|
||||||
const bool enapec = coddest == "0000000" && pec.full();
|
{
|
||||||
const bool privato = coddest.len() != 6;
|
static TString caus770; caus770.cut(0); caus770.format("%02d", sp.caus_770());
|
||||||
bool ok = true;
|
caus_la << cache().get("%CA7", caus770, "S2");
|
||||||
const TFirm& firm = prefix().firm();
|
}
|
||||||
const char* const paese = "IT";
|
|
||||||
TCausale caus = TCausale(doc.tipo().causale(), doc.anno());
|
paf0700f.set("P7_CAUSPAGAM", caus_la);
|
||||||
// Valorizzo la gestione del cambio
|
// </DatiRitenuta>
|
||||||
_doc_cambio._cod_val = doc.valuta();
|
}
|
||||||
_doc_cambio._is_valuta_estera = doc.valuta().full() && !is_euro_value(doc.valuta());
|
|
||||||
_doc_cambio._cambio = doc.cambio();
|
const TFirm& TDoc_fp::get_firm()
|
||||||
|
{
|
||||||
|
return prefix().firm();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TDoc_fp::export_paf0100f()
|
||||||
|
{
|
||||||
// <DatiTrassmissione>
|
// <DatiTrassmissione>
|
||||||
TPaf_record paf0100f("PAF0100F");
|
TPaf_record paf0100f("PAF0100F");
|
||||||
paf0100f.set("P1_KEYHEADERFATT", _hfatt);
|
paf0100f.set("P1_KEYHEADERFATT", _hfatt);
|
||||||
paf0100f.set("P1_KEYBODYFATT", _bfatt);
|
paf0100f.set("P1_KEYBODYFATT", _bfatt);
|
||||||
remove(paf0100f);
|
remove(paf0100f);
|
||||||
paf0100f.set("P1_TRASMITTPAESE", paese);
|
paf0100f.set("P1_TRASMITTPAESE", _paese);
|
||||||
paf0100f.set("P1_TRASMITTCOD", _cofi);
|
paf0100f.set("P1_TRASMITTCOD", _cofi);
|
||||||
paf0100f.set("P1_FMTTRASMISS", privato ? "FPR12" : "FPA12"); // SDI11 si usa dal 2015 per lo split payment (prima era SDI10)
|
paf0100f.set("P1_FMTTRASMISS", _privato ? "FPR12" : "FPA12"); // SDI11 si usa dal 2015 per lo split payment (prima era SDI10)
|
||||||
paf0100f.set("P1_CODDEST", coddest);
|
paf0100f.set("P1_CODDEST", _coddest);
|
||||||
|
|
||||||
TString80 tel;
|
TString80 tel;
|
||||||
tel << firm.get(NDT_PTEL) << firm.get(NDT_TEL);
|
|
||||||
|
tel << get_firm().get(NDT_PTEL) << get_firm().get(NDT_TEL);
|
||||||
paf0100f.set("P1_TELEFONO", tel);
|
paf0100f.set("P1_TELEFONO", tel);
|
||||||
paf0100f.set("P1_MAIL", firm.get(NDT_MAIL));
|
paf0100f.set("P1_MAIL", get_firm().get(NDT_MAIL));
|
||||||
paf0100f.set("P1_GESTIONE", "D");
|
paf0100f.set("P1_GESTIONE", "D");
|
||||||
ok &= insert(paf0100f);
|
|
||||||
// </DatiTrassmissione>
|
// </DatiTrassmissione>
|
||||||
#ifndef DBG
|
return insert(paf0100f);
|
||||||
if (enapec)
|
}
|
||||||
|
|
||||||
|
bool TDoc_fp::export_paf3200f()
|
||||||
|
{
|
||||||
|
if (_enapec)
|
||||||
{
|
{
|
||||||
// <Datipec>
|
// <Datipec>
|
||||||
TPaf_record paf3200f("PAF3200F");
|
TPaf_record paf3200f("PAF3200F");
|
||||||
paf3200f.set("PU_KEYHEADERFATT", _hfatt);
|
paf3200f.set("PU_KEYHEADERFATT", _hfatt);
|
||||||
paf3200f.set("PU_KEYBODYFATT", _bfatt);
|
paf3200f.set("PU_KEYBODYFATT", _bfatt);
|
||||||
remove(paf3200f);
|
remove(paf3200f);
|
||||||
paf3200f.set("PU_PEC", pec);
|
paf3200f.set("PU_PEC", _pec);
|
||||||
ok &= insert(paf3200f);
|
// </Datipec>
|
||||||
// </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
|
#endif
|
||||||
|
|
||||||
// <CedentePrestatore>
|
// <CedentePrestatore>
|
||||||
TPaf_record paf0200f("PAF0200F");
|
TPaf_record paf0200f("PAF0200F");
|
||||||
paf0200f.set("P2_KEYHEADERFATT", _hfatt);
|
paf0200f.set("P2_KEYHEADERFATT", _hfatt);
|
||||||
@ -938,7 +1015,7 @@ bool TDoc_fp::doc_to_paf(TDocumentoEsteso& doc)
|
|||||||
paf0200f.set("P2_SEDECAP", _ditta.CAP_residenza());
|
paf0200f.set("P2_SEDECAP", _ditta.CAP_residenza());
|
||||||
paf0200f.set("P2_SEDECOMUNE", _ditta.comune_residenza());
|
paf0200f.set("P2_SEDECOMUNE", _ditta.comune_residenza());
|
||||||
paf0200f.set("P2_SEDEPROV", _ditta.provincia_residenza());
|
paf0200f.set("P2_SEDEPROV", _ditta.provincia_residenza());
|
||||||
paf0200f.set("P2_SEDENAZ", paese);
|
paf0200f.set("P2_SEDENAZ", _paese);
|
||||||
paf0200f.set("P2_GESTIONE", "D");
|
paf0200f.set("P2_GESTIONE", "D");
|
||||||
TAnagrafica cliente(doc.clifor());
|
TAnagrafica cliente(doc.clifor());
|
||||||
TString rifamm = cco(doc).get("S4");
|
TString rifamm = cco(doc).get("S4");
|
||||||
@ -947,7 +1024,7 @@ bool TDoc_fp::doc_to_paf(TDocumentoEsteso& doc)
|
|||||||
paf0200f.set("P2_RIFAMMINISTR", rifamm);
|
paf0200f.set("P2_RIFAMMINISTR", rifamm);
|
||||||
paf0200f.set("P2_ISCRREASOCIOU", _ditta.sociounico() == 'S' ? "SU" : "SM");
|
paf0200f.set("P2_ISCRREASOCIOU", _ditta.sociounico() == 'S' ? "SU" : "SM");
|
||||||
TISAM_recordset unloc("USE UNLOC\nJOIN COMUNI INTO COM==COMCCIAA\nFROM CODDITTA=#DITTA\nTO CODDITTA=#DITTA");
|
TISAM_recordset unloc("USE UNLOC\nJOIN COMUNI INTO COM==COMCCIAA\nFROM CODDITTA=#DITTA\nTO CODDITTA=#DITTA");
|
||||||
unloc.set_var("#DITTA", firm.get(NDT_CODDITTA));
|
unloc.set_var("#DITTA", get_firm().get(NDT_CODDITTA));
|
||||||
if (unloc.move_first())
|
if (unloc.move_first())
|
||||||
{
|
{
|
||||||
const TString& numrea = unloc.get(ULC_NUMCCIAA).as_string();
|
const TString& numrea = unloc.get(ULC_NUMCCIAA).as_string();
|
||||||
@ -960,7 +1037,7 @@ bool TDoc_fp::doc_to_paf(TDocumentoEsteso& doc)
|
|||||||
if (_ditta.giuridica())
|
if (_ditta.giuridica())
|
||||||
{
|
{
|
||||||
TISAM_recordset anagiu("USE ANAGIU\nFROM CODANAGR=#CODICE\nTO CODANAGR=#CODICE");
|
TISAM_recordset anagiu("USE ANAGIU\nFROM CODANAGR=#CODICE\nTO CODANAGR=#CODICE");
|
||||||
anagiu.set_var("#CODICE", firm.get(NDT_CODANAGR));
|
anagiu.set_var("#CODICE", get_firm().get(NDT_CODANAGR));
|
||||||
if (anagiu.move_first())
|
if (anagiu.move_first())
|
||||||
{
|
{
|
||||||
paf0200f.set("P2_ISCRREACAP", anagiu.get(ANG_CAPSOC));
|
paf0200f.set("P2_ISCRREACAP", anagiu.get(ANG_CAPSOC));
|
||||||
@ -1027,7 +1104,18 @@ bool TDoc_fp::doc_to_paf(TDocumentoEsteso& doc)
|
|||||||
paf0700f.set("P7_NUMERO", complete_num_fp(doc.codice_numerazione(), doc.numero()));
|
paf0700f.set("P7_NUMERO", complete_num_fp(doc.codice_numerazione(), doc.numero()));
|
||||||
paf0700f.set("P7_GESTIONE", "D");
|
paf0700f.set("P7_GESTIONE", "D");
|
||||||
// <DatiBollo>
|
// <DatiBollo>
|
||||||
paf0700f.set("P7_IMPORTOBOLLO", converti_prezzo(doc.get_real("BOLLI")));
|
const bool set_bollo = doc.get_bool("ADDBOLLI");
|
||||||
|
if(!set_bollo)
|
||||||
|
{
|
||||||
|
doc.put("ADDBOLLI", true);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
real imponibile = doc.imponibile(true);
|
||||||
|
paf0700f.set("P7_IMPORTOBOLLO", converti_prezzo(doc.bolli(imponibile, 8)));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Nel dubbio risetto
|
||||||
|
doc.put("ADDBOLLI", set_bollo);
|
||||||
// </DatiBollo>
|
// </DatiBollo>
|
||||||
|
|
||||||
// <DatiCassaPrevidenziale>
|
// <DatiCassaPrevidenziale>
|
||||||
@ -1037,40 +1125,8 @@ bool TDoc_fp::doc_to_paf(TDocumentoEsteso& doc)
|
|||||||
// 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
|
||||||
*
|
*/
|
||||||
// <ScontoMaggiorazione>
|
|
||||||
TPaf_record paf0900f("PAF0900F");
|
|
||||||
paf0900f.set("P9_KEYHEADERFATT", _hfatt);
|
|
||||||
paf0900f.set("P9_KEYBODYFATT", _bfatt);
|
|
||||||
remove(paf0900f);
|
|
||||||
TString80 sconto_expr = doc.get(DOC_SCONTOPERC);
|
|
||||||
TToken_string sconti;
|
|
||||||
if (parse_sconto(sconto_expr, sconti))
|
|
||||||
{
|
|
||||||
long nlin_sconto = 0;
|
|
||||||
FOR_EACH_TOKEN(sconti, str)
|
|
||||||
{
|
|
||||||
const real sconto = str;
|
|
||||||
if (!sconto.is_zero()) // Precauzione inutile
|
|
||||||
{
|
|
||||||
paf0900f.set("P9_RIFNUMLINEA", ++nlin_sconto);
|
|
||||||
if (sconto > ZERO)
|
|
||||||
{
|
|
||||||
paf0900f.set("P9_TIPOSCONTO", "SC");
|
|
||||||
paf0900f.set("P9_PERCSCONTO", sconto);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
paf0900f.set("P9_TIPOSCONTO", "MG");
|
|
||||||
paf0900f.set("P9_PERCSCONTO", -sconto);
|
|
||||||
}
|
|
||||||
paf0900f.set("P9_GESTIONE", "D");
|
|
||||||
ok &= insert(paf0900f);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
// </ScontoMaggiorazione>
|
|
||||||
// <DatiGenerali>
|
// <DatiGenerali>
|
||||||
TPaf_record paf2700f("PAF2700F");
|
TPaf_record paf2700f("PAF2700F");
|
||||||
paf2700f.set("PQ_KEYHEADERFATT", _hfatt);
|
paf2700f.set("PQ_KEYHEADERFATT", _hfatt);
|
||||||
@ -1175,7 +1231,7 @@ bool TDoc_fp::doc_to_paf(TDocumentoEsteso& doc)
|
|||||||
ok &= insert(paf1200f);
|
ok &= insert(paf1200f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (is_pa && cup.blank() && cig.blank())
|
if (_is_pa && cup.blank() && cig.blank())
|
||||||
log(1, "CIG e CUP assenti");
|
log(1, "CIG e CUP assenti");
|
||||||
// <DatiBeniServizi>
|
// <DatiBeniServizi>
|
||||||
TPaf_record paf1800f("PAF1800F");
|
TPaf_record paf1800f("PAF1800F");
|
||||||
@ -1285,12 +1341,11 @@ bool TDoc_fp::doc_to_paf(TDocumentoEsteso& doc)
|
|||||||
find_ancestors(*rdoc, ancestors);
|
find_ancestors(*rdoc, ancestors);
|
||||||
for (int i = ancestors.last(); i > 0; i = ancestors.pred(i))
|
for (int i = ancestors.last(); i > 0; i = ancestors.pred(i))
|
||||||
{
|
{
|
||||||
has_bolla |= true;
|
_has_bolla |= true;
|
||||||
const TAncestor& a = (const TAncestor&)ancestors[i];
|
const TAncestor& a = (const TAncestor&)ancestors[i];
|
||||||
if (i == 1)
|
if (i == 1)
|
||||||
{
|
{
|
||||||
// <DatiDDT>
|
// <DatiDDT>
|
||||||
TPaf_record paf1600f("PAF1600F");
|
|
||||||
paf1600f.reset();
|
paf1600f.reset();
|
||||||
paf1600f.set("PF_KEYHEADERFATT", _hfatt);
|
paf1600f.set("PF_KEYHEADERFATT", _hfatt);
|
||||||
paf1600f.set("PF_KEYBODYFATT", _bfatt);
|
paf1600f.set("PF_KEYBODYFATT", _bfatt);
|
||||||
@ -1304,7 +1359,6 @@ bool TDoc_fp::doc_to_paf(TDocumentoEsteso& doc)
|
|||||||
else if (i == 3)
|
else if (i == 3)
|
||||||
{
|
{
|
||||||
// <DatiOrdineAcquisto>
|
// <DatiOrdineAcquisto>
|
||||||
TPaf_record paf1000f("PAF1000F");
|
|
||||||
paf1000f.set("P0_KEYHEADERFATT", _hfatt);
|
paf1000f.set("P0_KEYHEADERFATT", _hfatt);
|
||||||
paf1000f.set("P0_KEYBODYFATT", _bfatt);
|
paf1000f.set("P0_KEYBODYFATT", _bfatt);
|
||||||
paf1000f.set("P0_RIFNUMLINEA", (long)r);
|
paf1000f.set("P0_RIFNUMLINEA", (long)r);
|
||||||
@ -1346,7 +1400,7 @@ bool TDoc_fp::doc_to_paf(TDocumentoEsteso& doc)
|
|||||||
real prz = imp;
|
real prz = imp;
|
||||||
if (qta != UNO)
|
if (qta != UNO)
|
||||||
{
|
{
|
||||||
prz = rdoc->prezzo(true, false);
|
prz = rdoc->prezzo(true, false, 8);
|
||||||
if (prz.is_zero() && !imp.is_zero())
|
if (prz.is_zero() && !imp.is_zero())
|
||||||
{
|
{
|
||||||
const TPrice price(imp / qta);
|
const TPrice price(imp / qta);
|
||||||
@ -1356,17 +1410,12 @@ 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
|
|
||||||
// <DatiRitenuta>
|
// Controllo se è una ritenuta fiscale
|
||||||
if (sp.tipo_ritenuta() == 'F')
|
if (sp.tipo_ritenuta() == 'F')
|
||||||
{
|
{
|
||||||
paf0700f.set("P7_TIPORITENUTA", rec_clifo.get_char(CLI_TIPOPERS) == 'F' ? "RT01" : "RT02");
|
add_ritenuta(doc, rdoc->spesa(), paf0700f);
|
||||||
paf0700f.set("P7_IMPORTORIT", converti_prezzo(doc.imponibile() * sp.perc() / CENTO));
|
|
||||||
paf0700f.set("P7_ALIQUOTARIT", TCodiceIVA(sp.cod_iva()).percentuale());
|
|
||||||
static TString caus770; caus770.cut(0); caus770.format("%02d", sp.caus_770());
|
|
||||||
paf0700f.set("P7_CAUSPAGAM", cache().get("%CA7", caus770, "S2"));
|
|
||||||
}
|
}
|
||||||
// </DatiRitenuta>
|
|
||||||
}
|
}
|
||||||
else if (rdoc->is_prestazione())
|
else if (rdoc->is_prestazione())
|
||||||
{
|
{
|
||||||
@ -1408,8 +1457,8 @@ bool TDoc_fp::doc_to_paf(TDocumentoEsteso& doc)
|
|||||||
|
|
||||||
// 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));
|
paf1800f.set("PI_QUANTITA", rdoc->get_real(RDOC_QTA).string(0, 8));
|
||||||
paf1800f.set("PI_PREZZOUNIT", converti_prezzo(rdoc->prezzo(false, false)));
|
paf1800f.set("PI_PREZZOUNIT", converti_prezzo(rdoc->prezzo(false, false, 8)));
|
||||||
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)));
|
||||||
|
|
||||||
TOmaggio_info& omaggio_info = _omaggi[rdoc->iva().codice()];
|
TOmaggio_info& omaggio_info = _omaggi[rdoc->iva().codice()];
|
||||||
@ -1533,7 +1582,7 @@ bool TDoc_fp::doc_to_paf(TDocumentoEsteso& doc)
|
|||||||
paf1800f.set("PI_PREZZOUNIT", converti_prezzo(doc.spese_incasso(imponibile, 6, _netto)));
|
paf1800f.set("PI_PREZZOUNIT", converti_prezzo(doc.spese_incasso(imponibile, 6, _netto)));
|
||||||
paf1800f.set("PI_PRZTOTALE", converti_prezzo(doc.spese_incasso(imponibile, 6, _netto)));
|
paf1800f.set("PI_PRZTOTALE", converti_prezzo(doc.spese_incasso(imponibile, 6, _netto)));
|
||||||
|
|
||||||
set_IVA(doc.codiva_spese(), paf1800f);
|
set_IVA(doc.clifor().vendite().get("ASSFIS"), paf1800f);
|
||||||
ok &= insert(paf1800f) && insert(paf3000f);
|
ok &= insert(paf1800f) && insert(paf3000f);
|
||||||
}
|
}
|
||||||
// Conai assolto
|
// Conai assolto
|
||||||
@ -1594,7 +1643,7 @@ bool TDoc_fp::doc_to_paf(TDocumentoEsteso& doc)
|
|||||||
paf1700f.set("PG_KEYHEADERFATT", _hfatt);
|
paf1700f.set("PG_KEYHEADERFATT", _hfatt);
|
||||||
paf1700f.set("PG_KEYBODYFATT", _bfatt);
|
paf1700f.set("PG_KEYBODYFATT", _bfatt);
|
||||||
remove(paf1700f); // Cancella la riga del vettore
|
remove(paf1700f); // Cancella la riga del vettore
|
||||||
if (doc.get("CODVETT1").full() && !has_bolla)
|
if (doc.get("CODVETT1").full() && !_has_bolla)
|
||||||
{
|
{
|
||||||
TRectype vet = cache().get("%VET", doc.get("CODVETT1"));
|
TRectype vet = cache().get("%VET", doc.get("CODVETT1"));
|
||||||
const TString4 statopiva = vet.get("S3").mid(49, 2);
|
const TString4 statopiva = vet.get("S3").mid(49, 2);
|
||||||
@ -1735,54 +1784,66 @@ 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 && dongle().active(RSAUT) && doc.tipo().main_print_profile(rep, 2))
|
|
||||||
|
if (_allegafattura)
|
||||||
{
|
{
|
||||||
//ve1 -2 {CODNUM} {ANNO} {PROVV} {NDOC}(-{ANDOC}) {TIPO_ELABORAZIONE} {TIPO_STAMPA}
|
if (!dongle().active(RSAUT))
|
||||||
// Costruisco la chiamata
|
|
||||||
static TString commandline;
|
|
||||||
commandline.cut(0) << "ve1 -2 " << doc.get(DOC_CODNUM) << ' ' << doc.get(DOC_ANNO)
|
|
||||||
<< ' ' << doc.get(DOC_PROVV) << ' ' << doc.get(DOC_NDOC) << " X P"; // X: stampa su disco, P: provvisorio
|
|
||||||
TExternal_app interattivo(commandline);
|
|
||||||
if (interattivo.run() != NOERR)
|
|
||||||
{
|
{
|
||||||
TString msgerr = "Fallita generazione PDF documento ";
|
log(1, "Impossibile generare la fattura, il modulo RS non è abilitato!");
|
||||||
msgerr << doc.get(DOC_CODNUM) << ' ' << doc.get(DOC_ANNO)
|
}
|
||||||
<< ' ' << doc.get(DOC_PROVV) << ' ' << doc.get(DOC_NDOC);
|
else if (!doc.tipo().main_print_profile(rep, 2))
|
||||||
error_box(msgerr);
|
{
|
||||||
|
log(1, "Impossibile generare la fattura, non è disponibile un profilo di stampa per questo tipo documento!");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
TFilename pdf; pdf.tempdir();
|
//ve1 -2 {CODNUM} {ANNO} {PROVV} {NDOC}(-{ANDOC}) {TIPO_ELABORAZIONE} {TIPO_STAMPA}
|
||||||
pdf << SLASH << doc.get(DOC_ANNO) << '_' << doc.get(DOC_CODNUM) << '_' << doc.get(DOC_NDOC) << ".pdf";
|
// Costruisco la chiamata
|
||||||
if (!pdf.exist() && !yesno_box("Attenzione! Non è stato possibile creare il pdf, continuare?"))
|
static TString commandline;
|
||||||
|
commandline.cut(0) << "ve1 -2 " << doc.get(DOC_CODNUM) << ' ' << doc.get(DOC_ANNO)
|
||||||
|
<< ' ' << doc.get(DOC_PROVV) << ' ' << doc.get(DOC_NDOC) << " X P"; // X: stampa su disco, P: provvisorio
|
||||||
|
TExternal_app interattivo(commandline);
|
||||||
|
if (interattivo.run() != NOERR)
|
||||||
{
|
{
|
||||||
return false;
|
TString msgerr = "Fallita generazione PDF documento ";
|
||||||
|
msgerr << doc.get(DOC_CODNUM) << ' ' << doc.get(DOC_ANNO)
|
||||||
|
<< ' ' << doc.get(DOC_PROVV) << ' ' << doc.get(DOC_NDOC);
|
||||||
|
error_box(msgerr);
|
||||||
}
|
}
|
||||||
if (!add_row_alleg(pdf, nprogr, paf2600f))
|
else
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
TToken_string allegati(doc.get("COLL_GOLEM"), '\n');
|
|
||||||
bool load_allegati = true;
|
|
||||||
if (allegati.full())
|
|
||||||
{
|
|
||||||
if (_def_fld.empty())
|
|
||||||
{
|
|
||||||
TString msgerr; msgerr << "Errore: il documento " << _bfatt << " ha degli allegati ma nella configurazione non è stato impostato come trametterli\nCaricare il documento senza allegati?";
|
|
||||||
load_allegati = false;
|
|
||||||
if (!yesno_box(msgerr))
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
TFilename fname;
|
|
||||||
FOR_EACH_TOKEN(allegati, row)
|
|
||||||
{
|
{
|
||||||
const TToken_string entry(row);
|
TFilename pdf; pdf.tempdir();
|
||||||
if (entry.get(0, fname) && fname.exist())
|
pdf << SLASH << doc.get(DOC_ANNO) << '_' << doc.get(DOC_CODNUM) << '_' << doc.get(DOC_NDOC) << ".pdf";
|
||||||
|
if (!pdf.exist() && !yesno_box("Attenzione! Non è stato possibile creare il pdf, continuare?"))
|
||||||
{
|
{
|
||||||
if (!add_row_alleg(fname, nprogr, paf2600f))
|
return false;
|
||||||
return false;
|
}
|
||||||
|
if (!add_row_alleg(pdf, nprogr, paf2600f))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
TToken_string allegati(doc.get("COLL_GOLEM"), '\n');
|
||||||
|
bool load_allegati = true;
|
||||||
|
if (allegati.full())
|
||||||
|
{
|
||||||
|
if (_def_fld.empty())
|
||||||
|
{
|
||||||
|
TString msgerr; msgerr << "Errore: il documento " << _bfatt << " ha degli allegati ma nella configurazione non è stato impostato come trametterli\nCaricare il documento senza allegati?";
|
||||||
|
load_allegati = false;
|
||||||
|
if (!yesno_box(msgerr))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
TFilename fname;
|
||||||
|
FOR_EACH_TOKEN(allegati, row)
|
||||||
|
{
|
||||||
|
const TToken_string entry(row);
|
||||||
|
if (entry.get(0, fname) && fname.exist())
|
||||||
|
{
|
||||||
|
if (!add_row_alleg(fname, nprogr, paf2600f))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1804,7 +1865,7 @@ bool TDoc_fp::doc_to_paf(TDocumentoEsteso& doc)
|
|||||||
pafw300f.set("PW_CODSDI", "**********");
|
pafw300f.set("PW_CODSDI", "**********");
|
||||||
}
|
}
|
||||||
|
|
||||||
pafw300f.set("PW_CDEST", coddest);
|
pafw300f.set("PW_CDEST", _coddest);
|
||||||
pafw300f.set("PW_RAGSOC", cliente.ragione_sociale().left(35));
|
pafw300f.set("PW_RAGSOC", cliente.ragione_sociale().left(35));
|
||||||
pafw300f.set("PW_PAESE", cliente.stato_residenza_ISO());
|
pafw300f.set("PW_PAESE", cliente.stato_residenza_ISO());
|
||||||
pafw300f.set("PW_CODICE", cliente.codice_fiscale_estero());
|
pafw300f.set("PW_CODICE", cliente.codice_fiscale_estero());
|
||||||
@ -1863,7 +1924,8 @@ 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();
|
||||||
|
@ -204,7 +204,10 @@ void TFP_selected_docs::save_sheet(const TSheet_field& sheet) const
|
|||||||
{
|
{
|
||||||
// Chissene anche se copio ogni volta
|
// Chissene anche se copio ogni volta
|
||||||
rec = fill_rectype();
|
rec = fill_rectype();
|
||||||
rec.put(FP_SLD_CODTAB, n);
|
static TString num;
|
||||||
|
num.cut(0);
|
||||||
|
num.format("%08d", n);
|
||||||
|
rec.put(FP_SLD_CODTAB, num);
|
||||||
|
|
||||||
// Prendo tutta la riga tranne il cod sdi
|
// Prendo tutta la riga tranne il cod sdi
|
||||||
rec.put(FP_SLD_CODNUM, r->get(_codnum));
|
rec.put(FP_SLD_CODNUM, r->get(_codnum));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user