1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 13:12:50 +01:00

Update import process to handle new data format

This commit is contained in:
Joshua Dwire 2021-02-19 19:50:17 -05:00
parent e11e71514a
commit 4aae7c0b1a
2 changed files with 9 additions and 7 deletions

View File

@ -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;
}
/**

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',
];
@ -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',
];