Hi Guys, I have sorted out the problem.
Some background: I deleted any invoices which were over 8 years old. As soon as I did this, the system then re-allocated payments from customers to new invoices marking them as paid. It seems obvious now but what I should have done was carefully remove invoices and their corresponding payments at the same time.
This makes the removal of old invoices much more tedious but at least it keeps things correct.