Exemplo n.º 1
0
 /**
  * @param Carbon     $start
  * @param Carbon     $end
  * @param Collection $accounts
  *
  * @return CategoryCollection
  */
 public function getCategoryReport(Carbon $start, Carbon $end, Collection $accounts)
 {
     $object = new CategoryCollection();
     /**
      * GET CATEGORIES:
      */
     /** @var \FireflyIII\Repositories\Category\CategoryRepositoryInterface $repository */
     $repository = app('FireflyIII\\Repositories\\Category\\CategoryRepositoryInterface');
     $set = $repository->spentForAccountsPerMonth($accounts, $start, $end);
     foreach ($set as $category) {
         $object->addCategory($category);
     }
     return $object;
 }
Exemplo n.º 2
0
 /**
  * @param Carbon     $start
  * @param Carbon     $end
  * @param Collection $accounts
  *
  * @return CategoryCollection
  */
 public function getCategoryReport(Carbon $start, Carbon $end, Collection $accounts) : CategoryCollection
 {
     $object = new CategoryCollection();
     /** @var CategoryRepositoryInterface $repository */
     $repository = app(CategoryRepositoryInterface::class);
     $categories = $repository->getCategories();
     /** @var Category $category */
     foreach ($categories as $category) {
         $spent = $repository->spentInPeriod(new Collection([$category]), $accounts, $start, $end);
         // CategoryCollection expects the amount in $spent:
         $category->spent = $spent;
         $object->addCategory($category);
     }
     return $object;
 }
Exemplo n.º 3
0
 /**
  * @param Carbon  $start
  * @param Carbon  $end
  * @param boolean $shared
  *
  * @return CategoryCollection
  */
 public function getCategoryReport(Carbon $start, Carbon $end, $shared)
 {
     $object = new CategoryCollection();
     /**
      * GET CATEGORIES:
      */
     /** @var \FireflyIII\Repositories\Category\CategoryRepositoryInterface $repository */
     $repository = app('FireflyIII\\Repositories\\Category\\CategoryRepositoryInterface');
     $set = $repository->getCategories();
     foreach ($set as $category) {
         $spent = $repository->balanceInPeriod($category, $start, $end, $shared);
         $category->spent = $spent;
         $object->addCategory($category);
         $object->addTotal($spent);
     }
     return $object;
 }