| 
									
										
										
										
											2018-02-16 16:43:00 +01:00
										 |  |  | <?php | 
					
						
							| 
									
										
										
										
											2018-05-11 10:08:34 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-16 16:43:00 +01:00
										 |  |  | /** | 
					
						
							| 
									
										
										
										
											2019-04-06 08:10:50 +02:00
										 |  |  |  * TransactionStoreRequest.php | 
					
						
							| 
									
										
										
										
											2019-10-02 06:37:26 +02:00
										 |  |  |  * Copyright (c) 2019 thegrumpydictator@gmail.com | 
					
						
							| 
									
										
										
										
											2018-02-16 16:43:00 +01:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2019-10-02 06:37:26 +02:00
										 |  |  |  * This file is part of Firefly III (https://github.com/firefly-iii). | 
					
						
							| 
									
										
										
										
											2018-02-16 16:43:00 +01:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2019-10-02 06:37:26 +02:00
										 |  |  |  * 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. | 
					
						
							| 
									
										
										
										
											2018-02-16 16:43:00 +01:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2019-10-02 06:37:26 +02:00
										 |  |  |  * This program is distributed in the hope that it will be useful, | 
					
						
							| 
									
										
										
										
											2018-02-16 16:43:00 +01:00
										 |  |  |  * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
					
						
							|  |  |  |  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
					
						
							| 
									
										
										
										
											2019-10-02 06:37:26 +02:00
										 |  |  |  * GNU Affero General Public License for more details. | 
					
						
							| 
									
										
										
										
											2018-02-16 16:43:00 +01:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2019-10-02 06:37:26 +02:00
										 |  |  |  * 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/>. | 
					
						
							| 
									
										
										
										
											2018-02-16 16:43:00 +01:00
										 |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-11 10:08:34 +02:00
										 |  |  | declare(strict_types=1); | 
					
						
							| 
									
										
										
										
											2018-02-16 16:43:00 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | namespace FireflyIII\Api\V1\Requests; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | use FireflyIII\Rules\BelongsUser; | 
					
						
							| 
									
										
										
										
											2018-12-03 15:57:15 +01:00
										 |  |  | use FireflyIII\Rules\IsBoolean; | 
					
						
							| 
									
										
										
										
											2019-02-08 07:14:45 +01:00
										 |  |  | use FireflyIII\Rules\IsDateOrTime; | 
					
						
							| 
									
										
										
										
											2019-03-31 13:36:49 +02:00
										 |  |  | use FireflyIII\Support\NullArrayObject; | 
					
						
							| 
									
										
										
										
											2018-07-05 18:02:02 +02:00
										 |  |  | use FireflyIII\Validation\TransactionValidation; | 
					
						
							| 
									
										
										
										
											2018-02-16 16:43:00 +01:00
										 |  |  | use Illuminate\Validation\Validator; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** | 
					
						
							| 
									
										
										
										
											2019-04-06 08:10:50 +02:00
										 |  |  |  * Class TransactionStoreRequest | 
					
						
							| 
									
										
										
										
											2018-02-16 16:43:00 +01:00
										 |  |  |  */ | 
					
						
							| 
									
										
										
										
											2019-04-06 08:10:50 +02:00
										 |  |  | class TransactionStoreRequest extends Request | 
					
						
							| 
									
										
										
										
											2018-02-16 16:43:00 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2018-07-05 18:02:02 +02:00
										 |  |  |     use TransactionValidation; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-16 16:43:00 +01:00
										 |  |  |     /** | 
					
						
							| 
									
										
										
										
											2018-07-06 07:15:42 +02:00
										 |  |  |      * Authorize logged in users. | 
					
						
							|  |  |  |      * | 
					
						
							| 
									
										
										
										
											2018-02-16 16:43:00 +01:00
										 |  |  |      * @return bool | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     public function authorize(): bool | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         // Only allow authenticated users
 | 
					
						
							|  |  |  |         return auth()->check(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							| 
									
										
										
										
											2018-07-05 18:02:02 +02:00
										 |  |  |      * Get all data. Is pretty complex because of all the ??-statements. | 
					
						
							|  |  |  |      * | 
					
						
							| 
									
										
										
										
											2018-02-16 16:43:00 +01:00
										 |  |  |      * @return array | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     public function getAll(): array | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         $data = [ | 
					
						
							| 
									
										
										
										
											2019-03-31 13:36:49 +02:00
										 |  |  |             'group_title'  => $this->string('group_title'), | 
					
						
							|  |  |  |             'transactions' => $this->getTransactionData(), | 
					
						
							| 
									
										
										
										
											2018-02-16 16:43:00 +01:00
										 |  |  |         ]; | 
					
						
							| 
									
										
										
										
											2018-02-18 16:35:26 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-16 16:43:00 +01:00
										 |  |  |         return $data; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							| 
									
										
										
										
											2018-07-06 07:15:42 +02:00
										 |  |  |      * The rules that the incoming request must be matched against. | 
					
						
							|  |  |  |      * | 
					
						
							| 
									
										
										
										
											2018-02-16 16:43:00 +01:00
										 |  |  |      * @return array | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     public function rules(): array | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2018-02-21 08:51:30 +01:00
										 |  |  |         $rules = [ | 
					
						
							| 
									
										
										
										
											2019-03-31 13:36:49 +02:00
										 |  |  |             // basic fields for group:
 | 
					
						
							| 
									
										
										
										
											2019-10-13 11:50:04 +02:00
										 |  |  |             'group_title'                          => 'between:1,1000|nullable', | 
					
						
							| 
									
										
										
										
											2018-12-21 09:01:21 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-16 16:43:00 +01:00
										 |  |  |             // transaction rules (in array for splits):
 | 
					
						
							| 
									
										
										
										
											2019-03-31 13:36:49 +02:00
										 |  |  |             'transactions.*.type'                  => 'required|in:withdrawal,deposit,transfer,opening-balance,reconciliation', | 
					
						
							|  |  |  |             'transactions.*.date'                  => ['required', new IsDateOrTime], | 
					
						
							| 
									
										
										
										
											2019-04-06 08:10:50 +02:00
										 |  |  |             'transactions.*.order'                 => 'numeric|min:0', | 
					
						
							| 
									
										
										
										
											2019-03-31 13:36:49 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |             // currency info
 | 
					
						
							| 
									
										
										
										
											2019-10-13 11:50:04 +02:00
										 |  |  |             'transactions.*.currency_id'           => 'numeric|exists:transaction_currencies,id|nullable', | 
					
						
							|  |  |  |             'transactions.*.currency_code'         => 'min:3|max:3|exists:transaction_currencies,code|nullable', | 
					
						
							|  |  |  |             'transactions.*.foreign_currency_id'   => 'numeric|exists:transaction_currencies,id|nullable', | 
					
						
							|  |  |  |             'transactions.*.foreign_currency_code' => 'min:3|max:3|exists:transaction_currencies,code|nullable', | 
					
						
							| 
									
										
										
										
											2019-03-31 13:36:49 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |             // amount
 | 
					
						
							|  |  |  |             'transactions.*.amount'                => 'required|numeric|more:0', | 
					
						
							|  |  |  |             'transactions.*.foreign_amount'        => 'numeric|more:0', | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             // description
 | 
					
						
							| 
									
										
										
										
											2019-09-21 07:33:13 +02:00
										 |  |  |             'transactions.*.description'           => 'nullable|between:1,1000', | 
					
						
							| 
									
										
										
										
											2019-03-31 13:36:49 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |             // source of transaction
 | 
					
						
							|  |  |  |             'transactions.*.source_id'             => ['numeric', 'nullable', new BelongsUser], | 
					
						
							|  |  |  |             'transactions.*.source_name'           => 'between:1,255|nullable', | 
					
						
							| 
									
										
										
										
											2019-10-13 11:50:04 +02:00
										 |  |  |             'transactions.*.source_iban'           => 'between:1,255|nullable|iban', | 
					
						
							|  |  |  |             'transactions.*.source_number'         => 'between:1,255|nullable', | 
					
						
							|  |  |  |             'transactions.*.source_bic'            => 'between:1,255|nullable|bic', | 
					
						
							| 
									
										
										
										
											2019-03-31 13:36:49 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |             // destination of transaction
 | 
					
						
							|  |  |  |             'transactions.*.destination_id'        => ['numeric', 'nullable', new BelongsUser], | 
					
						
							|  |  |  |             'transactions.*.destination_name'      => 'between:1,255|nullable', | 
					
						
							| 
									
										
										
										
											2019-10-13 11:50:04 +02:00
										 |  |  |             'transactions.*.destination_iban'      => 'between:1,255|nullable|iban', | 
					
						
							|  |  |  |             'transactions.*.destination_number'    => 'between:1,255|nullable', | 
					
						
							|  |  |  |             'transactions.*.destination_bic'       => 'between:1,255|nullable|bic', | 
					
						
							| 
									
										
										
										
											2019-03-31 13:36:49 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |             // budget, category, bill and piggy
 | 
					
						
							| 
									
										
										
										
											2018-02-18 10:31:15 +01:00
										 |  |  |             'transactions.*.budget_id'             => ['mustExist:budgets,id', new BelongsUser], | 
					
						
							|  |  |  |             'transactions.*.budget_name'           => ['between:1,255', 'nullable', new BelongsUser], | 
					
						
							|  |  |  |             'transactions.*.category_id'           => ['mustExist:categories,id', new BelongsUser], | 
					
						
							|  |  |  |             'transactions.*.category_name'         => 'between:1,255|nullable', | 
					
						
							| 
									
										
										
										
											2019-03-31 13:36:49 +02:00
										 |  |  |             'transactions.*.bill_id'               => ['numeric', 'nullable', 'mustExist:bills,id', new BelongsUser], | 
					
						
							|  |  |  |             'transactions.*.bill_name'             => ['between:1,255', 'nullable', new BelongsUser], | 
					
						
							|  |  |  |             'transactions.*.piggy_bank_id'         => ['numeric', 'nullable', 'mustExist:piggy_banks,id', new BelongsUser], | 
					
						
							|  |  |  |             'transactions.*.piggy_bank_name'       => ['between:1,255', 'nullable', new BelongsUser], | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             // other interesting fields
 | 
					
						
							| 
									
										
										
										
											2018-12-03 15:57:15 +01:00
										 |  |  |             'transactions.*.reconciled'            => [new IsBoolean], | 
					
						
							| 
									
										
										
										
											2019-03-31 13:36:49 +02:00
										 |  |  |             'transactions.*.notes'                 => 'min:1,max:50000|nullable', | 
					
						
							| 
									
										
										
										
											2019-09-20 17:57:35 +02:00
										 |  |  |             'transactions.*.tags'                  => 'between:0,255', | 
					
						
							| 
									
										
										
										
											2019-03-31 13:36:49 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |             // meta info fields
 | 
					
						
							|  |  |  |             'transactions.*.internal_reference'    => 'min:1,max:255|nullable', | 
					
						
							|  |  |  |             'transactions.*.external_id'           => 'min:1,max:255|nullable', | 
					
						
							|  |  |  |             'transactions.*.recurrence_id'         => 'min:1,max:255|nullable', | 
					
						
							|  |  |  |             'transactions.*.bunq_payment_id'       => 'min:1,max:255|nullable', | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             // SEPA fields:
 | 
					
						
							|  |  |  |             'transactions.*.sepa_cc'               => 'min:1,max:255|nullable', | 
					
						
							|  |  |  |             'transactions.*.sepa_ct_op'            => 'min:1,max:255|nullable', | 
					
						
							|  |  |  |             'transactions.*.sepa_ct_id'            => 'min:1,max:255|nullable', | 
					
						
							|  |  |  |             'transactions.*.sepa_db'               => 'min:1,max:255|nullable', | 
					
						
							|  |  |  |             'transactions.*.sepa_country'          => 'min:1,max:255|nullable', | 
					
						
							|  |  |  |             'transactions.*.sepa_ep'               => 'min:1,max:255|nullable', | 
					
						
							|  |  |  |             'transactions.*.sepa_ci'               => 'min:1,max:255|nullable', | 
					
						
							|  |  |  |             'transactions.*.sepa_batch_id'         => 'min:1,max:255|nullable', | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             // dates
 | 
					
						
							|  |  |  |             'transactions.*.interest_date'         => 'date|nullable', | 
					
						
							|  |  |  |             'transactions.*.book_date'             => 'date|nullable', | 
					
						
							|  |  |  |             'transactions.*.process_date'          => 'date|nullable', | 
					
						
							|  |  |  |             'transactions.*.due_date'              => 'date|nullable', | 
					
						
							|  |  |  |             'transactions.*.payment_date'          => 'date|nullable', | 
					
						
							|  |  |  |             'transactions.*.invoice_date'          => 'date|nullable', | 
					
						
							| 
									
										
										
										
											2018-02-16 16:43:00 +01:00
										 |  |  |         ]; | 
					
						
							| 
									
										
										
										
											2018-02-21 08:51:30 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |         return $rules; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-16 16:43:00 +01:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * Configure the validator instance. | 
					
						
							|  |  |  |      * | 
					
						
							| 
									
										
										
										
											2019-04-06 08:10:50 +02:00
										 |  |  |      * @param Validator $validator | 
					
						
							| 
									
										
										
										
											2018-02-16 16:43:00 +01:00
										 |  |  |      * | 
					
						
							|  |  |  |      * @return void | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     public function withValidator(Validator $validator): void | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         $validator->after( | 
					
						
							|  |  |  |             function (Validator $validator) { | 
					
						
							| 
									
										
										
										
											2019-03-31 13:36:49 +02:00
										 |  |  |                 // must submit at least one transaction.
 | 
					
						
							| 
									
										
										
										
											2018-07-05 18:02:02 +02:00
										 |  |  |                 $this->validateOneTransaction($validator); | 
					
						
							| 
									
										
										
										
											2019-03-31 13:36:49 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |                 // all journals must have a description
 | 
					
						
							| 
									
										
										
										
											2018-07-05 18:02:02 +02:00
										 |  |  |                 $this->validateDescriptions($validator); | 
					
						
							| 
									
										
										
										
											2019-03-31 13:36:49 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-06 11:08:46 +02:00
										 |  |  |                 // all transaction types must be equal:
 | 
					
						
							|  |  |  |                 $this->validateTransactionTypes($validator); | 
					
						
							| 
									
										
										
										
											2019-03-31 13:36:49 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |                 // validate foreign currency info
 | 
					
						
							| 
									
										
										
										
											2018-07-05 18:02:02 +02:00
										 |  |  |                 $this->validateForeignCurrencyInformation($validator); | 
					
						
							| 
									
										
										
										
											2019-03-31 13:36:49 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |                 // validate all account info
 | 
					
						
							| 
									
										
										
										
											2018-02-16 16:43:00 +01:00
										 |  |  |                 $this->validateAccountInformation($validator); | 
					
						
							| 
									
										
										
										
											2019-03-31 13:36:49 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-06 11:08:46 +02:00
										 |  |  |                 // validate source/destination is equal, depending on the transaction journal type.
 | 
					
						
							|  |  |  |                 $this->validateEqualAccounts($validator); | 
					
						
							| 
									
										
										
										
											2019-03-31 13:36:49 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |                 // the group must have a description if > 1 journal.
 | 
					
						
							|  |  |  |                 $this->validateGroupDescription($validator); | 
					
						
							| 
									
										
										
										
											2019-04-06 08:10:50 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-16 16:43:00 +01:00
										 |  |  |             } | 
					
						
							|  |  |  |         ); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2019-06-09 08:26:23 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * Get transaction data. | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @return array | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     private function getTransactionData(): array | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         $return = []; | 
					
						
							|  |  |  |         /** | 
					
						
							| 
									
										
										
										
											2019-09-04 17:39:39 +02:00
										 |  |  |          * @var int   $index | 
					
						
							| 
									
										
										
										
											2019-06-09 08:26:23 +02:00
										 |  |  |          * @var array $transaction | 
					
						
							|  |  |  |          */ | 
					
						
							|  |  |  |         foreach ($this->get('transactions') as $index => $transaction) { | 
					
						
							|  |  |  |             $object   = new NullArrayObject($transaction); | 
					
						
							|  |  |  |             $return[] = [ | 
					
						
							|  |  |  |                 'type'  => $this->stringFromValue($object['type']), | 
					
						
							|  |  |  |                 'date'  => $this->dateFromValue($object['date']), | 
					
						
							|  |  |  |                 'order' => $this->integerFromValue((string)$object['order']), | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-13 11:50:04 +02:00
										 |  |  |                 'currency_id'           => $this->integerFromValue((string)$object['currency_id']), | 
					
						
							| 
									
										
										
										
											2019-06-09 08:26:23 +02:00
										 |  |  |                 'currency_code'         => $this->stringFromValue($object['currency_code']), | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 // foreign currency info:
 | 
					
						
							|  |  |  |                 'foreign_currency_id'   => $this->integerFromValue((string)$object['foreign_currency_id']), | 
					
						
							|  |  |  |                 'foreign_currency_code' => $this->stringFromValue($object['foreign_currency_code']), | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 // amount and foreign amount. Cannot be 0.
 | 
					
						
							|  |  |  |                 'amount'                => $this->stringFromValue((string)$object['amount']), | 
					
						
							|  |  |  |                 'foreign_amount'        => $this->stringFromValue((string)$object['foreign_amount']), | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 // description.
 | 
					
						
							|  |  |  |                 'description'           => $this->stringFromValue($object['description']), | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 // source of transaction. If everything is null, assume cash account.
 | 
					
						
							|  |  |  |                 'source_id'             => $this->integerFromValue((string)$object['source_id']), | 
					
						
							|  |  |  |                 'source_name'           => $this->stringFromValue($object['source_name']), | 
					
						
							| 
									
										
										
										
											2019-10-13 11:50:04 +02:00
										 |  |  |                 'source_iban'           => $this->stringFromValue($object['source_iban']), | 
					
						
							|  |  |  |                 'source_number'         => $this->stringFromValue($object['source_number']), | 
					
						
							|  |  |  |                 'source_bic'            => $this->stringFromValue($object['source_bic']), | 
					
						
							| 
									
										
										
										
											2019-06-09 08:26:23 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |                 // destination of transaction. If everything is null, assume cash account.
 | 
					
						
							|  |  |  |                 'destination_id'        => $this->integerFromValue((string)$object['destination_id']), | 
					
						
							|  |  |  |                 'destination_name'      => $this->stringFromValue($object['destination_name']), | 
					
						
							| 
									
										
										
										
											2019-10-13 11:50:04 +02:00
										 |  |  |                 'destination_iban'      => $this->stringFromValue($object['destination_iban']), | 
					
						
							|  |  |  |                 'destination_number'    => $this->stringFromValue($object['destination_number']), | 
					
						
							|  |  |  |                 'destination_bic'       => $this->stringFromValue($object['destination_bic']), | 
					
						
							| 
									
										
										
										
											2019-06-09 08:26:23 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |                 // budget info
 | 
					
						
							|  |  |  |                 'budget_id'             => $this->integerFromValue((string)$object['budget_id']), | 
					
						
							|  |  |  |                 'budget_name'           => $this->stringFromValue($object['budget_name']), | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 // category info
 | 
					
						
							|  |  |  |                 'category_id'           => $this->integerFromValue((string)$object['category_id']), | 
					
						
							|  |  |  |                 'category_name'         => $this->stringFromValue($object['category_name']), | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 // journal bill reference. Optional. Will only work for withdrawals
 | 
					
						
							|  |  |  |                 'bill_id'               => $this->integerFromValue((string)$object['bill_id']), | 
					
						
							|  |  |  |                 'bill_name'             => $this->stringFromValue($object['bill_name']), | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 // piggy bank reference. Optional. Will only work for transfers
 | 
					
						
							|  |  |  |                 'piggy_bank_id'         => $this->integerFromValue((string)$object['piggy_bank_id']), | 
					
						
							|  |  |  |                 'piggy_bank_name'       => $this->stringFromValue($object['piggy_bank_name']), | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 // some other interesting properties
 | 
					
						
							|  |  |  |                 'reconciled'            => $this->convertBoolean((string)$object['reconciled']), | 
					
						
							| 
									
										
										
										
											2019-09-22 17:36:18 +02:00
										 |  |  |                 'notes'                 => $this->nlStringFromValue($object['notes']), | 
					
						
							| 
									
										
										
										
											2019-06-09 08:26:23 +02:00
										 |  |  |                 'tags'                  => $this->arrayFromValue($object['tags']), | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 // all custom fields:
 | 
					
						
							|  |  |  |                 'internal_reference'    => $this->stringFromValue($object['internal_reference']), | 
					
						
							|  |  |  |                 'external_id'           => $this->stringFromValue($object['external_id']), | 
					
						
							|  |  |  |                 'original_source'       => sprintf('ff3-v%s|api-v%s', config('firefly.version'), config('firefly.api_version')), | 
					
						
							|  |  |  |                 'recurrence_id'         => $this->integerFromValue($object['recurrence_id']), | 
					
						
							|  |  |  |                 'bunq_payment_id'       => $this->stringFromValue($object['bunq_payment_id']), | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 'sepa_cc'       => $this->stringFromValue($object['sepa_cc']), | 
					
						
							|  |  |  |                 'sepa_ct_op'    => $this->stringFromValue($object['sepa_ct_op']), | 
					
						
							|  |  |  |                 'sepa_ct_id'    => $this->stringFromValue($object['sepa_ct_id']), | 
					
						
							|  |  |  |                 'sepa_db'       => $this->stringFromValue($object['sepa_db']), | 
					
						
							|  |  |  |                 'sepa_country'  => $this->stringFromValue($object['sepa_country']), | 
					
						
							|  |  |  |                 'sepa_ep'       => $this->stringFromValue($object['sepa_ep']), | 
					
						
							|  |  |  |                 'sepa_ci'       => $this->stringFromValue($object['sepa_ci']), | 
					
						
							|  |  |  |                 'sepa_batch_id' => $this->stringFromValue($object['sepa_batch_id']), | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 // custom date fields. Must be Carbon objects. Presence is optional.
 | 
					
						
							|  |  |  |                 'interest_date' => $this->dateFromValue($object['interest_date']), | 
					
						
							|  |  |  |                 'book_date'     => $this->dateFromValue($object['book_date']), | 
					
						
							|  |  |  |                 'process_date'  => $this->dateFromValue($object['process_date']), | 
					
						
							|  |  |  |                 'due_date'      => $this->dateFromValue($object['due_date']), | 
					
						
							|  |  |  |                 'payment_date'  => $this->dateFromValue($object['payment_date']), | 
					
						
							|  |  |  |                 'invoice_date'  => $this->dateFromValue($object['invoice_date']), | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             ]; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         return $return; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2018-03-05 19:35:58 +01:00
										 |  |  | } |