switch ($item['depreciation_method']) {
case 'D':
- $line_value = $item['actual_cost']*$item['depreciation_rate']/100/12;
+ $line_value = $item['purchase_cost']*$item['depreciation_rate']/100/12;
$value = $item['material_cost'] * $item['depreciation_rate'] * $item['depreciation_factor']/100/12;
if ($value < $line_value)
$value = $line_value;
break;
- case 'S': // actual_cost stores start cost of item
- $value = $item['actual_cost']*$item['depreciation_rate']/100/12;
+ case 'S': // purchase_cost stores start cost of item
+ $done_months = months_between_dates($item['depreciation_start'], $item['depreciation_date']);
+ $remaining_months = 12.0 * 100.0/$item['depreciation_rate'] - $done_months;
+ $value = $item['purchase_cost']*$item['depreciation_rate']/100/12;
break;
case 'N':
$N = $item['depreciation_rate'];
$done_years = months_between_dates($item['depreciation_start'], $item['depreciation_date'])/12;
- $value = $item['material_cost']* ($N-$done_years)/($N*($N+1)/2)/12;
+ $value = $item['purchase_cost']* ($N-$done_years)/($N*($N+1)/2)/12;
break;
case 'O':
$total = 0;
$cnt = 0;
for ($i=$m; $i < $m + $no_months; $i++) {
+
+ if ($item['depreciation_method'] == 'S') {
+ if ($cnt >= $remaining_months)
+ $value = 0;
+ }
+
$date = sql2date(date("$y-$i-t", strtotime("$y-$i-1")));
$total += $value;
$cnt++;
- if ($item['depreciation_method'] == 'S') {
- if ($cnt >= $remaining_months)
- $value = 0;
- }
- elseif ($item['depreciation_method'] == 'O') {
- // depreciate only in the first month
- $value = 0;
- }
- }
+ if ($item['depreciation_method'] == 'O') {
+ // depreciate only in the first month
+ $value = 0;
+ }
+ }
return $rows;
}