$value]); if (strlen($value) === 0) { $value = '(empty account name)'; } /** @var AccountCrudInterface $repository */ $repository = app(AccountCrudInterface::class, [$this->user]); if (isset($this->mapping[$value])) { Log::debug('Found account in mapping. Should exist.', ['value' => $value, 'map' => $this->mapping[$value]]); $account = $repository->find(intval($this->mapping[$value])); if (!is_null($account->id)) { Log::debug('Found account by ID', ['id' => $account->id]); $this->setCertainty(100); return $account; } } // not mapped? Still try to find it first: $account = $repository->findByName($value, []); if (!is_null($account->id)) { Log::debug('Found account by name', ['id' => $account->id]); Log::warning( 'The match between name and account is uncertain because the type of transactions may not have been determined.', ['id' => $account->id, 'name' => $value] ); $this->setCertainty(50); return $account; } $account = $repository->store( ['name' => $value, 'iban' => null, 'user' => $this->user->id, 'accountType' => 'import', 'virtualBalance' => 0, 'active' => true, 'openingBalance' => 0, ] ); $this->setCertainty(100); return $account; } }