mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-01-07 06:33:57 -06:00
Better import feedback.
This commit is contained in:
parent
9c9fc2b5dc
commit
f15267c1ab
@ -12,6 +12,7 @@ use FireflyIII\Models\Account;
|
|||||||
use FireflyIII\Models\Transaction;
|
use FireflyIII\Models\Transaction;
|
||||||
use FireflyIII\Models\TransactionJournal;
|
use FireflyIII\Models\TransactionJournal;
|
||||||
use FireflyIII\Models\TransactionType;
|
use FireflyIII\Models\TransactionType;
|
||||||
|
use Illuminate\Support\Collection;
|
||||||
use Illuminate\Support\MessageBag;
|
use Illuminate\Support\MessageBag;
|
||||||
use Log;
|
use Log;
|
||||||
|
|
||||||
@ -44,6 +45,9 @@ class Importer
|
|||||||
/** @var array */
|
/** @var array */
|
||||||
protected $specifix = [];
|
protected $specifix = [];
|
||||||
|
|
||||||
|
/** @var Collection */
|
||||||
|
protected $journals;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used by CsvController.
|
* Used by CsvController.
|
||||||
*
|
*
|
||||||
@ -74,6 +78,15 @@ class Importer
|
|||||||
return $this->rows;
|
return $this->rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Collection
|
||||||
|
*/
|
||||||
|
public function getJournals()
|
||||||
|
{
|
||||||
|
return $this->journals;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws FireflyException
|
* @throws FireflyException
|
||||||
*/
|
*/
|
||||||
@ -81,6 +94,7 @@ class Importer
|
|||||||
{
|
{
|
||||||
set_time_limit(0);
|
set_time_limit(0);
|
||||||
|
|
||||||
|
$this->journals = new Collection;
|
||||||
$this->map = $this->data->getMap();
|
$this->map = $this->data->getMap();
|
||||||
$this->roles = $this->data->getRoles();
|
$this->roles = $this->data->getRoles();
|
||||||
$this->mapped = $this->data->getMapped();
|
$this->mapped = $this->data->getMapped();
|
||||||
@ -91,11 +105,12 @@ class Importer
|
|||||||
Log::debug('--- Importing row ' . $index);
|
Log::debug('--- Importing row ' . $index);
|
||||||
$this->rows++;
|
$this->rows++;
|
||||||
$result = $this->importRow($row);
|
$result = $this->importRow($row);
|
||||||
if (!($result === true)) {
|
if (!($result instanceof TransactionJournal)) {
|
||||||
Log::error('Caught error at row #' . $index . ': ' . $result);
|
Log::error('Caught error at row #' . $index . ': ' . $result);
|
||||||
$this->errors[$index] = $result;
|
$this->errors[$index] = $result;
|
||||||
} else {
|
} else {
|
||||||
$this->imported++;
|
$this->imported++;
|
||||||
|
$this->journals->push($result);
|
||||||
}
|
}
|
||||||
Log::debug('---');
|
Log::debug('---');
|
||||||
}
|
}
|
||||||
@ -151,9 +166,6 @@ class Importer
|
|||||||
return $result; // return error.
|
return $result; // return error.
|
||||||
}
|
}
|
||||||
$journal = $this->createTransactionJournal();
|
$journal = $this->createTransactionJournal();
|
||||||
if ($journal instanceof TransactionJournal) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $journal;
|
return $journal;
|
||||||
}
|
}
|
||||||
|
@ -302,12 +302,13 @@ class CsvController extends Controller
|
|||||||
$rows = $importer->getRows();
|
$rows = $importer->getRows();
|
||||||
$errors = $importer->getErrors();
|
$errors = $importer->getErrors();
|
||||||
$imported = $importer->getImported();
|
$imported = $importer->getImported();
|
||||||
|
$journals = $importer->getJournals();
|
||||||
|
|
||||||
Preferences::mark();
|
Preferences::mark();
|
||||||
|
|
||||||
$subTitle = trans('firefly.csv_process_title');
|
$subTitle = trans('firefly.csv_process_title');
|
||||||
|
|
||||||
return view('csv.process', compact('rows', 'errors', 'imported', 'subTitle'));
|
return view('csv.process', compact('rows', 'errors', 'imported', 'subTitle', 'journals'));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,6 +42,14 @@
|
|||||||
{{ trans('firefly.csv_process_new_entries',{imported: imported}) }}
|
{{ trans('firefly.csv_process_new_entries',{imported: imported}) }}
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
{% if journals|length > 0 %}
|
||||||
|
<ul>
|
||||||
|
{% for journal in journals %}
|
||||||
|
<li>#{{ journal.id }}: <a href="{{ route('transactions.show', [journal.id]) }}">{{ journal.description }}</a></li>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
<a href="{{ route('csv.index') }}" class="btn btn-warning">{{ 'csv_start_over'|_ }}</a>
|
<a href="{{ route('csv.index') }}" class="btn btn-warning">{{ 'csv_start_over'|_ }}</a>
|
||||||
<a href="{{ route('index') }}" class="btn btn-success">{{ 'csv_to_index'|_ }}</a>
|
<a href="{{ route('index') }}" class="btn btn-success">{{ 'csv_to_index'|_ }}</a>
|
||||||
|
Loading…
Reference in New Issue
Block a user