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:
- payment_id: same as for the fx_transaction
- entry_id: entry_id of preceeding entry in acc_trans
- type: 0
When you do that, the customer balances should be fixed.