Fixes for find user in import

This commit is contained in:
David Bomba 2023-08-21 15:05:57 +10:00
parent a6d7584e14
commit 3285eb4862
3 changed files with 13 additions and 3 deletions

View File

@ -732,6 +732,15 @@ class BaseImport
protected function findUser($user_hash)
{
if(is_numeric($user_hash)) {
$user = User::query()->find($user_hash);
}
if($user)
return $user->id;
$user = User::where('account_id', $this->company->account->id)
->where(
\DB::raw('CONCAT_WS(" ", first_name, last_name)')->getValue(\DB::connection()->getQueryGrammar()),

View File

@ -238,14 +238,15 @@ class BaseTransformer
*/
public function hasClient($name)
{
nlog("has client");
return Client::query()->where('company_id', $this->company->id)
->where('is_deleted', false)
->whereRaw("LOWER(REPLACE(`name`, ' ' ,'')) = ?", [
->whereRaw("LOWER(REPLACE(`name`, ' ' , '')) = ?", [
strtolower(str_replace(' ', '', $name)),
])
->exists();
}
public function hasClientIdNumber($id_number)
{
return Client::query()->where('company_id', $this->company->id)

View File

@ -903,7 +903,7 @@ class EventTest extends TestCase
$response = $this->withHeaders([
'X-API-SECRET' => config('ninja.api_secret'),
'X-API-TOKEN' => $this->token,
])->postJson('/api/v1/purchase_orders/bulk?action=approve', $data)
])->postJson('/api/v1/purchase_orders/bulk?action=mark_sent', $data)
->assertStatus(200);
$response = $this->withHeaders([