diff --git a/src/cg/cgsaldac.cpp b/src/cg/cgsaldac.cpp index 9be75393c..22eef3b42 100755 --- a/src/cg/cgsaldac.cpp +++ b/src/cg/cgsaldac.cpp @@ -1440,14 +1440,34 @@ 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(); + tipo_movimento t = row.tipo(); - if (regs[nreg]) + if (t == tm_pagamento) { - _part.destroy_row(r); - changed = true; + if (regs[nreg]) + { + _part.destroy_row(r); + changed = true; + } + else + { + regs.set(nreg); + + const long nriga = row.get_long(PART_NRIGA); + TToken_string key; + + key.add(nreg); + key.add(nriga); + + const TRectype & cg = cache().get(LF_RMOV, key); + + if (cg.empty()) + { + _part.destroy_row(r); + changed = true; + } + } } - else - regs.set(nreg); } if (_part.exist(UNASSIGNED)) @@ -1461,7 +1481,7 @@ bool TPartita::read(const TBill& clifo, int year, const char* num) if (_unassigned.rows() > 0 &&_part.rows() <= 0) // non assegnati orfani! _unassigned.destroy_rows(); -/* + TImporto saldo; TImporto doc; TImporto pag; @@ -1479,7 +1499,7 @@ TImporto saldo; if (saldo != oldsaldo || doc != olddoc || pag != oldpag || imp != oldimp) write_saldo(true); - */ + if (changed) rewrite();