diff --git a/app/Import/Transformer/BaseTransformer.php b/app/Import/Transformer/BaseTransformer.php index ee9c47b537de..6072feacbb09 100644 --- a/app/Import/Transformer/BaseTransformer.php +++ b/app/Import/Transformer/BaseTransformer.php @@ -65,6 +65,7 @@ class BaseTransformer public function getClient($client_name, $client_email) { + if (! empty($client_name)) { $client_id_search = $this->company ->clients() diff --git a/app/Import/Transformer/Zoho/ClientTransformer.php b/app/Import/Transformer/Zoho/ClientTransformer.php index 617048ef8712..ef423e54fd53 100644 --- a/app/Import/Transformer/Zoho/ClientTransformer.php +++ b/app/Import/Transformer/Zoho/ClientTransformer.php @@ -38,13 +38,15 @@ class ClientTransformer extends BaseTransformer $settings->payment_terms = $data['Payment Terms']; } + $client_id_proxy = array_key_exists('Customer ID', $data) ? 'Customer ID' : 'Primary Contact ID'; + return [ 'company_id' => $this->company->id, - 'name' => $this->getString($data, 'Company Name'), + 'name' => $this->getString($data, 'Display Name'), 'phone' => $this->getString($data, 'Phone'), 'private_notes' => $this->getString($data, 'Notes'), 'website' => $this->getString($data, 'Website'), - 'id_number' => $this->getString($data, 'Customer ID'), + 'id_number' => $this->getString($data, $client_id_proxy), 'address1' => $this->getString($data, 'Billing Address'), 'address2' => $this->getString($data, 'Billing Street2'), 'city' => $this->getString($data, 'Billing City'), diff --git a/app/Import/Transformer/Zoho/InvoiceTransformer.php b/app/Import/Transformer/Zoho/InvoiceTransformer.php index ea29d6c825c4..f1f45c976349 100644 --- a/app/Import/Transformer/Zoho/InvoiceTransformer.php +++ b/app/Import/Transformer/Zoho/InvoiceTransformer.php @@ -40,7 +40,7 @@ class InvoiceTransformer extends BaseTransformer $transformed = [ 'company_id' => $this->company->id, - 'client_id' => $this->getClient($this->getString($invoice_data, 'Customer ID'), null), + 'client_id' => $this->getClient($this->getString($invoice_data, 'Customer ID'), $this->getString($invoice_data, 'Primary Contact EmailID')), 'number' => $this->getString($invoice_data, 'Invoice Number'), 'date' => isset($invoice_data['Invoice Date']) ? date('Y-m-d', strtotime($invoice_data['Invoice Date'])) : null, 'due_date' => isset($invoice_data['Due Date']) ? date('Y-m-d', strtotime($invoice_data['Due Date'])) : null,