Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Expanded report for categories.
James Cole18eba0202612
diff --git a/app/Helpers/Report/ReportHelper.php b/app/Helpers/Report/ReportHelper.phpindex 1d35ea7e6e..d5aa35acc9 100644--- a/app/Helpers/Report/ReportHelper.php+++ b/app/Helpers/Report/ReportHelper.php@@ -325,6 +325,33 @@ class ReportHelper implements ReportHelperInterfacereturn $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.*diff --git a/app/Helpers/Report/ReportHelperInterface.php b/app/Helpers/Report/ReportHelperInterface.phpindex 9d4c05a331..54fd8b0c31 100644--- a/app/Helpers/Report/ReportHelperInterface.php+++ b/app/Helpers/Report/ReportHelperInterface.php@@ -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.*diff --git a/app/Http/Controllers/ReportController.php b/app/Http/Controllers/ReportController.phpindex 7cb84f7145..82a3624459 100644--- a/app/Http/Controllers/ReportController.php+++ b/app/Http/Controllers/ReportController.php@@ -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);diff --git a/app/Repositories/Category/CategoryRepository.php b/app/Repositories/Category/CategoryRepository.phpindex 0055789a4a..95e76fda6d 100644--- a/app/Repositories/Category/CategoryRepository.php+++ b/app/Repositories/Category/CategoryRepository.php@@ -191,6 +191,19 @@ class CategoryRepository extends ComponentRepository implements CategoryRepositoreturn $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 CategoryRepositoreturn $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 CategoryRepositoreturn $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);diff --git a/app/Repositories/Category/CategoryRepositoryInterface.php b/app/Repositories/Category/CategoryRepositoryInterface.phpindex e424927fc8..62a4516d7b 100644--- a/app/Repositories/Category/CategoryRepositoryInterface.php+++ b/app/Repositories/Category/CategoryRepositoryInterface.php@@ -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