From 7b70afa2a14dd10ff9041a09e634f91ca7c7e650 Mon Sep 17 00:00:00 2001 From: Minaev Dmitriy Date: Fri, 24 Aug 2018 20:30:22 +0300 Subject: [PATCH] Integrate half-year convention inside working output --- app/Models/Depreciable.php | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/app/Models/Depreciable.php b/app/Models/Depreciable.php index b26215bc8f..9a4fe68b5e 100644 --- a/app/Models/Depreciable.php +++ b/app/Models/Depreciable.php @@ -41,6 +41,30 @@ class Depreciable extends SnipeModel */ public function getDepreciatedValue() + { + $depreciation = 0; + $setting = Setting::first(); + switch($setting->depreciation_method) { + case 'defalut': + $depreciation = $this->getLinearDepreciatedValue(); + break; + + case 'half_1': + $depreciation = $this->getHalfYearDepreciatedValue(true); + break; + + case 'half_2': + $depreciation = $this->getHalfYearDepreciatedValue(false); + break; + } + return $depreciation; + } + + /** + * @return float|int + */ + + public function getLinearDepreciatedValue() { if (!$this->get_depreciation()) { // will never happen return $this->purchase_cost;