Moved JournalCollector to other package to encourage reuse

This commit is contained in:
Robert Horlings
2016-02-18 20:01:53 +01:00
parent 2ddacf48d4
commit 50e5c21735
2 changed files with 2 additions and 2 deletions

View File

@@ -1,66 +0,0 @@
<?php
declare(strict_types = 1);
/**
* JournalCollector.php
* Copyright (C) 2016 Sander Dorigo
*
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
*/
namespace FireflyIII\Export;
use Carbon\Carbon;
use FireflyIII\User;
use Illuminate\Support\Collection;
/**
* Class JournalCollector
*
* @package FireflyIII\Export\Collector
*/
class JournalCollector
{
/** @var Collection */
private $accounts;
/** @var Carbon */
private $end;
/** @var Carbon */
private $start;
/** @var User */
private $user;
/**
* JournalCollector constructor.
*
* @param Collection $accounts
* @param User $user
* @param Carbon $start
* @param Carbon $end
*/
public function __construct(Collection $accounts, User $user, Carbon $start, Carbon $end)
{
$this->accounts = $accounts;
$this->user = $user;
$this->start = $start;
$this->end = $end;
}
/**
* @return Collection
*/
public function collect()
{
// get all the journals:
$ids = $this->accounts->pluck('id')->toArray();
return $this->user->transactionjournals()
->leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
->whereIn('transactions.account_id', $ids)
->before($this->end)
->after($this->start)
->orderBy('transaction_journals.date')
->get(['transaction_journals.*']);
}
}

View File

@@ -86,7 +86,7 @@ class Processor
public function collectJournals()
{
$args = [$this->accounts, Auth::user(), $this->settings['startDate'], $this->settings['endDate']];
$journalCollector = app('FireflyIII\Export\JournalCollector', $args);
$journalCollector = app('FireflyIII\Repositories\Journal\JournalCollector', $args);
$this->journals = $journalCollector->collect();
}