Fix tag repos #997

This commit is contained in:
James Cole 2017-11-17 08:23:49 +01:00
commit 7bdafb48d2

View File

@ -336,13 +336,13 @@ class TagRepository implements TagRepositoryInterface
// add date range (or not):
if (null === $year) {
$query->whereNull('tags.date');
$allTags->whereNull('date');
$allTags->whereNull('tags.date');
}
if (null !== $year) {
$start = $year . '-01-01';
$end = $year . '-12-31';
$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')]);
$tagsWithAmounts = [];
@ -351,7 +351,7 @@ class TagRepository implements TagRepositoryInterface
$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 = [];
/** @var Tag $tag */
foreach ($tags as $tag) {