@@ -68,7 +68,7 @@ |
||
68 | 68 | return 1; |
69 | 69 | } |
70 | 70 | |
71 | - $this->directory = (string) ($this->argument('directory') ?? './'); |
|
71 | + $this->directory = (string)($this->argument('directory') ?? './'); |
|
72 | 72 | $this->line(sprintf('Going to automatically import everything found in %s', $this->directory)); |
73 | 73 | |
74 | 74 | $files = $this->getFiles(); |
@@ -73,33 +73,33 @@ |
||
73 | 73 | { |
74 | 74 | Log::debug(sprintf('Now at the start of processAmount("%s")', $transaction['amount'])); |
75 | 75 | $amount = null; |
76 | - if (null === $amount && $this->validAmount((string) $transaction['amount'])) { |
|
76 | + if (null === $amount && $this->validAmount((string)$transaction['amount'])) { |
|
77 | 77 | Log::debug('Transaction["amount"] value is not NULL, assume this is the correct value.'); |
78 | 78 | $amount = $transaction['amount']; |
79 | 79 | } |
80 | 80 | |
81 | - if (null === $amount && $this->validAmount((string) $transaction['amount_debit'])) { |
|
81 | + if (null === $amount && $this->validAmount((string)$transaction['amount_debit'])) { |
|
82 | 82 | Log::debug(sprintf('Transaction["amount_debit"] value is not NULL ("%s"), assume this is the correct value.', $transaction['amount_debit'])); |
83 | 83 | $amount = $transaction['amount_debit']; |
84 | 84 | } |
85 | 85 | |
86 | - if (null === $amount && $this->validAmount((string) $transaction['amount_credit'])) { |
|
86 | + if (null === $amount && $this->validAmount((string)$transaction['amount_credit'])) { |
|
87 | 87 | Log::debug(sprintf('Transaction["amount_credit"] value is not NULL ("%s"), assume this is the correct value.', $transaction['amount_credit'])); |
88 | 88 | $amount = $transaction['amount_credit']; |
89 | 89 | } |
90 | 90 | |
91 | - if (null === $amount && $this->validAmount((string) $transaction['amount_negated'])) { |
|
91 | + if (null === $amount && $this->validAmount((string)$transaction['amount_negated'])) { |
|
92 | 92 | Log::debug(sprintf('Transaction["amount_negated"] value is not NULL ("%s"), assume this is the correct value.', $transaction['amount_negated'])); |
93 | 93 | $amount = $transaction['amount_negated']; |
94 | 94 | } |
95 | 95 | |
96 | 96 | if (array_key_exists('amount_modifier', $transaction)) { |
97 | - $transaction['amount_modifier'] = (string) $transaction['amount_modifier']; |
|
97 | + $transaction['amount_modifier'] = (string)$transaction['amount_modifier']; |
|
98 | 98 | } |
99 | 99 | if (array_key_exists('foreign_amount', $transaction)) { |
100 | - $transaction['foreign_amount'] = (string) $transaction['foreign_amount']; |
|
100 | + $transaction['foreign_amount'] = (string)$transaction['foreign_amount']; |
|
101 | 101 | } |
102 | - $amount = (string) $amount; |
|
102 | + $amount = (string)$amount; |
|
103 | 103 | if ('' === $amount) { |
104 | 104 | Log::error('Amount is EMPTY. This will give problems further ahead.', $transaction); |
105 | 105 |
@@ -41,8 +41,8 @@ |
||
41 | 41 | */ |
42 | 42 | public function build() |
43 | 43 | { |
44 | - $address = (string) config('mail.from.address'); |
|
45 | - $name = (string) config('mail.from.name'); |
|
44 | + $address = (string)config('mail.from.address'); |
|
45 | + $name = (string)config('mail.from.name'); |
|
46 | 46 | |
47 | 47 | return $this->from($address, $name)->markdown('emails.import.finished'); |
48 | 48 | } |
@@ -118,16 +118,16 @@ |
||
118 | 118 | |
119 | 119 | if ('withdrawal' === $transaction['type']) { |
120 | 120 | $destName = $transaction['destination_name'] ?? ''; |
121 | - $destId = (int) ($transaction['destination_id'] ?? 0); |
|
121 | + $destId = (int)($transaction['destination_id'] ?? 0); |
|
122 | 122 | $destIban = $transaction['destination_iban'] ?? ''; |
123 | - if ('' === $destName && 0 === $destId && ''=== $destIban) { |
|
123 | + if ('' === $destName && 0 === $destId && '' === $destIban) { |
|
124 | 124 | Log::debug('Destination name + ID + IBAN of withdrawal are empty, set to "(no name)".'); |
125 | 125 | $transaction['destination_name'] = '(no name)'; |
126 | 126 | } |
127 | 127 | } |
128 | 128 | if ('deposit' === $transaction['type']) { |
129 | 129 | $sourceName = $transaction['source_name'] ?? ''; |
130 | - $sourceId = (int) ($transaction['source_id'] ?? 0); |
|
130 | + $sourceId = (int)($transaction['source_id'] ?? 0); |
|
131 | 131 | $sourceIban = $transaction['source_iban'] ?? ''; |
132 | 132 | if ('' === $sourceName && 0 === $sourceId && '' === $sourceIban) { |
133 | 133 | Log::debug('Source name + IBAN + ID of deposit are empty, set to "(no name)".'); |
@@ -50,7 +50,7 @@ |
||
50 | 50 | try { |
51 | 51 | $array = json_decode($disk->get($identifier), true, 512, JSON_THROW_ON_ERROR); |
52 | 52 | $status = ImportJobStatus::fromArray($array); |
53 | - } catch (FileNotFoundException|JsonException $e) { |
|
53 | + } catch (FileNotFoundException | JsonException $e) { |
|
54 | 54 | Log::error($e->getMessage()); |
55 | 55 | $status = new ImportJobStatus; |
56 | 56 | } |
@@ -81,12 +81,12 @@ discard block |
||
81 | 81 | case 'VZ': // Verzamelbetaling |
82 | 82 | case 'IC': // Incasso |
83 | 83 | case 'DV': // Divers |
84 | - $this->removeIBANIngDescription(); // Remove "IBAN:", because it is already at "Tegenrekening" |
|
85 | - $this->removeNameIngDescription(); // Remove "Naam:", because it is already at "Naam/ Omschrijving" |
|
86 | - $this->removeIngDescription(); // Remove "Omschrijving", but not the value from description |
|
84 | + $this->removeIBANIngDescription(); // Remove "IBAN:", because it is already at "Tegenrekening" |
|
85 | + $this->removeNameIngDescription(); // Remove "Naam:", because it is already at "Naam/ Omschrijving" |
|
86 | + $this->removeIngDescription(); // Remove "Omschrijving", but not the value from description |
|
87 | 87 | $this->moveValutadatumDescription(); // Move "Valutadatum" from description to new column |
88 | - $this->MoveSavingsAccount(); // Move savings account number and name |
|
89 | - $this->moveDatumTijdValue(); // Move datum + tijd |
|
88 | + $this->MoveSavingsAccount(); // Move savings account number and name |
|
89 | + $this->moveDatumTijdValue(); // Move datum + tijd |
|
90 | 90 | break; |
91 | 91 | case 'BA': // Betaalautomaat |
92 | 92 | $this->moveValutadatumDescription(); // Move "Valutadatum" from description to new column |
@@ -171,19 +171,19 @@ discard block |
||
171 | 171 | |
172 | 172 | if (preg_match('/(Naar|Van) (.*rekening) ([A-Za-z0-9]+)/', $this->row[8], $matches)) { // Search for saving acount at 'Mededelingen' column |
173 | 173 | $this->row[1] .= ' ' . $matches[2] . ' ' . $matches[3]; // Current name + Saving acount name + Acount number |
174 | - if ('' === (string) $this->row[3]) { // if Saving account number does not yet exists |
|
174 | + if ('' === (string)$this->row[3]) { // if Saving account number does not yet exists |
|
175 | 175 | $this->row[3] = $matches[3]; // Copy savings account number |
176 | 176 | } |
177 | 177 | $this->row[8] = preg_replace('/(Naar|Van) (.*rekening) ([A-Za-z0-9]+)/', '', $this->row[8]); // Remove the savings account content from description |
178 | 178 | } elseif (preg_match('/(Naar|Van) (.*rekening) ([A-Za-z0-9]+)/', $this->row[1], $matches)) { // Search for saving acount at 'Naam / Omschrijving' column |
179 | - $this->row[1] = $matches[2] . ' ' . $matches[3]; // Saving acount name + Acount number |
|
180 | - if ('' === (string) $this->row[3]) { // if Saving account number does not yet exists |
|
179 | + $this->row[1] = $matches[2] . ' ' . $matches[3]; // Saving acount name + Acount number |
|
180 | + if ('' === (string)$this->row[3]) { // if Saving account number does not yet exists |
|
181 | 181 | $this->row[3] = $matches[3]; // Copy savings account number |
182 | 182 | } |
183 | 183 | } |
184 | 184 | |
185 | 185 | // if Saving account number exists |
186 | - if (('' !== (string) $this->row[3]) && !preg_match('/[A-Za-z]/', $this->row[3])) { // if Saving account number has no characters |
|
186 | + if (('' !== (string)$this->row[3]) && !preg_match('/[A-Za-z]/', $this->row[3])) { // if Saving account number has no characters |
|
187 | 187 | $this->row[3] = sprintf('%010d', $this->row[3]); // Make the number 10 digits |
188 | 188 | } |
189 | 189 | } |
@@ -62,7 +62,7 @@ |
||
62 | 62 | Log::debug(sprintf('Date converter is going to work on "%s" using format "%s"', $string, $this->dateFormat)); |
63 | 63 | try { |
64 | 64 | $carbon = Carbon::createFromFormat($this->dateFormat, $string); |
65 | - } catch (InvalidArgumentException|Exception $e) { |
|
65 | + } catch (InvalidArgumentException | Exception $e) { |
|
66 | 66 | Log::error(sprintf('%s converting the date: %s', get_class($e), $e->getMessage())); |
67 | 67 | |
68 | 68 | return Carbon::today()->startOfDay()->format('Y-m-d H:i:s'); |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | // if the ID is set, at least search for the ID. |
98 | 98 | if (is_int($array['id']) && $array['id'] > 0) { |
99 | 99 | Log::debug('Find by ID field.'); |
100 | - $result = $this->findById((string) $array['id']); |
|
100 | + $result = $this->findById((string)$array['id']); |
|
101 | 101 | } |
102 | 102 | if (null !== $result) { |
103 | 103 | $return = $result->toArray(); |
@@ -107,10 +107,10 @@ discard block |
||
107 | 107 | } |
108 | 108 | |
109 | 109 | // if the IBAN is set, search for the IBAN. |
110 | - if (isset($array['iban']) && '' !== (string) $array['iban']) { |
|
110 | + if (isset($array['iban']) && '' !== (string)$array['iban']) { |
|
111 | 111 | Log::debug('Find by IBAN.'); |
112 | - $transactionType = (string) ($array['transaction_type'] ?? null); |
|
113 | - $result = $this->findByIban((string) $array['iban'], $transactionType); |
|
112 | + $transactionType = (string)($array['transaction_type'] ?? null); |
|
113 | + $result = $this->findByIban((string)$array['iban'], $transactionType); |
|
114 | 114 | } |
115 | 115 | if (null !== $result) { |
116 | 116 | $return = $result->toArray(); |
@@ -120,9 +120,9 @@ discard block |
||
120 | 120 | } |
121 | 121 | |
122 | 122 | // find by name, return only if it's an asset or liability account. |
123 | - if (isset($array['name']) && '' !== (string) $array['name']) { |
|
123 | + if (isset($array['name']) && '' !== (string)$array['name']) { |
|
124 | 124 | Log::debug('Find by name.'); |
125 | - $result = $this->findByName((string) $array['name']); |
|
125 | + $result = $this->findByName((string)$array['name']); |
|
126 | 126 | } |
127 | 127 | if (null !== $result) { |
128 | 128 | $return = $result->toArray(); |
@@ -199,8 +199,8 @@ discard block |
||
199 | 199 | private function findById(string $value): ?Account |
200 | 200 | { |
201 | 201 | Log::debug(sprintf('Going to search account with ID "%s"', $value)); |
202 | - $uri = (string) config('csv_importer.uri'); |
|
203 | - $token = (string) config('csv_importer.access_token'); |
|
202 | + $uri = (string)config('csv_importer.uri'); |
|
203 | + $token = (string)config('csv_importer.access_token'); |
|
204 | 204 | $request = new GetSearchAccountRequest($uri, $token); |
205 | 205 | $request->setField('id'); |
206 | 206 | $request->setQuery($value); |
@@ -239,8 +239,8 @@ discard block |
||
239 | 239 | private function findByIban(string $iban, string $transactionType): ?Account |
240 | 240 | { |
241 | 241 | Log::debug(sprintf('Going to search account with IBAN "%s"', $iban)); |
242 | - $uri = (string) config('csv_importer.uri'); |
|
243 | - $token = (string) config('csv_importer.access_token'); |
|
242 | + $uri = (string)config('csv_importer.uri'); |
|
243 | + $token = (string)config('csv_importer.access_token'); |
|
244 | 244 | $request = new GetSearchAccountRequest($uri, $token); |
245 | 245 | $request->setField('iban'); |
246 | 246 | $request->setQuery($iban); |
@@ -285,8 +285,8 @@ discard block |
||
285 | 285 | private function findByName(string $name): ?Account |
286 | 286 | { |
287 | 287 | Log::debug(sprintf('Going to search account with name "%s"', $name)); |
288 | - $uri = (string) config('csv_importer.uri'); |
|
289 | - $token = (string) config('csv_importer.access_token'); |
|
288 | + $uri = (string)config('csv_importer.uri'); |
|
289 | + $token = (string)config('csv_importer.access_token'); |
|
290 | 290 | $request = new GetSearchAccountRequest($uri, $token); |
291 | 291 | $request->setField('name'); |
292 | 292 | $request->setQuery($name); |
@@ -381,7 +381,7 @@ discard block |
||
381 | 381 | $transaction = $this->setDestination($transaction, $destination); |
382 | 382 | $transaction['type'] = $this->determineType($source['type'], $destination['type']); |
383 | 383 | |
384 | - $amount = (string) $transaction['amount']; |
|
384 | + $amount = (string)$transaction['amount']; |
|
385 | 385 | $amount = '' === $amount ? '0' : $amount; |
386 | 386 | |
387 | 387 | if ('0' === $amount) { |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | return; |
99 | 99 | } |
100 | 100 | |
101 | - $groupId = (int) $groupInfo['group_id']; |
|
101 | + $groupId = (int)$groupInfo['group_id']; |
|
102 | 102 | Log::debug(sprintf('Going to add import tag to transaction group #%d', $groupId)); |
103 | 103 | $body = [ |
104 | 104 | 'transactions' => [], |
@@ -114,8 +114,8 @@ discard block |
||
114 | 114 | 'tags' => $currentTags, |
115 | 115 | ]; |
116 | 116 | } |
117 | - $uri = (string) config('csv_importer.uri'); |
|
118 | - $token = (string) config('csv_importer.access_token'); |
|
117 | + $uri = (string)config('csv_importer.uri'); |
|
118 | + $token = (string)config('csv_importer.access_token'); |
|
119 | 119 | $request = new PutTransactionRequest($uri, $token, $groupId); |
120 | 120 | $request->setBody($body); |
121 | 121 | $request->put(); |
@@ -168,8 +168,8 @@ discard block |
||
168 | 168 | |
169 | 169 | return; |
170 | 170 | } |
171 | - $uri = (string) config('csv_importer.uri'); |
|
172 | - $token = (string) config('csv_importer.access_token'); |
|
171 | + $uri = (string)config('csv_importer.uri'); |
|
172 | + $token = (string)config('csv_importer.access_token'); |
|
173 | 173 | $request = new PostTagRequest($uri, $token); |
174 | 174 | $body = [ |
175 | 175 | 'tag' => $this->tag, |
@@ -204,8 +204,8 @@ discard block |
||
204 | 204 | private function processTransaction(int $index, array $line): array |
205 | 205 | { |
206 | 206 | $return = []; |
207 | - $uri = (string) config('csv_importer.uri'); |
|
208 | - $token = (string) config('csv_importer.access_token'); |
|
207 | + $uri = (string)config('csv_importer.uri'); |
|
208 | + $token = (string)config('csv_importer.access_token'); |
|
209 | 209 | $request = new PostTransactionRequest($uri, $token); |
210 | 210 | Log::debug('Submitting to Firefly III:', $line); |
211 | 211 | $request->setBody($line); |
@@ -281,7 +281,7 @@ discard block |
||
281 | 281 | private function getOriginalValue(string $key, array $transaction): string |
282 | 282 | { |
283 | 283 | $parts = explode('.', $key); |
284 | - if(1 === count($parts)) { |
|
284 | + if (1 === count($parts)) { |
|
285 | 285 | return $transaction[$key] ?? '(not found)'; |
286 | 286 | } |
287 | 287 | if (3 !== count($parts)) { |