Harvest Reports WordPress Plugin

When free­lanc­ing I use the Har­vest appli­ca­tion to man­age all of my time track­ing. It has made invoic­ing pain­less, and while I got it think­ing I was over-charging my clients, it turns out then I was not charg­ing them enough! Any­way, after being listed as a Word­Press con­sul­tant by Automat­tic I nat­u­rally had more Word­Press con­tracts. I then wanted to solve a busi­ness need by allow­ing my clients to view their impend­ing charges inside the famil­iar Word­Press admin­is­tra­tion interface.

Harvest Reports PluginThis was impos­si­ble until recently when Har­vest pub­lished their full API. I now have the abil­ity, through REST, to retrieve my data via XML, parse it, and put it where I choose. This lead me to cre­at­ing a Word­Press plu­gin to accom­plish this, and I was encour­aged by some­one at Har­vest to make it pub­lic domain. So I present to you the “Har­vest Reports Word­Press Plu­gin.” See the screen­shot on the right for what will be accom­plished with the plugin.

Remem­ber that this was made to solve a spe­cific busi­ness need, namely the dis­play of pend­ing costs incurred since the last invoice. This is not meant to be an exhaus­tive rep­re­sen­ta­tion of their API as it only uses a slice of it.

Require­ments

  1. Word­Press 2.3+
  2. A Har­vest Account
  3. PHP5

You might won­der why you need PHP5 as Word­Press only needs PHP4. I use the PHP5 Sim­pleXML func­tion­al­ity to parse the XML. This is far eas­ier then try­ing to do it in PHP4. Most hosts do offer PHP5, but you might have to add the fol­low­ing to your .htac­cess file to uti­lize that edition.

AddHan­dler application/x-httpd-php5 .php

Instal­la­tion

  1. Down­load the plugin
  2. In Word­Press 2.3 — 2.5 go to “Options” — “Har­vest Reports”, and in 2.5 go to “Set­tings” — “Har­vest Reports”.
  3. Enter your information
  4. Hit “Save”
  5. Go to “Man­age” — “Your Cho­sen Title” to see the report

To get your project ID go to your Har­vest dash­board — “Man­age”, and you’ll see your projects listed. When you open up one you’ll see a numer­i­cal value in the URL bar (e.g. yourname.harvestapp.com /projects/49691/). The value you want is 49691. Remem­ber this is only meant for one project, as that was the busi­ness need I needed it to solve. Also, if you want to limit the end date on the report I have included that, but leave it blank to retrieve data up to the second.

Caveat On Hourly Rates

Since this plu­gin is intended to ulti­mately pro­vide a mon­e­tary fig­ure I wanted it to get the default hourly rate from the API. Unfor­tu­nately, when I first parsed the XML I saw that despite the fact that my tasks use my default hourly rate noth­ing was in the XML returned. I pinged their sup­port and got the fol­low­ing rationale.

When you read the Task API, you basi­cally get back “No set­ting” at the sec­ond (task) level. We use the rates for report­ing (and invoic­ing com­ing soon), here the defaults get cas­caded. But for the API no cas­cad­ing takes place to make it evi­dent from where the value comes.”

What this means is that for every task that is used for the project you have to go in and man­u­ally set the hourly rate. Not ideal, and to me it’s not expected behav­ior (espe­cially since the report­ing tool inside the Har­vest inter­face auto­mat­i­cally uses that value), but once you set it you can for­get it.

Upcom­ing Features

Even though I’ve worked a lot on this and need a break I still have improve­ments in mind.

  • JavaScript date picker
  • Excep­tion han­dling from the API
  • Ajax retrieval of projects inside the options page (no need to insert a project ID manually)

I also need to dou­ble check that is han­dles tasks that aren’t bill­able by default cor­rectly. Since I only track tasks that are bill­able I didn’t test this, but maybe some­one can ver­ify for me.

Props

I want to say thanks to Danny Wen of Har­vest for encour­ag­ing me to do this, and Andrew Charl­ton of Geekly Weekly for point­ing me in the way of cURL and SimpleXML.

3 Comments

  1. Love the info you have pro­vided here. I am inter­ested in chang­ing your php script to allow the return of info I need in Har­vest but I have to admit I do not know where to start. Could you pos­si­bly direct me to where I can start to edit your code to allow this?

    Evan Buxton on 07.02.08
  2. @Evan: Well, I don’t know what data you want to edit so that it returns cor­rectly.  I no longer have an Har­vest account (I closed my busi­ness and no longer need it) so I can’t test it.  The sup­port guys at Har­vest are a lot of help and reply quickly support@getharvest.com.

    Chris Poteet on 07.02.08
  3. Thanks for your work on this!

    Danny … cheap and effective :).

    Matt on 07.03.09

Got Something to Say?

(Required)
(Required)