Added totals to depreciation report footer

Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
snipe 2021-09-21 21:52:18 -07:00
parent 9b78b25372
commit b4a90045e6
3 changed files with 19 additions and 9 deletions

View file

@ -54,7 +54,7 @@ class DepreciationReportTransformer
* for the other calculations that come after, like diff, etc. * for the other calculations that come after, like diff, etc.
*/ */
if ($asset->purchase_cost!='') { if ($asset->purchase_cost!='') {
$purchase_cost = $purchase_cost_currency . ' ' . \App\Helpers\Helper::formatCurrencyOutput($asset->purchase_cost); $purchase_cost = $asset->purchase_cost;
} }
@ -62,9 +62,9 @@ class DepreciationReportTransformer
* Override the previously set null values if there is a valid model and associated depreciation * Override the previously set null values if there is a valid model and associated depreciation
*/ */
if (($asset->model) && ($asset->model->depreciation)) { if (($asset->model) && ($asset->model->depreciation)) {
$depreciated_value = $purchase_cost_currency . ' ' . \App\Helpers\Helper::formatCurrencyOutput($asset->getDepreciatedValue()); $depreciated_value = \App\Helpers\Helper::formatCurrencyOutput($asset->getDepreciatedValue());
$monthly_depreciation = $purchase_cost_currency . ' ' .\App\Helpers\Helper::formatCurrencyOutput(($asset->model->eol > 0 ? ($asset->purchase_cost / $asset->model->eol) : 0)); $monthly_depreciation = \App\Helpers\Helper::formatCurrencyOutput(($asset->model->eol > 0 ? ($asset->purchase_cost / $asset->model->eol) : 0));
$diff = $purchase_cost_currency . ' ' .\App\Helpers\Helper::formatCurrencyOutput(($asset->purchase_cost - $asset->getDepreciatedValue())); $diff = \App\Helpers\Helper::formatCurrencyOutput(($asset->purchase_cost - $asset->getDepreciatedValue()));
} }
if ($asset->assigned) { if ($asset->assigned) {
@ -93,12 +93,13 @@ class DepreciationReportTransformer
'order_number' => ($asset->order_number) ? e($asset->order_number) : null, 'order_number' => ($asset->order_number) ? e($asset->order_number) : null,
'location' => ($asset->location) ? e($asset->location->name) : null, 'location' => ($asset->location) ? e($asset->location->name) : null,
'warranty_expires' => ($asset->warranty_months > 0) ? Helper::getFormattedDateObject($asset->warranty_expires, 'date') : null, 'warranty_expires' => ($asset->warranty_months > 0) ? Helper::getFormattedDateObject($asset->warranty_expires, 'date') : null,
'currency' => $purchase_cost_currency,
'purchase_date' => Helper::getFormattedDateObject($asset->purchase_date, 'date'), 'purchase_date' => Helper::getFormattedDateObject($asset->purchase_date, 'date'),
'purchase_cost' => $purchase_cost, 'purchase_cost' => Helper::formatCurrencyOutput($asset->purchase_cost),
'book_value' => $depreciated_value, 'book_value' => Helper::formatCurrencyOutput($depreciated_value),
'monthly_depreciation' => $monthly_depreciation, 'monthly_depreciation' => $monthly_depreciation,
'checked_out_to' => $checkout_target, 'checked_out_to' => $checkout_target,
'diff' => $diff, 'diff' => Helper::formatCurrencyOutput($diff),
'number_of_months' => ($asset->model && $asset->model->depreciation) ? e($asset->model->depreciation->months) : null, 'number_of_months' => ($asset->model && $asset->model->depreciation) ? e($asset->model->depreciation->months) : null,
'depreciation' => (($asset->model) && ($asset->model->depreciation)) ? e($asset->model->depreciation->name) : null, 'depreciation' => (($asset->model) && ($asset->model->depreciation)) ? e($asset->model->depreciation->name) : null,

View file

@ -115,6 +115,12 @@ class DepreciationReportPresenter extends Presenter
"visible" => true, "visible" => true,
"title" => trans('general.purchase_date'), "title" => trans('general.purchase_date'),
"formatter" => "dateDisplayFormatter" "formatter" => "dateDisplayFormatter"
], [
"field" => "currency",
"searchable" => false,
"sortable" => false,
"visible" => false,
"title" => 'Currency',
], [ ], [
"field" => "purchase_cost", "field" => "purchase_cost",
"searchable" => true, "searchable" => true,
@ -140,7 +146,8 @@ class DepreciationReportPresenter extends Presenter
"searchable" => true, "searchable" => true,
"sortable" => true, "sortable" => true,
"visible" => true, "visible" => true,
"title" => trans('admin/hardware/table.book_value') "title" => trans('admin/hardware/table.book_value'),
"footerFormatter" => 'sumFormatter',
], [ ], [
"field" => "monthly_depreciation", "field" => "monthly_depreciation",
"searchable" => true, "searchable" => true,
@ -152,7 +159,8 @@ class DepreciationReportPresenter extends Presenter
"searchable" => false, "searchable" => false,
"sortable" => false, "sortable" => false,
"visible" => true, "visible" => true,
"title" => trans('admin/hardware/table.diff') "title" => trans('admin/hardware/table.diff'),
"footerFormatter" => 'sumFormatter',
],[ ],[
"field" => "warranty_expires", "field" => "warranty_expires",
"searchable" => false, "searchable" => false,

View file

@ -29,6 +29,7 @@
data-show-refresh="true" data-show-refresh="true"
data-sort-order="desc" data-sort-order="desc"
data-sort-name="created_at" data-sort-name="created_at"
data-show-footer="true"
id="depreciationReport" id="depreciationReport"
data-url="{{ route('api.depreciation-report.index') }}" data-url="{{ route('api.depreciation-report.index') }}"
data-mobile-responsive="true" data-mobile-responsive="true"