Wednesday, May 25, 2016

To Check AP Invoices are Validated or Not

using the below query can check the invoice status.

SELECT                 DECODE(AP_INVOICES_UTILITY_PKG.GET_APPROVAL_STATUS(AIA.INVOICE_ID,AIA.INVOICE_AMOUNT,AIA.PAYMENT_STATUS_FLAG,AIA.INVOICE_TYPE_LOOKUP_CODE),
                'FULL'            , 'Fully Applied',
                'NEVER APPROVED'  , 'Never Validated',
                'NEEDS REAPPROVAL', 'Needs Revalidation',
                'CANCELLED'       , 'Cancelled',
                'UNPAID'          , 'Unpaid',
                'AVAILABLE'       , 'Available',
                'UNAPPROVED'      , 'Unvalidated',
                'APPROVED'        , 'Validated',
                'PERMANENT'       , 'Permanent Prepayment',
                NULL
        FROM   
                AP_INVOICES_ALL AIA
        WHERE   AIA.INVOICE_NUM = 'Z234'


There is no column in the AP_INVOICES_ALL table that stores the validation status.
Invoice Distributions are validated individually and the status is stored at the Invoice Distributions level. 
This status is stored in  the match_status_flag column of the ap_invoice_distributions_all table (AP_INVOICE_DISTRIBUTIONS_ALL.MATCH_STATUS_FLAG).
Valid values for this column are: 
   A - Validated (it used to be called Approved)
   N or null - Never validated
   T - Tested but not validated
   S - Stopped
The invoice header form derives the invoice validation status based on the following:
Validated:
  • If ALL of the invoice distributions have a MATCH_STATUS_FLAG = 'A' 
  • If MATCH_STATUS_FLAG is 'T' on ALL the distributions and org has no encumbrance enabled then Invoice would show Validated (provided there is no Unreleased Hold)
Never Validated:
  • If all of the invoice distributions have a MATCH_STATUS_FLAG = null or 'N'
Needs Revalidation:
  • If any of the invoice distributions have a MATCH_STATUS_FLAG = 'T' and the org has Encumbrance enabled
  • If the invoice distributions have MATCH_STATUS_FLAG values = 'N', null and 'A' (mixed)
  • If the invoice distributions have MATCH_STATUS_FLAG value = 'S' (stopped)
  • If there are any rows in AP_HOLDS that do not have a release code
MATCH_STATUS_FLAG would remain 'T' if invoice has hold which does not allow Accounting. In such scenario you can not account the invoice because event status will be 'I'.
As soon as Hold is released from Holds Tab/Invoice Workbench event status is set to 'U'. Invoice is shown as Validated and accounting is allowed. Match_Status_Flag still remains 'T'.

1 comment:

  1. Do you know of a way to restrict the output by specific validation type? I've been able to do so with other packages such as accounting status, but not been able to with this package

    ReplyDelete

EBS Order Holds details and release responsibility

  SELECT ooh.order_number,                  ooh.ordered_date,                 ooh.flow_status_code,                 ooh.credit_card_approval...