mirror of
https://github.com/snipe/snipe-it.git
synced 2024-10-02 13:47:41 -07:00
fix: add more checks at Depreciable.php
This commit is contained in:
parent
7b70afa2a1
commit
daba90b346
|
@ -42,6 +42,13 @@ class Depreciable extends SnipeModel
|
||||||
|
|
||||||
public function getDepreciatedValue()
|
public function getDepreciatedValue()
|
||||||
{
|
{
|
||||||
|
if (!$this->get_depreciation()) { // will never happen
|
||||||
|
return $this->purchase_cost;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->get_depreciation()->months <= 0) {
|
||||||
|
return $this->purchase_cost;
|
||||||
|
}
|
||||||
$depreciation = 0;
|
$depreciation = 0;
|
||||||
$setting = Setting::first();
|
$setting = Setting::first();
|
||||||
switch($setting->depreciation_method) {
|
switch($setting->depreciation_method) {
|
||||||
|
@ -66,14 +73,6 @@ class Depreciable extends SnipeModel
|
||||||
|
|
||||||
public function getLinearDepreciatedValue()
|
public function getLinearDepreciatedValue()
|
||||||
{
|
{
|
||||||
if (!$this->get_depreciation()) { // will never happen
|
|
||||||
return $this->purchase_cost;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($this->get_depreciation()->months <= 0) {
|
|
||||||
return $this->purchase_cost;
|
|
||||||
}
|
|
||||||
|
|
||||||
// fraction of value left
|
// fraction of value left
|
||||||
$months_remaining = $this->time_until_depreciated()->m + 12*$this->time_until_depreciated()->y; //UGlY
|
$months_remaining = $this->time_until_depreciated()->m + 12*$this->time_until_depreciated()->y; //UGlY
|
||||||
$current_value = round(($months_remaining/ $this->get_depreciation()->months) * $this->purchase_cost, 2);
|
$current_value = round(($months_remaining/ $this->get_depreciation()->months) * $this->purchase_cost, 2);
|
||||||
|
|
Loading…
Reference in a new issue