/**
  * View single account
  *
  * @param $id int Account id
  * @param SetIntervalRequest|Request $request
  * @param GraphDirector $graphHelper
  *
  * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  */
 public function view($id, SetIntervalRequest $request, GraphDirector $graphHelper)
 {
     /** @var $account Account */
     $account = AccountContainer::getFullInfoAboutAccount($id);
     $chartData = $graphHelper->getGraphData($id, $request);
     $history = AccountsHistoryContainer::getHistory($id);
     return view('accounts.view', compact('account', 'chartData', 'history'));
 }
 /**
  * Get account by id and set the balance field to the collection
  * @param $accountId
  *
  * @return Account
  */
 public static function getFullInfoAboutAccount($accountId)
 {
     /* @var $account Account */
     $account = Account::findOrFail($accountId);
     $account->balance = AccountsHistoryContainer::getAccountBalance($accountId);
     $account->currentMonthIncome = AccountsHistoryContainer::getIncomeForCurrentMonth($accountId);
     return $account;
 }
 /**
  * Get income for current month from begin to current datetime
  * @param $accountId
  *
  * @return int
  */
 public static function getIncomeForCurrentMonth($accountId)
 {
     $transactions = AccountsHistoryContainer::getTransactionsByInterval($accountId, DateFormatter::getCurrentMonthInterval());
     $money = 0;
     foreach ($transactions as $transaction) {
         $money += $transaction->money;
     }
     return $money;
 }
Example #4
0
 /**
  * Set transactions data for each graphics
  *
  * @param $accountId
  *
  * @return mixed
  */
 private function setDataForGraphics($accountId)
 {
     $this->resultContainer['income']->data = AccountsHistoryContainer::getTransactionsByInterval($accountId, $this->resultContainer['income']->interval);
     $this->resultContainer['receipt']->data = AccountsHistoryContainer::getReceiptByInterval($accountId, $this->resultContainer['receipt']->interval);
     $this->resultContainer['expense']->data = AccountsHistoryContainer::getExpenseByInterval($accountId, $this->resultContainer['expense']->interval);
     return $this->resultContainer;
 }