All payments are first applied to the oldest unpaid invoice and are applied primarily to a balance. They are not necessarily linked to a specific invoice.
Automatic payments may be applied to more than one invoice but only to amounts which are due. If a payment or credit note is applied, the automatic payment will only debit the amount which is residual from the balance.