Monday, 31 October 2011

AP_Prepayment_Inv_Hdr

/* Formatted on 08-08-2011 20:05:50 (QP5 v5.115.810.9015) */
  SELECT  --SUM (aia.INVOICE_AMOUNT)
 aia.invoice_id,
    hou.name Operating_unit, pov.VENDOR_ID,pov.segment1 Vendor_Code,
    aia.INVOICE_NUM H_INVOICE_NUM,
             aia.INVOICE_TYPE_LOOKUP_CODE H_INVOICE_TYPE,
             pov.VENDOR_NAME H_VENDOR_NAME,
             sites.VENDOR_SITE_CODE H_VENDOR_SITE_CODE,
             aia.INVOICE_DATE H_INVOICE_DATE,
             aia.INVOICE_AMOUNT H_INVOICE_AMOUNT,
             aia.INVOICE_CURRENCY_CODE H_INVOICE_CURRENCY_CODE,
             aia.GL_DATE H_GL_DATE,
             term.NAME H_TERMS_CODE,
             'Appload' H_SOURCE,
             glcc.CONCATENATED_SEGMENTS H_LIB_ACCT,
             aia.GOODS_RECEIVED_DATE H_GOODS_RECEIVED_DATE ,
             aia.DOC_SEQUENCE_ID,
             aia.DOC_SEQUENCE_VALUE
    FROM   ap_invoices_all aia,
           apps.po_vendors pov,
           hr_operating_units hou,
           apps.ap_terms_tl term,
           apps.po_vendor_sites_all sites,
           apps.gl_code_combinations_kfv glcc
   WHERE       aia.vendor_id = pov.vendor_id
           AND hou.organization_id = aia.org_id
           AND aia.terms_id = term.term_id
           AND aia.vendor_site_id = sites.vendor_site_id
           AND aia.accts_pay_code_combination_id = glcc.code_combination_id
           AND hou.set_of_books_id = 5
           aND TRUNC (aia.GL_DATE) BETWEEN '01-JUL-2011' AND '31-JUL-2011'
                   --AND TRUNC (aia.INVOICE_DATE) BETWEEN '01-APR-2011' AND '30-JUN-2011'
           --AND (aia.INVOICE_AMOUNT - aia.AMOUNT_PAID) > 0
           AND aia.invoice_type_lookup_code = 'PREPAYMENT'
           /* AND AIA.INVOICE_ID IN
                    (  SELECT   DISTINCT invoice_id FROM xx_invoice_id1) */
ORDER BY  aia.invoice_id, aia.INVOICE_DATE

No comments:

Post a Comment