Templates can be created to fill in estimates and invoices in a quick and easy way.
Template scripting is based on the Lua language. For more information you can go to www.lua.org
Data Structure
Result
Items
Units
Utility Functions
project
project.id
project.name
project.status
client
client.id
client.name
result.add(item)
- item
- name
- quantity
- decimals
- price
- description
- unitquantity
- unitcategory
- unit
unitcategory: length, area, volume, weight, time
Quantity is the item's quantity to use when there is no units. Use UnitQuantity when you provided units. Quanity can be used as a fallback if the item doesn't have any units set.
Example:
result.add({ name = "My Item", quantity = 12, price = 2.99 });
for i=1, #form.item.values do result.add({ name = form.item.values[i], decimals = 1, unitquantity = area, unitcategory = 'area', unit = 'ft2' }); end
result.addaction(action)
- entry
- action
- executeon
- options
Possible action:
- 1 = Create Timesheet Entry
- start = date/time
- duration = duration in seconds
- comment = string
options:
Possible executeon:
- 12 = Status changed to Done
Example:
result.addaction({ action = 1, executeon = 12, });
items.get(selector)
- selector
- name
- price
- unitcategory
- unit
- unitquantity
- defaultunitcategory
- defaultunit
unit.fromto(value, from, to, category)
- value
- from
- to
- category
Possible categories:
- length
- area
- volume
- length
- weight
- time
Example:
local test = unit.fromto(1, 'm', 'ft', 'length');
unit.tostring(details)
- details
- value
- from
- to
- category
- decimals (optional)
Example:
unit.tostring({ value = 42, from = "ft", to = "m", category = "length", decimals = 2, });
Info Bubble
We use Remarkable as a text formatter. See here for more information: https://jonschlinkert.github.io/remarkable/demo/
Example:
form.info.text = 'Bubble!';
Basic script functions
math.ceil(value)
- value
Example:
local test = math.ceil(1.1); # test = 2
math.floor(value)
- value
Example:
local test = math.floor(1.9); # test = 1
math.sqrt(value)
- value
Square root of value.
Example:
local test = math.sqrt(6); # test = 36
os.time(os.date("*t"))
Returned valueThe current date and time.