bhima
bhima copied to clipboard
More flexible precision for currencies
Currently, our reports are forced to use the same precision (number of digits after the decimal separator) for currency for reports regardless of which currency the report is in. It would be good to make this more flexible. Here is the suggested approach:
- Extend the 'currency' table with an additional field for the desired number of decimal digits to display. It may be necessary to add two fields: one for the number of decimal digits for sums and a different (higher precision) value to use for unit prices.
- Update the HTML/handlebars 'currency' operator to get the number of decimal digits for the specified currency from the database. These will probably need an optional override of the number of decimal digits in for some situations.
- In some places, we truncate the values before display using toFloat(), etc. These will probably need to be revisited to determine if they are still needed.
- Add a new Administration page to support editing the number of decimal digits to display for each supported currency. It is quite possible that different institutions would prefer to see different numbers of decimal digits (eg, 0 or 1 for Francs, etc).
For reference, please review these potentially related Issues:
- https://github.com/IMA-WorldHealth/bhima/issues/5199
- https://github.com/IMA-WorldHealth/bhima/issues/2933
- https://github.com/IMA-WorldHealth/bhima/issues/3150
Thanks for all these issues @jmcameron. I agree, we need more flexible way to handle currencies. I also think that we need to unify the rendering of the currencies so that they use a common configuration between the client and server. For example, we have red negatives in parentheses on the server, but we don't necessarily do that on the client.
If we stored a common configuration file, we would be able to make sure that the rendering was rational across all platforms and reports.