2Patch level : 12.0 956

Files correlati     : ve0.exe ve1.exe ve5.exe vve6.exe
Commento            :

correta contabilizzazione note di credito split-payment e reverse charge nel saldaconto.
This commit is contained in:
Alessandro Bonazzi 2020-04-13 18:05:24 +02:00
parent e3fe3e0718
commit 19aec5be4f

View File

@ -2808,8 +2808,8 @@ error_type TContabilizzazione::write_scadenze(TDocumento& doc, bool recontabiliz
partita.put(PART_SEZ, sezione);
const real totdoc(head.get(MOV_TOTDOC));
const real totdocval(head.get(MOV_TOTDOCVAL));
const bool in_valuta = cambio.in_valuta();
const real totdocval(head.get_real(MOV_TOTDOCVAL));
const bool in_valuta = cambio.in_valuta();
const bool swapped = !in_valuta && test_swap();
const TCurrency_documento td((in_valuta ? totdocval : totdoc) * (swapped ? -UNO : UNO), doc);
@ -2961,7 +2961,7 @@ error_type TContabilizzazione::write_scadenze(TDocumento& doc, bool recontabiliz
} // if fattura
else if (is_nc)
{
TImporto residuoval(sezione, doc.totale_doc());
TImporto residuoval(sezione, abs(totdocval));
TImporto residuolit(sezione, abs(totdoc));
partita.put(PART_DATAPAG, doc.get(DOC_DATADOC));
@ -2990,24 +2990,39 @@ error_type TContabilizzazione::write_scadenze(TDocumento& doc, bool recontabiliz
if (p > 0 && p < nuova_riga)
{
TPagamento& pag = doc.pagamento();
TCurrency_documento totdoc(abs(doc.totale_doc()), doc);
TCurrency_documento totspese(abs(doc.spese()), doc);
TCurrency_documento totimposte(abs(doc.imposta(true)), doc);
TCurrency_documento totimponibili = totdoc - totspese - totimposte;
if (in_valuta)
{
TCurrency_documento val2(totimposte); val2.change_to_firm_val();
TCurrency_documento val3(totspese); val3.change_to_firm_val();
TCurrency_documento val1(totdoc); val1.change_to_firm_val(); val1 -= val2+val3;
// Cosi' corregge eventuali scompensi di poche lirette
TCurrency_documento totdoc(abs(totdocval), doc);
TCurrency_documento totspese(abs(doc.spese()), doc);
TCurrency_documento totimposte(abs(doc.imposta(true)), doc);
TCurrency_documento totimponibili = totdoc - totspese;
if (!cached_causale(head.get(MOV_CODCAUS), head.get_int(MOV_ANNOES)).reverse_charge_pubb())
totimponibili -= totimposte;
TCurrency_documento val1(totimponibili); val1.change_to_firm_val();
TCurrency_documento val2(totimposte); val2.change_to_firm_val();
TCurrency_documento val3(totspese); val3.change_to_firm_val();
// Cosi' corregge eventuali scompensi di poche lirette
pag.set_total_valuta(totimponibili, totimposte, totspese, val1, val2, val3);
}
else
pag.set_total(totimponibili, totimposte, totspese);
{
TCurrency_documento totdoc(abs(totdoc), doc);
TCurrency_documento totspese(abs(doc.spese()), doc);
TCurrency_documento totimposte(abs(doc.imposta(true)), doc);
TCurrency_documento totimponibili = totdoc - totspese - totimposte;
if (!cached_causale(head.get(MOV_CODCAUS), head.get_int(MOV_ANNOES)).reverse_charge_pubb())
totimponibili -= totimposte;
pag.set_total(totimponibili, totimposte, totspese);
}
pag.set_rate_auto();
const TRiga_partite& fatt = newgame->riga(p);
for (int r = 1; r <= fatt.rate() && r <= pag.n_rate(); r++)
{
const TRiga_scadenze& rata = fatt.rata(r);
@ -3058,7 +3073,7 @@ error_type TContabilizzazione::write_scadenze(TDocumento& doc, bool recontabiliz
}
}
if (!residuoval.is_zero())
if ((!residuoval.is_zero()) || (!residuolit.is_zero()))
{
// Pagamento non assegnato
TRectype unpag = newgame->pagamento(TPartita::UNASSIGNED, 0, nuova_riga);
@ -3068,7 +3083,7 @@ error_type TContabilizzazione::write_scadenze(TDocumento& doc, bool recontabiliz
unpag.put(PAGSCA_IMPORTO, residuolit.valore());
}
else
unpag.put(PAGSCA_IMPORTO, residuoval.valore());
unpag.put(PAGSCA_IMPORTO, residuolit.valore());
unpag.put(PAGSCA_ACCSAL, "A");
newgame->modifica_pagamento(unpag, cambio, true);
}