Integrate half-year convention inside working output

This commit is contained in:
Minaev Dmitriy 2018-08-24 20:30:22 +03:00
parent 8d3b201a49
commit 7b70afa2a1

View file

@ -41,6 +41,30 @@ class Depreciable extends SnipeModel
*/ */
public function getDepreciatedValue() 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 if (!$this->get_depreciation()) { // will never happen
return $this->purchase_cost; return $this->purchase_cost;