Skip to content

Firefly III: a personal finances manager

Merge branch 'develop' of github.com:firefly-iii/firefly-iii into develop

James Cole8a06c0f7ec32
diff --cc app/Support/Http/Controllers/PeriodOverview.php
index 1995bc15c8,b87dda9531..9cdf54d6e3
--- a/app/Support/Http/Controllers/PeriodOverview.php
+++ b/app/Support/Http/Controllers/PeriodOverview.php
@@@ -91,15 -87,14 +91,15 @@@ trait PeriodOvervie
{
Log::debug(sprintf('Now in getAccountPeriodOverview(#%d, %s %s)', $account->id, $start->format('Y-m-d H:i:s.u'), $end->format('Y-m-d H:i:s.u')));
$this->accountRepository = app(AccountRepositoryInterface::class);
+ $this->accountRepository->setUser($account->user);
$this->periodStatisticRepo = app(PeriodStatisticRepositoryInterface::class);
$range = Navigation::getViewRange(true);
- [$start, $end] = $end < $start ? [$end, $start] : [$start, $end];
+ [$start, $end] = $end < $start ? [$end, $start] : [$start, $end];
/** @var array $dates */
- $dates = Navigation::blockPeriods($start, $end, $range);
- [$start, $end] = $this->getPeriodFromBlocks($dates, $start, $end);
- $this->statistics = $this->periodStatisticRepo->allInRangeForModel($account, $start, $end);
+ $dates = Navigation::blockPeriods($start, $end, $range);
+ [$start, $end] = $this->getPeriodFromBlocks($dates, $start, $end);
+ $this->statistics = $this->periodStatisticRepo->allInRangeForModel($account, $start, $end);
// TODO needs to be re-arranged:
// get all period stats for entire range.
@@@ -143,31 -138,28 +143,30 @@@
*/
protected function getCategoryPeriodOverview(Category $category, Carbon $start, Carbon $end): array
{
- $range = Navigation::getViewRange(true);
+ $this->categoryRepository = app(CategoryRepositoryInterface::class);
+ $this->categoryRepository->setUser($category->user);
+ $this->periodStatisticRepo = app(PeriodStatisticRepositoryInterface::class);
+
+ $range = Navigation::getViewRange(true);
[$start, $end] = $end < $start ? [$end, $start] : [$start, $end];
- // properties for entries with their amounts.
- $cache = new CacheProperties();
- $cache->addProperty($start);
- $cache->addProperty($end);
- $cache->addProperty($range);
- $cache->addProperty('category-show-period-entries');
- $cache->addProperty($category->id);
+ /** @var array $dates */
+ $dates = Navigation::blockPeriods($start, $end, $range);
+ $entries = [];
+ [$start, $end] = $this->getPeriodFromBlocks($dates, $start, $end);
+ $this->statistics = $this->periodStatisticRepo->allInRangeForModel($category, $start, $end);
- if ($cache->has()) {
- return $cache->get();
+
+ Log::debug(sprintf('Count of loops: %d', count($dates)));
+ foreach ($dates as $currentDate) {
+ $entries[] = $this->getSingleCategoryPeriod($category, $currentDate['period'], $currentDate['start'], $currentDate['end']);
}
- /** @var array $dates */
- $dates = Navigation::blockPeriods($start, $end, $range);
- $entries = [];
+ return $entries;
-
// collect all expenses in this period:
/** @var GroupCollectorInterface $collector */
- $collector = app(GroupCollectorInterface::class);
+ $collector = app(GroupCollectorInterface::class);
$collector->setCategory($category);
$collector->setRange($start, $end);
$collector->setTypes([TransactionTypeEnum::DEPOSIT->value]);
@@@ -195,18 -187,19 +194,18 @@@
$title = Navigation::periodShow($currentDate['end'], $currentDate['period']);
$entries[]
= [
- 'transactions' => 0,
- 'title' => $title,
- 'route' => route(
- 'categories.show',
- [$category->id, $currentDate['start']->format('Y-m-d'), $currentDate['end']->format('Y-m-d')]
- ),
- 'total_transactions' => count($spent) + count($earned) + count($transferred),
- 'spent' => $this->groupByCurrency($spent),
- 'earned' => $this->groupByCurrency($earned),
- 'transferred' => $this->groupByCurrency($transferred),
- ];
+ 'transactions' => 0,
+ 'title' => $title,
+ 'route' => route(
+ 'categories.show',
+ [$category->id, $currentDate['start']->format('Y-m-d'), $currentDate['end']->format('Y-m-d')]
+ ),
+ 'total_transactions' => count($spent) + count($earned) + count($transferred),
+ 'spent' => $this->groupByCurrency($spent),
+ 'earned' => $this->groupByCurrency($earned),
+ 'transferred' => $this->groupByCurrency($transferred),
+ ];
}
- $cache->store($entries);
return $entries;
}