How to allocate overpayments to invoices

How to allocate overpayments to invoices