Tips for developing Settle Up for other platform

Are you developing iPhone, BlackBerry or Windows Phone app compatible with Settle Up? Settle Up is designed to work offline, so there is quite a lot of work for client developer. I will try to speed it up and help you.

Relation of your app and Android app

I try to be as open as possible here:
  • You can use graphics, UI flow, texts etc. from Android version in your app as long as you use API.
  • You can use parts of application name like "Settle Up for Symbian", "Settle Down", ...
  • You need to link Android version from you app's website and application store (if possible). I will also consider linking your product from this website.
  • Application for other platform is yours - you can collect revenue for it, keep it closed-source etc.
  • We can share GetSatisfaction for user feedback
  • I have right to decide about new features for Server API, but I'm open for discussion
  • I'm not responsible for any damage caused by API errors, outages, data loss or project termination

Algorithm for settling debts

Calculation "who owes who" should be done locally, user should not be dependent on internet connection. Algoritm is part of my master's thesis, written in Java. You are free to rewrite it into your programing language.
  • Source code with description is part of my master's thesis
  • I'm open-sourcing it under Apache License, which means no copy-left
  • Algorithm is exponencial, it works in reasonable time (<1s) until 15 members. For more members, you should use "basicDebts" algorithm. It gives correct, but not necessarily optimal solution.
  • I use this library for generating combinations

Local database

I strongly suggest to use some SQL-like database, I use SQLite. It will help you in coding synchronization. I suggest using online IDs as primary keys. Android app don't use it and it caused lot of errors during development.

Best way to look at database structure is use the export function in Android version. It will export SQLite database you can use in your app or inspire yourself. Open it in program SQLiteBrowser and discover how the fields are named (you will need it for data section in synchronization API). Here is one sample database I created from my phone.

Data definition

Synchronization API is generic, you can sync as many custom tables as you want. But when trying to use Settle Up data, it would be easier to have same local data structure. This is description of data structure from Android version, which matches names of fields in synchronization:

Data version: 1

Table 'payments'
Column Type Description
_id integer Local id
who_paid string Space separated local ids from members table
for_who string Space separated local ids from members table
amount string Space separated amounts (matching the order of who_paid)
weights string Space separated decimal numbers (matching the order of for_who)
purpose string Purpose of payment
created integer Local timestamp in unix time * 1000
group_id integer Foreign key from groups table
online_id string Calculated online id or from server
currency string Three letter ISO code
transfer boolean Whether it's a payment or transfer. Transfers doesn't count to Total Paid.
Table 'members'
Column Type Description
_id integer Local id
name string Name, try to shorten it as 'Firstname L.'
email string email used for sharing
group_id integer Foreign key to table groups
people decimal Default weight, it is used for prefilling weight in payments
online_id string Calculated or received online id
group_shared boolean Whether the groups is shared with this guy
shared_to_email string E-mail used for sharing with this guy
disabled boolean Whether this member is disabled (not active for new payments)
bank_account string Bank account number
Table 'groups'
Column Type Description
_id integer Local id
currency integer Foreign key to currencies table, default group currency
active boolean Whether this group is currently selected
online boolean Whether sync is enabled for this group
name string Group name, if user doesn't provide it, create it from member names.
last_sync integer Last sync received from server
online_id string Online id, calculated or received from the server.
Table 'changes'

Helper table for saving pending changes. It is truncated after successful sync.

Column Type Description
_id integer Local id
client_time integer Unix timestamp * 1000
group_id integer Groups foreign key
method string insert, update or delete
online_id string online id of that record (payment, member)
data string Data in JSON
data_table string payments, members or groups
name string User-friendly text describing the change
Table 'purposes'

Just a local table for easier input of purposes

Column Type Description
_id integer Local id
text string Purpose text
used integer How many times it was used, used for sorting
Table 'currencies'

Just a local table for currency management and storing exchange rates.

Column Type Description
_id integer Local id
code string Three letter currency ISO code
exchange_code string ISO code of currency used in exchange_rate
exchange_rate decimal Cached exchange rate into currency specified in exchange_code