diff --git a/app/Helpers/Csv/Importer.php b/app/Helpers/Csv/Importer.php index 33912ed48d..7ebee7eb5f 100644 --- a/app/Helpers/Csv/Importer.php +++ b/app/Helpers/Csv/Importer.php @@ -12,6 +12,7 @@ use FireflyIII\Models\Account; use FireflyIII\Models\Transaction; use FireflyIII\Models\TransactionJournal; use FireflyIII\Models\TransactionType; +use Illuminate\Support\Collection; use Illuminate\Support\MessageBag; use Log; @@ -44,6 +45,9 @@ class Importer /** @var array */ protected $specifix = []; + /** @var Collection */ + protected $journals; + /** * Used by CsvController. * @@ -74,6 +78,15 @@ class Importer return $this->rows; } + /** + * @return Collection + */ + public function getJournals() + { + return $this->journals; + } + + /** * @throws FireflyException */ @@ -81,6 +94,7 @@ class Importer { set_time_limit(0); + $this->journals = new Collection; $this->map = $this->data->getMap(); $this->roles = $this->data->getRoles(); $this->mapped = $this->data->getMapped(); @@ -91,11 +105,12 @@ class Importer Log::debug('--- Importing row ' . $index); $this->rows++; $result = $this->importRow($row); - if (!($result === true)) { + if (!($result instanceof TransactionJournal)) { Log::error('Caught error at row #' . $index . ': ' . $result); $this->errors[$index] = $result; } else { $this->imported++; + $this->journals->push($result); } Log::debug('---'); } @@ -151,9 +166,6 @@ class Importer return $result; // return error. } $journal = $this->createTransactionJournal(); - if ($journal instanceof TransactionJournal) { - return true; - } return $journal; } diff --git a/app/Http/Controllers/CsvController.php b/app/Http/Controllers/CsvController.php index 6e2dff8387..55fcb2ba7d 100644 --- a/app/Http/Controllers/CsvController.php +++ b/app/Http/Controllers/CsvController.php @@ -57,7 +57,7 @@ class CsvController extends Controller public function columnRoles() { - $fields = ['csv-file', 'csv-date-format', 'csv-has-headers','csv-import-account']; + $fields = ['csv-file', 'csv-date-format', 'csv-has-headers', 'csv-import-account']; if (!$this->wizard->sessionHasValues($fields)) { Session::flash('warning', 'Could not recover upload.'); @@ -302,12 +302,13 @@ class CsvController extends Controller $rows = $importer->getRows(); $errors = $importer->getErrors(); $imported = $importer->getImported(); + $journals = $importer->getJournals(); Preferences::mark(); $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')); } diff --git a/resources/twig/csv/process.twig b/resources/twig/csv/process.twig index 89911bc291..32a0da3ae3 100644 --- a/resources/twig/csv/process.twig +++ b/resources/twig/csv/process.twig @@ -42,6 +42,14 @@ {{ trans('firefly.csv_process_new_entries',{imported: imported}) }}

+ {% if journals|length > 0 %} + + {% endif %} +

{{ 'csv_start_over'|_ }} {{ 'csv_to_index'|_ }}