if eol is missing from asset model monthly depreciation will be recalculated

This commit is contained in:
Godfrey M 2022-08-09 15:05:15 -07:00
parent de449fd1c2
commit 92e6ea96b2

View file

@ -63,10 +63,16 @@ class DepreciationReportTransformer
*/ */
if (($asset->model) && ($asset->model->depreciation)) { if (($asset->model) && ($asset->model->depreciation)) {
$depreciated_value = Helper::formatCurrencyOutput($asset->getDepreciatedValue()); $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->model->eol > 0 ? ($asset->purchase_cost / $asset->model->eol) : 0));
}
$diff = Helper::formatCurrencyOutput(($asset->purchase_cost - $asset->getDepreciatedValue())); $diff = Helper::formatCurrencyOutput(($asset->purchase_cost - $asset->getDepreciatedValue()));
} }
if ($asset->assigned) { if ($asset->assigned) {
$checkout_target = $asset->assigned->name; $checkout_target = $asset->assigned->name;
if ($asset->checkedOutToUser()) { if ($asset->checkedOutToUser()) {