Skip to content

A free open source IT asset/license management system

Fixes #2622 - add depreciation to license report

snipeaa92b93bd18d
diff --git a/app/Http/Controllers/ReportsController.php b/app/Http/Controllers/ReportsController.php
index b892b46e19..00fbda3d5a 100644
--- a/app/Http/Controllers/ReportsController.php
+++ b/app/Http/Controllers/ReportsController.php
@@ -329,7 +329,7 @@ class ReportsController extends Controller
}
- $allowed_columns = ['name','min_amt','order_number','purchase_date','purchase_cost','companyName','category'];
+ $allowed_columns = ['created_at'];
$order = Input::get('order') === 'asc' ? 'asc' : 'desc';
$sort = in_array(Input::get('sort'), $allowed_columns) ? e(Input::get('sort')) : 'created_at';
@@ -406,7 +406,7 @@ class ReportsController extends Controller
public function getLicenseReport()
{
- $licenses = License::orderBy('created_at', 'DESC')
+ $licenses = License::with('depreciation')->orderBy('created_at', 'DESC')
->with('company')
->get();
@@ -433,6 +433,7 @@ class ReportsController extends Controller
trans('admin/licenses/form.remaining_seats'),
trans('admin/licenses/form.expiration'),
trans('admin/licenses/form.date'),
+ trans('admin/licenses/form.depreciation'),
trans('admin/licenses/form.cost')
];
@@ -448,6 +449,7 @@ class ReportsController extends Controller
$row[] = $license->remaincount();
$row[] = $license->expiration_date;
$row[] = $license->purchase_date;
+ $row[] = ($license->depreciation!='') ? '' : e($license->depreciation->name);
$row[] = '"' . Helper::formatCurrencyOutput($license->purchase_cost) . '"';
$rows[] = implode($row, ',');
diff --git a/resources/views/reports/licenses.blade.php b/resources/views/reports/licenses.blade.php
index 645ae8ae51..3271dd9c94 100644
--- a/resources/views/reports/licenses.blade.php
+++ b/resources/views/reports/licenses.blade.php
@@ -33,7 +33,10 @@
<th class="col-sm-1">{{ trans('admin/licenses/form.remaining_seats') }}</th>
<th class="col-sm-1">{{ trans('admin/licenses/form.expiration') }}</th>
<th class="col-sm-1">{{ trans('admin/licenses/form.date') }}</th>
- <th class="col-sm-1">{{ trans('admin/licenses/form.cost') }}</th>
+ <th class="col-sm-1 text-right" class="col-sm-1">{{ trans('admin/licenses/form.cost') }}</th>
+ <th class="col-sm-1">{{ trans('admin/licenses/form.depreciation') }}</th>
+ <th class="col-sm-1 text-right">{{ trans('admin/hardware/table.book_value') }}</th>
+ <th class="col-sm-1 text-right">{{ trans('admin/hardware/table.diff') }}</th>
</tr>
</thead>
<tbody>
@@ -47,9 +50,11 @@
<td>{{ $license->remaincount() }}</td>
<td>{{ $license->expiration_date }}</td>
<td>{{ $license->purchase_date }}</td>
- <td>
- {{ \App\Models\Setting::first()->default_currency }}
- {{ number_format($license->purchase_cost) }}</td>
+ <td class="text-right">
+ {{ \App\Models\Setting::getSettings()->default_currency }}{{ \App\Helpers\Helper::formatCurrencyOutput($license->purchase_cost) }}</td>
+ <td>{{ ($license->depreciation) ? e($license->depreciation->name).' ('.$license->depreciation->months.' '.trans('general.months').')' : '' }}</td>
+ <td class="text-right">{{ \App\Models\Setting::getSettings()->default_currency }}{{ \App\Helpers\Helper::formatCurrencyOutput($license->getDepreciatedValue()) }}</td>
+ <td class="text-right">-{{ \App\Models\Setting::getSettings()->default_currency }}{{ \App\Helpers\Helper::formatCurrencyOutput(($license->purchase_cost - $license->getDepreciatedValue())) }}</td>
</tr>
@endforeach
</tbody>