From cc73a8a842d53844b53a20fde647f4be15a8dc4e Mon Sep 17 00:00:00 2001 From: Florian Gareis Date: Sat, 20 Mar 2021 17:49:57 +0100 Subject: [PATCH 1/2] Adjust money format to respect swap_currency_symbol --- resources/assets/js/helpers/utilities.js | 42 +++++++++--------------- 1 file changed, 16 insertions(+), 26 deletions(-) diff --git a/resources/assets/js/helpers/utilities.js b/resources/assets/js/helpers/utilities.js index ff9b0021..b80f4593 100644 --- a/resources/assets/js/helpers/utilities.js +++ b/resources/assets/js/helpers/utilities.js @@ -23,7 +23,7 @@ export default { amount = amount / 100 - let { precision, decimal_separator, thousand_separator, symbol } = currency + let { precision, decimal_separator, thousand_separator, symbol, swap_currency_symbol } = currency try { precision = Math.abs(precision) @@ -37,19 +37,14 @@ export default { let j = i.length > 3 ? i.length % 3 : 0 let moneySymbol = `${symbol}` + let thousandText = (j ? i.substr(0, j) + thousand_separator : '') + let amountText = i.substr(j).replace(/(\d{3})(?=\d)/g, '$1' + thousand_separator) + let precisionText = (precision ? decimal_separator + Math.abs(amount - i).toFixed(precision).slice(2) : ''); + let combinedAmountText = negativeSign + thousandText + amountText + precisionText - return ( - moneySymbol + - ' ' + - negativeSign + - (j ? i.substr(0, j) + thousand_separator : '') + - i.substr(j).replace(/(\d{3})(?=\d)/g, '$1' + thousand_separator) + - (precision - ? decimal_separator + - Math.abs(amount - i) - .toFixed(precision) - .slice(2) - : '') + return (swap_currency_symbol + ? combinedAmountText + ' ' + moneySymbol + : moneySymbol + ' ' + combinedAmountText ) } catch (e) { console.log(e) @@ -68,7 +63,7 @@ export default { amount = amount / 100 - let { precision, decimal_separator, thousand_separator, symbol } = currency + let { precision, decimal_separator, thousand_separator, symbol, swap_currency_symbol } = currency try { precision = Math.abs(precision) @@ -82,19 +77,14 @@ export default { let j = i.length > 3 ? i.length % 3 : 0 let moneySymbol = `${symbol}` + let thousandText = (j ? i.substr(0, j) + thousand_separator : '') + let amountText = i.substr(j).replace(/(\d{3})(?=\d)/g, '$1' + thousand_separator) + let precisionText = (precision ? decimal_separator + Math.abs(amount - i).toFixed(precision).slice(2) : ''); + let combinedAmountText = negativeSign + thousandText + amountText + precisionText - return ( - moneySymbol + - ' ' + - negativeSign + - (j ? i.substr(0, j) + thousand_separator : '') + - i.substr(j).replace(/(\d{3})(?=\d)/g, '$1' + thousand_separator) + - (precision - ? decimal_separator + - Math.abs(amount - i) - .toFixed(precision) - .slice(2) - : '') + return (swap_currency_symbol + ? combinedAmountText + ' ' + moneySymbol + : moneySymbol + ' ' + combinedAmountText ) } catch (e) { console.log(e) From f8591f96a9761ad09f6239dbfbe8179343346616 Mon Sep 17 00:00:00 2001 From: Florian Gareis Date: Sun, 21 Mar 2021 13:04:36 +0100 Subject: [PATCH 2/2] =?UTF-8?q?Write=20=E2=82=AC=20symbol=20after=20amount?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- database/seeders/CurrenciesTableSeeder.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/database/seeders/CurrenciesTableSeeder.php b/database/seeders/CurrenciesTableSeeder.php index 2abed043..4e4c5142 100644 --- a/database/seeders/CurrenciesTableSeeder.php +++ b/database/seeders/CurrenciesTableSeeder.php @@ -37,7 +37,8 @@ class CurrenciesTableSeeder extends Seeder 'symbol' => '€', 'precision' => '2', 'thousand_separator' => '.', - 'decimal_separator' => ',' + 'decimal_separator' => ',', + 'swap_currency_symbol' => true ], [ 'name' => 'South African Rand',