Пример #1
0
 /**
  * Get a full report on the users incomes during the period for the given accounts.
  *
  * @param Carbon     $start
  * @param Carbon     $end
  * @param Collection $accounts
  *
  * @return Income
  */
 public function getIncomeReport($start, $end, Collection $accounts)
 {
     $object = new Income();
     $set = $this->query->income($accounts, $start, $end);
     foreach ($set as $entry) {
         $object->addToTotal($entry->journalAmount);
         $object->addOrCreateIncome($entry);
     }
     return $object;
 }
Пример #2
0
 /**
  * @param ReportQueryInterface $reportQuery
  *
  * @param ARI                  $accountRepository
  *
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function boxIn(ReportQueryInterface $reportQuery, ARI $accountRepository)
 {
     $start = Session::get('start', Carbon::now()->startOfMonth());
     $end = Session::get('end', Carbon::now()->endOfMonth());
     // works for json too!
     $cache = new CacheProperties();
     $cache->addProperty($start);
     $cache->addProperty($end);
     $cache->addProperty('box-in');
     if ($cache->has()) {
         return Response::json($cache->get());
         // @codeCoverageIgnore
     }
     $accounts = $accountRepository->getAccounts(['Default account', 'Asset account', 'Cash account']);
     $amount = $reportQuery->income($accounts, $start, $end)->sum('journalAmount');
     $data = ['box' => 'in', 'amount' => Amount::format($amount, false), 'amount_raw' => $amount];
     $cache->store($data);
     return Response::json($data);
 }