diff --git a/app/Http/Controllers/Budget/ShowController.php b/app/Http/Controllers/Budget/ShowController.php index 4347702490..170cf4ec19 100644 --- a/app/Http/Controllers/Budget/ShowController.php +++ b/app/Http/Controllers/Budget/ShowController.php @@ -88,7 +88,7 @@ class ShowController extends Controller 'firefly.without_budget_between', ['start' => $start->formatLocalized($this->monthAndDayFormat), 'end' => $end->formatLocalized($this->monthAndDayFormat)] ); - $periods = $this->getBudgetPeriodOverview($end); + $periods = $this->getNoBudgetPeriodOverview($end); $page = (int)$request->get('page'); $pageSize = (int)app('preferences')->get('listPageSize', 50)->data; diff --git a/app/Http/Controllers/Chart/CategoryController.php b/app/Http/Controllers/Chart/CategoryController.php index 7e6a17eefd..411ff6cad0 100644 --- a/app/Http/Controllers/Chart/CategoryController.php +++ b/app/Http/Controllers/Chart/CategoryController.php @@ -32,6 +32,7 @@ use FireflyIII\Repositories\Account\AccountRepositoryInterface; use FireflyIII\Repositories\Category\CategoryRepositoryInterface; use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface; use FireflyIII\Support\CacheProperties; +use FireflyIII\Support\Http\Controllers\DateCalculation; use Illuminate\Http\JsonResponse; use Illuminate\Support\Collection; @@ -40,6 +41,7 @@ use Illuminate\Support\Collection; */ class CategoryController extends Controller { + use DateCalculation; /** @var GeneratorInterface Chart generation methods. */ protected $generator; @@ -97,17 +99,36 @@ class CategoryController extends Controller 'entries' => [], 'type' => 'line', 'fill' => false, ], ]; - - while ($start <= $end) { - $currentEnd = app('navigation')->endOfPeriod($start, $range); - $spent = $repository->spentInPeriod(new Collection([$category]), $accounts, $start, $currentEnd); - $earned = $repository->earnedInPeriod(new Collection([$category]), $accounts, $start, $currentEnd); - $sum = bcadd($spent, $earned); - $label = app('navigation')->periodShow($start, $range); - $chartData[0]['entries'][$label] = round(bcmul($spent, '-1'), 12); - $chartData[1]['entries'][$label] = round($earned, 12); - $chartData[2]['entries'][$label] = round($sum, 12); - $start = app('navigation')->addPeriod($start, $range, 0); + $step = $this->calculateStep($start, $end); + $current = clone $start; + switch ($step) { + case '1D': + while ($current <= $end) { + $spent = $repository->spentInPeriod(new Collection([$category]), $accounts, $current, $current); + $earned = $repository->earnedInPeriod(new Collection([$category]), $accounts, $current, $current); + $sum = bcadd($spent, $earned); + $label = app('navigation')->periodShow($current, $step); + $chartData[0]['entries'][$label] = round(bcmul($spent, '-1'), 12); + $chartData[1]['entries'][$label] = round($earned, 12); + $chartData[2]['entries'][$label] = round($sum, 12); + $current->addDay(); + } + break; + case '1W': + case '1M': + case '1Y': + while ($current <= $end) { + $currentEnd = app('navigation')->endOfPeriod($current, $range); + $spent = $repository->spentInPeriod(new Collection([$category]), $accounts, $current, $currentEnd); + $earned = $repository->earnedInPeriod(new Collection([$category]), $accounts, $current, $currentEnd); + $sum = bcadd($spent, $earned); + $label = app('navigation')->periodShow($current, $step); + $chartData[0]['entries'][$label] = round(bcmul($spent, '-1'), 12); + $chartData[1]['entries'][$label] = round($earned, 12); + $chartData[2]['entries'][$label] = round($sum, 12); + $current= app('navigation')->addPeriod($current, $step, 0); + } + break; } $data = $this->generator->multiSet($chartData); @@ -135,7 +156,7 @@ class CategoryController extends Controller $cache->addProperty($end); $cache->addProperty('chart.category.frontpage'); if ($cache->has()) { - //return response()->json($cache->get()); // @codeCoverageIgnore + return response()->json($cache->get()); // @codeCoverageIgnore } // currency repos: @@ -168,7 +189,7 @@ class CategoryController extends Controller $noCategory = $repository->spentInPeriodPcWoCategory(new Collection, $start, $end); foreach ($noCategory as $currencyId => $spent) { $currencies[$currencyId] = $currencies[$currencyId] ?? $currencyRepository->findNull($currencyId); - $tempData[] = [ + $tempData[] = [ 'name' => trans('firefly.no_category'), 'spent' => bcmul($spent, '-1'), 'spent_float' => (float)bcmul($spent, '-1'), diff --git a/app/Http/Controllers/TagController.php b/app/Http/Controllers/TagController.php index a2731043dc..7dba1172fa 100644 --- a/app/Http/Controllers/TagController.php +++ b/app/Http/Controllers/TagController.php @@ -192,7 +192,7 @@ class TagController extends Controller 'firefly.journals_in_period_for_tag', ['tag' => $tag->tag, 'start' => $start->formatLocalized($this->monthAndDayFormat), 'end' => $end->formatLocalized($this->monthAndDayFormat),] ); - $periods = $this->getTagPeriodOverview($tag); + $periods = $this->getTagPeriodOverview($tag, $start); $path = route('tags.show', [$tag->id, $start->format('Y-m-d'), $end->format('Y-m-d')]); /** @var TransactionCollectorInterface $collector */ diff --git a/app/Repositories/Tag/TagRepository.php b/app/Repositories/Tag/TagRepository.php index 928bd97b0f..3a9b261bfd 100644 --- a/app/Repositories/Tag/TagRepository.php +++ b/app/Repositories/Tag/TagRepository.php @@ -92,6 +92,23 @@ class TagRepository implements TagRepositoryInterface return (string)$set->sum('transaction_amount'); } + /** + * @param Tag $tag + * @param Carbon $start + * @param Carbon $end + * + * @return Collection + */ + public function expenseInPeriod(Tag $tag, Carbon $start, Carbon $end): Collection + { + /** @var TransactionCollectorInterface $collector */ + $collector = app(TransactionCollectorInterface::class); + $collector->setUser($this->user); + $collector->setRange($start, $end)->setTypes([TransactionType::WITHDRAWAL])->setAllAssetAccounts()->setTag($tag); + + return $collector->getTransactions(); + } + /** * @param string $tag * @@ -151,6 +168,23 @@ class TagRepository implements TagRepositoryInterface return $tags; } + /** + * @param Tag $tag + * @param Carbon $start + * @param Carbon $end + * + * @return Collection + */ + public function incomeInPeriod(Tag $tag, Carbon $start, Carbon $end): Collection + { + /** @var TransactionCollectorInterface $collector */ + $collector = app(TransactionCollectorInterface::class); + $collector->setUser($this->user); + $collector->setRange($start, $end)->setTypes([TransactionType::DEPOSIT])->setAllAssetAccounts()->setTag($tag); + + return $collector->getTransactions(); + } + /** * @param Tag $tag * @@ -315,6 +349,23 @@ class TagRepository implements TagRepositoryInterface return $return; } + /** + * @param Tag $tag + * @param Carbon $start + * @param Carbon $end + * + * @return Collection + */ + public function transferredInPeriod(Tag $tag, Carbon $start, Carbon $end): Collection + { + /** @var TransactionCollectorInterface $collector */ + $collector = app(TransactionCollectorInterface::class); + $collector->setUser($this->user); + $collector->setRange($start, $end)->setTypes([TransactionType::TRANSFER])->setAllAssetAccounts()->setTag($tag); + + return $collector->getTransactions(); + } + /** * @param Tag $tag * @param array $data diff --git a/app/Repositories/Tag/TagRepositoryInterface.php b/app/Repositories/Tag/TagRepositoryInterface.php index bedfef3cb7..223b61e22c 100644 --- a/app/Repositories/Tag/TagRepositoryInterface.php +++ b/app/Repositories/Tag/TagRepositoryInterface.php @@ -55,6 +55,15 @@ interface TagRepositoryInterface */ public function earnedInPeriod(Tag $tag, Carbon $start, Carbon $end): string; + /** + * @param Tag $tag + * @param Carbon $start + * @param Carbon $end + * + * @return Collection + */ + public function expenseInPeriod(Tag $tag, Carbon $start, Carbon $end): Collection; + /** * @param string $tag * @@ -83,6 +92,15 @@ interface TagRepositoryInterface */ public function get(): Collection; + /** + * @param Tag $tag + * @param Carbon $start + * @param Carbon $end + * + * @return Collection + */ + public function incomeInPeriod(Tag $tag, Carbon $start, Carbon $end): Collection; + /** * @param Tag $tag * @@ -147,6 +165,15 @@ interface TagRepositoryInterface */ public function tagCloud(?int $year): array; + /** + * @param Tag $tag + * @param Carbon $start + * @param Carbon $end + * + * @return Collection + */ + public function transferredInPeriod(Tag $tag, Carbon $start, Carbon $end): Collection; + /** * Update a tag. * diff --git a/app/Support/Http/Controllers/PeriodOverview.php b/app/Support/Http/Controllers/PeriodOverview.php index 93e302af63..5d92acdbf9 100644 --- a/app/Support/Http/Controllers/PeriodOverview.php +++ b/app/Support/Http/Controllers/PeriodOverview.php @@ -60,12 +60,14 @@ trait PeriodOverview * and for each period, the amount of money spent and earned. This is a complex operation which is cached for * performance reasons. * - * @param Account $account the account involved - * @param Carbon $date + * The method has been refactored recently for better performance. + * + * @param Account $account The account involved + * @param Carbon $date The start date. * * @return Collection */ - protected function getAccountPeriodOverview(Account $account, Carbon $date): Collection // period overview + protected function getAccountPeriodOverview(Account $account, Carbon $date): Collection { /** @var AccountRepositoryInterface $repository */ $repository = app(AccountRepositoryInterface::class); @@ -95,15 +97,15 @@ trait PeriodOverview $collector = app(TransactionCollectorInterface::class); $collector->setAccounts(new Collection([$account]))->setRange($currentDate['start'], $currentDate['end'])->setTypes([TransactionType::DEPOSIT]) ->withOpposingAccount(); - $set = $collector->getTransactions(); - $earned = $this->groupByCurrency($set); + $earnedSet = $collector->getTransactions(); + $earned = $this->groupByCurrency($earnedSet); /** @var TransactionCollectorInterface $collector */ $collector = app(TransactionCollectorInterface::class); $collector->setAccounts(new Collection([$account]))->setRange($currentDate['start'], $currentDate['end'])->setTypes([TransactionType::WITHDRAWAL]) ->withOpposingAccount(); - $set = $collector->getTransactions(); - $spent = $this->groupByCurrency($set); + $spentSet = $collector->getTransactions(); + $spent = $this->groupByCurrency($spentSet); $title = app('navigation')->periodShow($currentDate['start'], $currentDate['period']); /** @noinspection PhpUndefinedMethodInspection */ @@ -115,7 +117,6 @@ trait PeriodOverview 'earned' => $earned, 'transferred' => '0', 'route' => route('accounts.show', [$account->id, $currentDate['start']->format('Y-m-d'), $currentDate['end']->format('Y-m-d')]), - ] ); } @@ -126,11 +127,84 @@ trait PeriodOverview } /** - * Gets period overview used for budgets. + * Overview for single category. Has been refactored recently. + * + * @param Category $category + * @param Carbon $date * * @return Collection */ - protected function getBudgetPeriodOverview(Carbon $date): Collection + protected function getCategoryPeriodOverview(Category $category, Carbon $date): Collection + { + /** @var JournalRepositoryInterface $journalRepository */ + $journalRepository = app(JournalRepositoryInterface::class); + $range = app('preferences')->get('viewRange', '1M')->data; + $first = $journalRepository->firstNull(); + $end = null === $first ? new Carbon : $first->date; + $start = clone $date; + + if ($end < $start) { + [$start, $end] = [$end, $start]; // @codeCoverageIgnore + } + + // 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); + + if ($cache->has()) { + return $cache->get(); // @codeCoverageIgnore + } + /** @var array $dates */ + $dates = app('navigation')->blockPeriods($start, $end, $range); + $entries = new Collection; + /** @var CategoryRepositoryInterface $categoryRepository */ + $categoryRepository = app(CategoryRepositoryInterface::class); + + foreach ($dates as $currentDate) { + $spent = $categoryRepository->spentInPeriodCollection(new Collection([$category]), new Collection, $currentDate['start'], $currentDate['end']); + $earned = $categoryRepository->earnedInPeriodCollection(new Collection([$category]), new Collection, $currentDate['start'], $currentDate['end']); + $spent = $this->groupByCurrency($spent); + $earned = $this->groupByCurrency($earned); + + // amount transferred + /** @var TransactionCollectorInterface $collector */ + $collector = app(TransactionCollectorInterface::class); + $collector->setAllAssetAccounts()->setRange($currentDate['start'], $currentDate['end'])->setCategory($category) + ->withOpposingAccount()->setTypes([TransactionType::TRANSFER]); + $collector->removeFilter(InternalTransferFilter::class); + $transferred = $this->groupByCurrency($collector->getTransactions()); + + $title = app('navigation')->periodShow($currentDate['end'], $currentDate['period']); + $entries->push( + [ + 'transactions' => 0, + 'title' => $title, + 'spent' => $spent, + 'earned' => $earned, + 'transferred' => $transferred, + 'route' => route('categories.show', [$category->id, $currentDate['start']->format('Y-m-d'), $currentDate['end']->format('Y-m-d')]), + ] + ); + } + $cache->store($entries); + + return $entries; + } + + /** + * Same as above, but for lists that involve transactions without a budget. + * + * This method has been refactored recently. + * + * @param Carbon $date + * + * @return Collection + */ + protected function getNoBudgetPeriodOverview(Carbon $date): Collection { /** @var JournalRepositoryInterface $repository */ $repository = app(JournalRepositoryInterface::class); @@ -138,8 +212,12 @@ trait PeriodOverview $end = null === $first ? new Carbon : $first->date; $start = clone $date; $range = app('preferences')->get('viewRange', '1M')->data; - $entries = new Collection; - $cache = new CacheProperties; + + if ($end < $start) { + [$start, $end] = [$end, $start]; // @codeCoverageIgnore + } + + $cache = new CacheProperties; $cache->addProperty($start); $cache->addProperty($end); $cache->addProperty('no-budget-period-entries'); @@ -149,7 +227,8 @@ trait PeriodOverview } /** @var array $dates */ - $dates = app('navigation')->blockPeriods($start, $end, $range); + $dates = app('navigation')->blockPeriods($start, $end, $range); + $entries = new Collection; foreach ($dates as $currentDate) { /** @var TransactionCollectorInterface $collector */ $collector = app(TransactionCollectorInterface::class); @@ -162,12 +241,12 @@ trait PeriodOverview $title = app('navigation')->periodShow($currentDate['end'], $currentDate['period']); $entries->push( [ - 'route' => route('budgets.no-budget', [$currentDate['start']->format('Y-m-d'), $currentDate['end']->format('Y-m-d')]), 'transactions' => $count, 'title' => $title, 'spent' => $spent, 'earned' => '0', 'transferred' => '0', + 'route' => route('budgets.no-budget', [$currentDate['start']->format('Y-m-d'), $currentDate['end']->format('Y-m-d')]), ] ); } @@ -177,133 +256,70 @@ trait PeriodOverview } /** - * Get a period overview for category. - * - * TODO refactor me. - * - * @param Category $category - * @param Carbon $date - * - * @return Collection - */ - protected function getCategoryPeriodOverview(Category $category, Carbon $date): Collection // periodOverview method - { - /** @var JournalRepositoryInterface $journalRepository */ - $journalRepository = app(JournalRepositoryInterface::class); - /** @var CategoryRepositoryInterface $categoryRepository */ - $categoryRepository = app(CategoryRepositoryInterface::class); - - - $range = app('preferences')->get('viewRange', '1M')->data; - $first = $journalRepository->firstNull(); - $end = null === $first ? new Carbon : $first->date; - $start = clone $date; - - // properties for entries with their amounts. - $cache = new CacheProperties(); - $cache->addProperty($start); - $cache->addProperty($end); - $cache->addProperty($range); - $cache->addProperty('categories.entries'); - $cache->addProperty($category->id); - - if ($cache->has()) { - //return $cache->get(); // @codeCoverageIgnore - } - /** @var array $dates */ - $dates = app('navigation')->blockPeriods($start, $end, $range); - $entries = new Collection; - - foreach ($dates as $currentDate) { - $spent = $categoryRepository->spentInPeriodCollection(new Collection([$category]), new Collection, $currentDate['start'], $currentDate['end']); - $earned = $categoryRepository->earnedInPeriodCollection(new Collection([$category]), new Collection, $currentDate['start'], $currentDate['end']); - $spent = $this->groupByCurrency($spent); - $earned = $this->groupByCurrency($earned); - // amount transferred - /** @var TransactionCollectorInterface $collector */ - $collector = app(TransactionCollectorInterface::class); - $collector->setAllAssetAccounts()->setRange($currentDate['start'], $currentDate['end'])->setCategory($category) - ->withOpposingAccount()->setTypes([TransactionType::TRANSFER]); - $collector->removeFilter(InternalTransferFilter::class); - $transferred = $this->groupByCurrency($collector->getTransactions()); - $title = app('navigation')->periodShow($currentDate['end'], $currentDate['period']); - $entries->push( - [ - 'route' => route('categories.show', [$category->id, $currentDate['start']->format('Y-m-d'), $currentDate['end']->format('Y-m-d')]), - 'title' => $title, - 'spent' => $spent, - 'earned' => $earned, - 'transferred' => $transferred, - ] - ); - } - $cache->store($entries); - - return $entries; - } - - /** - * Get overview of periods for tag. - * - * TODO refactor this. + * This shows a period overview for a tag. It goes back in time and lists all relevant transactions and sums. * * @param Tag $tag * * @return Collection */ - protected function getTagPeriodOverview(Tag $tag): Collection // period overview for tags. + protected function getTagPeriodOverview(Tag $tag, Carbon $date): Collection // period overview for tags. { /** @var TagRepositoryInterface $repository */ $repository = app(TagRepositoryInterface::class); - // get first and last tag date from tag: - $range = app('preferences')->get('viewRange', '1M')->data; + $range = app('preferences')->get('viewRange', '1M')->data; /** @var Carbon $end */ - $end = app('navigation')->endOfX($repository->lastUseDate($tag) ?? new Carbon, $range, null); - $start = $repository->firstUseDate($tag) ?? new Carbon; + $start = clone $date; + $end = $repository->firstUseDate($tag) ?? new Carbon; + if ($end < $start) { + [$start, $end] = [$end, $start]; // @codeCoverageIgnore + } + // properties for entries with their amounts. $cache = new CacheProperties; $cache->addProperty($start); $cache->addProperty($end); - $cache->addProperty('tag.entries'); + $cache->addProperty('tag-period-entries'); $cache->addProperty($tag->id); if ($cache->has()) { return $cache->get(); // @codeCoverageIgnore } - $collection = new Collection; - $currentEnd = clone $end; + /** @var array $dates */ + $dates = app('navigation')->blockPeriods($start, $end, $range); + $entries = new Collection; // while end larger or equal to start - while ($currentEnd >= $start) { - $currentStart = app('navigation')->startOfPeriod($currentEnd, $range); + foreach ($dates as $currentDate) { - // get expenses and what-not in this period and this tag. - $arr = [ - 'string' => $end->format('Y-m-d'), - 'name' => app('navigation')->periodShow($currentEnd, $range), - 'start' => clone $currentStart, - 'end' => clone $currentEnd, - 'date' => clone $end, - 'spent' => $repository->spentInPeriod($tag, $currentStart, $currentEnd), - 'earned' => $repository->earnedInPeriod($tag, $currentStart, $currentEnd), - ]; - $collection->push($arr); + $spentSet = $repository->expenseInPeriod($tag, $currentDate['start'], $currentDate['end']); + $spent = $this->groupByCurrency($spentSet); + $earnedSet = $repository->incomeInPeriod($tag, $currentDate['start'], $currentDate['end']); + $earned = $this->groupByCurrency($earnedSet); + $transferredSet = $repository->transferredInPeriod($tag, $currentDate['start'], $currentDate['end']); + $transferred = $this->groupByCurrency($transferredSet); + $title = app('navigation')->periodShow($currentDate['end'], $currentDate['period']); + + $entries->push( + [ + 'transactions' => $spentSet->count() + $earnedSet->count() + $transferredSet->count(), + 'title' => $title, + 'spent' => $spent, + 'earned' => $earned, + 'transferred' => $transferred, + 'route' => route('tags.show', [$tag->id, $currentDate['start']->format('Y-m-d'), $currentDate['end']->format('Y-m-d')]), + ] + ); - /** @var Carbon $currentEnd */ - $currentEnd = clone $currentStart; - $currentEnd->subDay(); } - $cache->store($collection); + $cache->store($entries); - return $collection; + return $entries; } /** - * Get period overview for index. - * - * TODO refactor me. + * This list shows the overview of a type of transaction, for the period blocks on the list of transactions. * * @param string $what * @param Carbon $date @@ -315,42 +331,60 @@ trait PeriodOverview /** @var JournalRepositoryInterface $repository */ $repository = app(JournalRepositoryInterface::class); $range = app('preferences')->get('viewRange', '1M')->data; - $first = $repository->firstNull(); - $start = Carbon::now()->subYear(); + $endJournal = $repository->firstNull(); + $end = null === $endJournal ? new Carbon : $endJournal->date; + $start = clone $date; $types = config('firefly.transactionTypesByWhat.' . $what); - $entries = new Collection; - if (null !== $first) { - $start = $first->date; - } - if ($date < $start) { - [$start, $date] = [$date, $start]; // @codeCoverageIgnore + + + if ($end < $start) { + [$start, $end] = [$end, $start]; // @codeCoverageIgnore } + // properties for entries with their amounts. + $cache = new CacheProperties; + $cache->addProperty($start); + $cache->addProperty($end); + $cache->addProperty('transactions-period-entries'); + $cache->addProperty($what); + + /** @var array $dates */ - $dates = app('navigation')->blockPeriods($start, $date, $range); + $dates = app('navigation')->blockPeriods($start, $end, $range); + $entries = new Collection; foreach ($dates as $currentDate) { + + // get all expenses, income or transfers: /** @var TransactionCollectorInterface $collector */ $collector = app(TransactionCollectorInterface::class); $collector->setAllAssetAccounts()->setRange($currentDate['start'], $currentDate['end'])->withOpposingAccount()->setTypes($types); $collector->removeFilter(InternalTransferFilter::class); $transactions = $collector->getTransactions(); - - if ($transactions->count() > 0) { - $sums = $this->sumPerCurrency($transactions); - $dateName = app('navigation')->periodShow($currentDate['start'], $currentDate['period']); - $sum = $transactions->sum('transaction_amount'); - /** @noinspection PhpUndefinedMethodInspection */ - $entries->push( - [ - 'name' => $dateName, - 'sums' => $sums, - 'sum' => $sum, - 'start' => $currentDate['start']->format('Y-m-d'), - 'end' => $currentDate['end']->format('Y-m-d'), - ] - ); + $title = app('navigation')->periodShow($currentDate['end'], $currentDate['period']); + $grouped = $this->groupByCurrency($transactions); + $spent = []; + $earned = []; + $transferred = []; + if ('expenses' === $what || 'withdrawal' === $what) { + $spent = $grouped; } + if ('revenue' === $what || 'deposit' === $what) { + $earned = $grouped; + } + if ('transfer' === $what || 'transfers' === $what) { + $transferred = $grouped; + } + $entries->push( + [ + 'transactions' => $transactions->count(), + 'title' => $title, + 'spent' => $spent, + 'earned' => $earned, + 'transferred' => $transferred, + 'route' => route('transactions.index', [$what, $currentDate['start']->format('Y-m-d'), $currentDate['end']->format('Y-m-d')]), + ] + ); } return $entries; diff --git a/resources/views/list/periods.twig b/resources/views/list/periods.twig index 7e8f9cd72c..c718663582 100644 --- a/resources/views/list/periods.twig +++ b/resources/views/list/periods.twig @@ -41,4 +41,5 @@ + {% endfor %} \ No newline at end of file diff --git a/resources/views/tags/show.twig b/resources/views/tags/show.twig index 42f8b48b7f..1a8e1ca4b7 100644 --- a/resources/views/tags/show.twig +++ b/resources/views/tags/show.twig @@ -154,33 +154,7 @@ {% if periods.count > 0 %}
- {% for period in periods %} - {% if period.spent != 0 or period.earned != 0 %} -
- -
- - {% if period.spent != 0 %} - - - - - {% endif %} - {% if period.earned != 0 %} - - - - - {% endif %} -
{{ 'spent'|_ }}{{ period.spent|formatAmount }}
{{ 'earned'|_ }}{{ period.earned|formatAmount }}
-
-
- {% endif %} - - {% endfor %} + {% include 'list.periods' %}
{% endif %} diff --git a/resources/views/transactions/index.twig b/resources/views/transactions/index.twig index 5a55f2d527..310582b7fc 100644 --- a/resources/views/transactions/index.twig +++ b/resources/views/transactions/index.twig @@ -58,47 +58,7 @@ {# boxes with info #} {% if periods.count > 0 %}
- {% for period in periods %} - - {% if period.sum != 0 %} -
- -
- - - {% for sum in period.sums %} - - - - - {% endfor %} - -
- {% if what == 'withdrawal' %} - {{ 'spent'|_ }} - {% endif %} - {% if what == 'deposit' %} - {{ 'earned'|_ }} - {% endif %} - {% if what == 'transfers' or what == 'transfer' %} - {{ 'transferred'|_ }} - {% endif %} - - {% if what == 'transfers' or what == 'transfer' %} - - {{ formatAmountBySymbol(Steam.positive(sum.sum), sum.currency.symbol, sum.currency.dp, false) }} - - {% else %} - {{ formatAmountBySymbol(sum.sum, sum.currency.symbol, sum.currency.dp) }} - {% endif %} -
-
-
- {% endif %} - {% endfor %} + {% include 'list.periods' %}
{% endif %}