List of PR Requesters for AP Invoice:
SELECT DISTINCT pda1.deliver_to_person_id
FROM ap_invoice_distributions_all aida,
po_distributions_all pda,
po_line_locations_all plla,
po_lines_all pla,
po_distributions_all pda1
WHERE aida.invoice_id = p_Transaction_id
AND aida.po_distribution_id = pda.po_distribution_id
AND pda.line_location_id = plla.line_location_id
AND pda.po_line_id = pla.po_line_id
AND pla.po_line_id = pda1.po_line_id
AND pda1.deliver_to_person_id IS NOT NULL
AND ( ( plla.inspection_required_flag = 'N'
AND plla.receipt_required_flag = 'N'
AND pda.distribution_type = 'STANDARD'
AND pda.po_distribution_id = pda1.po_distribution_id)
OR EXISTS
(SELECT 1
FROM ap_invoices_all aia
WHERE aia.invoice_id = aida.invoice_id
AND aia.invoice_type_lookup_code =
'PREPAYMENT'));
List of Project Mangers for Projects on AP Invoice:
SELECT ppp.person_id
FROM ap_invoice_distributions_all aid, pa_project_players ppp
WHERE aid.invoice_id = p_transaction_id
AND aid.project_id = ppp.project_id
AND ppp.person_id IS NOT NULL
AND ppp.project_role_type = 'PROJECT MANAGER'
AND TRUNC (SYSDATE) BETWEEN TRUNC (
NVL (ppp.start_date_active,
SYSDATE))
AND TRUNC (
NVL (ppp.end_date_active,
SYSDATE + 1))
GROUP BY ppp.person_id;
List of Task Mangers for Projects on AP Invoice:
SELECT pt.task_manager_person_id person_id
FROM ap_invoice_distributions_all aid, pa_tasks pt
WHERE invoice_id = p_transaction_id
AND aid.task_id = pt.task_id
AND pt.task_manager_person_id IS NOT NULL
AND TRUNC (SYSDATE) BETWEEN TRUNC (
NVL (pt.start_date, SYSDATE))
AND TRUNC (
NVL (pt.completion_date,
SYSDATE + 1))
GROUP BY pt.task_manager_person_id;
No comments:
Post a Comment