select * from ((select ifnull(sum(ifnull(aro.receive_amount,0)),0) as received
from 0p4_account_payable_oustanding aro
left join 0p4_account_payable ar on ar.account_payable_id=aro.account_payable_id
where aro.costing_id=131 and ar.post_status_id=2
and aro.apply=1) + (select ifnull(sum(ifnull(jo.receive_amount,0)),0) as amount from 0p4_journal_supplier_oustanding jo
where jo.costing_id=131 and jo.apply=1)) x



select sum(gl.local_debit) as debit, sum(gl.local_credit) as credit from  0p4_gl_transaction gl where  gl.date between '2020-03-31' and '2020-03-31'
and gl.transaction_no is not null



select gl.transaction_no,gl.local_debit, gl.local_credit from  0p4_gl_transaction gl where  gl.date between '2020-03-31' and '2020-03-31'
and gl.transaction_no is not null



select gl.transaction_no,gl.parent_object,gl.parent_pk as parent_pk, sum(gl.local_debit) as debit, sum(gl.local_credit) as credit from 0p4_gl_transaction gl
where  gl.transaction_no is not null
group by gl.transaction_no, gl.parent_object,gl.parent_pk
HAVING debit != credit



select gl.transaction_no,gl.parent_object,gl.parent_pk as parent_pk, sum(gl.local_debit) as debit, sum(gl.local_credit) as credit from 0p4_gl_transaction gl
where  gl.transaction_no is not null  and gl.parent_object = 'app\\models\\AccountReceivable'
group by gl.transaction_no, gl.parent_object,gl.parent_pk
HAVING debit != credit
