Search This Blog

Sunday, November 14, 2010

AR Balance Ad hoc Queries

Query to retrieve the balance amount of the transaction
-- INV BALANCE
SELECT acctd_amount_due_remaining
INTO l_inv_bal_amt
FROM ar_payment_schedules
Where customer_trx_id = l_inv_trx_id ;
-- CREDIT MEMO BALANCE
SELECT acctd_amount_due_remaining
INTO l_cm_bal_amt
FROM ar_payment_schedules
Where customer_trx_id = l_cm_trx_id ;
-- Amount applied should be the least of inv balance and cm balance
SELECT LEAST(l_inv_bal_amt, abs(l_cm_bal_amt))
INTO l_amount_applied
FROM DUAL;
Query to retrieve the customer_id of the transaction
SELECT customer_id
INTO l_customer_id
FROM ar_payment_schedules
WHERE customer_trx_id = l_inv_trx_id ;

1 comment: