Friday, 22 January 2016

Payment Clearing Query

http://aporaclepayables.blogspot.com/2016/01/payment-clearing-query.html

How to know the User who has cleared the Payment.
SELECT *
  FROM AP_PAYMENT_HISTORY_ALL
 WHERE check_id IN (SELECT distinct check_id
                      FROM AP_INVOICE_PAYMENTS_ALL
                     WHERE invoice_id = '?')
 ORDER BY accounting_event_id asc

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

--create or replace view Clearing_User as
select  * /*aca.DOC_SEQUENCE_VALUE APV_NUMBER,aca.CHECK_NUMBER Document_Number, aca.VENDOR_NAME,aca.VENDOR_SITE_CODE,
aca.CHECK_DATE,aca.CLEARED_AMOUNT, aca.CLEARED_DATE, APHA.TRANSACTION_TYPE, aca.LAST_UPDATE_DATE CHK_LAST_UPDATE, FU.USER_NAME CLEARING_USER_NAME
,APHA.LAST_UPDATE_DATE CLR_LAST_UPDATE,ACA.BANK_ACCOUNT_NAME*/
FROM AP_PAYMENT_HISTORY_ALL APHA, FND_USER FU, ap_checks_all aca 
 where aca.CHECK_ID=APHA.CHECK_ID 
 and APHA.CHECK_ID IN (SELECT distinct check_id
                      FROM AP_INVOICE_PAYMENTS_ALL
                  WHERE invoice_id ='&P_INVOICE_ID'
            )
                     and APHA.CREATED_BY=FU.USER_ID
                     AND APHA.TRANSACTION_TYPE='PAYMENT CLEARING'
                     and aca.CHECK_DATE is not null              
--------------------------------------------------------------------------------------------------------------------------
                select * 
               from Clearing_User TT where tt.CLR_LAST_UPDATE in (select max(last_update_date) from AP_PAYMENT_HISTORY_ALL)
              --7342114

No comments:

Post a Comment