mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2026-01-07 06:31:22 +00:00
Fix for #1760
This commit is contained in:
@@ -28,6 +28,7 @@ use Carbon\Carbon;
|
||||
use DB;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Helpers\Filter\CountAttachmentsFilter;
|
||||
use FireflyIII\Helpers\Filter\DoubleTransactionFilter;
|
||||
use FireflyIII\Helpers\Filter\FilterInterface;
|
||||
use FireflyIII\Helpers\Filter\InternalTransferFilter;
|
||||
use FireflyIII\Helpers\Filter\NegativeAmountFilter;
|
||||
@@ -53,26 +54,14 @@ use Log;
|
||||
/**
|
||||
* Class TransactionCollector
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
class TransactionCollector implements TransactionCollectorInterface
|
||||
{
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
if ('testing' === env('APP_ENV')) {
|
||||
Log::warning(sprintf('%s should not be instantiated in the TEST environment!', \get_class($this)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** @var array */
|
||||
private $accountIds = [];
|
||||
/** @var int */
|
||||
private $count = 0;
|
||||
|
||||
/** @var array */
|
||||
private $fields
|
||||
= [
|
||||
@@ -139,6 +128,16 @@ class TransactionCollector implements TransactionCollectorInterface
|
||||
/** @var User */
|
||||
private $user;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
if ('testing' === env('APP_ENV')) {
|
||||
Log::warning(sprintf('%s should not be instantiated in the TEST environment!', \get_class($this)));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $filter
|
||||
*
|
||||
@@ -253,6 +252,30 @@ class TransactionCollector implements TransactionCollectorInterface
|
||||
return $this->count;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return LengthAwarePaginator
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function getPaginatedTransactions(): LengthAwarePaginator
|
||||
{
|
||||
if (true === $this->run) {
|
||||
throw new FireflyException('Cannot getPaginatedTransactions after run in TransactionCollector.');
|
||||
}
|
||||
$this->count();
|
||||
$set = $this->getTransactions();
|
||||
$journals = new LengthAwarePaginator($set, $this->count, $this->limit, $this->page);
|
||||
|
||||
return $journals;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return EloquentBuilder
|
||||
*/
|
||||
public function getQuery(): EloquentBuilder
|
||||
{
|
||||
return $this->query;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection
|
||||
*/
|
||||
@@ -309,30 +332,6 @@ class TransactionCollector implements TransactionCollectorInterface
|
||||
return $set;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return LengthAwarePaginator
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function getPaginatedTransactions(): LengthAwarePaginator
|
||||
{
|
||||
if (true === $this->run) {
|
||||
throw new FireflyException('Cannot getPaginatedTransactions after run in TransactionCollector.');
|
||||
}
|
||||
$this->count();
|
||||
$set = $this->getTransactions();
|
||||
$journals = new LengthAwarePaginator($set, $this->count, $this->limit, $this->page);
|
||||
|
||||
return $journals;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return EloquentBuilder
|
||||
*/
|
||||
public function getQuery(): EloquentBuilder
|
||||
{
|
||||
return $this->query;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return TransactionCollectorInterface
|
||||
*/
|
||||
@@ -784,14 +783,15 @@ class TransactionCollector implements TransactionCollectorInterface
|
||||
{
|
||||
// create all possible filters:
|
||||
$filters = [
|
||||
InternalTransferFilter::class => new InternalTransferFilter($this->accountIds),
|
||||
OpposingAccountFilter::class => new OpposingAccountFilter($this->accountIds),
|
||||
TransferFilter::class => new TransferFilter,
|
||||
PositiveAmountFilter::class => new PositiveAmountFilter,
|
||||
NegativeAmountFilter::class => new NegativeAmountFilter,
|
||||
SplitIndicatorFilter::class => new SplitIndicatorFilter,
|
||||
CountAttachmentsFilter::class => new CountAttachmentsFilter,
|
||||
TransactionViewFilter::class => new TransactionViewFilter,
|
||||
InternalTransferFilter::class => new InternalTransferFilter($this->accountIds),
|
||||
OpposingAccountFilter::class => new OpposingAccountFilter($this->accountIds),
|
||||
TransferFilter::class => new TransferFilter,
|
||||
PositiveAmountFilter::class => new PositiveAmountFilter,
|
||||
NegativeAmountFilter::class => new NegativeAmountFilter,
|
||||
SplitIndicatorFilter::class => new SplitIndicatorFilter,
|
||||
CountAttachmentsFilter::class => new CountAttachmentsFilter,
|
||||
TransactionViewFilter::class => new TransactionViewFilter,
|
||||
DoubleTransactionFilter::class => new DoubleTransactionFilter,
|
||||
];
|
||||
Log::debug(sprintf('Will run %d filters on the set.', \count($this->filters)));
|
||||
foreach ($this->filters as $enabled) {
|
||||
|
||||
Reference in New Issue
Block a user