summaryrefslogtreecommitdiff
path: root/resources/js/helpers.js
diff options
context:
space:
mode:
authorDaniel Weipert <code@drogueronin.de>2023-08-23 20:29:07 +0200
committerDaniel Weipert <code@drogueronin.de>2023-08-23 20:29:07 +0200
commit7b1c251fcb085dc37de439ea1137373f1905d82e (patch)
tree32e3f2cd4367507726af6d0172e9621a37dff576 /resources/js/helpers.js
parent4dd1a344c6474087a3f8782dd54f5c7b4acc67ed (diff)
areas and capture and more
Diffstat (limited to 'resources/js/helpers.js')
-rw-r--r--resources/js/helpers.js20
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}`;
+}