Monday 31 October 2011

req_loc_tax_details

SELECT   (SELECT   poh.segment1
            FROM   po_requisition_headers_all poh
           WHERE   poh.requisition_header_id = po.requisition_header_id)
            "PO NO",
         (SELECT   LINE_NUM
            FROM   po_requisition_lines_all
           WHERE   REQUISITION_LINE_ID = po.REQUISITION_LINE_ID)
            "Line No",
         tax.TAX_NAME,
         po.TAX_TYPE,
         tax.TAX_RATE,
         po.TAX_AMOUNT
  FROM   JA_IN_REQN_TAX_LINES po, JA_IN_TAX_CODES tax
 WHERE   po.TAX_ID = tax.TAX_ID
         AND po.REQUISITION_HEADER_ID IN                 
         (SELECT DISTINCT
        prh.REQUISITION_HEADER_ID       
        from
        po.po_requisition_headers_all prh,
        po.po_requisition_lines_all prl,
        apps.per_people_f ppf1,
        (select distinct agent_id,agent_name from apps.po_agents_v ) ppf2,
        po.po_req_distributions_all prd,
        inv.mtl_system_items_b msi,
        org_organization_definitions ood
WHERE
        prh.requisition_header_id = prl.requisition_header_id
        and prl.requisition_line_id = prd.requisition_line_id
        and ppf1.person_id = prh.preparer_id
        and prh.creation_date between ppf1.effective_start_date and ppf1.effective_end_date
        and ppf2.agent_id(+) = msi.buyer_id
        and msi.inventory_item_id = prl.item_id
        and msi.organization_id = prl.destination_organization_id
        AND trunc(prh.creation_date) between '01-APR-2011' and '31-JUL-2011'
        AND prh.org_id = ood.operating_unit       
        --AND prh.CLOSED_CODE NOT IN 'FINALLY CLOSED'
        --AND prh.CLOSED_CODE NOT IN 'CLOSED'
        --AND prh.closed_code NOT in 'CLOSE'
        AND ood.set_of_books_id = 5)
ORDER BY 1

No comments:

Post a Comment