Merge branch 'R_10_00' of http://10.65.20.17:7990/scm/campo/campo into R_10_00
This commit is contained in:
commit
0297ddb848
@ -113,17 +113,18 @@ private:
|
|||||||
TCausale _caus;
|
TCausale _caus;
|
||||||
bool _is_pa;
|
bool _is_pa;
|
||||||
bool _has_bolla;
|
bool _has_bolla;
|
||||||
|
TString _codivadefault;
|
||||||
|
|
||||||
// Classe interna per gestire gli omaggi
|
// Classe interna per gestire righe aggiuntive in riepilogo
|
||||||
class TOmaggio_info
|
class TRiepilogo_agg
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
real imponibile;
|
real imponibile;
|
||||||
real imposta;
|
real imposta;
|
||||||
TOmaggio_info() : imponibile(ZERO), imposta(ZERO){}
|
TRiepilogo_agg() : imponibile(ZERO), imposta(ZERO){}
|
||||||
};
|
};
|
||||||
|
|
||||||
std::map<TString, TOmaggio_info> _omaggi;
|
std::map<TString, TRiepilogo_agg> _riepilogo_agg;
|
||||||
|
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
@ -153,13 +154,14 @@ protected:
|
|||||||
|
|
||||||
void log(int severity, const char* msg);
|
void log(int severity, const char* msg);
|
||||||
const char* natura(const TString& codiva) const;
|
const char* natura(const TString& codiva) const;
|
||||||
static void set_IVA(const TString& codiva, TPaf_record& paf);
|
void set_IVA(TString codiva, TPaf_record& paf) const;
|
||||||
static void set_IVA(const TRiga_documento& rdoc, TPaf_record& paf);
|
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_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;
|
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);
|
||||||
|
|
||||||
const TFirm& get_firm();
|
const TFirm& get_firm();
|
||||||
|
|
||||||
|
@ -719,6 +719,16 @@ bool TDoc_fp::initialize(const TDocumentoEsteso& doc)
|
|||||||
|
|
||||||
_caus = TCausale(doc.tipo().causale(), doc.anno());
|
_caus = TCausale(doc.tipo().causale(), doc.anno());
|
||||||
|
|
||||||
|
// Preparo il codice iva di default
|
||||||
|
{
|
||||||
|
FOR_EACH_PHYSICAL_RDOC(doc, r, rdoc)
|
||||||
|
{
|
||||||
|
_codivadefault = rdoc->get(RDOC_CODIVA);
|
||||||
|
if (_codivadefault.full())
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -807,14 +817,17 @@ const char* TDoc_fp::natura(const TString& codiva) const
|
|||||||
return cache().get("%IVA", codiva, "S12");
|
return cache().get("%IVA", codiva, "S12");
|
||||||
}
|
}
|
||||||
|
|
||||||
void TDoc_fp::set_IVA(const TString& codiva, TPaf_record& paf)
|
void TDoc_fp::set_IVA(TString codiva, TPaf_record& paf) const
|
||||||
{
|
{
|
||||||
// É necessario il cast a real?
|
if (codiva.empty())
|
||||||
paf.set("PI_ALIQUOTAIVA", static_cast<real>(cache().get("%IVA", codiva, "R0")));
|
codiva = _codivadefault;
|
||||||
paf.set("PI_NATURA", cache().get("%IVA", codiva, "S12"));
|
|
||||||
|
// É necessario il cast a real?
|
||||||
|
paf.set("PI_ALIQUOTAIVA", static_cast<real>(cache().get("%IVA", codiva, "R0")));
|
||||||
|
paf.set("PI_NATURA", natura(codiva));
|
||||||
}
|
}
|
||||||
|
|
||||||
void TDoc_fp::set_IVA(const TRiga_documento& rdoc, TPaf_record& paf)
|
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);
|
||||||
}
|
}
|
||||||
@ -931,6 +944,46 @@ void TDoc_fp::add_ritenuta(const TDocumentoEsteso& doc, const TSpesa_prest& sp,
|
|||||||
// </DatiRitenuta>
|
// </DatiRitenuta>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool TDoc_fp::add_riepilogo_iva(TPaf_record& paf2200f, const TCodiceIVA& cod_iva, const char* eiva, const real& imponibile,
|
||||||
|
const real& imposta)
|
||||||
|
{
|
||||||
|
paf2200f.reset();
|
||||||
|
paf2200f.set("PL_KEYHEADERFATT", _hfatt);
|
||||||
|
paf2200f.set("PL_KEYBODYFATT", _bfatt);
|
||||||
|
|
||||||
|
const real aliquota = cod_iva.percentuale();
|
||||||
|
const TString& cod_aliquota = cod_iva.codice();
|
||||||
|
TRiepilogo_agg& riepilogo_agg = _riepilogo_agg[cod_aliquota];
|
||||||
|
|
||||||
|
// Aliquota
|
||||||
|
paf2200f.set("PL_ALIQUOTAIVA", aliquota);
|
||||||
|
|
||||||
|
// Natura
|
||||||
|
if (aliquota.is_zero())
|
||||||
|
paf2200f.set("PL_NATURA", natura(cod_aliquota));
|
||||||
|
|
||||||
|
// Imponibile
|
||||||
|
paf2200f.set("PL_IMPONIBILE", converti_prezzo(imponibile + riepilogo_agg.imponibile));
|
||||||
|
|
||||||
|
// Imposta, per gli omaggi con addebito ho già l'imposta
|
||||||
|
paf2200f.set("PL_IMPOSTA", converti_prezzo(imposta));
|
||||||
|
|
||||||
|
// Esigibilità IVA
|
||||||
|
paf2200f.set("PL_ESIGIVA", eiva);
|
||||||
|
if (*eiva == 'S')
|
||||||
|
paf2200f.set("PL_RIFNORMATIVO", "Scissione pagamenti art.17-ter DPR 633/72");
|
||||||
|
else
|
||||||
|
paf2200f.set("PL_RIFNORMATIVO", cod_iva.descrizione());
|
||||||
|
|
||||||
|
paf2200f.set("PL_GESTIONE", "D");
|
||||||
|
|
||||||
|
// Elimino l'oggetto
|
||||||
|
_riepilogo_agg.erase(cod_aliquota);
|
||||||
|
|
||||||
|
// Inserisco
|
||||||
|
return insert(paf2200f);
|
||||||
|
}
|
||||||
|
|
||||||
const TFirm& TDoc_fp::get_firm()
|
const TFirm& TDoc_fp::get_firm()
|
||||||
{
|
{
|
||||||
return prefix().firm();
|
return prefix().firm();
|
||||||
@ -1255,15 +1308,7 @@ bool TDoc_fp::doc_to_paf(TDocumentoEsteso& doc)
|
|||||||
paf3000f.set("PT_KEYBODYFATT", _bfatt);
|
paf3000f.set("PT_KEYBODYFATT", _bfatt);
|
||||||
remove(paf3000f);
|
remove(paf3000f);
|
||||||
long riga = 0;
|
long riga = 0;
|
||||||
TString16 codivadefault;
|
|
||||||
{
|
|
||||||
FOR_EACH_PHYSICAL_RDOC(doc, r, rdoc)
|
|
||||||
{
|
|
||||||
codivadefault = rdoc->get(RDOC_CODIVA);
|
|
||||||
if (codivadefault.full())
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
FOR_EACH_PHYSICAL_RDOC(doc, r, rdoc)
|
FOR_EACH_PHYSICAL_RDOC(doc, r, rdoc)
|
||||||
{
|
{
|
||||||
paf1800f.reset();
|
paf1800f.reset();
|
||||||
@ -1311,7 +1356,7 @@ bool TDoc_fp::doc_to_paf(TDocumentoEsteso& doc)
|
|||||||
paf1800f.set("PI_QUANTITA", UNO);
|
paf1800f.set("PI_QUANTITA", UNO);
|
||||||
paf1800f.set("PI_PREZZOUNIT", ZERO);
|
paf1800f.set("PI_PREZZOUNIT", ZERO);
|
||||||
paf1800f.set("PI_PRZTOTALE", ZERO);
|
paf1800f.set("PI_PRZTOTALE", ZERO);
|
||||||
set_IVA(codivadefault, paf1800f);
|
set_IVA(_codivadefault, paf1800f);
|
||||||
}
|
}
|
||||||
else if (rdoc->is_merce())
|
else if (rdoc->is_merce())
|
||||||
{
|
{
|
||||||
@ -1324,7 +1369,7 @@ bool TDoc_fp::doc_to_paf(TDocumentoEsteso& doc)
|
|||||||
set_qta_prezzo(paf1800f, rdoc);
|
set_qta_prezzo(paf1800f, rdoc);
|
||||||
if(rdoc->iva().codice().empty())
|
if(rdoc->iva().codice().empty())
|
||||||
{
|
{
|
||||||
set_IVA(codivadefault, paf1800f);
|
set_IVA(_codivadefault, paf1800f);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
set_IVA(*rdoc, paf1800f);
|
set_IVA(*rdoc, paf1800f);
|
||||||
@ -1411,7 +1456,7 @@ bool TDoc_fp::doc_to_paf(TDocumentoEsteso& doc)
|
|||||||
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')
|
||||||
{
|
{
|
||||||
add_ritenuta(doc, rdoc->spesa(), paf0700f);
|
add_ritenuta(doc, rdoc->spesa(), paf0700f);
|
||||||
@ -1461,9 +1506,10 @@ bool TDoc_fp::doc_to_paf(TDocumentoEsteso& doc)
|
|||||||
paf1800f.set("PI_PREZZOUNIT", converti_prezzo(rdoc->prezzo(false, false, 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)));
|
paf1800f.set("PI_PRZTOTALE", converti_prezzo(rdoc->prezzo(false, false) * rdoc->get_real(RDOC_QTA)));
|
||||||
|
|
||||||
TOmaggio_info& omaggio_info = _omaggi[rdoc->iva().codice()];
|
TRiepilogo_agg& riepilogo_agg = _riepilogo_agg[rdoc->iva().codice()];
|
||||||
omaggio_info.imponibile += rdoc->imponibile_omaggio(2);
|
riepilogo_agg.imponibile += rdoc->imponibile_omaggio(2);
|
||||||
omaggio_info.imposta += rdoc->iva_omaggio(8, 2);
|
// Non metto l'imposta, è già presente nei totali
|
||||||
|
//riepilogo_agg.imposta += rdoc->iva_omaggio(8, 2);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1542,7 +1588,7 @@ bool TDoc_fp::doc_to_paf(TDocumentoEsteso& doc)
|
|||||||
paf1800f.set("PI_QUANTITA", UNO);
|
paf1800f.set("PI_QUANTITA", UNO);
|
||||||
paf1800f.set("PI_PREZZOUNIT", ZERO);
|
paf1800f.set("PI_PREZZOUNIT", ZERO);
|
||||||
paf1800f.set("PI_PRZTOTALE", ZERO);
|
paf1800f.set("PI_PRZTOTALE", ZERO);
|
||||||
set_IVA(codivadefault, paf1800f);
|
set_IVA(_codivadefault, paf1800f);
|
||||||
ok &= insert(paf1800f) && insert(paf3000f);
|
ok &= insert(paf1800f) && insert(paf3000f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1600,7 +1646,7 @@ bool TDoc_fp::doc_to_paf(TDocumentoEsteso& doc)
|
|||||||
paf1800f.set("PI_QUANTITA", UNO);
|
paf1800f.set("PI_QUANTITA", UNO);
|
||||||
paf1800f.set("PI_PREZZOUNIT", ZERO);
|
paf1800f.set("PI_PREZZOUNIT", ZERO);
|
||||||
paf1800f.set("PI_PRZTOTALE", ZERO);
|
paf1800f.set("PI_PRZTOTALE", ZERO);
|
||||||
set_IVA(codivadefault, paf1800f);
|
set_IVA(_codivadefault, paf1800f);
|
||||||
ok &= insert(paf1800f) && insert(paf3000f);
|
ok &= insert(paf1800f) && insert(paf3000f);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1690,37 +1736,20 @@ bool TDoc_fp::doc_to_paf(TDocumentoEsteso& doc)
|
|||||||
TAssoc_array& tiva = doc.tabella_iva(false);
|
TAssoc_array& tiva = doc.tabella_iva(false);
|
||||||
FOR_EACH_ASSOC_OBJECT(tiva, obj, key, itm)
|
FOR_EACH_ASSOC_OBJECT(tiva, obj, key, itm)
|
||||||
{
|
{
|
||||||
paf2200f.reset();
|
|
||||||
paf2200f.set("PL_KEYHEADERFATT", _hfatt);
|
|
||||||
paf2200f.set("PL_KEYBODYFATT", _bfatt);
|
|
||||||
const TRiepilogo_iva& riva = *dynamic_cast<const TRiepilogo_iva*>(itm);
|
const TRiepilogo_iva& riva = *dynamic_cast<const TRiepilogo_iva*>(itm);
|
||||||
const real aliquota = riva.cod_iva().percentuale();
|
|
||||||
const TString& cod_aliquota = riva.cod_iva().codice();
|
add_riepilogo_iva(paf2200f, riva.cod_iva(), eiva, riva.imponibile(), riva.imposta());
|
||||||
const TOmaggio_info& omaggio_info = _omaggi[cod_aliquota];
|
|
||||||
|
|
||||||
// Aliquota
|
|
||||||
paf2200f.set("PL_ALIQUOTAIVA", aliquota);
|
|
||||||
|
|
||||||
// Natura
|
|
||||||
if (aliquota.is_zero())
|
|
||||||
paf2200f.set("PL_NATURA", natura(riva.cod_iva().codice()));
|
|
||||||
|
|
||||||
// Imponibile
|
|
||||||
paf2200f.set("PL_IMPONIBILE", converti_prezzo(riva.imponibile() + omaggio_info.imponibile));
|
|
||||||
|
|
||||||
// Imposta, per gli omaggi con addebito ho già l'imposta
|
|
||||||
paf2200f.set("PL_IMPOSTA", converti_prezzo(riva.imposta()));
|
|
||||||
|
|
||||||
// Esigibilità IVA
|
|
||||||
paf2200f.set("PL_ESIGIVA", eiva);
|
|
||||||
if (*eiva == 'S')
|
|
||||||
paf2200f.set("PL_RIFNORMATIVO", "Scissione pagamenti art.17-ter DPR 633/72");
|
|
||||||
else
|
|
||||||
paf2200f.set("PL_RIFNORMATIVO", riva.cod_iva().descrizione());
|
|
||||||
|
|
||||||
paf2200f.set("PL_GESTIONE", "D");
|
|
||||||
ok &= insert(paf2200f);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!_riepilogo_agg.empty())
|
||||||
|
{
|
||||||
|
for(auto i = _riepilogo_agg.begin(); i != _riepilogo_agg.end(); ++i)
|
||||||
|
{
|
||||||
|
const TCodiceIVA cod_iva(i->first);
|
||||||
|
add_riepilogo_iva(paf2200f, cod_iva, eiva);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// </DatiRiepilogo>
|
// </DatiRiepilogo>
|
||||||
// <DatiPagamento>
|
// <DatiPagamento>
|
||||||
TPaf_record paf2400f("PAF2400F");
|
TPaf_record paf2400f("PAF2400F");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user