mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Expand tag view.
This commit is contained in:
parent
989e931edf
commit
50837af607
@ -171,7 +171,6 @@ class TagController extends Controller
|
||||
}
|
||||
$count = $repository->count();
|
||||
|
||||
|
||||
return view('tags.index', compact('clouds', 'count'));
|
||||
}
|
||||
|
||||
@ -205,6 +204,7 @@ class TagController extends Controller
|
||||
$start = $repository->firstUseDate($tag);
|
||||
$end = new Carbon;
|
||||
$sum = $repository->sumOfTag($tag, null, null);
|
||||
$result = $repository->resultOfTag($tag, null, null);
|
||||
$path = route('tags.show', [$tag->id, 'all']);
|
||||
}
|
||||
|
||||
@ -219,6 +219,7 @@ class TagController extends Controller
|
||||
);
|
||||
$periods = $this->getPeriodOverview($tag);
|
||||
$sum = $repository->sumOfTag($tag, $start, $end);
|
||||
$result = $repository->resultOfTag($tag, $start, $end);
|
||||
$path = route('tags.show', [$tag->id, $moment]);
|
||||
}
|
||||
|
||||
@ -227,6 +228,8 @@ class TagController extends Controller
|
||||
$start = clone session('start', Navigation::startOfPeriod(new Carbon, $range));
|
||||
$end = clone session('end', Navigation::endOfPeriod(new Carbon, $range));
|
||||
$periods = $this->getPeriodOverview($tag);
|
||||
$sum = $repository->sumOfTag($tag, $start, $end);
|
||||
$result = $repository->resultOfTag($tag, $start, $end);
|
||||
$subTitle = trans(
|
||||
'firefly.journals_in_period_for_tag',
|
||||
['tag' => $tag->tag, 'start' => $start->formatLocalized($this->monthAndDayFormat), 'end' => $end->formatLocalized($this->monthAndDayFormat)]
|
||||
@ -241,7 +244,7 @@ class TagController extends Controller
|
||||
$journals->setPath($path);
|
||||
|
||||
|
||||
return view('tags.show', compact('apiKey', 'tag', 'periods', 'subTitle', 'subTitleIcon', 'journals', 'sum', 'start', 'end', 'moment'));
|
||||
return view('tags.show', compact('apiKey', 'tag', 'result', 'periods', 'subTitle', 'subTitleIcon', 'journals', 'sum', 'start', 'end', 'moment'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -262,6 +262,34 @@ class TagRepository implements TagRepositoryInterface
|
||||
return strval($sum);
|
||||
}
|
||||
|
||||
/**
|
||||
* Same as sum of tag but substracts income instead of adding it as well.
|
||||
*
|
||||
* @param Tag $tag
|
||||
* @param Carbon|null $start
|
||||
* @param Carbon|null $end
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function resultOfTag(Tag $tag, ?Carbon $start, ?Carbon $end): string
|
||||
{
|
||||
/** @var JournalCollectorInterface $collector */
|
||||
$collector = app(JournalCollectorInterface::class);
|
||||
|
||||
if (!is_null($start) && !is_null($end)) {
|
||||
$collector->setRange($start, $end);
|
||||
}
|
||||
|
||||
$collector->setAllAssetAccounts()->setTag($tag);
|
||||
$journals = $collector->getJournals();
|
||||
$sum = '0';
|
||||
foreach ($journals as $journal) {
|
||||
$sum = bcadd($sum, strval($journal->transaction_amount));
|
||||
}
|
||||
|
||||
return strval($sum);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a tag cloud.
|
||||
*
|
||||
|
@ -108,6 +108,15 @@ interface TagRepositoryInterface
|
||||
*/
|
||||
public function setUser(User $user);
|
||||
|
||||
/**
|
||||
* @param Tag $tag
|
||||
* @param Carbon|null $start
|
||||
* @param Carbon|null $end
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function resultOfTag(Tag $tag, ?Carbon $start, ?Carbon $end): string;
|
||||
|
||||
/**
|
||||
* @param Tag $tag
|
||||
* @param Carbon $start
|
||||
|
@ -311,6 +311,7 @@ return [
|
||||
'meta_data' => 'Meta data',
|
||||
'location' => 'Location',
|
||||
'without_date' => 'Without date',
|
||||
'result' => 'Result',
|
||||
|
||||
// preferences
|
||||
'pref_home_screen_accounts' => 'Home screen accounts',
|
||||
|
@ -40,10 +40,12 @@
|
||||
{% if moment == 'all' %}
|
||||
<p>
|
||||
{{ 'total_sum'|_ }}: {{ sum|formatAmount }}<br/>
|
||||
{{ 'total_result'|_ }}: {{ result|formatAmount }}<br/>
|
||||
</p>
|
||||
{% else %}
|
||||
<p>
|
||||
{{ 'sum'|_ }}: {{ sum|formatAmount }}<br/>
|
||||
{{ 'result'|_ }}: {{ result|formatAmount }}<br/>
|
||||
</p>
|
||||
{% endif %}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user