From c99e23302659a2da81176d346928c86918c5cfc1 Mon Sep 17 00:00:00 2001 From: James Cole Date: Mon, 9 Jul 2018 20:42:16 +0200 Subject: [PATCH] Add some debug entries. --- app/Import/Routine/FileRoutine.php | 2 +- app/Providers/EventServiceProvider.php | 2 +- app/Support/Import/Placeholder/ImportTransaction.php | 8 ++++++-- app/Support/Import/Routine/File/MappingConverger.php | 10 ++++++++-- 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/app/Import/Routine/FileRoutine.php b/app/Import/Routine/FileRoutine.php index db228ac494..e88fe64456 100644 --- a/app/Import/Routine/FileRoutine.php +++ b/app/Import/Routine/FileRoutine.php @@ -48,7 +48,7 @@ class FileRoutine implements RoutineInterface public function run(): void { Log::debug(sprintf('Now in run() for file routine with status: %s', $this->importJob->status)); - if ($this->importJob->status === 'ready_to_run') { + if ('ready_to_run' === $this->importJob->status) { $this->repository->setStatus($this->importJob, 'running'); // get processor, depending on file type // is just CSV for now. diff --git a/app/Providers/EventServiceProvider.php b/app/Providers/EventServiceProvider.php index 2ffb23d88b..ed5c39efca 100644 --- a/app/Providers/EventServiceProvider.php +++ b/app/Providers/EventServiceProvider.php @@ -135,7 +135,7 @@ class EventServiceProvider extends ServiceProvider $repository = app(UserRepositoryInterface::class); $user = $repository->findNull((int)$oauthClient->user_id); if (null === $user) { - Log::error('OAuth client generated but no user associated.'); + Log::info('OAuth client generated but no user associated.'); return; } diff --git a/app/Support/Import/Placeholder/ImportTransaction.php b/app/Support/Import/Placeholder/ImportTransaction.php index bdda187930..ccc64a7a57 100644 --- a/app/Support/Import/Placeholder/ImportTransaction.php +++ b/app/Support/Import/Placeholder/ImportTransaction.php @@ -139,8 +139,10 @@ class ImportTransaction ); // @codeCoverageIgnoreEnd case 'account-id': + $mappedValue = $this->getMappedValue($columnValue); // could be the result of a mapping? - $this->accountId = $this->getMappedValue($columnValue); + $this->accountId = $mappedValue; + Log::debug(sprintf('Going to set the account-id. Original value is "%s", mapped value is "%s".', $columnValue->getValue(), $mappedValue)); break; case 'account-iban': $this->accountIban = $columnValue->getValue(); @@ -233,7 +235,9 @@ class ImportTransaction $this->note = trim($this->note . ' ' . $columnValue->getValue()); break; case 'opposing-id': - $this->opposingId = $this->getMappedValue($columnValue); + $mappedValue = $this->getMappedValue($columnValue); + $this->opposingId = $mappedValue; + Log::debug(sprintf('Going to set the OPPOSING-id. Original value is "%s", mapped value is "%s".', $columnValue->getValue(), $mappedValue)); break; case 'opposing-iban': $this->opposingIban = $columnValue->getValue(); diff --git a/app/Support/Import/Routine/File/MappingConverger.php b/app/Support/Import/Routine/File/MappingConverger.php index 08fd612526..a6d161041a 100644 --- a/app/Support/Import/Routine/File/MappingConverger.php +++ b/app/Support/Import/Routine/File/MappingConverger.php @@ -121,12 +121,17 @@ class MappingConverger private function getRoleForColumn(int $column, int $mapped): string { $role = $this->roles[$column] ?? '_ignore'; - if ($mapped === 0) { + if (0 === $mapped) { Log::debug(sprintf('Column #%d with role "%s" is not mapped.', $column, $role)); return $role; } - if (!(isset($this->doMapping[$column]) && $this->doMapping[$column] === true)) { + if (!(isset($this->doMapping[$column]) && true === $this->doMapping[$column])) { + + // if the mapping has been filled in already by a role with a higher priority, + // ignore the mapping. + Log::debug(sprintf('Column #%d ("%s") has something.', $column, $role)); + return $role; } @@ -172,6 +177,7 @@ class MappingConverger // also store the $mapped values in a "mappedValues" array. $this->mappedValues[$newRole][] = $mapped; + Log::debug(sprintf('Values mapped to role "%s" are: ', $newRole), $this->mappedValues[$newRole]); return $newRole; }