This can be achieved through Excess Payment. If you have collected payment from a customer in advance, or if the customer has made a single payment for multiple invoices, use the Record a Payment paid offline option to account for the same:

The recorded payment will be automatically applied to future invoices. It can also be manually applied to the existing Not Paid or Payment Due invoices.