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