Tuesday, 12 September 2023

Sample Fast Formula - Global Absence Type Duration Formula

/******************************************************************************

FORMULA NAME: XYZ_Client_LWP_Duration_FF
FORMULA TYPE: Global Absence Type Duration Formula
DESCRIPTION: This formula returns the duration for India Client emps for LWP absence type deducting Republic Day, Independence Day and Gandhi Jayanthi
Change History:
Name Date Version Comments
-------------------------------------------------------------------------------
Aditya  Initial Version
*******************************************************************************/
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 PER_ASG_FTE_VALUE IS 1
INPUTS ARE IV_START_DATE (date), IV_END_DATE (date), IV_START_TIME(text),IV_END_TIME(text)
ln_entry_duration_d = 0
ln_subtract_duration = 0
DURATION =0
ld_period_start_date = to_date(to_char(IV_START_DATE,'DD/MM/RRRR')||' '||'00:00:00','DD/MM/RRRR HH24:MI:SS')
ld_period_end_date = to_date(to_char(IV_END_DATE,'DD/MM/RRRR')||' '||'00:00:00','DD/MM/RRRR HH24:MI:SS')

ln_entry_duration_d = days_between(ld_period_end_date,ld_period_start_date) + 1
ln_start_year = to_number(to_char(IV_START_DATE,'RRRR'))
ln_end_year = to_number(to_char(IV_END_DATE,'RRRR'))
while ln_start_year<=ln_end_year loop
(
ld_republic_day = to_date('26/01/'||to_char(ln_start_year)||' '||'00:00:00','DD/MM/RRRR HH24:MI:SS')
ld_independence_day = to_date('15/08/'||to_char(ln_start_year)||' '||'00:00:00','DD/MM/RRRR HH24:MI:SS')
ld_gandhi_jayanthi = to_date('02/10/'||to_char(ln_start_year)||' '||'00:00:00','DD/MM/RRRR HH24:MI:SS')
ln_subtract_duration = ln_subtract_duration + is_date_between(ld_republic_day,ld_period_start_date,ld_period_end_date)
ln_subtract_duration = ln_subtract_duration + is_date_between(ld_independence_day,ld_period_start_date,ld_period_end_date)
ln_subtract_duration = ln_subtract_duration + is_date_between(ld_gandhi_jayanthi,ld_period_start_date,ld_period_end_date)
ln_start_year = ln_start_year + 1
)
ln_entry_duration_d = ln_entry_duration_d - ln_subtract_duration
if ln_entry_duration_d > 0 then
DURATION = ln_entry_duration_d
else
DURATION = 0

RETURN DURATION

No comments:

Post a Comment