mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-29 18:20:01 +00:00
Moved JournalCollector to other package to encourage reuse
This commit is contained in:
@@ -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.*']);
|
||||
}
|
||||
|
||||
}
|
@@ -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();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user