diff options
author | Daniel Weipert <code@drogueronin.de> | 2023-08-23 20:29:07 +0200 |
---|---|---|
committer | Daniel Weipert <code@drogueronin.de> | 2023-08-23 20:29:07 +0200 |
commit | 7b1c251fcb085dc37de439ea1137373f1905d82e (patch) | |
tree | 32e3f2cd4367507726af6d0172e9621a37dff576 /resources/js/helpers.js | |
parent | 4dd1a344c6474087a3f8782dd54f5c7b4acc67ed (diff) |
areas and capture and more
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}`; +} |