Wednesday 20 July 2022

Query to find AR invoice, receipt and journal details in oracle fusion

 select 
distinct 
acra.receipt_date ,
xal.accounting_date,
gjh.period_name ,
(select flv.meaning from fnd_lookup_values flv where 
flv.lookup_code = apsa.class
and language =userenv('LANG')
and lookup_type = 'INV/CM' ) activity_class,
acra.receipt_number,
hca_bill.attribute28 account_id,
hp_bill.party_name,
arm.name receipt_method,
(SELECT distinct gcc.segment3||'-'||ffvt.description
FROM
        fnd_flex_value_sets ffvs ,
fnd_flex_values ffv ,
        fnd_flex_values_tl ffvt
        where 
  ffvs.flex_value_set_id = ffv.flex_value_set_id
AND ffv.flex_value_id = ffvt.flex_value_id
        AND ffvt.language = USERENV('LANG')
        AND ffv.ENABLED_FLAG='Y'
        AND ffv.SUMMARY_FLAG !='Y'
        AND ffv.flex_value=gcc.segment3
AND rownum <=1) natural_account_description,
(SELECT distinct gcc.segment1||'-'||ffvt.description
FROM
        fnd_flex_value_sets ffvs ,
fnd_flex_values ffv ,
        fnd_flex_values_tl ffvt
        where 
  ffvs.flex_value_set_id = ffv.flex_value_set_id
AND ffv.flex_value_id = ffvt.flex_value_id
        AND ffvt.language = USERENV('LANG')
        AND ffv.ENABLED_FLAG='Y'
        AND ffv.SUMMARY_FLAG !='Y'
        AND ffv.flex_value=gcc.segment1
AND rownum <=1) balancing_segment_description,
gjl.description memo,
acra.amount,
araa.acctd_amount_applied_from Accounted_Amount,
araa.amount_applied Applied_Amount,
/*gjl.ENTERED_DR,
gjl.ENTERED_CR,
gjl.accounted_dr,
gjl.accounted_cr,
xal.accounted_dr debit,
xal.accounted_cr credit,*/
acra.attribute_category,
acra.ussgl_transaction_code_context,
acra.attribute1,
araa.apply_date activity_date,
acra.attribute2,
(select hou.name from hr_operating_units hou
where hou.organization_id=acra.org_id) activity_business_unit,
acra.attribute3,
acra.attribute4,
(select flv.meaning from fnd_lookup_values flv where 
flv.lookup_code = araa.status
and language =userenv('LANG')
and lookup_type = 'PAYMENT_TYPE' ) activity_status,
acra.attribute5,
rcta.trx_number,
rctta.name transaction_type,
rctta.type transaction_class,
xal.gl_sl_link_id
--flv.meaning
from 
ra_customer_trx_all rcta,
ra_cust_trx_types_all rctta,
--fnd_lookup_values flv,
ar_receivable_applications_all araa,
ar_payment_schedules_all apsa,
ar_cash_receipts_all acra,
ar_receipt_methods arm,
hz_cust_accounts hca_bill,
hz_parties hp_bill,
gl_je_headers gjh,
gl_je_lines gjl,
gl_code_combinations gcc,
gl_import_references imp,
xla_ae_lines xal,
xla_ae_headers xah,
xla_events xe,
xla_transaction_entities xte
where 1=1
and rcta.customer_trx_id = araa.applied_customer_trx_id 
and araa.cash_receipt_id = acra.cash_receipt_id
and rcta.org_id = acra.org_id
AND rcta.cust_trx_type_seq_id = rctta.cust_trx_type_seq_id 
--AND rctta.type =flv.lookup_code
AND acra.receipt_method_id = arm.receipt_method_id
AND araa.payment_schedule_id = apsa.payment_schedule_id
AND acra.cash_receipt_id = apsa.cash_receipt_id
AND acra.pay_from_customer=hca_bill.cust_account_id
AND hca_bill.party_id = hp_bill.party_id
AND gjh.je_source = 'Receivables'
AND gjh.je_header_id = gjl.je_header_id
AND gjl.je_header_id = imp.je_header_id
AND gjl.je_line_num = imp.je_line_num
AND imp.gl_sl_link_id = xal.gl_sl_link_id
AND imp.gl_sl_link_table = xal.gl_sl_link_table
AND xal.application_id = xah.application_id
AND xal.ae_header_id = xah.ae_header_id
AND xah.application_id = xe.application_id
AND xah.event_id = xe.event_id
AND xe.application_id = xte.application_id
AND xte.application_id = 222
AND xe.entity_id = xte.entity_id
--AND xte.entity_code = 'TRANSACTIONS'
--AND xte.source_id_int_1 = rcta.customer_trx_id
AND xte.entity_code = 'RECEIPTS'
AND xte.source_id_int_1 = acra.cash_receipt_id
AND gjl.code_combination_id = gcc.code_combination_id
--and acra.receipt_number in ('P-11677740')--,'P-11596072')
AND gcc.segment3 = nvl(:p_account_code,gcc.segment3)
AND gcc.segment1 = nvl(:p_business_unit,gcc.segment1)
and araa.apply_date >= nvl(:p_period_from,araa.apply_date) 
and araa.apply_date <= nvl(:p_period_to,araa.apply_date)
--and rownum <=1000

No comments:

Post a Comment