Preparation
As the admin
There are some steps that need to be done as the tmetric admin and the OpenProject admin.
tmetric
- get the client ID by selecting the client, whose data you want to sync with OpenProject, from Manage->Clients and copying the last number from the URL. For example, if the URL is
https://app.tmetric.com/#/account/12345/clients/67890
, the client ID is 67890
.
- create a dummy project. You can give it any name you like. No time will be logged to this project, but it's needed to create links to OpenProject.
- get the ID of the dummy project. For example, if the URL is
https://app.tmetric.com/#/account/12345/projects/989898
the project ID is 989898
.
- create work types. The names of the Work Types must match the names of the time tracking activities in OpenProject.
- assign the work types to the project which data you want to sync to OpenProject.
- create a tag called
transferred-to-openproject
. This tag will be used to mark time entries that have been transferred to OpenProject.
OpenProject
- enable the 'Time and costs' module for the projects you want to sync with tmetric
As the user
get tokens
OpenProject
- go to your profile (by clicking on your avatar in the top right corner)
- click on
My account
- click on
Access tokens
- click on
+ API token
- give the token a name and click on
Create
- copy the token
t-metric
- go to your profile (by clicking on your avatar in the top right corner)
- click on
Profile Settings
- click on
Get new API token
- copy the token
in your home folder create a file called .OpenProjectTmetricIntegration.yaml
with the following content (enter your tokens):
openproject:
url: 'https://community.openproject.org'
token: <openproject token>
tmetric:
token: <t-metric token>
clientId: <id of the client in tmetric>
dummyProjectId: <id of the dummy project the admin created>
run
check and fix the time entries in tmetric
go run main.go check tmetric
The tool with show you any invalid or inconsistent time entries and ask you for data to fix them.
This step will only adjust data on tmetric, no data will be written to OpenProject.
transfer the time entries to OpenProject
go run main.go copy
This will copy the time entries from tmetric to OpenProject. The time entries will be marked with the tag transferred-to-openproject
in tmetric. Any entry that already has this tag will be skipped.
validate if the data in tmetric and OpenProject is consistent
go run main.go diff
This will show you a table with the time entries in both systems and if there is any difference in the logged time per day. Check if the data is correct.
- If some data is in tmetric but not in OpenProject, run the
copy
command again.
- If some data is in OpenProject but not in tmetric, delete or edit it in OpenProject. To do so use the cost-report feature.
- If you want to sync data again from tmetric to OpenProject, remove the
transferred-to-openproject
tag from the time entries in tmetric. This will create new entries in OpenProject and by that might lead to duplication.
export data
Data can be exported using the Go template system. This is useful e.g. to generate an invoice.
First create a template file and then run:
go run main.go export --template template.tmpl
- DetailedReport with parameters:
clientName string, tagName string, groupName string
. Gets a detailed report from t-metric and returns a tmetric.Report
object.
- AllWorkTypes. Gets all possible work types from t-metric and returns an array of
tmetric.Tag
- AllTeams. Gets all teams from t-metric and returns an array of
tmetric.Team
- ServiceDate. Returns the month of the
--start
date for the export in the format 01/2006
- AllTimeEntriesFromOpenProject with parameter
user string
. Gets all time entries for that user from OpenProject and returns an array of openproject.TimeEntry
- ArbitraryString with parameter
i int
. Gets the data of the arbitraryString
command line flag. Useful e.g. to add an invoice number.
- formatFloat with parameters
f float64, decimalSeparator string (optional)
. Formats the float value to %.2f
with that given separator.
- all functions from spring
work for a specific time period
By default, the script will work with the current calendar month, but the start and end date can be configured with the --start
and --end
flags. The date format is YYYY-MM-DD
.