Some cleaning up and more charts.

This commit is contained in:
James Cole
2016-04-26 09:21:57 +02:00
parent 01cab599bb
commit d551333fa2
15 changed files with 150 additions and 18 deletions

View File

@@ -11,6 +11,7 @@ use FireflyIII\Helpers\Collection\Expense;
use FireflyIII\Helpers\Collection\Income;
use FireflyIII\Helpers\FiscalHelperInterface;
use FireflyIII\Models\Bill;
use FireflyIII\Models\Category;
use FireflyIII\Models\Tag;
use FireflyIII\Models\TransactionJournal;
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
@@ -311,4 +312,30 @@ class ReportHelper implements ReportHelperInterface
return $sum;
}
/**
* @param Carbon $start
* @param Carbon $end
* @param Collection $accounts
*
* @return Collection
*/
public function getCategoriesWithExpenses(Carbon $start, Carbon $end, Collection $accounts): Collection
{
/** @var \FireflyIII\Repositories\Category\CategoryRepositoryInterface $repository */
$repository = app('FireflyIII\Repositories\Category\CategoryRepositoryInterface');
$collection = $repository->earnedForAccountsPerMonth($accounts, $start, $end);
$second = $repository->spentForAccountsPerMonth($accounts, $start, $end);
$collection = $collection->merge($second);
$array = [];
/** @var Category $category */
foreach ($collection as $category) {
$id = $category->id;
$array[$id] = $category;
}
$set = new Collection($array);
return $set;
}
}

View File

@@ -81,4 +81,14 @@ interface ReportHelperInterface
*/
public function tagReport(Carbon $start, Carbon $end, Collection $accounts): array;
/**
* @param Carbon $start
* @param Carbon $end
* @param Collection $accounts
*
* @return Collection
*/
public function getCategoriesWithExpenses(Carbon $start, Carbon $end, Collection $accounts): Collection;
}