Patch level : 12.0 566

Files correlati     : cg4.exe f171.dir f171.trr

Modificata la liquidazione delle fatture in ritardo
Aggiunta la gestione dell'uscita dal regime di cassa
Sistemata la cancellazione di IVADIFF nei mesi e in 13.

git-svn-id: svn://10.65.10.50/branches/R_10_00@24470 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
bonazzi 2018-04-24 07:44:01 +00:00
parent 20907f72fb
commit 70dbffa8e9

View File

@ -1072,7 +1072,7 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt, TAssoc_array &
t.set_year(month < 12 ? year_int : year_int+1);
t.set_month(month < 12 ? 12 : _freqviva == "M" ? 1 : 3);
}
t.set_end_month();
t.set_end_month();
const TDate inizio(fromdate - 1L);
@ -1156,7 +1156,7 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt, TAssoc_array &
#ifdef DBG
long nr = _mov->get_long(MOV_NUMREG);
if (nr == 22060 || nr == 27710)
if (nr == 1931434 || nr == 27710)
int i = 1;
#endif
@ -1236,12 +1236,12 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt, TAssoc_array &
#ifdef DBG
nr = _mov->get_long(MOV_NUMREG);
if (nr == 22060 || nr == 27710)
if (nr == 29214 || nr == 27710)
int i = 1;
#endif
if (fattrit && _month == 13)
dok = true;
if (fattrit)
dok = (atoi(_year) == datadoc.year()) && _month == 13;
if (bIsMovDiff && tm == tm_fattura)
{
@ -1264,102 +1264,111 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt, TAssoc_array &
const TPartita* p = arrpart.first();
const int row = p ? p->mov2rig(numreg, 0) : 0;
game_found = row > 0;
if (game_found && !id_chiusa)
{
const TRiga_partite& rp = p->riga(row);
if (game_found && !id_chiusa)
{
const TRiga_partite& rp = p->riga(row);
TDate orizzonte = fine; // caso tradizionale
if (iva_cass)
{
TDate data_rif = data_maturazione_IVA_diff(_mov->curr());
if (data_rif < fine)
orizzonte = data_rif;
}
TDate orizzonte = fine; // caso tradizionale
TImporto pg_per, nc_per;
if (iva_cass)
{
TDate data_rif = data_maturazione_IVA_diff(_mov->curr());
if (data_rif < fine)
orizzonte = data_rif;
}
TImporto pg_per, nc_per;
bool regular_month = orizzonte >= date;
bool first_month = regular_month && date > inizio + 1L;
#ifdef DBG
nr = _mov->get_long(MOV_NUMREG);
if (nr == 22060 || nr == 27710)
if (nr == 29214 || nr == 27710)
int i = 1;
#endif
flag_pg_nc = rp.calcola_pagato_periodo(first_month ? botime : inizio + 1L, orizzonte, pg_per, nc_per, &pagscatt) && regular_month;
if (pagscatt.items() >= 2)
{
// Fondo tra loro le righe generate dallo stesso pagamento
for (int p = pagscatt.last(); p > 0; p--)
{
const TRectype& p0 = (const TRectype&)pagscatt[p];
const TRectype& p1 = (const TRectype&)pagscatt[p-1];
if (p0.get_int(PAGSCA_NRIGP) == p1.get_int(PAGSCA_NRIGP))
{
const real imp = p0.get_real(PAGSCA_IMPORTO);
((TRectype&)p1).add(PAGSCA_IMPORTO, imp);
pagscatt.destroy(p, true);
}
}
}
if (iva_diff || sarebbe_maturata(_mov->curr(), inizio+1L, fine) || (iva_cass && _end_cassa))
{
TPointer_array pagscaold;
TImporto pg_tot, nc_tot;
if (pagscatt.items() >= 2)
{
// Fondo tra loro le righe generate dallo stesso pagamento
for (int p = pagscatt.last(); p > 0; p--)
{
const TRectype& p0 = (const TRectype&)pagscatt[p];
const TRectype& p1 = (const TRectype&)pagscatt[p - 1];
if (p0.get_int(PAGSCA_NRIGP) == p1.get_int(PAGSCA_NRIGP))
{
const real imp = p0.get_real(PAGSCA_IMPORTO);
((TRectype&)p1).add(PAGSCA_IMPORTO, imp);
pagscatt.destroy(p, true);
}
}
}
if (iva_diff || sarebbe_maturata(_mov->curr(), inizio + 1L, fine) || (iva_cass && _end_cassa))
{
TPointer_array pagscaold;
TImporto pg_tot, nc_tot;
rp.calcola_pagato_periodo(TDate(0L), orizzonte, pg_tot, nc_tot, &pagscaold);
// Controllo se ci siam persi delle note di credito negli anni scorsi
if (!nc_tot.is_zero() && pagscaold.items() > pagscatt.items())
{
FOR_EACH_ARRAY_ITEM(pagscaold, i, obj)
{
const TRectype& pagsca = *(const TRectype*)obj;
const int anno = pagsca.get_int(PAGSCA_ANNO);
const int nrigp = pagsca.get_int(PAGSCA_NRIGP);
// Appartiene all'anno scorso?
if (anno < year_int && nrigp < 999) // 9999 on pagsca -> 999 on ivadiff
{
const TPartita& p = arrpart.partita(pagsca);
const TRiga_partite& rp = p.riga(nrigp);
// E' veramente una nota di credito?
if (rp.tipo() == tm_nota_credito)
{
bool found = false;
FOR_EACH_ARRAY_ITEM(pagscatt, j, ps)
{
if (ps == obj)
{
found = true;
break;
}
}
if (!found)
{
TLocalisamfile id(LF_IVADIFF);
id.put(RMI_NUMREG, _rmoviva->get(RMI_NUMREG));
id.put(RMI_NUMRIG, _rmoviva->get(RMI_NUMRIG));
id.put("NUMPRO", nrigp);
if (id.read(_isequal) != NOERR || id.get_int("ANNOLIQ") == 0)
pagscatt.add(obj);
}
}
}
}
}
// Controllo se ci siam persi delle note di credito negli anni scorsi
if (!nc_tot.is_zero() && pagscaold.items() > pagscatt.items())
{
FOR_EACH_ARRAY_ITEM(pagscaold, i, obj)
{
const TRectype& pagsca = *(const TRectype*)obj;
const int anno = pagsca.get_int(PAGSCA_ANNO);
const int nrigp = pagsca.get_int(PAGSCA_NRIGP);
// Appartiene all'anno scorso?
if (anno < year_int && nrigp < 999) // 9999 on pagsca -> 999 on ivadiff
{
const TPartita& p = arrpart.partita(pagsca);
const TRiga_partite& rp = p.riga(nrigp);
// E' veramente una nota di credito?
if (rp.tipo() == tm_nota_credito)
{
bool found = false;
FOR_EACH_ARRAY_ITEM(pagscatt, j, ps)
{
if (ps == obj)
{
found = true;
break;
}
}
if (!found)
{
TLocalisamfile id(LF_IVADIFF);
id.put(RMI_NUMREG, _rmoviva->get(RMI_NUMREG));
id.put(RMI_NUMRIG, _rmoviva->get(RMI_NUMRIG));
id.put("NUMPRO", nrigp);
if (id.read(_isequal) != NOERR || id.get_int("ANNOLIQ") == 0)
pagscatt.add(obj);
}
}
}
}
}
TImporto incasso = pg_tot;
TImporto saldo = rp.importo(false);
incasso += nc_tot;
saldo += incasso;
saldo.normalize(sezfat);
saldo += incasso;
saldo.normalize(sezfat);
incasso.normalize(sezpag);
if (saldo.valore() > ZERO)
tot_da_incassare = saldo.valore();
if (saldo.valore() > ZERO)
tot_da_incassare = saldo.valore();
if (incasso.valore() > ZERO)
tot_incassato = incasso.valore();
}
}
}
else
{
TImporto incasso = pg_per;
incasso += nc_per;
incasso.normalize(sezpag);
if (incasso.valore() > ZERO)
tot_incassato = incasso.valore();
}
}
}
if (!game_found) // No saldaconto o partita assente
{
@ -1529,7 +1538,7 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt, TAssoc_array &
#ifdef DBG
nr = _mov->get_long(MOV_NUMREG);
if (nr == 22060 || nr == 27710)
if (nr == 29214 || nr == 27710)
int i = 1;
#endif