Tuesday, 22 June 2021

Sample Formula to calculate absence duration in Oracle Cloud HCM

 DEFAULT FOR IV_START_DATE IS '4712/12/31 00:00:00' (date)
DEFAULT FOR IV_END_DATE IS '4712/12/31 00:00:00' (date)
DEFAULT FOR IV_START_TIME IS '00:00'
DEFAULT FOR IV_END_TIME IS '23:59'
DEFAULT FOR IV_START_DURATION IS 1
DEFAULT FOR IV_END_DURATION IS 1
DEFAULT FOR PER_ASG_FTE_VALUE IS 1
        DEFAULT FOR PER_ASG_EMPLOYMENT_CATEGORY IS 'UNKNOWN'

INPUTS ARE IV_START_DATE (date), IV_END_DATE (date), IV_START_TIME(text),IV_END_TIME(text), IV_START_DURATION(number), IV_END_DURATION(number)

ln_duration = 0
ln_unrounded_duration_d = 0

lc_asg_resource_type = 'ASSIGN'
ld_period_start_date = to_date(to_char(IV_START_DATE,'DD/MM/RRRR')||' '||IV_START_TIME,'DD/MM/RRRR HH24:MI:SS')
ld_period_end_date = to_date(to_char(IV_END_DATE,'DD/MM/RRRR')||' '||IV_END_TIME,'DD/MM/RRRR HH24:MI:SS')
lc_use_sch_asg_y = 'Y'
lc_use_sch_inh_y = 'Y'
lc_include_noshift_y = 'Y'
lc_include_calevents_y = 'Y'
lc_calc_units_d = 'D'

/* Retrieve the absence duration based on the work schedule */
ln_unrounded_duration_d = GET_PAY_AVAILABILITY (lc_asg_resource_type,
    ld_period_start_date,
    ld_period_end_date,
    lc_use_sch_asg_y,
    lc_use_sch_inh_y,
    lc_include_noshift_y,
    lc_include_calevents_y,
    lc_calc_units_d)
/* test if (vertical) Part time apply the FTE */
       IF PER_ASG_EMPLOYMENT_CATEGORY ='FR_20' THEN 
   ln_duration = ln_unrounded_duration_d * (1/PER_ASG_FTE_VALUE)
       ELSE ln_duration = ln_unrounded_duration_d
  /*duration = ROUND(ln_duration,2)*/
       duration = ln_duration

       RETURN duration

No comments:

Post a Comment