From a0624fe179ea5fa72f4f6534753e206f8bd82852 Mon Sep 17 00:00:00 2001 From: Godfrey M Date: Wed, 14 Sep 2022 16:00:21 -0700 Subject: [PATCH] reworks the depreciation formula, includes months passed instead of months remaining --- app/Models/Depreciable.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/Models/Depreciable.php b/app/Models/Depreciable.php index 0f3f73aa30..512e8dbff6 100644 --- a/app/Models/Depreciable.php +++ b/app/Models/Depreciable.php @@ -68,9 +68,10 @@ 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' { - $months_remaining = $this->time_until_depreciated()->m + 12 * $this->time_until_depreciated()->y; //UGlY + $months_passed = $this->purchase_date->diff(now())->m; - $current_value = round(($months_remaining / $this->get_depreciation()->months) * $this->purchase_cost, 2); + // The equation here is (Purchase_Cost-Floor_min)*(Months_passed/Months_til_depreciated) + $current_value= round((($this->purchase_cost-$this->get_depreciation()->depreciation_min)*($months_passed/$this->get_depreciation()->months)),2); if($this->get_depreciation()->depreciation_min > $current_value) {