When you log a payment for a guest who has several unpaid bookings, the payments will automatically get allocated in order of guests’ arrivals.
To log a payment for the guest, in Contacts-> Guests -> Individuals, choose the guest and click on +Payment button at the top right of the page.