Fixes for unequal array combinations when mergins CSV imports

This commit is contained in:
David Bomba 2023-03-01 10:14:25 +11:00
parent e4bddeaa22
commit a24f58d3d8
4 changed files with 21 additions and 4 deletions

View File

@ -1 +1 @@
5.5.76
5.5.77

View File

@ -54,6 +54,14 @@ class BaseImport
public $transformer;
public ?array $column_map = [];
public ?string $hash;
public ?string $import_type;
public ?bool $skip_header;
public function __construct(array $request, Company $company)
{
$this->company = $company;
@ -78,6 +86,7 @@ class BaseImport
public function getCsvData($entity_type)
{
$base64_encoded_csv = Cache::pull($this->hash.'-'.$entity_type);
if (empty($base64_encoded_csv)) {
return null;
}
@ -636,6 +645,14 @@ class BaseImport
ksort($keys);
$data = array_map(function ($row) use ($keys) {
$row_count = count($row);
$key_count = count($keys);
if($key_count > $row_count) {
$row = array_pad($row, $key_count, ' ');
}
return array_combine($keys, array_intersect_key($row, $keys));
}, $data);

View File

@ -42,7 +42,7 @@ class CSVIngest implements ShouldQueue
public ?string $skip_header;
public $column_map;
public ?array $column_map = [];
public array $request;

View File

@ -14,8 +14,8 @@ return [
'require_https' => env('REQUIRE_HTTPS', true),
'app_url' => rtrim(env('APP_URL', ''), '/'),
'app_domain' => env('APP_DOMAIN', 'invoicing.co'),
'app_version' => '5.5.76',
'app_tag' => '5.5.76',
'app_version' => '5.5.77',
'app_tag' => '5.5.77',
'minimum_client_version' => '5.0.16',
'terms_version' => '1.0.1',
'api_secret' => env('API_SECRET', ''),