This article is to help with some logic that shows up in PTO policies often.
- How to script for years of service based on calendar year instead of anniversary:
$years = reportingdate.year - year(employee.startdate);
- This script accrues up 8 for employees who have started their 5th calendar year or greater:
if($years >= 5){ accrueup("PTO", 8); }
- How to prorate according to days until the next year:
$nextjan = dateserial(reportingdate.year + 1, 1, 1); $daysuntil = $nextjan - employee.startdate; $multiplier = $daysuntil / 365;
- This script accrues up on the employee's start date for the amount of 40 prorated for the rest of the year:
if(reportingdate.date = employee.startdate){ accrueup("Sick", 40 * $multiplier); }
- How to prorate on a weekly basis:
$multiplier = reportingdate.weekhours / 40; if($multiplier > 1) { $multiplier = 1; }
- This script accrues up according to the prorated amount per week:
if(reportingdate.date = reportingdate.workweekend){ accrueup("PTO", 1.538 * $multiplier); }
- How to prorate on a biweekly basis:
$multiplier = reportingdate.pphours / 80; if($multiplier > 1) { $multiplier = 1; }
- This script accrues up according to the prorated amount per pay period:
if(reportingdate.date = reportingdate.payperiodend){ accrueup("PTO", 1.538 * $multiplier); }
- This script carries over the next year with an expiration date of 4/30 for the carryover ONLY. This needs to go in the bottom box, before the rest of the scripting and it requires a second accrual category called PTO Carryover.
//accrueupscript Bottom box if(reportingdate.day = 1 and reportingdate.month = 1){ $carryover = 40; if(getbalance("PTO") < 40){$carryover = getbalance("PTO");} accruedown("PTO", getbalance("PTO"), 0); accrueup("PTO Carryover", $carryover, "", "", dateserial(reportingdate.year, 4, 30)); }
//This allows hours to count properly when they use hours on the last day of the year with a carryover //accrueup top if(reportingdate.date = dateserial(reportingdate.year,12,31)){ if(category = "PTO" and hours > 0){ $shortfall = accruedown(category,hours,0); unpay($shortfall); } }
//accruedown if(reportingdate.date <> dateserial(reportingdate.year,12,31)){ if(category = "PTO" and hours > 0){ $shortfall = accruedown(category,hours,0); unpay($shortfall); } }
- Set the expiration date on the day before their anniversary $expdate = dateserial(reportingdate.year, month(employee.startdate), day(employee.startdate)) - 1; if(reportingdate.date > $expdate){ $expdate = dateserial(reportingdate.year + 1, month(employee.startdate), day(employee.startdate)) - 1; } accrueup("Personal", 3.333, 80, "", $expdate);
- Set the expiration date on the day before a date that expires mid year $expdate = dateserial(reportingdate.year, 6, 30); if(reportingdate.date > $expdate){ $expdate = dateserial(reportingdate.year + 1, 6, 30); } accrueup("PTO", 3.08, 80, "", $expdate);
// The following would be used to accrue on the anniversary date and 6 months from the anniversary date
$ann = dateadd("y", cint(employee.yearsofservice), employee.startdate); $sixmonth = dateadd("mm", ((cint(employee.yearsofservice) * 12) + 6), employee.startdate);
if(reportingdate.date >= "2014-01-01" and (reportingdate.date = $ann or reportingdate.date = $sixmonth)){ if(employee.monthsofservice >= 0){ accrueup("Vacation", (40 / 2), 40, (employee.startdate) + 90); } }
// Accrue ONLY on first 6 month anniversary $6monthanniv = dateadd("mm",6,employee.startdate);
// expiration of accrual on the last day of the pay period containing 12/31
$eoy = dateserial(reportingdate.year,12,31) - reportingdate.date; $eop = reportingdate.payperiodend - reportingdate.date; $eopaeoy=( (14- (($eoy - $eop)%14)) + $eoy );
if(reportingdate.date = reportingdate.payperiodend){ accrueup("PTO", 8,"","",dateadd("d", $eopaeoy, reportingdate.date)) }
//Accrue Monthly - Day of the employee startdate if(reportingdate.day = day(employee.startdate) or (reportingdate.islastdayofmonth and reportingdate.day < day(employee.startdate)) ){
HD - Updated on 9/9/18 to include variable for only 1st 6 month anniversary JG - updated 12/5/2018 - added carry over that allowed to properly count hours on the day of carry over (12/31) | |