envato/double_entry — pull request #51 by eadz (2014-07-30 13:51:10+00:00)
Title: Multi Currency Support [WIP - feedback requested]

**note: draft code**

At the moment, all money values are using `Money.default_currency` as the currency.

This PR does the following:

Allows an account to have a currency. This is set in the accounts definition ( so no need for any more database tables ). It is my reasoning, that as it never makes sense to transfer from an account in currency A to account in currency B ( you are subtracting apples from oranges ), then a per-account currency makes sense.

An example config would be:

```ruby
accounts.define(:identifier => :savings)
accounts.define(:identifier => :store)
accounts.define(:identifier => :btc_store, :currency => 'BTC')
accounts.define(:identifier => :btc_wallet, :currency => 'BTC')
```

With this setup, savings and store would be in USD, and btc_store, btc_wallet in BTC.

a transfer can only happen between two accounts of the same currency.

all balances are in the currency of the account.

Almost all the specs are passing, I'm having trouble with the account balance spec, as it makes a lot of assumptions about the implementation. Because currency is not stored in the DB, to get a balance you need access to the account object instance to get the currency, not just a symbol.

but keen for feedback before I go much further down this route.

Another option is to store the currency in the DB, which I'm not opposed to, but I do like the lightweightness of defining it on the account.