Merge pull request #4946 from joshuadwire/v5-develop

Update import process to handle new data format
This commit is contained in:
David Bomba 2021-02-20 11:57:36 +11:00 committed by GitHub
commit e8da728428
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 7 deletions

View File

@ -79,7 +79,9 @@ class CSVImport implements ShouldQueue {
$this->hash = $request['hash'];
$this->import_type = $request['import_type'];
$this->skip_header = $request['skip_header'] ?? null;
$this->column_map = $request['column_map'] ?? null;
$this->column_map =
! empty( $request['column_map'] ) ?
array_combine( array_keys( $request['column_map'] ), array_column( $request['column_map'], 'mapping' ) ) : null;
}
/**

View File

@ -74,7 +74,7 @@ class ImportCsvTest extends TestCase
$data = [
'hash' => $hash,
'column_map' => [ 'client' => $column_map ],
'column_map' => [ 'client' => [ 'mapping' => $column_map ] ],
'skip_header' => true,
'import_type' => 'csv',
];
@ -139,7 +139,7 @@ class ImportCsvTest extends TestCase
$data = [
'hash' => $hash,
'column_map' => [ 'invoice' => $column_map ],
'column_map' => [ 'invoice' => [ 'mapping' => $column_map ] ],
'skip_header' => true,
'import_type' => 'csv',
];
@ -167,7 +167,7 @@ class ImportCsvTest extends TestCase
$data = [
'hash' => $hash,
'column_map' => [ 'vendor' => $column_map ],
'column_map' => [ 'vendor' => [ 'mapping' => $column_map ] ],
'skip_header' => true,
'import_type' => 'csv',
];
@ -192,7 +192,7 @@ class ImportCsvTest extends TestCase
$data = [
'hash' => $hash,
'column_map' => [ 'product' => $column_map ],
'column_map' => [ 'product' => [ 'mapping' => $column_map ] ],
'skip_header' => true,
'import_type' => 'csv',
];
@ -217,7 +217,7 @@ class ImportCsvTest extends TestCase
$data = [
'hash' => $hash,
'column_map' => [ 'expense' => $column_map ],
'column_map' => [ 'expense' => [ 'mapping' => $column_map ] ],
'skip_header' => true,
'import_type' => 'csv',
];
@ -308,7 +308,7 @@ class ImportCsvTest extends TestCase
$data = [
'hash' => $hash,
'column_map' => [ 'payment' => $column_map ],
'column_map' => [ 'payment' => [ 'mapping' => $column_map ] ],
'skip_header' => true,
'import_type' => 'csv',
];