...
To do this, double click the unpaid invoice record in the data grid Unpaid invoice (Near date and matching amount). Select and Ctrl-C the value in InvoiceRef.
Open details for the unallocated payment in Invoice Payments (Unallocated). Ctrl-V to paste the value you copied from the unpaid invoice into the InvoiceRef field in the case data for this unallocated payment.