diff --git a/cg/saldacon.cpp b/cg/saldacon.cpp index f9cf4db30..9c4084ab6 100755 --- a/cg/saldacon.cpp +++ b/cg/saldacon.cpp @@ -536,7 +536,7 @@ int TPartita::mov2rig(long numreg, int rm) const } // Trova la prima riga della partita contenente una fattura -int TPartita::prima_fattura() const +int TPartita::prima_fattura(long nreg) const { const int lastrow = last(); for (int r = first(); r <= lastrow; r = succ(r)) @@ -544,7 +544,23 @@ int TPartita::prima_fattura() const const TRiga_partite& row = riga(r); const int tipomov = row.get_int(PART_TIPOMOV); if (tipomov == 1 || tipomov == 2) - return r; + if (nreg == -1 || nreg == row.get_long(PART_NREG)) + return r; + } + return -1; +} + +// Trova la prima riga della partita contenente una fattura +int TPartita::primo_pagamento(long nreg) const +{ + const int lastrow = last(); + for (int r = first(); r <= lastrow; r = succ(r)) + { + const TRiga_partite& row = riga(r); + const int tipomov = row.get_int(PART_TIPOMOV); + if (tipomov == 3) // TBI controllare per insoluti (tipomov == 6) + if (nreg == -1 || nreg == row.get_long(PART_NREG)) + return r; } return -1; }