In this page

What is Tempo Timesheets?

(supported since Better PDF Exporter 3.4.0)

Tempo Timesheets is the most widely used time tracking solution for Jira.

Tempo Timesheets integration features

  • You can export PDF documents directly from the Timesheet (with all issues in the timesheet), Calendar (with all issues in the selected period), Report (with all issues in the report) and List views (with all unique issues in the list). (supported since Better PDF Exporter 4.0.0)
  • You can export the Tempo-managed custom field types, like Account, Team, Iteration, etc., to PDF.
  • You can export the Tempo-managed worklogs to PDF, along with their custom worklog attributes. You can filter the Tempo worklogs by start date, by end date and by custom worklog attributes. You can exclude the non-billable worklogs and implement other types of custom filtering.
  • Better PDF Exporter also offers a customizable timesheet/invoice template to generate custom timesheets and time-based invoices from Tempo worklogs.

Tutorial video

Create customized timesheets or invoices from the Tempo timesheets with one click!

Export samples

Timesheet

This is a simplistic timesheet, aggregating the worklogs of an issue list, in a professional document that you can share with your clients.

jira-timesheet.pdf

Time-based invoice

After specifying the hourly rate, it will include money information as well (amout due, net, gross). You may event want to add tax information, payment information (SWIFT code and IBAN). If you run time and material based projects, you can easily turn Jira into a powerful billing system with this template.

jira-invoice.pdf

Tempo invoice

Invoices can also be created from Tempo worklogs, making use of the additional domain data like Account or Team.

jira-tempo-invoice-example.pdf

Configuration

Exporting Tempo custom fields

There is nothing to do. Better PDF Exporter will automatically recognize the Tempo-managed fields and export them accordingly.

Configuring the Tempo Servlet API access

If you want to export Tempo worklogs, PDF templates download those from the Tempo Servlet API during the document rendering. Tempo servlet is basically Tempo's HTTP based API.

Execute these steps to allow the templates to connect to the Tempo servlet:

  1. Login to Jira as administrator.
  2. Go to AdministrationAdd-onsAccess Control (under Tempo).
  3. Enter "127.0.0.1" (localhost) or the Jira server's actual IP to "Allowed addresses", and "Save" the changes.
  4. Copy the "Security token" string to the clipboard.
  5. Go to AdministrationAdd-onsPDF Templates (under Better PDF Exporter).
  6. Open the issue-fo.vm template for editing, uncomment this variable in the top part, and paste the security token from the clipboard to the value:
    ## issue-fo.vm
    
    #set($tempoApiToken = '3022ac1e-db73-4c54-9c15-cceccbb94554')
    
  7. Paste the security token similarly to the timesheet-fo.vm template, as well.
  8. Export a Jira issue having Tempo worklogs with the "PDF" view as a test. You will see java.io.IOException: Server returned HTTP response code: 401 for URL error messages in the exports until the access permissions are properly set up.

Configuring the PDF templates for Tempo worklogs

After you set up the Tempo servlet access, you may want to configure the details of exporting the worklogs.

There is a configuration parameter in the top part of the issue-fo.vm template to filter the worklogs for the current user:

## issue-fo.vm

#set($tempoFilterByUser = false)       ## set to "true" to export the Tempo worklogs of the current user only, or "false" to export everyone's

There are multiple configuration parameters in timesheet-fo.vm to look up the customer from Tempo, to export the custom worklog attributes, and to filter the worklogs by their worklog attributes (e.g. to skip non-billable worklogs):

## timesheet-fo.vm

#set($tempoExportCustomer = true)              ## whether to look up the "Customer" from Tempo based on the account set in the first issue to be exported
#set($tempoExportWorklogAttributes = false)    ## whether to display the worklog attributes for each worklog item
#set($tempoExcludeWorklogsWithAttributesContaining = "NonBillable=NonBillable")    ## Tempo worklogs with attributes containing this string will be skipped, ex: "NonBillable=NonBillable" will exclude the worklog where the "NonBillable" checkbox attribute is checked

## mapping of Tempo customer keys to customer address lines (note: keys are case-sensitive)
#set($tempoCustomerAddresses = {
	"ACME":		[ "17 boulevard Saint-Marcel", "75013 Paris", "France" ],
	"MEGACORP":	[ "45 Stirling Highway", "Crawley WA 6009 Perth", "Australia" ],
	"XYZINC": 	[ "Schwanthaler Strasse 85a", "Munich 80336", "Germany" ]
})

Configuring the customer invoice addresses

When the timesheet-fo.vm template is rendered in "invoice" mode, it will automatically figure out the customer's invoice address based on the Tempo worklogs. This section explains how.

First, let's see the underlying Tempo concepts!

In Tempo, each worklog is linked to a Tempo account in one of these two ways:

  1. Either the worklog inherits the account from the Account custom field of its owning issue. (This is the default.)
  2. Or, the worklog has the account set by using an "Account" type work attribute.

