File tree Expand file tree Collapse file tree 1 file changed +3
-8
lines changed Expand file tree Collapse file tree 1 file changed +3
-8
lines changed Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments