Home      Ask a Question      My Stuff      Help   
  
TimeWorks/TimeWorks Plus - Scripting for Mileage and Calculations Based on Mileage Entered
Question
ID
222
Category
<Unassigned>
Date Created
3/17/2008 2:39:51 PM
Date Updated
8/10/2015 4:07:42 PM
Is there a way to script mileage and have it calculate a payrate on the mileage entered?
Answer
Yes. You would first have to setup two clock prompts out of the collection prompts. So two out of I,J, or K prompts. These are usually used to calculate tips but we will use these prompts to create two more columns on the employee timecard.

The first prompt (we will use I as an example) will be what you would use to collect the mileage and should be set up as below:

Data Collection Mode: Collect on Clock OUT

What do you want to name this field?: Mileage (This can be anything the client desires)

How do you want the prompt to appear on the clock's screen?: MILEAGE (This can be anything the client desires but it has to be in CAPS and no longer then 16 characters)

Collect data for employees with which type of cards?: Depends on the client and which card they are using.

Should the data be visible or editable on the online edit screen?: Visible and editable

What type of numbers should we collect?: Depends on the client and how they are calculating the mileage with or without decimals.

What should we do with the data?: Add them up and show totals on the reports.

The second prompt (we will use J as an example) needs the "Data Collection Mode:" set to "Show online, but do not collect anything" and we need to change the "What do you want to name this field?" this needs to be there to have the mileage calculate to a second column on the timesheet. We will name it "Mileage Reimb.".

Now we write a script. We will script it so that each mile entered will equal $.50:

if (i >= 1)
{
j = i * 0.50
}

This means that if the I prompt (Mileage) is greater or equal to 1 (mile) then the J prompt (Mileage Reimb.)should equal I times $.50.

What will next happen is that it will display on the employee timecard two category columns one named "Mileage" which will be the mileage the employee enters at the prompt and one named "Mileage Reimb." which will show our calculation off of the script or mileage times $.50.

Attached is a screenshot of what it should look like when completed:





Back to Search Results