adds optional breakdowns for total cost

This commit is contained in:
Godfrey M
2023-04-19 17:51:37 -07:00
parent 6872f8da7b
commit 97df39001d
2 changed files with 11 additions and 7 deletions
+7 -5
View File
@@ -767,23 +767,25 @@ class User extends SnipeModel implements AuthenticatableContract, AuthorizableCo
return $this->locale;
}
public function getUserTotalCost(){
$total_cost= array();
$asset_cost= 0;
$license_cost= 0;
$accessory_cost= 0;
foreach ($this->assets as $asset){
$asset_cost += $asset->purchase_cost;
array_push($total_cost, $asset_cost);
$this->asset_cost = $asset_cost;
}
foreach ($this->licenses as $license){
$license_cost += $license->purchase_cost;
array_push($total_cost, $license_cost);
$this->license_cost = $license_cost;
}
foreach ($this->accessories as $accessory){
$accessory_cost += $accessory->purchase_cost;
array_push($total_cost, $accessory_cost);
$this->accessory_cost = $accessory_cost;
}
return $total_cost;
$this->total_user_cost = ($asset_cost + $accessory_cost + $license_cost);
return $this;
}
}