Home      KBase      Ask a Question      My Stuff      Help   
  
TimeWorks Plus: Scripting - Common Accrual Scripting Help
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.

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));
}

- 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);
}
}


// 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)) ){

ID
1047
Category
>Support
  Accruals
Date Created
12/10/2013 8:49:02 AM
Date Updated
7/28/2017 1:41:56 PM
Was this information helpful?
 
Back to Search Results