Wednesday 20 July 2022

Query to find AR Invoice details in oracle fusion

 select distinct
(select rba.name from ra_batches_all rba where rba.batch_id = rcta.batch_id and rownum <=1) batch_name,
hca_bill.attribute28 account_id, 
hca_bill.account_number,
hcsua_bill.cust_acct_site_id,
hps_bill.party_site_number,
hp_bill.party_name,
rcta.customer_trx_id,
rcta.invoice_currency_code Currency,
rcta.trx_number credit_memo_number, 
rcta.trx_date credit_memo_date,
rctla.extended_amount total_amount,
rctla.inventory_item_id,
(select item_number from egp_system_items_b esi where esi.inventory_item_id = rctla.inventory_item_id and rownum <=1 ) item_number,
rctla.description,
rctla.attribute6 service_start_date,
rctla.attribute7 servic_end_date,
rctla.quantity_credited,
(select uomt.unit_of_measure 
from inv_units_of_measure_tl uomt, inv_units_of_measure_b uomb 
where uomb.uom_code = rctla.uom_code
and uomt.language =userenv('LANG')
and uomt.unit_of_measure_id = uomb.unit_of_measure_id) UOM,
rctla.line_type, 
decode(rctla.line_type,'LINE',rctla.extended_amount,0) without_tax_amount,
decode(rctla.line_type,'TAX',rctla.extended_amount,0) tax_amount,
rctla.attribute3 opp_id,
rctla.attribute1 order_id,
rctla.attribute2 order_line_item_id,
rcta.attribute_category transaction_source,
(select name from ra_terms_vl rt where rt.term_id = rcta.term_id and rownum <=1) payment_term_name,
(select description from ra_terms_vl rt where rt.term_id = rcta.term_id and rownum <=1) payment_term_desc,
rctla.creation_date,
rctla.created_by,
rctla.last_update_login,
rctla.trx_business_category,
rctla.product_fisc_classification,
rctla.product_type,
rcta.attribute13 sfdc_sync_status
/*--rcta.end_date_commitment,
--rcta.start_date_commitment,
rcta.batch_id,
(select attribute28 from hz_cust_accounts hca where rcta.bill_to_customer_id  = hca.cust_account_id and rownum <=1) account_id,
--rcta.ct_reference,
--previous_customer_trx_id
gjh.period_name*/
from ra_customer_trx_all rcta,
ra_customer_trx_lines_all rctla,
hz_cust_accounts hca_bill,
hz_parties hp_bill,
hz_cust_site_uses_all hcsua_bill,
hz_cust_acct_sites_all hcasa_bill,
hz_party_sites hps_bill
/*gl_je_headers gjh,
gl_je_lines gjl,
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 = rctla.customer_trx_id
AND rcta.bill_to_customer_id = hca_bill.cust_account_id
ANd hca_bill.party_id = hp_bill.party_id
AND rcta.bill_to_site_use_id = hcsua_bill.site_use_id
AND hcsua_bill.cust_acct_site_id = hcasa_bill.cust_acct_site_id(+)
AND hcasa_bill.party_site_id = hps_bill.party_site_id(+)
and rcta.previous_customer_trx_id is not null
/*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 rcta.customer_trx_id =181754
and rcta.trx_number in  ('CM00849945','CM01249142')--('INV23994226','111100001030')

No comments:

Post a Comment