iTunes Connect and FreeAgent redux

15 November 2010 iTunes Connect and FreeAgent redux

Back in July, I wrote a blog post explaining how I automate the process of getting my monthly iTunes Connect reports for my iPhone apps and converting them into FreeAgent invoices using a couple of shell scripts.

The scripts save me a lot of time but I still had to go through the process of running the processing script against each individual report (or reports). This was fine as some months I wouldn't generate an invoice for a particular region (as I wouldn't have sold enough units to receive any money from Apple).

However, not long after I wrote that post, Apple implemented a new payment system whereby all regions are paid in one single payment, meaning that all regions would be cleared each month.

This meant, since then, that each month I would routinely fetch all of the reports and run my processing script against each report downloaded (i.e. all of them). Yet another opportunity to automate presented itself.

The solution is a very simple Ruby script that loops through all of the reports and runs them through my processing script. It groups the US and WW reports into one invoice as they both share the same currency. It automatically works out the location of the reports because my report downloader uses a fixed directory name format - it just looks for last month's reports.

If you wanted, you could go one step further and combine the calls to the report downloader and this script into one - you could even run it on a fixed schedule (cronjob, launchd task) each month although I kind of like the monthly ritual; it's up to you.