How do I fix out-of-balance overpayments?
How do I clean up my books as a result of Issue #2346, URGENT: Use Overpayments creates accounting errors?
What you need to do is look for rows in payment_links which have type=0
Then, in acc_trans, you need to identify those rows which have an entry_id of a row which has a 0 amount. That row is probably an fx_transaction row.
The preceding entry_id row is likely one for the same transaction, with a non-zero, non-fx_transaction amount.
You need to insert a new row into the payment_links table with: