From 7707c81b2dabda66ed2ffb2c433291aeafac6edd Mon Sep 17 00:00:00 2001 From: James Cole Date: Fri, 29 Jul 2016 21:29:46 +0200 Subject: [PATCH] Each CSV converter can set the certainty of their conversion. --- app/Import/Converter/AccountId.php | 8 ++++++++ app/Import/Converter/BasicConverter.php | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/app/Import/Converter/AccountId.php b/app/Import/Converter/AccountId.php index 5ba5e19d61..221f5e4c84 100644 --- a/app/Import/Converter/AccountId.php +++ b/app/Import/Converter/AccountId.php @@ -34,6 +34,8 @@ class AccountId extends BasicConverter implements ConverterInterface Log::debug('Going to convert using AssetAccountId', ['value' => $value]); if ($value === 0) { + $this->setCertainty(0); + return new Account; } @@ -47,6 +49,8 @@ class AccountId extends BasicConverter implements ConverterInterface if (!is_null($account->id)) { Log::debug('Found account by ID', ['id' => $account->id]); + $this->setCertainty(100); + return $account; } } @@ -54,11 +58,15 @@ class AccountId extends BasicConverter implements ConverterInterface // not mapped? Still try to find it first: $account = $repository->find($value); if (!is_null($account->id)) { + $this->setCertainty(90); + Log::debug('Found account by ID ', ['id' => $account->id]); return $account; } + $this->setCertainty(0); + // should not really happen. If the ID does not match FF, what is FF supposed to do? return new Account; diff --git a/app/Import/Converter/BasicConverter.php b/app/Import/Converter/BasicConverter.php index f160d0e4fa..d93590c81c 100644 --- a/app/Import/Converter/BasicConverter.php +++ b/app/Import/Converter/BasicConverter.php @@ -40,6 +40,14 @@ class BasicConverter return $this->certainty; } + /** + * @param int $certainty + */ + protected function setCertainty(int $certainty) + { + $this->certainty = $certainty; + } + /** * @param array $config */