When a payment is, it must be applied to an open invoice. You cannot post a payment without attaching it to an open invoice. If the payment is not applied to an invoice and you try to post it, then the payment is not posted, and an error message is displayed.