diff --git a/app/Http/Controllers/Import/IndexController.php b/app/Http/Controllers/Import/IndexController.php index b644e561e3..1b6911a458 100644 --- a/app/Http/Controllers/Import/IndexController.php +++ b/app/Http/Controllers/Import/IndexController.php @@ -7,6 +7,7 @@ namespace FireflyIII\Http\Controllers\Import; use FireflyIII\Exceptions\FireflyException; use FireflyIII\Http\Controllers\Controller; use FireflyIII\Import\Routine\ImportRoutine; +use FireflyIII\Import\Routine\RoutineInterface; use FireflyIII\Models\ImportJob; use FireflyIII\Repositories\ImportJob\ImportJobRepositoryInterface; use Illuminate\Http\Response as LaravelResponse; @@ -126,11 +127,9 @@ class IndexController extends Controller if (null === $className || !class_exists($className)) { throw new FireflyException(sprintf('Cannot find import routine class for job of type "%s".', $type)); // @codeCoverageIgnore } - var_dump($className); - exit; - /** @var ImportRoutine $routine */ - $routine = app(ImportRoutine::class); + /** @var RoutineInterface $routine */ + $routine = app($className); $routine->setJob($job); $result = $routine->run(); diff --git a/app/Http/Controllers/Import/StatusController.php b/app/Http/Controllers/Import/StatusController.php index eea28fea64..297b085e15 100644 --- a/app/Http/Controllers/Import/StatusController.php +++ b/app/Http/Controllers/Import/StatusController.php @@ -43,7 +43,7 @@ class StatusController extends Controller if (!in_array($job->status, $statuses)) { return redirect(route('import.file.configure', [$job->key])); } - $subTitle = trans('firefly.import_status_sub_title'); + $subTitle = trans('import.status_sub_title'); $subTitleIcon = 'fa-star'; return view('import.status', compact('job', 'subTitle', 'subTitleIcon')); @@ -67,7 +67,7 @@ class StatusController extends Controller 'show_percentage' => false, 'steps' => $job->extended_status['steps'], 'done' => $job->extended_status['done'], - 'statusText' => trans('firefly.import_status_job_' . $job->status), + 'statusText' => trans('import.status_job_' . $job->status), 'status' => $job->status, 'finishedText' => '', ]; @@ -83,7 +83,7 @@ class StatusController extends Controller $repository = app(TagRepositoryInterface::class); $tag = $repository->find($tagId); $result['finished'] = true; - $result['finishedText'] = trans('firefly.import_status_finished_job', ['link' => route('tags.show', [$tag->id, 'all']), 'tag' => $tag->tag]); + $result['finishedText'] = trans('import.status_finished_job', ['link' => route('tags.show', [$tag->id, 'all']), 'tag' => $tag->tag]); } if ('running' === $job->status) { diff --git a/app/Http/breadcrumbs.php b/app/Http/breadcrumbs.php index ae1b3bb1a4..78ef0b1e62 100644 --- a/app/Http/breadcrumbs.php +++ b/app/Http/breadcrumbs.php @@ -552,14 +552,14 @@ Breadcrumbs::register( 'import.configure', function (BreadCrumbGenerator $breadcrumbs, ImportJob $job) { $breadcrumbs->parent('import.index'); - $breadcrumbs->push(trans('firefly.import_config_sub_title', ['key' => $job->key]), route('import.configure', [$job->key])); + $breadcrumbs->push(trans('import.config_sub_title', ['key' => $job->key]), route('import.configure', [$job->key])); } ); Breadcrumbs::register( 'import.status', function (BreadCrumbGenerator $breadcrumbs, ImportJob $job) { $breadcrumbs->parent('import.index'); - $breadcrumbs->push(trans('firefly.import_status_bread_crumb', ['key' => $job->key]), route('import.status', [$job->key])); + $breadcrumbs->push(trans('import.status_bread_crumb', ['key' => $job->key]), route('import.status', [$job->key])); } ); diff --git a/app/Import/FileProcessor/CsvProcessor.php b/app/Import/FileProcessor/CsvProcessor.php index daa985f973..cdeb54805c 100644 --- a/app/Import/FileProcessor/CsvProcessor.php +++ b/app/Import/FileProcessor/CsvProcessor.php @@ -256,7 +256,7 @@ class CsvProcessor implements FileProcessorInterface * @var string $value */ foreach ($row as $rowIndex => $value) { - $value = trim($value); + $value = trim(strval($value)); if (strlen($value) > 0) { $annotated = $this->annotateValue($rowIndex, $value); Log::debug('Annotated value', $annotated); diff --git a/app/Import/Routine/FileRoutine.php b/app/Import/Routine/FileRoutine.php index eb5ea1cd9c..4d0ce8006c 100644 --- a/app/Import/Routine/FileRoutine.php +++ b/app/Import/Routine/FileRoutine.php @@ -109,9 +109,11 @@ class FileRoutine implements RoutineInterface */ protected function getImportObjects(): Collection { - $objects = new Collection; - $type = $this->job->file_type; - $class = config(sprintf('firefly.import_processors.%s', $type)); + $objects = new Collection; + $config = $this->job->configuration; + $fileType = $config['file-type']; + // will only respond to "file" + $class = config(sprintf('import.options.file.processors.%s', $fileType)); /** @var FileProcessorInterface $processor */ $processor = app($class); $processor->setJob($this->job); @@ -146,7 +148,7 @@ class FileRoutine implements RoutineInterface $repository = app(TagRepositoryInterface::class); $repository->setUser($this->job->user); $data = [ - 'tag' => trans('firefly.import_with_key', ['key' => $this->job->key]), + 'tag' => trans('import.import_with_key', ['key' => $this->job->key]), 'date' => new Carbon, 'description' => null, 'latitude' => null, diff --git a/config/firefly.php b/config/firefly.php index e389c8bc5d..265c3a5d32 100644 --- a/config/firefly.php +++ b/config/firefly.php @@ -40,23 +40,6 @@ return [ 'export_formats' => [ 'csv' => 'FireflyIII\Export\Exporter\CsvExporter', ], - 'import_formats' => [ - 'csv' => 'FireflyIII\Import\Configurator\CsvConfigurator', - 'spectre' => '', - ], - 'import_processors' => [ - 'csv' => 'FireflyIII\Import\FileProcessor\CsvProcessor', - ], - 'import_info' => [ - 'bunq' => 'FireflyIII\Support\Import\Information\BunqInformation', - 'spectre' => 'FireflyIII\Support\Import\Information\SpectreInformation', - 'plaid' => 'FireflyIII\Support\Import\Information\PlaidInformation', - ], - 'import_transactions' => [ - 'bunq' => 'FireflyIII\Support\Import\Transactions\BunqTransactions', - 'spectre' => 'FireflyIII\Support\Import\Transactions\SpectreTransactions', - 'plaid' => 'FireflyIII\Support\Import\Transactions\PlaidTransactions', - ], 'bunq' => [ 'server' => 'https://sandbox.public.api.bunq.com', ], diff --git a/config/import.php b/config/import.php index 877eeb4711..df1fcae827 100644 --- a/config/import.php +++ b/config/import.php @@ -32,6 +32,9 @@ return [ 'file' => [ 'import_formats' => ['csv'], // mt940 'default_import_format' => 'csv', + 'processors' => [ + 'csv' => 'FireflyIII\Import\FileProcessor\CsvProcessor', + ], ], ], 'default_config' => [ diff --git a/resources/lang/en_US/firefly.php b/resources/lang/en_US/firefly.php index ef97fb4956..aba14a68b2 100644 --- a/resources/lang/en_US/firefly.php +++ b/resources/lang/en_US/firefly.php @@ -1074,7 +1074,6 @@ return [ 'import_from_bunq' => 'Import from bunq', 'import_using_spectre' => 'Import using Spectre', 'import_using_plaid' => 'Import using Plaid', - 'import_config_sub_title' => 'Set up your import', 'import_config_bread_crumb' => 'Set up your import', // import index page: @@ -1082,23 +1081,6 @@ return [ 'import_index_sub_title' => 'Index', 'import_general_index_intro' => 'Welcome to Firefly\'s import routine. There are a few ways of importing data into Firefly III, displayed here as buttons.', - // import status page: - 'import_status_bread_crumb' => 'Import status', - 'import_status_sub_title' => 'Import status', - 'import_status_ready_config' => 'Download configuration', - 'import_status_ready_start' => 'Start the import', - 'import_status_ready_share' => 'Please consider downloading your configuration and sharing it at the import configuration center. This will allow other users of Firefly III to import their files more easily.', - 'import_status_running_title' => 'The import is running', - 'import_status_running_placeholder' => 'Please hold for an update...', - 'import_status_errors_title' => 'Errors during the import', - 'import_status_errors_single' => 'An error has occured during the import. It does not appear to be fatal.', - 'import_status_errors_multi' => 'Some errors occured during the import. These do not appear to be fatal.', - 'import_status_finished_title' => 'Import routine finished', - 'import_status_finished_text' => 'The import routine has imported your file.', - 'import_status_finished_job' => 'The transactions imported can be found in tag :tag.', - 'import_status_job_running' => 'The import is running...', - 'import_with_key' => 'Import with key \':key\'', - // sandstorm.io errors and messages: 'sandstorm_not_available' => 'This function is not available when you are using Firefly III within a Sandstorm.io environment.', diff --git a/resources/lang/en_US/import.php b/resources/lang/en_US/import.php index baf69809a6..858daff129 100644 --- a/resources/lang/en_US/import.php +++ b/resources/lang/en_US/import.php @@ -26,6 +26,22 @@ return [ 'status_ready_title' => 'Import is ready to start', 'status_ready_text' => 'The import is ready to start. All the configuration you needed to do has been done. Please download the configuration file. It will help you with the import should it not go as planned. To actually run the import, you can either execute the following command in your console, or run the web-based import. Depending on your configuration, the console import will give you more feedback.', 'status_ready_noconfig_text' => 'The import is ready to start. All the configuration you needed to do has been done. To actually run the import, you can either execute the following command in your console, or run the web-based import. Depending on your configuration, the console import will give you more feedback.', + 'status_ready_config' => 'Download configuration', + 'status_ready_start' => 'Start the import', + 'status_ready_share' => 'Please consider downloading your configuration and sharing it at the import configuration center. This will allow other users of Firefly III to import their files more easily.', + 'status_job_running' => 'The import is running.. Please wait..', + 'status_running_title' => 'The import is running', + 'status_running_placeholder' => 'Please hold for an update...', + 'status_finished_title' => 'Import routine finished', + 'status_finished_text' => 'The import routine has imported your data.', + 'status_errors_title' => 'Errors during the import', + 'status_errors_single' => 'An error has occurred during the import. It does not appear to be fatal.', + 'status_errors_multi' => 'Some errors occurred during the import. These do not appear to be fatal.', + 'status_bread_crumb' => 'Import status', + 'status_sub_title' => 'Import status', + 'config_sub_title' => 'Set up your import', + 'status_finished_job' => 'The transactions imported can be found in tag :tag.', + 'import_with_key' => 'Import with key \':key\'', // file: upload something: 'file_upload_title' => 'Import setup (1/4) - Upload your file', diff --git a/resources/views/import/_old/finished.twig b/resources/views/import/_old/finished.twig deleted file mode 100644 index 9f981e3517..0000000000 --- a/resources/views/import/_old/finished.twig +++ /dev/null @@ -1,38 +0,0 @@ -{% extends "./layout/default" %} - -{% block breadcrumbs %} - {{ Breadcrumbs.renderIfExists }} -{% endblock %} -{% block content %} -
- {{ 'import_finished_intro'|_ }} -
- {% if tagId > 0 %} -- {{ trans('firefly.import_finished_text_with_link', {tag: tagId})|raw }} -
- {% else %} -- {{ 'import_finished_text_without_link'|_ }} -
- {% endif %} - -- {{ 'import_share_configuration'|_ }} -
-- {{ 'import_index_intro'|_ }} -
-- {{ 'import_status_wait_text'|_ }} -
-- {{ 'import_status_ready_share'|_ }} + {{ trans('import.status_ready_share')|raw }}
{% endif %} @@ -90,7 +90,7 @@{{ 'import_status_running_placeholder'|_ }}
+{{ trans('import.status_running_placeholder') }}
- {{ 'import_status_finished_text'|_ }} + {{ trans('import.status_finished_text') }}
@@ -145,8 +145,8 @@