Skip to content

Firefly III: a personal finances manager

Extend ImportObject with row hash.

James Cole117bb602dc50
diff --git a/app/Import/ImportEntry.php b/app/Import/ImportEntry.php
index 759263171e..931079fc55 100644
--- a/app/Import/ImportEntry.php
+++ b/app/Import/ImportEntry.php
@@ -32,6 +32,8 @@ class ImportEntry
public $externalID;
/** @var array */
public $fields = [];
+ /** @var string */
+ public $hash;
/** @var User */
public $user;
/** @var bool */
@@ -77,6 +79,10 @@ class ImportEntry
default:
Log::error('Import entry cannot handle object.', ['role' => $role]);
throw new FireflyException('Import entry cannot handle object of type "' . $role . '".');
+ case 'hash':
+ $this->hash = $convertedValue;
+
+ return;
case 'amount':
/*
* Easy enough.
diff --git a/app/Import/Importer/CsvImporter.php b/app/Import/Importer/CsvImporter.php
index 9732bb24fa..970529caa0 100644
--- a/app/Import/Importer/CsvImporter.php
+++ b/app/Import/Importer/CsvImporter.php
@@ -100,6 +100,10 @@ class CsvImporter implements ImporterInterface
$object->setUser($this->job->user);
$config = $this->job->configuration;
+ // hash the row:
+ $hash = hash('sha256', json_encode($row));
+ $object->importValue('hash', 100, $hash);
+
// and this is the point where the specifix go to work.
foreach ($config['specifics'] as $name => $enabled) {
/** @var SpecificInterface $specific */