Saturday, January 24, 2009

Kharcha

I stay with 4 other roomies in our rented flat @ pune. As usual, we share resources to cut down on expenses. rent, utensils, food raw materials, gas refills, electricity bill, paying the maid, internet, paper bill n what not. Different people pay for each of these, as and when required and based on availability of money. During the early few months, it was quite difficult to keep track how much each person owes others, at the end of the month. It was a boring procedure and there used to be a lot of confusion. There might be apps doing this, but the initial searches got me complicated apps that were designed to do some other things but not exactly what i want. May be i didnt search well. My requirements were quite simple, so i stopped hunting for apps. I could write some rudimentary ruby by then. So, Instead of finding an app to do this, I thought of writing a ruby script that make this easy.

So the script parses a simple text file(i call it a .kharcha file :) ) containing comma separated entries that talk about expenses.

Each line says the following:
1) who were involved in the expense.
2) who paid
3) the date of exp

a) one can use shortcuts for big names to make it easy to make entries in a .kharcha file.
b) for a line, if #1 is empty, it assumes all users were involved.
c) I usually create one kharcha file for each month e.g jan.kharcha, feb.kharcha

The script then spits text indicating "who owes whom what".

Sample .kharcha file => january.kharcha

Sample script output => kharcha.txt

Script => kharcha2.rb

If somebody finds this hacked together script useful, do let me know. If i find time, i might put together RoR based web ui for this.

No comments: