In March of this year, I left Billings for the more cloud-friendly Harvest time tracking and invoicing service. It was an excellent choice, and the only complaint I’ve had is that recently I’ll have to log in every day to duplicate the previous day’s Timesheet, making my usual billable buckets available and ready to go.
Since this is an annoying and painfully redundant task, I decided to cut it down to a script I can run with Alfred. For this, I’m using some simple PHP to execute commands via the Harvest API. I simply choose my new "Harvest - Duplicate Timesheet" command, a few seconds pass, and then the browser opens to my current Timesheet to confirm that all went well.
What This Does
- Searches a day at a time into the past (from today) to find the last-used Timesheet. I’ve limited the search to 10 days so we don’t get an infinite loop – you may need to adjust if you rarely work or take long vacations.
- Duplicates each item from the last sheet onto today’s, with 0 hours.
- Toggles the last timer. By default, the last timer will start out running. By toggling it, our new Timesheet will be ready to go with no items running.
What This Doesn’t Do
Anything else. I made it for myself, and you’re free to improve it – it won’t be friendly warning you about invalid credentials or telling you that it can’t find a last-used Timesheet within the search period.
On the plus side, it would also have a hard time screwing anything up. It doesn’t modify existing data, it doesn’t delete anything, and it doesn’t change any timers. It’s pretty simple.
I guess I have to remind you that I offer no warranty, and should you ruin everything and blow up the planet while playing with my humble PHP, it’s not my fault.
Making It Go (Three Steps)
1. Grab the Script
Clone or save this PHP, add your account credentials, and put it somewhere that it can be called upon. (I have a Google Drive folder of scripts, for example, which I can conveniently run with the same path on any machine.)
2. Create an Alfred Trigger
You could do this with cron so it’d be totally automated, but for some reason I still prefer Alfred.
- Open Alfred’s Extensions preference pane.
- Click the little "+" (bottom left) to create a new Shell Script.
- Add some basic information, a title, description, and choose a keyword that you like. I run this silently, but this is your choice of course.
- In the Command box, add…
Change the path and account shortname to reflect your own details.php ~/path/to/your/harvest-duplicate-timesheet.php open https://shortname.harvestapp.com/time
- Save.
3. Run it!
Use your new trigger, and if all goes well you’ll just wait a few seconds and your freshly-copied Timesheet will be staring right back at you from the browser.