Merge pull request #12880 from Godmartinz/asset_total_cost

Added component costs to asset view
This commit is contained in:
snipe 2023-05-03 10:49:03 -07:00 committed by GitHub
commit 4a643c1252
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 27 additions and 1 deletions

View file

@ -909,7 +909,13 @@ class Asset extends Depreciable
return false; return false;
} }
public function getComponentCost(){
$cost = 0;
foreach($this->components as $component) {
$cost += $component->pivot->assigned_qty*$component->purchase_cost;
}
return $cost;
}
/** /**
* ----------------------------------------------- * -----------------------------------------------

View file

@ -8,6 +8,7 @@ return [
'change' => 'In/Out', 'change' => 'In/Out',
'checkout_date' => 'Checkout Date', 'checkout_date' => 'Checkout Date',
'checkoutto' => 'Checked Out', 'checkoutto' => 'Checked Out',
'components_cost' => 'Total Components Cost',
'current_value' => 'Current Value', 'current_value' => 'Current Value',
'diff' => 'Diff', 'diff' => 'Diff',
'dl_csv' => 'Download CSV', 'dl_csv' => 'Download CSV',

View file

@ -530,6 +530,25 @@
</div> </div>
</div> </div>
@endif @endif
@if(($asset->components->count() > 0) && ($asset->purchase_cost))
<div class="row">
<div class="col-md-2">
<strong>
{{ trans('admin/hardware/table.components_cost') }}
</strong>
</div>
<div class="col-md-6">
@if (($asset->id) && ($asset->location))
{{ $asset->location->currency }}
@elseif (($asset->id) && ($asset->location))
{{ $asset->location->currency }}
@else
{{ $snipeSettings->default_currency }}
@endif
{{Helper::formatCurrencyOutput($asset->getComponentCost())}}
</div>
</div>
@endif
@if (($asset->model) && ($asset->depreciation) && ($asset->purchase_date)) @if (($asset->model) && ($asset->depreciation) && ($asset->purchase_date))
<div class="row"> <div class="row">
<div class="col-md-2"> <div class="col-md-2">