Sei sulla pagina 1di 20

DEFAULT FOR ACP_INELIGIBILITY_PERIOD_UOM IS 'CM'

DEFAULT FOR ACP_INELIGIBILITY_PERIOD_LENGTH IS 0


DEFAULT FOR ACP_CONTINUOUS_SERVICE_DATE IS '4712/12/31 00:00:00' (date)
DEFAULT FOR ACP_ENROLLMENT_START_DATE IS '4712/12/31 00:00:00' (date)
DEFAULT FOR ACP_ENROLLMENT_END_DATE IS '4712/12/31 00:00:00' (date)
DEFAULT FOR ACP_HIRE_DATE IS '4712/12/31 00:00:00' (date)
DEFAULT FOR ACP_TERMINATION_DATE IS '4712/12/31 00:00:00' (date)
/*DEFAULT FOR ACP_TERM_START IS '01/06' DD/MM format */
DEFAULT FOR ACP_TERM_START IS '01/01'
DEFAULT FOR ACP_TERM_LENGTH IS 1
DEFAULT FOR ACP_TERM_UOM IS 'Y'
DEFAULT FOR ACP_FREQUENCY_LENGTH IS 1
DEFAULT FOR ACP_FREQUENCY_UOM IS 'CM'
DEFAULT FOR ACP_UNITS IS 'D'
DEFAULT FOR ACP_ACCRUAL_ELEMENT_TYPE_ID IS 0
DEFAULT FOR ACP_ACCRUAL_INPUT_VALUE_ID IS 0
DEFAULT FOR ACP_TERM_TYPE IS 'S'
DEFAULT FOR PER_ASG_LOCATION_NAME IS 'V1'
DEFAULT FOR PER_ASG_REL_ATTRIBUTE1 IS '10'

INPUTS ARE Calculation_Date (date) , Log_Balance_Details (Text)

Period_Length = ACP_FREQUENCY_LENGTH
Period_Units = ACP_FREQUENCY_UOM
Enroll_Start_Date = ACP_ENROLLMENT_START_DATE
Enroll_End_Date = ACP_ENROLLMENT_END_DATE

HR_VAC = 0
HR_VAC = to_num(PER_ASG_REL_ATTRIBUTE1)

