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