/**
  * Returns an array of tags and their comparitive size with amounts bla bla.
  *
  * @param Carbon     $start
  * @param Carbon     $end
  * @param Collection $accounts
  *
  * @return array
  */
 public function tagReport(Carbon $start, Carbon $end, Collection $accounts) : array
 {
     $ids = $accounts->pluck('id')->toArray();
     $set = Tag::leftJoin('tag_transaction_journal', 'tags.id', '=', 'tag_transaction_journal.tag_id')->leftJoin('transaction_journals', 'tag_transaction_journal.transaction_journal_id', '=', 'transaction_journals.id')->leftJoin('transactions AS source', function (JoinClause $join) {
         $join->on('source.transaction_journal_id', '=', 'transaction_journals.id')->where('source.amount', '<', '0');
     })->leftJoin('transactions AS destination', function (JoinClause $join) {
         $join->on('destination.transaction_journal_id', '=', 'transaction_journals.id')->where('destination.amount', '>', '0');
     })->where('transaction_journals.date', '>=', $start->format('Y-m-d'))->where('transaction_journals.date', '<=', $end->format('Y-m-d'))->where(function (Builder $q) use($ids) {
         $q->whereIn('source.account_id', $ids)->whereIn('destination.account_id', $ids, 'xor');
     })->get(['tags.id', 'tags.tag', 'transaction_journals.id as journal_id', 'destination.amount']);
     $collection = [];
     if ($set->count() === 0) {
         return $collection;
     }
     /** @var Tag $entry */
     foreach ($set as $entry) {
         // less than zero? multiply to be above zero.
         $amount = $entry->amount;
         $id = intval($entry->id);
         $previousAmount = $collection[$id]['amount'] ?? '0';
         $collection[$id] = ['id' => $id, 'tag' => $entry->tag, 'amount' => bcadd($previousAmount, $amount)];
     }
     // cleanup collection (match "fonts")
     $max = strval(max(array_column($collection, 'amount')));
     foreach ($collection as $id => $entry) {
         $size = bcdiv($entry['amount'], $max, 4);
         if (bccomp($size, '0.25') === -1) {
             $size = '0.5';
         }
         $collection[$id]['fontsize'] = $size;
     }
     return $collection;
 }
 /**
  * Reports on tags without any transactions.
  */
 private function reportTags()
 {
     $set = Tag::leftJoin('tag_transaction_journal', 'tags.id', '=', 'tag_transaction_journal.tag_id')->leftJoin('users', 'tags.user_id', '=', 'users.id')->distinct()->whereNull('tag_transaction_journal.tag_id')->whereNull('tags.deleted_at')->get(['tags.id', 'tags.tag', 'tags.user_id', 'users.email']);
     /** @var stdClass $entry */
     foreach ($set as $entry) {
         $line = 'Notice: User #' . $entry->user_id . ' (' . $entry->email . ') has tag #' . $entry->id . ' ("' . $entry->tag . '") which has no transactions.';
         $this->line($line);
     }
 }