--AP Invoice Cancel List with PO number and GRN
SELECT
aps.vendor_name,
assa.vendor_site_code,
aia.invoice_num,
aia.invoice_currency_code,
aia.invoice_date,
aia.invoice_type_lookup_code,
aia.description,
aia.invoice_amount,
pha.segment1 po_number,
rsh.receipt_num,
rt.primary_quantity rcv_qty,
rt.transaction_type,
fu.user_name "Cancelled By"
FROM
ap_invoices_all aia,
ap_invoice_lines_all ail,
rcv_transactions rt,
rcv_shipment_headers rsh,
po_distributions_all pda,
po_headers_all pha,
ap_suppliers aps,
ap_supplier_sites_all assa,
fnd_user fu
WHERE 1=1
AND aia.cancelled_date IS NOT NULL
AND aia.cancelled_by IS NOT NULL
AND ail.invoice_id = aia.invoice_id
AND ail.rcv_transaction_id (+) = rt.transaction_id
AND rt.shipment_header_id = rsh.shipment_header_id
AND pda.po_header_id = pha.po_header_id
AND pda.po_distribution_id = rt.po_distribution_id
AND aia.vendor_id = aps.vendor_id
AND aps.vendor_id = assa.vendor_id
AND aia.vendor_site_id = assa.vendor_site_id
AND aia.cancelled_by = fu.user_id
ORDER BY
aps.vendor_name
/