mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2024-12-27 17:31:09 -06:00
Better reporting for double imported rows. See also #164
This commit is contained in:
parent
da5e48d769
commit
106665a468
@ -85,14 +85,17 @@ class ImportStorage
|
||||
/**
|
||||
* @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;
|
||||
}
|
||||
|
||||
if ($this->alreadyImported($entry->hash)) {
|
||||
Log::warning(sprintf('Cannot import row %d, because it has already been imported.', $index));
|
||||
$alreadyImported = $this->alreadyImported($entry->hash);
|
||||
if (!is_null($alreadyImported->id)) {
|
||||
Log::warning(sprintf('Cannot import row %d, because it has already been imported (journal #%d).', $index, $alreadyImported->id));
|
||||
$result = new ImportResult();
|
||||
$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);
|
||||
$extendedStatus = $this->job->extended_status;
|
||||
$extendedStatus['errors'][] = $errorText;
|
||||
|
@ -71,7 +71,7 @@ function reportErrors(data) {
|
||||
// fill the list with error texts
|
||||
$('#import-status-error-list').empty();
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -790,4 +790,5 @@ return [
|
||||
'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_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>.',
|
||||
];
|
||||
|
Loading…
Reference in New Issue
Block a user