Read about how to apply a payment to an invoice here.  (current version 8.6.2)