Skip to content

Commit 6a13a7e

Browse files
committed
Merge remote-tracking branch 'origin/develop'
2 parents 7969a66 + e366caf commit 6a13a7e

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

app/Models/Depreciable.php

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,16 +66,11 @@ public function getDepreciatedValue()
6666
/**
6767
* @return float|int
6868
*/
69-
public function getLinearDepreciatedValue()
69+
public function getLinearDepreciatedValue() // TODO - for testing it might be nice to have an optional $relative_to param here, defaulted to 'now'
7070
{
71-
$numerator= (($this->purchase_cost-($this->purchase_cost*12/($this->get_depreciation()->months))));
72-
$denominator=$this->get_depreciation()->months/12;
73-
$deprecation_per_year= $numerator/$denominator;
74-
$deprecation_per_month= $deprecation_per_year/12;
75-
7671
$months_remaining = $this->time_until_depreciated()->m + 12 * $this->time_until_depreciated()->y; //UGlY
77-
$months_depreciated=$this->get_depreciation()->months-$months_remaining;
78-
$current_value = $this->purchase_cost-($deprecation_per_month*$months_depreciated);
72+
73+
$current_value = round(($months_remaining / $this->get_depreciation()->months) * $this->purchase_cost, 2);
7974

8075
if($this->get_depreciation()->depreciation_min > $current_value) {
8176

0 commit comments

Comments
 (0)