BillSplitter is a small utility that lets you organize bills in a convenient way. You can specify any number of people involved and bills payed, who payed what, and who is in on a particular bill. The result is an overview over the amount each person has to pay, and who it has to be payed to.

How it works

It's been a few years since I made the script, and it tangles up the data and UI a bit. So instead of reading the source code, you can read how it works here:

First, the total is calculated for each person (amount payed minus amount owed). This is pretty straight forward: For each bill, divide the amount owed by the number of people in on the bill. Then subtract that amount from whatever each person payed for that bill. Do this for all the bills, and you have the total. A negative total means the person owes something to someone else, while a positive total means that someone owes something to them.

Next, to find who should pay what to whom, there is an iterative algorithm in place. For each step in the algorithm, if there is a match, go back to the start.

  1. Check for an exact match, i.e. anyone who can pay off their entire debt with one payment, and simultaneously pay back everything to another person
  2. Check for one less-than match, i.e. a person gets rid of their entire debt, but the receiver still needs some more money from someone else
  3. Check for one more-than match, i.e. a person can't get rid of their entire debt, but the receiver doesn't need any more money

When no matches are found in any of the steps, the algorithm is complete.

Android app

I also made an Android app with the same functionality. Haven't gotten around to uploading it to Google Play yet. I'll post a link if I do. The app is a bit smarter than the script above, as it separates data and UI better, and also handles currency rounding in a much smarter way. Here are some images from the app: