|
|
|
@ -671,9 +671,9 @@ protected:
|
|
|
|
|
|
|
|
|
|
void log(int severity, const char* msg);
|
|
|
|
|
bool show_log();
|
|
|
|
|
const char * natura(const TString& tipo, const int tipo_acquisti, const int regspiva) const;
|
|
|
|
|
void set_IVA(const TString& codiva, const int regspiva, TPaf_record& paf) const;
|
|
|
|
|
void set_IVA(const TRiga_documento& rdoc, const int regspiva, TPaf_record& paf) const;
|
|
|
|
|
const char * natura(const TString& codiva) const;
|
|
|
|
|
void set_IVA(const TString& codiva, TPaf_record& paf) const;
|
|
|
|
|
void set_IVA(const TRiga_documento& rdoc, TPaf_record& paf) const;
|
|
|
|
|
|
|
|
|
|
bool elabora(TDocumentoEsteso& doc);
|
|
|
|
|
bool elabora(const TRectype& rec);
|
|
|
|
@ -882,29 +882,39 @@ bool TDoc2Paf::show_log()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const char * TDoc2Paf::natura(const TString& tipo, const int tipo_acquisti, const int regspiva) const
|
|
|
|
|
const char * TDoc2Paf::natura(const TString& codiva) const
|
|
|
|
|
{
|
|
|
|
|
const TRectype& ai = cache().get("%IVA", codiva);
|
|
|
|
|
TString & natura = get_tmp_string(4);
|
|
|
|
|
|
|
|
|
|
// N1 escluse ex art 15
|
|
|
|
|
if (tipo_acquisti == 5)
|
|
|
|
|
natura = "N5"; // regime del margine
|
|
|
|
|
else
|
|
|
|
|
if (regspiva >12 && regspiva < 52)
|
|
|
|
|
natura = "N6"; // Inversione contabile (REVERSE CHARGE)
|
|
|
|
|
else
|
|
|
|
|
if (tipo == "NS")
|
|
|
|
|
natura = "N2"; // Non soggetto
|
|
|
|
|
natura = ai.get("S12");
|
|
|
|
|
if(natura.blank())
|
|
|
|
|
{
|
|
|
|
|
const int tipo_iva11 = ai.get_int("S2");
|
|
|
|
|
const bool revcharge = tipo_iva11 >= 31 && tipo_iva11 <= 38;
|
|
|
|
|
const TString& tipo = ai.get("S1");
|
|
|
|
|
const int tipo_vendite = ai.get_int("S7");
|
|
|
|
|
|
|
|
|
|
// N1 escluse ex art 15
|
|
|
|
|
if (tipo_vendite == 5)
|
|
|
|
|
natura = "N5"; // regime del margine
|
|
|
|
|
else
|
|
|
|
|
if (tipo == "NI")
|
|
|
|
|
natura = "N3"; // Non imponibile
|
|
|
|
|
if (revcharge)
|
|
|
|
|
natura = "N6"; // Inversione contabile (REVERSE CHARGE)
|
|
|
|
|
else
|
|
|
|
|
if (tipo == "NS")
|
|
|
|
|
natura = "N2"; // Non soggetto
|
|
|
|
|
else
|
|
|
|
|
if (tipo == "ES")
|
|
|
|
|
natura = "N4"; // Esente
|
|
|
|
|
if (tipo == "NI")
|
|
|
|
|
natura = "N3"; // Non imponibile
|
|
|
|
|
else
|
|
|
|
|
if (tipo == "ES")
|
|
|
|
|
natura = "N4"; // Esente
|
|
|
|
|
}
|
|
|
|
|
return natura;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TDoc2Paf::set_IVA(const TString& codiva, const int regspiva, TPaf_record& paf) const
|
|
|
|
|
void TDoc2Paf::set_IVA(const TString& codiva, TPaf_record& paf) const
|
|
|
|
|
{
|
|
|
|
|
const TRectype& ai = cache().get("%IVA", codiva);
|
|
|
|
|
const real aliquota = ai.get("R0");
|
|
|
|
@ -912,18 +922,13 @@ void TDoc2Paf::set_IVA(const TString& codiva, const int regspiva, TPaf_record& p
|
|
|
|
|
if (codiva.full())
|
|
|
|
|
{
|
|
|
|
|
if (aliquota.is_zero())
|
|
|
|
|
{
|
|
|
|
|
const TString& tipo = ai.get("S1");
|
|
|
|
|
const int tipo_acquisti = ai.get_int("S8");
|
|
|
|
|
|
|
|
|
|
paf.set("PI_NATURA", natura(tipo, tipo_acquisti, regspiva));
|
|
|
|
|
}
|
|
|
|
|
paf.set("PI_NATURA", natura(codiva));
|
|
|
|
|
else
|
|
|
|
|
paf.set("PI_NATURA", "");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TDoc2Paf::set_IVA(const TRiga_documento& rdoc, const int regspiva, TPaf_record& paf) const
|
|
|
|
|
void TDoc2Paf::set_IVA(const TRiga_documento& rdoc, TPaf_record& paf) const
|
|
|
|
|
{
|
|
|
|
|
const TString8 codiva(rdoc.get(RDOC_CODIVA));
|
|
|
|
|
const TRectype& ai = cache().get("%IVA", codiva);
|
|
|
|
@ -932,12 +937,7 @@ void TDoc2Paf::set_IVA(const TRiga_documento& rdoc, const int regspiva, TPaf_rec
|
|
|
|
|
if (codiva.full())
|
|
|
|
|
{
|
|
|
|
|
if (aliquota.is_zero())
|
|
|
|
|
{
|
|
|
|
|
const TString& tipo = ai.get("S1");
|
|
|
|
|
const int tipo_acquisti = ai.get_int("S8");
|
|
|
|
|
|
|
|
|
|
paf.set("PI_NATURA", natura(tipo, tipo_acquisti, regspiva));
|
|
|
|
|
}
|
|
|
|
|
paf.set("PI_NATURA", natura(codiva));
|
|
|
|
|
else
|
|
|
|
|
paf.set("PI_NATURA", "");
|
|
|
|
|
}
|
|
|
|
@ -955,7 +955,6 @@ bool TDoc2Paf::elabora(TDocumentoEsteso& doc)
|
|
|
|
|
const TFirm& firm = prefix().firm();
|
|
|
|
|
const char* const paese = "IT";
|
|
|
|
|
TCausale caus = TCausale(doc.tipo().causale(), doc.anno());
|
|
|
|
|
const int regspiva = caus.regime_speciale();
|
|
|
|
|
|
|
|
|
|
// <DatiTrassmissione>
|
|
|
|
|
TPaf_record paf0100f("PAF0100F");
|
|
|
|
@ -1277,7 +1276,7 @@ bool TDoc2Paf::elabora(TDocumentoEsteso& doc)
|
|
|
|
|
// paf1800f.set("PI_ALIQUOTAIVA", "22.00"); // Altrimenti scarta le righe di descrizione
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
set_IVA(codivadefault, regspiva, paf1800f);
|
|
|
|
|
set_IVA(codivadefault, paf1800f);
|
|
|
|
|
|
|
|
|
|
if (rdoc->is_merce())
|
|
|
|
|
{
|
|
|
|
@ -1299,7 +1298,7 @@ bool TDoc2Paf::elabora(TDocumentoEsteso& doc)
|
|
|
|
|
paf1800f.set("PI_PREZZOUNIT", -rdoc->prezzo(true, false));
|
|
|
|
|
}
|
|
|
|
|
paf1800f.set("PI_PRZTOTALE", rdoc->importo(true, false));
|
|
|
|
|
set_IVA(*rdoc, regspiva, paf1800f);
|
|
|
|
|
set_IVA(*rdoc, paf1800f);
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
const TDate data = doc.get(DOC_DATADOC);
|
|
|
|
@ -1398,7 +1397,7 @@ bool TDoc2Paf::elabora(TDocumentoEsteso& doc)
|
|
|
|
|
}
|
|
|
|
|
paf1800f.set("PI_PREZZOUNIT", prz);
|
|
|
|
|
paf1800f.set("PI_PRZTOTALE", imp);
|
|
|
|
|
set_IVA(*rdoc, regspiva, paf1800f);
|
|
|
|
|
set_IVA(*rdoc, paf1800f);
|
|
|
|
|
} else
|
|
|
|
|
if (rdoc->is_prestazione())
|
|
|
|
|
{
|
|
|
|
@ -1407,7 +1406,7 @@ bool TDoc2Paf::elabora(TDocumentoEsteso& doc)
|
|
|
|
|
paf1800f.set("PI_QUANTITA", qta);
|
|
|
|
|
paf1800f.set("PI_PREZZOUNIT", rdoc->prezzo(false, false));
|
|
|
|
|
paf1800f.set("PI_PRZTOTALE", rdoc->importo(true, false));
|
|
|
|
|
set_IVA(*rdoc, regspiva, paf1800f);
|
|
|
|
|
set_IVA(*rdoc, paf1800f);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
paf1800f.set("PI_GESTIONE", "D");
|
|
|
|
@ -1436,13 +1435,8 @@ bool TDoc2Paf::elabora(TDocumentoEsteso& doc)
|
|
|
|
|
paf2200f.set("PL_KEYNPROGR", ++num_riep);
|
|
|
|
|
paf2200f.set("PL_ALIQUOTAIVA", aliquota);
|
|
|
|
|
if (aliquota.is_zero())
|
|
|
|
|
{
|
|
|
|
|
const TString& tipo = riva.cod_iva().tipo();
|
|
|
|
|
const int tipo_acquisti = riva.cod_iva().get_int("S8");
|
|
|
|
|
paf2200f.set("PL_NATURA", natura(riva.cod_iva().codice()));
|
|
|
|
|
|
|
|
|
|
paf2200f.set("PL_NATURA", natura(tipo, tipo_acquisti, regspiva));
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
paf2200f.set("PL_IMPONIBILE", riva.imponibile());
|
|
|
|
|
paf2200f.set("PL_IMPOSTA", riva.imposta());
|
|
|
|
|
paf2200f.set("PL_ESIGIVA", eiva);
|
|
|
|
|