diff --git a/app/Filters/ProductFilters.php b/app/Filters/ProductFilters.php index e4e98f2a41..77d8d39594 100644 --- a/app/Filters/ProductFilters.php +++ b/app/Filters/ProductFilters.php @@ -42,6 +42,15 @@ class ProductFilters extends QueryFilters }); } + public function product_key(string $filter = '') : Builder + { + if (strlen($filter) == 0) { + return $this->builder; + } + + return $this->builder->where('product_key', $filter); + } + /** * Filters the list based on the status * archived, active, deleted. diff --git a/app/Http/Controllers/ClientPortal/InvitationController.php b/app/Http/Controllers/ClientPortal/InvitationController.php index ab353600c6..7b9e08a594 100644 --- a/app/Http/Controllers/ClientPortal/InvitationController.php +++ b/app/Http/Controllers/ClientPortal/InvitationController.php @@ -83,9 +83,6 @@ class InvitationController extends Controller $invitation = $entity_obj::withTrashed() ->with($entity) ->where('key', $invitation_key) - // ->whereHas($entity, function ($query) { - // $query->where('is_deleted',0); - // }) ->with('contact.client') ->first(); diff --git a/app/Import/Providers/BaseImport.php b/app/Import/Providers/BaseImport.php index 5d9957bbdc..cc6addedeb 100644 --- a/app/Import/Providers/BaseImport.php +++ b/app/Import/Providers/BaseImport.php @@ -170,7 +170,21 @@ class BaseImport { $count = 0; + $is_free_hosted_client = $this->company->account->isFreeHostedClient(); + $hosted_client_count = $this->company->account->hosted_client_count; + foreach ($data as $key => $record) { + + if($this->factory_name instanceof ClientFactory && $is_free_hosted_client && ($this->company->clients()->count() > $hosted_client_count)) + { + $this->error_array[$entity_type][] = [ + $entity_type => $record, + 'error' => 'Client limit reached', + ]; + + return $count; + } + try { $entity = $this->transformer->transform($record); // $validator = $this->request_name::runFormRequest($entity); diff --git a/app/PaymentDrivers/Square/CreditCard.php b/app/PaymentDrivers/Square/CreditCard.php index acfcd8a5cc..84fd4bea00 100644 --- a/app/PaymentDrivers/Square/CreditCard.php +++ b/app/PaymentDrivers/Square/CreditCard.php @@ -76,6 +76,8 @@ class CreditCard implements MethodInterface { $client = new \stdClass; + $country = $this->square_driver->client->country ? $this->square_driver->client->country->iso_3166_2 : $this->square_driver->client->company->country()->iso_3166_2; + $client->addressLines = [$this->square_driver->client->address1 ?: '', $this->square_driver->client->address2 ?: '']; $client->givenName = $this->square_driver->client->present()->first_name(); $client->familyName = $this->square_driver->client->present()->last_name(); @@ -83,7 +85,7 @@ class CreditCard implements MethodInterface $client->phone = $this->square_driver->client->phone; $client->city = $this->square_driver->client->city; $client->region = $this->square_driver->client->state; - $client->country = $this->square_driver->client->country->iso_3166_2; + $client->country = $country; return (array) $client; } @@ -202,6 +204,8 @@ class CreditCard implements MethodInterface private function createClient() { + $country = $this->square_driver->client->country ? $this->square_driver->client->country->iso_3166_2 : $this->square_driver->client->company->country()->iso_3166_2; + /* Step two - create the customer */ $billing_address = new \Square\Models\Address(); $billing_address->setAddressLine1($this->square_driver->client->address1); @@ -209,7 +213,7 @@ class CreditCard implements MethodInterface $billing_address->setLocality($this->square_driver->client->city); $billing_address->setAdministrativeDistrictLevel1($this->square_driver->client->state); $billing_address->setPostalCode($this->square_driver->client->postal_code); - $billing_address->setCountry($this->square_driver->client->country->iso_3166_2); + $billing_address->setCountry($country); $body = new \Square\Models\CreateCustomerRequest(); $body->setGivenName($this->square_driver->client->present()->name());