mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-12-12 01:42:32 +00:00
Expand tag view.
This commit is contained in:
@@ -171,7 +171,6 @@ class TagController extends Controller
|
|||||||
}
|
}
|
||||||
$count = $repository->count();
|
$count = $repository->count();
|
||||||
|
|
||||||
|
|
||||||
return view('tags.index', compact('clouds', 'count'));
|
return view('tags.index', compact('clouds', 'count'));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -205,6 +204,7 @@ class TagController extends Controller
|
|||||||
$start = $repository->firstUseDate($tag);
|
$start = $repository->firstUseDate($tag);
|
||||||
$end = new Carbon;
|
$end = new Carbon;
|
||||||
$sum = $repository->sumOfTag($tag, null, null);
|
$sum = $repository->sumOfTag($tag, null, null);
|
||||||
|
$result = $repository->resultOfTag($tag, null, null);
|
||||||
$path = route('tags.show', [$tag->id, 'all']);
|
$path = route('tags.show', [$tag->id, 'all']);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -219,6 +219,7 @@ class TagController extends Controller
|
|||||||
);
|
);
|
||||||
$periods = $this->getPeriodOverview($tag);
|
$periods = $this->getPeriodOverview($tag);
|
||||||
$sum = $repository->sumOfTag($tag, $start, $end);
|
$sum = $repository->sumOfTag($tag, $start, $end);
|
||||||
|
$result = $repository->resultOfTag($tag, $start, $end);
|
||||||
$path = route('tags.show', [$tag->id, $moment]);
|
$path = route('tags.show', [$tag->id, $moment]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -227,6 +228,8 @@ class TagController extends Controller
|
|||||||
$start = clone session('start', Navigation::startOfPeriod(new Carbon, $range));
|
$start = clone session('start', Navigation::startOfPeriod(new Carbon, $range));
|
||||||
$end = clone session('end', Navigation::endOfPeriod(new Carbon, $range));
|
$end = clone session('end', Navigation::endOfPeriod(new Carbon, $range));
|
||||||
$periods = $this->getPeriodOverview($tag);
|
$periods = $this->getPeriodOverview($tag);
|
||||||
|
$sum = $repository->sumOfTag($tag, $start, $end);
|
||||||
|
$result = $repository->resultOfTag($tag, $start, $end);
|
||||||
$subTitle = trans(
|
$subTitle = trans(
|
||||||
'firefly.journals_in_period_for_tag',
|
'firefly.journals_in_period_for_tag',
|
||||||
['tag' => $tag->tag, 'start' => $start->formatLocalized($this->monthAndDayFormat), 'end' => $end->formatLocalized($this->monthAndDayFormat)]
|
['tag' => $tag->tag, 'start' => $start->formatLocalized($this->monthAndDayFormat), 'end' => $end->formatLocalized($this->monthAndDayFormat)]
|
||||||
@@ -241,7 +244,7 @@ class TagController extends Controller
|
|||||||
$journals->setPath($path);
|
$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);
|
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.
|
* Generates a tag cloud.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -108,6 +108,15 @@ interface TagRepositoryInterface
|
|||||||
*/
|
*/
|
||||||
public function setUser(User $user);
|
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 Tag $tag
|
||||||
* @param Carbon $start
|
* @param Carbon $start
|
||||||
|
|||||||
@@ -311,6 +311,7 @@ return [
|
|||||||
'meta_data' => 'Meta data',
|
'meta_data' => 'Meta data',
|
||||||
'location' => 'Location',
|
'location' => 'Location',
|
||||||
'without_date' => 'Without date',
|
'without_date' => 'Without date',
|
||||||
|
'result' => 'Result',
|
||||||
|
|
||||||
// preferences
|
// preferences
|
||||||
'pref_home_screen_accounts' => 'Home screen accounts',
|
'pref_home_screen_accounts' => 'Home screen accounts',
|
||||||
|
|||||||
@@ -40,10 +40,12 @@
|
|||||||
{% if moment == 'all' %}
|
{% if moment == 'all' %}
|
||||||
<p>
|
<p>
|
||||||
{{ 'total_sum'|_ }}: {{ sum|formatAmount }}<br/>
|
{{ 'total_sum'|_ }}: {{ sum|formatAmount }}<br/>
|
||||||
|
{{ 'total_result'|_ }}: {{ result|formatAmount }}<br/>
|
||||||
</p>
|
</p>
|
||||||
{% else %}
|
{% else %}
|
||||||
<p>
|
<p>
|
||||||
{{ 'sum'|_ }}: {{ sum|formatAmount }}<br/>
|
{{ 'sum'|_ }}: {{ sum|formatAmount }}<br/>
|
||||||
|
{{ 'result'|_ }}: {{ result|formatAmount }}<br/>
|
||||||
</p>
|
</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user