How do I attached an existing payment to an invoice

Some how I managed to untie a few payments from an invoice so it shows that I have a payment (credit) balance. I have the cash deposited into the checking account and the payments and invoices both show in my customer invoice log.