SQL Query to get Balance Due amount on AR Invoice

 Use the below query to get balance due amount on AR Invoice


select rcta.trx_number

,( select sum(extended_amount)
        from apps.ra_customer_trx_lines_all b ,apps.ra_customer_trx_all a where 1=1
                and a.customer_trx_id = b.customer_trx_id
                 and a.org_id = 376
                  and a.trx_number = rcta.trx_number
                  group by a.trx_number,a.customer_trx_id) orig_amount
                  ,sum(aps.amount_due_original)
                  ,sum(aps.amount_due_remaining)
from apps.ra_customer_trx_all rcta
,apps.ar_payment_schedules_all aps
where 1=1
and rcta.customer_trx_id = aps.customer_trx_id
and rcta.trx_number in ('19052397')
group by rcta.trx_number
;

Comments