From b094ebdd663c27568c42ea7a8f31aa0506f2ab8b Mon Sep 17 00:00:00 2001 From: snipe Date: Wed, 2 Jul 2025 17:53:32 +0100 Subject: [PATCH 1/6] Removed validation of > 0 Signed-off-by: snipe --- app/Models/Depreciation.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Models/Depreciation.php b/app/Models/Depreciation.php index 11ee82c16a..f6ed78649a 100755 --- a/app/Models/Depreciation.php +++ b/app/Models/Depreciation.php @@ -16,7 +16,7 @@ class Depreciation extends SnipeModel // Declare the rules for the form validation protected $rules = [ 'name' => 'required|min:3|max:255|unique:depreciations,name', - 'months' => 'required|max:3600|integer|gt:0', + 'months' => 'required|max:3600|integer', ]; /** From cdfe6c21c179511ac8891ff5990d9ec26638d932 Mon Sep 17 00:00:00 2001 From: snipe Date: Wed, 2 Jul 2025 17:53:42 +0100 Subject: [PATCH 2/6] Tightened HTML, added translations Signed-off-by: snipe --- resources/views/depreciations/edit.blade.php | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/resources/views/depreciations/edit.blade.php b/resources/views/depreciations/edit.blade.php index f86e484f81..a89750ab2f 100755 --- a/resources/views/depreciations/edit.blade.php +++ b/resources/views/depreciations/edit.blade.php @@ -15,11 +15,9 @@ -
-
- - {!! $errors->first('months', '') !!} -
+
+ + {!! $errors->first('months', '') !!}
@@ -28,13 +26,14 @@ -
- +
+ + {!! $errors->first('depreciation_min', '') !!}
- {!! $errors->first('depreciation_min', '') !!} +
@stop From 556a9039e972ae867e59997c7b76a94ecc5e7b17 Mon Sep 17 00:00:00 2001 From: snipe Date: Wed, 2 Jul 2025 17:53:55 +0100 Subject: [PATCH 3/6] New strings Signed-off-by: snipe --- resources/lang/en-US/general.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/resources/lang/en-US/general.php b/resources/lang/en-US/general.php index 361f5cf3a5..6f99d8a2f7 100644 --- a/resources/lang/en-US/general.php +++ b/resources/lang/en-US/general.php @@ -659,5 +659,11 @@ return [ 'confirm_delete' => 'Are you sure you want to delete this file?', ], + 'depreciation_options' => [ + 'amount' => 'Amount', + 'percent' => 'Percentage', + 'months' => '1 month|:count months', + ], + ]; From 88fef73d6faf780aaca07be7430a88c369519ed4 Mon Sep 17 00:00:00 2001 From: snipe Date: Wed, 2 Jul 2025 17:54:10 +0100 Subject: [PATCH 4/6] Use new translation Signed-off-by: snipe --- app/Http/Transformers/DepreciationsTransformer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Transformers/DepreciationsTransformer.php b/app/Http/Transformers/DepreciationsTransformer.php index 64d4c88f7e..2ccbfdb7cd 100644 --- a/app/Http/Transformers/DepreciationsTransformer.php +++ b/app/Http/Transformers/DepreciationsTransformer.php @@ -26,7 +26,7 @@ class DepreciationsTransformer $array = [ 'id' => (int) $depreciation->id, 'name' => e($depreciation->name), - 'months' => $depreciation->months.' '.trans('general.months'), + 'months' => trans_choice('general.depreciation_options.months', $depreciation->months), 'depreciation_min' => $depreciation->depreciation_type === 'percent' ? $depreciation->depreciation_min.'%' : $depreciation->depreciation_min, 'assets_count' => $depreciation->assets_count, 'models_count' => $depreciation->models_count, From b135c1eac276a2d485fdf4defab193fc78c7e88d Mon Sep 17 00:00:00 2001 From: snipe Date: Wed, 2 Jul 2025 18:15:06 +0100 Subject: [PATCH 5/6] Updated language strings in view Signed-off-by: snipe --- app/Http/Transformers/DepreciationsTransformer.php | 2 +- resources/lang/en-US/general.php | 3 ++- resources/views/hardware/view.blade.php | 7 ++----- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/app/Http/Transformers/DepreciationsTransformer.php b/app/Http/Transformers/DepreciationsTransformer.php index 2ccbfdb7cd..c3002a6969 100644 --- a/app/Http/Transformers/DepreciationsTransformer.php +++ b/app/Http/Transformers/DepreciationsTransformer.php @@ -26,7 +26,7 @@ class DepreciationsTransformer $array = [ 'id' => (int) $depreciation->id, 'name' => e($depreciation->name), - 'months' => trans_choice('general.depreciation_options.months', $depreciation->months), + 'months' => trans_choice('general.months_plural', $depreciation->months), 'depreciation_min' => $depreciation->depreciation_type === 'percent' ? $depreciation->depreciation_min.'%' : $depreciation->depreciation_min, 'assets_count' => $depreciation->assets_count, 'models_count' => $depreciation->models_count, diff --git a/resources/lang/en-US/general.php b/resources/lang/en-US/general.php index 6f99d8a2f7..138232b6b3 100644 --- a/resources/lang/en-US/general.php +++ b/resources/lang/en-US/general.php @@ -662,8 +662,9 @@ return [ 'depreciation_options' => [ 'amount' => 'Amount', 'percent' => 'Percentage', - 'months' => '1 month|:count months', ], + 'months_plural' => '1 month|:count months', + ]; diff --git a/resources/views/hardware/view.blade.php b/resources/views/hardware/view.blade.php index d0906da8be..c34fafbedd 100755 --- a/resources/views/hardware/view.blade.php +++ b/resources/views/hardware/view.blade.php @@ -903,9 +903,7 @@
- {{ $asset->warranty_months }} - {{ trans('admin/hardware/form.months') }} - + {{ trans_choice('general.months_plural', $asset->warranty_months) }} @if (($asset->model) && ($asset->model->manufacturer) && ($asset->model->manufacturer->warranty_lookup_url!='')) @@ -947,8 +945,7 @@
{{ $asset->depreciation->name }} - ({{ $asset->depreciation->months }} - {{ trans('admin/hardware/form.months') }}) + ({{ trans_choice('general.months_plural', $asset->depreciation->months) }})
From 30ebea4f2dc9ea7e25b5aee686444199a9b94421 Mon Sep 17 00:00:00 2001 From: snipe Date: Wed, 2 Jul 2025 18:24:27 +0100 Subject: [PATCH 6/6] Return int count Signed-off-by: snipe --- app/Http/Transformers/DepreciationsTransformer.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/Http/Transformers/DepreciationsTransformer.php b/app/Http/Transformers/DepreciationsTransformer.php index c3002a6969..af153539e2 100644 --- a/app/Http/Transformers/DepreciationsTransformer.php +++ b/app/Http/Transformers/DepreciationsTransformer.php @@ -28,9 +28,9 @@ class DepreciationsTransformer 'name' => e($depreciation->name), 'months' => trans_choice('general.months_plural', $depreciation->months), 'depreciation_min' => $depreciation->depreciation_type === 'percent' ? $depreciation->depreciation_min.'%' : $depreciation->depreciation_min, - 'assets_count' => $depreciation->assets_count, - 'models_count' => $depreciation->models_count, - 'licenses_count' => $depreciation->licenses_count, + 'assets_count' => ($depreciation->assets_count > 0) ? (int) $depreciation->assets_count : 0, + 'models_count' => ($depreciation->models_count > 0) ? (int) $depreciation->models_count : 0, + 'licenses_count' => ($depreciation->licenses_count > 0) ? (int) $depreciation->licenses_count : 0, 'created_by' => ($depreciation->adminuser) ? [ 'id' => (int) $depreciation->adminuser->id, 'name'=> e($depreciation->adminuser->present()->fullName()),