Make Gnucash iCal from invoices

Something handy, make an iCal calendar file from your Gnucash datafile, I use this to create a calendar of invoiced day's so i can see if i missed any days for invoicing.

Gnucash datafile is a compressed XML file with a fairly straightforward schema, here we use xml2 command line xml swiss army knife to turn the XML into something we can grep, then use some simple formatting to output to the iCalendar output.

Accepts the gnucash datafile as argument 1, and the output as argument 2.

Warning: dont mix this up or it will wipe out your gnucash file :D

#!/bin/bash

> $2
echo "BEGIN:VCALENDAR" >>  $2
echo "VERSION:2.0" >>  $2


cat $1|gunzip -|xml2|grep "/gnc-v2/gnc:book/gnc:GncEntry/entry:date"|awk -F= '{print $2}'|awk '{print $1}'|sed 's/\-//g'|while read item
do
    echo "BEGIN:VEVENT" >>  $2
    echo "DTSTART;VALUE=DATE:$item" >>  $2
    echo "SUMMARY:InvoiceItem" >>  $2
    echo "UID:6E517E49-5699-11D8-8C8D-000A957CBED4" >>  $2
    echo "DURATION:P1H" >>  $2
    echo "END:VEVENT" >>  $2


done

echo "END:VCALENDAR" >>  $2
AttachmentSize
make-ical-of-invoice-items483 bytes
0
Your rating: None