Here are a couple of simple bash scripts I wrote for my iphone to
automate ledger creation. Of course you'll need a jail broken iphone
and the terminal. I call one o.sh and the other i.sh. Then I use the
menu to type ./o.sh for me and I just have to enter a few keystrokes
and press return. Please customize to suit. I hope someone finds this
useful. Please let me know any suggestions or improvements.

#!/bin/sh
# script to
# accept input:
#      * amount
#      * account
#      * note
# output:
#      * ledger format text
# automatically includes date and source account (wallet)
#

fname='wallet.ledger'
if [ ! -z "$2" ]; then

account='expenses:simon:'$2
if [ $2 = 'f' ]; then
account='expenses:simon:food'
fi
if [ $2 = 'o' ]; then
account='expenses:simon:transportation:oil'
fi
if [ $2 = 'p' ]; then
account='expenses:simon:transportation::parking'
fi
if [ $2 = 't' ]; then
account='expenses:simon:telecom'
fi
if [ $2 = 'd' ]; then
account='expenses:simon:drinks'
fi
if [ $2 = 'g' ]; then
account='expenses:simon:gift'
fi

echo `date +%Y/%m/%d` ' ' $3 >> $fname
echo '    ' $account '    ' $1 >> $fname
echo '     assets:cash:wallet' >> $fname
echo >> $fname

else
echo "usage: $0 amount account note"
fi


#!/bin/sh
# script to
# accept input:
#      * amount
#      * account
#      * subaccount
#      * note
# output:
#      * ledger format text
# automatically includes date and destination account (wallet)
#

fname='wallet.ledger'
account='income:'$2':'$3

if [ ! -z $3 ]; then

if [ $2 = 'b' ]; then
account='assets:bank:'$3
fi
if [ $2 = 'a' ]; then
account='assets:accounts receivable:'$3
fi
if [ $2 = 'p' ]; then
account='assets:payback:'$3
fi
if [ $2 = 'c' ]; then
account='income:other:cash:'$3
fi

echo `date +%Y/%m/%d` ' ' $4 >> $fname
echo '     assets:cash:wallet    ' $1 >> $fname
echo '    ' $account >> $fname
echo >> $fname

else
echo "usage: $0 amount account subaccount note"
fi

Reply via email to