Switch the link for a payment from one SO/Invoice to another
When we have payments unlinked to a sales order or an invoice, we can click on the three dots and select "Switch SO/Invoice".
Select the Sales Order/Invoice to assign the payment, and save
After that, you will have the payment linked to the SO/Invoice