mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Expanded report for categories.
This commit is contained in:
parent
d4690ce580
commit
18eba02026
@ -325,6 +325,33 @@ class ReportHelper implements ReportHelperInterface
|
||||
return $object;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param Collection $accounts
|
||||
*
|
||||
* @return CategoryCollection
|
||||
*/
|
||||
public function getCategoryReportForList(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->getCategories();
|
||||
foreach ($set as $category) {
|
||||
$spent = $repository->balanceInPeriodForList($category, $start, $end, $accounts);
|
||||
$category->spent = $spent;
|
||||
$object->addCategory($category);
|
||||
$object->addTotal($spent);
|
||||
}
|
||||
|
||||
return $object;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a full report on the users expenses during the period.
|
||||
*
|
||||
|
@ -91,6 +91,15 @@ interface ReportHelperInterface
|
||||
*/
|
||||
public function getCategoryReport(Carbon $start, Carbon $end, $shared);
|
||||
|
||||
/**
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param Collection $accounts
|
||||
*
|
||||
* @return CategoryCollection
|
||||
*/
|
||||
public function getCategoryReportForList(Carbon $start, Carbon $end, Collection $accounts);
|
||||
|
||||
/**
|
||||
* Get a full report on the users expenses during the period.
|
||||
*
|
||||
|
@ -241,11 +241,11 @@ class ReportController extends Controller
|
||||
$expenseTopLength = 8;
|
||||
|
||||
// get report stuff!
|
||||
$accounts = $this->helper->getAccountReportForList($start, $end, $list);
|
||||
$incomes = $this->helper->getIncomeReportForList($start, $end, $list);
|
||||
$expenses = $this->helper->getExpenseReportForList($start, $end, $list);
|
||||
$budgets = $this->helper->getBudgetReportForList($start, $end, $list);
|
||||
// $categories = $this->helper->getCategoryReportForList($start, $end, $list);
|
||||
$accounts = $this->helper->getAccountReportForList($start, $end, $list);
|
||||
$incomes = $this->helper->getIncomeReportForList($start, $end, $list);
|
||||
$expenses = $this->helper->getExpenseReportForList($start, $end, $list);
|
||||
$budgets = $this->helper->getBudgetReportForList($start, $end, $list);
|
||||
$categories = $this->helper->getCategoryReportForList($start, $end, $list);
|
||||
// $balance = $this->helper->getBalanceReportForList($start, $end, $list);
|
||||
// $bills = $this->helper->getBillReportForList($start, $end);
|
||||
|
||||
|
@ -191,6 +191,19 @@ class CategoryRepository extends ComponentRepository implements CategoryReposito
|
||||
return $this->commonBalanceInPeriod($category, $start, $end, $shared);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Category $category
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param Collection $accounts
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function balanceInPeriodForList(Category $category, Carbon $start, Carbon $end, Collection $accounts)
|
||||
{
|
||||
return $this->commonBalanceInPeriodForList($category, $start, $end, $accounts);
|
||||
}
|
||||
|
||||
/**
|
||||
* Corrected for tags
|
||||
*
|
||||
@ -286,9 +299,10 @@ class CategoryRepository extends ComponentRepository implements CategoryReposito
|
||||
return $cache->get(); // @codeCoverageIgnore
|
||||
}
|
||||
|
||||
$sum = $category->transactionjournals()->transactionTypes([TransactionType::WITHDRAWAL])->before($end)->after($start)->get(['transaction_journals.*'])->sum(
|
||||
'amount'
|
||||
);
|
||||
$sum = $category->transactionjournals()->transactionTypes([TransactionType::WITHDRAWAL])->before($end)->after($start)->get(['transaction_journals.*'])
|
||||
->sum(
|
||||
'amount'
|
||||
);
|
||||
|
||||
$cache->store($sum);
|
||||
|
||||
@ -316,9 +330,10 @@ class CategoryRepository extends ComponentRepository implements CategoryReposito
|
||||
return $cache->get(); // @codeCoverageIgnore
|
||||
}
|
||||
|
||||
$sum = $category->transactionjournals()->transactionTypes([TransactionType::DEPOSIT])->before($end)->after($start)->get(['transaction_journals.*'])->sum(
|
||||
'amount'
|
||||
);
|
||||
$sum = $category->transactionjournals()->transactionTypes([TransactionType::DEPOSIT])->before($end)->after($start)->get(['transaction_journals.*'])
|
||||
->sum(
|
||||
'amount'
|
||||
);
|
||||
|
||||
$cache->store($sum);
|
||||
|
||||
|
@ -77,8 +77,8 @@ interface CategoryRepositoryInterface
|
||||
* limited by a start or end date.
|
||||
*
|
||||
* @param Category $category
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
@ -112,6 +112,19 @@ interface CategoryRepositoryInterface
|
||||
*/
|
||||
public function balanceInPeriod(Category $category, Carbon $start, Carbon $end, $shared = false);
|
||||
|
||||
|
||||
/**
|
||||
* Corrected for tags.
|
||||
*
|
||||
* @param Category $category
|
||||
* @param \Carbon\Carbon $start
|
||||
* @param \Carbon\Carbon $end
|
||||
* @param Collection $accounts
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function balanceInPeriodForList(Category $category, Carbon $start, Carbon $end, Collection $accounts);
|
||||
|
||||
/**
|
||||
* @param Category $category
|
||||
* @param \Carbon\Carbon $start
|
||||
|
Loading…
Reference in New Issue
Block a user