Multiple currencies and Fx support #69
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request add a few things to the app, as discussed in #64
Here are the features and below a brief explanation on how they are implemented. We can discuss potential changes then.
Features
How is it implemented ?
All currencies are stored in a worldCurrencies.json file. I had wrote a simple go script to generate currencies.go file to keep the old hard-coded storage of currencies.
However, the UI needs informations like formatting behavior (use commas ? where the symbol is placed ?) but the backend does not need it. The UI also fetch this worldCurrencies.json file to import the behaviors.
Another form is added in the expense-form to select currencies. The currencies are loaded from backend (we just need CODE/SYMBOL representation) but the default one is the currency set in settings.
Whenever a new expense is added, the backend launch a goroutine to fetch rates from a cdn. it is a simple http call and around 340 rates are returned for a base currency and a date. We only store rates present in our worldCurrencies.json file. There is around 160 rates. When the rate is present, the UI fetch it and update the UI within a correspondant case. It works like the tags class. If there is no other currencies in expense, that case is not shown.
In index.html all amounts are converted to the currency set in settings. Under total we have a list of the other currencies total aswell with a choice of showing them in their currency or yours.
There is NO UI BLOCKING when retrieving the rates, the initialize() function is called again 3s after adding expense to refresh data. If no rates has been fetched (no internet connection, timeout, etc) the backend will try on another refresh.
After selecting your .csv file you'll be prompted with a modal asking for the currency to add with these expenses. Just use your previous currency set in settings and it will import them.
What could be done different ?
Some screenshots
Settings page.
Import modal.
Existings Recurring expenses.
Different tables dependings of Tags and Currencies.
Pie chart and legend.
And whenever I change my default currency, all amounts gets converted instantly because of fx rates storage.
Feel free to ask anything or any changes.