From 7b1c251fcb085dc37de439ea1137373f1905d82e Mon Sep 17 00:00:00 2001 From: Daniel Weipert Date: Wed, 23 Aug 2023 20:29:07 +0200 Subject: areas and capture and more --- resources/js/helpers.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'resources/js/helpers.js') 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}`; +} -- cgit v1.2.3