need help in writing sql to list invoices having outstanding balances , to which previously receipts
need help in writing sql to list invoices having outstanding balances , to which previously receipts were applied but were reversed.
for example if inv #1234 had original inv amount = 1000
amount due remaining = 1000
then a receipt xyz was applied for 1000 or any other amount, then the receipt was unapplied and reversed.
so invoice became open again. need to list such invoices.
I have written a sql, but not sure if its perfect. it produces duplicate rows( cartesian product ), want to know if there is a better way .
select ara.applied_customer_trx_id,ach.cash_receipt_id,ara.cash_receipt_id,ach.amount,ara.status,ach.status, ach.reversal_gl_date,ara.reversal_gl_date