Skip to content

Firefly III: a personal finances manager

Each CSV converter can set the certainty of their conversion.

James Cole7707c81b2dab
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
*/