select cttv.transaction_type_id , cttv.name from cs_transaction_types_vl cttv, cs_txn_billing_types ctbt, cs_bus_process_txns cbpt, cs_business_processes cbp, csi_txn_sub_types ctst, csi_txn_types ctt, csi_instance_statuses cis where cttv.transaction_type_id = ctbt.transaction_type_id and ctbt.transaction_type_id = cbpt.transaction_type_id and trunc(sysdate) between nvl(ctbt.start_date_active,to_date(sysdate)) and nvl(ctbt.end_date_active,to_date(sysdate)) and trunc(sysdate) between nvl(cbpt.start_date_active, to_date(sysdate)) and nvl(cbpt.end_date_active, to_date(sysdate)) and cbpt.business_process_id = cbp.business_process_id and cbp.field_service_flag = 'Y' and ctbt.billing_type = 'M' and ctst.cs_transaction_type_id = cttv.transaction_type_id and ctt.source_application_id=513 and ctt.transaction_type_id = ctst.transaction_type_id and ctst.src_status_id = cis.instance_status_id(+) and (nvl(ctst.update_ib_flag, 'N') = 'N' or ( ctst.update_ib_flag = 'Y' and trunc(sysdate) between nvl(cis.start_date_active,trunc(sysdate)) and nvl(cis.end_date_active,trunc(sysdate)) and nvl(cis.terminated_flag, 'N') <> 'Y' and ctst.src_change_owner = 'Y' and nvl(ctst.src_return_reqd, 'N') = 'N' and ( (ctst.src_change_owner_to_code = 'I' and nvl(ctst.parent_reference_reqd, 'N') = 'N' and cttv.line_order_category_code='RETURN') or (ctst.src_change_owner_to_code = 'E' and ctst.src_reference_reqd = 'Y' and cttv.line_order_category_code='ORDER') ) ) ) order by cttv.name