Merge pull request #15593 from Godmartinz/Fixed-divide-by-zero-bug

Fixed divide by zero bug in depreciation transformer
This commit is contained in:
snipe 2024-10-02 12:38:46 +01:00 committed by GitHub
commit 4db7358086
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -63,15 +63,12 @@ class DepreciationReportTransformer
*/
if (($asset->model) && ($asset->model->depreciation)) {
$depreciated_value = Helper::formatCurrencyOutput($asset->getDepreciatedValue());
if($asset->model->eol==0 || $asset->model->eol==null ){
$monthly_depreciation = Helper::formatCurrencyOutput($asset->purchase_cost / $asset->model->depreciation->months);
}
else {
$monthly_depreciation = Helper::formatCurrencyOutput(($asset->model->eol > 0 ? ($asset->purchase_cost / $asset->model->eol) : 0));
}
$monthly_depreciation =Helper::formatCurrencyOutput($asset->purchase_cost / $asset->model->depreciation->months);
$diff = Helper::formatCurrencyOutput(($asset->purchase_cost - $asset->getDepreciatedValue()));
}
else if($asset->model->eol !== null) {
$monthly_depreciation = Helper::formatCurrencyOutput(($asset->model->eol > 0 ? ($asset->purchase_cost / $asset->model->eol) : 0));
}
if ($asset->assigned) {
$checkout_target = $asset->assigned->name;