Thursday 26 December 2013

Invoices including AP Distributions

/*##############################################################################
#      invoices including distributions
/*############################################################################*/
 
SELECT aia.invoice_id
     , aia.invoice_num
     , aia.doc_sequence_value voucher_num
     , aida.*
  FROM ap.ap_invoices_all aia
     , ap.ap_invoice_distributions_all aida
     , ap.ap_terms_tl att
     , applsys.fnd_user fu
     , po.po_vendors pv
     , po.po_vendor_sites_all pvsa
 WHERE aia.invoice_id = aida.invoice_id
   AND aia.terms_id = att.term_id
   AND aia.created_by = fu.user_id
   AND aia.vendor_id = pv.vendor_id
   AND aia.vendor_site_id = pvsa.vendor_site_id
   AND pv.vendor_id = pvsa.vendor_id
   AND aia.invoice_date < SYSDATE - 50        -- raised in the last 50 days
   AND 1 = 1;

No comments:

Post a Comment