diff --git a/app/Http/Requests/Request.php b/app/Http/Requests/Request.php index a53cd70540c6..628fb76ef547 100644 --- a/app/Http/Requests/Request.php +++ b/app/Http/Requests/Request.php @@ -39,6 +39,10 @@ class Request extends FormRequest } } + //01-02-2022 needed for CSV Imports + if(!$merge_rules) + return $rules; + return array_merge($merge_rules, $rules); } diff --git a/app/Http/ValidationRules/Company/ValidCompanyQuantity.php b/app/Http/ValidationRules/Company/ValidCompanyQuantity.php index 1e5de928edde..6dd88aab32d3 100644 --- a/app/Http/ValidationRules/Company/ValidCompanyQuantity.php +++ b/app/Http/ValidationRules/Company/ValidCompanyQuantity.php @@ -11,6 +11,7 @@ namespace App\Http\ValidationRules\Company; +use App\Utils\Ninja; use Illuminate\Contracts\Validation\Rule; /** @@ -25,7 +26,12 @@ class ValidCompanyQuantity implements Rule */ public function passes($attribute, $value) { - return auth()->user()->company()->account->companies->count() <= 10; + if(Ninja::isSelfHost()) + return auth()->user()->company()->account->companies->count() < 10; + + + return auth()->user()->company()->account->companies->count() < auth()->user()->company()->account->hosted_company_count; + } /** diff --git a/app/Http/ValidationRules/Ninja/CanStoreClientsRule.php b/app/Http/ValidationRules/Ninja/CanStoreClientsRule.php index a1523c2f2efd..23221c042c2b 100644 --- a/app/Http/ValidationRules/Ninja/CanStoreClientsRule.php +++ b/app/Http/ValidationRules/Ninja/CanStoreClientsRule.php @@ -35,7 +35,7 @@ class CanStoreClientsRule implements Rule { $company = Company::find($this->company_id); - return $company->clients->count() < config('ninja.quotas.free.clients'); + return $company->clients->count() < $company->account->hosted_client_count; } /** @@ -43,6 +43,6 @@ class CanStoreClientsRule implements Rule */ public function message() { - return ctrans('texts.limit_clients', ['count' => config('ninja.quotas.free.clients')]); + return ctrans('texts.limit_clients', ['count' => $company->account->hosted_client_count]); } } diff --git a/app/PaymentDrivers/Authorize/AuthorizeCreateCustomer.php b/app/PaymentDrivers/Authorize/AuthorizeCreateCustomer.php index af39afbe3249..e170a5042968 100644 --- a/app/PaymentDrivers/Authorize/AuthorizeCreateCustomer.php +++ b/app/PaymentDrivers/Authorize/AuthorizeCreateCustomer.php @@ -44,7 +44,7 @@ class AuthorizeCreateCustomer $this->authorize->init(); // Create the Bill To info for new payment type - $contact = $this->client->primary_contact()->first(); + $contact = $this->client->primary_contact()->first() ?: $this->client->contacts()->first(); $refId = 'ref'.time(); // Create a new CustomerProfileType and add the payment profile object diff --git a/app/PaymentDrivers/CheckoutCom/Utilities.php b/app/PaymentDrivers/CheckoutCom/Utilities.php index eddc38495eba..3697f3d8c5c5 100644 --- a/app/PaymentDrivers/CheckoutCom/Utilities.php +++ b/app/PaymentDrivers/CheckoutCom/Utilities.php @@ -62,7 +62,7 @@ trait Utilities $data = [ 'payment_method' => $_payment->source['id'], - 'payment_type' => PaymentType::parseCardType(strtolower($_payment->source['scheme'])), + 'payment_type' => 12, 'amount' => $this->getParent()->payment_hash->data->raw_value, 'transaction_reference' => $_payment->id, 'gateway_type_id' => GatewayType::CREDIT_CARD, diff --git a/app/Repositories/ActivityRepository.php b/app/Repositories/ActivityRepository.php index 6da7e24d398d..a4a771991813 100644 --- a/app/Repositories/ActivityRepository.php +++ b/app/Repositories/ActivityRepository.php @@ -54,7 +54,7 @@ class ActivityRepository extends BaseRepository $activity->token_id = $token_id; } - $activity->ip = $event_vars['ip']; + $activity->ip = $event_vars['ip'] ?: ' '; $activity->is_system = $event_vars['is_system']; $activity->save();