|
|
Applies to versions: 2.5, 3.0, 3.1, 3.2
Advanced Modifications and Accruals using Expressions
Accruals and Modifications can be configured to calculate with an expression for special rules not covered by the built-in settings and options.
Accruals
The accrual expression should return the amount of the accrual in hours.
The following variables are available to the expression when calculating the accrual amount:
- usersID - The ID of the user benefit accruals are being calculated for
- benefitTypeID - The ID of the benefit type being calculated
- begTimestamp - The timestamp of the beginning of the accrual range
- endTimestamp - The timestamp of the end of the accrual range
- workedhours - The number of hours worked between the start and end of the accrual. Includes benefits/holidays that count toward accruals
- accrualStartDate - The timestamp of the most recent (prior to the end of the accrual range) benefit start date set under the employee's pay history.
- accrualAnniversary - The timestamp of the anniversary of the most recent (prior to the end of the accrual range) benefit start date set under the employee's pay history.
- intervalCode - The interval type, i.e. one of the following: week, month, year, semimonth, quarter, never, day
- intervalCount - The number of interval. Usually 1, but for accruals that happen periodically, the number of the period. i.e. For accruals every two weeks: 2. For accruals every 10 days: 10. For accruals every 4 months: 4, etc.
Example 1:
An accrual policy grants 50 hours a year on Jan 1st each year. And, for employees who where hired between Jan and June, an additional 8 hours is granted on Jul 1st.
- This is a special rule because the amount accrued on Jul 1st is different than on Jan 1st and depends on the hire date of the employee.
- To accommodate this, accruals would be set to run twice a year
- The accrual amount would be set to Expression
- The expression would be
=if(utcdate("m",[begTimestamp])=1,50, /* this gives 50 hours if it is the Jan accrual */ if(substr(employeeInfo([usersID], 'payrollSyncStartDate'),6,2)<7,8,0)) /* this looks at the month of the start date and, if it's less than 7 (Jan->Jun) then give 8 hours, otherwise none */
Example 2:
An accrual policy grants employees .025 hour of vacation per hour worked (i.e. 1 hour for 40 hours), but the total amount for the calendar year, starting Jan 1st, is limited to 32 hours earned (no limit on how much is available).
- This is a special rule because the amount accrued has an earnings limit for the year.
- To accommodate this, accruals could be set to run every day, week, month, etc.
- The accrual amount would be set to Expression:
- ==hourlimit=32
==bentype='vacation' ==rate=.025 ==earned=[workedhours]*[rate] ==startofyear=strtoutctime(utcdate("Y",[endTimestamp])."-01-01 12:00:00 AM") ==maxearned=[hourlimit]-(getBenefitAccrued([usersID], [startofyear], [endTimestamp], [bentype])/3600) =if([earned]>[maxearned],[maxearned],[earned])
Example 2A:
An accrual policy grants employees .05 hour of sick per hour worked (i.e. 2 hours for 40 hours), but the total amount for a year, starting July 1st at 8am, is limited to 56 hours earned (no limit on how much is available).
- This is a special rule because the amount accrued has an earnings limit for the year.
- To accommodate this, accruals could be set to run every day, week, month, etc.
- The accrual amount would be set to Expression:
- ==hourlimit=56
==bentype='sick' ==rate=.05 ==earned=[workedhours]*[rate] ==benefityear="07-01 8:00:00 AM" ==startofyear=strtoutctime(utcdate("Y",[endTimestamp])."-".[benefityear]) ==startofyear=strtoutctime(utcdate("Y",[endTimestamp]-if([startofyear]>[endTimestamp],365*86400,0))."-".[benefityear]) ==maxearned=[hourlimit]-(getBenefitAccrued([usersID], [startofyear], [endTimestamp], [bentype])/3600) =if([earned]>[maxearned],[maxearned],[earned])
Example 3:
An accrual policy grants employees 16 hours of vacation per month worked, but limited to 80 hours per year every year from their hire date anniversary.
- This is a special rule because the amount accrued has an earnings limit for the year, and the year is different for each employee.
- To accommodate this, accruals could be set to run every month with an expression:
- ==hourlimit=80
==rate=16 ==alreadyAccruedThisYear=(getBenefitAccrued([usersID], [accrualAnniversary], [endTimestamp], 'vacation')/3600) =if([workedhours]>0 && [alreadyAccruedThisYear]<[hourlimit],[rate],0)
Example 4:
An accrual policy grants employees 30 hours of vacation per year until 2024, then changes to 40 hours of vacation per year.
- This is a special rule because the amount accrued changes after a certain year
- To accommodate this, accruals could be set to run every year with an expression:
- =if(utcdate("Y",[begTimestamp])<2024,30,40)
Modifications
The following variables are available to the expression when calculating the modification amount:
- usersID - The ID of the user benefit accruals are being calculated for
- benefitTypeID - The ID of the benefit type being calculated
- begTimestamp - The timestamp of the beginning of the accrual range
- endTimestamp - The timestamp of the end of the accrual range
- workedhours - The number of hours worked between the start and end of the accrual. Includes benefits/holidays that count toward accruals
|