mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-08 17:04:30 -04:00
zoho improvements
This commit is contained in:
parent
786bda2515
commit
de7afb9944
@ -246,6 +246,15 @@ class BaseTransformer
|
|||||||
->exists();
|
->exists();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function hasClientIdNumber($id_number)
|
||||||
|
{
|
||||||
|
return Client::where('company_id', $this->company->id)
|
||||||
|
->where('is_deleted', false)
|
||||||
|
->where('id_number', trim($id_number))
|
||||||
|
->exists();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $name
|
* @param $name
|
||||||
*
|
*
|
||||||
|
@ -27,7 +27,12 @@ class ClientTransformer extends BaseTransformer
|
|||||||
*/
|
*/
|
||||||
public function transform($data)
|
public function transform($data)
|
||||||
{
|
{
|
||||||
if (isset($data['Company Name']) && $this->hasClient($data['Company Name'])) {
|
$client_id_proxy = array_key_exists('Customer ID', $data) ? 'Customer ID' : 'Primary Contact ID';
|
||||||
|
|
||||||
|
if(isset($data[$client_id_proxy]) && $this->hasClientIdNumber($data[$client_id_proxy])) {
|
||||||
|
throw new ImportException('Client ID already exists => '. $data[$client_id_proxy]);
|
||||||
|
}
|
||||||
|
elseif (isset($data['Company Name']) && $this->hasClient($data['Company Name'])) {
|
||||||
throw new ImportException('Client already exists => '. $data['Company Name']);
|
throw new ImportException('Client already exists => '. $data['Company Name']);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -38,8 +43,6 @@ class ClientTransformer extends BaseTransformer
|
|||||||
$settings->payment_terms = $data['Payment Terms'];
|
$settings->payment_terms = $data['Payment Terms'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$client_id_proxy = array_key_exists('Customer ID', $data) ? 'Customer ID' : 'Primary Contact ID';
|
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'company_id' => $this->company->id,
|
'company_id' => $this->company->id,
|
||||||
'name' => $this->getString($data, 'Display Name'),
|
'name' => $this->getString($data, 'Display Name'),
|
||||||
|
@ -123,7 +123,6 @@ class InvoiceTransformer extends BaseTransformer
|
|||||||
return $client_id_search->first()->id;
|
return $client_id_search->first()->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$client_repository = app()->make(\App\Repositories\ClientRepository::class);
|
$client_repository = app()->make(\App\Repositories\ClientRepository::class);
|
||||||
$client_repository->import_mode = true;
|
$client_repository->import_mode = true;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user