Item Templates Overview
Item Templates define the format of invoice line items generated from fees, expenses, and time logs.
Name
The Item Template is displayed in the Add form by the name.
Grouping
The following are options for how generated line items will be grouped.
- No Grouping: Each time log, expense, or fee will be added as a separate line item.
- Employee: Time logs or expenses will be grouped by employee.
- Project: Time logs, expenses, or fees will be grouped by project.
- Task: Time logs, expenses, or fees will be grouped by task.
- Group: Time logs or expenses will be grouped by group (role, office, department, or other group that includes employees).
Template
This defines the description format of the generated line items (see the syntax).
Syntax
The syntax formats an invoice item template string for an object with variables.
Variables
The available variables are as follows.
date
project
projectcode
task
invoiceclient
invoiceproject
invoiceprojectcode
comment
(timelogs)description
(expenses, fees)employee
(timelogs, expenses)from
(timelogs, expenses)to
(timelogs, expenses)- groups (timelogs, expenses):
client
company
department
role
office
groupvi
groupvii
groupviii
groupix
groupx
groupxi
groupxii
Template Expression
The template is a combination of plain text and code. The code is separated using braces ({
, }
). The code itself is an expression. See the details below.
Example: Plain text and a little bit of {code}
.
Code Expression
The code can use:
- Variables, see above.
- Literals: strings separated by quotes (
"
) - "If" expressions.
- "Or" expressions.
- "Plus" expressions.
"If" expression
Syntax: if(condition, result, fallback)
.
All three arguments (condition, result, fallback) are expressions. The default value of the result
is the condition
itself. The default value of the fallback
is an empty string.
If the condition
is true, then it uses the result
; otherwise, it uses the fallback
.
"Or" expression
Syntax: expression or fallback
.
Both arguments are expressions. It basically uses the expression
if the latter is true or uses the fallback
otherwise.
Can be expressed using a special if
expression:
expression or fallback = if(expression, expression, fallback)
The "or" expression is used when an "if" expression is not intuitive.
"Plus" expression
Syntax: expr + expr + … + expr
.
All arguments are expressions. As every expression in this DSL is a string, the "plus" expression basically concatenates all the arguments.
Template Examples
- Just a single variable:
{project}
- Plain text with variables:
{employee} timelogs {from} – {to}
- Variable falls back to a literal:
{date} {comment or "Time"}
- Variable falls back to a variable:
Fee {description or project}
- Optional value with parentheses:
{if(task, task + " ") + if(project, "(" + project + ")")}