http://aporaclepayables.blogspot.com/2016/01/payment-status-plsql-query.html
begin
MO_GLOBAL.SET_POLICY_CONTEXT('S', '?');
end;
-----------------------------------------
SELECT b.vendor_name vendor_name,
c.vendor_site_code,
a.invoice_num invoice_number,
a.invoice_date,
a.invoice_currency_code,
a.invoice_amount,
a.amount_paid,
a.payment_status_flag, -- --'Y' -- Fully Paid, 'P' -- Partially Paid , 'N'-- Not Paid
al.posting_flag "Invoice Accounting Status",
DECODE
(apps.ap_invoices_pkg.get_approval_status
(a.invoice_id,
a.invoice_amount,
a.payment_status_flag,
a.invoice_type_lookup_code
),
'NEVER APPROVED', 'Never Validated',
'NEEDS REAPPROVAL', 'Needs Revalidation',
'APPROVED', 'Validated',
'CANCELLED', 'Cancelled',
'AVAILABLE PREPAYMENT', 'Available Prepayment',
'AVAILABLE', 'Available'
) invoice_status,
ac.status_lookup_code "Payment Status",
asd.posting_flag -- --'Y' -- Processed, 'P' -- Partial , 'N'-- UnProcessed
FROM apps.ap_invoices_all a,
apps.ap_suppliers b,
apps.ap_supplier_sites_all c,
apps.ap_payment_schedules_all d,
apps.ap_invoice_payments_all ap,
ap_checks_all ac,
Ap_Invoices_v al,
ap_checks_v asd
WHERE a.vendor_id = b.vendor_id
AND a.vendor_site_id = c.vendor_site_id
AND b.vendor_id = c.vendor_id
AND a.invoice_id = d.invoice_id
AND ap.invoice_id = a.invoice_id
AND ac.CHECK_ID = ap.CHECK_ID
and ac.check_id=asd.check_id
and ap.check_id=asd.check_id
and a.invoice_id=al.invoice_id
and d.invoice_id=al.invoice_id
-- and ac.STATUS_LOOKUP_CODE <> 'VOIDED'
-- AND a.org_id =?
and ac.check_number='?'
--and a.invoice_id= 1234
--AND a.pay_group_lookup_code IN ('DISTRIBUTOR')
-- AND ac.check_date BETWEEN TO_DATE ('01-Apr-2014', 'DD-MON-YYYY') AND TO_DATE ('30-Jun-2014 23:59:59', 'DD-MON-YYYY HH24:MI:SS')]
It works Fine on our system!
ReplyDelete