Thursday, August 30, 2018

Query to get Prepayment Invoice Status in Oracle Payables

SELECT   aps.vendor_name,
           ai.invoice_num,
           NVL (
              DECODE (
                 SIGN (SUM (amount - NVL (prepay_amount_remaining, amount))),
                 1,
                 DECODE (SUM (prepay_amount_remaining), 0, 'Y', NULL),
                 NULL
              ),
              'N'
           )
              AS prepayment_invoice_status     -- Y is Fully Applied, N is Partially or Not Applied
    FROM ap_invoice_distributions_all aid
        ,ap_invoices_all ai
        ,ap_suppliers aps
   WHERE aid.invoice_id = ai.invoice_id
     AND aps.vendor_id = ai.vendor_id
     AND aid.line_type_lookup_code = 'ITEM'
     AND ai.invoice_type_lookup_code = 'PREPAYMENT'
     --AND ai.invoice_id = :p_invoice_id
     AND NVL (reversal_flag, 'N') <> 'Y'
GROUP BY   aps.vendor_name, ai.invoice_num

No comments:

Post a Comment

SupplierAddressImportTemplate.xlsm South Africa Suburb Field mapping in POZ_SUPPLIER_ADDRESSES_INT

Suburb mpping in Supplier Address Import Template will be mapped to Address Element Attribute2 (HZ_LOCATIONS. ADDR_ELEMENT_ATTRIBUTE2)