select
haouv.name operating_unit,
aqha.quote_number,
aqha.quote_version,
aqha.quote_name,
aqsv.meaning status,
aqha.quote_source_code source,
hp.party_name customer,
hca.account_number,
(
select
hp2.party_name
from
hz_relationships hr,
hz_parties hp2
where
aqha.party_id=hr.party_id and
hr.subject_type='PERSON' and
hr.subject_table_name='HZ_PARTIES' and
hr.subject_id=hp2.party_id
) contact,
jrrev.resource_name salesperson,
xxen_util.client_time(aqha.creation_date) creation_date,
aqha.quote_expiration_date expiration_date,
aqha.currency_code currency,
(select qlhv.name from qp_list_headers_vl qlhv where aqha.price_list_id=qlhv.list_header_id) price_list,
aqha.total_list_price,
aqha.total_adjusted_amount total_adjustment,
aqha.total_tax,
aqha.total_shipping_charge,
aqha.total_quote_price,
ooha.order_number,
count(aqla.quote_line_id) over (partition by aqha.quote_header_id) line_count,
aqha.quote_description,
xxen_util.user_name(aqha.created_by) created_by,
xxen_util.client_time(aqha.last_update_date) last_update_date,
aqla.line_number line,
xxen_util.meaning(aqla.item_type_code,'ASO_ITEM_TYPE',697) item_type,
msiv.concatenated_segments item,
msiv.description item_description,
aqla.quantity,
aqla.uom_code uom,
aqla.line_list_price unit_list_price,
aqla.line_adjusted_percent discount_percent,
aqla.line_quote_price unit_selling_price,
aqla.quantity*aqla.line_quote_price line_amount,
ash_line.request_date,
(select hz_format_pub.format_address(hps.location_id,null,null,' , ') from hz_party_sites hps where nvl(ash_line.ship_to_party_site_id,ash_hdr.ship_to_party_site_id)=hps.party_site_id) ship_to_address
from
hr_all_organization_units_vl haouv,
aso_quote_headers_all aqha,
aso_quote_statuses_vl aqsv,
hz_cust_accounts hca,
hz_parties hp,
jtf_rs_resource_extns_vl jrrev,
oe_order_headers_all ooha,
aso_shipments ash_hdr,
aso_quote_lines_all aqla,
aso_shipments ash_line,
mtl_system_items_vl msiv
where
1=1 and
aqha.org_id in (select xroa.id from xxen_report_org_access xroa where xroa.access_type='OU') and
aqha.org_id=haouv.organization_id and
aqha.quote_status_id=aqsv.quote_status_id and
aqha.cust_account_id=hca.cust_account_id(+) and
nvl(aqha.cust_party_id,aqha.party_id)=hp.party_id(+) and
aqha.resource_id=jrrev.resource_id(+) and
aqha.order_id=ooha.header_id(+) and
aqha.quote_header_id=ash_hdr.quote_header_id(+) and
ash_hdr.quote_line_id(+) is null and
aqha.quote_header_id=aqla.quote_header_id(+) and
aqla.quote_line_id=ash_line.quote_line_id(+) and
aqla.inventory_item_id=msiv.inventory_item_id(+) and
aqla.organization_id=msiv.organization_id(+)
order by
haouv.name,
aqha.quote_number,
aqha.quote_version,
aqla.line_number,
aqla.quote_line_id |