SELECT DISTINCT ou.name "OPERATING UNIT",
pv.segment1 "Supplier GSL",
pv.vendor_name "Supplier Name" ,
apt1.name "Supplier Header Terms",
apt.NAME "Supplier Site Terms",
ph.segment1 "PO#",
ph.CLOSED_CODE "PO Status",
(SELECT name
FROM ap_terms
WHERE term_id = ph.terms_id)
"PO Terms",
aia.invoice_num,
(SELECT name
FROM ap_terms
WHERE term_id = aia.terms_id)
"AP Terms",
decode(CANCELLED_DATE,null,'', 'Cancelled') "AP Status"
-- ,apt.description
-- ,pvsa.PAY_DATE_BASIS_LOOKUP_CODE "Pay Date Basis"
FROM apps.AP_SUPPLIERS pv,
apps.AP_SUPPLIER_SITES_ALL pvsa,
apps.ap_invoices_all aia,
-- apps.ap_invoice_payments_all aip,
ap_invoice_distributions_all aida,
(SELECT *
FROM apps.ap_terms_tl
WHERE lANGUAGE = 'US') apt,
(SELECT *
FROM apps.ap_terms_tl
WHERE lANGUAGE = 'US') apt1,
po_headers_all ph,
po_lines_all pla,
po_distributions_all pda,
hr_operating_units ou,
ap_tolerance_templates att
WHERE pv.vendor_id = pvsa.vendor_id
AND pv.vendor_id = aia.vendor_id
AND pvsa.VENDOR_SITE_ID = aia.VENDOR_SITE_ID
AND ou.organization_id = pvsa.org_id
-- AND aip.invoice_id = aia.invoice_id
AND pvsa.TERMS_ID = apt.TERM_ID(+)
AND pv.TERMS_ID = apt1.TERM_ID(+)
AND pvsa.TOLERANCE_ID = att.TOLERANCE_ID(+)
AND ph.vendor_id = pv.vendor_id
AND ph.org_id = pvsa.org_id
AND ph.po_header_id = pla.po_header_id
AND ph.org_id = pla.org_id
AND ph.po_header_id = pda.po_header_id
AND pla.po_line_id = pda.po_line_id
AND ph.org_id = pda.org_id
AND aida.invoice_id = aia.invoice_id
AND pda.org_id = aida.org_id
AND aia.org_id = aida.org_id
AND pda.po_distribution_id = aida.po_distribution_id
AND aia.PAYMENT_STATUS_FLAG = 'N'
AND NVL (pv.end_DATE_ACTIVE, SYSDATE) >= SYSDATE
-- and ph.segment1 ='700021845'
--and CANCELLED_DATE is null
-- AND pv.segment1 = 'E52029'
ORDER BY pv.segment1 ASC
No comments:
Post a Comment