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 <memory>
|
||||
#include <map>
|
||||
#include <cg2103.h>
|
||||
|
||||
#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
|
||||
SSimple_query& fp_db();
|
||||
@ -85,6 +89,7 @@ class TDoc_fp : public TObject
|
||||
{
|
||||
private:
|
||||
TRectype* _doc_rec;
|
||||
TRectype _rec_clifo;
|
||||
TAnagrafica _ditta;
|
||||
TString16 _cofi;
|
||||
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
|
||||
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;
|
||||
|
||||
// Classe interna per gestire gli omaggi
|
||||
class TOmaggio_info
|
||||
@ -131,6 +144,7 @@ private:
|
||||
|
||||
|
||||
protected:
|
||||
bool initialize(const 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(const TDocumento& doc, TString& iban, TString& abi, TString& cab, TString& istituto) const;
|
||||
@ -141,12 +155,22 @@ protected:
|
||||
const char* natura(const TString& codiva) const;
|
||||
static void set_IVA(const TString& codiva, TPaf_record& paf);
|
||||
static void set_IVA(const TRiga_documento& rdoc, TPaf_record& paf);
|
||||
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);
|
||||
const TString& converti_prezzo(const real& prezzo) 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:
|
||||
|
||||
bool doc_to_paf(TDocumentoEsteso& doc);
|
||||
bool doc_to_paf(const TRectype& rec);
|
||||
bool doc_to_paf(const TDoc_key& key);
|
||||
|
@ -671,6 +671,57 @@ bool TDoc_fp::save_paf()
|
||||
}
|
||||
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
|
||||
{
|
||||
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);
|
||||
}
|
||||
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_TIPOARTICOLO", codice_tipo);
|
||||
@ -825,7 +876,7 @@ void TDoc_fp::set_qta_prezzo(TPaf_record& paf1800f, TRiga_documento* rdoc) const
|
||||
if (qta == ZERO)
|
||||
qta = UNO;
|
||||
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);
|
||||
}
|
||||
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
|
||||
paf1800f.set("PI_QUANTITA", qta_string.mid(1));
|
||||
// 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));
|
||||
}
|
||||
// Salvo tutto
|
||||
paf1800f.set("PI_PREZZOUNIT", converti_prezzo(prezzo_unit));
|
||||
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
|
||||
_hfatt.cut(0);
|
||||
_bfatt.cut(0);
|
||||
bool has_bolla = false;
|
||||
if (!chiave_paf(doc, _hfatt, _bfatt))
|
||||
return false;
|
||||
log(-1, _bfatt);
|
||||
#ifndef DBG
|
||||
// Controllo se il documento è almeno in stato di stampa
|
||||
if (doc.stato() < doc.tipo().stato_finale_stampa())
|
||||
// <DatiRitenuta>
|
||||
paf0700f.set("P7_TIPORITENUTA", _rec_clifo.get_char(CLI_TIPOPERS) == 'F' ? "RT01" : "RT02");
|
||||
TString doc_imponibile = doc.imponibile().string();
|
||||
|
||||
real imponibile_prestazioni = ZERO;
|
||||
{
|
||||
log(3, "Il documento non è stato ancora stampato, verrà saltato");
|
||||
return false;
|
||||
FOR_EACH_PHYSICAL_RDOC(doc, r, rdoc)
|
||||
{
|
||||
if (rdoc->is_prestazione())
|
||||
imponibile_prestazioni += rdoc->imponibile();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
TAnagrafica clifo(doc.clifor().tipo(), doc.clifor().codice());
|
||||
TRectype rec_clifo(LF_CLIFO);
|
||||
rec_clifo.put(CLI_TIPOCF, doc.clifor().tipo());
|
||||
rec_clifo.put(CLI_CODCF, doc.clifor().codice());
|
||||
rec_clifo.read(TLocalisamfile(LF_CLIFO));
|
||||
TString8 coddest;
|
||||
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))
|
||||
return false;
|
||||
#else
|
||||
const bool is_pa = true;
|
||||
coddest = "WSUHKZ";
|
||||
#endif
|
||||
const bool enapec = coddest == "0000000" && pec.full();
|
||||
const bool privato = coddest.len() != 6;
|
||||
bool ok = true;
|
||||
const TFirm& firm = prefix().firm();
|
||||
const char* const paese = "IT";
|
||||
TCausale caus = TCausale(doc.tipo().causale(), doc.anno());
|
||||
// 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();
|
||||
real imponibile = imponibile_prestazioni;
|
||||
{
|
||||
// Riciclo per sommare la % delle spese da sommare
|
||||
FOR_EACH_PHYSICAL_RDOC(doc, r, rdoc)
|
||||
{
|
||||
if (rdoc->is_spese() && rdoc->spesa().get_bool("B1"))
|
||||
imponibile += imponibile * rdoc->spesa().perc() / CENTO;
|
||||
}
|
||||
}
|
||||
|
||||
paf0700f.set("P7_IMPORTORIT", converti_prezzo(imponibile * sp.perc() / CENTO));
|
||||
paf0700f.set("P7_ALIQUOTARIT", sp.perc());
|
||||
static TString caus_la; caus_la.cut(0);
|
||||
caus_la << sp.get("S14");
|
||||
|
||||
if (caus_la.empty())
|
||||
{
|
||||
static TString caus770; caus770.cut(0); caus770.format("%02d", sp.caus_770());
|
||||
caus_la << cache().get("%CA7", caus770, "S2");
|
||||
}
|
||||
|
||||
paf0700f.set("P7_CAUSPAGAM", caus_la);
|
||||
// </DatiRitenuta>
|
||||
}
|
||||
|
||||
const TFirm& TDoc_fp::get_firm()
|
||||
{
|
||||
return prefix().firm();
|
||||
}
|
||||
|
||||
bool TDoc_fp::export_paf0100f()
|
||||
{
|
||||
// <DatiTrassmissione>
|
||||
TPaf_record paf0100f("PAF0100F");
|
||||
paf0100f.set("P1_KEYHEADERFATT", _hfatt);
|
||||
paf0100f.set("P1_KEYBODYFATT", _bfatt);
|
||||
remove(paf0100f);
|
||||
paf0100f.set("P1_TRASMITTPAESE", paese);
|
||||
paf0100f.set("P1_TRASMITTPAESE", _paese);
|
||||
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_CODDEST", coddest);
|
||||
paf0100f.set("P1_FMTTRASMISS", _privato ? "FPR12" : "FPA12"); // SDI11 si usa dal 2015 per lo split payment (prima era SDI10)
|
||||
paf0100f.set("P1_CODDEST", _coddest);
|
||||
|
||||
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_MAIL", firm.get(NDT_MAIL));
|
||||
paf0100f.set("P1_MAIL", get_firm().get(NDT_MAIL));
|
||||
paf0100f.set("P1_GESTIONE", "D");
|
||||
ok &= insert(paf0100f);
|
||||
// </DatiTrassmissione>
|
||||
#ifndef DBG
|
||||
if (enapec)
|
||||
return insert(paf0100f);
|
||||
}
|
||||
|
||||
bool TDoc_fp::export_paf3200f()
|
||||
{
|
||||
if (_enapec)
|
||||
{
|
||||
// <Datipec>
|
||||
TPaf_record paf3200f("PAF3200F");
|
||||
paf3200f.set("PU_KEYHEADERFATT", _hfatt);
|
||||
paf3200f.set("PU_KEYBODYFATT", _bfatt);
|
||||
remove(paf3200f);
|
||||
paf3200f.set("PU_PEC", pec);
|
||||
ok &= insert(paf3200f);
|
||||
// </Datipec>
|
||||
// <Datipec>
|
||||
TPaf_record paf3200f("PAF3200F");
|
||||
paf3200f.set("PU_KEYHEADERFATT", _hfatt);
|
||||
paf3200f.set("PU_KEYBODYFATT", _bfatt);
|
||||
remove(paf3200f);
|
||||
paf3200f.set("PU_PEC", _pec);
|
||||
// </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
|
||||
|
||||
// <CedentePrestatore>
|
||||
TPaf_record paf0200f("PAF0200F");
|
||||
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_SEDECOMUNE", _ditta.comune_residenza());
|
||||
paf0200f.set("P2_SEDEPROV", _ditta.provincia_residenza());
|
||||
paf0200f.set("P2_SEDENAZ", paese);
|
||||
paf0200f.set("P2_SEDENAZ", _paese);
|
||||
paf0200f.set("P2_GESTIONE", "D");
|
||||
TAnagrafica cliente(doc.clifor());
|
||||
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_ISCRREASOCIOU", _ditta.sociounico() == 'S' ? "SU" : "SM");
|
||||
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())
|
||||
{
|
||||
const TString& numrea = unloc.get(ULC_NUMCCIAA).as_string();
|
||||
@ -960,7 +1037,7 @@ bool TDoc_fp::doc_to_paf(TDocumentoEsteso& doc)
|
||||
if (_ditta.giuridica())
|
||||
{
|
||||
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())
|
||||
{
|
||||
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_GESTIONE", "D");
|
||||
// <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>
|
||||
|
||||
// <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)
|
||||
/*
|
||||
* 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>
|
||||
TPaf_record paf2700f("PAF2700F");
|
||||
paf2700f.set("PQ_KEYHEADERFATT", _hfatt);
|
||||
@ -1175,7 +1231,7 @@ bool TDoc_fp::doc_to_paf(TDocumentoEsteso& doc)
|
||||
ok &= insert(paf1200f);
|
||||
}
|
||||
}
|
||||
if (is_pa && cup.blank() && cig.blank())
|
||||
if (_is_pa && cup.blank() && cig.blank())
|
||||
log(1, "CIG e CUP assenti");
|
||||
// <DatiBeniServizi>
|
||||
TPaf_record paf1800f("PAF1800F");
|
||||
@ -1285,12 +1341,11 @@ bool TDoc_fp::doc_to_paf(TDocumentoEsteso& doc)
|
||||
find_ancestors(*rdoc, ancestors);
|
||||
for (int i = ancestors.last(); i > 0; i = ancestors.pred(i))
|
||||
{
|
||||
has_bolla |= true;
|
||||
_has_bolla |= true;
|
||||
const TAncestor& a = (const TAncestor&)ancestors[i];
|
||||
if (i == 1)
|
||||
{
|
||||
// <DatiDDT>
|
||||
TPaf_record paf1600f("PAF1600F");
|
||||
paf1600f.reset();
|
||||
paf1600f.set("PF_KEYHEADERFATT", _hfatt);
|
||||
paf1600f.set("PF_KEYBODYFATT", _bfatt);
|
||||
@ -1304,7 +1359,6 @@ bool TDoc_fp::doc_to_paf(TDocumentoEsteso& doc)
|
||||
else if (i == 3)
|
||||
{
|
||||
// <DatiOrdineAcquisto>
|
||||
TPaf_record paf1000f("PAF1000F");
|
||||
paf1000f.set("P0_KEYHEADERFATT", _hfatt);
|
||||
paf1000f.set("P0_KEYBODYFATT", _bfatt);
|
||||
paf1000f.set("P0_RIFNUMLINEA", (long)r);
|
||||
@ -1346,7 +1400,7 @@ bool TDoc_fp::doc_to_paf(TDocumentoEsteso& doc)
|
||||
real prz = imp;
|
||||
if (qta != UNO)
|
||||
{
|
||||
prz = rdoc->prezzo(true, false);
|
||||
prz = rdoc->prezzo(true, false, 8);
|
||||
if (prz.is_zero() && !imp.is_zero())
|
||||
{
|
||||
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_PRZTOTALE", converti_prezzo(imp));
|
||||
set_IVA(*rdoc, paf1800f);
|
||||
// Controllo se è una ritenuta fiscale
|
||||
// <DatiRitenuta>
|
||||
|
||||
// Controllo se è una ritenuta fiscale
|
||||
if (sp.tipo_ritenuta() == 'F')
|
||||
{
|
||||
paf0700f.set("P7_TIPORITENUTA", rec_clifo.get_char(CLI_TIPOPERS) == 'F' ? "RT01" : "RT02");
|
||||
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"));
|
||||
add_ritenuta(doc, rdoc->spesa(), paf0700f);
|
||||
}
|
||||
// </DatiRitenuta>
|
||||
}
|
||||
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
|
||||
paf1800f.set("PI_UNITAMISURA", rdoc->get(RDOC_UMQTA));
|
||||
paf1800f.set("PI_QUANTITA", rdoc->get_real(RDOC_QTA));
|
||||
paf1800f.set("PI_PREZZOUNIT", converti_prezzo(rdoc->prezzo(false, false)));
|
||||
paf1800f.set("PI_QUANTITA", rdoc->get_real(RDOC_QTA).string(0, 8));
|
||||
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)));
|
||||
|
||||
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_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);
|
||||
}
|
||||
// Conai assolto
|
||||
@ -1594,7 +1643,7 @@ bool TDoc_fp::doc_to_paf(TDocumentoEsteso& doc)
|
||||
paf1700f.set("PG_KEYHEADERFATT", _hfatt);
|
||||
paf1700f.set("PG_KEYBODYFATT", _bfatt);
|
||||
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"));
|
||||
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
|
||||
// Se abilitato stampo il documento e lo allego
|
||||
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}
|
||||
// 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)
|
||||
if (!dongle().active(RSAUT))
|
||||
{
|
||||
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);
|
||||
log(1, "Impossibile generare la fattura, il modulo RS non è abilitato!");
|
||||
}
|
||||
else if (!doc.tipo().main_print_profile(rep, 2))
|
||||
{
|
||||
log(1, "Impossibile generare la fattura, non è disponibile un profilo di stampa per questo tipo documento!");
|
||||
}
|
||||
else
|
||||
{
|
||||
TFilename pdf; pdf.tempdir();
|
||||
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?"))
|
||||
//ve1 -2 {CODNUM} {ANNO} {PROVV} {NDOC}(-{ANDOC}) {TIPO_ELABORAZIONE} {TIPO_STAMPA}
|
||||
// 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)
|
||||
{
|
||||
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))
|
||||
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)
|
||||
else
|
||||
{
|
||||
const TToken_string entry(row);
|
||||
if (entry.get(0, fname) && fname.exist())
|
||||
TFilename pdf; pdf.tempdir();
|
||||
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_CDEST", coddest);
|
||||
pafw300f.set("PW_CDEST", _coddest);
|
||||
pafw300f.set("PW_RAGSOC", cliente.ragione_sociale().left(35));
|
||||
pafw300f.set("PW_PAESE", cliente.stato_residenza_ISO());
|
||||
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());
|
||||
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());
|
||||
_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
|
||||
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
|
||||
rec.put(FP_SLD_CODNUM, r->get(_codnum));
|
||||
|
Loading…
x
Reference in New Issue
Block a user