/** * Вычисляет вклад операции в статью бюджета * @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; }