Skip to content

A free open source IT asset/license management system

Avoid trying to divide by zero

Marcus Moore1098b8cd9d55
diff --git a/app/Http/Transformers/DepreciationReportTransformer.php b/app/Http/Transformers/DepreciationReportTransformer.php
index 33d9a1f5fd..00eb984fa5 100644
--- a/app/Http/Transformers/DepreciationReportTransformer.php
+++ b/app/Http/Transformers/DepreciationReportTransformer.php
@@ -61,7 +61,7 @@ class DepreciationReportTransformer
/**
* Override the previously set null values if there is a valid model and associated depreciation
*/
- if (($asset->model) && ($asset->model->depreciation)) {
+ if (($asset->model) && ($asset->model->depreciation) && ($asset->model->depreciation->months !== 0)) {
$depreciated_value = Helper::formatCurrencyOutput($asset->getDepreciatedValue());
$monthly_depreciation =Helper::formatCurrencyOutput($asset->purchase_cost / $asset->model->depreciation->months);
$diff = Helper::formatCurrencyOutput(($asset->purchase_cost - $asset->getDepreciatedValue()));