Use the A/P Payment Entry screen to:
You can post the invoice or the prepayment first. Accounts Payable matches up prepayments when you post payment batches and when you post invoice batches.
If the prepayment correctly references the invoice number, PO number, or sales order number of an invoice, it is applied to the invoice no matter which document is posted first.