diff --git a/app/Jobs/Setting/DeleteCategory.php b/app/Jobs/Setting/DeleteCategory.php index 24e855f3329..e8a3be56d0e 100644 --- a/app/Jobs/Setting/DeleteCategory.php +++ b/app/Jobs/Setting/DeleteCategory.php @@ -31,6 +31,13 @@ public function handle(): bool */ public function authorize(): void { + // Can not delete transfer category + if ($this->model->isTransferCategory()) { + $message = trans('messages.error.transfer_category', ['type' => $this->model->name]); + + throw new \Exception($message); + } + // Can not delete the last category by type if (Category::where('type', $this->model->type)->count() == 1) { $message = trans('messages.error.last_category', ['type' => strtolower(trans_choice('general.' . $this->model->type . 's', 1))]); diff --git a/resources/lang/en-GB/messages.php b/resources/lang/en-GB/messages.php index 4652bc0cc27..c29678f859b 100644 --- a/resources/lang/en-GB/messages.php +++ b/resources/lang/en-GB/messages.php @@ -25,7 +25,8 @@ 'not_user_company' => 'Error: You are not allowed to manage this company!', 'customer' => 'Error: User not created! :name already uses this email address.', 'no_file' => 'Error: No file selected!', - 'last_category' => 'Error: Can not delete the last :type category!', + 'last_category' => 'Error: Can not delete the last :type category!', + 'transfer_category' => 'Error: Can not delete the transfer :type category!', 'change_type' => 'Error: Can not change the type because it has :text related!', 'invalid_apikey' => 'Error: The API Key entered is invalid!', 'import_column' => 'Error: :message Column name: :column. Line number: :line.', diff --git a/resources/views/settings/categories/edit.blade.php b/resources/views/settings/categories/edit.blade.php index 9ffc7fc75f2..f3ad8fefd44 100644 --- a/resources/views/settings/categories/edit.blade.php +++ b/resources/views/settings/categories/edit.blade.php @@ -17,21 +17,23 @@ @if ($type_disabled) - + @else - @endif - + - - + + + @endif + @if (! $type_disabled) + @endif @can('update-settings-categories') diff --git a/resources/views/settings/categories/index.blade.php b/resources/views/settings/categories/index.blade.php index cc8d401588f..c67bcf8ed1b 100644 --- a/resources/views/settings/categories/index.blade.php +++ b/resources/views/settings/categories/index.blade.php @@ -67,7 +67,11 @@ @foreach($categories as $item) - +