Plus, each Tempo account is linked to a Tempo customer. Consequently, each worklog is indirectly linked to a Tempo customer. Note that both accounts and customers are identified by unique textual keys.

So, how is the customer address figured out by the timesheet-fo.vm template?

  1. It takes the first issue passed to it.
  2. It takes the first worklog of that issue.
  3. It takes the customer name from the worklog. (It means you can maintain your customers natively in Tempo.)
  4. It takes the customer key from the worklog, and using that key it looks up the customer address from the $tempoCustomerAddresses map. (It means you can maintain the list of the customer addresses in the template, see the code block above!).

Note that this logic is coded to the template itself. As always, it can be easily modified if necessary.

Of course, every invoice must be created for one specific customer. The simplistic logic above assumes that all the worklogs of all the issues passed to the template are created for the same customer. It means that:

  • It is safe to check only the first worklog to figure out the customer.
  • It is your responsibility to export only those issues that are created for the same customer to an invoice.

To troubleshoot the case when the customer or its address is not found by template, check these:

  1. Is the first issue's first worklog linked to a Tempo account?
  2. Is that Tempo account linked to a Tempo customer?
  3. Is there a $tempoCustomerAddresses entry with the key of that Tempo customer?

Configuring the period filter for Tempo worklogs

If there is a time period specified, then the tempo-tool.groovy script exports only the worklogs in that time period. The time period is specified by its start date and end date passed as request parameters.

The start date and the end date are available in Tempo contexts (like the Timesheet screen), but not available in others (like the Issue Navigator screen). This is simply because while the Tempo contexts offer a period selector, Issue Navigator doesn't.

For this latter case, the period is basically "all times". You can configure the default period by setting these values in the templates:

## issue-fo.vm or timesheet-fo.vm

#set($tempoDateFrom = '2000-01-01')    ## start date for the exportable Tempo worklog period
#set($tempoDateTo = '2099-12-31')      ## end date for the exportable Tempo worklog period

Or, you can disable the filter by ignoring the period passed and forcing "all times":

// tempo-tool.groovy

// remove this snippet to ignore passed period
if(tempoDateFromRequestParameter && tempoDateToRequestParameter) {
	tempoDateFrom = tempoDateFromRequestParameter
	tempoDateTo = tempoDateToRequestParameter
}

Configuring the user filter for Tempo worklogs

Since app version 6.2.0, the tempo-tool.groovy script can export the worklogs of only one specific user if the username is passed in a request parameter.

The username is available in Tempo contexts (like in the Timesheet screen), but not available in others. Again, this is simply because the user selector is available only in Tempo contexts.

You may want to disable this filtering also in Tempo contexts, in order to export the worklogs for all users. The most typical use case example is creating a monthly report that accumulates the work of every team member. To disable the filtering, set this configuration variable to true:

// tempo-tool.groovy

def exportWorklogsOfAllUsers = false

Configuring the pre-loading for Tempo worklogs

tempo-tool.groovy script supports two loading strategies: "pre-load worklogs for all issues" vs. "load worklogs for each issue separately".

In our profiling, the former works faster for larger number of issues, i.e. when we expect a larger number of worklogs to be returned. These requests can be served faster if all the worklogs in the period are downloaded with a single Tempo API call (instead of one Tempo API call per issue).

Beware! If you have a large number of issues and the period is "all times" (or very long), then pre-loading can generate heavy load on Tempo. Therefore, by default, pre-loading is used only if there are more than 10 issues to export and the period is not "all times" (but some specific start and end date)!

This is the expression in tempo-tool.groovy that captures the default decision logic, allowing to change the value of 10 issues:

preloadWorklogs = (issues.size() > 10) && !exportWorklogsOfAllTimes

If you are not worried about longer periods and want to make it depend only on the issue count, you can reduce the decision to this:

preloadWorklogs = (issues.size() > 10)

Or, you can enforce pre-loading (in every case) by deleting the right-side expression and setting the variable to true:

preloadWorklogs = true

Configuring the Tempo servlet request details

If you wanted to change the low-level details of invoking the Tempo servlet, you can do that by editing the tempo-tool.groovy script. The script itself is short and very easy to understand. You can change the servlet's URL by editing this line, for instance:

def url = "${baseUrl}/plugins/servlet/tempo-getWorklog/?dateFrom=${dateFrom}&dateTo=${dateTo}&format=xml&addBillingInfo=true&addUserDetails=true&tempoApiToken=${apiToken}"

Troubleshooting

Characters encoding problems

If you see broken international characters in the exported files (especially in the worklog description field), start Jira with the -Dfile.encoding=utf-8 parameter. If it doesn't help, see the Troubleshoot character display issues in Jira server page in the Jira manual.

Learn more about Tempo Timesheets