Professional Documents
Culture Documents
/* Alias Section */
ALIAS ABSENCES_DELIVERY_DATE AS Delivery_Date
/* local variables */
l_leave_name = GET_ABSENCE_TYPE(absence_attendance_type_id)
error_or_warning = ' '
invalid_msg = ' '
duration = '0'
v_dur = 0
number_of_days = 0
first_day_hours = 0
last_day_hours = 0
p_year = to_char(date_end,'YYYY')
/* Defaults Section */
/* default values for working day, these are only used if no
working conditions can be found */
begin_day = '09:00'
end_day = '17:00'
IF (PER_SEX = 'Male')
THEN
(
duration = 'FAILED'
invalid_msg = 'Only female are eligible for Maternity Leave'
)
IF (MONTHS_BETWEEN(date_start,EMP_HIRE_DATE ) < 3)
THEN
(
duration = 'FAILED'
invalid_msg = 'Employee is only eligible to avail Sick Leave if service
period is more than 3 months'
)
IF (Tot_Leaves > XXDLALA_SICK_LEAVE_FULL_PAID_LEAVE_MAX_DAYS)
THEN
(
duration = 'FAILED'
invalid_msg = 'Duration of Sick Leave Full Paid Leave should be maximum of
'||to_char
(XXDLALA_SICK_LEAVE_FULL_PAID_LEAVE_MAX_DAYS)||' Calendar days.'
)
)
/************* Sick Leave Half Paid Absence
********************************************/
IF (l_leave_name = 'Sick Leave Half Paid')
THEN
(
v_duration = DAYS_BETWEEN(date_end,date_start) + 1
duration = to_char(v_duration)
Tot_Leaves = v_duration +
GET_COMMITTED_LEAVE_DAYS(absence_attendance_type_id,p_year)
IF (MONTHS_BETWEEN(date_start,EMP_HIRE_DATE ) < 3)
THEN
(
duration = 'FAILED'
invalid_msg = 'Employee is only eligible to avail Sick Leave if service
period is more than 3 months'
)
IF (Tot_Leaves > XXDLALA_SICK_LEAVE_HALF_PAID_LEAVE_MAX_DAYS)
THEN
(
duration = 'FAILED'
invalid_msg = 'Duration of Sick Leave Half Paid Leave should be maximum of
'||to_char
(XXDLALA_SICK_LEAVE_HALF_PAID_LEAVE_MAX_DAYS)||' Calendar days.'
)
)
/************* HAJJ LEAVE
**************************************************************/
IF (l_leave_name = 'Hajj Leave')
THEN
(
v_duration = days_between(date_end,date_start)+1
duration = to_char(v_duration)
IF (GET_RELIGION() <> 'Muslim')
THEN
(
duration = 'FAILED'
invalid_msg = 'Only Muslim employee are eligible for Hajj Leave'
)
IF ((MONTHS_BETWEEN(date_start,EMP_HIRE_DATE )/12) < 2)
THEN
(
duration = 'FAILED'
invalid_msg = 'Employee is eligible to avail Hajj Leave only if the service
period is more then 2 years'
)
IF (v_duration > XXDLALA_HAJJ_LEAVE_MAX_DAYS)
THEN
(
duration = 'FAILED'
invalid_msg = 'Duration of Hajj Leave should be a maximum of '||
to_char(XXDLALA_HAJJ_LEAVE_MAX_DAYS)||' Calendar days.'
)
IF (GET_LEAVE_TIMES(absence_attendance_type_id) > 0)
THEN
(
duration = 'FAILED'
invalid_msg = 'Employee has already taken Hajj Leave'
)
)
/************* CONDOLENCE LEAVE
********************************************************/
IF (l_leave_name = 'Condolence Leave')
THEN
(
v_duration = days_between(date_end,date_start)+1
duration = to_char(v_duration)
Tot_Leaves = v_duration +
GET_COMMITTED_LEAVE_DAYS(absence_attendance_type_id,p_year)
)
/************* EMERGENCY LEAVE
**********************************************************/
IF (l_leave_name = 'Emergency Leave')
THEN
(
v_duration = days_between(Date_End,Date_Start)+1 -
GET_WEEKEND_DAYS(Date_start,Date_End)
duration = to_char(v_duration)
Tot_Leaves = v_duration +
GET_COMMITTED_LEAVE_DAYS_NO_WE(absence_attendance_type_id,p_year)
IF (Tot_Leaves > XXDLALA_EMERGENCY_LEAVE_MAX_DAYS)
THEN
(
duration = 'FAILED'
invalid_msg = 'Emergency Leave cannot exceed '||
to_char(XXDLALA_EMERGENCY_LEAVE_MAX_DAYS)||' working days.'
)
)
/********* TRAINING LEAVE
****************************************************************/
IF (l_leave_name = 'Training Leave')
THEN
(
v_duration = days_between(Date_End,Date_Start)+1
duration = to_char(v_duration)
/* Return Section */
RETURN duration,invalid_msg