-
Notifications
You must be signed in to change notification settings - Fork 105
Exchange Rate Design
Jonathan Niles edited this page Aug 13, 2018
·
3 revisions
This document describes the way bhima computes exchange rates.
Defining an Exchange Rates
New exchange rates are defined in the #/exchange
module. They are stored in the exchange_rate
table as a unique tuple of date, currency_id, enterprise_id, and value.
Computing an Exchange Rate for a Date
In general, exchange rates are only set when the rate changes. Exchange rates are computed by finding the last valid rate for a date. If the rate is not defined on a given date, the most recent record prior to that date is used.
Example
Date (dd/mm/yyyy) | Rate (FC) |
---|---|
01/01/2016 | 930 |
05/01/2016 | 945 |
12/01/2016 | 965 |
17/01/2016 | 950 |
28/01/2016 | 1000 |
Using the above table, bhima's algorithm will compute:
- The rate on Jan 1st was 930FC.
- The rate on Jan 6th was 945FC.
- The rate on Jan 11th was 945FC.
- The rate on Jan 12th was 965FC.
- The rate on Jan 17th was 950FC.
- The rate on March 12th was 1000FC.