Patch level : 12.0 656
Files correlati : fp Commento : - Aggiunta conversione qualsiasi valuta -> Euro - Aggiunto controllo alle righe che vado a scrivere, ogni tanto finivano delle righe non volute - Tolto importo in testata - Camiata lettura importi dettaglio iva
This commit is contained in:
parent
fdd0dd4fc9
commit
00048f0239
@ -835,6 +835,22 @@ bool TDoc_fp::add_row_alleg(TFilename& file, long& nprogr, TPaf_record& paf)
|
||||
return ok;
|
||||
}
|
||||
|
||||
const TString& TDoc_fp::converti_prezzo(const real& prezzo) const
|
||||
{
|
||||
TString& ret = get_tmp_string();
|
||||
ret.cut(0);
|
||||
|
||||
if (_is_valuta_estera)
|
||||
{
|
||||
TCurrency ret(prezzo);
|
||||
ret.change_to_euro_val();
|
||||
return ret.string(true);
|
||||
}
|
||||
else
|
||||
ret << prezzo;
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool TDoc_fp::doc_to_paf(TDocumentoEsteso& doc)
|
||||
{
|
||||
// Azzero
|
||||
@ -859,11 +875,12 @@ bool TDoc_fp::doc_to_paf(TDocumentoEsteso& doc)
|
||||
|
||||
TString8 coddest;
|
||||
TString pec;
|
||||
const bool is_pa = doc.clifor().get_int("ALLEG") == 7;
|
||||
#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
|
||||
|
||||
@ -876,6 +893,8 @@ bool TDoc_fp::doc_to_paf(TDocumentoEsteso& doc)
|
||||
const char* const paese = "IT";
|
||||
TCausale caus = TCausale(doc.tipo().causale(), doc.anno());
|
||||
|
||||
_is_valuta_estera = !is_euro_value(doc.valuta());
|
||||
|
||||
// <DatiTrassmissione>
|
||||
TPaf_record paf0100f("PAF0100F");
|
||||
paf0100f.set("P1_KEYHEADERFATT", _hfatt);
|
||||
@ -1032,7 +1051,7 @@ bool TDoc_fp::doc_to_paf(TDocumentoEsteso& doc)
|
||||
paf0700f.set("P7_KEYBODYFATT", _bfatt);
|
||||
remove(paf0700f);
|
||||
paf0700f.set("P7_TIPODOC", tipo_doc_sdi(doc));
|
||||
paf0700f.set("P7_DIVISA", "EUR"); // Aggiungere codice ISO 4217 a tabella divise (%VAL)
|
||||
paf0700f.set("P7_DIVISA", doc.valuta());
|
||||
paf0700f.set("P7_DATA", doc.data());
|
||||
|
||||
const TCodice_numerazione& codnum = doc.codice_numerazione();
|
||||
@ -1042,7 +1061,7 @@ bool TDoc_fp::doc_to_paf(TDocumentoEsteso& doc)
|
||||
paf0700f.set("P7_GESTIONE", "D");
|
||||
|
||||
// <DatiBollo>
|
||||
paf0700f.set("P7_IMPORTOBOLLO", doc.get("BOLLI"));
|
||||
paf0700f.set("P7_IMPORTOBOLLO", converti_prezzo(doc.get_real("BOLLI")));
|
||||
// </DatiBollo>
|
||||
|
||||
// <DatiCassaPrevidenziale>
|
||||
@ -1090,7 +1109,10 @@ bool TDoc_fp::doc_to_paf(TDocumentoEsteso& doc)
|
||||
paf2700f.set("PQ_KEYHEADERFATT", _hfatt);
|
||||
paf2700f.set("PQ_KEYBODYFATT", _bfatt);
|
||||
remove(paf2700f);
|
||||
paf2700f.set("PQ_IMPTOTDOC", doc.totale_doc());
|
||||
|
||||
// Disabilitata la scrittura del totale del documento, questo causa problemi se è presente uno sconto in testata e l'addebito del bollo.
|
||||
// Campo calcola prima il totale, poi lo sconta e ci applica il bollo mentre lo SDI sconta a bollo già applicato.
|
||||
// paf2700f.set("PQ_IMPTOTDOC", doc.totale_doc());
|
||||
|
||||
const TRectype& cont_conv_off = cco(doc);
|
||||
TString causale = cont_conv_off.get("S1");
|
||||
@ -1281,11 +1303,6 @@ bool TDoc_fp::doc_to_paf(TDocumentoEsteso& doc)
|
||||
paf3000f.set("PT_RIFNUMLINEA", riga);
|
||||
paf3000f.set("PT_COMMENTO", descrizione(*rdoc));
|
||||
|
||||
// Nel dubbio preparo la riga di descrizione
|
||||
paf1800f.set("PI_QUANTITA", UNO);
|
||||
paf1800f.set("PI_PREZZOUNIT", ZERO);
|
||||
paf1800f.set("PI_PRZTOTALE", ZERO);
|
||||
|
||||
// <CodiceArticolo>
|
||||
long riga_art = 0;
|
||||
TArticolo& art = rdoc->articolo();
|
||||
@ -1306,9 +1323,14 @@ bool TDoc_fp::doc_to_paf(TDocumentoEsteso& doc)
|
||||
}
|
||||
// </CodiceArticolo>
|
||||
|
||||
if(rdoc->is_descrizione())
|
||||
{
|
||||
paf1800f.set("PI_QUANTITA", UNO);
|
||||
paf1800f.set("PI_PREZZOUNIT", ZERO);
|
||||
paf1800f.set("PI_PRZTOTALE", ZERO);
|
||||
set_IVA(codivadefault, paf1800f);
|
||||
|
||||
if (rdoc->is_merce())
|
||||
}
|
||||
else if (rdoc->is_merce())
|
||||
{
|
||||
paf1800f.set("PI_UNITAMISURA", rdoc->get(RDOC_UMQTA));
|
||||
const real qta = rdoc->get(RDOC_QTA);
|
||||
@ -1321,14 +1343,14 @@ bool TDoc_fp::doc_to_paf(TDocumentoEsteso& doc)
|
||||
if (qta >= ZERO)
|
||||
{
|
||||
paf1800f.set("PI_QUANTITA", qta);
|
||||
paf1800f.set("PI_PREZZOUNIT", rdoc->prezzo(false, false));
|
||||
paf1800f.set("PI_PREZZOUNIT", converti_prezzo(rdoc->prezzo(false, false)));
|
||||
}
|
||||
else
|
||||
{
|
||||
paf1800f.set("PI_QUANTITA", -qta);
|
||||
paf1800f.set("PI_PREZZOUNIT", -rdoc->prezzo(true, false));
|
||||
paf1800f.set("PI_PREZZOUNIT", converti_prezzo(-rdoc->prezzo(true, false)));
|
||||
}
|
||||
paf1800f.set("PI_PRZTOTALE", rdoc->importo(true, false));
|
||||
paf1800f.set("PI_PRZTOTALE", converti_prezzo(rdoc->importo(true, false)));
|
||||
set_IVA(*rdoc, paf1800f);
|
||||
|
||||
/*
|
||||
@ -1437,8 +1459,8 @@ bool TDoc_fp::doc_to_paf(TDocumentoEsteso& doc)
|
||||
prz = price.get_value();
|
||||
}
|
||||
}
|
||||
paf1800f.set("PI_PREZZOUNIT", prz);
|
||||
paf1800f.set("PI_PRZTOTALE", imp);
|
||||
paf1800f.set("PI_PREZZOUNIT", converti_prezzo(prz));
|
||||
paf1800f.set("PI_PRZTOTALE", converti_prezzo(imp));
|
||||
set_IVA(*rdoc, paf1800f);
|
||||
|
||||
// Controllo se è una ritenuta fiscale
|
||||
@ -1446,7 +1468,7 @@ bool TDoc_fp::doc_to_paf(TDocumentoEsteso& doc)
|
||||
if (sp.tipo_ritenuta() == 'F')
|
||||
{
|
||||
paf0700f.set("P7_TIPORITENUTA", cliente.fisica() ? "RT01" : "RT02");
|
||||
paf0700f.set("P7_IMPORTORIT", doc.imponibile() * sp.perc() / CENTO);
|
||||
paf0700f.set("P7_IMPORTORIT", converti_prezzo(doc.imponibile() * sp.perc() / CENTO));
|
||||
paf0700f.set("P7_ALIQUOTARIT", TCodiceIVA(sp.cod_iva()).percentuale());
|
||||
paf0700f.set("P7_CAUSPAGAM", cache().get("CA7", to_tstring(sp.caus_770()), "S2"));
|
||||
}
|
||||
@ -1458,10 +1480,15 @@ bool TDoc_fp::doc_to_paf(TDocumentoEsteso& doc)
|
||||
real qta = rdoc->get(RDOC_QTA);
|
||||
if (qta.is_zero()) qta = UNO;
|
||||
paf1800f.set("PI_QUANTITA", qta);
|
||||
paf1800f.set("PI_PREZZOUNIT", rdoc->prezzo(false, false));
|
||||
paf1800f.set("PI_PRZTOTALE", rdoc->importo(true, false));
|
||||
paf1800f.set("PI_PREZZOUNIT", converti_prezzo(rdoc->prezzo(false, false)));
|
||||
paf1800f.set("PI_PRZTOTALE", converti_prezzo(rdoc->importo(true, false)));
|
||||
set_IVA(*rdoc, paf1800f);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Salto tutte le altre righe
|
||||
continue;
|
||||
}
|
||||
|
||||
paf1800f.set("PI_GESTIONE", "D");
|
||||
ok &= insert(paf1800f) && insert(paf3000f);
|
||||
@ -1510,8 +1537,8 @@ bool TDoc_fp::doc_to_paf(TDocumentoEsteso& doc)
|
||||
paf3000f.set("PT_COMMENTO", "Imposta bollo assolta in modo virtuale");
|
||||
|
||||
paf1800f.set("PI_QUANTITA", UNO);
|
||||
paf1800f.set("PI_PREZZOUNIT", doc.get_real("BOLLI"));
|
||||
paf1800f.set("PI_PRZTOTALE", doc.get_real("BOLLI"));
|
||||
paf1800f.set("PI_PREZZOUNIT", converti_prezzo(doc.get_real("BOLLI")));
|
||||
paf1800f.set("PI_PRZTOTALE", converti_prezzo(doc.get_real("BOLLI")));
|
||||
set_IVA(doc.codiva_bolli(), paf1800f);
|
||||
ok &= insert(paf1800f) && insert(paf3000f);
|
||||
}
|
||||
@ -1534,8 +1561,8 @@ bool TDoc_fp::doc_to_paf(TDocumentoEsteso& doc)
|
||||
|
||||
paf1800f.set("PI_QUANTITA", UNO);
|
||||
real imponibile = doc.imponibile();
|
||||
paf1800f.set("PI_PREZZOUNIT", doc.spese_incasso(imponibile, 6, _netto));
|
||||
paf1800f.set("PI_PRZTOTALE", 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)));
|
||||
|
||||
set_IVA(doc.codiva_spese(), paf1800f);
|
||||
ok &= insert(paf1800f) && insert(paf3000f);
|
||||
@ -1589,8 +1616,12 @@ bool TDoc_fp::doc_to_paf(TDocumentoEsteso& doc)
|
||||
if (aliquota.is_zero())
|
||||
paf2200f.set("PL_NATURA", natura(riva.cod_iva().codice()));
|
||||
|
||||
paf2200f.set("PL_IMPONIBILE", riva.imponibile());
|
||||
paf2200f.set("PL_IMPOSTA", riva.imposta());
|
||||
real imponibile = riva.imp_orig();
|
||||
if (imponibile <= ZERO)
|
||||
imponibile = riva.imponibile();
|
||||
|
||||
paf2200f.set("PL_IMPONIBILE", converti_prezzo(imponibile));
|
||||
paf2200f.set("PL_IMPOSTA", converti_prezzo(riva.imposta()));
|
||||
paf2200f.set("PL_ESIGIVA", eiva);
|
||||
if (*eiva == 'S')
|
||||
paf2200f.set("PL_RIFNORMATIVO", "Scissione pagamenti art.17-ter DPR 633/72");
|
||||
@ -1658,7 +1689,7 @@ bool TDoc_fp::doc_to_paf(TDocumentoEsteso& doc)
|
||||
|
||||
TToken_string& riga = scad.row(nr); // Data|Importo
|
||||
paf2500f.set("PO_DATASCADENZA", TDate(riga.get(0))); // Data scadenza
|
||||
paf2500f.set("PO_IMPORTO", real(riga.get())); // Importo rata
|
||||
paf2500f.set("PO_IMPORTO", converti_prezzo(real(riga.get()))); // Importo rata
|
||||
|
||||
paf2500f.set("PO_GESTIONE", "D");
|
||||
ok &= insert(paf2500f);
|
||||
|
@ -77,7 +77,7 @@ public:
|
||||
class TDoc_fp
|
||||
{
|
||||
private:
|
||||
TRectype *_doc_rec;
|
||||
TRectype* _doc_rec;
|
||||
TAnagrafica _ditta;
|
||||
TString16 _cofi;
|
||||
TFilename _dbname;
|
||||
@ -92,6 +92,7 @@ private:
|
||||
vector<TString> _query;
|
||||
TString8 _hfatt; // Codice univoco di 6 caratteri dell'ufficio P.A. o di 7 caratteri per un privato
|
||||
TString20 _bfatt; // Codice univoco di 20 caratteri del documento
|
||||
bool _is_valuta_estera; // Se il documento è in valuta estera
|
||||
|
||||
int parse_line(const TString& line, TString& var, TString& val) const;
|
||||
bool create_table(TScanner& paf, const TString& table);
|
||||
@ -116,7 +117,7 @@ protected:
|
||||
static void set_IVA(const TRiga_documento& rdoc, TPaf_record& paf);
|
||||
bool add_row_art(const TString codice_tipo, const TString& codice_valore, TPaf_record& paf);
|
||||
bool add_row_alleg(TFilename& file, long& nprogr, TPaf_record& paf);
|
||||
void set_descrizione(const TRiga_documento* doc);
|
||||
const TString& converti_prezzo(const real& prezzo) const;
|
||||
|
||||
public:
|
||||
bool doc_to_paf(TDocumentoEsteso& doc);
|
||||
|
Loading…
x
Reference in New Issue
Block a user