select
z.business_group,
z.employee_number,
z.employee_name,
z.assignment_number,
z.organization,
z.job,
z.position,
z.grade,
z.location,
z.supervisor,
z.payroll,
z.accrual_plan,
z.accrual_category,
z.accrual_unit,
z.enrollment_start_date,
z.accrual_term_start_date,
z.carried_over,
z.accrued,
z.taken,
z.other_contributions,
z.net_balance,
z.salary_basis,
z.pay_basis,
z.currency,
z.salary,
z.annualized_salary,
round(z.unit_rate,2) unit_rate,
round(z.net_balance*z.unit_rate,2) leave_liability,
z.calculation_message
from
(
select
y.*,
fnd_date.canonical_to_date(regexp_substr(y.accrual,'([^~]*)~',1,1,null,1)) accrual_term_start_date,
fnd_number.canonical_to_number(regexp_substr(y.accrual,'([^~]*)~',1,2,null,1)) accrued,
fnd_number.canonical_to_number(regexp_substr(y.accrual,'([^~]*)~',1,3,null,1)) taken,
fnd_number.canonical_to_number(regexp_substr(y.accrual,'([^~]*)~',1,4,null,1)) carried_over,
fnd_number.canonical_to_number(regexp_substr(y.accrual,'([^~]*)~',1,5,null,1)) other_contributions,
fnd_number.canonical_to_number(regexp_substr(y.accrual,'([^~]*)~',1,6,null,1)) net_balance,
substr(y.accrual,instr(y.accrual,'~',1,6)+1) calculation_message
from
(
select /*+ no_merge */
x.*,
x.salary*x.pay_factor annualized_salary,
case
when x.accrual_uom='D' then x.salary*x.pay_factor/:working_days_per_year
when x.pay_basis_code='HOURLY' then x.salary
else x.salary*x.pay_factor/nullif(x.annual_hours,0)
end unit_rate,
(select xxen_per.accrual(x.assignment_id,x.accrual_plan_id,x.payroll_id,x.business_group_id,:effective_date) from dual) accrual
from
(
select
haouv.name business_group,
papf.employee_number,
papf.full_name employee_name,
paaf.assignment_number,
haouv2.name organization,
(select pjv.name from per_jobs_vl pjv where paaf.job_id=pjv.job_id) job,
(select hapft.name from hr_all_positions_f_tl hapft where paaf.position_id=hapft.position_id and hapft.language=userenv('lang')) position,
(select pgv.name from per_grades_vl pgv where paaf.grade_id=pgv.grade_id) grade,
(select hlav.location_code from hr_locations_all_vl hlav where paaf.location_id=hlav.location_id) location,
(select papf2.full_name from per_all_people_f papf2 where paaf.supervisor_id=papf2.person_id and :effective_date between papf2.effective_start_date and papf2.effective_end_date) supervisor,
(select paypf.payroll_name from pay_all_payrolls_f paypf where paaf.payroll_id=paypf.payroll_id and :effective_date between paypf.effective_start_date and paypf.effective_end_date) payroll,
pap.accrual_plan_name accrual_plan,
xxen_util.meaning(pap.accrual_category,'US_PTO_ACCRUAL',3) accrual_category,
xxen_util.meaning(pap.accrual_units_of_measure,'HOURS_OR_DAYS',3) accrual_unit,
(select min(peef2.effective_start_date) from pay_element_entries_f peef2 where peef.element_entry_id=peef2.element_entry_id) enrollment_start_date,
ppb.name salary_basis,
xxen_util.meaning(ppb.pay_basis,'PAY_BASIS',3) pay_basis,
(
select
petf.input_currency_code
from
pay_input_values_f pivf,
pay_element_types_f petf
where
ppb.input_value_id=pivf.input_value_id and
:effective_date between pivf.effective_start_date and pivf.effective_end_date and
pivf.element_type_id=petf.element_type_id and
:effective_date between petf.effective_start_date and petf.effective_end_date
) currency,
(select max(ppp.proposed_salary_n) keep (dense_rank last order by ppp.change_date) from per_pay_proposals ppp where paaf.assignment_id=ppp.assignment_id and ppp.approved='Y' and ppp.change_date<=:effective_date) salary,
decode(ppb.pay_annualization_factor,
0,1,
null,decode(ppb.pay_basis,'PERIOD',(select ptpt.number_per_fiscal_year from pay_all_payrolls_f paypf, per_time_period_types ptpt where paaf.payroll_id=paypf.payroll_id and :effective_date between paypf.effective_start_date and paypf.effective_end_date and paypf.period_type=ptpt.period_type)),
ppb.pay_annualization_factor
) pay_factor,
paaf.normal_hours*decode(paaf.frequency,'D',:working_days_per_year,'W',52,'M',12,'Y',1) annual_hours,
pap.accrual_units_of_measure accrual_uom,
ppb.pay_basis pay_basis_code,
pap.accrual_plan_id,
paaf.assignment_id,
paaf.payroll_id,
paaf.business_group_id
from
hr_all_organization_units_vl haouv,
pay_accrual_plans pap,
pay_element_links_f pelf,
pay_element_entries_f peef,
per_all_assignments_f paaf,
per_all_people_f papf,
hr_all_organization_units_vl haouv2,
per_pay_bases ppb
where
1=1 and
haouv.organization_id=pap.business_group_id and
pap.accrual_plan_element_type_id=pelf.element_type_id and
:effective_date between pelf.effective_start_date and pelf.effective_end_date and
pelf.element_link_id=peef.element_link_id and
:effective_date between peef.effective_start_date and peef.effective_end_date and
peef.assignment_id=paaf.assignment_id and
:effective_date between paaf.effective_start_date and paaf.effective_end_date and
paaf.person_id=papf.person_id and
:effective_date between papf.effective_start_date and papf.effective_end_date and
paaf.organization_id=haouv2.organization_id and
paaf.pay_basis_id=ppb.pay_basis_id(+)
) x
) y
) z
where
2=2
order by
z.business_group,
z.employee_name,
z.employee_number,
z.assignment_number,
z.accrual_plan |