SELECT
AI.INVOICE_NUM,
NVL (AP_INVOICES_PKG.GET_DISTRIBUTION_TOTAL (AI.INVOICE_ID), 0)
DISTRIBUTION_TOTAL,
AP_INVOICES_PKG.GET_POSTING_STATUS (AI.INVOICE_ID) POSTING_FLAG,
AP_INVOICES_PKG.GET_APPROVAL_STATUS (AI.INVOICE_ID,
AI.INVOICE_AMOUNT,
AI.PAYMENT_STATUS_FLAG,
AI.INVOICE_TYPE_LOOKUP_CODE)
APPROVAL_STATUS_LOOKUP_CODE,
AP_INVOICES_PKG.GET_PO_NUMBER (AI.INVOICE_ID) PO_NUMBER,
-- AP_INVOICES_PKG.GET_RELEASE_NUMBER (AI.INVOICE_ID),
AP_INVOICES_PKG.GET_RECEIPT_NUMBER (AI.INVOICE_ID) RECEIPT_NUM,
AP_INVOICES_PKG.GET_AMOUNT_WITHHELD (AI.INVOICE_ID) AMOUNT_WITHHELD,
AP_PREPAY_UTILS_PKG.GET_PREPAID_AMOUNT (AI.INVOICE_ID) PREPAID_AMOUNT,
AP_INVOICES_PKG.GET_NOTES_COUNT (AI.INVOICE_ID) NOTES_COUNT,
AP_INVOICES_PKG.GET_HOLDS_COUNT (AI.INVOICE_ID) HOLDS_COUNT,
AP_INVOICES_PKG.GET_AMOUNT_HOLD_FLAG (AI.INVOICE_ID) AMOUNT_HOLD_FLAG,
AP_INVOICES_PKG.GET_VENDOR_HOLD_FLAG (AI.INVOICE_ID) VENDOR_HOLD_FLAG,
AP_INVOICES_PKG.GET_ENCUMBERED_FLAG (AI.INVOICE_ID) ENCUMBERED_FLAG,
AI.GL_DATE GL_DATE,
AP_INVOICES_PKG.GET_PERIOD_NAME (AI.GL_DATE, NULL, AI.ORG_ID)
PERIOD_NAME,
AP_INVOICES_PKG.SELECTED_FOR_PAYMENT_FLAG (AI.INVOICE_ID)
SELECTED_FOR_PAYMENT_FLAG,
AP_INVOICES_PKG.GET_UNPOSTED_VOID_PAYMENT (AI.INVOICE_ID)
UNPOSTED_VOID_PAYMENT_FLAG,
AP_INVOICES_PKG.GET_DISCOUNT_PAY_DISTS_FLAG (AI.INVOICE_ID)
DISCOUNT_PAY_DISTS_FLAG,
AP_PREPAY_UTILS_PKG.GET_PREPAYMENTS_APPLIED_FLAG (AI.INVOICE_ID)
PREPAYMENTS_APPLIED_FLAG,
AP_INVOICES_PKG.GET_PAYMENTS_EXIST_FLAG (AI.INVOICE_ID)
PAYMENTS_EXIST_FLAG,
AP_INVOICES_PKG.GET_PACKET_ID (AI.INVOICE_ID) QUERY_PACKET_ID,
DECODE (
AI.INVOICE_TYPE_LOOKUP_CODE,
'PREPAYMENT', AP_PREPAY_UTILS_PKG.GET_PREPAY_AMOUNT_APPLIED (
AI.INVOICE_ID),
0)
PREPAY_AMOUNT_APPLIED
FROM AP_INVOICES_ALL AI