Thursday, 5 October 2023

Script to get Payables Invoice Approval Status:

CREATE OR REPLACE FUNCTION APPS.XXAP_INVOICE_STATUS
       (p_invoice_id NUMBER)
   RETURN VARCHAR2
IS
   v_inv_status  VARCHAR2 (500);
BEGIN
   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)

     INTO v_inv_status
     FROM ap_invoices_all aia
    WHERE 1=1
      AND aia.invoice_id = p_invoice_id;

   RETURN (v_inv_status);
EXCEPTION
   WHEN NO_DATA_FOUND
   THEN
      RETURN NULL;
END;
/

No comments:

Post a Comment