Skip to content

Firefly III: a personal finances manager

Fix broken duplication test routine.

James Coleb09504d0f79e
diff --git a/app/Factory/TransactionJournalFactory.php b/app/Factory/TransactionJournalFactory.php
index dcbb85111d..76c382c9cc 100644
--- a/app/Factory/TransactionJournalFactory.php
+++ b/app/Factory/TransactionJournalFactory.php
@@ -384,13 +384,14 @@ class TransactionJournalFactory
*/
private function hashArray(NullArrayObject $row): string
{
- $row['import_hash_v2'] = null;
- $row['original_source'] = null;
- $json = json_encode($row);
+ $dataRow = $row->getArrayCopy();
+
+ unset($dataRow['import_hash_v2'], $dataRow['original_source']);
+ $json = json_encode($dataRow);
if (false === $json) {
// @codeCoverageIgnoreStart
$json = json_encode((string)microtime());
- Log::error(sprintf('Could not hash the original row! %s', json_last_error_msg()), $row->getArrayCopy());
+ Log::error(sprintf('Could not hash the original row! %s', json_last_error_msg()), $dataRow);
// @codeCoverageIgnoreEnd
}
$hash = hash('sha256', $json);
diff --git a/app/Import/Storage/ImportArrayStorage.php b/app/Import/Storage/ImportArrayStorage.php
index 6eb084657b..4963d35039 100644
--- a/app/Import/Storage/ImportArrayStorage.php
+++ b/app/Import/Storage/ImportArrayStorage.php
@@ -234,19 +234,21 @@ class ImportArrayStorage
private function storeGroup(int $index, array $group): ?TransactionGroup
{
- // do duplicate detection!
- if ($this->duplicateDetected($index, $group)) {
- Log::warning(sprintf('Row #%d seems to be a imported already and will be ignored.', $index));
- return null;
- }
Log::debug(sprintf('Going to store entry #%d', $index + 1));
// do some basic error catching.
- foreach ($group['transactions'] as $index => $transaction) {
- $group['transactions'][$index]['date'] = Carbon::parse($transaction['date'], config('app.timezone'));
- $group['transactions'][$index]['description'] = '' === $transaction['description'] ? '(empty description)' : $transaction['description'];
+ foreach ($group['transactions'] as $groupIndex => $transaction) {
+ $group['transactions'][$groupIndex]['date'] = Carbon::parse($transaction['date'], config('app.timezone'));
+ $group['transactions'][$groupIndex]['description'] = '' === $transaction['description'] ? '(empty description)' : $transaction['description'];
+ }
+
+ // do duplicate detection!
+ if ($this->duplicateDetected($index, $group)) {
+ Log::warning(sprintf('Row #%d seems to be a imported already and will be ignored.', $index));
+
+ return null;
}
// store the group