/* CALIFORNIA */
IF (PER_ASG_LOCATION_NAME = 'Orange' Or PER_ASG_LOCATION_NAME = 'San Diego') THEN
(
/* Sumathi */
Accrual_Term_Start_Date = TO_DATE(ACP_TERM_START||'/'||
to_char(Calculation_Date,'YYYY'),'DD/MM/YYYY')
Accrual_Term_End_Date = ADD_DAYS(GET_END_DATE(Accrual_Term_Start_Date ,
ACP_TERM_LENGTH , ACP_TERM_UOM),-1)
Period_Length = ACP_FREQUENCY_LENGTH
Period_Units = ACP_FREQUENCY_UOM
E = GET_PERIOD_DATES(Accrual_Term_Start_Date,
Period_Length ,
Period_Units,
Accrual_Term_Start_Date)
First_Period_SD = GET_DATE('PERIOD_START_DATE')
First_Period_ED = GET_DATE('PERIOD_END_DATE')
E = GET_PERIOD_DATES( Accrual_Term_Start_Date,
Period_Length,
Period_Units,
Calculation_Date)

Calculation_Period_SD = get_date('PERIOD_START_DATE')
Calculation_Period_ED = get_date('PERIOD_END_DATE')
IF (Calculation_Date <> Calculation_Period_ED) THEN
(
E = GET_PERIOD_DATES( Accrual_Term_Start_Date,
Period_Length,
Period_Units,
ADD_DAYS(Calculation_Period_SD,-1))

Calculation_Period_SD = get_date('PERIOD_START_DATE')
Calculation_Period_ED = get_date('PERIOD_END_DATE')
)
IF (Calculation_Period_ED < First_Period_ED) THEN
( Total_Accrued_Amt = 0
)
Accrual_Start_Period_SD = First_Period_SD
Accrual_Start_Period_ED = First_Period_ED
Continuous_Service_Date = ACP_HIRE_DATE
Accrual_Period_Length_In_Days = DAYS_BETWEEN
(Accrual_Start_Period_ED,Accrual_Start_Period_SD)
Accrual_Term_Length_In_Days = DAYS_BETWEEN (Accrual_Term_End_Date,
Accrual_Term_Start_Date)
No_Of_Periods = TRUNC(Accrual_Term_Length_In_Days /
Accrual_Period_Length_In_Days)
Years_service = floor(months_between(Calculation_Date, Continuous_Service_Date) /
12)
Accrual_Band_Id = GET_NUMBER('ACCRUAL_BAND_ID')

Max_Carryover = GET_NUMBER('MAX_CARRY_OVER')
Term_Accrual_Rate = GET_NUMBER('TERM_ACCRUAL_RATE')
Ceiling_Amt = GET_NUMBER('CEILING')

Accrual_Rate = ROUND(Term_Accrual_Rate / No_Of_Periods,2)


Total_Accrued_Amt = 0

Period_SD = Accrual_Start_Period_SD

Period_ED = Accrual_Start_Period_ED

Last_Period_SD = Calculation_Period_SD

Last_Period_ED = Calculation_Period_ED

WHILE ( Period_SD <= Last_Period_SD) LOOP

Years_service = floor(months_between(Period_SD, Continuous_Service_Date) / 12)

IF (GET_ACCRUAL_BAND('NN',years_service) = 0) THEN

Accrual_Band_Id = GET_NUMBER('ACCRUAL_BAND_ID')

Max_Carryover = GET_NUMBER('MAX_CARRY_OVER')

Term_Accrual_Rate = GET_NUMBER('TERM_ACCRUAL_RATE')

Ceiling_Amt = GET_NUMBER('CEILING')

)
ELSE

Accrual_Band_Id = 0

Max_Carryover = 45

Term_Accrual_Rate = 24

Ceiling_Amt = 60

Accrual_Rate = ROUND(Term_Accrual_Rate / No_Of_Periods,2)

Period_Accrued_Amt = Accrual_Rate

Absence = GET_ABSENCE(Accrual_Term_Start_Date, Period_ED)

CarryOver = GET_CARRY_OVER(Accrual_Term_Start_Date, Period_ED)

Other = GET_OTHER_NET_CONTRIBUTION(Accrual_Term_Start_Date, Period_ED)

Period_Others = CarryOver + Other - Absence

IF (Ceiling_Amt > 0) THEN

IF ( (Total_Accrued_Amt + Period_Accrued_Amt + Period_Others) > Ceiling_Amt)


THEN

Amount_Over_Ceiling = ( Total_Accrued_Amt + Period_Accrued_Amt +


Period_Others ) - Ceiling_Amt

IF ( Amount_Over_Ceiling > Period_Accrued_Amt ) THEN

Period_Accrued_Amt = 0

ELSE

Period_Accrued_Amt = Period_Accrued_Amt - Amount_Over_Ceiling


)

IF ( Log_Balance_Details = 'Y' ) THEN

Accrual_Element_Type_Id = ACP_ACCRUAL_ELEMENT_TYPE_ID

Accrual_Element_Input_Id = ACP_ACCRUAL_INPUT_VALUE_ID

Absence_Type_Id = 0

Absence_Attendance_Id = 0

E= SET_ACCRUAL_BALANCE

('ACR',Accrual_Element_Type_Id,Accrual_Element_Input_Id,Accrual_Band_Id,Absence_Typ
e_Id,Absence_Attendance_Id,Period_SD,Period_ED,Period_Accrued_Amt)

Total_Accrued_Amt = Total_Accrued_Amt + Period_Accrued_Amt

