diff options
Diffstat (limited to 'resources/js/helpers.js')
-rw-r--r-- | resources/js/helpers.js | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/resources/js/helpers.js b/resources/js/helpers.js index e9cb37d..adf0bb7 100644 --- a/resources/js/helpers.js +++ b/resources/js/helpers.js @@ -63,3 +63,23 @@ function randomString () { function translate (msgid) { return DB.translations[Memory.state.Settings.language][msgid]; } + +/** + * @param {number} amount + * + * @returns {number} + */ +function convertToCurrencyBase (amount) { + const baseDecimalDiff = 2 - DB.currencies.map[Memory.state.Settings.currency].decimals; + + return amount * Math.pow(10, baseDecimalDiff); +} + +/** + * @param {number} price + * + * @returns {number} + */ +function formatPrice (price) { + return `${price} ${DB.currencies.map[Memory.state.Settings.currency].symbol}`; +} |