select paa.person_id,
paat.name LeaveType,
paat.name LeaveType,
paa.absence_days Leave_Days,
paa.date_start,
paa.date_end,
hr_general.decode_lookup('ABSENCE_REASON',paar.name) Absence_Reason,
paa.attribute1 Exam_Status,
paa.attribute2 Study_Status,
hr_general.decode_lookup('YES_NO',paa.attribute3) Leave_Allowance,
hr_general.decode_lookup('YES_NO',paa.attribute4) Leave_Salary,
NVL(abs( (SELECT DISTINCT SUM(TO_NUMBER(peev.screen_entry_value)) VALUE
FROM pay_element_entries_f peef,
pay_element_entry_values_f peev,
pay_element_links_f LINK,
pay_element_types_f TYPE,
pay_input_values_f input
WHERE TYPE.element_name = 'Annual Leave Adjustment'
AND input.NAME = 'Plan Days'
AND TYPE.business_group_id = 81
AND peef.assignment_id =PAAF.assignment_id
AND peev.element_entry_id IN (SELECT DISTINCT a.ELEMENT_ENTRY_ID
FROM pay_element_entries_f a,
pay_element_entry_values_f b,
pay_element_links_f c,
pay_element_types_f d,
pay_input_values_f e
WHERE d.element_name = 'Annual Leave Adjustment'
AND e.NAME ='Adjusted Leave Period'
AND b.screen_entry_value=PAA.ABSENCE_ATTENDANCE_ID
AND d.business_group_id = 81
AND a.assignment_id =PAAF.assignment_id
AND d.business_group_id = c.business_group_id
AND d.business_group_id =
e.business_group_id
AND a.element_entry_id = b.element_entry_id
AND a.element_link_id = c.element_link_id
AND c.element_type_id = d.element_type_id
AND d.element_type_id = e.element_type_id
AND b.input_value_id = e.input_value_id
AND paa.date_start
BETWEEN d.effective_start_date
AND d.effective_end_date
AND paa.date_start
BETWEEN c.effective_start_date
AND c.effective_end_date
AND paa.date_start
BETWEEN a.effective_start_date
AND a.effective_end_date
AND paa.date_start
BETWEEN b.effective_start_date
AND b.effective_end_date
AND paa.date_start
BETWEEN e.effective_start_date
AND e.effective_end_date)
AND TYPE.business_group_id = LINK.business_group_id
AND TYPE.business_group_id =
input.business_group_id
AND peef.element_entry_id = peev.element_entry_id
AND peef.element_link_id = LINK.element_link_id
AND LINK.element_type_id = TYPE.element_type_id
AND TYPE.element_type_id = input.element_type_id
AND peev.input_value_id = input.input_value_id
AND paa.date_start
BETWEEN TYPE.effective_start_date
AND TYPE.effective_end_date
AND paa.date_start
BETWEEN LINK.effective_start_date
AND LINK.effective_end_date
AND paa.date_start
BETWEEN peef.effective_start_date
AND peef.effective_end_date
AND paa.date_start
BETWEEN peev.effective_start_date
AND peev.effective_end_date
AND paa.date_start
BETWEEN input.effective_start_date
AND input.effective_end_date)),0) ADJUSTMENT_DAYS,
Case When paat.name='Annual Leave' Then paa.absence_days-nvl(abs( (SELECT DISTINCT sum(to_number(peev.screen_entry_value)) VALUE
FROM pay_element_entries_f peef,
pay_element_entry_values_f peev,
pay_element_links_f LINK,
pay_element_types_f TYPE,
pay_input_values_f input
WHERE TYPE.element_name = 'Annual Leave Adjustment'
AND input.NAME = 'Plan Days'
AND TYPE.business_group_id = 81
AND peef.assignment_id =PAAF.assignment_id
AND TYPE.business_group_id = LINK.business_group_id
AND TYPE.business_group_id =
input.business_group_id
AND peef.element_entry_id = peev.element_entry_id
AND peef.element_link_id = LINK.element_link_id
AND LINK.element_type_id = TYPE.element_type_id
AND TYPE.element_type_id = input.element_type_id
AND peev.input_value_id = input.input_value_id
AND peev.element_entry_id IN (SELECT DISTINCT a.ELEMENT_ENTRY_ID
FROM pay_element_entries_f a,
pay_element_entry_values_f b,
pay_element_links_f c,
pay_element_types_f d,
pay_input_values_f e
WHERE d.element_name = 'Annual Leave Adjustment'
AND e.NAME ='Adjusted Leave Period'
AND b.screen_entry_value=PAA.ABSENCE_ATTENDANCE_ID
AND d.business_group_id = 81
AND a.assignment_id =PAAF.assignment_id
AND d.business_group_id = c.business_group_id
AND d.business_group_id =
e.business_group_id
AND a.element_entry_id = b.element_entry_id
AND a.element_link_id = c.element_link_id
AND c.element_type_id = d.element_type_id
AND d.element_type_id = e.element_type_id
AND b.input_value_id = e.input_value_id
AND paa.date_start
BETWEEN d.effective_start_date
AND d.effective_end_date
AND paa.date_start
BETWEEN c.effective_start_date
AND c.effective_end_date
AND paa.date_start
BETWEEN a.effective_start_date
AND a.effective_end_date
AND paa.date_start
BETWEEN b.effective_start_date
AND b.effective_end_date
AND paa.date_start
BETWEEN e.effective_start_date
AND e.effective_end_date)
AND paa.date_start
BETWEEN TYPE.effective_start_date
AND TYPE.effective_end_date
AND paa.date_start
BETWEEN LINK.effective_start_date
AND LINK.effective_end_date
AND paa.date_start
BETWEEN peef.effective_start_date
AND peef.effective_end_date
AND paa.date_start
BETWEEN peev.effective_start_date
AND peev.effective_end_date
AND paa.date_start
BETWEEN input.effective_start_date
AND input.effective_end_date)),0) Else 0 End TOTAL_ANNUAL
from per_absence_attendance_types paat,
per_absence_attendances paa,
per_abs_attendance_reasons paar,
per_all_assignments_f paaf
where 1=1
AND paat.absence_attendance_type_id=paa.absence_attendance_type_id
and paa.person_id=paaf.person_id
AND PAAF.PRIMARY_FLAG='Y'
and paa.date_start between paaf.effective_start_date and paaf.effective_end_date
AND paa.abs_attendance_reason_id =paar.abs_attendance_reason_id(+)
AND paat.name =nvl(:p_leavetype,paat.name)
/*AND (paa.date_start BETWEEN fnd_date.canonical_to_date(:P_START_DATE) AND fnd_date.canonical_to_date(:P_END_DATE) OR
paa.date_end BETWEEN fnd_date.canonical_to_date(:P_START_DATE) AND fnd_date.canonical_to_date(:P_END_DATE) OR
(fnd_date.canonical_to_date(:P_START_DATE) < paa.date_start AND fnd_date.canonical_to_date(:P_END_DATE) > paa.date_end))*/
AND ((paa.date_start BETWEEN :P_START_DATE AND :P_END_DATE) OR
(paa.date_end BETWEEN :P_START_DATE AND :P_END_DATE) OR
(:P_START_DATE < paa.date_start AND :P_END_DATE > paa.date_end))
AND paa.person_id = :person_id
ORDER BY paat.name,paa.date_start
paat.name LeaveType,
paat.name LeaveType,
paa.absence_days Leave_Days,
paa.date_start,
paa.date_end,
hr_general.decode_lookup('ABSENCE_REASON',paar.name) Absence_Reason,
paa.attribute1 Exam_Status,
paa.attribute2 Study_Status,
hr_general.decode_lookup('YES_NO',paa.attribute3) Leave_Allowance,
hr_general.decode_lookup('YES_NO',paa.attribute4) Leave_Salary,
NVL(abs( (SELECT DISTINCT SUM(TO_NUMBER(peev.screen_entry_value)) VALUE
FROM pay_element_entries_f peef,
pay_element_entry_values_f peev,
pay_element_links_f LINK,
pay_element_types_f TYPE,
pay_input_values_f input
WHERE TYPE.element_name = 'Annual Leave Adjustment'
AND input.NAME = 'Plan Days'
AND TYPE.business_group_id = 81
AND peef.assignment_id =PAAF.assignment_id
AND peev.element_entry_id IN (SELECT DISTINCT a.ELEMENT_ENTRY_ID
FROM pay_element_entries_f a,
pay_element_entry_values_f b,
pay_element_links_f c,
pay_element_types_f d,
pay_input_values_f e
WHERE d.element_name = 'Annual Leave Adjustment'
AND e.NAME ='Adjusted Leave Period'
AND b.screen_entry_value=PAA.ABSENCE_ATTENDANCE_ID
AND d.business_group_id = 81
AND a.assignment_id =PAAF.assignment_id
AND d.business_group_id = c.business_group_id
AND d.business_group_id =
e.business_group_id
AND a.element_entry_id = b.element_entry_id
AND a.element_link_id = c.element_link_id
AND c.element_type_id = d.element_type_id
AND d.element_type_id = e.element_type_id
AND b.input_value_id = e.input_value_id
AND paa.date_start
BETWEEN d.effective_start_date
AND d.effective_end_date
AND paa.date_start
BETWEEN c.effective_start_date
AND c.effective_end_date
AND paa.date_start
BETWEEN a.effective_start_date
AND a.effective_end_date
AND paa.date_start
BETWEEN b.effective_start_date
AND b.effective_end_date
AND paa.date_start
BETWEEN e.effective_start_date
AND e.effective_end_date)
AND TYPE.business_group_id = LINK.business_group_id
AND TYPE.business_group_id =
input.business_group_id
AND peef.element_entry_id = peev.element_entry_id
AND peef.element_link_id = LINK.element_link_id
AND LINK.element_type_id = TYPE.element_type_id
AND TYPE.element_type_id = input.element_type_id
AND peev.input_value_id = input.input_value_id
AND paa.date_start
BETWEEN TYPE.effective_start_date
AND TYPE.effective_end_date
AND paa.date_start
BETWEEN LINK.effective_start_date
AND LINK.effective_end_date
AND paa.date_start
BETWEEN peef.effective_start_date
AND peef.effective_end_date
AND paa.date_start
BETWEEN peev.effective_start_date
AND peev.effective_end_date
AND paa.date_start
BETWEEN input.effective_start_date
AND input.effective_end_date)),0) ADJUSTMENT_DAYS,
Case When paat.name='Annual Leave' Then paa.absence_days-nvl(abs( (SELECT DISTINCT sum(to_number(peev.screen_entry_value)) VALUE
FROM pay_element_entries_f peef,
pay_element_entry_values_f peev,
pay_element_links_f LINK,
pay_element_types_f TYPE,
pay_input_values_f input
WHERE TYPE.element_name = 'Annual Leave Adjustment'
AND input.NAME = 'Plan Days'
AND TYPE.business_group_id = 81
AND peef.assignment_id =PAAF.assignment_id
AND TYPE.business_group_id = LINK.business_group_id
AND TYPE.business_group_id =
input.business_group_id
AND peef.element_entry_id = peev.element_entry_id
AND peef.element_link_id = LINK.element_link_id
AND LINK.element_type_id = TYPE.element_type_id
AND TYPE.element_type_id = input.element_type_id
AND peev.input_value_id = input.input_value_id
AND peev.element_entry_id IN (SELECT DISTINCT a.ELEMENT_ENTRY_ID
FROM pay_element_entries_f a,
pay_element_entry_values_f b,
pay_element_links_f c,
pay_element_types_f d,
pay_input_values_f e
WHERE d.element_name = 'Annual Leave Adjustment'
AND e.NAME ='Adjusted Leave Period'
AND b.screen_entry_value=PAA.ABSENCE_ATTENDANCE_ID
AND d.business_group_id = 81
AND a.assignment_id =PAAF.assignment_id
AND d.business_group_id = c.business_group_id
AND d.business_group_id =
e.business_group_id
AND a.element_entry_id = b.element_entry_id
AND a.element_link_id = c.element_link_id
AND c.element_type_id = d.element_type_id
AND d.element_type_id = e.element_type_id
AND b.input_value_id = e.input_value_id
AND paa.date_start
BETWEEN d.effective_start_date
AND d.effective_end_date
AND paa.date_start
BETWEEN c.effective_start_date
AND c.effective_end_date
AND paa.date_start
BETWEEN a.effective_start_date
AND a.effective_end_date
AND paa.date_start
BETWEEN b.effective_start_date
AND b.effective_end_date
AND paa.date_start
BETWEEN e.effective_start_date
AND e.effective_end_date)
AND paa.date_start
BETWEEN TYPE.effective_start_date
AND TYPE.effective_end_date
AND paa.date_start
BETWEEN LINK.effective_start_date
AND LINK.effective_end_date
AND paa.date_start
BETWEEN peef.effective_start_date
AND peef.effective_end_date
AND paa.date_start
BETWEEN peev.effective_start_date
AND peev.effective_end_date
AND paa.date_start
BETWEEN input.effective_start_date
AND input.effective_end_date)),0) Else 0 End TOTAL_ANNUAL
from per_absence_attendance_types paat,
per_absence_attendances paa,
per_abs_attendance_reasons paar,
per_all_assignments_f paaf
where 1=1
AND paat.absence_attendance_type_id=paa.absence_attendance_type_id
and paa.person_id=paaf.person_id
AND PAAF.PRIMARY_FLAG='Y'
and paa.date_start between paaf.effective_start_date and paaf.effective_end_date
AND paa.abs_attendance_reason_id =paar.abs_attendance_reason_id(+)
AND paat.name =nvl(:p_leavetype,paat.name)
/*AND (paa.date_start BETWEEN fnd_date.canonical_to_date(:P_START_DATE) AND fnd_date.canonical_to_date(:P_END_DATE) OR
paa.date_end BETWEEN fnd_date.canonical_to_date(:P_START_DATE) AND fnd_date.canonical_to_date(:P_END_DATE) OR
(fnd_date.canonical_to_date(:P_START_DATE) < paa.date_start AND fnd_date.canonical_to_date(:P_END_DATE) > paa.date_end))*/
AND ((paa.date_start BETWEEN :P_START_DATE AND :P_END_DATE) OR
(paa.date_end BETWEEN :P_START_DATE AND :P_END_DATE) OR
(:P_START_DATE < paa.date_start AND :P_END_DATE > paa.date_end))
AND paa.person_id = :person_id
ORDER BY paat.name,paa.date_start
No comments :
Post a Comment