mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Fix tag repos #997
This commit is contained in:
commit
7bdafb48d2
@ -331,18 +331,18 @@ class TagRepository implements TagRepositoryInterface
|
|||||||
->leftJoin('transaction_journals', 'tag_transaction_journal.transaction_journal_id', '=', 'transaction_journals.id')
|
->leftJoin('transaction_journals', 'tag_transaction_journal.transaction_journal_id', '=', 'transaction_journals.id')
|
||||||
->leftJoin('transactions', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
|
->leftJoin('transactions', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
|
||||||
->where('transactions.amount', '>', 0)
|
->where('transactions.amount', '>', 0)
|
||||||
->groupBy(['tags.id','tags.tag']);
|
->groupBy(['tags.id', 'tags.tag']);
|
||||||
|
|
||||||
// add date range (or not):
|
// add date range (or not):
|
||||||
if (null === $year) {
|
if (null === $year) {
|
||||||
$query->whereNull('tags.date');
|
$query->whereNull('tags.date');
|
||||||
$allTags->whereNull('date');
|
$allTags->whereNull('tags.date');
|
||||||
}
|
}
|
||||||
if (null !== $year) {
|
if (null !== $year) {
|
||||||
$start = $year . '-01-01';
|
$start = $year . '-01-01';
|
||||||
$end = $year . '-12-31';
|
$end = $year . '-12-31';
|
||||||
$query->where('tags.date', '>=', $start)->where('tags.date', '<=', $end);
|
$query->where('tags.date', '>=', $start)->where('tags.date', '<=', $end);
|
||||||
$allTags->where('date', '>=', $start)->where('date', '<=', $end);
|
$allTags->where('tags.date', '>=', $start)->where('tags.date', '<=', $end);
|
||||||
}
|
}
|
||||||
$set = $query->get(['tags.id', DB::raw('SUM(transactions.amount) as amount_sum')]);
|
$set = $query->get(['tags.id', DB::raw('SUM(transactions.amount) as amount_sum')]);
|
||||||
$tagsWithAmounts = [];
|
$tagsWithAmounts = [];
|
||||||
@ -351,7 +351,7 @@ class TagRepository implements TagRepositoryInterface
|
|||||||
$tagsWithAmounts[$tag->id] = strval($tag->amount_sum);
|
$tagsWithAmounts[$tag->id] = strval($tag->amount_sum);
|
||||||
}
|
}
|
||||||
|
|
||||||
$tags = $query->orderBy('id', 'desc')->get(['tags.id','tags.tag']);
|
$tags = $query->orderBy('tags.id', 'desc')->get(['tags.id', 'tags.tag']);
|
||||||
$temporary = [];
|
$temporary = [];
|
||||||
/** @var Tag $tag */
|
/** @var Tag $tag */
|
||||||
foreach ($tags as $tag) {
|
foreach ($tags as $tag) {
|
||||||
|
Loading…
Reference in New Issue
Block a user