Templates can be created to fill in estimates and invoices.

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
  • options:
    • start = date/time
    • duration = duration in seconds
    • comment = string
Possible executeon:
  • 12 = Status changed to Done

Example:
        result.addaction({
          action = 1,
          executeon = 12,
        });
      

items.get(selector)

  • selector
Returned values
  • 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,
        });

result.setinfo(details)

We use Remarkable as a text formatter. See here for more information: https://jonschlinkert.github.io/remarkable/demo/

  • details
    • id
    • text

Example:
        result.setinfo({ id = 1, text = 'test' });
      

Basic script functions

math.ceil(value)

  • value
Returned value

Example:
        local test = math.ceil(1.1);
        # test = 2
      

math.floor(value)

  • value
Returned value

Example:
        local test = math.floor(1.9);
        # test = 1
      

math.sqrt(value)

  • value
Returned value

Square root of value.

Example:
        local test = math.sqrt(6);
        # test = 36
      

os.time(os.date("*t"))

Returned value

The current date and time.