/** * Вычисляет вклад операции в статью бюджета * @param Operation $operation * @return BudgetArticleIncrement */ public function calculate(Operation $operation) { $increment = new BudgetArticleIncrement(); //получаем модуль вклада операции в бюджет: //получаем без знака $signed = false; $operationContributionAmount = $operation->getAmountForBudget($this->_currency, $signed); if ($operation->getDate() < $this->_startDate->format('Y-m-d')) { $increment->mean += $operationContributionAmount / $this->_meanRateMonthsAmount; } else { if (!$operation->isFromCalendar()) { $increment->adhoc += $operationContributionAmount; } else { if ($operation->isAccepted()) { $increment->calendarAccepted += $operationContributionAmount; } else { $increment->calendarFuture += $operationContributionAmount; } } } return $increment; }
public function setOperation(Operation $operation) { $this->_levelValues["parentCategory"] = $operation->getCategory()->getParentCategory(); $this->_levelValues["category"] = $operation->getCategory(); $tags = array_map('trim', explode(',', $operation->getTags())); $tag = isset($tags[0]) ? $tags[0] : null; $this->_levelValues["tag"] = $tag; $this->amount = $operation->getAmountForBudget($this->currency, true); }