Two more queries that might help you locate the discrepency:
SELECT id from ap join acc_trans ON (
ap.id = acc_trans.trans_id)
WHERE chart_id = (select id from chart where accno = [ap account number])
GROUP BY
ap.id, acc_trans.trans_id, ap.amount, ap.paid
HAVING sum(acc_trans.amount) <> (ap.amount - ap.paid);
This pulls up AP entries with wrong summary info.
SELECT trans_id FROM acc_trans
WHERE trans_id NOT IN (select id FROM ap)
AND chart_id = (select id from chart where accno = [ap account number])
GROUP BY trans_id;