diff --git a/VERSION.txt b/VERSION.txt index 9baf8dbc7227..9e5a077653d6 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1 +1 @@ -5.3.84 \ No newline at end of file +5.3.85 \ No newline at end of file diff --git a/app/Http/Controllers/Auth/LoginController.php b/app/Http/Controllers/Auth/LoginController.php index bf57f96ae966..a4ea5f9b35a7 100644 --- a/app/Http/Controllers/Auth/LoginController.php +++ b/app/Http/Controllers/Auth/LoginController.php @@ -217,6 +217,9 @@ class LoginController extends BaseController $cu = CompanyUser::query() ->where('user_id', auth()->user()->id); + if($cu->count() == 0) + return response()->json(['message' => 'User found, but not attached to any companies, please see your administrator'], 400); + $truth = app()->make(TruthSource::class); $truth->setCompanyUser($cu->first()); @@ -320,6 +323,9 @@ class LoginController extends BaseController $cu = CompanyUser::query() ->where('user_id', $company_token->user_id); + if($cu->count() == 0) + return response()->json(['message' => 'User found, but not attached to any companies, please see your administrator'], 400); + $cu->first()->account->companies->each(function ($company) use($cu, $request){ if($company->tokens()->where('is_system', true)->count() == 0) @@ -390,6 +396,8 @@ class LoginController extends BaseController $cu = CompanyUser::query() ->where('user_id', auth()->user()->id); + if($cu->count() == 0) + return response()->json(['message' => 'User found, but not attached to any companies, please see your administrator'], 400); $truth = app()->make(TruthSource::class); $truth->setCompanyUser($cu->first()); @@ -441,6 +449,9 @@ class LoginController extends BaseController $cu = CompanyUser::query() ->where('user_id', auth()->user()->id); + if($cu->count() == 0) + return response()->json(['message' => 'User found, but not attached to any companies, please see your administrator'], 400); + $truth = app()->make(TruthSource::class); $truth->setCompanyUser($cu->first()); $truth->setUser($existing_login_user); @@ -496,6 +507,9 @@ class LoginController extends BaseController $cu = CompanyUser::query() ->where('user_id', auth()->user()->id); + if($cu->count() == 0) + return response()->json(['message' => 'User found, but not attached to any companies, please see your administrator'], 400); + $truth = app()->make(TruthSource::class); $truth->setCompanyUser($cu->first()); $truth->setUser($existing_login_user); @@ -555,6 +569,8 @@ class LoginController extends BaseController $cu = CompanyUser::whereUserId(auth()->user()->id); + if($cu->count() == 0) + return response()->json(['message' => 'User found, but not attached to any companies, please see your administrator'], 400); $truth = app()->make(TruthSource::class); $truth->setCompanyUser($cu->first()); diff --git a/app/Http/Controllers/ClientPortal/NinjaPlanController.php b/app/Http/Controllers/ClientPortal/NinjaPlanController.php index f2c8caaf6245..93b85bf68027 100644 --- a/app/Http/Controllers/ClientPortal/NinjaPlanController.php +++ b/app/Http/Controllers/ClientPortal/NinjaPlanController.php @@ -92,7 +92,6 @@ class NinjaPlanController extends Controller ]); $data['intent'] = $setupIntent; - // $data['account'] = $account; $data['client'] = Auth::guard('contact')->user()->client; return $this->render('plan.trial', $data); @@ -139,6 +138,8 @@ class NinjaPlanController extends Controller $account = Account::where('key', auth()->guard('contact')->user()->client->custom_value2)->first(); $account->trial_started = now(); $account->trial_plan = 'pro'; + $account->plan = 'pro'; + $account->plan_expires = now()->addDays(14); $account->save(); } diff --git a/app/Http/Controllers/CompanyController.php b/app/Http/Controllers/CompanyController.php index 78130ef55419..c780d66f3007 100644 --- a/app/Http/Controllers/CompanyController.php +++ b/app/Http/Controllers/CompanyController.php @@ -232,7 +232,7 @@ class CompanyController extends BaseController 'notifications' => CompanySettings::notificationDefaults(), ]); - if(auth()->user()->company()->account->companies()->where('is_large', 1)->exists()) + if($company->account->companies()->where('is_large', 1)->exists()) { $company->account->companies()->update(['is_large' => true]); } diff --git a/app/Http/Requests/Account/CreateAccountRequest.php b/app/Http/Requests/Account/CreateAccountRequest.php index 78661967c3fa..c073bc59e9b8 100644 --- a/app/Http/Requests/Account/CreateAccountRequest.php +++ b/app/Http/Requests/Account/CreateAccountRequest.php @@ -38,9 +38,9 @@ class CreateAccountRequest extends Request { if(Ninja::isHosted()) - $email_rules = ['required', 'email:rfc,dns', new NewUniqueUserRule, new BlackListRule, new EmailBlackListRule]; + $email_rules = ['bail','required', 'email:rfc,dns', new NewUniqueUserRule, new BlackListRule, new EmailBlackListRule]; else - $email_rules = ['required', 'email:rfc,dns', new NewUniqueUserRule]; + $email_rules = ['bail','required', 'email:rfc,dns', new NewUniqueUserRule]; return [ diff --git a/app/Jobs/Company/CompanyExport.php b/app/Jobs/Company/CompanyExport.php index 0ca4cc8dfd9e..3d11955eadb0 100644 --- a/app/Jobs/Company/CompanyExport.php +++ b/app/Jobs/Company/CompanyExport.php @@ -192,7 +192,7 @@ class CompanyExport implements ShouldQueue })->all(); - $this->export_data['company_users'] = $this->company->company_users->map(function ($company_user){ + $this->export_data['company_users'] = $this->company->company_users()->without(['user','account'])->cursor()->map(function ($company_user){ $company_user = $this->transformArrayOfKeys($company_user, ['company_id', 'account_id', 'user_id']); diff --git a/app/Jobs/Company/CompanyImport.php b/app/Jobs/Company/CompanyImport.php index d614d5775bff..da8f22a28c7b 100644 --- a/app/Jobs/Company/CompanyImport.php +++ b/app/Jobs/Company/CompanyImport.php @@ -490,7 +490,8 @@ class CompanyImport implements ShouldQueue foreach($this->company_properties as $value){ - $this->company->{$value} = $tmp_company->{$value}; + if(property_exists($tmp_company, $value)) + $this->company->{$value} = $tmp_company->{$value}; } @@ -1119,11 +1120,17 @@ class CompanyImport implements ShouldQueue unset($cu_array['id']); unset($cu_array['company_id']); unset($cu_array['user_id']); + unset($cu_array['user']); + unset($cu_array['account']); + + // $cu_array['settings'] = json_encode($cu_array['settings']); + // $cu_array['notifications'] = json_encode($cu_array['notifications']); + // $cu_array['permissions'] = json_encode($cu_array['permissions']); $new_cu = CompanyUser::withTrashed()->firstOrNew( - ['user_id' => $user_id, 'company_id' => $this->company->id], - $cu_array, - ); + ['user_id' => $user_id, 'company_id' => $this->company->id], + $cu_array, + ); $new_cu->account_id = $this->account->id; $new_cu->save(['timestamps' => false]); diff --git a/app/Jobs/Mail/PaymentFailedMailer.php b/app/Jobs/Mail/PaymentFailedMailer.php index 5a53e8c17ce8..8a9d46785298 100644 --- a/app/Jobs/Mail/PaymentFailedMailer.php +++ b/app/Jobs/Mail/PaymentFailedMailer.php @@ -111,7 +111,7 @@ class PaymentFailedMailer implements ShouldQueue //add client payment failures here. // - if($contact = $this->client->primary_contact()->first() && $this->payment_hash) + if($contact = $this->client->contacts()->first() && $this->payment_hash) { $mail_obj = (new ClientPaymentFailureObject($this->client, $this->error, $this->company, $this->payment_hash))->build(); diff --git a/app/Models/Account.php b/app/Models/Account.php index 3e802f6d4834..8af56a3a590d 100644 --- a/app/Models/Account.php +++ b/app/Models/Account.php @@ -428,10 +428,13 @@ class Account extends BaseModel public function gmailCredentialNotification() :bool { + nlog("checking if gmail credential notification has already been sent"); if(is_null(Cache::get($this->key))) return false; + nlog("Sending notification"); + try { if(is_null(Cache::get("gmail_credentials_notified:{$this->key}"))) { diff --git a/app/Models/InvoiceInvitation.php b/app/Models/InvoiceInvitation.php index 21ccce4c2e0b..062e02a47a56 100644 --- a/app/Models/InvoiceInvitation.php +++ b/app/Models/InvoiceInvitation.php @@ -43,38 +43,6 @@ class InvoiceInvitation extends BaseModel return self::class; } - // public function getSignatureDateAttribute($value) - // { - // if (!$value) { - // return (new Carbon($value))->format('Y-m-d'); - // } - // return $value; - // } - - // public function getSentDateAttribute($value) - // { - // if (!$value) { - // return (new Carbon($value))->format('Y-m-d'); - // } - // return $value; - // } - - // public function getViewedDateAttribute($value) - // { - // if (!$value) { - // return (new Carbon($value))->format('Y-m-d'); - // } - // return $value; - // } - - // public function getOpenedDateAttribute($value) - // { - // if (!$value) { - // return (new Carbon($value))->format('Y-m-d'); - // } - // return $value; - // } - public function entityType() { return Invoice::class; diff --git a/app/PaymentDrivers/Authorize/AuthorizeCreditCard.php b/app/PaymentDrivers/Authorize/AuthorizeCreditCard.php index 835197d5a777..0b1a03c9299f 100644 --- a/app/PaymentDrivers/Authorize/AuthorizeCreditCard.php +++ b/app/PaymentDrivers/Authorize/AuthorizeCreditCard.php @@ -253,7 +253,7 @@ class AuthorizeCreditCard $response = $data['response']; $amount = array_key_exists('amount_with_fee', $data) ? $data['amount_with_fee'] : 0; - $code = "Error"; + $code = 1; $description = "There was an error processing the payment"; if ($response && $response->getErrors() != null) { diff --git a/app/PaymentDrivers/PayPalExpressPaymentDriver.php b/app/PaymentDrivers/PayPalExpressPaymentDriver.php index 8590a361c698..afe824304a37 100644 --- a/app/PaymentDrivers/PayPalExpressPaymentDriver.php +++ b/app/PaymentDrivers/PayPalExpressPaymentDriver.php @@ -185,7 +185,7 @@ class PayPalExpressPaymentDriver extends BaseDriver 'currency' => $this->client->getCurrencyCode(), 'transactionType' => 'Purchase', 'clientIp' => request()->getClientIp(), - 'amount' => $data['total']['amount_with_fee'] + $this->fee, + 'amount' => round(($data['total']['amount_with_fee'] + $this->fee),2), 'returnUrl' => route('client.payments.response', [ 'company_gateway_id' => $this->company_gateway->id, 'payment_hash' => $this->payment_hash->hash, diff --git a/app/Transformers/AccountTransformer.php b/app/Transformers/AccountTransformer.php index 6882a5d97316..661ad79b2ce9 100644 --- a/app/Transformers/AccountTransformer.php +++ b/app/Transformers/AccountTransformer.php @@ -85,6 +85,7 @@ class AccountTransformer extends EntityTransformer 'is_migrated' => (bool) $account->is_migrated, 'hosted_client_count' => (int) $account->hosted_client_count, 'hosted_company_count' => (int) $account->hosted_company_count, + 'is_hosted' => (bool) Ninja::isHosted(), ]; } diff --git a/app/Utils/Traits/GeneratesConvertedQuoteCounter.php b/app/Utils/Traits/GeneratesConvertedQuoteCounter.php index f4f42a88e978..7c33334cac7c 100644 --- a/app/Utils/Traits/GeneratesConvertedQuoteCounter.php +++ b/app/Utils/Traits/GeneratesConvertedQuoteCounter.php @@ -631,7 +631,7 @@ trait GeneratesConvertedQuoteCounter } $search = ['{$year}']; - $replace = [date('Y')]; + $replace = [Carbon::now($entity->company->timezone()->name)->format('Y')]; $search[] = '{$counter}'; $replace[] = $counter; @@ -646,8 +646,8 @@ trait GeneratesConvertedQuoteCounter $replace[] = $counter; $search[] = '{$year}'; - $replace[] = date('Y'); - + $replace[] = Carbon::now($entity->company->timezone()->name)->format('Y'); + if (strstr($pattern, '{$user_id}') || strstr($pattern, '{$userId}')) { $user_id = $entity->user_id ? $entity->user_id : 0; $search[] = '{$user_id}'; diff --git a/app/Utils/Traits/GeneratesCounter.php b/app/Utils/Traits/GeneratesCounter.php index 0ed905279800..b9606621246a 100644 --- a/app/Utils/Traits/GeneratesCounter.php +++ b/app/Utils/Traits/GeneratesCounter.php @@ -642,9 +642,9 @@ trait GeneratesCounter return $counter; } - $search = ['{$year}']; - $replace = [date('Y')]; - + $search = []; + $replace = []; + $search[] = '{$counter}'; $replace[] = $counter; @@ -658,7 +658,7 @@ trait GeneratesCounter $replace[] = $counter; $search[] = '{$year}'; - $replace[] = date('Y'); + $replace[] = Carbon::now($entity->company->timezone()->name)->format('Y'); if (strstr($pattern, '{$user_id}') || strstr($pattern, '{$userId}')) { $user_id = $entity->user_id ? $entity->user_id : 0; diff --git a/config/ninja.php b/config/ninja.php index 2b09aa28889e..869268aadea3 100644 --- a/config/ninja.php +++ b/config/ninja.php @@ -14,8 +14,8 @@ return [ 'require_https' => env('REQUIRE_HTTPS', true), 'app_url' => rtrim(env('APP_URL', ''), '/'), 'app_domain' => env('APP_DOMAIN', 'invoicing.co'), - 'app_version' => '5.3.84', - 'app_tag' => '5.3.84', + 'app_version' => '5.3.85', + 'app_tag' => '5.3.85', 'minimum_client_version' => '5.0.16', 'terms_version' => '1.0.1', 'api_secret' => env('API_SECRET', ''), diff --git a/resources/lang/en/texts.php b/resources/lang/en/texts.php index 09a162e83923..11191744bf39 100644 --- a/resources/lang/en/texts.php +++ b/resources/lang/en/texts.php @@ -888,7 +888,7 @@ $LANG = array( 'custom_invoice_charges_helps' => 'Add a field when creating an invoice and include the charge in the invoice subtotals.', 'token_expired' => 'Validation token was expired. Please try again.', 'invoice_link' => 'Invoice Link', - 'button_confirmation_message' => 'Click to confirm your email.', + 'button_confirmation_message' => 'Confirm your email.', 'confirm' => 'Confirm', 'email_preferences' => 'Email Preferences', 'created_invoices' => 'Successfully created :count invoice(s)',