OKS Service Contracts Billing Schedule

Description
Categories: Enginatics, Service
Repository: Github Columns: Operating Unit, Class, Category, Contract Number, Contract Status, Line Status, Subline Status, Line Number, Contract Line Type, Base Reading ...
select
haouv.name operating_unit,
ocv.meaning class,
osclv.meaning category,
okhab.contract_number,
osv0.meaning contract_status,
osv1.meaning line_status,
osv2.meaning subline_status,
oklb1.line_number||nvl2(oklb2.line_number,'.'||oklb2.line_number,null) line_number,
xxen_util.meaning((select olsb.lty_code from okc_line_styles_b olsb where nvl(oklb2.lse_id,oklb1.lse_id)=olsb.id),'OKC_LINE_TYPE',0)||decode(okslb1.usage_type,'VRT',' Actual','FRT',' Fixed','NPR',' Negotiated') contract_line_type,
okslb2.base_reading,
okslb1.usage_period,
rr.name invoice_rule,
rr2.name accounting_rule,
oslb.sequence_no,
oslb.level_periods,
oslb.uom_per_period,
oslb.uom_code,
oslb.start_date,
oslb.end_date,
ole.sequence_number,
ole.date_start,
ole.date_end,
ole.date_completed,
ole.amount,
ole.date_to_interface,
okhab.scs_code,
okslb1.usage_type,
olsb1.lty_code
from
hr_all_organization_units_vl haouv,
okc_k_headers_all_b okhab,
okc_subclasses_v osclv,
okc_classes_v ocv,
okc_statuses_v osv0,
okc_statuses_v osv1,
okc_statuses_v osv2,
okc_k_lines_b oklb1,
okc_k_lines_b oklb2,
oks_k_lines_b okslb1,
oks_k_lines_b okslb2,
okc_line_styles_b olsb1,
okc_line_styles_b olsb2,
oks_stream_levels_b oslb,
oks_level_elements ole,
ra_rules rr,
ra_rules rr2
where
1=1 and
haouv.organization_id=okhab.org_id and
okhab.scs_code=osclv.code(+