From 730aa4219cd2129276caf7bd8b8f3b0e0b64d0c9 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sun, 1 May 2022 16:35:33 +1000 Subject: [PATCH 01/16] Change text of confirmation button --- resources/lang/en/texts.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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)', From 90e60fb8fc59ac2529f4ed86fa787099bacfb7b6 Mon Sep 17 00:00:00 2001 From: = Date: Mon, 2 May 2022 07:51:39 +1000 Subject: [PATCH 02/16] Add is_hosted flag to accoun transformer --- app/Transformers/AccountTransformer.php | 1 + 1 file changed, 1 insertion(+) 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(), ]; } From b0ae010e42276ac7eb63c03e516101d026423273 Mon Sep 17 00:00:00 2001 From: = Date: Mon, 2 May 2022 08:10:12 +1000 Subject: [PATCH 03/16] Fixes for types in Authorize --- app/PaymentDrivers/Authorize/AuthorizeCreditCard.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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) { From 6709e5bbc41ef9780f40657acd154ab902ea5c31 Mon Sep 17 00:00:00 2001 From: = Date: Mon, 2 May 2022 08:20:54 +1000 Subject: [PATCH 04/16] Fixes for localizing dates for reset counter --- app/Utils/Traits/GeneratesCounter.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Utils/Traits/GeneratesCounter.php b/app/Utils/Traits/GeneratesCounter.php index 0ed905279800..a1a10bd2f392 100644 --- a/app/Utils/Traits/GeneratesCounter.php +++ b/app/Utils/Traits/GeneratesCounter.php @@ -643,7 +643,7 @@ trait GeneratesCounter } $search = ['{$year}']; - $replace = [date('Y')]; + $replace = [Carbon::now($entity->company->timezone()->name)->format('Y')]; $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; From e989644718ff885a19d727f64201494f231908cb Mon Sep 17 00:00:00 2001 From: = Date: Mon, 2 May 2022 12:07:55 +1000 Subject: [PATCH 05/16] Round appropriately for paypal --- app/PaymentDrivers/PayPalExpressPaymentDriver.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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, From d7d3c8d591bdcc343907953dcb0bba5e3641b403 Mon Sep 17 00:00:00 2001 From: = Date: Mon, 2 May 2022 12:50:55 +1000 Subject: [PATCH 06/16] Fixes for generates counter --- app/Utils/Traits/GeneratesCounter.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/app/Utils/Traits/GeneratesCounter.php b/app/Utils/Traits/GeneratesCounter.php index a1a10bd2f392..d8bce41b7d83 100644 --- a/app/Utils/Traits/GeneratesCounter.php +++ b/app/Utils/Traits/GeneratesCounter.php @@ -642,9 +642,12 @@ trait GeneratesCounter return $counter; } - $search = ['{$year}']; - $replace = [Carbon::now($entity->company->timezone()->name)->format('Y')]; - + $search = []; + $replace = []; + + // $search = ['{$year}']; + //$replace = [Carbon::now($entity->company->timezone()->name)->format('Y')]; + $search[] = '{$counter}'; $replace[] = $counter; @@ -658,7 +661,7 @@ trait GeneratesCounter $replace[] = $counter; $search[] = '{$year}'; - $replace = [Carbon::now($entity->company->timezone()->name)->format('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; From 623fbdb2297a5e9028d66deeda84182619fe9280 Mon Sep 17 00:00:00 2001 From: = Date: Tue, 3 May 2022 09:00:07 +1000 Subject: [PATCH 07/16] Update trial plans --- app/Http/Controllers/ClientPortal/NinjaPlanController.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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(); } From 342cc10bc24eefced172495f8840b6b3214031d3 Mon Sep 17 00:00:00 2001 From: = Date: Tue, 3 May 2022 09:04:44 +1000 Subject: [PATCH 08/16] Check is_large flag when creating a new company --- app/Http/Controllers/CompanyController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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]); } From c7a9e2bac706841759635c62264ec57a2bc8b3fb Mon Sep 17 00:00:00 2001 From: = Date: Tue, 3 May 2022 09:33:18 +1000 Subject: [PATCH 09/16] Fixes for generates counter --- app/Utils/Traits/GeneratesConvertedQuoteCounter.php | 6 +++--- app/Utils/Traits/GeneratesCounter.php | 5 +---- 2 files changed, 4 insertions(+), 7 deletions(-) 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 d8bce41b7d83..b9606621246a 100644 --- a/app/Utils/Traits/GeneratesCounter.php +++ b/app/Utils/Traits/GeneratesCounter.php @@ -645,9 +645,6 @@ trait GeneratesCounter $search = []; $replace = []; - // $search = ['{$year}']; - //$replace = [Carbon::now($entity->company->timezone()->name)->format('Y')]; - $search[] = '{$counter}'; $replace[] = $counter; @@ -661,7 +658,7 @@ trait GeneratesCounter $replace[] = $counter; $search[] = '{$year}'; - $replace[] = [Carbon::now($entity->company->timezone()->name)->format('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; From 854141ede86f282ec598536c405cd2175a63a167 Mon Sep 17 00:00:00 2001 From: = Date: Tue, 3 May 2022 09:45:40 +1000 Subject: [PATCH 10/16] Logging for gmail notifications --- app/Models/Account.php | 3 +++ 1 file changed, 3 insertions(+) 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}"))) { From 2dca66d23c1566938b1bc84aef7fdc38f17bbb24 Mon Sep 17 00:00:00 2001 From: = Date: Tue, 3 May 2022 09:51:53 +1000 Subject: [PATCH 11/16] Additional fixes for client payment failure mails --- app/Jobs/Mail/PaymentFailedMailer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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(); From f09e460fc4dcb76bf2994545ab55555dfcbbc35a Mon Sep 17 00:00:00 2001 From: = Date: Tue, 3 May 2022 14:43:46 +1000 Subject: [PATCH 12/16] Bail early --- app/Http/Requests/Account/CreateAccountRequest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 [ From d9ec77003dd8e82f86ef172dff9d806f67f75e4b Mon Sep 17 00:00:00 2001 From: David Bomba Date: Tue, 3 May 2022 17:24:35 +1000 Subject: [PATCH 13/16] Fixes for missing properties --- app/Jobs/Company/CompanyImport.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/Jobs/Company/CompanyImport.php b/app/Jobs/Company/CompanyImport.php index d614d5775bff..396ff88d34ae 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}; } From 352a1fc1c0af5887bb8d662bf4d5da8915f0a779 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Wed, 4 May 2022 08:35:36 +1000 Subject: [PATCH 14/16] Handle edge case where removed user tries to log into the system --- app/Http/Controllers/Auth/LoginController.php | 3 ++ app/Models/InvoiceInvitation.php | 32 ------------------- 2 files changed, 3 insertions(+), 32 deletions(-) diff --git a/app/Http/Controllers/Auth/LoginController.php b/app/Http/Controllers/Auth/LoginController.php index bf57f96ae966..42959015863b 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()); 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; From 0ae42195b2076c8c4d3733a6a7114cdc828c7d04 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Wed, 4 May 2022 08:39:54 +1000 Subject: [PATCH 15/16] Handle edge case where removed user tries to log into the system --- app/Http/Controllers/Auth/LoginController.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/app/Http/Controllers/Auth/LoginController.php b/app/Http/Controllers/Auth/LoginController.php index 42959015863b..a4ea5f9b35a7 100644 --- a/app/Http/Controllers/Auth/LoginController.php +++ b/app/Http/Controllers/Auth/LoginController.php @@ -323,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) @@ -393,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()); @@ -444,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); @@ -499,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); @@ -558,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()); From 9c9d721866f91821d16893daa2b93559984bb9e8 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Wed, 4 May 2022 09:29:43 +1000 Subject: [PATCH 16/16] v5.3.85 --- VERSION.txt | 2 +- app/Jobs/Company/CompanyExport.php | 2 +- app/Jobs/Company/CompanyImport.php | 12 +++++++++--- config/ninja.php | 4 ++-- 4 files changed, 13 insertions(+), 7 deletions(-) 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/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 396ff88d34ae..da8f22a28c7b 100644 --- a/app/Jobs/Company/CompanyImport.php +++ b/app/Jobs/Company/CompanyImport.php @@ -1120,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/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', ''),