E = GET_PERIOD_DATES(Accrual_Term_Start_Date,

Period_Length,

Period_Units,

ADD_DAYS(Period_ED,1) )

Period_SD = get_date('PERIOD_START_DATE')

Period_ED = get_date('PERIOD_END_DATE')

/* Sumathi */

X = to_char(Calculation_Date,'YYYY')

Y = to_char(ACP_HIRE_DATE,'YYYY')

Accrual_Term_End_value='31/12'

Accrual_End_dt=TO_DATE(Accrual_Term_End_value||'/'||
to_char(Calculation_Date,'YYYY'),'DD/MM/YYYY')

IF ( X = Y ) THEN

/* Total_Accrued_Amt=ROUND((DAYS_BETWEEN (Accrual_End_dt,ACP_HIRE_DATE) *
Accrual_Rate_Per_DAY),2) */

Total_Accrued_Amt=(MONTHS_BETWEEN(Accrual_End_dt,ACP_HIRE_DATE) + 1) * Accrual_Rate

/*Total_Accrued_Amt=5*/

V1 = ACP_HIRE_DATE

V2 =ACP_HIRE_DATE

V1 = GET_END_DATE(ACP_HIRE_DATE , 1, 'CM')

V2 = add_months(ACP_HIRE_DATE , 1)

IF ( Calculation_Date <= V2) THEN

Total_Accrued_Amt = 0

)
ELSE

Total_Accrued_Amt = Total_Accrued_Amt

IF Accrual_Start_Period_SD <= Calculation_Period_SD THEN

( Last_Accrual_Date = Calculation_Period_ED )

/* CALIFORNIA */

/* Other LOCATION */

IF (PER_ASG_LOCATION_NAME <> 'Orange' and PER_ASG_LOCATION_NAME <> 'San Diego')


THEN

IF (ACP_TERM_TYPE = 'S') THEN

Accrual_Term_Start_Date = TO_DATE(ACP_TERM_START||'/'||
to_char(Calculation_Date,'YYYY'),'DD/MM/YYYY')

ELSE IF (ACP_TERM_TYPE = 'H') THEN

Accrual_Term_Start_Date =
add_months(ACP_HIRE_DATE,trunc(months_between(Calculation_Date,ACP_HIRE_DATE) / 12)
* 12)

ELSE IF (ACP_TERM_TYPE = 'R') THEN

Accrual_Term_Start_Date = add_months(Calculation_Date,-12)
)

IF Accrual_Term_Start_Date > Calculation_Date THEN

Accrual_Term_Start_Date = GET_END_DATE(Accrual_Term_Start_Date , -
ACP_TERM_LENGTH , ACP_TERM_UOM)

Accrual_Term_End_Date = ADD_DAYS(GET_END_DATE(Accrual_Term_Start_Date ,
ACP_TERM_LENGTH , ACP_TERM_UOM),-1)

E = GET_PERIOD_DATES(Accrual_Term_Start_Date,

Period_Length ,

Period_Units,

Accrual_Term_Start_Date)

First_Period_SD = GET_DATE('PERIOD_START_DATE')

First_Period_ED = GET_DATE('PERIOD_END_DATE')

/* ------------------------------------------------------------------------

Set Calculation_Date to Termination/Enrollment end Date if not null

-------------------------------------------------------------------------- */

IF NOT (ACP_TERMINATION_DATE WAS DEFAULTED) OR NOT (ACP_ENROLLMENT_END_DATE WAS


DEFAULTED) THEN

Early_End_Date = least(ACP_TERMINATION_DATE, Enroll_End_Date)

IF (Early_End_Date < First_Period_ED) THEN


