Rewrote importer to be more clean about the stage it is in.

This commit is contained in:
James Cole
2018-01-04 19:33:16 +01:00
parent 5866300ac1
commit e7debc5466
9 changed files with 211 additions and 97 deletions

View File

@@ -50,6 +50,7 @@ class FileConfigurator implements ConfiguratorInterface
'column-roles' => [], // unknown
'column-do-mapping' => [], // not yet set which columns must be mapped
'column-mapping-config' => [], // no mapping made yet.
'file-type' => 'csv', // assume
'has-config-file' => true,
'apply-rules' => true,
'match-bills' => false,
@@ -132,7 +133,7 @@ class FileConfigurator implements ConfiguratorInterface
}
$config = $this->getConfig();
$stage = $config['stage'] ?? 'initial';
switch($stage) {
switch ($stage) {
case 'initial': // has nothing, no file upload or anything.
return 'import.file.initial';
case 'upload-config': // has file, needs file config.
@@ -189,7 +190,10 @@ class FileConfigurator implements ConfiguratorInterface
$this->job = $job;
$this->repository = app(ImportJobRepositoryInterface::class);
$this->repository->setUser($job->user);
$this->repository->setConfiguration($job, $this->defaultConfig);
$config = $this->getConfig();
$newConfig = array_merge($this->defaultConfig, $config);
$this->repository->setConfiguration($job, $newConfig);
}
/**

View File

@@ -50,7 +50,10 @@ class SnsDescription implements SpecificInterface
*/
public function run(array $row): array
{
$row = array_values($row);
$row = array_values($row);
if (!isset($row[17])) {
return $row;
}
$row[17] = ltrim($row[17], "'");
$row[17] = rtrim($row[17], "'");