| 
									
										
										
										
											2020-08-09 18:58:18 +02:00
										 |  |  | <?php | 
					
						
							| 
									
										
										
										
											2021-01-29 18:50:35 +01:00
										 |  |  | /* | 
					
						
							|  |  |  |  * OperatorQuerySearch.php | 
					
						
							|  |  |  |  * Copyright (c) 2021 james@firefly-iii.org | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * This file is part of Firefly III (https://github.com/firefly-iii). | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * This program is free software: you can redistribute it and/or modify | 
					
						
							|  |  |  |  * it under the terms of the GNU Affero General Public License as | 
					
						
							|  |  |  |  * published by the Free Software Foundation, either version 3 of the | 
					
						
							|  |  |  |  * License, or (at your option) any later version. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * This program is distributed in the hope that it will be useful, | 
					
						
							|  |  |  |  * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
					
						
							|  |  |  |  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
					
						
							|  |  |  |  * GNU Affero General Public License for more details. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * You should have received a copy of the GNU Affero General Public License | 
					
						
							|  |  |  |  * along with this program.  If not, see <https://www.gnu.org/licenses/>. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-09-18 12:16:47 +02:00
										 |  |  | declare(strict_types=1); | 
					
						
							| 
									
										
										
										
											2020-08-09 18:58:18 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | namespace FireflyIII\Support\Search; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | use Carbon\Carbon; | 
					
						
							|  |  |  | use FireflyIII\Exceptions\FireflyException; | 
					
						
							|  |  |  | use FireflyIII\Helpers\Collector\GroupCollectorInterface; | 
					
						
							| 
									
										
										
										
											2020-08-18 17:48:27 +02:00
										 |  |  | use FireflyIII\Models\Account; | 
					
						
							| 
									
										
										
										
											2020-08-22 12:24:01 +02:00
										 |  |  | use FireflyIII\Models\AccountMeta; | 
					
						
							| 
									
										
										
										
											2020-08-09 18:58:18 +02:00
										 |  |  | use FireflyIII\Models\AccountType; | 
					
						
							| 
									
										
										
										
											2020-08-22 12:24:01 +02:00
										 |  |  | use FireflyIII\Models\TransactionCurrency; | 
					
						
							| 
									
										
										
										
											2020-08-09 18:58:18 +02:00
										 |  |  | use FireflyIII\Repositories\Account\AccountRepositoryInterface; | 
					
						
							|  |  |  | use FireflyIII\Repositories\Bill\BillRepositoryInterface; | 
					
						
							|  |  |  | use FireflyIII\Repositories\Budget\BudgetRepositoryInterface; | 
					
						
							|  |  |  | use FireflyIII\Repositories\Category\CategoryRepositoryInterface; | 
					
						
							| 
									
										
										
										
											2020-08-22 12:24:01 +02:00
										 |  |  | use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface; | 
					
						
							| 
									
										
										
										
											2020-08-09 18:58:18 +02:00
										 |  |  | use FireflyIII\Repositories\Tag\TagRepositoryInterface; | 
					
						
							| 
									
										
										
										
											2020-08-22 13:01:37 +02:00
										 |  |  | use FireflyIII\Support\ParseDateString; | 
					
						
							| 
									
										
										
										
											2020-08-09 18:58:18 +02:00
										 |  |  | use FireflyIII\User; | 
					
						
							| 
									
										
										
										
											2022-09-24 18:06:01 +02:00
										 |  |  | use Gdbots\QueryParser\Enum\BoolOperator; | 
					
						
							| 
									
										
										
										
											2020-09-10 14:50:22 +02:00
										 |  |  | use Gdbots\QueryParser\Node\Date; | 
					
						
							| 
									
										
										
										
											2020-09-10 14:53:35 +02:00
										 |  |  | use Gdbots\QueryParser\Node\Emoji; | 
					
						
							|  |  |  | use Gdbots\QueryParser\Node\Emoticon; | 
					
						
							| 
									
										
										
										
											2020-08-09 18:58:18 +02:00
										 |  |  | use Gdbots\QueryParser\Node\Field; | 
					
						
							| 
									
										
										
										
											2020-09-10 14:50:49 +02:00
										 |  |  | use Gdbots\QueryParser\Node\Hashtag; | 
					
						
							| 
									
										
										
										
											2020-09-10 14:53:35 +02:00
										 |  |  | use Gdbots\QueryParser\Node\Mention; | 
					
						
							| 
									
										
										
										
											2020-08-09 18:58:18 +02:00
										 |  |  | use Gdbots\QueryParser\Node\Node; | 
					
						
							| 
									
										
										
										
											2020-09-09 06:10:00 +02:00
										 |  |  | use Gdbots\QueryParser\Node\Numbr; | 
					
						
							| 
									
										
										
										
											2020-08-18 17:48:27 +02:00
										 |  |  | use Gdbots\QueryParser\Node\Phrase; | 
					
						
							| 
									
										
										
										
											2020-12-20 06:56:27 +01:00
										 |  |  | use Gdbots\QueryParser\Node\Subquery; | 
					
						
							| 
									
										
										
										
											2020-09-10 14:48:02 +02:00
										 |  |  | use Gdbots\QueryParser\Node\Url; | 
					
						
							| 
									
										
										
										
											2020-08-09 18:58:18 +02:00
										 |  |  | use Gdbots\QueryParser\Node\Word; | 
					
						
							|  |  |  | use Gdbots\QueryParser\QueryParser; | 
					
						
							|  |  |  | use Illuminate\Pagination\LengthAwarePaginator; | 
					
						
							|  |  |  | use Illuminate\Support\Collection; | 
					
						
							|  |  |  | use Log; | 
					
						
							| 
									
										
										
										
											2021-10-02 18:46:26 +02:00
										 |  |  | use LogicException; | 
					
						
							| 
									
										
										
										
											2021-10-02 18:45:42 +02:00
										 |  |  | use TypeError; | 
					
						
							| 
									
										
										
										
											2020-08-09 18:58:18 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | /** | 
					
						
							| 
									
										
										
										
											2020-08-22 13:01:37 +02:00
										 |  |  |  * Class OperatorQuerySearch | 
					
						
							| 
									
										
										
										
											2020-08-09 18:58:18 +02:00
										 |  |  |  */ | 
					
						
							| 
									
										
										
										
											2020-08-22 13:01:37 +02:00
										 |  |  | class OperatorQuerySearch implements SearchInterface | 
					
						
							| 
									
										
										
										
											2020-08-09 18:58:18 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2021-06-30 20:02:19 +02:00
										 |  |  |     private AccountRepositoryInterface  $accountRepository; | 
					
						
							|  |  |  |     private BillRepositoryInterface     $billRepository; | 
					
						
							|  |  |  |     private BudgetRepositoryInterface   $budgetRepository; | 
					
						
							|  |  |  |     private CategoryRepositoryInterface $categoryRepository; | 
					
						
							|  |  |  |     private GroupCollectorInterface     $collector; | 
					
						
							|  |  |  |     private CurrencyRepositoryInterface $currencyRepository; | 
					
						
							|  |  |  |     private Carbon                      $date; | 
					
						
							| 
									
										
										
										
											2021-09-18 10:26:12 +02:00
										 |  |  |     private array                       $invalidOperators; | 
					
						
							| 
									
										
										
										
											2021-06-30 20:02:19 +02:00
										 |  |  |     private int                         $limit; | 
					
						
							|  |  |  |     private Collection                  $operators; | 
					
						
							|  |  |  |     private int                         $page; | 
					
						
							| 
									
										
										
										
											2022-12-29 19:42:26 +01:00
										 |  |  |     private array                       $prohibitedWords; | 
					
						
							| 
									
										
										
										
											2021-06-30 20:02:19 +02:00
										 |  |  |     private float                       $startTime; | 
					
						
							|  |  |  |     private TagRepositoryInterface      $tagRepository; | 
					
						
							|  |  |  |     private array                       $validOperators; | 
					
						
							|  |  |  |     private array                       $words; | 
					
						
							| 
									
										
										
										
											2020-08-09 18:58:18 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-08-18 17:48:27 +02:00
										 |  |  |     /** | 
					
						
							| 
									
										
										
										
											2020-08-22 13:01:37 +02:00
										 |  |  |      * OperatorQuerySearch constructor. | 
					
						
							| 
									
										
										
										
											2020-10-24 07:40:56 +02:00
										 |  |  |      * | 
					
						
							| 
									
										
										
										
											2023-02-12 07:23:57 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-08-18 17:48:27 +02:00
										 |  |  |      */ | 
					
						
							| 
									
										
										
										
											2020-08-09 18:58:18 +02:00
										 |  |  |     public function __construct() | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2020-08-22 13:01:37 +02:00
										 |  |  |         Log::debug('Constructed OperatorQuerySearch'); | 
					
						
							| 
									
										
										
										
											2022-10-30 14:24:37 +01:00
										 |  |  |         $this->operators          = new Collection(); | 
					
						
							| 
									
										
										
										
											2020-08-09 18:58:18 +02:00
										 |  |  |         $this->page               = 1; | 
					
						
							|  |  |  |         $this->words              = []; | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  |         $this->prohibitedWords    = []; | 
					
						
							| 
									
										
										
										
											2021-06-30 20:02:19 +02:00
										 |  |  |         $this->invalidOperators   = []; | 
					
						
							| 
									
										
										
										
											2020-08-22 16:55:54 +02:00
										 |  |  |         $this->limit              = 25; | 
					
						
							| 
									
										
										
										
											2021-02-03 10:41:41 +01:00
										 |  |  |         $this->date               = today(config('app.timezone')); | 
					
						
							| 
									
										
										
										
											2022-03-20 07:42:39 +01:00
										 |  |  |         $this->validOperators     = array_keys(config('search.operators')); | 
					
						
							| 
									
										
										
										
											2020-08-09 18:58:18 +02:00
										 |  |  |         $this->startTime          = microtime(true); | 
					
						
							|  |  |  |         $this->accountRepository  = app(AccountRepositoryInterface::class); | 
					
						
							|  |  |  |         $this->categoryRepository = app(CategoryRepositoryInterface::class); | 
					
						
							|  |  |  |         $this->budgetRepository   = app(BudgetRepositoryInterface::class); | 
					
						
							|  |  |  |         $this->billRepository     = app(BillRepositoryInterface::class); | 
					
						
							|  |  |  |         $this->tagRepository      = app(TagRepositoryInterface::class); | 
					
						
							| 
									
										
										
										
											2020-08-22 12:24:01 +02:00
										 |  |  |         $this->currencyRepository = app(CurrencyRepositoryInterface::class); | 
					
						
							| 
									
										
										
										
											2020-08-09 18:58:18 +02:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-09-18 10:26:12 +02:00
										 |  |  |     /** | 
					
						
							|  |  |  |      * @return array | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     public function getInvalidOperators(): array | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         return $this->invalidOperators; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-08-09 18:58:18 +02:00
										 |  |  |     /** | 
					
						
							|  |  |  |      * @inheritDoc | 
					
						
							| 
									
										
										
										
											2023-02-12 07:23:57 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-08-09 18:58:18 +02:00
										 |  |  |      */ | 
					
						
							|  |  |  |     public function getModifiers(): Collection | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2020-08-22 12:25:00 +02:00
										 |  |  |         return $this->getOperators(); | 
					
						
							| 
									
										
										
										
											2020-08-22 12:24:01 +02:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * @inheritDoc | 
					
						
							| 
									
										
										
										
											2023-02-12 07:23:57 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-08-22 12:24:01 +02:00
										 |  |  |      */ | 
					
						
							|  |  |  |     public function getOperators(): Collection | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         return $this->operators; | 
					
						
							| 
									
										
										
										
											2020-08-09 18:58:18 +02:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * @inheritDoc | 
					
						
							| 
									
										
										
										
											2023-02-12 07:23:57 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-08-09 18:58:18 +02:00
										 |  |  |      */ | 
					
						
							|  |  |  |     public function getWordsAsString(): string | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         return implode(' ', $this->words); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * @inheritDoc | 
					
						
							| 
									
										
										
										
											2023-02-12 07:23:57 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-08-09 18:58:18 +02:00
										 |  |  |      */ | 
					
						
							|  |  |  |     public function hasModifiers(): bool | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         die(__METHOD__); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * @inheritDoc | 
					
						
							| 
									
										
										
										
											2020-08-18 17:48:27 +02:00
										 |  |  |      * @throws FireflyException | 
					
						
							| 
									
										
										
										
											2020-08-09 18:58:18 +02:00
										 |  |  |      */ | 
					
						
							|  |  |  |     public function parseQuery(string $query) | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2022-03-27 16:03:50 +02:00
										 |  |  |         Log::debug(sprintf('Now in parseQuery(%s)', $query)); | 
					
						
							| 
									
										
										
										
											2021-09-18 10:20:19 +02:00
										 |  |  |         $parser = new QueryParser(); | 
					
						
							| 
									
										
										
										
											2021-10-02 18:45:42 +02:00
										 |  |  |         try { | 
					
						
							|  |  |  |             $query1 = $parser->parse($query); | 
					
						
							| 
									
										
										
										
											2022-03-20 17:11:33 +01:00
										 |  |  |         } catch (TypeError|LogicException $e) { | 
					
						
							| 
									
										
										
										
											2021-10-02 18:45:42 +02:00
										 |  |  |             Log::error($e->getMessage()); | 
					
						
							|  |  |  |             Log::error(sprintf('Could not parse search: "%s".', $query)); | 
					
						
							| 
									
										
										
										
											2023-01-20 22:08:18 +01:00
										 |  |  |             throw new FireflyException(sprintf('Invalid search value "%s". See the logs.', e($query)), 0, $e); | 
					
						
							| 
									
										
										
										
											2021-10-02 18:45:42 +02:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2020-08-18 17:48:27 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-09-18 10:20:19 +02:00
										 |  |  |         Log::debug(sprintf('Found %d node(s)', count($query1->getNodes()))); | 
					
						
							|  |  |  |         foreach ($query1->getNodes() as $searchNode) { | 
					
						
							| 
									
										
										
										
											2020-08-09 18:58:18 +02:00
										 |  |  |             $this->handleSearchNode($searchNode); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         $this->collector->setSearchWords($this->words); | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  |         $this->collector->excludeSearchWords($this->prohibitedWords); | 
					
						
							| 
									
										
										
										
											2020-08-09 18:58:18 +02:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							| 
									
										
										
										
											2022-12-29 19:42:26 +01:00
										 |  |  |      * @param  Node  $searchNode | 
					
						
							| 
									
										
										
										
											2020-10-24 07:40:56 +02:00
										 |  |  |      * | 
					
						
							| 
									
										
										
										
											2020-08-09 18:58:18 +02:00
										 |  |  |      * @throws FireflyException | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     private function handleSearchNode(Node $searchNode): void | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         $class = get_class($searchNode); | 
					
						
							| 
									
										
										
										
											2021-10-30 21:32:02 +02:00
										 |  |  |         Log::debug(sprintf('Now in handleSearchNode(%s)', $class)); | 
					
						
							| 
									
										
										
										
											2020-08-09 18:58:18 +02:00
										 |  |  |         switch ($class) { | 
					
						
							|  |  |  |             default: | 
					
						
							| 
									
										
										
										
											2020-08-18 17:48:27 +02:00
										 |  |  |                 Log::error(sprintf('Cannot handle node %s', $class)); | 
					
						
							| 
									
										
										
										
											2020-08-09 18:58:18 +02:00
										 |  |  |                 throw new FireflyException(sprintf('Firefly III search cant handle "%s"-nodes', $class)); | 
					
						
							| 
									
										
										
										
											2020-12-20 06:56:27 +01:00
										 |  |  |             case Subquery::class: | 
					
						
							|  |  |  |                 // loop all notes in subquery:
 | 
					
						
							| 
									
										
										
										
											2022-12-31 13:32:42 +01:00
										 |  |  |                 foreach ($searchNode->getNodes() as $subNode) { // @phpstan-ignore-line PHPStan thinks getNodes() does not exist but it does.
 | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |                     $this->handleSearchNode($subNode);          // let's hope it's not too recursive
 | 
					
						
							| 
									
										
										
										
											2020-12-20 06:56:27 +01:00
										 |  |  |                 } | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2020-08-09 18:58:18 +02:00
										 |  |  |             case Word::class: | 
					
						
							| 
									
										
										
										
											2020-08-18 17:48:27 +02:00
										 |  |  |             case Phrase::class: | 
					
						
							| 
									
										
										
										
											2020-09-09 06:10:00 +02:00
										 |  |  |             case Numbr::class: | 
					
						
							| 
									
										
										
										
											2020-09-10 14:48:02 +02:00
										 |  |  |             case Url::class: | 
					
						
							| 
									
										
										
										
											2020-09-10 14:50:22 +02:00
										 |  |  |             case Date::class: | 
					
						
							| 
									
										
										
										
											2020-09-10 14:50:49 +02:00
										 |  |  |             case Hashtag::class: | 
					
						
							| 
									
										
										
										
											2020-09-10 14:53:35 +02:00
										 |  |  |             case Emoticon::class: | 
					
						
							|  |  |  |             case Emoji::class: | 
					
						
							|  |  |  |             case Mention::class: | 
					
						
							| 
									
										
										
										
											2022-12-29 19:42:26 +01:00
										 |  |  |                 $allWords = (string)$searchNode->getValue(); | 
					
						
							| 
									
										
										
										
											2021-05-24 08:06:56 +02:00
										 |  |  |                 Log::debug(sprintf('Add words "%s" to search string, because Node class is "%s"', $allWords, $class)); | 
					
						
							|  |  |  |                 $this->words[] = $allWords; | 
					
						
							| 
									
										
										
										
											2020-08-09 18:58:18 +02:00
										 |  |  |                 break; | 
					
						
							|  |  |  |             case Field::class: | 
					
						
							| 
									
										
										
										
											2021-05-13 05:34:49 +02:00
										 |  |  |                 Log::debug(sprintf('Now handle Node class %s', $class)); | 
					
						
							| 
									
										
										
										
											2020-08-09 18:58:18 +02:00
										 |  |  |                 /** @var Field $searchNode */ | 
					
						
							|  |  |  |                 // used to search for x:y
 | 
					
						
							| 
									
										
										
										
											2022-09-24 18:06:01 +02:00
										 |  |  |                 $operator   = strtolower($searchNode->getValue()); | 
					
						
							|  |  |  |                 $value      = $searchNode->getNode()->getValue(); | 
					
						
							| 
									
										
										
										
											2023-01-11 06:10:57 +01:00
										 |  |  |                 $prohibited = $searchNode->getBoolOperator() === BoolOperator::PROHIBITED; | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  |                 $context    = config(sprintf('search.operators.%s.needs_context', $operator)); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 // is an operator that needs no context, and value is false, then prohibited = true.
 | 
					
						
							|  |  |  |                 if ('false' === $value && in_array($operator, $this->validOperators, true) && false === $context) { | 
					
						
							|  |  |  |                     $prohibited = true; | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-08-09 18:58:18 +02:00
										 |  |  |                 // must be valid operator:
 | 
					
						
							| 
									
										
										
										
											2022-09-24 18:06:01 +02:00
										 |  |  |                 if ( | 
					
						
							|  |  |  |                     in_array($operator, $this->validOperators, true) && | 
					
						
							| 
									
										
										
										
											2022-12-29 19:42:26 +01:00
										 |  |  |                     $this->updateCollector($operator, (string)$value, $prohibited)) { | 
					
						
							| 
									
										
										
										
											2020-10-24 07:40:56 +02:00
										 |  |  |                     $this->operators->push( | 
					
						
							|  |  |  |                         [ | 
					
						
							| 
									
										
										
										
											2022-09-24 18:06:01 +02:00
										 |  |  |                             'type'       => self::getRootOperator($operator), | 
					
						
							| 
									
										
										
										
											2022-12-29 19:42:26 +01:00
										 |  |  |                             'value'      => (string)$value, | 
					
						
							| 
									
										
										
										
											2022-09-24 18:06:01 +02:00
										 |  |  |                             'prohibited' => $prohibited, | 
					
						
							| 
									
										
										
										
											2020-10-24 07:40:56 +02:00
										 |  |  |                         ] | 
					
						
							|  |  |  |                     ); | 
					
						
							| 
									
										
										
										
											2021-10-30 21:32:02 +02:00
										 |  |  |                     Log::debug(sprintf('Added operator type "%s"', $operator)); | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |                 if (!in_array($operator, $this->validOperators, true)) { | 
					
						
							|  |  |  |                     Log::debug(sprintf('Added INVALID operator type "%s"', $operator)); | 
					
						
							| 
									
										
										
										
											2021-06-30 20:02:19 +02:00
										 |  |  |                     $this->invalidOperators[] = [ | 
					
						
							|  |  |  |                         'type'  => $operator, | 
					
						
							| 
									
										
										
										
											2022-12-29 19:42:26 +01:00
										 |  |  |                         'value' => (string)$value, | 
					
						
							| 
									
										
										
										
											2021-06-30 20:02:19 +02:00
										 |  |  |                     ]; | 
					
						
							| 
									
										
										
										
											2020-08-09 18:58:18 +02:00
										 |  |  |                 } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							| 
									
										
										
										
											2022-12-29 19:42:26 +01:00
										 |  |  |      * @param  string  $operator | 
					
						
							|  |  |  |      * @param  string  $value | 
					
						
							| 
									
										
										
										
											2020-10-24 07:40:56 +02:00
										 |  |  |      * | 
					
						
							| 
									
										
										
										
											2020-08-22 12:24:01 +02:00
										 |  |  |      * @return bool | 
					
						
							| 
									
										
										
										
											2020-08-18 17:48:27 +02:00
										 |  |  |      * @throws FireflyException | 
					
						
							| 
									
										
										
										
											2020-08-09 18:58:18 +02:00
										 |  |  |      */ | 
					
						
							| 
									
										
										
										
											2022-09-24 18:06:01 +02:00
										 |  |  |     private function updateCollector(string $operator, string $value, bool $prohibited): bool | 
					
						
							| 
									
										
										
										
											2020-08-09 18:58:18 +02:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2022-09-24 18:06:01 +02:00
										 |  |  |         if ($prohibited) { | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             Log::debug(sprintf('Operator "%s" is now "%s"', $operator, sprintf('-%s', $operator))); | 
					
						
							|  |  |  |             $operator = sprintf('-%s', $operator); | 
					
						
							| 
									
										
										
										
											2022-09-24 18:06:01 +02:00
										 |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-10-30 21:32:02 +02:00
										 |  |  |         Log::debug(sprintf('Now in updateCollector("%s", "%s")', $operator, $value)); | 
					
						
							| 
									
										
										
										
											2020-08-22 12:24:01 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |         // check if alias, replace if necessary:
 | 
					
						
							| 
									
										
										
										
											2020-08-27 06:19:16 +02:00
										 |  |  |         $operator = self::getRootOperator($operator); | 
					
						
							| 
									
										
										
										
											2020-08-22 12:24:01 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-08-09 18:58:18 +02:00
										 |  |  |         switch ($operator) { | 
					
						
							|  |  |  |             default: | 
					
						
							| 
									
										
										
										
											2020-08-18 17:48:27 +02:00
										 |  |  |                 Log::error(sprintf('No such operator: %s', $operator)); | 
					
						
							|  |  |  |                 throw new FireflyException(sprintf('Unsupported search operator: "%s"', $operator)); | 
					
						
							| 
									
										
										
										
											2022-10-30 14:24:37 +01:00
										 |  |  |                 // some search operators are ignored, basically:
 | 
					
						
							| 
									
										
										
										
											2020-08-18 17:48:27 +02:00
										 |  |  |             case 'user_action': | 
					
						
							|  |  |  |                 Log::info(sprintf('Ignore search operator "%s"', $operator)); | 
					
						
							| 
									
										
										
										
											2020-10-24 07:40:56 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-08-22 12:24:01 +02:00
										 |  |  |                 return false; | 
					
						
							|  |  |  |             //
 | 
					
						
							| 
									
										
										
										
											2022-10-30 14:24:37 +01:00
										 |  |  |                 // all account related searches:
 | 
					
						
							| 
									
										
										
										
											2020-08-22 12:24:01 +02:00
										 |  |  |             //
 | 
					
						
							| 
									
										
										
										
											2022-03-20 17:11:33 +01:00
										 |  |  |             case 'account_is': | 
					
						
							|  |  |  |                 $this->searchAccount($value, 3, 4); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             case '-account_is': | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  |                 $this->searchAccount($value, 3, 4, true); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-03-20 17:11:33 +01:00
										 |  |  |             case 'account_contains': | 
					
						
							|  |  |  |                 $this->searchAccount($value, 3, 3); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             case '-account_contains': | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  |                 $this->searchAccount($value, 3, 3, true); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-03-20 17:11:33 +01:00
										 |  |  |             case 'account_ends': | 
					
						
							|  |  |  |                 $this->searchAccount($value, 3, 2); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             case '-account_ends': | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  |                 $this->searchAccount($value, 3, 2, true); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-03-20 17:11:33 +01:00
										 |  |  |             case 'account_starts': | 
					
						
							|  |  |  |                 $this->searchAccount($value, 3, 1); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             case '-account_starts': | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  |                 $this->searchAccount($value, 3, 1, true); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-03-20 17:11:33 +01:00
										 |  |  |             case 'account_nr_is': | 
					
						
							|  |  |  |                 $this->searchAccountNr($value, 3, 4); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             case '-account_nr_is': | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  |                 $this->searchAccountNr($value, 3, 4, true); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-03-20 17:11:33 +01:00
										 |  |  |             case 'account_nr_contains': | 
					
						
							|  |  |  |                 $this->searchAccountNr($value, 3, 3); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             case '-account_nr_contains': | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  |                 $this->searchAccountNr($value, 3, 3, true); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-03-20 17:11:33 +01:00
										 |  |  |             case 'account_nr_ends': | 
					
						
							|  |  |  |                 $this->searchAccountNr($value, 3, 2); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             case '-account_nr_ends': | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  |                 $this->searchAccountNr($value, 3, 2, true); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-03-20 17:11:33 +01:00
										 |  |  |             case 'account_nr_starts': | 
					
						
							|  |  |  |                 $this->searchAccountNr($value, 3, 1); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             case '-account_nr_starts': | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  |                 $this->searchAccountNr($value, 3, 1, true); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2020-08-22 12:24:01 +02:00
										 |  |  |             case 'source_account_starts': | 
					
						
							|  |  |  |                 $this->searchAccount($value, 1, 1); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             case '-source_account_starts': | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  |                 $this->searchAccount($value, 1, 1, true); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2020-08-22 12:24:01 +02:00
										 |  |  |             case 'source_account_ends': | 
					
						
							|  |  |  |                 $this->searchAccount($value, 1, 2); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             case '-source_account_ends': | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  |                 $this->searchAccount($value, 1, 2, true); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2020-08-22 12:24:01 +02:00
										 |  |  |             case 'source_account_is': | 
					
						
							|  |  |  |                 $this->searchAccount($value, 1, 4); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             case '-source_account_is': | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  |                 $this->searchAccount($value, 1, 4, true); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2020-08-22 12:24:01 +02:00
										 |  |  |             case 'source_account_nr_starts': | 
					
						
							|  |  |  |                 $this->searchAccountNr($value, 1, 1); | 
					
						
							| 
									
										
										
										
											2020-08-18 17:48:27 +02:00
										 |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             case '-source_account_nr_starts': | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  |                 $this->searchAccountNr($value, 1, 1, true); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2020-08-22 12:24:01 +02:00
										 |  |  |             case 'source_account_nr_ends': | 
					
						
							|  |  |  |                 $this->searchAccountNr($value, 1, 2); | 
					
						
							| 
									
										
										
										
											2020-08-18 17:48:27 +02:00
										 |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             case '-source_account_nr_ends': | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  |                 $this->searchAccountNr($value, 1, 2, true); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2020-08-22 12:24:01 +02:00
										 |  |  |             case 'source_account_nr_is': | 
					
						
							|  |  |  |                 $this->searchAccountNr($value, 1, 4); | 
					
						
							| 
									
										
										
										
											2020-08-18 17:48:27 +02:00
										 |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             case '-source_account_nr_is': | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  |                 $this->searchAccountNr($value, 1, 4, true); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2020-08-22 12:24:01 +02:00
										 |  |  |             case 'source_account_nr_contains': | 
					
						
							|  |  |  |                 $this->searchAccountNr($value, 1, 3); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             case '-source_account_nr_contains': | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  |                 $this->searchAccountNr($value, 1, 3, true); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2020-08-22 12:24:01 +02:00
										 |  |  |             case 'source_account_contains': | 
					
						
							|  |  |  |                 $this->searchAccount($value, 1, 3); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             case '-source_account_contains': | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  |                 $this->searchAccount($value, 1, 3, true); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2020-08-22 12:24:01 +02:00
										 |  |  |             case 'source_account_id': | 
					
						
							| 
									
										
										
										
											2022-12-29 19:42:26 +01:00
										 |  |  |                 $account = $this->accountRepository->find((int)$value); | 
					
						
							| 
									
										
										
										
											2020-08-22 13:01:37 +02:00
										 |  |  |                 if (null !== $account) { | 
					
						
							| 
									
										
										
										
											2020-08-22 12:24:01 +02:00
										 |  |  |                     $this->collector->setSourceAccounts(new Collection([$account])); | 
					
						
							| 
									
										
										
										
											2020-08-09 18:58:18 +02:00
										 |  |  |                 } | 
					
						
							| 
									
										
										
										
											2021-09-17 08:46:03 +02:00
										 |  |  |                 if (null === $account) { | 
					
						
							|  |  |  |                     // since the source does not exist, cannot return results:
 | 
					
						
							|  |  |  |                     $this->collector->findNothing(); | 
					
						
							|  |  |  |                 } | 
					
						
							| 
									
										
										
										
											2020-08-22 12:24:01 +02:00
										 |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             case '-source_account_id': | 
					
						
							| 
									
										
										
										
											2022-12-29 19:42:26 +01:00
										 |  |  |                 $account = $this->accountRepository->find((int)$value); | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  |                 if (null !== $account) { | 
					
						
							|  |  |  |                     $this->collector->excludeSourceAccounts(new Collection([$account])); | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |                 if (null === $account) { | 
					
						
							|  |  |  |                     // since the source does not exist, cannot return results:
 | 
					
						
							|  |  |  |                     $this->collector->findNothing(); | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2020-08-24 07:03:17 +02:00
										 |  |  |             case 'journal_id': | 
					
						
							|  |  |  |                 $parts = explode(',', $value); | 
					
						
							|  |  |  |                 $this->collector->setJournalIds($parts); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             case '-journal_id': | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  |                 $parts = explode(',', $value); | 
					
						
							|  |  |  |                 $this->collector->excludeJournalIds($parts); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2021-01-20 18:41:31 +01:00
										 |  |  |             case 'id': | 
					
						
							|  |  |  |                 $parts = explode(',', $value); | 
					
						
							|  |  |  |                 $this->collector->setIds($parts); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             case '-id': | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  |                 $parts = explode(',', $value); | 
					
						
							|  |  |  |                 $this->collector->excludeIds($parts); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2020-08-22 12:24:01 +02:00
										 |  |  |             case 'destination_account_starts': | 
					
						
							|  |  |  |                 $this->searchAccount($value, 2, 1); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             case '-destination_account_starts': | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  |                 $this->searchAccount($value, 2, 1, true); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2020-08-22 12:24:01 +02:00
										 |  |  |             case 'destination_account_ends': | 
					
						
							|  |  |  |                 $this->searchAccount($value, 2, 2); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             case '-destination_account_ends': | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  |                 $this->searchAccount($value, 2, 2, true); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2020-08-22 12:24:01 +02:00
										 |  |  |             case 'destination_account_nr_starts': | 
					
						
							|  |  |  |                 $this->searchAccountNr($value, 2, 1); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             case '-destination_account_nr_starts': | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  |                 $this->searchAccountNr($value, 2, 1, true); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2020-08-22 12:24:01 +02:00
										 |  |  |             case 'destination_account_nr_ends': | 
					
						
							|  |  |  |                 $this->searchAccountNr($value, 2, 2); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             case '-destination_account_nr_ends': | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  |                 $this->searchAccountNr($value, 2, 2, true); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2020-08-22 12:24:01 +02:00
										 |  |  |             case 'destination_account_nr_is': | 
					
						
							|  |  |  |                 $this->searchAccountNr($value, 2, 4); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             case '-destination_account_nr_is': | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  |                 $this->searchAccountNr($value, 2, 4, true); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2020-08-22 12:24:01 +02:00
										 |  |  |             case 'destination_account_is': | 
					
						
							|  |  |  |                 $this->searchAccount($value, 2, 4); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             case '-destination_account_is': | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  |                 $this->searchAccount($value, 2, 4, true); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2020-08-22 12:24:01 +02:00
										 |  |  |             case 'destination_account_nr_contains': | 
					
						
							|  |  |  |                 $this->searchAccountNr($value, 2, 3); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             case '-destination_account_nr_contains': | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  |                 $this->searchAccountNr($value, 2, 3, true); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2020-08-22 12:24:01 +02:00
										 |  |  |             case 'destination_account_contains': | 
					
						
							|  |  |  |                 $this->searchAccount($value, 2, 3); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             case '-destination_account_contains': | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  |                 $this->searchAccount($value, 2, 3, true); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2020-08-22 12:24:01 +02:00
										 |  |  |             case 'destination_account_id': | 
					
						
							| 
									
										
										
										
											2022-12-29 19:42:26 +01:00
										 |  |  |                 $account = $this->accountRepository->find((int)$value); | 
					
						
							| 
									
										
										
										
											2020-08-22 13:01:37 +02:00
										 |  |  |                 if (null !== $account) { | 
					
						
							| 
									
										
										
										
											2020-08-22 12:24:01 +02:00
										 |  |  |                     $this->collector->setDestinationAccounts(new Collection([$account])); | 
					
						
							|  |  |  |                 } | 
					
						
							| 
									
										
										
										
											2021-09-17 08:46:03 +02:00
										 |  |  |                 if (null === $account) { | 
					
						
							|  |  |  |                     $this->collector->findNothing(); | 
					
						
							|  |  |  |                 } | 
					
						
							| 
									
										
										
										
											2020-08-22 12:24:01 +02:00
										 |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             case '-destination_account_id': | 
					
						
							| 
									
										
										
										
											2022-12-29 19:42:26 +01:00
										 |  |  |                 $account = $this->accountRepository->find((int)$value); | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  |                 if (null !== $account) { | 
					
						
							|  |  |  |                     $this->collector->excludeDestinationAccounts(new Collection([$account])); | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |                 if (null === $account) { | 
					
						
							|  |  |  |                     $this->collector->findNothing(); | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2020-08-22 12:24:01 +02:00
										 |  |  |             case 'account_id': | 
					
						
							| 
									
										
										
										
											2020-08-22 16:55:54 +02:00
										 |  |  |                 $parts      = explode(',', $value); | 
					
						
							| 
									
										
										
										
											2022-10-30 14:24:37 +01:00
										 |  |  |                 $collection = new Collection(); | 
					
						
							| 
									
										
										
										
											2020-08-22 16:55:54 +02:00
										 |  |  |                 foreach ($parts as $accountId) { | 
					
						
							| 
									
										
										
										
											2022-12-29 19:42:26 +01:00
										 |  |  |                     $account = $this->accountRepository->find((int)$accountId); | 
					
						
							| 
									
										
										
										
											2020-08-22 16:55:54 +02:00
										 |  |  |                     if (null !== $account) { | 
					
						
							|  |  |  |                         $collection->push($account); | 
					
						
							|  |  |  |                     } | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |                 if ($collection->count() > 0) { | 
					
						
							|  |  |  |                     $this->collector->setAccounts($collection); | 
					
						
							| 
									
										
										
										
											2020-08-09 18:58:18 +02:00
										 |  |  |                 } | 
					
						
							| 
									
										
										
										
											2021-09-17 08:46:03 +02:00
										 |  |  |                 if (0 === $collection->count()) { | 
					
						
							|  |  |  |                     $this->collector->findNothing(); | 
					
						
							|  |  |  |                 } | 
					
						
							| 
									
										
										
										
											2020-08-09 18:58:18 +02:00
										 |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             case '-account_id': | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  |                 $parts      = explode(',', $value); | 
					
						
							| 
									
										
										
										
											2022-10-30 14:24:37 +01:00
										 |  |  |                 $collection = new Collection(); | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  |                 foreach ($parts as $accountId) { | 
					
						
							| 
									
										
										
										
											2022-12-29 19:42:26 +01:00
										 |  |  |                     $account = $this->accountRepository->find((int)$accountId); | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  |                     if (null !== $account) { | 
					
						
							|  |  |  |                         $collection->push($account); | 
					
						
							|  |  |  |                     } | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |                 if ($collection->count() > 0) { | 
					
						
							|  |  |  |                     $this->collector->setNotAccounts($collection); | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |                 if (0 === $collection->count()) { | 
					
						
							|  |  |  |                     $this->collector->findNothing(); | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2020-08-22 12:24:01 +02:00
										 |  |  |             //
 | 
					
						
							| 
									
										
										
										
											2022-10-30 14:24:37 +01:00
										 |  |  |                 // cash account
 | 
					
						
							| 
									
										
										
										
											2020-08-26 20:18:27 +02:00
										 |  |  |             //
 | 
					
						
							|  |  |  |             case 'source_is_cash': | 
					
						
							|  |  |  |                 $account = $this->getCashAccount(); | 
					
						
							|  |  |  |                 $this->collector->setSourceAccounts(new Collection([$account])); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             case '-source_is_cash': | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  |                 $account = $this->getCashAccount(); | 
					
						
							|  |  |  |                 $this->collector->excludeSourceAccounts(new Collection([$account])); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2020-08-26 20:18:27 +02:00
										 |  |  |             case 'destination_is_cash': | 
					
						
							|  |  |  |                 $account = $this->getCashAccount(); | 
					
						
							|  |  |  |                 $this->collector->setDestinationAccounts(new Collection([$account])); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             case '-destination_is_cash': | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  |                 $account = $this->getCashAccount(); | 
					
						
							|  |  |  |                 $this->collector->excludeDestinationAccounts(new Collection([$account])); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2020-08-26 20:18:27 +02:00
										 |  |  |             case 'account_is_cash': | 
					
						
							|  |  |  |                 $account = $this->getCashAccount(); | 
					
						
							|  |  |  |                 $this->collector->setAccounts(new Collection([$account])); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             case '-account_is_cash': | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  |                 $account = $this->getCashAccount(); | 
					
						
							|  |  |  |                 $this->collector->excludeAccounts(new Collection([$account])); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2020-08-26 20:18:27 +02:00
										 |  |  |             //
 | 
					
						
							| 
									
										
										
										
											2022-10-30 14:24:37 +01:00
										 |  |  |                 // description
 | 
					
						
							| 
									
										
										
										
											2020-08-22 12:24:01 +02:00
										 |  |  |             //
 | 
					
						
							|  |  |  |             case 'description_starts': | 
					
						
							|  |  |  |                 $this->collector->descriptionStarts([$value]); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             case '-description_starts': | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  |                 $this->collector->descriptionDoesNotStart([$value]); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2020-08-22 12:24:01 +02:00
										 |  |  |             case 'description_ends': | 
					
						
							|  |  |  |                 $this->collector->descriptionEnds([$value]); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             case '-description_ends': | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  |                 $this->collector->descriptionDoesNotEnd([$value]); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2020-08-22 12:24:01 +02:00
										 |  |  |             case 'description_contains': | 
					
						
							|  |  |  |                 $this->words[] = $value; | 
					
						
							| 
									
										
										
										
											2020-10-24 07:40:56 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-08-22 12:24:01 +02:00
										 |  |  |                 return false; | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             case '-description_contains': | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  |                 $this->prohibitedWords[] = $value; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2020-08-22 12:24:01 +02:00
										 |  |  |             case 'description_is': | 
					
						
							|  |  |  |                 $this->collector->descriptionIs($value); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             case '-description_is': | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  |                 $this->collector->descriptionIsNot($value); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2020-08-22 12:24:01 +02:00
										 |  |  |             //
 | 
					
						
							| 
									
										
										
										
											2022-10-30 14:24:37 +01:00
										 |  |  |                 // currency
 | 
					
						
							| 
									
										
										
										
											2020-08-22 12:24:01 +02:00
										 |  |  |             //
 | 
					
						
							|  |  |  |             case 'currency_is': | 
					
						
							|  |  |  |                 $currency = $this->findCurrency($value); | 
					
						
							|  |  |  |                 if (null !== $currency) { | 
					
						
							|  |  |  |                     $this->collector->setCurrency($currency); | 
					
						
							|  |  |  |                 } | 
					
						
							| 
									
										
										
										
											2021-09-17 08:46:03 +02:00
										 |  |  |                 if (null === $currency) { | 
					
						
							|  |  |  |                     $this->collector->findNothing(); | 
					
						
							|  |  |  |                 } | 
					
						
							| 
									
										
										
										
											2020-08-22 12:24:01 +02:00
										 |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             case '-currency_is': | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  |                 $currency = $this->findCurrency($value); | 
					
						
							|  |  |  |                 if (null !== $currency) { | 
					
						
							|  |  |  |                     $this->collector->excludeCurrency($currency); | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |                 if (null === $currency) { | 
					
						
							|  |  |  |                     $this->collector->findNothing(); | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2020-08-22 12:24:01 +02:00
										 |  |  |             case 'foreign_currency_is': | 
					
						
							|  |  |  |                 $currency = $this->findCurrency($value); | 
					
						
							|  |  |  |                 if (null !== $currency) { | 
					
						
							|  |  |  |                     $this->collector->setForeignCurrency($currency); | 
					
						
							|  |  |  |                 } | 
					
						
							| 
									
										
										
										
											2021-09-17 08:46:03 +02:00
										 |  |  |                 if (null === $currency) { | 
					
						
							|  |  |  |                     $this->collector->findNothing(); | 
					
						
							|  |  |  |                 } | 
					
						
							| 
									
										
										
										
											2020-08-22 12:24:01 +02:00
										 |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             case '-foreign_currency_is': | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  |                 $currency = $this->findCurrency($value); | 
					
						
							|  |  |  |                 if (null !== $currency) { | 
					
						
							|  |  |  |                     $this->collector->excludeForeignCurrency($currency); | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |                 if (null === $currency) { | 
					
						
							|  |  |  |                     $this->collector->findNothing(); | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2020-08-22 12:24:01 +02:00
										 |  |  |             //
 | 
					
						
							| 
									
										
										
										
											2022-10-30 14:24:37 +01:00
										 |  |  |                 // attachments
 | 
					
						
							| 
									
										
										
										
											2020-08-22 12:24:01 +02:00
										 |  |  |             //
 | 
					
						
							|  |  |  |             case 'has_attachments': | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             case '-has_no_attachments': | 
					
						
							| 
									
										
										
										
											2020-08-22 12:24:01 +02:00
										 |  |  |                 Log::debug('Set collector to filter on attachments.'); | 
					
						
							|  |  |  |                 $this->collector->hasAttachments(); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-03-27 08:48:30 +02:00
										 |  |  |             case 'has_no_attachments': | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             case '-has_attachments': | 
					
						
							| 
									
										
										
										
											2022-03-27 08:48:30 +02:00
										 |  |  |                 Log::debug('Set collector to filter on NO attachments.'); | 
					
						
							|  |  |  |                 $this->collector->hasNoAttachments(); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2020-08-22 12:24:01 +02:00
										 |  |  |             //
 | 
					
						
							| 
									
										
										
										
											2022-10-30 14:24:37 +01:00
										 |  |  |                 // categories
 | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             case '-has_any_category': | 
					
						
							| 
									
										
										
										
											2020-08-22 12:24:01 +02:00
										 |  |  |             case 'has_no_category': | 
					
						
							|  |  |  |                 $this->collector->withoutCategory(); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             case '-has_no_category': | 
					
						
							| 
									
										
										
										
											2020-08-22 12:24:01 +02:00
										 |  |  |             case 'has_any_category': | 
					
						
							|  |  |  |                 $this->collector->withCategory(); | 
					
						
							|  |  |  |                 break; | 
					
						
							|  |  |  |             case 'category_is': | 
					
						
							| 
									
										
										
										
											2022-03-20 17:11:33 +01:00
										 |  |  |                 $category = $this->categoryRepository->findByName($value); | 
					
						
							|  |  |  |                 if (null !== $category) { | 
					
						
							|  |  |  |                     $this->collector->setCategory($category); | 
					
						
							|  |  |  |                     break; | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |                 $this->collector->findNothing(); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             case '-category_is': | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  |                 $category = $this->categoryRepository->findByName($value); | 
					
						
							|  |  |  |                 if (null !== $category) { | 
					
						
							|  |  |  |                     $this->collector->excludeCategory($category); | 
					
						
							|  |  |  |                     break; | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-03-20 17:11:33 +01:00
										 |  |  |             case 'category_ends': | 
					
						
							|  |  |  |                 $result = $this->categoryRepository->categoryEndsWith($value, 1337); | 
					
						
							|  |  |  |                 if ($result->count() > 0) { | 
					
						
							|  |  |  |                     $this->collector->setCategories($result); | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |                 if (0 === $result->count()) { | 
					
						
							|  |  |  |                     $this->collector->findNothing(); | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             case '-category_ends': | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  |                 $result = $this->categoryRepository->categoryEndsWith($value, 1337); | 
					
						
							|  |  |  |                 if ($result->count() > 0) { | 
					
						
							|  |  |  |                     $this->collector->excludeCategories($result); | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |                 if (0 === $result->count()) { | 
					
						
							|  |  |  |                     $this->collector->findNothing(); | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-03-20 17:11:33 +01:00
										 |  |  |             case 'category_starts': | 
					
						
							|  |  |  |                 $result = $this->categoryRepository->categoryStartsWith($value, 1337); | 
					
						
							|  |  |  |                 if ($result->count() > 0) { | 
					
						
							|  |  |  |                     $this->collector->setCategories($result); | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |                 if (0 === $result->count()) { | 
					
						
							|  |  |  |                     $this->collector->findNothing(); | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             case '-category_starts': | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  |                 $result = $this->categoryRepository->categoryStartsWith($value, 1337); | 
					
						
							|  |  |  |                 if ($result->count() > 0) { | 
					
						
							|  |  |  |                     $this->collector->excludeCategories($result); | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |                 if (0 === $result->count()) { | 
					
						
							|  |  |  |                     $this->collector->findNothing(); | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-03-20 17:11:33 +01:00
										 |  |  |             case 'category_contains': | 
					
						
							| 
									
										
										
										
											2022-02-02 20:15:28 +01:00
										 |  |  |                 $result = $this->categoryRepository->searchCategory($value, 1337); | 
					
						
							| 
									
										
										
										
											2020-08-09 18:58:18 +02:00
										 |  |  |                 if ($result->count() > 0) { | 
					
						
							|  |  |  |                     $this->collector->setCategories($result); | 
					
						
							|  |  |  |                 } | 
					
						
							| 
									
										
										
										
											2021-09-17 08:46:03 +02:00
										 |  |  |                 if (0 === $result->count()) { | 
					
						
							|  |  |  |                     $this->collector->findNothing(); | 
					
						
							|  |  |  |                 } | 
					
						
							| 
									
										
										
										
											2020-08-09 18:58:18 +02:00
										 |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             case '-category_contains': | 
					
						
							| 
									
										
										
										
											2022-09-24 18:06:01 +02:00
										 |  |  |                 $result = $this->categoryRepository->searchCategory($value, 1337); | 
					
						
							|  |  |  |                 if ($result->count() > 0) { | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  |                     $this->collector->excludeCategories($result); | 
					
						
							| 
									
										
										
										
											2022-09-24 18:06:01 +02:00
										 |  |  |                 } | 
					
						
							|  |  |  |                 if (0 === $result->count()) { | 
					
						
							|  |  |  |                     $this->collector->findNothing(); | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2020-08-22 12:24:01 +02:00
										 |  |  |             //
 | 
					
						
							| 
									
										
										
										
											2022-10-30 14:24:37 +01:00
										 |  |  |                 // budgets
 | 
					
						
							| 
									
										
										
										
											2020-08-22 12:24:01 +02:00
										 |  |  |             //
 | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             case '-has_any_budget': | 
					
						
							| 
									
										
										
										
											2020-08-22 12:24:01 +02:00
										 |  |  |             case 'has_no_budget': | 
					
						
							|  |  |  |                 $this->collector->withoutBudget(); | 
					
						
							|  |  |  |                 break; | 
					
						
							|  |  |  |             case 'has_any_budget': | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             case '-has_no_budget': | 
					
						
							| 
									
										
										
										
											2020-08-22 12:24:01 +02:00
										 |  |  |                 $this->collector->withBudget(); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-03-20 17:11:33 +01:00
										 |  |  |             case 'budget_contains': | 
					
						
							| 
									
										
										
										
											2022-02-02 20:15:28 +01:00
										 |  |  |                 $result = $this->budgetRepository->searchBudget($value, 1337); | 
					
						
							| 
									
										
										
										
											2020-08-22 12:24:01 +02:00
										 |  |  |                 if ($result->count() > 0) { | 
					
						
							|  |  |  |                     $this->collector->setBudgets($result); | 
					
						
							|  |  |  |                 } | 
					
						
							| 
									
										
										
										
											2021-09-17 08:46:03 +02:00
										 |  |  |                 if (0 === $result->count()) { | 
					
						
							|  |  |  |                     $this->collector->findNothing(); | 
					
						
							|  |  |  |                 } | 
					
						
							| 
									
										
										
										
											2020-08-22 12:24:01 +02:00
										 |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             case '-budget_contains': | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  |                 $result = $this->budgetRepository->searchBudget($value, 1337); | 
					
						
							|  |  |  |                 if ($result->count() > 0) { | 
					
						
							|  |  |  |                     $this->collector->excludeBudgets($result); | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |                 if (0 === $result->count()) { | 
					
						
							|  |  |  |                     $this->collector->findNothing(); | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-03-20 17:11:33 +01:00
										 |  |  |             case 'budget_is': | 
					
						
							|  |  |  |                 $budget = $this->budgetRepository->findByName($value); | 
					
						
							|  |  |  |                 if (null !== $budget) { | 
					
						
							|  |  |  |                     $this->collector->setBudget($budget); | 
					
						
							|  |  |  |                     break; | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |                 $this->collector->findNothing(); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             case '-budget_is': | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  |                 $budget = $this->budgetRepository->findByName($value); | 
					
						
							|  |  |  |                 if (null !== $budget) { | 
					
						
							|  |  |  |                     $this->collector->excludeBudget($budget); | 
					
						
							|  |  |  |                     break; | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |                 $this->collector->findNothing(); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-03-20 17:11:33 +01:00
										 |  |  |             case 'budget_ends': | 
					
						
							|  |  |  |                 $result = $this->budgetRepository->budgetEndsWith($value, 1337); | 
					
						
							|  |  |  |                 if ($result->count() > 0) { | 
					
						
							|  |  |  |                     $this->collector->setBudgets($result); | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |                 if (0 === $result->count()) { | 
					
						
							|  |  |  |                     $this->collector->findNothing(); | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             case '-budget_ends': | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  |                 $result = $this->budgetRepository->budgetEndsWith($value, 1337); | 
					
						
							|  |  |  |                 if ($result->count() > 0) { | 
					
						
							|  |  |  |                     $this->collector->excludeBudgets($result); | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |                 if (0 === $result->count()) { | 
					
						
							|  |  |  |                     $this->collector->findNothing(); | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-03-20 17:11:33 +01:00
										 |  |  |             case 'budget_starts': | 
					
						
							|  |  |  |                 $result = $this->budgetRepository->budgetStartsWith($value, 1337); | 
					
						
							|  |  |  |                 if ($result->count() > 0) { | 
					
						
							|  |  |  |                     $this->collector->setBudgets($result); | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |                 if (0 === $result->count()) { | 
					
						
							|  |  |  |                     $this->collector->findNothing(); | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             case '-budget_starts': | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  |                 $result = $this->budgetRepository->budgetStartsWith($value, 1337); | 
					
						
							|  |  |  |                 if ($result->count() > 0) { | 
					
						
							|  |  |  |                     $this->collector->excludeBudgets($result); | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |                 if (0 === $result->count()) { | 
					
						
							|  |  |  |                     $this->collector->findNothing(); | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2020-08-22 12:24:01 +02:00
										 |  |  |             //
 | 
					
						
							| 
									
										
										
										
											2022-10-30 14:24:37 +01:00
										 |  |  |                 // bill
 | 
					
						
							| 
									
										
										
										
											2020-08-22 12:24:01 +02:00
										 |  |  |             //
 | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             case '-has_any_bill': | 
					
						
							| 
									
										
										
										
											2021-04-08 16:07:07 +02:00
										 |  |  |             case 'has_no_bill': | 
					
						
							|  |  |  |                 $this->collector->withoutBill(); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             case '-has_no_bill': | 
					
						
							| 
									
										
										
										
											2021-04-08 16:07:07 +02:00
										 |  |  |             case 'has_any_bill': | 
					
						
							|  |  |  |                 $this->collector->withBill(); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-03-20 17:11:33 +01:00
										 |  |  |             case 'bill_contains': | 
					
						
							| 
									
										
										
										
											2022-02-02 20:15:28 +01:00
										 |  |  |                 $result = $this->billRepository->searchBill($value, 1337); | 
					
						
							| 
									
										
										
										
											2022-03-20 17:11:33 +01:00
										 |  |  |                 if ($result->count() > 0) { | 
					
						
							|  |  |  |                     $this->collector->setBills($result); | 
					
						
							|  |  |  |                     break; | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |                 $this->collector->findNothing(); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             case '-bill_contains': | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  |                 $result = $this->billRepository->searchBill($value, 1337); | 
					
						
							|  |  |  |                 if ($result->count() > 0) { | 
					
						
							|  |  |  |                     $this->collector->excludeBills($result); | 
					
						
							|  |  |  |                     break; | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |                 $this->collector->findNothing(); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-03-20 17:11:33 +01:00
										 |  |  |             case 'bill_is': | 
					
						
							|  |  |  |                 $bill = $this->billRepository->findByName($value); | 
					
						
							|  |  |  |                 if (null !== $bill) { | 
					
						
							|  |  |  |                     $this->collector->setBill($bill); | 
					
						
							|  |  |  |                     break; | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |                 $this->collector->findNothing(); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             case '-bill_is': | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  |                 $bill = $this->billRepository->findByName($value); | 
					
						
							|  |  |  |                 if (null !== $bill) { | 
					
						
							|  |  |  |                     $this->collector->excludeBills(new Collection([$bill])); | 
					
						
							|  |  |  |                     break; | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |                 $this->collector->findNothing(); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-03-20 17:11:33 +01:00
										 |  |  |             case 'bill_ends': | 
					
						
							|  |  |  |                 $result = $this->billRepository->billEndsWith($value, 1337); | 
					
						
							|  |  |  |                 if ($result->count() > 0) { | 
					
						
							|  |  |  |                     $this->collector->setBills($result); | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |                 if (0 === $result->count()) { | 
					
						
							|  |  |  |                     $this->collector->findNothing(); | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             case '-bill_ends': | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  |                 $result = $this->billRepository->billEndsWith($value, 1337); | 
					
						
							|  |  |  |                 if ($result->count() > 0) { | 
					
						
							|  |  |  |                     $this->collector->excludeBills($result); | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |                 if (0 === $result->count()) { | 
					
						
							|  |  |  |                     $this->collector->findNothing(); | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-03-20 17:11:33 +01:00
										 |  |  |             case 'bill_starts': | 
					
						
							|  |  |  |                 $result = $this->billRepository->billStartsWith($value, 1337); | 
					
						
							| 
									
										
										
										
											2020-08-09 18:58:18 +02:00
										 |  |  |                 if ($result->count() > 0) { | 
					
						
							|  |  |  |                     $this->collector->setBills($result); | 
					
						
							|  |  |  |                 } | 
					
						
							| 
									
										
										
										
											2021-09-17 08:46:03 +02:00
										 |  |  |                 if (0 === $result->count()) { | 
					
						
							|  |  |  |                     $this->collector->findNothing(); | 
					
						
							|  |  |  |                 } | 
					
						
							| 
									
										
										
										
											2020-08-09 18:58:18 +02:00
										 |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             case '-bill_starts': | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  |                 $result = $this->billRepository->billStartsWith($value, 1337); | 
					
						
							|  |  |  |                 if ($result->count() > 0) { | 
					
						
							|  |  |  |                     $this->collector->excludeBills($result); | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |                 if (0 === $result->count()) { | 
					
						
							|  |  |  |                     $this->collector->findNothing(); | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2020-08-22 12:24:01 +02:00
										 |  |  |             //
 | 
					
						
							| 
									
										
										
										
											2022-10-30 14:24:37 +01:00
										 |  |  |                 // tags
 | 
					
						
							| 
									
										
										
										
											2020-08-22 12:24:01 +02:00
										 |  |  |             //
 | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             case '-has_any_tag': | 
					
						
							| 
									
										
										
										
											2020-08-22 12:24:01 +02:00
										 |  |  |             case 'has_no_tag': | 
					
						
							|  |  |  |                 $this->collector->withoutTags(); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             case '-has_no_tag': | 
					
						
							| 
									
										
										
										
											2020-08-22 12:24:01 +02:00
										 |  |  |             case 'has_any_tag': | 
					
						
							|  |  |  |                 $this->collector->hasAnyTag(); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             case '-tag_is_not': | 
					
						
							| 
									
										
										
										
											2020-08-23 18:48:40 +02:00
										 |  |  |             case 'tag_is': | 
					
						
							| 
									
										
										
										
											2020-08-09 18:58:18 +02:00
										 |  |  |                 $result = $this->tagRepository->searchTag($value); | 
					
						
							|  |  |  |                 if ($result->count() > 0) { | 
					
						
							|  |  |  |                     $this->collector->setTags($result); | 
					
						
							|  |  |  |                 } | 
					
						
							| 
									
										
										
										
											2021-09-17 08:46:03 +02:00
										 |  |  |                 // no tags found means search must result in nothing.
 | 
					
						
							|  |  |  |                 if (0 === $result->count()) { | 
					
						
							|  |  |  |                     Log::info(sprintf('No valid tags in "%s"-operator, so search will not return ANY results.', $operator)); | 
					
						
							|  |  |  |                     $this->collector->findNothing(); | 
					
						
							|  |  |  |                 } | 
					
						
							| 
									
										
										
										
											2020-08-09 18:58:18 +02:00
										 |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             case '-tag_is': | 
					
						
							| 
									
										
										
										
											2022-03-20 17:11:33 +01:00
										 |  |  |             case 'tag_is_not': | 
					
						
							|  |  |  |                 $result = $this->tagRepository->searchTag($value); | 
					
						
							|  |  |  |                 if ($result->count() > 0) { | 
					
						
							|  |  |  |                     $this->collector->setWithoutSpecificTags($result); | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2020-08-22 12:24:01 +02:00
										 |  |  |             //
 | 
					
						
							| 
									
										
										
										
											2022-10-30 14:24:37 +01:00
										 |  |  |                 // notes
 | 
					
						
							| 
									
										
										
										
											2020-08-22 12:24:01 +02:00
										 |  |  |             //
 | 
					
						
							| 
									
										
										
										
											2022-03-20 17:11:33 +01:00
										 |  |  |             case 'notes_contains': | 
					
						
							| 
									
										
										
										
											2020-08-22 12:24:01 +02:00
										 |  |  |                 $this->collector->notesContain($value); | 
					
						
							| 
									
										
										
										
											2020-08-09 18:58:18 +02:00
										 |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             case '-notes_contains': | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  |                 $this->collector->notesDoNotContain($value); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-03-20 17:11:33 +01:00
										 |  |  |             case 'notes_starts': | 
					
						
							| 
									
										
										
										
											2020-08-22 12:24:01 +02:00
										 |  |  |                 $this->collector->notesStartWith($value); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             case '-notes_starts': | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  |                 $this->collector->notesDontStartWith($value); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-03-20 17:11:33 +01:00
										 |  |  |             case 'notes_ends': | 
					
						
							| 
									
										
										
										
											2020-08-22 12:24:01 +02:00
										 |  |  |                 $this->collector->notesEndWith($value); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             case '-notes_ends': | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  |                 $this->collector->notesDontEndWith($value); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-03-20 17:11:33 +01:00
										 |  |  |             case 'notes_is': | 
					
						
							| 
									
										
										
										
											2020-08-22 12:24:01 +02:00
										 |  |  |                 $this->collector->notesExactly($value); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             case '-notes_is': | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  |                 $this->collector->notesExactlyNot($value); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             case '-any_notes': | 
					
						
							| 
									
										
										
										
											2020-08-22 12:24:01 +02:00
										 |  |  |             case 'no_notes': | 
					
						
							|  |  |  |                 $this->collector->withoutNotes(); | 
					
						
							|  |  |  |                 break; | 
					
						
							|  |  |  |             case 'any_notes': | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             case '-no_notes': | 
					
						
							| 
									
										
										
										
											2020-08-22 12:24:01 +02:00
										 |  |  |                 $this->collector->withAnyNotes(); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-09-18 12:23:20 +02:00
										 |  |  |             case 'reconciled': | 
					
						
							|  |  |  |                 $this->collector->isReconciled(); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             case '-reconciled': | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  |                 $this->collector->isNotReconciled(); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2020-08-22 12:24:01 +02:00
										 |  |  |             //
 | 
					
						
							| 
									
										
										
										
											2022-10-30 14:24:37 +01:00
										 |  |  |                 // amount
 | 
					
						
							| 
									
										
										
										
											2020-08-22 12:24:01 +02:00
										 |  |  |             //
 | 
					
						
							| 
									
										
										
										
											2022-03-20 17:11:33 +01:00
										 |  |  |             case 'amount_is': | 
					
						
							| 
									
										
										
										
											2020-12-01 12:24:23 +01:00
										 |  |  |                 // strip comma's, make dots.
 | 
					
						
							| 
									
										
										
										
											2022-05-04 20:32:51 +02:00
										 |  |  |                 Log::debug(sprintf('Original value "%s"', $value)); | 
					
						
							| 
									
										
										
										
											2022-12-29 19:42:26 +01:00
										 |  |  |                 $value  = str_replace(',', '.', (string)$value); | 
					
						
							| 
									
										
										
										
											2020-12-01 12:24:23 +01:00
										 |  |  |                 $amount = app('steam')->positive($value); | 
					
						
							| 
									
										
										
										
											2020-08-09 18:58:18 +02:00
										 |  |  |                 Log::debug(sprintf('Set "%s" using collector with value "%s"', $operator, $amount)); | 
					
						
							|  |  |  |                 $this->collector->amountIs($amount); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             case '-amount_is': | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  |                 // strip comma's, make dots.
 | 
					
						
							|  |  |  |                 Log::debug(sprintf('Original value "%s"', $value)); | 
					
						
							| 
									
										
										
										
											2022-12-29 19:42:26 +01:00
										 |  |  |                 $value  = str_replace(',', '.', (string)$value); | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  |                 $amount = app('steam')->positive($value); | 
					
						
							|  |  |  |                 Log::debug(sprintf('Set "%s" using collector with value "%s"', $operator, $amount)); | 
					
						
							|  |  |  |                 $this->collector->amountIsNot($amount); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-03-27 16:03:50 +02:00
										 |  |  |             case 'foreign_amount_is': | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 // strip comma's, make dots.
 | 
					
						
							| 
									
										
										
										
											2022-12-29 19:42:26 +01:00
										 |  |  |                 $value = str_replace(',', '.', (string)$value); | 
					
						
							| 
									
										
										
										
											2022-03-27 16:03:50 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |                 $amount = app('steam')->positive($value); | 
					
						
							|  |  |  |                 Log::debug(sprintf('Set "%s" using collector with value "%s"', $operator, $amount)); | 
					
						
							|  |  |  |                 $this->collector->foreignAmountIs($amount); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             case '-foreign_amount_is': | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |                 // strip comma's, make dots.
 | 
					
						
							| 
									
										
										
										
											2022-12-29 19:42:26 +01:00
										 |  |  |                 $value = str_replace(',', '.', (string)$value); | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |                 $amount = app('steam')->positive($value); | 
					
						
							|  |  |  |                 Log::debug(sprintf('Set "%s" using collector with value "%s"', $operator, $amount)); | 
					
						
							|  |  |  |                 $this->collector->foreignAmountIsNot($amount); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             case '-amount_more': | 
					
						
							| 
									
										
										
										
											2020-08-09 18:58:18 +02:00
										 |  |  |             case 'amount_less': | 
					
						
							| 
									
										
										
										
											2020-12-01 12:24:23 +01:00
										 |  |  |                 // strip comma's, make dots.
 | 
					
						
							| 
									
										
										
										
											2022-12-29 19:42:26 +01:00
										 |  |  |                 $value = str_replace(',', '.', (string)$value); | 
					
						
							| 
									
										
										
										
											2020-12-01 12:24:23 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |                 $amount = app('steam')->positive($value); | 
					
						
							| 
									
										
										
										
											2020-08-09 18:58:18 +02:00
										 |  |  |                 Log::debug(sprintf('Set "%s" using collector with value "%s"', $operator, $amount)); | 
					
						
							|  |  |  |                 $this->collector->amountLess($amount); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             case '-foreign_amount_more': | 
					
						
							| 
									
										
										
										
											2022-03-27 16:03:50 +02:00
										 |  |  |             case 'foreign_amount_less': | 
					
						
							|  |  |  |                 // strip comma's, make dots.
 | 
					
						
							| 
									
										
										
										
											2022-12-29 19:42:26 +01:00
										 |  |  |                 $value = str_replace(',', '.', (string)$value); | 
					
						
							| 
									
										
										
										
											2022-03-27 16:03:50 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |                 $amount = app('steam')->positive($value); | 
					
						
							|  |  |  |                 Log::debug(sprintf('Set "%s" using collector with value "%s"', $operator, $amount)); | 
					
						
							|  |  |  |                 $this->collector->foreignAmountLess($amount); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             case '-amount_less': | 
					
						
							| 
									
										
										
										
											2020-08-09 18:58:18 +02:00
										 |  |  |             case 'amount_more': | 
					
						
							| 
									
										
										
										
											2021-05-13 05:34:49 +02:00
										 |  |  |                 Log::debug(sprintf('Now handling operator "%s"', $operator)); | 
					
						
							| 
									
										
										
										
											2020-12-01 12:24:23 +01:00
										 |  |  |                 // strip comma's, make dots.
 | 
					
						
							| 
									
										
										
										
											2022-12-29 19:42:26 +01:00
										 |  |  |                 $value  = str_replace(',', '.', (string)$value); | 
					
						
							| 
									
										
										
										
											2020-12-01 12:24:23 +01:00
										 |  |  |                 $amount = app('steam')->positive($value); | 
					
						
							| 
									
										
										
										
											2020-08-09 18:58:18 +02:00
										 |  |  |                 Log::debug(sprintf('Set "%s" using collector with value "%s"', $operator, $amount)); | 
					
						
							|  |  |  |                 $this->collector->amountMore($amount); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             case '-foreign_amount_less': | 
					
						
							| 
									
										
										
										
											2022-03-27 16:03:50 +02:00
										 |  |  |             case 'foreign_amount_more': | 
					
						
							|  |  |  |                 Log::debug(sprintf('Now handling operator "%s"', $operator)); | 
					
						
							|  |  |  |                 // strip comma's, make dots.
 | 
					
						
							| 
									
										
										
										
											2022-12-29 19:42:26 +01:00
										 |  |  |                 $value  = str_replace(',', '.', (string)$value); | 
					
						
							| 
									
										
										
										
											2022-03-27 16:03:50 +02:00
										 |  |  |                 $amount = app('steam')->positive($value); | 
					
						
							|  |  |  |                 Log::debug(sprintf('Set "%s" using collector with value "%s"', $operator, $amount)); | 
					
						
							|  |  |  |                 $this->collector->foreignAmountMore($amount); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2020-08-22 12:24:01 +02:00
										 |  |  |             //
 | 
					
						
							| 
									
										
										
										
											2022-10-30 14:24:37 +01:00
										 |  |  |                 // transaction type
 | 
					
						
							| 
									
										
										
										
											2020-08-22 12:24:01 +02:00
										 |  |  |             //
 | 
					
						
							|  |  |  |             case 'transaction_type': | 
					
						
							| 
									
										
										
										
											2020-08-09 18:58:18 +02:00
										 |  |  |                 $this->collector->setTypes([ucfirst($value)]); | 
					
						
							|  |  |  |                 Log::debug(sprintf('Set "%s" using collector with value "%s"', $operator, $value)); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             case '-transaction_type': | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  |                 $this->collector->excludeTypes([ucfirst($value)]); | 
					
						
							|  |  |  |                 Log::debug(sprintf('Set "%s" using collector with value "%s"', $operator, $value)); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2020-08-22 12:24:01 +02:00
										 |  |  |             //
 | 
					
						
							| 
									
										
										
										
											2022-10-30 14:24:37 +01:00
										 |  |  |                 // dates
 | 
					
						
							| 
									
										
										
										
											2020-08-22 12:24:01 +02:00
										 |  |  |             //
 | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             case '-date_on': | 
					
						
							| 
									
										
										
										
											2022-03-27 08:48:30 +02:00
										 |  |  |             case 'date_on': | 
					
						
							| 
									
										
										
										
											2020-08-22 13:01:37 +02:00
										 |  |  |                 $range = $this->parseDateRange($value); | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  |                 $this->setExactDateParams($range, $prohibited); | 
					
						
							| 
									
										
										
										
											2020-08-22 13:01:37 +02:00
										 |  |  |                 return false; | 
					
						
							| 
									
										
										
										
											2020-08-09 18:58:18 +02:00
										 |  |  |             case 'date_before': | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             case '-date_after': | 
					
						
							| 
									
										
										
										
											2020-08-22 13:01:37 +02:00
										 |  |  |                 $range = $this->parseDateRange($value); | 
					
						
							| 
									
										
										
										
											2021-12-17 17:27:29 +01:00
										 |  |  |                 $this->setDateBeforeParams($range); | 
					
						
							| 
									
										
										
										
											2020-08-22 13:01:37 +02:00
										 |  |  |                 return false; | 
					
						
							| 
									
										
										
										
											2020-08-09 18:58:18 +02:00
										 |  |  |             case 'date_after': | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             case '-date_before': | 
					
						
							| 
									
										
										
										
											2020-08-22 13:01:37 +02:00
										 |  |  |                 $range = $this->parseDateRange($value); | 
					
						
							| 
									
										
										
										
											2021-12-17 17:27:29 +01:00
										 |  |  |                 $this->setDateAfterParams($range); | 
					
						
							| 
									
										
										
										
											2020-08-22 13:01:37 +02:00
										 |  |  |                 return false; | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-03-27 08:48:30 +02:00
										 |  |  |             case 'interest_date_on': | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             case '-interest_date_on': | 
					
						
							| 
									
										
										
										
											2022-03-27 08:48:30 +02:00
										 |  |  |                 $range = $this->parseDateRange($value); | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  |                 $this->setExactMetaDateParams('interest_date', $range, $prohibited); | 
					
						
							| 
									
										
										
										
											2022-03-27 16:03:50 +02:00
										 |  |  |                 return false; | 
					
						
							|  |  |  |             case 'interest_date_before': | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             case '-interest_date_after': | 
					
						
							| 
									
										
										
										
											2022-03-27 16:03:50 +02:00
										 |  |  |                 $range = $this->parseDateRange($value); | 
					
						
							|  |  |  |                 $this->setMetaDateBeforeParams('interest_date', $range); | 
					
						
							|  |  |  |                 return false; | 
					
						
							|  |  |  |             case 'interest_date_after': | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             case '-interest_date_before': | 
					
						
							| 
									
										
										
										
											2022-03-27 16:03:50 +02:00
										 |  |  |                 $range = $this->parseDateRange($value); | 
					
						
							|  |  |  |                 $this->setMetaDateAfterParams('interest_date', $range); | 
					
						
							|  |  |  |                 return false; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             case 'book_date_on': | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             case '-book_date_on': | 
					
						
							| 
									
										
										
										
											2022-03-27 16:03:50 +02:00
										 |  |  |                 $range = $this->parseDateRange($value); | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  |                 $this->setExactMetaDateParams('book_date', $range, $prohibited); | 
					
						
							| 
									
										
										
										
											2022-03-27 16:03:50 +02:00
										 |  |  |                 return false; | 
					
						
							|  |  |  |             case 'book_date_before': | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             case '-book_date_after': | 
					
						
							| 
									
										
										
										
											2022-03-27 16:03:50 +02:00
										 |  |  |                 $range = $this->parseDateRange($value); | 
					
						
							|  |  |  |                 $this->setMetaDateBeforeParams('book_date', $range); | 
					
						
							|  |  |  |                 return false; | 
					
						
							|  |  |  |             case 'book_date_after': | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             case '-book_date_before': | 
					
						
							| 
									
										
										
										
											2022-03-27 16:03:50 +02:00
										 |  |  |                 $range = $this->parseDateRange($value); | 
					
						
							|  |  |  |                 $this->setMetaDateAfterParams('book_date', $range); | 
					
						
							|  |  |  |                 return false; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             case 'process_date_on': | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             case '-process_date_on': | 
					
						
							| 
									
										
										
										
											2022-03-27 16:03:50 +02:00
										 |  |  |                 $range = $this->parseDateRange($value); | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  |                 $this->setExactMetaDateParams('process_date', $range, $prohibited); | 
					
						
							| 
									
										
										
										
											2022-03-27 16:03:50 +02:00
										 |  |  |                 return false; | 
					
						
							|  |  |  |             case 'process_date_before': | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             case '-process_date_after': | 
					
						
							| 
									
										
										
										
											2022-03-27 16:03:50 +02:00
										 |  |  |                 $range = $this->parseDateRange($value); | 
					
						
							|  |  |  |                 $this->setMetaDateBeforeParams('process_date', $range); | 
					
						
							|  |  |  |                 return false; | 
					
						
							|  |  |  |             case 'process_date_after': | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             case '-process_date_before': | 
					
						
							| 
									
										
										
										
											2022-03-27 16:03:50 +02:00
										 |  |  |                 $range = $this->parseDateRange($value); | 
					
						
							|  |  |  |                 $this->setMetaDateAfterParams('process_date', $range); | 
					
						
							|  |  |  |                 return false; | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-03-27 16:03:50 +02:00
										 |  |  |             case 'due_date_on': | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             case '-due_date_on': | 
					
						
							| 
									
										
										
										
											2022-03-27 16:03:50 +02:00
										 |  |  |                 $range = $this->parseDateRange($value); | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  |                 $this->setExactMetaDateParams('due_date', $range, $prohibited); | 
					
						
							| 
									
										
										
										
											2022-03-27 16:03:50 +02:00
										 |  |  |                 return false; | 
					
						
							|  |  |  |             case 'due_date_before': | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             case '-due_date_after': | 
					
						
							| 
									
										
										
										
											2022-03-27 16:03:50 +02:00
										 |  |  |                 $range = $this->parseDateRange($value); | 
					
						
							|  |  |  |                 $this->setMetaDateBeforeParams('due_date', $range); | 
					
						
							|  |  |  |                 return false; | 
					
						
							|  |  |  |             case 'due_date_after': | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             case '-due_date_before': | 
					
						
							| 
									
										
										
										
											2022-03-27 16:03:50 +02:00
										 |  |  |                 $range = $this->parseDateRange($value); | 
					
						
							|  |  |  |                 $this->setMetaDateAfterParams('due_date', $range); | 
					
						
							|  |  |  |                 return false; | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-03-27 16:03:50 +02:00
										 |  |  |             case 'payment_date_on': | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             case '-payment_date_on': | 
					
						
							| 
									
										
										
										
											2022-03-27 16:03:50 +02:00
										 |  |  |                 $range = $this->parseDateRange($value); | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  |                 $this->setExactMetaDateParams('payment_date', $range, $prohibited); | 
					
						
							| 
									
										
										
										
											2022-03-27 16:03:50 +02:00
										 |  |  |                 return false; | 
					
						
							|  |  |  |             case 'payment_date_before': | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             case '-payment_date_after': | 
					
						
							| 
									
										
										
										
											2022-03-27 16:03:50 +02:00
										 |  |  |                 $range = $this->parseDateRange($value); | 
					
						
							|  |  |  |                 $this->setMetaDateBeforeParams('payment_date', $range); | 
					
						
							|  |  |  |                 return false; | 
					
						
							|  |  |  |             case 'payment_date_after': | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             case '-payment_date_before': | 
					
						
							| 
									
										
										
										
											2022-03-27 16:03:50 +02:00
										 |  |  |                 $range = $this->parseDateRange($value); | 
					
						
							|  |  |  |                 $this->setMetaDateAfterParams('payment_date', $range); | 
					
						
							|  |  |  |                 return false; | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-03-27 16:03:50 +02:00
										 |  |  |             case 'invoice_date_on': | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             case '-invoice_date_on': | 
					
						
							| 
									
										
										
										
											2022-03-27 16:03:50 +02:00
										 |  |  |                 $range = $this->parseDateRange($value); | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  |                 $this->setExactMetaDateParams('invoice_date', $range, $prohibited); | 
					
						
							| 
									
										
										
										
											2022-03-27 16:03:50 +02:00
										 |  |  |                 return false; | 
					
						
							|  |  |  |             case 'invoice_date_before': | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             case '-invoice_date_after': | 
					
						
							| 
									
										
										
										
											2022-03-27 16:03:50 +02:00
										 |  |  |                 $range = $this->parseDateRange($value); | 
					
						
							|  |  |  |                 $this->setMetaDateBeforeParams('invoice_date', $range); | 
					
						
							|  |  |  |                 return false; | 
					
						
							|  |  |  |             case 'invoice_date_after': | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             case '-invoice_date_before': | 
					
						
							| 
									
										
										
										
											2022-03-27 16:03:50 +02:00
										 |  |  |                 $range = $this->parseDateRange($value); | 
					
						
							|  |  |  |                 $this->setMetaDateAfterParams('invoice_date', $range); | 
					
						
							|  |  |  |                 return false; | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-03-27 16:03:50 +02:00
										 |  |  |             case 'created_at_on': | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             case '-created_at_on': | 
					
						
							| 
									
										
										
										
											2020-08-09 18:58:18 +02:00
										 |  |  |                 Log::debug(sprintf('Set "%s" using collector with value "%s"', $operator, $value)); | 
					
						
							| 
									
										
										
										
											2022-03-27 16:03:50 +02:00
										 |  |  |                 $range = $this->parseDateRange($value); | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  |                 $this->setExactObjectDateParams('created_at', $range, $prohibited); | 
					
						
							| 
									
										
										
										
											2022-03-27 16:03:50 +02:00
										 |  |  |                 return false; | 
					
						
							|  |  |  |             case 'created_at_before': | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             case '-created_at_after': | 
					
						
							| 
									
										
										
										
											2020-08-09 18:58:18 +02:00
										 |  |  |                 Log::debug(sprintf('Set "%s" using collector with value "%s"', $operator, $value)); | 
					
						
							| 
									
										
										
										
											2022-03-27 16:03:50 +02:00
										 |  |  |                 $range = $this->parseDateRange($value); | 
					
						
							|  |  |  |                 $this->setObjectDateBeforeParams('created_at', $range); | 
					
						
							|  |  |  |                 return false; | 
					
						
							|  |  |  |             case 'created_at_after': | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             case '-created_at_before': | 
					
						
							| 
									
										
										
										
											2022-03-27 16:03:50 +02:00
										 |  |  |                 Log::debug(sprintf('Set "%s" using collector with value "%s"', $operator, $value)); | 
					
						
							|  |  |  |                 $range = $this->parseDateRange($value); | 
					
						
							|  |  |  |                 $this->setObjectDateAfterParams('created_at', $range); | 
					
						
							|  |  |  |                 return false; | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-03-27 16:03:50 +02:00
										 |  |  |             case 'updated_at_on': | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             case '-updated_at_on': | 
					
						
							| 
									
										
										
										
											2022-03-27 16:03:50 +02:00
										 |  |  |                 Log::debug(sprintf('Set "%s" using collector with value "%s"', $operator, $value)); | 
					
						
							|  |  |  |                 $range = $this->parseDateRange($value); | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  |                 $this->setExactObjectDateParams('updated_at', $range, $prohibited); | 
					
						
							| 
									
										
										
										
											2022-03-27 16:03:50 +02:00
										 |  |  |                 return false; | 
					
						
							|  |  |  |             case 'updated_at_before': | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             case '-updated_at_after': | 
					
						
							| 
									
										
										
										
											2022-03-27 16:03:50 +02:00
										 |  |  |                 Log::debug(sprintf('Set "%s" using collector with value "%s"', $operator, $value)); | 
					
						
							|  |  |  |                 $range = $this->parseDateRange($value); | 
					
						
							|  |  |  |                 $this->setObjectDateBeforeParams('updated_at', $range); | 
					
						
							|  |  |  |                 return false; | 
					
						
							|  |  |  |             case 'updated_at_after': | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             case '-updated_at_before': | 
					
						
							| 
									
										
										
										
											2022-03-27 16:03:50 +02:00
										 |  |  |                 Log::debug(sprintf('Set "%s" using collector with value "%s"', $operator, $value)); | 
					
						
							|  |  |  |                 $range = $this->parseDateRange($value); | 
					
						
							|  |  |  |                 $this->setObjectDateAfterParams('updated_at', $range); | 
					
						
							|  |  |  |                 return false; | 
					
						
							| 
									
										
										
										
											2020-08-22 12:24:01 +02:00
										 |  |  |             //
 | 
					
						
							| 
									
										
										
										
											2022-10-30 14:24:37 +01:00
										 |  |  |                 // external URL
 | 
					
						
							| 
									
										
										
										
											2022-01-24 20:20:03 -07:00
										 |  |  |             //
 | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             case '-any_external_url': | 
					
						
							| 
									
										
										
										
											2022-01-24 20:20:03 -07:00
										 |  |  |             case 'no_external_url': | 
					
						
							|  |  |  |                 $this->collector->withoutExternalUrl(); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             case '-no_external_url': | 
					
						
							| 
									
										
										
										
											2022-01-24 20:20:03 -07:00
										 |  |  |             case 'any_external_url': | 
					
						
							|  |  |  |                 $this->collector->withExternalUrl(); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-12-29 15:42:26 +01:00
										 |  |  |             case '-any_external_id': | 
					
						
							|  |  |  |             case 'no_external_id': | 
					
						
							|  |  |  |                 $this->collector->withoutExternalId(); | 
					
						
							|  |  |  |                 break; | 
					
						
							|  |  |  |             case '-no_external_id': | 
					
						
							|  |  |  |             case 'any_external_id': | 
					
						
							|  |  |  |                 $this->collector->withExternalId(); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-03-24 19:34:32 +01:00
										 |  |  |             case 'external_url_is': | 
					
						
							|  |  |  |                 $this->collector->setExternalUrl($value); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             case '-external_url_is': | 
					
						
							|  |  |  |                 $this->collector->excludeExternalUrl($value); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-03-24 19:34:32 +01:00
										 |  |  |             case 'external_url_contains': | 
					
						
							|  |  |  |                 $this->collector->externalUrlContains($value); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             case '-external_url_contains': | 
					
						
							|  |  |  |                 $this->collector->externalUrlDoesNotContain($value); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-03-24 19:34:32 +01:00
										 |  |  |             case 'external_url_starts': | 
					
						
							|  |  |  |                 $this->collector->externalUrlStarts($value); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             case '-external_url_starts': | 
					
						
							|  |  |  |                 $this->collector->externalUrlDoesNotStart($value); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-03-24 19:34:32 +01:00
										 |  |  |             case 'external_url_ends': | 
					
						
							|  |  |  |                 $this->collector->externalUrlEnds($value); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             case '-external_url_ends': | 
					
						
							|  |  |  |                 $this->collector->externalUrlDoesNotEnd($value); | 
					
						
							|  |  |  |                 break; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-24 20:20:03 -07:00
										 |  |  |             //
 | 
					
						
							| 
									
										
										
										
											2022-10-30 14:24:37 +01:00
										 |  |  |                 // other fields
 | 
					
						
							| 
									
										
										
										
											2020-08-22 12:24:01 +02:00
										 |  |  |             //
 | 
					
						
							| 
									
										
										
										
											2022-03-21 06:24:40 +01:00
										 |  |  |             case 'external_id_is': | 
					
						
							| 
									
										
										
										
											2020-08-09 18:58:18 +02:00
										 |  |  |                 $this->collector->setExternalId($value); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             case '-external_id_is': | 
					
						
							|  |  |  |                 $this->collector->excludeExternalId($value); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-03-27 08:48:30 +02:00
										 |  |  |             case 'recurrence_id': | 
					
						
							|  |  |  |                 $this->collector->setRecurrenceId($value); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             case '-recurrence_id': | 
					
						
							|  |  |  |                 $this->collector->excludeRecurrenceId($value); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-03-21 06:24:40 +01:00
										 |  |  |             case 'external_id_contains': | 
					
						
							|  |  |  |                 $this->collector->externalIdContains($value); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             case '-external_id_contains': | 
					
						
							|  |  |  |                 $this->collector->externalIdDoesNotContain($value); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-03-21 06:24:40 +01:00
										 |  |  |             case 'external_id_starts': | 
					
						
							|  |  |  |                 $this->collector->externalIdStarts($value); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             case '-external_id_starts': | 
					
						
							|  |  |  |                 $this->collector->externalIdDoesNotStart($value); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-03-21 06:24:40 +01:00
										 |  |  |             case 'external_id_ends': | 
					
						
							|  |  |  |                 $this->collector->externalIdEnds($value); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             case '-external_id_ends': | 
					
						
							|  |  |  |                 $this->collector->externalIdDoesNotEnd($value); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-03-21 06:31:38 +01:00
										 |  |  |             case 'internal_reference_is': | 
					
						
							| 
									
										
										
										
											2020-08-09 18:58:18 +02:00
										 |  |  |                 $this->collector->setInternalReference($value); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             case '-internal_reference_is': | 
					
						
							|  |  |  |                 $this->collector->excludeInternalReference($value); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-03-21 06:31:38 +01:00
										 |  |  |             case 'internal_reference_contains': | 
					
						
							|  |  |  |                 $this->collector->internalReferenceContains($value); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             case '-internal_reference_contains': | 
					
						
							|  |  |  |                 $this->collector->internalReferenceDoesNotContain($value); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-03-21 06:31:38 +01:00
										 |  |  |             case 'internal_reference_starts': | 
					
						
							|  |  |  |                 $this->collector->internalReferenceStarts($value); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             case '-internal_reference_starts': | 
					
						
							|  |  |  |                 $this->collector->internalReferenceDoesNotStart($value); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-03-21 06:31:38 +01:00
										 |  |  |             case 'internal_reference_ends': | 
					
						
							|  |  |  |                 $this->collector->internalReferenceEnds($value); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             case '-internal_reference_ends': | 
					
						
							|  |  |  |                 $this->collector->internalReferenceDoesNotEnd($value); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-03-28 07:54:52 +02:00
										 |  |  |             case 'attachment_name_is': | 
					
						
							|  |  |  |                 $this->collector->attachmentNameIs($value); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             case '-attachment_name_is': | 
					
						
							|  |  |  |                 $this->collector->attachmentNameIsNot($value); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-03-28 07:54:52 +02:00
										 |  |  |             case 'attachment_name_contains': | 
					
						
							|  |  |  |                 $this->collector->attachmentNameContains($value); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             case '-attachment_name_contains': | 
					
						
							|  |  |  |                 $this->collector->attachmentNameDoesNotContain($value); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-03-28 07:54:52 +02:00
										 |  |  |             case 'attachment_name_starts': | 
					
						
							|  |  |  |                 $this->collector->attachmentNameStarts($value); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             case '-attachment_name_starts': | 
					
						
							|  |  |  |                 $this->collector->attachmentNameDoesNotStart($value); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-03-28 07:54:52 +02:00
										 |  |  |             case 'attachment_name_ends': | 
					
						
							|  |  |  |                 $this->collector->attachmentNameEnds($value); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             case '-attachment_name_ends': | 
					
						
							|  |  |  |                 $this->collector->attachmentNameDoesNotEnd($value); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-03-28 07:54:52 +02:00
										 |  |  |             case 'attachment_notes_are': | 
					
						
							|  |  |  |                 $this->collector->attachmentNotesAre($value); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             case '-attachment_notes_are': | 
					
						
							|  |  |  |                 $this->collector->attachmentNotesAreNot($value); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-03-28 07:54:52 +02:00
										 |  |  |             case 'attachment_notes_contains': | 
					
						
							|  |  |  |                 $this->collector->attachmentNotesContains($value); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             case '-attachment_notes_contains': | 
					
						
							|  |  |  |                 $this->collector->attachmentNotesDoNotContain($value); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-03-28 07:54:52 +02:00
										 |  |  |             case 'attachment_notes_starts': | 
					
						
							|  |  |  |                 $this->collector->attachmentNotesStarts($value); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             case '-attachment_notes_starts': | 
					
						
							|  |  |  |                 $this->collector->attachmentNotesDoNotStart($value); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-03-28 07:54:52 +02:00
										 |  |  |             case 'attachment_notes_ends': | 
					
						
							|  |  |  |                 $this->collector->attachmentNotesEnds($value); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             case '-attachment_notes_ends': | 
					
						
							|  |  |  |                 $this->collector->attachmentNotesDoNotEnd($value); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-09-24 17:43:49 +02:00
										 |  |  |             case 'exists': | 
					
						
							|  |  |  |                 $this->collector->exists(); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             case '-exists': | 
					
						
							|  |  |  |                 $this->collector->findNothing(); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2022-11-27 16:48:47 +01:00
										 |  |  |             case 'sepa_ct_is': | 
					
						
							|  |  |  |                 $this->collector->setSepaCT($value); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2020-08-09 18:58:18 +02:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2020-08-22 12:24:01 +02:00
										 |  |  |         return true; | 
					
						
							| 
									
										
										
										
											2020-08-09 18:58:18 +02:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2020-08-18 17:48:27 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-03-21 09:15:40 +01:00
										 |  |  |     /** | 
					
						
							| 
									
										
										
										
											2022-12-29 19:42:26 +01:00
										 |  |  |      * @param  string  $operator | 
					
						
							| 
									
										
										
										
											2021-03-21 09:15:40 +01:00
										 |  |  |      * | 
					
						
							|  |  |  |      * @return string | 
					
						
							|  |  |  |      * @throws FireflyException | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     public static function getRootOperator(string $operator): string | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  |         $original = $operator; | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |         // if the string starts with "-" (not), we can remove it and recycle
 | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  |         // the configuration from the original operator.
 | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |         if (str_starts_with($operator, '-')) { | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  |             $operator = substr($operator, 1); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-03-20 17:11:33 +01:00
										 |  |  |         $config = config(sprintf('search.operators.%s', $operator)); | 
					
						
							| 
									
										
										
										
											2021-03-21 09:15:40 +01:00
										 |  |  |         if (null === $config) { | 
					
						
							|  |  |  |             throw new FireflyException(sprintf('No configuration for search operator "%s"', $operator)); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         if (true === $config['alias']) { | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  |             $return = $config['alias_for']; | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |             if (str_starts_with($original, '-')) { | 
					
						
							|  |  |  |                 $return = sprintf('-%s', $config['alias_for']); | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  |             } | 
					
						
							|  |  |  |             Log::debug(sprintf('"%s" is an alias for "%s", so return that instead.', $original, $return)); | 
					
						
							| 
									
										
										
										
											2021-03-21 09:15:40 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  |             return $return; | 
					
						
							| 
									
										
										
										
											2021-03-21 09:15:40 +01:00
										 |  |  |         } | 
					
						
							|  |  |  |         Log::debug(sprintf('"%s" is not an alias.', $operator)); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  |         return $original; | 
					
						
							| 
									
										
										
										
											2021-03-21 09:15:40 +01:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-08-18 17:48:27 +02:00
										 |  |  |     /** | 
					
						
							| 
									
										
										
										
											2022-03-20 17:11:33 +01:00
										 |  |  |      * searchDirection: 1 = source (default), 2 = destination, 3 = both | 
					
						
							| 
									
										
										
										
											2020-08-22 12:24:01 +02:00
										 |  |  |      * stringPosition: 1 = start (default), 2 = end, 3 = contains, 4 = is | 
					
						
							| 
									
										
										
										
											2020-10-24 07:40:56 +02:00
										 |  |  |      * | 
					
						
							| 
									
										
										
										
											2022-12-29 19:42:26 +01:00
										 |  |  |      * @param  string  $value | 
					
						
							|  |  |  |      * @param  int  $searchDirection | 
					
						
							|  |  |  |      * @param  int  $stringPosition | 
					
						
							|  |  |  |      * @param  bool  $prohibited | 
					
						
							| 
									
										
										
										
											2020-08-18 17:48:27 +02:00
										 |  |  |      */ | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  |     private function searchAccount(string $value, int $searchDirection, int $stringPosition, bool $prohibited = false): void | 
					
						
							| 
									
										
										
										
											2020-08-18 17:48:27 +02:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2020-10-17 08:53:32 +02:00
										 |  |  |         Log::debug(sprintf('searchAccount("%s", %d, %d)', $value, $stringPosition, $searchDirection)); | 
					
						
							| 
									
										
										
										
											2020-08-22 12:24:01 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |         // search direction (default): for source accounts
 | 
					
						
							|  |  |  |         $searchTypes     = [AccountType::ASSET, AccountType::MORTGAGE, AccountType::LOAN, AccountType::DEBT, AccountType::REVENUE]; | 
					
						
							|  |  |  |         $collectorMethod = 'setSourceAccounts'; | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  |         if ($prohibited) { | 
					
						
							|  |  |  |             $collectorMethod = 'excludeSourceAccounts'; | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2020-08-22 12:24:01 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |         // search direction: for destination accounts
 | 
					
						
							|  |  |  |         if (2 === $searchDirection) { | 
					
						
							|  |  |  |             // destination can be
 | 
					
						
							|  |  |  |             $searchTypes     = [AccountType::ASSET, AccountType::MORTGAGE, AccountType::LOAN, AccountType::DEBT, AccountType::EXPENSE]; | 
					
						
							|  |  |  |             $collectorMethod = 'setDestinationAccounts'; | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  |             if ($prohibited) { | 
					
						
							|  |  |  |                 $collectorMethod = 'excludeDestinationAccounts'; | 
					
						
							|  |  |  |             } | 
					
						
							| 
									
										
										
										
											2020-08-22 12:24:01 +02:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2022-03-20 17:11:33 +01:00
										 |  |  |         // either account could be:
 | 
					
						
							|  |  |  |         if (3 === $searchDirection) { | 
					
						
							|  |  |  |             $searchTypes     = [AccountType::ASSET, AccountType::MORTGAGE, AccountType::LOAN, AccountType::DEBT, AccountType::EXPENSE, AccountType::REVENUE]; | 
					
						
							|  |  |  |             $collectorMethod = 'setAccounts'; | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  |             if ($prohibited) { | 
					
						
							|  |  |  |                 $collectorMethod = 'excludeAccounts'; | 
					
						
							|  |  |  |             } | 
					
						
							| 
									
										
										
										
											2022-03-20 17:11:33 +01:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2020-08-22 12:24:01 +02:00
										 |  |  |         // string position (default): starts with:
 | 
					
						
							|  |  |  |         $stringMethod = 'str_starts_with'; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         // string position: ends with:
 | 
					
						
							|  |  |  |         if (2 === $stringPosition) { | 
					
						
							|  |  |  |             $stringMethod = 'str_ends_with'; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         if (3 === $stringPosition) { | 
					
						
							|  |  |  |             $stringMethod = 'str_contains'; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         if (4 === $stringPosition) { | 
					
						
							|  |  |  |             $stringMethod = 'str_is_equal'; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         // get accounts:
 | 
					
						
							| 
									
										
										
										
											2022-02-02 20:15:28 +01:00
										 |  |  |         $accounts = $this->accountRepository->searchAccount($value, $searchTypes, 1337); | 
					
						
							| 
									
										
										
										
											2020-08-18 17:48:27 +02:00
										 |  |  |         if (0 === $accounts->count()) { | 
					
						
							| 
									
										
										
										
											2021-09-17 08:46:03 +02:00
										 |  |  |             Log::debug('Found zero accounts, search for non existing account, NO results will be returned.'); | 
					
						
							|  |  |  |             $this->collector->findNothing(); | 
					
						
							| 
									
										
										
										
											2020-09-23 19:32:46 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-08-18 17:48:27 +02:00
										 |  |  |             return; | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2020-08-22 12:24:01 +02:00
										 |  |  |         Log::debug(sprintf('Found %d accounts, will filter.', $accounts->count())); | 
					
						
							| 
									
										
										
										
											2020-10-24 07:40:56 +02:00
										 |  |  |         $filtered = $accounts->filter( | 
					
						
							|  |  |  |             function (Account $account) use ($value, $stringMethod) { | 
					
						
							|  |  |  |                 return $stringMethod(strtolower($account->name), strtolower($value)); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         ); | 
					
						
							| 
									
										
										
										
											2020-08-22 12:24:01 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-08-18 17:48:27 +02:00
										 |  |  |         if (0 === $filtered->count()) { | 
					
						
							| 
									
										
										
										
											2021-09-17 08:46:03 +02:00
										 |  |  |             Log::debug('Left with zero accounts, so cannot find anything, NO results will be returned.'); | 
					
						
							|  |  |  |             $this->collector->findNothing(); | 
					
						
							| 
									
										
										
										
											2020-10-24 07:40:56 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-08-18 17:48:27 +02:00
										 |  |  |             return; | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2020-08-22 12:24:01 +02:00
										 |  |  |         Log::debug(sprintf('Left with %d, set as %s().', $filtered->count(), $collectorMethod)); | 
					
						
							|  |  |  |         $this->collector->$collectorMethod($filtered); | 
					
						
							| 
									
										
										
										
											2020-08-18 17:48:27 +02:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							| 
									
										
										
										
											2022-03-20 17:11:33 +01:00
										 |  |  |      * searchDirection: 1 = source (default), 2 = destination, 3 = both | 
					
						
							| 
									
										
										
										
											2020-08-22 12:24:01 +02:00
										 |  |  |      * stringPosition: 1 = start (default), 2 = end, 3 = contains, 4 = is | 
					
						
							| 
									
										
										
										
											2020-10-24 07:40:56 +02:00
										 |  |  |      * | 
					
						
							| 
									
										
										
										
											2022-12-29 19:42:26 +01:00
										 |  |  |      * @param  string  $value | 
					
						
							|  |  |  |      * @param  int  $searchDirection | 
					
						
							|  |  |  |      * @param  int  $stringPosition | 
					
						
							|  |  |  |      * @param  bool  $prohibited | 
					
						
							| 
									
										
										
										
											2020-08-18 17:48:27 +02:00
										 |  |  |      */ | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  |     private function searchAccountNr(string $value, int $searchDirection, int $stringPosition, bool $prohibited = false): void | 
					
						
							| 
									
										
										
										
											2020-08-18 17:48:27 +02:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2020-08-22 12:24:01 +02:00
										 |  |  |         Log::debug(sprintf('searchAccountNr(%s, %d, %d)', $value, $searchDirection, $stringPosition)); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         // search direction (default): for source accounts
 | 
					
						
							|  |  |  |         $searchTypes     = [AccountType::ASSET, AccountType::MORTGAGE, AccountType::LOAN, AccountType::DEBT, AccountType::REVENUE]; | 
					
						
							|  |  |  |         $collectorMethod = 'setSourceAccounts'; | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  |         if (true === $prohibited) { | 
					
						
							|  |  |  |             $collectorMethod = 'excludeSourceAccounts'; | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2020-08-22 12:24:01 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |         // search direction: for destination accounts
 | 
					
						
							|  |  |  |         if (2 === $searchDirection) { | 
					
						
							|  |  |  |             // destination can be
 | 
					
						
							|  |  |  |             $searchTypes     = [AccountType::ASSET, AccountType::MORTGAGE, AccountType::LOAN, AccountType::DEBT, AccountType::EXPENSE]; | 
					
						
							|  |  |  |             $collectorMethod = 'setDestinationAccounts'; | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  |             if (true === $prohibited) { | 
					
						
							|  |  |  |                 $collectorMethod = 'excludeDestinationAccounts'; | 
					
						
							|  |  |  |             } | 
					
						
							| 
									
										
										
										
											2020-08-22 12:24:01 +02:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2022-03-20 17:11:33 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |         // either account could be:
 | 
					
						
							|  |  |  |         if (3 === $searchDirection) { | 
					
						
							|  |  |  |             $searchTypes     = [AccountType::ASSET, AccountType::MORTGAGE, AccountType::LOAN, AccountType::DEBT, AccountType::EXPENSE, AccountType::REVENUE]; | 
					
						
							|  |  |  |             $collectorMethod = 'setAccounts'; | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  |             if (true === $prohibited) { | 
					
						
							|  |  |  |                 $collectorMethod = 'excludeAccounts'; | 
					
						
							|  |  |  |             } | 
					
						
							| 
									
										
										
										
											2022-03-20 17:11:33 +01:00
										 |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-08-22 12:24:01 +02:00
										 |  |  |         // string position (default): starts with:
 | 
					
						
							|  |  |  |         $stringMethod = 'str_starts_with'; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         // string position: ends with:
 | 
					
						
							|  |  |  |         if (2 === $stringPosition) { | 
					
						
							|  |  |  |             $stringMethod = 'str_ends_with'; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         if (3 === $stringPosition) { | 
					
						
							|  |  |  |             $stringMethod = 'str_contains'; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         if (4 === $stringPosition) { | 
					
						
							|  |  |  |             $stringMethod = 'str_is_equal'; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         // search for accounts:
 | 
					
						
							| 
									
										
										
										
											2022-02-02 20:15:28 +01:00
										 |  |  |         $accounts = $this->accountRepository->searchAccountNr($value, $searchTypes, 1337); | 
					
						
							| 
									
										
										
										
											2020-08-18 17:48:27 +02:00
										 |  |  |         if (0 === $accounts->count()) { | 
					
						
							| 
									
										
										
										
											2020-09-23 19:32:46 +02:00
										 |  |  |             Log::debug('Found zero accounts, search for invalid account.'); | 
					
						
							| 
									
										
										
										
											2021-09-17 08:46:03 +02:00
										 |  |  |             $this->collector->findNothing(); | 
					
						
							| 
									
										
										
										
											2020-10-24 07:40:56 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-08-18 17:48:27 +02:00
										 |  |  |             return; | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2020-08-22 12:24:01 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |         // if found, do filter
 | 
					
						
							|  |  |  |         Log::debug(sprintf('Found %d accounts, will filter.', $accounts->count())); | 
					
						
							| 
									
										
										
										
											2020-10-24 07:40:56 +02:00
										 |  |  |         $filtered = $accounts->filter( | 
					
						
							|  |  |  |             function (Account $account) use ($value, $stringMethod) { | 
					
						
							| 
									
										
										
										
											2022-09-28 07:35:57 +02:00
										 |  |  |                 // either IBAN or account number
 | 
					
						
							| 
									
										
										
										
											2022-12-29 19:42:26 +01:00
										 |  |  |                 $ibanMatch      = $stringMethod(strtolower((string)$account->iban), strtolower((string)$value)); | 
					
						
							| 
									
										
										
										
											2020-10-24 07:40:56 +02:00
										 |  |  |                 $accountNrMatch = false; | 
					
						
							|  |  |  |                 /** @var AccountMeta $meta */ | 
					
						
							|  |  |  |                 foreach ($account->accountMeta as $meta) { | 
					
						
							|  |  |  |                     if ('account_number' === $meta->name && $stringMethod(strtolower($meta->data), strtolower($value))) { | 
					
						
							|  |  |  |                         $accountNrMatch = true; | 
					
						
							|  |  |  |                     } | 
					
						
							| 
									
										
										
										
											2020-08-22 12:24:01 +02:00
										 |  |  |                 } | 
					
						
							| 
									
										
										
										
											2020-10-24 07:40:56 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |                 return $ibanMatch || $accountNrMatch; | 
					
						
							| 
									
										
										
										
											2020-08-22 12:24:01 +02:00
										 |  |  |             } | 
					
						
							| 
									
										
										
										
											2020-10-24 07:40:56 +02:00
										 |  |  |         ); | 
					
						
							| 
									
										
										
										
											2020-08-22 12:24:01 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-08-18 17:48:27 +02:00
										 |  |  |         if (0 === $filtered->count()) { | 
					
						
							| 
									
										
										
										
											2020-09-23 19:32:46 +02:00
										 |  |  |             Log::debug('Left with zero, search for invalid account'); | 
					
						
							| 
									
										
										
										
											2021-09-17 08:46:03 +02:00
										 |  |  |             $this->collector->findNothing(); | 
					
						
							| 
									
										
										
										
											2020-10-24 07:40:56 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-08-18 17:48:27 +02:00
										 |  |  |             return; | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2020-09-23 19:32:46 +02:00
										 |  |  |         Log::debug(sprintf('Left with %d, set as %s().', $filtered->count(), $collectorMethod)); | 
					
						
							| 
									
										
										
										
											2020-08-22 12:24:01 +02:00
										 |  |  |         $this->collector->$collectorMethod($filtered); | 
					
						
							| 
									
										
										
										
											2020-08-18 17:48:27 +02:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2020-08-22 12:24:01 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-03-21 09:15:40 +01:00
										 |  |  |     /** | 
					
						
							|  |  |  |      * @return Account | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     private function getCashAccount(): Account | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         return $this->accountRepository->getCashAccount(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-08-22 12:24:01 +02:00
										 |  |  |     /** | 
					
						
							| 
									
										
										
										
											2022-12-29 19:42:26 +01:00
										 |  |  |      * @param  string  $value | 
					
						
							| 
									
										
										
										
											2020-10-24 07:40:56 +02:00
										 |  |  |      * | 
					
						
							| 
									
										
										
										
											2020-08-22 12:24:01 +02:00
										 |  |  |      * @return TransactionCurrency|null | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     private function findCurrency(string $value): ?TransactionCurrency | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2020-09-09 06:10:00 +02:00
										 |  |  |         if (str_contains($value, '(') && str_contains($value, ')')) { | 
					
						
							| 
									
										
										
										
											2020-08-28 06:09:04 +02:00
										 |  |  |             // bad method to split and get the currency code:
 | 
					
						
							|  |  |  |             $parts = explode(' ', $value); | 
					
						
							| 
									
										
										
										
											2020-09-09 06:10:00 +02:00
										 |  |  |             $value = trim($parts[count($parts) - 1], "() \t\n\r\0\x0B"); | 
					
						
							| 
									
										
										
										
											2020-08-28 06:09:04 +02:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2020-08-22 12:24:01 +02:00
										 |  |  |         $result = $this->currencyRepository->findByCodeNull($value); | 
					
						
							|  |  |  |         if (null === $result) { | 
					
						
							|  |  |  |             $result = $this->currencyRepository->findByNameNull($value); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2020-10-24 07:40:56 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-08-22 12:24:01 +02:00
										 |  |  |         return $result; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-08-22 13:01:37 +02:00
										 |  |  |     /** | 
					
						
							| 
									
										
										
										
											2022-12-29 19:42:26 +01:00
										 |  |  |      * @param  string  $value | 
					
						
							| 
									
										
										
										
											2020-10-24 07:40:56 +02:00
										 |  |  |      * | 
					
						
							| 
									
										
										
										
											2020-08-22 13:01:37 +02:00
										 |  |  |      * @return array | 
					
						
							|  |  |  |      * @throws FireflyException | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     private function parseDateRange(string $value): array | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2022-10-30 14:24:37 +01:00
										 |  |  |         $parser = new ParseDateString(); | 
					
						
							| 
									
										
										
										
											2020-08-22 13:01:37 +02:00
										 |  |  |         if ($parser->isDateRange($value)) { | 
					
						
							| 
									
										
										
										
											2021-12-17 17:27:29 +01:00
										 |  |  |             return $parser->parseRange($value); | 
					
						
							| 
									
										
										
										
											2020-08-22 13:01:37 +02:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2021-05-24 08:06:56 +02:00
										 |  |  |         $parsedDate = $parser->parseDate($value); | 
					
						
							| 
									
										
										
										
											2020-10-24 07:40:56 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-08-22 13:01:37 +02:00
										 |  |  |         return [ | 
					
						
							| 
									
										
										
										
											2021-12-17 17:27:29 +01:00
										 |  |  |             'exact' => $parsedDate, | 
					
						
							| 
									
										
										
										
											2020-08-22 13:01:37 +02:00
										 |  |  |         ]; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-17 17:27:29 +01:00
										 |  |  |     /** | 
					
						
							| 
									
										
										
										
											2022-12-29 19:42:26 +01:00
										 |  |  |      * @param  array  $range | 
					
						
							| 
									
										
										
										
											2021-12-17 17:27:29 +01:00
										 |  |  |      * | 
					
						
							|  |  |  |      * @throws FireflyException | 
					
						
							|  |  |  |      */ | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  |     private function setExactDateParams(array $range, bool $prohibited = false): void | 
					
						
							| 
									
										
										
										
											2021-12-17 17:27:29 +01:00
										 |  |  |     { | 
					
						
							|  |  |  |         /** | 
					
						
							| 
									
										
										
										
											2022-12-29 19:42:26 +01:00
										 |  |  |          * @var string $key | 
					
						
							| 
									
										
										
										
											2021-12-17 17:27:29 +01:00
										 |  |  |          * @var Carbon|string $value | 
					
						
							|  |  |  |          */ | 
					
						
							|  |  |  |         foreach ($range as $key => $value) { | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  |             $key = $prohibited ? sprintf('%s_not', $key) : $key; | 
					
						
							| 
									
										
										
										
											2021-12-17 17:27:29 +01:00
										 |  |  |             switch ($key) { | 
					
						
							|  |  |  |                 default: | 
					
						
							|  |  |  |                     throw new FireflyException(sprintf('Cannot handle key "%s" in setExactParameters()', $key)); | 
					
						
							|  |  |  |                 case 'exact': | 
					
						
							|  |  |  |                     Log::debug(sprintf('Set date_is_exact value "%s"', $value->format('Y-m-d'))); | 
					
						
							|  |  |  |                     $this->collector->setRange($value, $value); | 
					
						
							| 
									
										
										
										
											2022-03-27 08:48:30 +02:00
										 |  |  |                     $this->operators->push(['type' => 'date_on', 'value' => $value->format('Y-m-d'),]); | 
					
						
							| 
									
										
										
										
											2021-12-17 17:27:29 +01:00
										 |  |  |                     break; | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  |                 case 'exact_not': | 
					
						
							|  |  |  |                     $this->collector->excludeRange($value, $value); | 
					
						
							|  |  |  |                     $this->operators->push(['type' => 'not_date_on', 'value' => $value->format('Y-m-d'),]); | 
					
						
							|  |  |  |                     break; | 
					
						
							| 
									
										
										
										
											2021-12-17 17:27:29 +01:00
										 |  |  |                 case 'year': | 
					
						
							|  |  |  |                     Log::debug(sprintf('Set date_is_exact YEAR value "%s"', $value)); | 
					
						
							|  |  |  |                     $this->collector->yearIs($value); | 
					
						
							| 
									
										
										
										
											2022-03-27 08:48:30 +02:00
										 |  |  |                     $this->operators->push(['type' => 'date_on_year', 'value' => $value,]); | 
					
						
							| 
									
										
										
										
											2021-12-17 17:27:29 +01:00
										 |  |  |                     break; | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  |                 case 'year_not': | 
					
						
							|  |  |  |                     Log::debug(sprintf('Set date_is_exact_not YEAR value "%s"', $value)); | 
					
						
							|  |  |  |                     $this->collector->yearIsNot($value); | 
					
						
							|  |  |  |                     $this->operators->push(['type' => 'not_date_on_year', 'value' => $value,]); | 
					
						
							|  |  |  |                     break; | 
					
						
							| 
									
										
										
										
											2021-12-17 17:27:29 +01:00
										 |  |  |                 case 'month': | 
					
						
							|  |  |  |                     Log::debug(sprintf('Set date_is_exact MONTH value "%s"', $value)); | 
					
						
							|  |  |  |                     $this->collector->monthIs($value); | 
					
						
							| 
									
										
										
										
											2022-03-27 08:48:30 +02:00
										 |  |  |                     $this->operators->push(['type' => 'date_on_month', 'value' => $value,]); | 
					
						
							| 
									
										
										
										
											2021-12-17 17:27:29 +01:00
										 |  |  |                     break; | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  |                 case 'month_not': | 
					
						
							|  |  |  |                     Log::debug(sprintf('Set date_is_exact not MONTH value "%s"', $value)); | 
					
						
							|  |  |  |                     $this->collector->monthIsNot($value); | 
					
						
							|  |  |  |                     $this->operators->push(['type' => 'not_date_on_month', 'value' => $value,]); | 
					
						
							|  |  |  |                     break; | 
					
						
							| 
									
										
										
										
											2021-12-17 17:27:29 +01:00
										 |  |  |                 case 'day': | 
					
						
							|  |  |  |                     Log::debug(sprintf('Set date_is_exact DAY value "%s"', $value)); | 
					
						
							|  |  |  |                     $this->collector->dayIs($value); | 
					
						
							| 
									
										
										
										
											2022-03-27 08:48:30 +02:00
										 |  |  |                     $this->operators->push(['type' => 'date_on_day', 'value' => $value,]); | 
					
						
							| 
									
										
										
										
											2021-12-17 17:27:29 +01:00
										 |  |  |                     break; | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  |                 case 'day_not': | 
					
						
							|  |  |  |                     Log::debug(sprintf('Set not date_is_exact DAY value "%s"', $value)); | 
					
						
							|  |  |  |                     $this->collector->dayIsNot($value); | 
					
						
							|  |  |  |                     $this->operators->push(['type' => 'not_date_on_day', 'value' => $value,]); | 
					
						
							|  |  |  |                     break; | 
					
						
							| 
									
										
										
										
											2021-12-17 17:27:29 +01:00
										 |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-03-27 16:03:50 +02:00
										 |  |  |     /** | 
					
						
							| 
									
										
										
										
											2022-12-29 19:42:26 +01:00
										 |  |  |      * @param  array  $range | 
					
						
							| 
									
										
										
										
											2022-03-29 14:59:58 +02:00
										 |  |  |      * | 
					
						
							| 
									
										
										
										
											2022-03-27 16:03:50 +02:00
										 |  |  |      * @throws FireflyException | 
					
						
							|  |  |  |      */ | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  |     private function setDateBeforeParams(array $range, bool $prohibited = false): void | 
					
						
							| 
									
										
										
										
											2022-03-27 16:03:50 +02:00
										 |  |  |     { | 
					
						
							|  |  |  |         /** | 
					
						
							| 
									
										
										
										
											2022-12-29 19:42:26 +01:00
										 |  |  |          * @var string $key | 
					
						
							| 
									
										
										
										
											2022-03-27 16:03:50 +02:00
										 |  |  |          * @var Carbon|string $value | 
					
						
							|  |  |  |          */ | 
					
						
							|  |  |  |         foreach ($range as $key => $value) { | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  |             $key = $prohibited ? sprintf('%s_not', $key) : $key; | 
					
						
							| 
									
										
										
										
											2022-03-27 16:03:50 +02:00
										 |  |  |             switch ($key) { | 
					
						
							|  |  |  |                 default: | 
					
						
							| 
									
										
										
										
											2022-03-29 14:59:58 +02:00
										 |  |  |                     throw new FireflyException(sprintf('Cannot handle key "%s" in setDateBeforeParams()', $key)); | 
					
						
							| 
									
										
										
										
											2022-03-27 16:03:50 +02:00
										 |  |  |                 case 'exact': | 
					
						
							| 
									
										
										
										
											2022-03-29 14:59:58 +02:00
										 |  |  |                     $this->collector->setBefore($value); | 
					
						
							|  |  |  |                     $this->operators->push(['type' => 'date_before', 'value' => $value->format('Y-m-d'),]); | 
					
						
							| 
									
										
										
										
											2022-03-27 16:03:50 +02:00
										 |  |  |                     break; | 
					
						
							|  |  |  |                 case 'year': | 
					
						
							| 
									
										
										
										
											2022-03-29 14:59:58 +02:00
										 |  |  |                     Log::debug(sprintf('Set date_is_before YEAR value "%s"', $value)); | 
					
						
							|  |  |  |                     $this->collector->yearBefore($value); | 
					
						
							|  |  |  |                     $this->operators->push(['type' => 'date_before_year', 'value' => $value,]); | 
					
						
							| 
									
										
										
										
											2022-03-27 16:03:50 +02:00
										 |  |  |                     break; | 
					
						
							|  |  |  |                 case 'month': | 
					
						
							| 
									
										
										
										
											2022-03-29 14:59:58 +02:00
										 |  |  |                     Log::debug(sprintf('Set date_is_before MONTH value "%s"', $value)); | 
					
						
							|  |  |  |                     $this->collector->monthBefore($value); | 
					
						
							|  |  |  |                     $this->operators->push(['type' => 'date_before_month', 'value' => $value,]); | 
					
						
							| 
									
										
										
										
											2022-03-27 16:03:50 +02:00
										 |  |  |                     break; | 
					
						
							|  |  |  |                 case 'day': | 
					
						
							| 
									
										
										
										
											2022-03-29 14:59:58 +02:00
										 |  |  |                     Log::debug(sprintf('Set date_is_before DAY value "%s"', $value)); | 
					
						
							|  |  |  |                     $this->collector->dayBefore($value); | 
					
						
							|  |  |  |                     $this->operators->push(['type' => 'date_before_day', 'value' => $value,]); | 
					
						
							| 
									
										
										
										
											2022-03-27 16:03:50 +02:00
										 |  |  |                     break; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-17 17:27:29 +01:00
										 |  |  |     /** | 
					
						
							| 
									
										
										
										
											2022-12-29 19:42:26 +01:00
										 |  |  |      * @param  array  $range | 
					
						
							| 
									
										
										
										
											2021-12-17 17:27:29 +01:00
										 |  |  |      * | 
					
						
							|  |  |  |      * @throws FireflyException | 
					
						
							|  |  |  |      */ | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  |     private function setDateAfterParams(array $range, bool $prohibited = false) | 
					
						
							| 
									
										
										
										
											2021-12-17 17:27:29 +01:00
										 |  |  |     { | 
					
						
							|  |  |  |         /** | 
					
						
							| 
									
										
										
										
											2022-12-29 19:42:26 +01:00
										 |  |  |          * @var string $key | 
					
						
							| 
									
										
										
										
											2021-12-17 17:27:29 +01:00
										 |  |  |          * @var Carbon|string $value | 
					
						
							|  |  |  |          */ | 
					
						
							|  |  |  |         foreach ($range as $key => $value) { | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  |             $key = $prohibited ? sprintf('%s_not', $key) : $key; | 
					
						
							| 
									
										
										
										
											2021-12-17 17:27:29 +01:00
										 |  |  |             switch ($key) { | 
					
						
							|  |  |  |                 default: | 
					
						
							| 
									
										
										
										
											2022-03-29 14:59:58 +02:00
										 |  |  |                     throw new FireflyException(sprintf('Cannot handle key "%s" in setDateAfterParams()', $key)); | 
					
						
							| 
									
										
										
										
											2021-12-17 17:27:29 +01:00
										 |  |  |                 case 'exact': | 
					
						
							| 
									
										
										
										
											2022-03-29 14:59:58 +02:00
										 |  |  |                     $this->collector->setAfter($value); | 
					
						
							|  |  |  |                     $this->operators->push(['type' => 'date_after', 'value' => $value->format('Y-m-d'),]); | 
					
						
							| 
									
										
										
										
											2021-12-17 17:27:29 +01:00
										 |  |  |                     break; | 
					
						
							|  |  |  |                 case 'year': | 
					
						
							| 
									
										
										
										
											2022-03-29 14:59:58 +02:00
										 |  |  |                     Log::debug(sprintf('Set date_is_after YEAR value "%s"', $value)); | 
					
						
							|  |  |  |                     $this->collector->yearAfter($value); | 
					
						
							|  |  |  |                     $this->operators->push(['type' => 'date_after_year', 'value' => $value,]); | 
					
						
							| 
									
										
										
										
											2021-12-17 17:27:29 +01:00
										 |  |  |                     break; | 
					
						
							|  |  |  |                 case 'month': | 
					
						
							| 
									
										
										
										
											2022-03-29 14:59:58 +02:00
										 |  |  |                     Log::debug(sprintf('Set date_is_after MONTH value "%s"', $value)); | 
					
						
							|  |  |  |                     $this->collector->monthAfter($value); | 
					
						
							|  |  |  |                     $this->operators->push(['type' => 'date_after_month', 'value' => $value,]); | 
					
						
							| 
									
										
										
										
											2021-12-17 17:27:29 +01:00
										 |  |  |                     break; | 
					
						
							|  |  |  |                 case 'day': | 
					
						
							| 
									
										
										
										
											2022-03-29 14:59:58 +02:00
										 |  |  |                     Log::debug(sprintf('Set date_is_after DAY value "%s"', $value)); | 
					
						
							|  |  |  |                     $this->collector->dayAfter($value); | 
					
						
							|  |  |  |                     $this->operators->push(['type' => 'date_after_day', 'value' => $value,]); | 
					
						
							|  |  |  |                     break; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							| 
									
										
										
										
											2022-12-29 19:42:26 +01:00
										 |  |  |      * @param  string  $field | 
					
						
							|  |  |  |      * @param  array  $range | 
					
						
							| 
									
										
										
										
											2022-03-29 14:59:58 +02:00
										 |  |  |      * @return void | 
					
						
							|  |  |  |      * @throws FireflyException | 
					
						
							|  |  |  |      */ | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  |     private function setExactMetaDateParams(string $field, array $range, bool $prohibited = false): void | 
					
						
							| 
									
										
										
										
											2022-03-29 14:59:58 +02:00
										 |  |  |     { | 
					
						
							|  |  |  |         Log::debug('Now in setExactMetaDateParams()'); | 
					
						
							|  |  |  |         /** | 
					
						
							| 
									
										
										
										
											2022-12-29 19:42:26 +01:00
										 |  |  |          * @var string $key | 
					
						
							| 
									
										
										
										
											2022-03-29 14:59:58 +02:00
										 |  |  |          * @var Carbon|string $value | 
					
						
							|  |  |  |          */ | 
					
						
							|  |  |  |         foreach ($range as $key => $value) { | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  |             $key = $prohibited ? sprintf('%s_not', $key) : $key; | 
					
						
							| 
									
										
										
										
											2022-03-29 14:59:58 +02:00
										 |  |  |             switch ($key) { | 
					
						
							|  |  |  |                 default: | 
					
						
							|  |  |  |                     throw new FireflyException(sprintf('Cannot handle key "%s" in setExactMetaDateParams()', $key)); | 
					
						
							|  |  |  |                 case 'exact': | 
					
						
							|  |  |  |                     Log::debug(sprintf('Set %s_is_exact value "%s"', $field, $value->format('Y-m-d'))); | 
					
						
							|  |  |  |                     $this->collector->setMetaDateRange($value, $value, $field); | 
					
						
							|  |  |  |                     $this->operators->push(['type' => sprintf('%s_on', $field), 'value' => $value->format('Y-m-d'),]); | 
					
						
							|  |  |  |                     break; | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  |                 case 'exact_not': | 
					
						
							|  |  |  |                     Log::debug(sprintf('Set NOT %s_is_exact value "%s"', $field, $value->format('Y-m-d'))); | 
					
						
							|  |  |  |                     $this->collector->excludeMetaDateRange($value, $value, $field); | 
					
						
							|  |  |  |                     $this->operators->push(['type' => sprintf('not_%s_on', $field), 'value' => $value->format('Y-m-d'),]); | 
					
						
							|  |  |  |                     break; | 
					
						
							| 
									
										
										
										
											2022-03-29 14:59:58 +02:00
										 |  |  |                 case 'year': | 
					
						
							|  |  |  |                     Log::debug(sprintf('Set %s_is_exact YEAR value "%s"', $field, $value)); | 
					
						
							|  |  |  |                     $this->collector->metaYearIs($value, $field); | 
					
						
							|  |  |  |                     $this->operators->push(['type' => sprintf('%s_on_year', $field), 'value' => $value,]); | 
					
						
							|  |  |  |                     break; | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  |                 case 'year_not': | 
					
						
							|  |  |  |                     Log::debug(sprintf('Set NOT %s_is_exact YEAR value "%s"', $field, $value)); | 
					
						
							|  |  |  |                     $this->collector->metaYearIsNot($value, $field); | 
					
						
							|  |  |  |                     $this->operators->push(['type' => sprintf('not_%s_on_year', $field), 'value' => $value,]); | 
					
						
							|  |  |  |                     break; | 
					
						
							| 
									
										
										
										
											2022-03-29 14:59:58 +02:00
										 |  |  |                 case 'month': | 
					
						
							|  |  |  |                     Log::debug(sprintf('Set %s_is_exact MONTH value "%s"', $field, $value)); | 
					
						
							|  |  |  |                     $this->collector->metaMonthIs($value, $field); | 
					
						
							|  |  |  |                     $this->operators->push(['type' => sprintf('%s_on_month', $field), 'value' => $value,]); | 
					
						
							|  |  |  |                     break; | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  |                 case 'month_not': | 
					
						
							|  |  |  |                     Log::debug(sprintf('Set NOT %s_is_exact MONTH value "%s"', $field, $value)); | 
					
						
							|  |  |  |                     $this->collector->metaMonthIsNot($value, $field); | 
					
						
							|  |  |  |                     $this->operators->push(['type' => sprintf('not_%s_on_month', $field), 'value' => $value,]); | 
					
						
							|  |  |  |                     break; | 
					
						
							| 
									
										
										
										
											2022-03-29 14:59:58 +02:00
										 |  |  |                 case 'day': | 
					
						
							|  |  |  |                     Log::debug(sprintf('Set %s_is_exact DAY value "%s"', $field, $value)); | 
					
						
							|  |  |  |                     $this->collector->metaDayIs($value, $field); | 
					
						
							|  |  |  |                     $this->operators->push(['type' => sprintf('%s_on_day', $field), 'value' => $value,]); | 
					
						
							| 
									
										
										
										
											2021-12-17 17:27:29 +01:00
										 |  |  |                     break; | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  |                 case 'day_not': | 
					
						
							|  |  |  |                     Log::debug(sprintf('Set NOT %s_is_exact DAY value "%s"', $field, $value)); | 
					
						
							|  |  |  |                     $this->collector->metaDayIsNot($value, $field); | 
					
						
							|  |  |  |                     $this->operators->push(['type' => sprintf('not_%s_on_day', $field), 'value' => $value,]); | 
					
						
							|  |  |  |                     break; | 
					
						
							| 
									
										
										
										
											2021-12-17 17:27:29 +01:00
										 |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-03-27 16:03:50 +02:00
										 |  |  |     /** | 
					
						
							| 
									
										
										
										
											2022-12-29 19:42:26 +01:00
										 |  |  |      * @param  string  $field | 
					
						
							|  |  |  |      * @param  array  $range | 
					
						
							| 
									
										
										
										
											2022-03-27 16:03:50 +02:00
										 |  |  |      * @return void | 
					
						
							|  |  |  |      * @throws FireflyException | 
					
						
							|  |  |  |      */ | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  |     private function setMetaDateBeforeParams(string $field, array $range, bool $prohibited = false): void | 
					
						
							| 
									
										
										
										
											2022-03-27 16:03:50 +02:00
										 |  |  |     { | 
					
						
							|  |  |  |         /** | 
					
						
							| 
									
										
										
										
											2022-12-29 19:42:26 +01:00
										 |  |  |          * @var string $key | 
					
						
							| 
									
										
										
										
											2022-03-27 16:03:50 +02:00
										 |  |  |          * @var Carbon|string $value | 
					
						
							|  |  |  |          */ | 
					
						
							|  |  |  |         foreach ($range as $key => $value) { | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  |             $key = $prohibited ? sprintf('%s_not', $key) : $key; | 
					
						
							| 
									
										
										
										
											2022-03-27 16:03:50 +02:00
										 |  |  |             switch ($key) { | 
					
						
							|  |  |  |                 default: | 
					
						
							|  |  |  |                     throw new FireflyException(sprintf('Cannot handle key "%s" in setMetaDateBeforeParams()', $key)); | 
					
						
							|  |  |  |                 case 'exact': | 
					
						
							|  |  |  |                     $this->collector->setMetaBefore($value, $field); | 
					
						
							|  |  |  |                     $this->operators->push(['type' => sprintf('%s_before', $field), 'value' => $value->format('Y-m-d'),]); | 
					
						
							|  |  |  |                     break; | 
					
						
							|  |  |  |                 case 'year': | 
					
						
							|  |  |  |                     Log::debug(sprintf('Set %s_is_before YEAR value "%s"', $field, $value)); | 
					
						
							|  |  |  |                     $this->collector->metaYearBefore($value, $field); | 
					
						
							|  |  |  |                     $this->operators->push(['type' => sprintf('%s_before_year', $field), 'value' => $value,]); | 
					
						
							|  |  |  |                     break; | 
					
						
							|  |  |  |                 case 'month': | 
					
						
							|  |  |  |                     Log::debug(sprintf('Set %s_is_before MONTH value "%s"', $field, $value)); | 
					
						
							|  |  |  |                     $this->collector->metaMonthBefore($value, $field); | 
					
						
							|  |  |  |                     $this->operators->push(['type' => sprintf('%s_before_month', $field), 'value' => $value,]); | 
					
						
							|  |  |  |                     break; | 
					
						
							|  |  |  |                 case 'day': | 
					
						
							|  |  |  |                     Log::debug(sprintf('Set %s_is_before DAY value "%s"', $field, $value)); | 
					
						
							|  |  |  |                     $this->collector->metaDayBefore($value, $field); | 
					
						
							|  |  |  |                     $this->operators->push(['type' => sprintf('%s_before_day', $field), 'value' => $value,]); | 
					
						
							|  |  |  |                     break; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							| 
									
										
										
										
											2022-12-29 19:42:26 +01:00
										 |  |  |      * @param  string  $field | 
					
						
							|  |  |  |      * @param  array  $range | 
					
						
							| 
									
										
										
										
											2022-03-27 16:03:50 +02:00
										 |  |  |      * @return void | 
					
						
							|  |  |  |      * @throws FireflyException | 
					
						
							|  |  |  |      */ | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  |     private function setMetaDateAfterParams(string $field, array $range, bool $prohibited = false): void | 
					
						
							| 
									
										
										
										
											2022-03-27 16:03:50 +02:00
										 |  |  |     { | 
					
						
							|  |  |  |         /** | 
					
						
							| 
									
										
										
										
											2022-12-29 19:42:26 +01:00
										 |  |  |          * @var string $key | 
					
						
							| 
									
										
										
										
											2022-03-27 16:03:50 +02:00
										 |  |  |          * @var Carbon|string $value | 
					
						
							|  |  |  |          */ | 
					
						
							|  |  |  |         foreach ($range as $key => $value) { | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  |             $key = $prohibited ? sprintf('%s_not', $key) : $key; | 
					
						
							| 
									
										
										
										
											2022-03-27 16:03:50 +02:00
										 |  |  |             switch ($key) { | 
					
						
							|  |  |  |                 default: | 
					
						
							|  |  |  |                     throw new FireflyException(sprintf('Cannot handle key "%s" in setMetaDateAfterParams()', $key)); | 
					
						
							|  |  |  |                 case 'exact': | 
					
						
							|  |  |  |                     $this->collector->setMetaAfter($value, $field); | 
					
						
							|  |  |  |                     $this->operators->push(['type' => sprintf('%s_after', $field), 'value' => $value->format('Y-m-d'),]); | 
					
						
							|  |  |  |                     break; | 
					
						
							|  |  |  |                 case 'year': | 
					
						
							|  |  |  |                     Log::debug(sprintf('Set %s_is_after YEAR value "%s"', $field, $value)); | 
					
						
							|  |  |  |                     $this->collector->metaYearAfter($value, $field); | 
					
						
							|  |  |  |                     $this->operators->push(['type' => sprintf('%s_after_year', $field), 'value' => $value,]); | 
					
						
							|  |  |  |                     break; | 
					
						
							|  |  |  |                 case 'month': | 
					
						
							|  |  |  |                     Log::debug(sprintf('Set %s_is_after MONTH value "%s"', $field, $value)); | 
					
						
							|  |  |  |                     $this->collector->metaMonthAfter($value, $field); | 
					
						
							|  |  |  |                     $this->operators->push(['type' => sprintf('%s_after_month', $field), 'value' => $value,]); | 
					
						
							|  |  |  |                     break; | 
					
						
							|  |  |  |                 case 'day': | 
					
						
							|  |  |  |                     Log::debug(sprintf('Set %s_is_after DAY value "%s"', $field, $value)); | 
					
						
							|  |  |  |                     $this->collector->metaDayAfter($value, $field); | 
					
						
							|  |  |  |                     $this->operators->push(['type' => sprintf('%s_after_day', $field), 'value' => $value,]); | 
					
						
							|  |  |  |                     break; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-17 17:27:29 +01:00
										 |  |  |     /** | 
					
						
							| 
									
										
										
										
											2022-12-29 19:42:26 +01:00
										 |  |  |      * @param  string  $field | 
					
						
							|  |  |  |      * @param  array  $range | 
					
						
							| 
									
										
										
										
											2022-03-29 14:59:58 +02:00
										 |  |  |      * @return void | 
					
						
							| 
									
										
										
										
											2022-03-27 16:03:50 +02:00
										 |  |  |      * @throws FireflyException | 
					
						
							|  |  |  |      */ | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  |     private function setExactObjectDateParams(string $field, array $range, bool $prohibited = false): void | 
					
						
							| 
									
										
										
										
											2022-03-27 16:03:50 +02:00
										 |  |  |     { | 
					
						
							|  |  |  |         /** | 
					
						
							| 
									
										
										
										
											2022-12-29 19:42:26 +01:00
										 |  |  |          * @var string $key | 
					
						
							| 
									
										
										
										
											2022-03-27 16:03:50 +02:00
										 |  |  |          * @var Carbon|string $value | 
					
						
							|  |  |  |          */ | 
					
						
							|  |  |  |         foreach ($range as $key => $value) { | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  |             $key = $prohibited ? sprintf('%s_not', $key) : $key; | 
					
						
							| 
									
										
										
										
											2022-03-27 16:03:50 +02:00
										 |  |  |             switch ($key) { | 
					
						
							|  |  |  |                 default: | 
					
						
							| 
									
										
										
										
											2022-03-29 14:59:58 +02:00
										 |  |  |                     throw new FireflyException(sprintf('Cannot handle key "%s" in setExactObjectDateParams()', $key)); | 
					
						
							| 
									
										
										
										
											2022-03-27 16:03:50 +02:00
										 |  |  |                 case 'exact': | 
					
						
							| 
									
										
										
										
											2022-03-29 14:59:58 +02:00
										 |  |  |                     Log::debug(sprintf('Set %s_is_exact value "%s"', $field, $value->format('Y-m-d'))); | 
					
						
							|  |  |  |                     $this->collector->setObjectRange($value, clone $value, $field); | 
					
						
							|  |  |  |                     $this->operators->push(['type' => sprintf('%s_on', $field), 'value' => $value->format('Y-m-d'),]); | 
					
						
							| 
									
										
										
										
											2022-03-27 16:03:50 +02:00
										 |  |  |                     break; | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  |                 case 'exact_not': | 
					
						
							|  |  |  |                     Log::debug(sprintf('Set NOT %s_is_exact value "%s"', $field, $value->format('Y-m-d'))); | 
					
						
							|  |  |  |                     $this->collector->excludeObjectRange($value, clone $value, $field); | 
					
						
							|  |  |  |                     $this->operators->push(['type' => sprintf('not_%s_on', $field), 'value' => $value->format('Y-m-d'),]); | 
					
						
							|  |  |  |                     break; | 
					
						
							| 
									
										
										
										
											2022-03-27 16:03:50 +02:00
										 |  |  |                 case 'year': | 
					
						
							| 
									
										
										
										
											2022-03-29 14:59:58 +02:00
										 |  |  |                     Log::debug(sprintf('Set %s_is_exact YEAR value "%s"', $field, $value)); | 
					
						
							|  |  |  |                     $this->collector->objectYearIs($value, $field); | 
					
						
							|  |  |  |                     $this->operators->push(['type' => sprintf('%s_on_year', $field), 'value' => $value,]); | 
					
						
							| 
									
										
										
										
											2022-03-27 16:03:50 +02:00
										 |  |  |                     break; | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  |                 case 'year_not': | 
					
						
							|  |  |  |                     Log::debug(sprintf('Set NOT %s_is_exact YEAR value "%s"', $field, $value)); | 
					
						
							|  |  |  |                     $this->collector->objectYearIsNot($value, $field); | 
					
						
							|  |  |  |                     $this->operators->push(['type' => sprintf('not_%s_on_year', $field), 'value' => $value,]); | 
					
						
							|  |  |  |                     break; | 
					
						
							| 
									
										
										
										
											2022-03-27 16:03:50 +02:00
										 |  |  |                 case 'month': | 
					
						
							| 
									
										
										
										
											2022-03-29 14:59:58 +02:00
										 |  |  |                     Log::debug(sprintf('Set %s_is_exact MONTH value "%s"', $field, $value)); | 
					
						
							|  |  |  |                     $this->collector->objectMonthIs($value, $field); | 
					
						
							|  |  |  |                     $this->operators->push(['type' => sprintf('%s_on_month', $field), 'value' => $value,]); | 
					
						
							| 
									
										
										
										
											2022-03-27 16:03:50 +02:00
										 |  |  |                     break; | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  |                 case 'month_not': | 
					
						
							|  |  |  |                     Log::debug(sprintf('Set NOT %s_is_exact MONTH value "%s"', $field, $value)); | 
					
						
							|  |  |  |                     $this->collector->objectMonthIsNot($value, $field); | 
					
						
							|  |  |  |                     $this->operators->push(['type' => sprintf('not_%s_on_month', $field), 'value' => $value,]); | 
					
						
							|  |  |  |                     break; | 
					
						
							| 
									
										
										
										
											2022-03-27 16:03:50 +02:00
										 |  |  |                 case 'day': | 
					
						
							| 
									
										
										
										
											2022-03-29 14:59:58 +02:00
										 |  |  |                     Log::debug(sprintf('Set %s_is_exact DAY value "%s"', $field, $value)); | 
					
						
							|  |  |  |                     $this->collector->objectDayIs($value, $field); | 
					
						
							|  |  |  |                     $this->operators->push(['type' => sprintf('%s_on_day', $field), 'value' => $value,]); | 
					
						
							| 
									
										
										
										
											2022-03-27 16:03:50 +02:00
										 |  |  |                     break; | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  |                 case 'day_not': | 
					
						
							|  |  |  |                     Log::debug(sprintf('Set NOT %s_is_exact DAY value "%s"', $field, $value)); | 
					
						
							|  |  |  |                     $this->collector->objectDayIsNot($value, $field); | 
					
						
							|  |  |  |                     $this->operators->push(['type' => sprintf('not_%s_on_day', $field), 'value' => $value,]); | 
					
						
							|  |  |  |                     break; | 
					
						
							| 
									
										
										
										
											2022-03-27 16:03:50 +02:00
										 |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							| 
									
										
										
										
											2022-12-29 19:42:26 +01:00
										 |  |  |      * @param  string  $field | 
					
						
							|  |  |  |      * @param  array  $range | 
					
						
							| 
									
										
										
										
											2022-03-27 16:03:50 +02:00
										 |  |  |      * | 
					
						
							|  |  |  |      * @throws FireflyException | 
					
						
							|  |  |  |      */ | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  |     private function setObjectDateBeforeParams(string $field, array $range, bool $prohibited = false): void | 
					
						
							| 
									
										
										
										
											2022-03-27 16:03:50 +02:00
										 |  |  |     { | 
					
						
							|  |  |  |         /** | 
					
						
							| 
									
										
										
										
											2022-12-29 19:42:26 +01:00
										 |  |  |          * @var string $key | 
					
						
							| 
									
										
										
										
											2022-03-27 16:03:50 +02:00
										 |  |  |          * @var Carbon|string $value | 
					
						
							|  |  |  |          */ | 
					
						
							|  |  |  |         foreach ($range as $key => $value) { | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  |             $key = $prohibited ? sprintf('%s_not', $key) : $key; | 
					
						
							| 
									
										
										
										
											2022-03-27 16:03:50 +02:00
										 |  |  |             switch ($key) { | 
					
						
							|  |  |  |                 default: | 
					
						
							| 
									
										
										
										
											2022-04-13 14:11:36 +02:00
										 |  |  |                     throw new FireflyException(sprintf('Cannot handle key "%s" in setObjectDateBeforeParams()', $key)); | 
					
						
							| 
									
										
										
										
											2022-03-27 16:03:50 +02:00
										 |  |  |                 case 'exact': | 
					
						
							|  |  |  |                     $this->collector->setObjectBefore($value, $field); | 
					
						
							|  |  |  |                     $this->operators->push(['type' => sprintf('%s_before', $field), 'value' => $value->format('Y-m-d'),]); | 
					
						
							|  |  |  |                     break; | 
					
						
							|  |  |  |                 case 'year': | 
					
						
							|  |  |  |                     Log::debug(sprintf('Set date_is_before YEAR value "%s"', $value)); | 
					
						
							|  |  |  |                     $this->collector->objectYearBefore($value, $field); | 
					
						
							|  |  |  |                     $this->operators->push(['type' => sprintf('%s_before_year', $field), 'value' => $value,]); | 
					
						
							|  |  |  |                     break; | 
					
						
							|  |  |  |                 case 'month': | 
					
						
							|  |  |  |                     Log::debug(sprintf('Set date_is_before MONTH value "%s"', $value)); | 
					
						
							|  |  |  |                     $this->collector->objectMonthBefore($value, $field); | 
					
						
							|  |  |  |                     $this->operators->push(['type' => sprintf('%s_before_month', $field), 'value' => $value,]); | 
					
						
							|  |  |  |                     break; | 
					
						
							|  |  |  |                 case 'day': | 
					
						
							|  |  |  |                     Log::debug(sprintf('Set date_is_before DAY value "%s"', $value)); | 
					
						
							|  |  |  |                     $this->collector->objectDayBefore($value, $field); | 
					
						
							|  |  |  |                     $this->operators->push(['type' => sprintf('%s_before_day', $field), 'value' => $value,]); | 
					
						
							|  |  |  |                     break; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-03-27 08:48:30 +02:00
										 |  |  |     /** | 
					
						
							| 
									
										
										
										
											2022-12-29 19:42:26 +01:00
										 |  |  |      * @param  string  $field | 
					
						
							|  |  |  |      * @param  array  $range | 
					
						
							| 
									
										
										
										
											2022-03-29 14:59:58 +02:00
										 |  |  |      * | 
					
						
							| 
									
										
										
										
											2022-03-27 08:48:30 +02:00
										 |  |  |      * @throws FireflyException | 
					
						
							|  |  |  |      */ | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  |     private function setObjectDateAfterParams(string $field, array $range, bool $prohibited = false): void | 
					
						
							| 
									
										
										
										
											2022-03-27 08:48:30 +02:00
										 |  |  |     { | 
					
						
							|  |  |  |         /** | 
					
						
							| 
									
										
										
										
											2022-12-29 19:42:26 +01:00
										 |  |  |          * @var string $key | 
					
						
							| 
									
										
										
										
											2022-03-27 08:48:30 +02:00
										 |  |  |          * @var Carbon|string $value | 
					
						
							|  |  |  |          */ | 
					
						
							|  |  |  |         foreach ($range as $key => $value) { | 
					
						
							| 
									
										
										
										
											2022-09-25 15:31:07 +02:00
										 |  |  |             $key = $prohibited ? sprintf('%s_not', $key) : $key; | 
					
						
							| 
									
										
										
										
											2022-03-27 08:48:30 +02:00
										 |  |  |             switch ($key) { | 
					
						
							|  |  |  |                 default: | 
					
						
							| 
									
										
										
										
											2022-04-13 14:11:36 +02:00
										 |  |  |                     throw new FireflyException(sprintf('Cannot handle key "%s" in setObjectDateAfterParams()', $key)); | 
					
						
							| 
									
										
										
										
											2022-03-27 08:48:30 +02:00
										 |  |  |                 case 'exact': | 
					
						
							| 
									
										
										
										
											2022-03-29 14:59:58 +02:00
										 |  |  |                     $this->collector->setObjectAfter($value, $field); | 
					
						
							|  |  |  |                     $this->operators->push(['type' => sprintf('%s_after', $field), 'value' => $value->format('Y-m-d'),]); | 
					
						
							| 
									
										
										
										
											2022-03-27 08:48:30 +02:00
										 |  |  |                     break; | 
					
						
							|  |  |  |                 case 'year': | 
					
						
							| 
									
										
										
										
											2022-03-29 14:59:58 +02:00
										 |  |  |                     Log::debug(sprintf('Set date_is_after YEAR value "%s"', $value)); | 
					
						
							|  |  |  |                     $this->collector->objectYearAfter($value, $field); | 
					
						
							|  |  |  |                     $this->operators->push(['type' => sprintf('%s_after_year', $field), 'value' => $value,]); | 
					
						
							| 
									
										
										
										
											2022-03-27 08:48:30 +02:00
										 |  |  |                     break; | 
					
						
							|  |  |  |                 case 'month': | 
					
						
							| 
									
										
										
										
											2022-03-29 14:59:58 +02:00
										 |  |  |                     Log::debug(sprintf('Set date_is_after MONTH value "%s"', $value)); | 
					
						
							|  |  |  |                     $this->collector->objectMonthAfter($value, $field); | 
					
						
							|  |  |  |                     $this->operators->push(['type' => sprintf('%s_after_month', $field), 'value' => $value,]); | 
					
						
							| 
									
										
										
										
											2022-03-27 08:48:30 +02:00
										 |  |  |                     break; | 
					
						
							|  |  |  |                 case 'day': | 
					
						
							| 
									
										
										
										
											2022-03-29 14:59:58 +02:00
										 |  |  |                     Log::debug(sprintf('Set date_is_after DAY value "%s"', $value)); | 
					
						
							|  |  |  |                     $this->collector->objectDayAfter($value, $field); | 
					
						
							|  |  |  |                     $this->operators->push(['type' => sprintf('%s_after_day', $field), 'value' => $value,]); | 
					
						
							| 
									
										
										
										
											2022-03-27 08:48:30 +02:00
										 |  |  |                     break; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2022-03-29 14:59:58 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * @inheritDoc | 
					
						
							| 
									
										
										
										
											2023-02-12 07:23:57 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-03-29 14:59:58 +02:00
										 |  |  |      */ | 
					
						
							|  |  |  |     public function searchTime(): float | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         return microtime(true) - $this->startTime; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * @inheritDoc | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     public function searchTransactions(): LengthAwarePaginator | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2022-11-04 05:11:05 +01:00
										 |  |  |         if (0 === count($this->getWords()) && 0 === count($this->getOperators())) { | 
					
						
							| 
									
										
										
										
											2022-03-29 14:59:58 +02:00
										 |  |  |             return new LengthAwarePaginator([], 0, 5, 1); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         return $this->collector->getPaginatedGroups(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * @return array | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     public function getWords(): array | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         return $this->words; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							| 
									
										
										
										
											2022-12-29 19:42:26 +01:00
										 |  |  |      * @param  Carbon  $date | 
					
						
							| 
									
										
										
										
											2022-03-29 14:59:58 +02:00
										 |  |  |      */ | 
					
						
							|  |  |  |     public function setDate(Carbon $date): void | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         $this->date = $date; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * @inheritDoc | 
					
						
							| 
									
										
										
										
											2023-02-12 07:23:57 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-03-29 14:59:58 +02:00
										 |  |  |      */ | 
					
						
							|  |  |  |     public function setPage(int $page): void | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         $this->page = $page; | 
					
						
							|  |  |  |         $this->collector->setPage($this->page); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * @inheritDoc | 
					
						
							| 
									
										
										
										
											2023-02-12 07:23:57 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-03-29 14:59:58 +02:00
										 |  |  |      */ | 
					
						
							|  |  |  |     public function setUser(User $user): void | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         $this->accountRepository->setUser($user); | 
					
						
							|  |  |  |         $this->billRepository->setUser($user); | 
					
						
							|  |  |  |         $this->categoryRepository->setUser($user); | 
					
						
							|  |  |  |         $this->budgetRepository->setUser($user); | 
					
						
							|  |  |  |         $this->tagRepository->setUser($user); | 
					
						
							|  |  |  |         $this->collector = app(GroupCollectorInterface::class); | 
					
						
							|  |  |  |         $this->collector->setUser($user); | 
					
						
							|  |  |  |         $this->collector->withAccountInformation()->withCategoryInformation()->withBudgetInformation(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-12-29 19:42:26 +01:00
										 |  |  |         $this->setLimit((int)app('preferences')->getForUser($user, 'listPageSize', 50)->data); | 
					
						
							| 
									
										
										
										
											2022-03-29 14:59:58 +02:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							| 
									
										
										
										
											2022-12-29 19:42:26 +01:00
										 |  |  |      * @param  int  $limit | 
					
						
							| 
									
										
										
										
											2022-03-29 14:59:58 +02:00
										 |  |  |      */ | 
					
						
							|  |  |  |     public function setLimit(int $limit): void | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         $this->limit = $limit; | 
					
						
							|  |  |  |         $this->collector->setLimit($this->limit); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2020-12-22 05:35:06 +01:00
										 |  |  | } |