Thursday, 29 September 2016

AR Checking Query

http://receivablesar.blogspot.com/2016/09/ar-checking-query.html

Customer Checking

select count(*)
  from RA_CUSTOMER_TRX_ALL          ll,
       ar_customers                 kk,
       RA_CUST_TRX_LINE_GL_DIST_ALL jj,
       gl_code_combinations         gcc,
       Ra_Cust_Trx_Types_all tt
 where kk.CUSTOMER_ID = ll.BILL_TO_CUSTOMER_ID
   and jj.CUSTOMER_TRX_ID = ll.CUSTOMER_TRX_ID
   and gcc.CODE_COMBINATION_ID = jj.CODE_COMBINATION_ID
   and tt.CUST_TRX_TYPE_ID=ll.CUST_TRX_TYPE_ID
   and ll.ORG_ID=jj.ORG_ID
   and tt.ORG_ID=  jj.ORG_ID
   and jj.ORG_ID=82   --479

 
 and gcc.SEGMENT2 = '001'
 and kk.customer_id !=1040 --001

  --and gcc.SEGMENT2='002'
 --and kk.CUSTOMER_ID !=1043 --002

-- and gcc.SEGMENT2='002'
 -- and kk.CUSTOMER_ID !=1047 --002


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

Transaction Type and Line Item Location Checking

select count(*)
  from RA_CUSTOMER_TRX_ALL          ll,
       ar_customers                 kk,
       RA_CUST_TRX_LINE_GL_DIST_ALL jj,
       gl_code_combinations         gcc,
       gl_code_combinations gc,
       Ra_Cust_Trx_Types_all tt
 where kk.CUSTOMER_ID = ll.BILL_TO_CUSTOMER_ID
   and jj.CUSTOMER_TRX_ID = ll.CUSTOMER_TRX_ID
   and gcc.CODE_COMBINATION_ID = jj.CODE_COMBINATION_ID
   and tt.CUST_TRX_TYPE_ID=ll.CUST_TRX_TYPE_ID
   and gc.CODE_COMBINATION_ID=tt.GL_ID_REC
   and gcc.SEGMENT2!=gc.SEGMENT2