In case you didn't know, our service is retiring. You can now download your data from the menu
As part of our final blog post, we'd like to leave you with the inner-workings of Billsup's bills.
How Billsup's bills work
- Participants - all persons involved in a bill
- Each participant is assigned an id for the bill
- E.g. Tom=#1, Mary=#2, John=#3
- Items - breakdown the cost of the bills by item(s)
- Each bill has at least one item, and each item contains information of how the cost of that item should be split between the participants. An item could be split between one or more participants.
- Appetizer - $30 - Mary and Tom shared - each should pay $15
- Salad - $13 - Tom should pay
- Pasta - $16 - Mary should pay
- Lasagna - $15 - John should pay
- Dessert - $20 - Mary and John shared - each should pay $10
- Payers - who paid for the bill
- the payer could be one or more of the participants.
- E.g. John paid the entire bill - $94
- Settle details - contains who should pay whom for the current bill
- Based on items and payers, the balances are calculated:
Tom Mary John Appetizer 15 15 Salad 13 Pasta 16 Lasagna 15 Dessert 10 10 Payment -94 Balance 28 31 -69
- Tom->John - $28
- Mary->John - $31
How about debts?
A debt or a payment has the same inner workings as the above. It's basically the above bill with one item. For example, let's say you input a debt - Tom owes Mary $100
- Participants = Tom, Mary
- Item = debt $100 - Tom should pay
- Payer = Mary
- Settle details (calculated) = Tom->Mary - $100
Getting your debt balances with your friend:
- To get how much you owe each friend (or how much they owe you), we sum up all settle details of all bills involving your friend (Tom), for example
- Bill 1: Tom should pay you $100
- Bill 2: You should pay Tom $20
- Bill 3: Tom should pay you $100
- Bill 4: You should pay Tom $50
So how do debt transfers work?
- Tom should pay Mary $100
- Mary should pay John $50
- Mary should pay Jack $70
- Jack should pay Tom $20
- John should pay Tom $60
- John should pay Jack $80
2. Extract participant balances for each participant based on relationship balances:
+100, Mary: -100
- Mary: +50, John: -50
- Mary: +70, Jack:-70
- Jack: +20, Tom: -20
- John: +60, Tom: -60
- John: +80, Jack -80
3. Sum up all balances for each participant
- Tom = 100 - 20 - 60 = 20
- Mary = -100 + 50 + 70 = 20
- Jack = -70 + 20 -80 = -130
- John = -50 + 60 + 80 = 90
4. Optimize payments based on the new balances
- Tom should pay Jack $20
- Mary should pay Jack $20
- John should pay Jack $90
Viola! 6 payments down to 3 payments.
Hope that helps. thanks guys, and happy billing!