mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-22 20:16:22 +00:00
Better reporting for double imported rows. See also #164
This commit is contained in:
@@ -85,14 +85,17 @@ class ImportStorage
|
|||||||
/**
|
/**
|
||||||
* @param string $hash
|
* @param string $hash
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return TransactionJournal
|
||||||
*/
|
*/
|
||||||
private function alreadyImported(string $hash): bool
|
private function alreadyImported(string $hash): TransactionJournal
|
||||||
{
|
{
|
||||||
|
|
||||||
$count = TransactionJournalMeta::where('name', 'originalImportHash')->where('data', json_encode($hash))->count();
|
$meta = TransactionJournalMeta::where('name', 'originalImportHash')->where('data', json_encode($hash))->first(['journal_meta.*']);
|
||||||
|
if (!is_null($meta)) {
|
||||||
|
return $meta->transactionjournal;
|
||||||
|
}
|
||||||
|
|
||||||
return $count > 0;
|
return new TransactionJournal;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -252,12 +255,15 @@ class ImportStorage
|
|||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
$alreadyImported = $this->alreadyImported($entry->hash);
|
||||||
if ($this->alreadyImported($entry->hash)) {
|
if (!is_null($alreadyImported->id)) {
|
||||||
Log::warning(sprintf('Cannot import row %d, because it has already been imported.', $index));
|
Log::warning(sprintf('Cannot import row %d, because it has already been imported (journal #%d).', $index, $alreadyImported->id));
|
||||||
$result = new ImportResult();
|
$result = new ImportResult();
|
||||||
$result->failed();
|
$result->failed();
|
||||||
$errorText = sprintf('Row #%d: This row has been imported before.', $index);
|
$errorText = trans(
|
||||||
|
'firefly.import_double',
|
||||||
|
['row' => $index, 'link' => route('transactions.show', [$alreadyImported->id]), 'description' => $alreadyImported->description]
|
||||||
|
);
|
||||||
$result->appendError($errorText);
|
$result->appendError($errorText);
|
||||||
$extendedStatus = $this->job->extended_status;
|
$extendedStatus = $this->job->extended_status;
|
||||||
$extendedStatus['errors'][] = $errorText;
|
$extendedStatus['errors'][] = $errorText;
|
||||||
|
@@ -71,7 +71,7 @@ function reportErrors(data) {
|
|||||||
// fill the list with error texts
|
// fill the list with error texts
|
||||||
$('#import-status-error-list').empty();
|
$('#import-status-error-list').empty();
|
||||||
for (var i = 0; i < data.errors.length; i++) {
|
for (var i = 0; i < data.errors.length; i++) {
|
||||||
var item = $('<li>').text(data.errors[i]);
|
var item = $('<li>').html(data.errors[i]);
|
||||||
$('#import-status-error-list').append(item);
|
$('#import-status-error-list').append(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -790,4 +790,5 @@ return [
|
|||||||
'import_error_multi' => 'Some errors occured during the import.',
|
'import_error_multi' => 'Some errors occured during the import.',
|
||||||
'import_error_fatal' => 'There was an error during the import routine. Please check the log files. The error seems to be:',
|
'import_error_fatal' => 'There was an error during the import routine. Please check the log files. The error seems to be:',
|
||||||
'import_error_timeout' => 'The import seems to have timed out. If this error persists, please import your data using the console command.',
|
'import_error_timeout' => 'The import seems to have timed out. If this error persists, please import your data using the console command.',
|
||||||
|
'import_double' => 'Row #:row: This row has been imported before, and is stored in <a href=":link">:description</a>.',
|
||||||
];
|
];
|
||||||
|
Reference in New Issue
Block a user