diff --git a/app/Libraries/Utils.php b/app/Libraries/Utils.php index 7c1b11dfd8..4699603d4d 100644 --- a/app/Libraries/Utils.php +++ b/app/Libraries/Utils.php @@ -341,6 +341,7 @@ class Utils $currency = self::getFromCache($currencyId, 'currencies'); $thousand = $currency->thousand_separator; $decimal = $currency->decimal_separator; + $precision = $currency->precision; $code = $currency->code; $swapSymbol = false; @@ -355,7 +356,7 @@ class Utils } } - $value = number_format($value, $currency->precision, $decimal, $thousand); + $value = number_format($value, $precision, $decimal, $thousand); $symbol = $currency->symbol; if ($showCode || !$symbol) { diff --git a/database/seeds/CurrenciesSeeder.php b/database/seeds/CurrenciesSeeder.php index b3da84dad0..3b44d55d8d 100644 --- a/database/seeds/CurrenciesSeeder.php +++ b/database/seeds/CurrenciesSeeder.php @@ -8,6 +8,7 @@ class CurrenciesSeeder extends Seeder { Eloquent::unguard(); + // http://www.localeplanet.com/icu/currency.html $currencies = [ ['name' => 'US Dollar', 'code' => 'USD', 'symbol' => '$', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'], ['name' => 'Pound Sterling', 'code' => 'GBP', 'symbol' => '£', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'], @@ -56,6 +57,7 @@ class CurrenciesSeeder extends Seeder ['name' => 'Japanese Yen', 'code' => 'JPY', 'symbol' => '¥', 'precision' => '0', 'thousand_separator' => ',', 'decimal_separator' => '.'], ['name' => 'Maldivian Rufiyaa', 'code' => 'MVR', 'symbol' => '', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'], ['name' => 'Costa Rican Colón', 'code' => 'CRC', 'symbol' => '', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'], + ['name' => 'Pakistani Rupee', 'code' => 'PKR', 'symbol' => 'Rs ', 'precision' => '0', 'thousand_separator' => ',', 'decimal_separator' => '.'], ]; foreach ($currencies as $currency) { diff --git a/resources/views/money_script.blade.php b/resources/views/money_script.blade.php index f6d5067bc0..0dc44eac64 100644 --- a/resources/views/money_script.blade.php +++ b/resources/views/money_script.blade.php @@ -66,6 +66,7 @@ } var currency = currencyMap[currencyId]; + var precision = currency.precision; var thousand = currency.thousand_separator; var decimal = currency.decimal_separator; var code = currency.code; @@ -82,7 +83,7 @@ } } - value = accounting.formatMoney(value, '', 2, thousand, decimal); + value = accounting.formatMoney(value, '', precision, thousand, decimal); var symbol = currency.symbol; if (hideSymbol) {