Previous | Next | Contents | Index | Navigation | Glossary | Library |
As a simple example, suppose you pay some salaried employees using a recurring element called Salary. The Salary element has an input value called annual_salary. You need a formula that divides the input value into twelve parts:
INPUTS ARE annual_salary
Salary = annual_salary/12
RETURN Salary
Attention: When you use an Inputs statement, you need to make sure that none of the input values can have a value of null because this causes the formula to fail. You can avoid this problem by using the Default statement.
Using an Inputs statement is the most efficient way to access the input values of the element with which the formula is associated. However, if the formula uses the input values of other elements, it must access the database items for them.
For example, if you want to use the input value annual_salary in the formula to calculate the element Bonus, you use the database item as follows:
IF Salary_annual_salary > 20000
THEN
Bonus = bonus_rate * (sales_achieved - sales_threshold)
Notice that the database item name is in two parts: the input value (annual_salary) name prefixed by the element name (Salary). This is the naming convention for the database items of element input values.
As a simple example, suppose you use the element Wages to pay some weekly-paid employees. The Wages element has the input value hours_worked. Each week, you regularly make five entries for the input value hours_worked.
To calculate Wages, you can multiply the hours worked each day by the employee's standard rate from the grade rates table, so that your formula looks like this:
INPUTS ARE hours_worked
Wages = hours_worked * standard_rate
RETURN Wages
During the payroll run, the formula fires five times, creating five separate pay values, one for each entry.
Now consider using the database item Wages_hours_worked instead of an Inputs statement. The database item for an entry value sums up all the entries made in the payroll period.
This is a great convenience when referring to input value totals for a payroll period. However, you must be sure that it is the totals that you want to use. In this example, using the database item produces the wrong result.
Wages_hours_worked gives a single value that is the sum of the five entries in each weekly payroll period. When the payroll runs, the formula fires five times, each time calculating wages using the total hours worked in the week.
Attention: If multiple entries are enabled for an element, be careful when using database items for the element's entry values. These database items hold the sum of all the entries. This includes entries made as indirect formula results during the payroll run.
Previous | Next | Contents | Index | Navigation | Glossary | Library |