You are on page 1of 3

------- Payment -----------------

SELECT DISTINCT
--petf.business_group_id,fnd_profile.value('PER_BUSINESS_GROUP_ID'),
paa.assignment_action_id
-- ,ppa.payroll_action_id
-- ,ppa.payroll_id
-- ,papf.employee_number
,papf.employee_number emp_num
,papf.full_name emp_name
,to_char(ppa.effective_date,'MON-YYYY') PERIOD
-- ,papf.effective_end_date
-- ,papf.person_id
-- ,papf.original_date_of_hire date_of_joining
-- ,paaf.assignment_id
-- ,paaf.assignment_number
-- ,paaf.location_id
-- ,ptp.start_date
-- ,ppa.effective_date
-- ,pcak.segment3 cost_centre
-- ,nvl(petf.reporting_name,petf.element_name) element_name
-- ,DECODE(cla.classification_name,'Earnings',cla.classification_name,
-- 'Allowances','Earnings',
-- 'Deductions') classification_name
-- ,prrv.run_result_id
,nvl(run_res_val.result_value,0) pay_value
-- ,to_number(nvl(petf.attribute1,'9999')) seq
-- ,petf.processing_priority
,pap.name position
,pos.D_PARENT_NAME dept
,haou.NAME subdept
-- ppa.time_period_id
FROM pay_assignment_actions paa
,pay_payroll_actions ppa
,per_all_assignments_f paaf
,per_all_people_f papf
,per_time_periods ptp
,pay_cost_allocations_f pcaf
,pay_cost_allocation_keyflex pcak
,pay_run_results prrv
,pay_run_result_values run_res_val
,pay_element_types_f petf
,per_all_positions pap
,hr_all_organization_units haou
,PER_ORG_STRUCTURE_ELEMENTS_V pos
--,
--hr_assignment_sets assign_set
,pay_element_classifications cla
,pay_input_values_f ip
WHERE paa.payroll_action_id = ppa.payroll_action_id
aND paaf.position_id = pap.position_id (+)
-- AND PAPF.EMPLOYEE_NUMBER = '10041'
AND paaf.organization_id = haou.organization_id
and paaf.organization_id = pos.ORGANIZATION_ID_CHILD(+)
-- AND ppa.payroll_id = nvl(:p_payroll_id,ppa.payroll_id)
--and papf.employee_number in ('10771')
AND ppa.action_type IN ('R','Q') --R --> payroll run
AND ptp.time_period_id = ppa.time_period_id
AND paaf.assignment_id = paa.assignment_id
AND prrv.assignment_action_id = paa.assignment_action_id
-- AND PAPF.EMPLOYEE_NUMBER = '10002'
AND cla.classification_name IN ('Earnings', 'Statutory Deductions', 'Involuntary
Deductions','Voluntary Deductions','Allowances')
AND ppa.effective_date BETWEEN paaf.effective_start_date AND
paaf.effective_end_date
and paaf.PRIMARY_FLAG='Y'
AND papf.current_employee_flag = 'Y' --- Added on 30-May-2012
AND paaf.person_id = papf.person_id
--AND prrv.element_name = petf.element_name
AND pcaf.cost_allocation_keyflex_id = pcak.cost_allocation_keyflex_id(+)
AND pcaf.assignment_id(+) = paaf.assignment_id
-- AND ppa.effective_date BETWEEN papf.effective_start_date AND
papf.effective_end_date
-- AND ppa.effective_date BETWEEN petf.effective_start_date AND
petf.effective_end_date
AND run_res_val.result_value IS NOT NULL
and prrv.RUN_RESULT_ID=run_res_val.RUN_RESULT_ID
and cla.CLASSIFICATION_ID=petf.CLASSIFICATION_ID
and petf.ELEMENT_TYPE_ID=prrv.ELEMENT_TYPE_ID
and petf.ELEMENT_TYPE_ID=ip.ELEMENT_TYPE_ID
and run_res_val.INPUT_VALUE_ID=ip.INPUT_VALUE_ID
and ip.name='Pay Value'
AND petf.element_name IN ('Annual Leave Salary') --, 'Annual Leave Salary
Recovery')
-- ORDER BY
papf.employee_number,cla.classification_name,to_number(nvl(petf.attribute1,'9999'))
,petf.processing_priority,petf.element_name
order by papf.employee_number

------------- Recovery -----------------


SELECT DISTINCT
--petf.business_group_id,fnd_profile.value('PER_BUSINESS_GROUP_ID'),
paa.assignment_action_id
-- ,ppa.payroll_action_id
-- ,ppa.payroll_id
,papf.employee_number
-- ,papf.employee_number emp_num
,papf.full_name emp_name
-- ,papf.effective_end_date
-- ,papf.person_id
-- ,papf.original_date_of_hire date_of_joining
-- ,paaf.assignment_id
-- ,paaf.assignment_number
-- ,paaf.location_id
-- ,ptp.start_date
-- ,ppa.effective_date
,to_char(ppa.effective_date,'MON-YYYY') PERIOD
-- ,pcak.segment3 cost_centre
-- ,nvl(petf.reporting_name,petf.element_name) element_name
-- ,DECODE(cla.classification_name,'Earnings',cla.classification_name,
-- 'Allowances','Earnings',
-- 'Deductions') classification_name
-- ,prrv.run_result_id
,nvl(run_res_val.result_value,0) pay_value
-- ,to_number(nvl(petf.attribute1,'9999')) seq
-- ,petf.processing_priority
,pap.name position
,pos.D_PARENT_NAME dept
,haou.NAME subdept
-- ppa.time_period_id
FROM pay_assignment_actions paa
,pay_payroll_actions ppa
,per_all_assignments_f paaf
,per_all_people_f papf
,per_time_periods ptp
,pay_cost_allocations_f pcaf
,pay_cost_allocation_keyflex pcak
,pay_run_results prrv
,pay_run_result_values run_res_val
,pay_element_types_f petf
,per_all_positions pap
,hr_all_organization_units haou
,PER_ORG_STRUCTURE_ELEMENTS_V pos
--,
--hr_assignment_sets assign_set
,pay_element_classifications cla
,pay_input_values_f ip
WHERE paa.payroll_action_id = ppa.payroll_action_id
aND paaf.position_id = pap.position_id (+)
-- AND PAPF.EMPLOYEE_NUMBER = '10041'
AND paaf.organization_id = haou.organization_id
and paaf.organization_id = pos.ORGANIZATION_ID_CHILD(+)
-- AND ppa.payroll_id = nvl(:p_payroll_id,ppa.payroll_id)
--and papf.employee_number in ('10771')
AND ppa.action_type IN ('R','Q') --R --> payroll run
AND ptp.time_period_id = ppa.time_period_id
AND paaf.assignment_id = paa.assignment_id
AND prrv.assignment_action_id = paa.assignment_action_id
AND cla.classification_name IN ('Earnings', 'Statutory Deductions', 'Involuntary
Deductions','Voluntary Deductions','Allowances')
AND ppa.effective_date BETWEEN paaf.effective_start_date AND
paaf.effective_end_date
and paaf.PRIMARY_FLAG='Y'
AND papf.current_employee_flag = 'Y' --- Added on 30-May-2012
AND paaf.person_id = papf.person_id
--AND prrv.element_name = petf.element_name
AND pcaf.cost_allocation_keyflex_id = pcak.cost_allocation_keyflex_id(+)
AND pcaf.assignment_id(+) = paaf.assignment_id
-- AND ppa.effective_date BETWEEN papf.effective_start_date AND
papf.effective_end_date
-- AND ppa.effective_date BETWEEN petf.effective_start_date AND
petf.effective_end_date
AND run_res_val.result_value IS NOT NULL
and prrv.RUN_RESULT_ID=run_res_val.RUN_RESULT_ID
and cla.CLASSIFICATION_ID=petf.CLASSIFICATION_ID
and petf.ELEMENT_TYPE_ID=prrv.ELEMENT_TYPE_ID
and petf.ELEMENT_TYPE_ID=ip.ELEMENT_TYPE_ID
and run_res_val.INPUT_VALUE_ID=ip.INPUT_VALUE_ID
and ip.name='Pay Value'
AND petf.element_name LIKE ('Annual Leave Salary Recovery')
and run_res_val.result_value <>0
--ORDER BY
papf.employee_number,cla.classification_name,to_number(nvl(petf.attribute1,'9999'))
,petf.processing_priority,petf.element_name
order by papf.employee_number