Wednesday 10 August 2011

RA----> AR -----> HZ ----> Link

SELECT   *
    FROM ar_cash_receipts_all cr,
         ar_cash_receipt_history_all crh_current,
         ar_receivable_applications_all apa,
         ar_payment_schedules_all psa,
         ar_lookups l_class,
         ra_customer_trx_all trx,
         ra_customer_trx_lines_all trxl,
         hz_cust_accounts cust,
         hz_parties party,
         hz_cust_site_uses_all su,
         hz_locations loc,
         hz_cust_acct_sites_all cas,
         hz_party_sites ps
   WHERE 1 = 1
     AND crh_current.cash_receipt_id = cr.cash_receipt_id
     AND crh_current.current_record_flag = 'Y'
     AND 'Cleared' =
            arpt_sql_func_util.get_lookup_meaning ('RECEIPT_CREATION_STATUS',
                                                   crh_current.status
                                                  )
     AND cr.pay_from_customer = cust.cust_account_id
     AND cust.party_id = party.party_id
     AND su.site_use_id = cr.customer_site_use_id
     AND cust.party_id = party.party_id
     AND cust.cust_account_id = cas.cust_account_id
     AND su.site_use_code = 'BILL_TO'
     AND su.cust_acct_site_id = cas.cust_acct_site_id
     AND cas.party_site_id = ps.party_site_id
     AND loc.location_id = ps.location_id
     AND cr.cash_receipt_id = apa.cash_receipt_id
     AND trx.customer_trx_id = trxl.customer_trx_id
     AND trx.customer_trx_id = psa.customer_trx_id
     AND psa.CLASS = l_class.lookup_code
     AND apa.applied_payment_schedule_id = psa.payment_schedule_id
     AND trxl.line_type = 'LINE'
     AND l_class.lookup_type = 'INV/CM'
ORDER BY cr.attribute5 ASC;

No comments:

Post a Comment