|
|
|
@ -366,16 +366,141 @@ TImporto TPartita::importo_pagsca(const TRectype& pag, bool val, int mode) const
|
|
|
|
|
TImporto TRiga_scadenze::importo_pagato_al(bool val, const TDate& al, int mode) const
|
|
|
|
|
{
|
|
|
|
|
CHECKD(mode > 0x0 && mode <= 0xFF, "Bad importo_pagato mode ", mode);
|
|
|
|
|
const TPartita& game = partita();
|
|
|
|
|
TPartita& game = partita();
|
|
|
|
|
|
|
|
|
|
TImporto totale;
|
|
|
|
|
for (int p = last(); p > 0; p = pred(p))
|
|
|
|
|
|
|
|
|
|
for (int p = last(); p > 0; p = pred(p))
|
|
|
|
|
{
|
|
|
|
|
const TRectype& pag = row(p); // Riga pagamento
|
|
|
|
|
const TRiga_partite& sum = game.riga(p); // Riga partite
|
|
|
|
|
const TDate datapag = sum.get_date(PART_DATAPAG);
|
|
|
|
|
const int rigap = row(p).get_int(PAGSCA_NRIGP);
|
|
|
|
|
TDate datapag;
|
|
|
|
|
|
|
|
|
|
if (game.esiste(rigap))
|
|
|
|
|
{
|
|
|
|
|
const TRiga_partite & sum = game.riga(rigap); // Riga partite
|
|
|
|
|
|
|
|
|
|
datapag = sum.get_date(PART_DATAPAG);
|
|
|
|
|
if (datapag <= al)
|
|
|
|
|
totale += game.importo_pagsca(pag, val, mode);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
const int rigaf = pag.get_int(PAGSCA_NRIGA);
|
|
|
|
|
const int nrata = pag.get_int(PAGSCA_NRATA);
|
|
|
|
|
const TRiga_partite & riga_part = game.riga(rigaf);
|
|
|
|
|
const TRiga_scadenze & scad = riga_part.rata(nrata);
|
|
|
|
|
const real importo = pag.get(PAGSCA_IMPORTO);
|
|
|
|
|
TImporto i((riga_part.get(PART_SEZ) == "A") ? 'D' : 'A', importo);
|
|
|
|
|
TRectype recpart(LF_PARTITE);
|
|
|
|
|
|
|
|
|
|
i.normalize();
|
|
|
|
|
datapag = scad.get_date(SCAD_DATASCAD);
|
|
|
|
|
const real imp = i.valore();
|
|
|
|
|
const char sez = i.sezione();
|
|
|
|
|
|
|
|
|
|
recpart.put(PART_TIPOCF, pag.get(PAGSCA_TIPOC));
|
|
|
|
|
recpart.put(PART_GRUPPO, pag.get(PAGSCA_GRUPPO));
|
|
|
|
|
recpart.put(PART_CONTO, pag.get(PAGSCA_CONTO));
|
|
|
|
|
recpart.put(PART_SOTTOCONTO, pag.get(PAGSCA_SOTTOCONTO));
|
|
|
|
|
recpart.put(PART_ANNO, pag.get(PAGSCA_ANNO));
|
|
|
|
|
recpart.put(PART_NUMPART, pag.get(PAGSCA_NUMPART));
|
|
|
|
|
recpart.put(PART_NRIGA, rigap);
|
|
|
|
|
recpart.put(PART_TIPOMOV, importo < ZERO ? tm_insoluto : tm_pagamento);
|
|
|
|
|
recpart.put(PART_TIPOPAG, scad.get_int(SCAD_TIPOPAG));
|
|
|
|
|
recpart.put(PART_SEZ, sez);
|
|
|
|
|
recpart.put(PART_IMPORTO, imp);
|
|
|
|
|
recpart.put(PART_IMPTOTDOC, imp);
|
|
|
|
|
recpart.put(PART_CHIUSA, game.rata_chiusa(rigaf, nrata));
|
|
|
|
|
|
|
|
|
|
// trova il movimento contabile
|
|
|
|
|
|
|
|
|
|
TRectype from(LF_RMOV);
|
|
|
|
|
TRectype to(LF_RMOV);
|
|
|
|
|
|
|
|
|
|
TCursor rmov(new TRelation(LF_RMOV), "", 3, &from, &to);
|
|
|
|
|
|
|
|
|
|
from.put(RMV_TIPOC, pag.get(PAGSCA_TIPOC));
|
|
|
|
|
from.put(RMV_SOTTOCONTO, pag.get(PAGSCA_SOTTOCONTO));
|
|
|
|
|
from.put(RMV_ROWTYPE, "K");
|
|
|
|
|
from.put(RMV_DATAREG, TDate(1, 1, datapag.year()));
|
|
|
|
|
to.put(RMV_TIPOC, pag.get(PAGSCA_TIPOC));
|
|
|
|
|
to.put(RMV_SOTTOCONTO, pag.get(PAGSCA_SOTTOCONTO));
|
|
|
|
|
to.put(RMV_ROWTYPE, "K");
|
|
|
|
|
to.put(RMV_DATAREG, TDate(31, 12, datapag.year()));
|
|
|
|
|
rmov.setregion(from, to);
|
|
|
|
|
const long items = rmov.items();
|
|
|
|
|
long nreg = 0L;
|
|
|
|
|
int nrig = 0;
|
|
|
|
|
|
|
|
|
|
for (rmov = 0L; rmov.pos() < items && nreg <= 0L; ++rmov)
|
|
|
|
|
{
|
|
|
|
|
const char sezione = rmov.curr().get_char(RMV_SEZIONE);
|
|
|
|
|
|
|
|
|
|
if (sezione == sez)
|
|
|
|
|
{
|
|
|
|
|
const real importo = rmov.curr().get_real(RMV_IMPORTO);
|
|
|
|
|
|
|
|
|
|
if (imp == importo)
|
|
|
|
|
{
|
|
|
|
|
nreg = rmov.curr().get_long(RMV_NUMREG);
|
|
|
|
|
nrig = rmov.curr().get_long(RMV_NUMRIG);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
if (imp < importo)
|
|
|
|
|
{
|
|
|
|
|
nreg = -rmov.curr().get_long(RMV_NUMREG);
|
|
|
|
|
nrig = rmov.curr().get_long(RMV_NUMRIG);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (nreg < 0L)
|
|
|
|
|
nreg = abs(nreg);
|
|
|
|
|
if (nreg > 0L)
|
|
|
|
|
{
|
|
|
|
|
const TRectype & mov = cache().get(LF_MOV, nreg);
|
|
|
|
|
TString descr = rmov.curr().get(RMV_DESCR);
|
|
|
|
|
|
|
|
|
|
if (descr.empty())
|
|
|
|
|
descr = mov.get(MOV_DESCR);
|
|
|
|
|
recpart.put(PART_NREG, nreg);
|
|
|
|
|
recpart.put(PART_NUMRIG, nrig);
|
|
|
|
|
recpart.put(PART_DESCR, descr);
|
|
|
|
|
recpart.put(PART_DATAREG, mov.get_date(MOV_DATAREG));
|
|
|
|
|
recpart.put(PART_DATADOC, mov.get_date(MOV_DATADOC));
|
|
|
|
|
datapag = mov.get_date(MOV_DATAREG);
|
|
|
|
|
recpart.put(PART_DATAPAG, datapag);
|
|
|
|
|
recpart.put(PART_NUMDOC, mov.get(MOV_NUMDOC));
|
|
|
|
|
recpart.put(PART_CODCAUS, mov.get(MOV_CODCAUS));
|
|
|
|
|
recpart.put(PART_CODVAL, mov.get(MOV_CODVAL));
|
|
|
|
|
recpart.put(PART_CAMBIO, mov.get(MOV_CAMBIO));
|
|
|
|
|
recpart.put(PART_DATACAM, mov.get_date(MOV_DATACAM));
|
|
|
|
|
recpart.put(PART_IMPORTOVAL, pag.get_real(PAGSCA_IMPORTOVAL));
|
|
|
|
|
recpart.put(PART_IMPTOTVAL, pag.get_real(PAGSCA_IMPORTOVAL));
|
|
|
|
|
recpart.put(PART_RITENUTE, mov.get_real(MOV_RITFIS));
|
|
|
|
|
recpart.put(PART_RITSOC, mov.get_real(MOV_RITSOC));
|
|
|
|
|
recpart.put(PART_ABBUONI, pag.get_real(PAGSCA_ABBUONI));
|
|
|
|
|
recpart.put(PART_DIFFCAM, pag.get_real(PAGSCA_DIFFCAM));
|
|
|
|
|
recpart.put(PART_SEZABB, sez);
|
|
|
|
|
recpart.put(PART_SEZDIFCAM, sez);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
datapag = scad.get_date(SCAD_DATASCAD);
|
|
|
|
|
|
|
|
|
|
recpart.put(PART_DESCR, "Riga Pagamento recuperata");
|
|
|
|
|
recpart.put(PART_DATAREG, datapag);
|
|
|
|
|
recpart.put(PART_DATADOC, datapag);
|
|
|
|
|
recpart.put(PART_DATAPAG, datapag);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int err = recpart.write();
|
|
|
|
|
|
|
|
|
|
if (err != NOERR)
|
|
|
|
|
error_box(FR("Errore n.ro %d nel recupero partita"), err);
|
|
|
|
|
}
|
|
|
|
|
if (datapag <= al)
|
|
|
|
|
totale += game.importo_pagsca(pag, val, mode);
|
|
|
|
|
totale += game.importo_pagsca(row(p), val, mode);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return totale.normalize();
|
|
|
|
@ -806,9 +931,9 @@ tipo_movimento TRiga_partite::tipo() const
|
|
|
|
|
tm = tm_fattura;
|
|
|
|
|
#ifdef DBG
|
|
|
|
|
else
|
|
|
|
|
yesnofatal_box("Riga partite %c%ld %d/%s : %d con un tipo losco.",
|
|
|
|
|
get_char(PART_TIPOCF), get_long(PART_SOTTOCONTO),
|
|
|
|
|
get_int(PART_ANNO), (const char*)get(PART_NUMPART), nriga);
|
|
|
|
|
yesno_box("Riga partite %c%ld %d/%s : %d con un tipo losco.",
|
|
|
|
|
get_char(PART_TIPOCF), get_long(PART_SOTTOCONTO),
|
|
|
|
|
get_int(PART_ANNO), (const char*)get(PART_NUMPART), nriga);
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -1361,6 +1486,132 @@ void TPartita::allinea(char all)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void TPartita::recover_rpart(const TRectype & pag, int rigap, int unass_row)
|
|
|
|
|
{
|
|
|
|
|
const int rigaf = pag.get_int(PAGSCA_NRIGA);
|
|
|
|
|
const int nrata = pag.get_int(PAGSCA_NRATA);
|
|
|
|
|
TRiga_partite & recpart = new_row(rigap);
|
|
|
|
|
const real importo = pag.get(PAGSCA_IMPORTO);
|
|
|
|
|
char sez = pag.get(PAGSCA_TIPOC) == "C" ? 'A' : 'D';
|
|
|
|
|
TDate datapag(31, 12, _anno);
|
|
|
|
|
tipo_movimento tipopag = tm_pagamento;
|
|
|
|
|
|
|
|
|
|
if (rigaf != UNASSIGNED)
|
|
|
|
|
{
|
|
|
|
|
const TRiga_partite & riga_part = riga(rigaf);
|
|
|
|
|
const TRiga_scadenze & scad = riga_part.rata(nrata);
|
|
|
|
|
|
|
|
|
|
datapag = scad.get_date(SCAD_DATASCAD);
|
|
|
|
|
tipopag = (tipo_movimento) scad.get_int(SCAD_TIPOPAG);
|
|
|
|
|
sez = (riga_part.get(PART_SEZ) == "A") ? 'D' : 'A';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TImporto i(sez, importo);
|
|
|
|
|
|
|
|
|
|
i.normalize();
|
|
|
|
|
|
|
|
|
|
const real imp = i.valore();
|
|
|
|
|
|
|
|
|
|
sez = i.sezione();
|
|
|
|
|
recpart.put(PART_TIPOCF, pag.get(PAGSCA_TIPOC));
|
|
|
|
|
recpart.put(PART_GRUPPO, pag.get(PAGSCA_GRUPPO));
|
|
|
|
|
recpart.put(PART_CONTO, pag.get(PAGSCA_CONTO));
|
|
|
|
|
recpart.put(PART_SOTTOCONTO, pag.get(PAGSCA_SOTTOCONTO));
|
|
|
|
|
recpart.put(PART_ANNO, pag.get(PAGSCA_ANNO));
|
|
|
|
|
recpart.put(PART_NUMPART, pag.get(PAGSCA_NUMPART));
|
|
|
|
|
recpart.put(PART_NRIGA, rigap);
|
|
|
|
|
recpart.put(PART_TIPOMOV, importo < ZERO ? tm_insoluto : tm_pagamento);
|
|
|
|
|
recpart.put(PART_TIPOPAG, tipopag);
|
|
|
|
|
recpart.put(PART_SEZ, sez);
|
|
|
|
|
recpart.put(PART_IMPORTO, imp);
|
|
|
|
|
recpart.put(PART_IMPTOTDOC, imp);
|
|
|
|
|
recpart.put(PART_CHIUSA, rata_chiusa(rigaf, nrata));
|
|
|
|
|
|
|
|
|
|
// trova il movimento contabile
|
|
|
|
|
|
|
|
|
|
TRectype from(LF_RMOV);
|
|
|
|
|
TRectype to(LF_RMOV);
|
|
|
|
|
|
|
|
|
|
TCursor rmov(new TRelation(LF_RMOV), "", 3, &from, &to);
|
|
|
|
|
|
|
|
|
|
from.put(RMV_TIPOC, pag.get(PAGSCA_TIPOC));
|
|
|
|
|
from.put(RMV_SOTTOCONTO, pag.get(PAGSCA_SOTTOCONTO));
|
|
|
|
|
from.put(RMV_ROWTYPE, "K");
|
|
|
|
|
from.put(RMV_DATAREG, TDate(1, 1, datapag.year()));
|
|
|
|
|
to.put(RMV_TIPOC, pag.get(PAGSCA_TIPOC));
|
|
|
|
|
to.put(RMV_SOTTOCONTO, pag.get(PAGSCA_SOTTOCONTO));
|
|
|
|
|
to.put(RMV_ROWTYPE, "K");
|
|
|
|
|
to.put(RMV_DATAREG, TDate(31, 12, datapag.year()));
|
|
|
|
|
rmov.setregion(from, to);
|
|
|
|
|
const long items = rmov.items();
|
|
|
|
|
long nreg = 0L;
|
|
|
|
|
int nrig = 0;
|
|
|
|
|
|
|
|
|
|
for (rmov = 0L; rmov.pos() < items && nreg <= 0L; ++rmov)
|
|
|
|
|
{
|
|
|
|
|
const char sezione = rmov.curr().get_char(RMV_SEZIONE);
|
|
|
|
|
|
|
|
|
|
if (sezione == sez)
|
|
|
|
|
{
|
|
|
|
|
const real importo = rmov.curr().get_real(RMV_IMPORTO);
|
|
|
|
|
|
|
|
|
|
if (imp == importo)
|
|
|
|
|
{
|
|
|
|
|
nreg = rmov.curr().get_long(RMV_NUMREG);
|
|
|
|
|
nrig = rmov.curr().get_long(RMV_NUMRIG);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
if (imp < importo)
|
|
|
|
|
{
|
|
|
|
|
nreg = -rmov.curr().get_long(RMV_NUMREG);
|
|
|
|
|
nrig = rmov.curr().get_long(RMV_NUMRIG);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (nreg < 0L)
|
|
|
|
|
nreg = abs(nreg);
|
|
|
|
|
|
|
|
|
|
const TRectype & mov = cache().get(LF_RMOV, nreg);
|
|
|
|
|
|
|
|
|
|
if (mov.full())
|
|
|
|
|
{
|
|
|
|
|
TString descr = rmov.curr().get(RMV_DESCR);
|
|
|
|
|
|
|
|
|
|
if (descr.empty())
|
|
|
|
|
descr = mov.get(MOV_DESCR);
|
|
|
|
|
recpart.put(PART_NREG, nreg);
|
|
|
|
|
recpart.put(PART_NUMRIG, nrig);
|
|
|
|
|
recpart.put(PART_DESCR, "Riga Pagamento recuperata");
|
|
|
|
|
recpart.put(PART_DATAREG, mov.get_date(MOV_DATAREG));
|
|
|
|
|
recpart.put(PART_DATADOC, mov.get_date(MOV_DATADOC));
|
|
|
|
|
recpart.put(PART_DATAPAG, mov.get_date(MOV_DATAREG));
|
|
|
|
|
recpart.put(PART_NUMDOC, mov.get(MOV_NUMDOC));
|
|
|
|
|
recpart.put(PART_CODCAUS, mov.get(MOV_CODCAUS));
|
|
|
|
|
recpart.put(PART_CODVAL, mov.get(MOV_CODVAL));
|
|
|
|
|
recpart.put(PART_CAMBIO, mov.get(MOV_CAMBIO));
|
|
|
|
|
recpart.put(PART_IMPORTOVAL, pag.get_real(PAGSCA_IMPORTOVAL));
|
|
|
|
|
recpart.put(PART_IMPTOTVAL, pag.get_real(PAGSCA_IMPORTOVAL));
|
|
|
|
|
recpart.put(PART_RITENUTE, mov.get_real(MOV_RITFIS));
|
|
|
|
|
recpart.put(PART_RITSOC, mov.get_real(MOV_RITSOC));
|
|
|
|
|
recpart.put(PART_ABBUONI, pag.get_real(PAGSCA_ABBUONI));
|
|
|
|
|
recpart.put(PART_DIFFCAM, pag.get_real(PAGSCA_DIFFCAM));
|
|
|
|
|
recpart.put(PART_SEZABB, sez);
|
|
|
|
|
recpart.put(PART_SEZDIFCAM, sez);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
recpart.put(PART_DESCR, "Riga Pagamento recuperata");
|
|
|
|
|
recpart.put(PART_DATAREG, datapag);
|
|
|
|
|
recpart.put(PART_DATADOC, datapag);
|
|
|
|
|
recpart.put(PART_DATAPAG, datapag);
|
|
|
|
|
if (rigaf == UNASSIGNED && unass_row > 0)
|
|
|
|
|
{
|
|
|
|
|
_unassigned.destroy_row(unass_row);
|
|
|
|
|
rimuovi_riga(rigap);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TPartita::is_on_file() const
|
|
|
|
|
{
|
|
|
|
|
TLocalisamfile partite(LF_PARTITE);
|
|
|
|
@ -1431,7 +1682,7 @@ bool TPartita::read(const TBill& clifo, int year, const char* num)
|
|
|
|
|
partita->renum_key(PART_NUMPART, _num); // Numero partita
|
|
|
|
|
_part.read(partita);
|
|
|
|
|
|
|
|
|
|
TBit_array regs;
|
|
|
|
|
TAssoc_array regs;
|
|
|
|
|
int firstrow =first();
|
|
|
|
|
bool changed = false;
|
|
|
|
|
|
|
|
|
@ -1439,31 +1690,26 @@ bool TPartita::read(const TBill& clifo, int year, const char* num)
|
|
|
|
|
{
|
|
|
|
|
TRiga_partite & row = riga(r);
|
|
|
|
|
long nreg = row.get_long(PART_NREG);
|
|
|
|
|
int rate = row.rate();
|
|
|
|
|
const int nriga = row.get_long(PART_NRIGA);
|
|
|
|
|
tipo_movimento t = row.tipo();
|
|
|
|
|
|
|
|
|
|
if (t == tm_pagamento)
|
|
|
|
|
if (t == tm_pagamento && nreg > 0)
|
|
|
|
|
{
|
|
|
|
|
if (regs[nreg])
|
|
|
|
|
TToken_string key;
|
|
|
|
|
|
|
|
|
|
key.add(nreg);
|
|
|
|
|
key.add(nriga);
|
|
|
|
|
if (regs.is_key(key))
|
|
|
|
|
{
|
|
|
|
|
_part.destroy_row(r);
|
|
|
|
|
((TRiga_partite &)_part.row(r)).zero(PART_NREG);
|
|
|
|
|
((TRiga_partite &)_part.row(r)).zero(PART_NUMRIG);
|
|
|
|
|
changed = true;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
regs.set(nreg);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!changed)
|
|
|
|
|
for (int r = last(); r >= firstrow; r = pred(r))
|
|
|
|
|
{
|
|
|
|
|
TRiga_partite & row = riga(r);
|
|
|
|
|
long nreg = row.get_long(PART_NREG);
|
|
|
|
|
int rate = row.rate();
|
|
|
|
|
tipo_movimento t = row.tipo();
|
|
|
|
|
regs.add(key);
|
|
|
|
|
|
|
|
|
|
if (t == tm_pagamento)
|
|
|
|
|
if (nreg > 0)
|
|
|
|
|
{
|
|
|
|
|
const long nriga = row.get_long(PART_NRIGA);
|
|
|
|
|
TToken_string key;
|
|
|
|
|
|
|
|
|
|
key.add(nreg);
|
|
|
|
@ -1477,29 +1723,55 @@ bool TPartita::read(const TBill& clifo, int year, const char* num)
|
|
|
|
|
|
|
|
|
|
if (m.cg_rows() == 0)
|
|
|
|
|
{
|
|
|
|
|
_part.destroy_row(r);
|
|
|
|
|
((TRiga_partite &)_part.row(r)).zero(PART_NREG);
|
|
|
|
|
((TRiga_partite &)_part.row(r)).zero(PART_NUMRIG);
|
|
|
|
|
changed = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (_part.exist(UNASSIGNED))
|
|
|
|
|
_part.destroy_row(UNASSIGNED); // Elimina riga saldo;
|
|
|
|
|
|
|
|
|
|
TRectype* unas = new TRectype(LF_PAGSCA); // Record pagamenti non assegnati
|
|
|
|
|
partita->copy_key_to_row(*unas);
|
|
|
|
|
unas->put(PART_NRIGA, (int)UNASSIGNED);
|
|
|
|
|
unas->put(SCAD_NRATA, (int)UNASSIGNED);
|
|
|
|
|
_unassigned.read(unas);
|
|
|
|
|
if (_unassigned.rows() > 0 &&_part.rows() <= 0) // non assegnati orfani!
|
|
|
|
|
_unassigned.destroy_rows();
|
|
|
|
|
}
|
|
|
|
|
for (int p = last(); p > 0; p = pred(p))
|
|
|
|
|
{
|
|
|
|
|
TRiga_partite & rpart = riga(p);
|
|
|
|
|
|
|
|
|
|
if (rpart.tipo() == tm_fattura)
|
|
|
|
|
{
|
|
|
|
|
int nrate = rpart.rate();
|
|
|
|
|
for (int s = 1; s <= nrate; s++)
|
|
|
|
|
{
|
|
|
|
|
TRiga_scadenze & rscad = rpart.rata(s);
|
|
|
|
|
|
|
|
|
|
TImporto saldo;
|
|
|
|
|
for (int rp = last(); rp > 0; rp = pred(rp))
|
|
|
|
|
{
|
|
|
|
|
const TRectype& pag = rscad.row(rp); // Riga pagamento
|
|
|
|
|
const int rigap = pag.get_int(PAGSCA_NRIGP);
|
|
|
|
|
|
|
|
|
|
if (!esiste(rigap))
|
|
|
|
|
{
|
|
|
|
|
recover_rpart(pag, rigap);
|
|
|
|
|
changed = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (_part.exist(UNASSIGNED))
|
|
|
|
|
_part.destroy_row(UNASSIGNED); // Elimina riga saldo;
|
|
|
|
|
|
|
|
|
|
TRectype* unas = new TRectype(LF_PAGSCA); // Record pagamenti non assegnati
|
|
|
|
|
partita->copy_key_to_row(*unas);
|
|
|
|
|
unas->put(PART_NRIGA, (int)UNASSIGNED);
|
|
|
|
|
unas->put(SCAD_NRATA, (int)UNASSIGNED);
|
|
|
|
|
_unassigned.read(unas);
|
|
|
|
|
if (_unassigned.rows() > 0 && _part.rows() <= 0) // non assegnati orfani!
|
|
|
|
|
_unassigned.destroy_rows();
|
|
|
|
|
|
|
|
|
|
TImporto saldo;
|
|
|
|
|
TImporto doc;
|
|
|
|
|
TImporto pag;
|
|
|
|
|
TImporto imp;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
calcola_saldo(saldo, doc, pag, imp);
|
|
|
|
|
|
|
|
|
|
TImporto oldsaldo;
|
|
|
|
@ -1508,15 +1780,23 @@ TImporto saldo;
|
|
|
|
|
TImporto oldimp;
|
|
|
|
|
TRectype riga_saldo(LF_PARTITE);
|
|
|
|
|
|
|
|
|
|
read_saldo(riga_saldo,oldsaldo, olddoc, oldpag, oldimp, true);
|
|
|
|
|
read_saldo(riga_saldo, oldsaldo, olddoc, oldpag, oldimp, true);
|
|
|
|
|
|
|
|
|
|
if (saldo != oldsaldo || doc != olddoc || pag != oldpag || imp != oldimp)
|
|
|
|
|
write_saldo(true);
|
|
|
|
|
for (int f = _unassigned.last_row(); f > 0; f = _unassigned.pred_row(f))
|
|
|
|
|
{
|
|
|
|
|
const TRectype & pag = _unassigned.row(f);
|
|
|
|
|
const int rigap = pag.get_int(PAGSCA_NRIGP);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!esiste(rigap))
|
|
|
|
|
{
|
|
|
|
|
recover_rpart(pag, rigap, f);
|
|
|
|
|
changed = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (changed)
|
|
|
|
|
rewrite();
|
|
|
|
|
|
|
|
|
|
return ok();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -1709,10 +1989,9 @@ TRiga_partite& TPartita::riga(int r) const
|
|
|
|
|
{
|
|
|
|
|
if (r > 0 && !_part.exist(r))
|
|
|
|
|
{
|
|
|
|
|
yesnofatal_box("La partita %d %s del conto %c %d %d %ld (%s) è incoerente: manca la riga %d",
|
|
|
|
|
anno(), (const char*)numero(),
|
|
|
|
|
_conto.tipo(), _conto.gruppo(), _conto.conto(), _conto.sottoconto(),
|
|
|
|
|
(const char*)_conto.descrizione(), r);
|
|
|
|
|
yesno_box("La partita %d %s del conto %c %d %d %ld (%s) è incoerente: manca la riga %d",
|
|
|
|
|
anno(), (const char*)numero(), _conto.tipo(), _conto.gruppo(), _conto.conto(),
|
|
|
|
|
_conto.sottoconto(), (const char*)_conto.descrizione(), r);
|
|
|
|
|
|
|
|
|
|
// Ricreiamo una riga fasulla tanto per non bloccare il programma
|
|
|
|
|
TRiga_partite& newrow = ((TPartita*)this)->new_row(r);
|
|
|
|
|