Patch level : 10.0 290
Files correlati : Commento : Corretta liquidazione per quanto riguarda l'IVA differita, vedi Diana2000 settembre. git-svn-id: svn://10.65.10.50/branches/R_10_00@23379 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
23361876f6
commit
adfc9e1e5d
@ -693,74 +693,6 @@ bool TLiquidazione_app::sarebbe_maturata(const TRectype& mov, const TDate& inizi
|
||||
return true; // E' passato più di un anno!
|
||||
}
|
||||
|
||||
bool TLiquidazione_app::residuo_da_liquidare(const TRectype& lastid, real& importo_res, real& imponib_res, real& imposta_res) const
|
||||
{
|
||||
const long numreg = lastid.get_long(RMI_NUMREG);
|
||||
const int numrig = lastid.get_int(RMI_NUMRIG);
|
||||
CHECKD(numreg > 0 && numrig > 0, "Numero registrazione non valido ", numreg);
|
||||
const long lastpro = lastid.get_long("NUMPRO");
|
||||
|
||||
bool found = false;
|
||||
|
||||
if (!found) // dummy bracketing test
|
||||
{
|
||||
TString query;
|
||||
query << "USE IVADIFF"
|
||||
<< "\nFROM NUMREG=" << numreg << " NUMRIG=" << numrig
|
||||
<< "\nTO NUMREG=" << numreg << " NUMRIG=" << numrig;
|
||||
TISAM_recordset id(query);
|
||||
found = id.items() >= 2; // riga fattura ed almeno un pagamento o nota di credito
|
||||
if (found)
|
||||
{
|
||||
TImporto importo, imponib, imposta;
|
||||
for (bool ok = id.move_first(); ok; ok = id.move_next())
|
||||
{
|
||||
const char sez = id.get("SEZIONE").as_string()[0];
|
||||
const long numpro = id.get("NUMPRO").as_int();
|
||||
if (numpro != lastpro)
|
||||
{
|
||||
importo += TImporto(sez, id.get(PAGSCA_IMPORTO).as_real());
|
||||
imponib += TImporto(sez, id.get(RMI_IMPONIBILE).as_real());
|
||||
imposta += TImporto(sez, id.get(RMI_IMPOSTA).as_real());
|
||||
}
|
||||
}
|
||||
|
||||
bool is_good = imponib.valore() > ZERO;
|
||||
if (!is_good)
|
||||
{
|
||||
const TRectype& mov_head = cache().get(LF_MOV, numreg);
|
||||
int good_sign = +1;
|
||||
if (mov_head.get_int(MOV_TIPOMOV) == tm_fattura && mov_head.get(MOV_TIPODOC) == "NC")
|
||||
good_sign = -1;
|
||||
const real totdoc = mov_head.get(MOV_TOTDOC);
|
||||
is_good = totdoc.sign() == good_sign;
|
||||
}
|
||||
if (is_good)
|
||||
{
|
||||
importo_res = importo.valore();
|
||||
imponib_res = imponib.valore();
|
||||
imposta_res = imposta.valore();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!found)
|
||||
{
|
||||
TLocalisamfile rmi(LF_RMOVIVA);
|
||||
rmi.put(RMI_NUMREG, numreg);
|
||||
rmi.put(RMI_NUMRIG, numrig);
|
||||
found = rmi.read() == NOERR;
|
||||
if (found)
|
||||
{
|
||||
imposta_res = rmi.get_real(RMI_IMPOSTA);
|
||||
imponib_res = rmi.get_real(RMI_IMPONIBILE);
|
||||
importo_res = imponib_res + imposta_res;
|
||||
}
|
||||
}
|
||||
|
||||
return found;
|
||||
}
|
||||
|
||||
static bool partita_chiusa_al(const TPartita& p, const TDate& d)
|
||||
{
|
||||
bool c = p.chiusa();
|
||||
@ -1573,42 +1505,28 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt)
|
||||
}
|
||||
idcurr.put("MESELIQ", meseliq);
|
||||
idcurr.put("SEZIONE", pagtmp.sezione());
|
||||
if (ultimo)
|
||||
{
|
||||
real importo, imponibile, imposta;
|
||||
residuo_da_liquidare(idcurr, importo, imponibile, imposta);
|
||||
idcurr.put("IMPORTO", importo);
|
||||
idcurr.put(RMI_IMPONIBILE, imponibile);
|
||||
idcurr.put(RMI_IMPOSTA, imposta);
|
||||
if (tipomov_pag >= tm_pagamento) // 5-3-2014 incremento incdiff_imp solo coi pagamenti! Coerentemente con !ultimo
|
||||
{
|
||||
incdiff_imp += imponibile; // ??????????? qui
|
||||
incdiff_iva += imposta;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
const real perc = pagtmp.valore() / totfat;
|
||||
|
||||
real val_imp = imponibile_orig * perc;
|
||||
round_al_centesimo(val_imp);
|
||||
const real perc = pagtmp.valore() / totfat;
|
||||
|
||||
real val_imp = imponibile_orig * perc;
|
||||
round_al_centesimo(val_imp);
|
||||
|
||||
real val_iva = imposta_orig * perc;
|
||||
round_al_centesimo(val_iva);
|
||||
real val_iva = imposta_orig * perc;
|
||||
round_al_centesimo(val_iva);
|
||||
|
||||
idcurr.put("IMPORTO", val_imp + val_iva);
|
||||
idcurr.put(RMI_IMPONIBILE, val_imp);
|
||||
idcurr.put(RMI_IMPOSTA, val_iva);
|
||||
idcurr.put("IMPORTO", val_imp + val_iva);
|
||||
idcurr.put(RMI_IMPONIBILE, val_imp);
|
||||
idcurr.put(RMI_IMPOSTA, val_iva);
|
||||
|
||||
if (tipomov_pag >= tm_pagamento)
|
||||
{
|
||||
incdiff_imp += val_imp;
|
||||
incdiff_iva += val_iva;
|
||||
}
|
||||
if (tipomov_pag >= tm_pagamento)
|
||||
{
|
||||
incdiff_imp += val_imp;
|
||||
incdiff_iva += val_iva;
|
||||
}
|
||||
|
||||
int err = id.rewrite();
|
||||
if (err != NOERR)
|
||||
|
||||
if (err != NOERR)
|
||||
error_box("Errore %d in aggiornamento file IVADIFF", err);
|
||||
LOG_IVA_DIFF(id.curr());
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user