diff --git a/app/Helpers/Helper.php b/app/Helpers/Helper.php index b950064988..cd712c46ee 100644 --- a/app/Helpers/Helper.php +++ b/app/Helpers/Helper.php @@ -46,7 +46,10 @@ class Helper public static function formatCurrencyOutput($cost) { if (is_numeric($cost)) { - return number_format($cost, 2, '.', ''); + if (Setting::getSettings()->digit_separator=='1.234,56') { + return number_format($cost, 2, ',', '.'); + } + return number_format($cost, 2, '.', ','); } // It's already been parsed. return $cost; diff --git a/app/Presenters/AssetPresenter.php b/app/Presenters/AssetPresenter.php index 05cff0dfdc..feb8aa8b8b 100644 --- a/app/Presenters/AssetPresenter.php +++ b/app/Presenters/AssetPresenter.php @@ -146,7 +146,6 @@ class AssetPresenter extends Presenter "searchable" => true, "sortable" => true, "title" => trans('general.purchase_cost'), - "formatter" => 'numberWithCommas', "footerFormatter" => 'sumFormatter', ], [ "field" => "order_number", diff --git a/database/migrations/2020_12_14_233815_add_digit_separator_to_settings.php b/database/migrations/2020_12_14_233815_add_digit_separator_to_settings.php index 8a5471233e..70fc292cf9 100644 --- a/database/migrations/2020_12_14_233815_add_digit_separator_to_settings.php +++ b/database/migrations/2020_12_14_233815_add_digit_separator_to_settings.php @@ -14,7 +14,7 @@ class AddDigitSeparatorToSettings extends Migration public function up() { Schema::table('settings', function (Blueprint $table) { - $table->char('digit_separator')->nullable()->default('1234.56'); + $table->char('digit_separator')->nullable()->default('1,234.56'); }); } diff --git a/resources/macros/macros.php b/resources/macros/macros.php index f022aaf046..e514b969c7 100644 --- a/resources/macros/macros.php +++ b/resources/macros/macros.php @@ -414,7 +414,7 @@ Form::macro('time_display_format', function ($name = "time_display_format", $sel Form::macro('digit_separator', function ($name = "digit_separator", $selected = null, $class = null) { $formats = [ - '1234.56', + '1,234.56', '1.234,56', ]; diff --git a/resources/views/partials/bootstrap-table.blade.php b/resources/views/partials/bootstrap-table.blade.php index 13de846d39..7138ecf804 100644 --- a/resources/views/partials/bootstrap-table.blade.php +++ b/resources/views/partials/bootstrap-table.blade.php @@ -608,9 +608,13 @@ function numberWithCommas(value) { if ((value) && ("{{$snipeSettings->digit_separator}}" == "1.234,56")){ - var parts = value.toString().split("."); - parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, "."); - return parts.join(","); + var parts = value.toString().split("."); + parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, "."); + return parts.join(","); + } else { + var parts = value.toString().split(","); + parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ","); + return parts.join("."); } return value }