diff --git a/app/Jobs/Import/CSVImport.php b/app/Jobs/Import/CSVImport.php index e0fc289ad8..392272327e 100644 --- a/app/Jobs/Import/CSVImport.php +++ b/app/Jobs/Import/CSVImport.php @@ -78,7 +78,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; } /** diff --git a/tests/Feature/Import/ImportCsvTest.php b/tests/Feature/Import/ImportCsvTest.php index ecc9779409..6f2989d6b4 100644 --- a/tests/Feature/Import/ImportCsvTest.php +++ b/tests/Feature/Import/ImportCsvTest.php @@ -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', ]; @@ -113,7 +113,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', ]; @@ -141,7 +141,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', ]; @@ -166,7 +166,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', ]; @@ -191,7 +191,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', ]; @@ -218,7 +218,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', ];