( Total_Accrued_Amt = 0

/*RAISE WARNING RETURN */

IF (Early_End_Date < Calculation_Date) THEN

( Calculation_Date = Early_End_Date

/* ------------------------------------------------------------------------

Get last whole period prior to Calculation Date and ensure that it is within

the Year (if Calculation Date is the End of a Period then use that period)

------------------------------------------------------------------------ */

E = GET_PERIOD_DATES( Accrual_Term_Start_Date,

Period_Length,

Period_Units,

Calculation_Date)

Calculation_Period_SD = get_date('PERIOD_START_DATE')
Calculation_Period_ED = get_date('PERIOD_END_DATE')

IF (Calculation_Date <> Calculation_Period_ED) THEN

E = GET_PERIOD_DATES( Accrual_Term_Start_Date,

Period_Length,

Period_Units,

ADD_DAYS(Calculation_Period_SD,-1))

Calculation_Period_SD = get_date('PERIOD_START_DATE')

Calculation_Period_ED = get_date('PERIOD_END_DATE')

IF (Calculation_Period_ED < First_Period_ED) THEN

( Total_Accrued_Amt = 0

/*RAISE WARNING RETURN */

/* ------------------------------------------------------------------------

Set the Continuous Service Global Variable, whilst also

ensuring that the continuous service date is before the Calculation Period

------------------------------------------------------------------------ */

IF (ACP_CONTINUOUS_SERVICE_DATE WAS DEFAULTED) THEN

(
Continuous_Service_Date = ACP_HIRE_DATE

ELSE IF(ACP_CONTINUOUS_SERVICE_DATE > Calculation_Period_SD) THEN

Total_Accrued_Amt = 0

Continuous_Service_Date = ACP_CONTINUOUS_SERVICE_DATE

ELSE

Continuous_Service_Date = ACP_CONTINUOUS_SERVICE_DATE

First_Eligible_To_Accrue_Date = Continuous_Service_Date

/*------------------------------------------------------------------------

Determine the date on which accrued PTo may first be registered,

i.e the date on which the Ineligibility Period expires

------------------------------------------------------------------------ */

Accrual_Ineligibility_Expired_Date = First_Eligible_To_Accrue_Date

IF (ACP_INELIGIBILITY_PERIOD_LENGTH > 0) THEN

( Accrual_Ineligibility_Expired_Date = get_end_date(Continuous_Service_Date ,
ACP_INELIGIBILITY_PERIOD_LENGTH,

ACP_INELIGIBILITY_PERIOD_UOM)

IF ( (Accrual_Ineligibility_Expired_Date > First_Eligible_To_Accrue_Date) AND


(Calculation_Date < Accrual_Ineligibility_Expired_Date) ) THEN

( First_Eligible_To_Accrue_Date =
Accrual_Ineligibility_Expired_Date )

IF ( First_Eligible_To_Accrue_Date > Accrual_Term_Start_Date ) THEN

E = GET_PERIOD_DATES( Accrual_Term_Start_Date,

Period_Length,

Period_Units,

First_Eligible_To_Accrue_Date)

First_Eligible_To_Accrue_Period_SD = get_date('PERIOD_START_DATE')

First_Eligible_To_Accrue_Period_ED = get_date('PERIOD_END_DATE')

IF ( First_Eligible_To_Accrue_Date <> First_Eligible_To_Accrue_Period_SD ) THEN


(

E = GET_PERIOD_DATES(Accrual_Term_Start_Date,

Period_Length,

Period_Units,

add_days(First_Eligible_To_Accrue_Period_ED,1))

First_Eligible_To_Accrue_Period_SD = get_date('PERIOD_START_DATE')

First_Eligible_To_Accrue_Period_ED = get_date('PERIOD_END_DATE')

IF (First_Eligible_To_Accrue_Period_SD > Calculation_Period_ED) THEN

Total_Accrued_Amt = 0

/*E = PUT_MESSAGE('HR_52793_PTO_FML_ASG_INELIG') RETURN */

ELSE

First_Eligible_To_Accrue_Period_SD = First_Period_SD

First_Eligible_To_Accrue_Period_ED = First_Period_ED

/* ------------------------------------------------------------------------

Determine the date on which actually starts accruing based on Hire Date,

Continuous Service Date and plan Enrollment Start Date.

Remember, we have already determined whether to user hire date or CSD earlier
in the formula. If this date is after the 1st period and the fisrt eligible

date then establish the first full period after this date (if the

Actual Start Date falls on the beginning of a period then use this period)

------------------------------------------------------------------------ */

IF Continuous_Service_date = ACP_CONTINUOUS_SERVICE_DATE THEN

Actual_Accrual_Start_Date = Continuous_service_Date

ELSE

Actual_Accrual_Start_Date = greatest(Continuous_Service_Date,

Enroll_Start_Date,

First_Period_SD)

/* -------------------------------------------------------------------------

Determine the actual start of the accrual calculation

-------------------------------------------------------------------------*/

IF (Actual_Accrual_Start_Date > First_Period_SD AND

Actual_Accrual_Start_Date > First_Eligible_To_Accrue_Period_SD) THEN

E = GET_PERIOD_DATES(Accrual_Term_Start_Date,

Period_Length,

Period_Units,

Actual_Accrual_Start_Date)
Accrual_Start_Period_SD = get_date('PERIOD_START_DATE')

Accrual_Start_Period_ED = get_date('PERIOD_END_DATE')

IF Actual_Accrual_Start_Date > Accrual_Start_Period_SD THEN

E = GET_PERIOD_DATES(Accrual_Term_Start_Date,

Period_Length,

Period_Units,

add_days(Accrual_Start_Period_ED,1)

Accrual_Start_Period_SD = get_date('PERIOD_START_DATE')

Accrual_Start_Period_ED = get_date('PERIOD_END_DATE')

/* -----------------------------------------------------------------

If the Actual Acrual Period is after the Calculation Period then

end the processing.

----------------------------------------------------------------- */

IF (Accrual_Start_Period_SD > Calculation_Period_ED) THEN

Total_Accrued_Amt = 0

/*E = PUT_MESSAGE('HR_52797_PTO_FML_ACT_ACCRUAL') RETURN */

)
ELSE IF (First_Eligible_To_Accrue_Period_SD > First_Period_SD) THEN

Accrual_Start_Period_SD = First_Eligible_To_Accrue_Period_SD

Accrual_Start_Period_ED = First_Eligible_To_Accrue_Period_ED

ELSE

Accrual_Start_Period_SD = First_Period_SD

Accrual_Start_Period_ED = First_Period_ED

/* -------------------------------------------------------------------

Now set up information that will be used in when looping through the periods

--------------------------------------------------------------------- */

Accrual_Period_Length_In_Days = DAYS_BETWEEN
(Accrual_Start_Period_ED,Accrual_Start_Period_SD)

Accrual_Term_Length_In_Days = DAYS_BETWEEN (Accrual_Term_End_Date,


Accrual_Term_Start_Date)

No_Of_Periods = TRUNC(Accrual_Term_Length_In_Days /
Accrual_Period_Length_In_Days)

/*------------------------------------------------------

Getting the bands info

------------------------------------------------------ */

/* Band Change - 3 years */


Years_service = floor(months_between(Calculation_Date,
Continuous_Service_Date) / 12)

IF (GET_ACCRUAL_BAND('NN',years_service) = 0) THEN

Accrual_Band_Id = GET_NUMBER('ACCRUAL_BAND_ID')

Max_Carryover = GET_NUMBER('MAX_CARRY_OVER')

Term_Accrual_Rate = GET_NUMBER('TERM_ACCRUAL_RATE')

Ceiling_Amt = GET_NUMBER('CEILING')

ELSE

Accrual_Band_Id = 0

Max_Carryover = 45

Term_Accrual_Rate = 24

Ceiling_Amt = 60

If (Years_Service = 3) THEN

Current_year_hire =
add_months(ACP_HIRE_DATE,trunc(months_between(Calculation_Date,ACP_HIRE_DATE) / 12)
* 12)

Before_Hire = (floor(Months_between(Current_year_hire, Accrual_Term_start_date))


+ 1) * (10/12)

After_Hire = (Floor(Months_between(Accrual_Term_End_Date, Current_year_hire))) *


(15/12)

Term_Accrual_Rate = Before_Hire + After_Hire

If (HR_VAC > 10 ) THEN


(

Term_Accrual_Rate = HR_VAC

If (HR_VAC > 25) THEN

Term_Accrual_Rate = 25

Accrual_Rate = ROUND(Term_Accrual_Rate / No_Of_Periods,2)

Accrual_Rate_Per_DAY=ROUND(Term_Accrual_Rate / 365,2)

Total_Accrued_Amt=Term_Accrual_Rate

Period_Accrued_Amt=Term_Accrual_Rate

Period_SD = Accrual_Start_Period_SD

Period_ED = Accrual_Start_Period_ED

Last_Accrual_Date = Period_SD

IF ( Log_Balance_Details = 'Y' ) THEN

Accrual_Element_Type_Id = ACP_ACCRUAL_ELEMENT_TYPE_ID

Accrual_Element_Input_Id = ACP_ACCRUAL_INPUT_VALUE_ID

Absence_Type_Id = 0

Absence_Attendance_Id = 0

E=
SET_ACCRUAL_BALANCE('ACR',Accrual_Element_Type_Id,Accrual_Element_Input_Id,Accrual_
Band_Id,Absence_Type_Id,Absence_Attendance_Id,Period_SD,Period_ED,Period_Accrued_Am
t)

IF Accrual_Start_Period_SD <= Calculation_Period_SD THEN

( Last_Accrual_Date = Calculation_Period_ED )

Accrual_Start_date = Accrual_Start_Period_SD

Accrual_End_date = Calculation_Date

Absence = GET_ABSENCE(Accrual_Term_Start_Date, Period_ED)

IF Accrual_Start_date >= Accrual_End_date THEN

( Accrual_Start_date = Accrual_End_date )

X = to_char(Calculation_Date,'YYYY')

Y = to_char(ACP_HIRE_DATE,'YYYY')

Accrual_Term_End_value='31/12'

Accrual_End_dt=TO_DATE(Accrual_Term_End_value||'/'||
to_char(Calculation_Date,'YYYY'),'DD/MM/YYYY')

IF ( X = Y ) THEN

Total_Accrued_Amt=(MONTHS_BETWEEN(Accrual_End_dt,ACP_HIRE_DATE) + 1) * Accrual_Rate

Last_Accrual_Date = ACP_HIRE_DATE
V1 = ACP_HIRE_DATE

V2 =ACP_HIRE_DATE

V1 = GET_END_DATE(ACP_HIRE_DATE , 1, 'CM')

V2 = add_months(ACP_HIRE_DATE , 1)

IF ( Calculation_Date <= V2) THEN

Total_Accrued_Amt = 0

ELSE

Total_Accrued_Amt = Total_Accrued_Amt

/* Other LOCATION */

Accrued_Amt = Total_Accrued_Amt

Entitled_Amt = Total_Accrued_Amt
E= GET_ASSIGNMENT_SALARY()

accrual_units = ACP_UNITS

Currency_Code = get_text('ASG_SALARY_CURRENCY_CODE')

IF ( accrual_units = 'H') THEN

Pay_Rate_Per_Unit = get_number('ASG_SALARY_HOUR_PAY')

ELSE

Pay_Rate_Per_Unit = get_number('ASG_SALARY_DAY_PAY')

RETURN Enroll_Start_Date,
Enroll_End_Date,
Continuous_Service_date,
Accrual_Start_date,
Accrual_End_date,
Last_Accrual_Date,
Accrual_Rate,
Ceiling_Amt,
Max_Carryover,
Accrued_Amt,
Entitled_Amt,
Pay_Rate_Per_Unit,
Currency_Code