From 117bb602dc506d51c51192a08e43296523eee0f7 Mon Sep 17 00:00:00 2001 From: James Cole Date: Sun, 14 Aug 2016 08:34:51 +0200 Subject: [PATCH] Extend ImportObject with row hash. --- app/Import/ImportEntry.php | 6 ++++++ app/Import/Importer/CsvImporter.php | 4 ++++ 2 files changed, 10 insertions(+) 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 */