/** * {@inheritDoc} */ public function render() { $dataProvider = new DataProvider(); $budgetControlService = new BudgetControlService(new PurchaseService($dataProvider), new Goalr()); $monthlyGoal = MonthlyGoal::query()->mine()->currentMonth()->first(); if ($monthlyGoal) { $todayBudget = new Currency($budgetControlService->getDailyMonthlyBudget($monthlyGoal, \BackendAuth::getUser())); $todayBudget->setFormat('{number}'); $todaySpent = new Currency(Purchase::calcAmountByPeriod(new \DateTime(), new \DateTime(), \BackendAuth::getUser()->id)); $todaySpent->setFormat('{number}'); $this->vars['todaySpent'] = $todaySpent; $this->vars['todayBudget'] = $todayBudget; return $this->makePartial('dailybudget'); } else { return $this->makePartial('no_monthly_goal'); } }
/** * @param \DateTime $date_start * @param \DateTime $date_end * @param integer $user_id * @param bool $only_forecast * @return float */ public function calcAmountByPeriod(\DateTime $date_start, \DateTime $date_end, $user_id, $only_forecast = false) { return Purchase::calcAmountByPeriod($date_start, $date_end, $user_id, $only_forecast); }