Fixes for imports

This commit is contained in:
David Bomba 2024-10-03 16:02:04 +10:00
parent f5c65a68cb
commit 7c9b4fe0bf
3 changed files with 30 additions and 33 deletions

View File

@ -216,7 +216,6 @@ class BaseTransformer
->where('is_deleted', false) ->where('is_deleted', false)
->where('id_number', $client_name); ->where('id_number', $client_name);
nlog("idnommer ".$client_id_search->count());
if ($client_id_search->count() >= 1) { if ($client_id_search->count() >= 1) {
return $client_id_search->first()->id; return $client_id_search->first()->id;
} }
@ -227,9 +226,6 @@ class BaseTransformer
strtolower(str_replace(' ', '', $client_name)), strtolower(str_replace(' ', '', $client_name)),
]); ]);
nlog("client_name_search ".$client_name_search->count());
if ($client_name_search->count() >= 1) { if ($client_name_search->count() >= 1) {
return $client_name_search->first()->id; return $client_name_search->first()->id;
} }
@ -241,8 +237,6 @@ class BaseTransformer
->where('company_id', $this->company->id) ->where('company_id', $this->company->id)
->where('email', $client_email); ->where('email', $client_email);
nlog("contact count = " . $contacts->count());
if ($contacts->count() >= 1) { if ($contacts->count() >= 1) {
return $contacts->first()->client_id; return $contacts->first()->client_id;
} }
@ -281,12 +275,14 @@ class BaseTransformer
public function hasClient($name) public function hasClient($name)
{ {
return Client::query()->where('company_id', $this->company->id) $x= Client::query()
->where('company_id', $this->company->id)
->where('is_deleted', false) ->where('is_deleted', false)
->whereRaw("LOWER(REPLACE(`name`, ' ' , '')) = ?", [ ->whereRaw("LOWER(REPLACE(`name`, ' ' , '')) = ?", [
strtolower(str_replace(' ', '', $name)), strtolower(str_replace(' ', '', $name)),
]) ]);
->exists();
return $x->exists();
} }
public function hasClientIdNumber($id_number) public function hasClientIdNumber($id_number)
@ -416,7 +412,8 @@ class BaseTransformer
*/ */
public function getContact($email): ?ClientContact public function getContact($email): ?ClientContact
{ {
$contact = ClientContact::query()->where('company_id', $this->company->id) $contact = ClientContact::query()
->where('company_id', $this->company->id)
->whereRaw("LOWER(REPLACE(`email`, ' ' ,'')) = ?", [ ->whereRaw("LOWER(REPLACE(`email`, ' ' ,'')) = ?", [
strtolower(str_replace(' ', '', $email)), strtolower(str_replace(' ', '', $email)),
]) ])

View File

@ -72,7 +72,8 @@ class InvoiceTransformer extends BaseTransformer
if ($client_id) { if ($client_id) {
$transformed['client_id'] = $client_id; $transformed['client_id'] = $client_id;
} else { }
$settings = new \stdClass(); $settings = new \stdClass();
$settings->currency_id = $this->getCurrencyByCode($invoice_data, 'Currency'); $settings->currency_id = $this->getCurrencyByCode($invoice_data, 'Currency');
@ -94,7 +95,6 @@ class InvoiceTransformer extends BaseTransformer
$transformed['client'] = array_merge($transformed['client'], $addresses); $transformed['client'] = array_merge($transformed['client'], $addresses);
}
if (! empty($invoice_data['Date Paid'])) { if (! empty($invoice_data['Date Paid'])) {
$transformed['payments'] = [ $transformed['payments'] = [
[ [

View File

@ -121,9 +121,9 @@ class Invoice2GoTest extends TestCase
$client = Client::find($client_id); $client = Client::find($client_id);
$this->assertInstanceOf(Client::class, $client); $this->assertInstanceOf(Client::class, $client);
$this->assertEquals('840', $client->country_id); // $this->assertEquals('840', $client->country_id);
$this->assertEquals('wade@projectx.net', $client->contacts->first()->email); // $this->assertEquals('wade@projectx.net', $client->contacts->first()->email);
$this->assertEquals('2584 Sesame Street', $client->address1); // $this->assertEquals('2584 Sesame Street', $client->address1);
$this->assertTrue($base_transformer->hasInvoice('1')); $this->assertTrue($base_transformer->hasInvoice('1'));
$this->assertTrue($base_transformer->hasInvoice('2')); $this->assertTrue($base_transformer->hasInvoice('2'));