| 
									
										
										
										
											2018-02-13 21:04:15 +01:00
										 |  |  | <?php | 
					
						
							| 
									
										
										
										
											2018-03-19 12:08:50 +01:00
										 |  |  | declare(strict_types=1); | 
					
						
							| 
									
										
										
										
											2018-02-13 21:04:15 +01:00
										 |  |  | /** | 
					
						
							|  |  |  |  * TransactionController.php | 
					
						
							|  |  |  |  * Copyright (c) 2018 thegrumpydictator@gmail.com | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * This file is part of Firefly III. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Firefly III is free software: you can redistribute it and/or modify | 
					
						
							|  |  |  |  * it under the terms of the GNU General Public License as published by | 
					
						
							|  |  |  |  * the Free Software Foundation, either version 3 of the License, or | 
					
						
							|  |  |  |  * (at your option) any later version. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Firefly III 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 General Public License for more details. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * You should have received a copy of the GNU General Public License | 
					
						
							|  |  |  |  * along with Firefly III. If not, see <http://www.gnu.org/licenses/>. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | namespace FireflyIII\Api\V1\Controllers; | 
					
						
							| 
									
										
										
										
											2018-02-16 16:42:13 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | use FireflyIII\Api\V1\Requests\TransactionRequest; | 
					
						
							| 
									
										
										
										
											2018-02-18 10:31:15 +01:00
										 |  |  | use FireflyIII\Helpers\Collector\JournalCollectorInterface; | 
					
						
							| 
									
										
										
										
											2018-02-16 16:42:13 +01:00
										 |  |  | use FireflyIII\Helpers\Filter\InternalTransferFilter; | 
					
						
							|  |  |  | use FireflyIII\Helpers\Filter\NegativeAmountFilter; | 
					
						
							|  |  |  | use FireflyIII\Helpers\Filter\PositiveAmountFilter; | 
					
						
							|  |  |  | use FireflyIII\Models\Transaction; | 
					
						
							|  |  |  | use FireflyIII\Models\TransactionType; | 
					
						
							| 
									
										
										
										
											2018-02-13 21:04:15 +01:00
										 |  |  | use FireflyIII\Repositories\Journal\JournalRepositoryInterface; | 
					
						
							| 
									
										
										
										
											2018-02-16 16:42:13 +01:00
										 |  |  | use FireflyIII\Transformers\TransactionTransformer; | 
					
						
							| 
									
										
										
										
											2018-02-13 21:04:15 +01:00
										 |  |  | use Illuminate\Http\Request; | 
					
						
							|  |  |  | use Illuminate\Support\Collection; | 
					
						
							| 
									
										
										
										
											2018-02-16 16:42:13 +01:00
										 |  |  | use League\Fractal\Manager; | 
					
						
							|  |  |  | use League\Fractal\Pagination\IlluminatePaginatorAdapter; | 
					
						
							|  |  |  | use League\Fractal\Resource\Collection as FractalCollection; | 
					
						
							|  |  |  | use League\Fractal\Serializer\JsonApiSerializer; | 
					
						
							| 
									
										
										
										
											2018-03-03 08:12:18 +01:00
										 |  |  | use Log; | 
					
						
							| 
									
										
										
										
											2018-02-13 21:04:15 +01:00
										 |  |  | use Preferences; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** | 
					
						
							|  |  |  |  * Class TransactionController | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | class TransactionController extends Controller | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** @var JournalRepositoryInterface */ | 
					
						
							|  |  |  |     private $repository; | 
					
						
							| 
									
										
										
										
											2018-02-16 16:42:13 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-13 21:04:15 +01:00
										 |  |  |     /** | 
					
						
							|  |  |  |      * TransactionController constructor. | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @throws \FireflyIII\Exceptions\FireflyException | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     public function __construct() | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         parent::__construct(); | 
					
						
							|  |  |  |         $this->middleware( | 
					
						
							|  |  |  |             function ($request, $next) { | 
					
						
							|  |  |  |                 /** @var JournalRepositoryInterface repository */ | 
					
						
							|  |  |  |                 $this->repository = app(JournalRepositoryInterface::class); | 
					
						
							|  |  |  |                 $this->repository->setUser(auth()->user()); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 return $next($request); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         ); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * Remove the specified resource from storage. | 
					
						
							|  |  |  |      * | 
					
						
							| 
									
										
										
										
											2018-02-16 16:42:13 +01:00
										 |  |  |      * @param  \FireflyIII\Models\Transaction $transaction | 
					
						
							| 
									
										
										
										
											2018-02-13 21:04:15 +01:00
										 |  |  |      * | 
					
						
							|  |  |  |      * @return \Illuminate\Http\Response | 
					
						
							|  |  |  |      */ | 
					
						
							| 
									
										
										
										
											2018-02-16 16:42:13 +01:00
										 |  |  |     public function delete(Transaction $transaction) | 
					
						
							| 
									
										
										
										
											2018-02-13 21:04:15 +01:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2018-02-16 16:42:13 +01:00
										 |  |  |         $journal = $transaction->transactionJournal; | 
					
						
							| 
									
										
										
										
											2018-03-04 08:22:32 +01:00
										 |  |  |         $this->repository->destroy($journal); | 
					
						
							| 
									
										
										
										
											2018-02-13 21:04:15 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |         return response()->json([], 204); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * @param Request $request | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @return \Illuminate\Http\JsonResponse | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     public function index(Request $request) | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2018-04-02 14:17:11 +02:00
										 |  |  |         $pageSize = (int)Preferences::getForUser(auth()->user(), 'listPageSize', 50)->data; | 
					
						
							| 
									
										
										
										
											2018-02-16 16:42:13 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |         // read type from URI
 | 
					
						
							|  |  |  |         $type = $request->get('type') ?? 'default'; | 
					
						
							|  |  |  |         $this->parameters->set('type', $type); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         // types to get, page size:
 | 
					
						
							|  |  |  |         $types = $this->mapTypes($this->parameters->get('type')); | 
					
						
							| 
									
										
										
										
											2018-02-13 21:04:15 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |         $manager = new Manager(); | 
					
						
							|  |  |  |         $baseUrl = $request->getSchemeAndHttpHost() . '/api/v1'; | 
					
						
							|  |  |  |         $manager->setSerializer(new JsonApiSerializer($baseUrl)); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-16 16:42:13 +01:00
										 |  |  |         // collect transactions using the journal collector
 | 
					
						
							| 
									
										
										
										
											2018-02-18 10:31:15 +01:00
										 |  |  |         $collector = app(JournalCollectorInterface::class); | 
					
						
							| 
									
										
										
										
											2018-02-16 16:42:13 +01:00
										 |  |  |         $collector->setUser(auth()->user()); | 
					
						
							|  |  |  |         $collector->withOpposingAccount()->withCategoryInformation()->withBudgetInformation(); | 
					
						
							|  |  |  |         $collector->setAllAssetAccounts(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         // remove internal transfer filter:
 | 
					
						
							|  |  |  |         if (in_array(TransactionType::TRANSFER, $types)) { | 
					
						
							|  |  |  |             $collector->removeFilter(InternalTransferFilter::class); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-02 14:17:11 +02:00
										 |  |  |         if (null !== $this->parameters->get('start') && null !== $this->parameters->get('end')) { | 
					
						
							| 
									
										
										
										
											2018-02-16 16:42:13 +01:00
										 |  |  |             $collector->setRange($this->parameters->get('start'), $this->parameters->get('end')); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         $collector->setLimit($pageSize)->setPage($this->parameters->get('page')); | 
					
						
							|  |  |  |         $collector->setTypes($types); | 
					
						
							|  |  |  |         $paginator = $collector->getPaginatedJournals(); | 
					
						
							|  |  |  |         $paginator->setPath(route('api.v1.transactions.index') . $this->buildParams()); | 
					
						
							|  |  |  |         $transactions = $paginator->getCollection(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         $resource = new FractalCollection($transactions, new TransactionTransformer($this->parameters), 'transactions'); | 
					
						
							| 
									
										
										
										
											2018-02-13 21:04:15 +01:00
										 |  |  |         $resource->setPaginator(new IlluminatePaginatorAdapter($paginator)); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-18 10:31:15 +01:00
										 |  |  |         return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json'); | 
					
						
							| 
									
										
										
										
											2018-02-13 21:04:15 +01:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							| 
									
										
										
										
											2018-02-16 16:42:13 +01:00
										 |  |  |      * @param Request     $request | 
					
						
							|  |  |  |      * @param Transaction $transaction | 
					
						
							| 
									
										
										
										
											2018-02-13 21:04:15 +01:00
										 |  |  |      * | 
					
						
							|  |  |  |      * @return \Illuminate\Http\JsonResponse | 
					
						
							|  |  |  |      */ | 
					
						
							| 
									
										
										
										
											2018-02-16 16:42:13 +01:00
										 |  |  |     public function show(Request $request, Transaction $transaction) | 
					
						
							| 
									
										
										
										
											2018-02-13 21:04:15 +01:00
										 |  |  |     { | 
					
						
							|  |  |  |         $manager = new Manager(); | 
					
						
							|  |  |  |         $baseUrl = $request->getSchemeAndHttpHost() . '/api/v1'; | 
					
						
							|  |  |  |         $manager->setSerializer(new JsonApiSerializer($baseUrl)); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-16 16:42:13 +01:00
										 |  |  |         // add include parameter:
 | 
					
						
							|  |  |  |         $include = $request->get('include') ?? ''; | 
					
						
							|  |  |  |         $manager->parseIncludes($include); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         // collect transactions using the journal collector
 | 
					
						
							| 
									
										
										
										
											2018-02-18 10:31:15 +01:00
										 |  |  |         $collector = app(JournalCollectorInterface::class); | 
					
						
							| 
									
										
										
										
											2018-02-16 16:42:13 +01:00
										 |  |  |         $collector->setUser(auth()->user()); | 
					
						
							|  |  |  |         $collector->withOpposingAccount()->withCategoryInformation()->withBudgetInformation(); | 
					
						
							|  |  |  |         // filter on specific journals.
 | 
					
						
							|  |  |  |         $collector->setJournals(new Collection([$transaction->transactionJournal])); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         // add filter to remove transactions:
 | 
					
						
							|  |  |  |         $transactionType = $transaction->transactionJournal->transactionType->type; | 
					
						
							|  |  |  |         if ($transactionType === TransactionType::WITHDRAWAL) { | 
					
						
							|  |  |  |             $collector->addFilter(PositiveAmountFilter::class); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         if (!($transactionType === TransactionType::WITHDRAWAL)) { | 
					
						
							|  |  |  |             $collector->addFilter(NegativeAmountFilter::class); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-18 10:31:15 +01:00
										 |  |  |         $transactions = $collector->getJournals(); | 
					
						
							| 
									
										
										
										
											2018-03-04 14:20:23 +01:00
										 |  |  |         $resource     = new FractalCollection($transactions, new TransactionTransformer($this->parameters), 'transactions'); | 
					
						
							| 
									
										
										
										
											2018-02-16 16:42:13 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-18 10:31:15 +01:00
										 |  |  |         return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json'); | 
					
						
							| 
									
										
										
										
											2018-02-13 21:04:15 +01:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							| 
									
										
										
										
											2018-03-11 16:24:07 +01:00
										 |  |  |      * @param TransactionRequest         $request | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @param JournalRepositoryInterface $repository | 
					
						
							| 
									
										
										
										
											2018-02-13 21:04:15 +01:00
										 |  |  |      * | 
					
						
							|  |  |  |      * @return \Illuminate\Http\JsonResponse | 
					
						
							|  |  |  |      */ | 
					
						
							| 
									
										
										
										
											2018-02-23 16:59:21 +01:00
										 |  |  |     public function store(TransactionRequest $request, JournalRepositoryInterface $repository) | 
					
						
							| 
									
										
										
										
											2018-02-13 21:04:15 +01:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2018-02-16 16:42:13 +01:00
										 |  |  |         $data         = $request->getAll(); | 
					
						
							|  |  |  |         $data['user'] = auth()->user()->id; | 
					
						
							| 
									
										
										
										
											2018-02-23 16:59:21 +01:00
										 |  |  |         $journal      = $repository->store($data); | 
					
						
							| 
									
										
										
										
											2018-02-16 16:42:13 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-13 21:04:15 +01:00
										 |  |  |         $manager = new Manager(); | 
					
						
							|  |  |  |         $baseUrl = $request->getSchemeAndHttpHost() . '/api/v1'; | 
					
						
							|  |  |  |         $manager->setSerializer(new JsonApiSerializer($baseUrl)); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-16 16:57:27 +01:00
										 |  |  |         // add include parameter:
 | 
					
						
							|  |  |  |         $include = $request->get('include') ?? ''; | 
					
						
							|  |  |  |         $manager->parseIncludes($include); | 
					
						
							| 
									
										
										
										
											2018-02-13 21:04:15 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-16 16:57:27 +01:00
										 |  |  |         // collect transactions using the journal collector
 | 
					
						
							| 
									
										
										
										
											2018-02-18 10:31:15 +01:00
										 |  |  |         $collector = app(JournalCollectorInterface::class); | 
					
						
							| 
									
										
										
										
											2018-02-16 16:57:27 +01:00
										 |  |  |         $collector->setUser(auth()->user()); | 
					
						
							|  |  |  |         $collector->withOpposingAccount()->withCategoryInformation()->withBudgetInformation(); | 
					
						
							|  |  |  |         // filter on specific journals.
 | 
					
						
							|  |  |  |         $collector->setJournals(new Collection([$journal])); | 
					
						
							| 
									
										
										
										
											2018-02-13 21:04:15 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-16 16:57:27 +01:00
										 |  |  |         // add filter to remove transactions:
 | 
					
						
							|  |  |  |         $transactionType = $journal->transactionType->type; | 
					
						
							|  |  |  |         if ($transactionType === TransactionType::WITHDRAWAL) { | 
					
						
							|  |  |  |             $collector->addFilter(PositiveAmountFilter::class); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         if (!($transactionType === TransactionType::WITHDRAWAL)) { | 
					
						
							|  |  |  |             $collector->addFilter(NegativeAmountFilter::class); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-18 10:31:15 +01:00
										 |  |  |         $transactions = $collector->getJournals(); | 
					
						
							| 
									
										
										
										
											2018-02-20 18:03:02 +01:00
										 |  |  |         $resource     = new FractalCollection($transactions, new TransactionTransformer($this->parameters), 'transactions'); | 
					
						
							| 
									
										
										
										
											2018-02-16 16:57:27 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-18 10:31:15 +01:00
										 |  |  |         return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json'); | 
					
						
							| 
									
										
										
										
											2018-02-13 21:04:15 +01:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							| 
									
										
										
										
											2018-03-03 08:12:18 +01:00
										 |  |  |      * @param TransactionRequest         $request | 
					
						
							|  |  |  |      * @param JournalRepositoryInterface $repository | 
					
						
							|  |  |  |      * @param Transaction                $transaction | 
					
						
							| 
									
										
										
										
											2018-02-13 21:04:15 +01:00
										 |  |  |      * | 
					
						
							|  |  |  |      * @return \Illuminate\Http\JsonResponse | 
					
						
							|  |  |  |      */ | 
					
						
							| 
									
										
										
										
											2018-03-03 08:12:18 +01:00
										 |  |  |     public function update(TransactionRequest $request, JournalRepositoryInterface $repository, Transaction $transaction) | 
					
						
							| 
									
										
										
										
											2018-02-13 21:04:15 +01:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2018-02-21 08:51:30 +01:00
										 |  |  |         $data         = $request->getAll(); | 
					
						
							|  |  |  |         $data['user'] = auth()->user()->id; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-03 08:12:18 +01:00
										 |  |  |         Log::debug('Inside transaction update'); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         $journal = $repository->update($transaction->transactionJournal, $data); | 
					
						
							| 
									
										
										
										
											2018-02-21 08:51:30 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-13 21:04:15 +01:00
										 |  |  |         $manager = new Manager(); | 
					
						
							|  |  |  |         $baseUrl = $request->getSchemeAndHttpHost() . '/api/v1'; | 
					
						
							|  |  |  |         $manager->setSerializer(new JsonApiSerializer($baseUrl)); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-21 08:51:30 +01:00
										 |  |  |         // add include parameter:
 | 
					
						
							|  |  |  |         $include = $request->get('include') ?? ''; | 
					
						
							|  |  |  |         $manager->parseIncludes($include); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         // needs a lot of extra data to match the journal collector. Or just expand that one.
 | 
					
						
							|  |  |  |         // collect transactions using the journal collector
 | 
					
						
							|  |  |  |         $collector = app(JournalCollectorInterface::class); | 
					
						
							|  |  |  |         $collector->setUser(auth()->user()); | 
					
						
							|  |  |  |         $collector->withOpposingAccount()->withCategoryInformation()->withBudgetInformation(); | 
					
						
							|  |  |  |         // filter on specific journals.
 | 
					
						
							|  |  |  |         $collector->setJournals(new Collection([$journal])); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         // add filter to remove transactions:
 | 
					
						
							|  |  |  |         $transactionType = $journal->transactionType->type; | 
					
						
							|  |  |  |         if ($transactionType === TransactionType::WITHDRAWAL) { | 
					
						
							|  |  |  |             $collector->addFilter(PositiveAmountFilter::class); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         if (!($transactionType === TransactionType::WITHDRAWAL)) { | 
					
						
							|  |  |  |             $collector->addFilter(NegativeAmountFilter::class); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         $transactions = $collector->getJournals(); | 
					
						
							|  |  |  |         $resource     = new FractalCollection($transactions, new TransactionTransformer($this->parameters), 'transactions'); | 
					
						
							| 
									
										
										
										
											2018-02-13 21:04:15 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-18 10:31:15 +01:00
										 |  |  |         return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json'); | 
					
						
							| 
									
										
										
										
											2018-02-13 21:04:15 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2018-02-16 16:42:13 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * @param string $type | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @return array | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     private function mapTypes(string $type): array | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         $types = [ | 
					
						
							|  |  |  |             'all'             => [ | 
					
						
							|  |  |  |                 TransactionType::WITHDRAWAL, | 
					
						
							|  |  |  |                 TransactionType::DEPOSIT, | 
					
						
							|  |  |  |                 TransactionType::TRANSFER, | 
					
						
							|  |  |  |                 TransactionType::OPENING_BALANCE, | 
					
						
							|  |  |  |                 TransactionType::RECONCILIATION, | 
					
						
							|  |  |  |             ], | 
					
						
							|  |  |  |             'withdrawal'      => [ | 
					
						
							|  |  |  |                 TransactionType::WITHDRAWAL, | 
					
						
							|  |  |  |             ], | 
					
						
							|  |  |  |             'withdrawals'     => [ | 
					
						
							|  |  |  |                 TransactionType::WITHDRAWAL, | 
					
						
							|  |  |  |             ], | 
					
						
							|  |  |  |             'expense'         => [ | 
					
						
							|  |  |  |                 TransactionType::WITHDRAWAL, | 
					
						
							|  |  |  |             ], | 
					
						
							|  |  |  |             'income'          => [ | 
					
						
							|  |  |  |                 TransactionType::DEPOSIT, | 
					
						
							|  |  |  |             ], | 
					
						
							|  |  |  |             'deposit'         => [ | 
					
						
							|  |  |  |                 TransactionType::DEPOSIT, | 
					
						
							|  |  |  |             ], | 
					
						
							|  |  |  |             'deposits'        => [ | 
					
						
							|  |  |  |                 TransactionType::DEPOSIT, | 
					
						
							|  |  |  |             ], | 
					
						
							|  |  |  |             'transfer'        => [ | 
					
						
							|  |  |  |                 TransactionType::TRANSFER, | 
					
						
							|  |  |  |             ], | 
					
						
							|  |  |  |             'transfers'       => [ | 
					
						
							|  |  |  |                 TransactionType::TRANSFER, | 
					
						
							|  |  |  |             ], | 
					
						
							|  |  |  |             'opening_balance' => [ | 
					
						
							|  |  |  |                 TransactionType::OPENING_BALANCE, | 
					
						
							|  |  |  |             ], | 
					
						
							|  |  |  |             'reconciliation'  => [ | 
					
						
							|  |  |  |                 TransactionType::RECONCILIATION, | 
					
						
							|  |  |  |             ], | 
					
						
							|  |  |  |             'reconciliations' => [ | 
					
						
							|  |  |  |                 TransactionType::RECONCILIATION, | 
					
						
							|  |  |  |             ], | 
					
						
							|  |  |  |             'special'         => [ | 
					
						
							|  |  |  |                 TransactionType::OPENING_BALANCE, | 
					
						
							|  |  |  |                 TransactionType::RECONCILIATION, | 
					
						
							|  |  |  |             ], | 
					
						
							|  |  |  |             'specials'        => [ | 
					
						
							|  |  |  |                 TransactionType::OPENING_BALANCE, | 
					
						
							|  |  |  |                 TransactionType::RECONCILIATION, | 
					
						
							|  |  |  |             ], | 
					
						
							|  |  |  |             'default'         => [ | 
					
						
							|  |  |  |                 TransactionType::WITHDRAWAL, | 
					
						
							|  |  |  |                 TransactionType::DEPOSIT, | 
					
						
							|  |  |  |                 TransactionType::TRANSFER, | 
					
						
							|  |  |  |             ], | 
					
						
							|  |  |  |         ]; | 
					
						
							|  |  |  |         if (isset($types[$type])) { | 
					
						
							|  |  |  |             return $types[$type]; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-18 10:31:15 +01:00
										 |  |  |         return $types['default']; // @codeCoverageIgnore
 | 
					
						
							| 
									
										
										
										
											2018-02-16 16:42:13 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2018-03-05 19:35:58 +01:00
										 |  |  | } |