0% found this document useful (0 votes)
213 views

Sales Invoice Report Query

This document contains an SQL query that selects various data fields from different tables related to customer transactions, parties, locations, and other entities. The query joins several tables together to retrieve information like customer IDs, addresses, names, and other details needed for invoices or receipts. It filters the results based on transaction number, date range, customer name, operating unit, and legal entity parameters passed into the query.

Uploaded by

Sumit
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
213 views

Sales Invoice Report Query

This document contains an SQL query that selects various data fields from different tables related to customer transactions, parties, locations, and other entities. The query joins several tables together to retrieve information like customer IDs, addresses, names, and other details needed for invoices or receipts. It filters the results based on transaction number, date range, customer name, operating unit, and legal entity parameters passed into the query.

Uploaded by

Sumit
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

SELECT RECEIPT_METHOD_ID

hp.party_id,

ct.doc_sequence_value

inv_number,

ct.ship_to_party_address_id

ship_to_id,

hps.party_site_id,

hr.NAME

"Business Name",

hp.party_name

bill_customer,

ct.trx_number,

ct.trx_date,

ct.invoice_currency_code,

ct.ship_to_customer_id,

ct.bill_to_customer_id,

ct.bill_to_site_use_id,

ct.customer_trx_id,

ct.org_id,

ct.doc_sequence_id,

ct.cust_trx_type_seq_id,

hl.address1

bill_address1,

hl.address2

bill_address2,

hl.city

bill_city,

hl.state

bill_state,
hl.postal_code

bill_zip,

(SELECT description

FROM fnd_territories_vl ft

WHERE ft.territory_code = hl.country)

bill_country,

(SELECT hcsua1.LOCATION

FROM hz_cust_site_uses_all hcsua1, hz_cust_acct_sites_all hcasa1

WHERE 1 = 1

AND hcsua1.site_use_code = 'SHIP_TO'

AND hcasa1.cust_acct_site_id = hcsua1.cust_acct_site_id

AND hcasa1.party_site_id = ct.ship_to_party_address_id)

ship_to_location,

hcsua.LOCATION

bill_to_location,

hrl.address_line_1

seller_address1,

hrl.address_line_2

seller_address2,

(SELECT description

FROM fnd_territories_vl ft

WHERE ft.territory_code = hrl.country)

seller_country,

xep.NAME

seller_company_name,

(SELECT zxl.registration_number

FROM hz_parties hp, zx_registrations zxl

WHERE 1 = 1

AND hp.iden_addr_location_id = zxl.legal_location_id


AND party_id = xep.party_id

AND ROWNUM = 1)

tax_reg_no,

NVL (

(SELECT phone_number

FROM hz_contact_points

WHERE owner_table_id = 300000002343811

AND contact_point_type = 'PHONE'

AND phone_type = 'MOBILE'

AND status = 'A'

AND ROWNUM = 1),

(SELECT phone_area_code || '-' || phone_number

FROM hz_contact_points

WHERE owner_table_id = ct.ship_to_party_contact_id

AND contact_point_type = 'PHONE'

AND phone_type = 'LAND'

AND status = 'A'

AND ROWNUM = 1))

phone,

(SELECT phone_number

FROM hz_contact_points

WHERE owner_table_id = ct.ship_to_party_contact_id

AND contact_point_type = 'PHONE'

AND phone_type = 'FAX'

AND status = 'A'

AND ROWNUM = 1)

fax,

(SELECT party_name

FROM hz_parties
WHERE party_id = ct.ship_to_party_contact_id)

contact

FROM ra_customer_trx_all ct,

hz_cust_accounts hca,

hz_parties hp,

hz_party_sites hps,

hz_cust_site_uses_all hcsua,

hz_cust_acct_sites_all hcasa,

hz_locations hl,

hr_operating_units hr,

hr_organization_units hro,

hr_locations hrl,

xle_entity_profiles xep

WHERE 1 = 1

AND ct.bill_to_customer_id = hca.cust_account_id

AND hp.party_id = hca.party_id

AND hr.organization_id = ct.org_id

AND hp.party_id = hps.party_id

AND hro.organization_id = hr.organization_id

AND hro.location_id = hrl.location_id

AND hr.default_legal_context_id = xep.legal_entity_id

AND hps.location_id = hl.location_id

AND hca.cust_account_id = hcasa.cust_account_id

AND hcasa.cust_acct_site_id = hcsua.cust_acct_site_id

AND hcsua.site_use_id = ct.bill_to_site_use_id

AND hcasa.party_site_id = hps.party_site_id

AND hcsua.site_use_code = 'BILL_TO'

AND trx_number = :p_trx_num

AND trx_date between :p_from_date and :p_to_date


AND hp.party_name = :p_customer_name

AND hr.name = :p_operating_unit

AND xep.legal_entity_id = :p_legal_entity

You might also like