Query to fetch Prepaid amount for a Standard Invoice
SELECT (0 - SUM(NVL(aid.amount,0))) prepaid_amount
FROM ap_invoice_distributions_all aid,
ap_invoice_lines_all ail
WHERE ail.invoice_id = &P_invoice_id -- invoice id of std invoice
AND ail.invoice_id = aid.invoice_id
AND ail.line_number = aid.invoice_line_number
AND aid.line_type_lookup_code = 'PREPAY'
AND aid.prepay_distribution_id IS NOT NULL
AND NVL(ail.invoice_includes_prepay_flag, 'N') = 'N';
OR
SELECT ABS(SUM(amount))
FROM ap_invoice_lines_all ail
WHERE ail.invoice_id = &P_invoice_id -- invoice id of std invoice
AND ail.line_type_lookup_code = 'PREPAY';
It’s wonderful post and very helpful, thanks for all this information. PSG Grant Accounting Software Singapore ,
ReplyDelete