Sunday 17 January 2016

Invoice Speedometer Query

http://aporaclepayables.blogspot.com/2016/01/invoice-speedometer-query.html

begin
MO_GLOBAL.SET_POLICY_CONTEXT('S', '?');
end;

--------------------------------------------------------------

SELECT distinct i.invoice_num, i.invoice_date, k.invoice_amount, k.doc_sequence_value
         ,DECODE
             (apps.ap_invoices_pkg.get_approval_status
                                                   (i.invoice_id,
                                                    i.invoice_amount,
                                                    i.payment_status_flag,
                                                    i.invoice_type_lookup_code
                                                   ),
              'NEVER APPROVED', 'Never Validated',
              'NEEDS REAPPROVAL', 'Needs Revalidation',
              'APPROVED', 'Validated',
              'CANCELLED', 'Cancelled',
              'AVAILABLE PREPAYMENT', 'Available Prepayment',
              'AVAILABLE', 'Available'
         
              ) invoice_status, i.payment_status_flag "Payment Status",        --'Y' -- Fully Paid, 'P' -- Partially Paid , 'N'-- Not Paid
               k.posting_flag "Invoice Accounting Status"               --'Y' -- Accounted, 'P' -- Partial , 'N'-- No Accounted
   FROM   ap_invoices_all i, Ap_Invoices_v k
 
   where 1=1
   and i.invoice_id=k.invoice_id
  --   and i.invoice_id=69912

No comments:

Post a Comment