First, let’s correct terminology. A purchase invoice credits Accounts payable and the supplier’s subaccount. So a debit note debits Accounts payable. Nevertheless, I understood what you were describing.
As I was suspecting, your problem occurred because of the debit note. You haven’t explained everything in quite enough detail to be sure, but it sounds like your debit note might not have specified the purchase invoice it applied to, only the supplier. Is that correct? If so, you’ve created an unallocated amount of money that Manager will try to apply to open invoices. When you enter the refund receipt, if you specified an invoice, that one could end up being overdue because you’ve forced Manager to reverse a payment you already made on it.
Look at all the transactions involved again. Do they all specify invoices? If not, edit them so they do. If that doesn’t fix them, remove all invoice references from all of them to see how Manager auto allocates. Having still not seen all the transactions, it’s tough to visualize exactly what happened, but I think the trouble stems from a mix of transactions where part specified invoices and part did not. I think it will work either way, but requires consistency. Sorry, but I don’t have time to model this right now.