Skip to content

A free open source IT asset/license management system

Added #8522 - depreciation info on Asset API

snipe1488271a83f7
diff --git a/app/Http/Controllers/Api/AssetsController.php b/app/Http/Controllers/Api/AssetsController.php
index f0fadb84c4..cb8c9bdcc6 100644
--- a/app/Http/Controllers/Api/AssetsController.php
+++ b/app/Http/Controllers/Api/AssetsController.php
@@ -146,6 +146,7 @@ class AssetsController extends Controller
'model.category',
'model.manufacturer',
'model.fieldset',
+ 'model.depreciation',
'supplier'
); // it might be tempting to add 'assetlog' here, but don't. It blows up update-heavy users.
diff --git a/app/Http/Transformers/AssetsTransformer.php b/app/Http/Transformers/AssetsTransformer.php
index 976aff94f1..eb2f6b26a1 100644
--- a/app/Http/Transformers/AssetsTransformer.php
+++ b/app/Http/Transformers/AssetsTransformer.php
@@ -58,6 +58,13 @@ class AssetsTransformer
'id' => (int) $asset->model->manufacturer->id,
'name'=> e($asset->model->manufacturer->name),
] : null,
+ 'depreciation' => (($asset->model) && ($asset->model->depreciation)) ? [
+ 'id' => (int) $asset->model->depreciation->id,
+ 'name'=> e($asset->model->depreciation->name),
+ 'months'=> (int) $asset->model->depreciation->months,
+ 'type'=> e($asset->model->depreciation->depreciation_type),
+ 'minimum'=> ($asset->model->depreciation->depreciation_min) ? (int) $asset->model->depreciation->depreciation_min : null,
+ ] : null,
'supplier' => ($asset->supplier) ? [
'id' => (int) $asset->supplier->id,
'name'=> e($asset->supplier->name),