Merge pull request #13346 from snipe/fixes/depreciable

Check that $this->get_depreciation() returns
This commit is contained in:
snipe 2023-07-20 16:33:15 +01:00 committed by GitHub
commit 0b8a3ee9a5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -68,7 +68,7 @@ class Depreciable extends SnipeModel
*/
public function getLinearDepreciatedValue() // TODO - for testing it might be nice to have an optional $relative_to param here, defaulted to 'now'
{
if ($this->purchase_date) {
if (($this->get_depreciation()) && ($this->purchase_date)) {
$months_passed = ($this->purchase_date->diff(now())->m)+($this->purchase_date->diff(now())->y*12);
} else {
return null;