diff --git a/app/Http/Controllers/ClientPortal/InvitationController.php b/app/Http/Controllers/ClientPortal/InvitationController.php index 9f89fd780948..e5e5f9d21e62 100644 --- a/app/Http/Controllers/ClientPortal/InvitationController.php +++ b/app/Http/Controllers/ClientPortal/InvitationController.php @@ -45,7 +45,7 @@ class InvitationController extends Controller auth()->guard('contact')->login($invitation->contact, false); } - if(!request()->has('is_admin')){ + if(!request()->has('silent')){ $invitation->markViewed(); diff --git a/app/Http/Requests/Company/StoreCompanyRequest.php b/app/Http/Requests/Company/StoreCompanyRequest.php index b1deefebe641..69bc29b31a82 100644 --- a/app/Http/Requests/Company/StoreCompanyRequest.php +++ b/app/Http/Requests/Company/StoreCompanyRequest.php @@ -13,6 +13,7 @@ namespace App\Http\Requests\Company; use App\DataMapper\CompanySettings; use App\Http\Requests\Request; +use App\Http\ValidationRules\Company\ValidCompanyQuantity; use App\Http\ValidationRules\ValidSettingsRule; use App\Models\ClientContact; use App\Models\Company; @@ -36,7 +37,7 @@ class StoreCompanyRequest extends Request { $rules = []; - //$rules['name'] = 'required'; + $rules['name'] = new ValidCompanyQuantity(); $rules['company_logo'] = 'mimes:jpeg,jpg,png,gif|max:10000'; // max 10000kb $rules['settings'] = new ValidSettingsRule(); diff --git a/app/Http/ValidationRules/Company/ValidCompanyQuantity.php b/app/Http/ValidationRules/Company/ValidCompanyQuantity.php new file mode 100644 index 000000000000..fe0a754f9509 --- /dev/null +++ b/app/Http/ValidationRules/Company/ValidCompanyQuantity.php @@ -0,0 +1,44 @@ +user()->company()->account->companies->count() <= 10; + + } + + /** + * @return string + */ + public function message() + { + return "Limit of 10 companies per account."; + } + + +} diff --git a/app/Listeners/Misc/InvitationViewedListener.php b/app/Listeners/Misc/InvitationViewedListener.php index 749cb7cffc9c..862652011573 100644 --- a/app/Listeners/Misc/InvitationViewedListener.php +++ b/app/Listeners/Misc/InvitationViewedListener.php @@ -49,7 +49,7 @@ class InvitationViewedListener implements ShouldQueue /*** Check for Mail notifications***/ $all_user_notifications = ''; - if($event->entity->user_id == $company_user->user_id || $event->entity->assigned_user_id == $company_user->user_id) + if($invitation->{$entity_name}->user_id == $company_user->user_id || $invitation->{$entity_name}->assigned_user_id == $company_user->user_id) $all_user_notifications = "all_user_notifications"; $possible_permissions = [$entity_viewed, "all_notifications", $all_user_notifications]; diff --git a/app/Notifications/Admin/EntityViewedNotification.php b/app/Notifications/Admin/EntityViewedNotification.php index 2387b31b7969..27fffeb36924 100644 --- a/app/Notifications/Admin/EntityViewedNotification.php +++ b/app/Notifications/Admin/EntityViewedNotification.php @@ -43,7 +43,7 @@ class EntityViewedNotification extends Notification implements ShouldQueue $this->settings = $this->entity->client->getMergedSettings(); $this->is_system = $is_system; $this->invitation = $invitation; - + $this->method = null; } /** @@ -55,7 +55,7 @@ class EntityViewedNotification extends Notification implements ShouldQueue public function via($notifiable) { - return $this->method; + return $this->method ?: []; } @@ -138,7 +138,7 @@ class EntityViewedNotification extends Notification implements ShouldQueue 'client' => $this->contact->present()->name(), $this->entity_name => $this->entity->number, ]), - 'url' => config('ninja.site_url') . "/{$this->entity_name}s/" . $this->entity->hashed_id, + 'url' => config('ninja.site_url') . "/client/{$this->entity_name}/" . $this->invitation->key . "?silent=true", 'button' => ctrans("texts.view_{$this->entity_name}"), 'signature' => $this->settings->email_signature, 'logo' => $this->company->present()->logo(), diff --git a/app/Policies/UserPolicy.php b/app/Policies/UserPolicy.php index 7e20262c201a..9b7323560042 100644 --- a/app/Policies/UserPolicy.php +++ b/app/Policies/UserPolicy.php @@ -41,7 +41,7 @@ class UserPolicy extends EntityPolicy */ public function edit(User $user, $user_entity) : bool { - $company_user = CompanyUser::whereUserId($user_entity->id)->company()->first(); + $company_user = CompanyUser::whereUserId($user->id)->company()->first(); return ($user->isAdmin() && $company_user); } diff --git a/app/Services/Invoice/ApplyPayment.php b/app/Services/Invoice/ApplyPayment.php index a99bba072b11..e005424e3ac0 100644 --- a/app/Services/Invoice/ApplyPayment.php +++ b/app/Services/Invoice/ApplyPayment.php @@ -60,7 +60,7 @@ class ApplyPayment extends AbstractService } elseif ($this->payment_amount == $this->invoice->balance) { //total invoice paid. $this->invoice->service()->clearPartial()->setStatus(Invoice::STATUS_PAID)->updateBalance($this->payment_amount*-1); } elseif($this->payment_amount < $this->invoice->balance) { //partial invoice payment made - $this->invoice->service()->clearPartial()->updateBalance($this->payment_amount*-1); + $this->invoice->service()->clearPartial()->setStatus(Invoice::STATUS_PARTIAL)->updateBalance($this->payment_amount*-1); } return $this->invoice; diff --git a/app/Services/Notification/NotificationService.php b/app/Services/Notification/NotificationService.php index b7c080ac0e86..6865a53130a4 100644 --- a/app/Services/Notification/NotificationService.php +++ b/app/Services/Notification/NotificationService.php @@ -23,15 +23,15 @@ class NotificationService extends AbstractService const ALL_USER = 'all_user_notifications'; - const PAYMENT_SUCCESS = 'payment_success'; + const PAYMENT_SUCCESS = 'payment_success'; //@todo - const PAYMENT_FAILURE = 'payment_failure'; + const PAYMENT_FAILURE = 'payment_failure'; //@todo - const INVOICE_SENT = 'invoice_sent'; + const INVOICE_SENT = 'invoice_sent'; //@todo - const QUOTE_SENT = 'quote_sent'; + const QUOTE_SENT = 'quote_sent'; //@todo - const CREDIT_SENT = 'credit_sent'; + const CREDIT_SENT = 'credit_sent'; //@todo const QUOTE_VIEWED = 'quote_viewed'; @@ -39,7 +39,7 @@ class NotificationService extends AbstractService const CREDIT_VIEWED = 'credit_viewed'; - const QUOTE_APPROVED = 'quote_approved'; + const QUOTE_APPROVED = 'quote_approved'; //@todo public $company; diff --git a/app/Utils/Traits/Inviteable.php b/app/Utils/Traits/Inviteable.php index e26b221d46f7..f71a75b3c5bb 100644 --- a/app/Utils/Traits/Inviteable.php +++ b/app/Utils/Traits/Inviteable.php @@ -71,6 +71,6 @@ trait Inviteable public function getAdminLink() :string { - return $this->getLink(). '?is_admin=true'; + return $this->getLink(). '?silent=true'; } } diff --git a/database/seeds/PaymentTypesSeeder.php b/database/seeds/PaymentTypesSeeder.php index 3c05dd9c49b9..4a76e05e8d0c 100644 --- a/database/seeds/PaymentTypesSeeder.php +++ b/database/seeds/PaymentTypesSeeder.php @@ -26,7 +26,7 @@ class PaymentTypesSeeder extends Seeder Eloquent::unguard(); $paymentTypes = [ - ['name' => 'Apply Credit'], +// ['name' => 'Apply Credit'], ['name' => 'Bank Transfer', 'gateway_type_id' => self::GATEWAY_TYPE_BANK_TRANSFER], ['name' => 'Cash'], ['name' => 'Debit', 'gateway_type_id' => self::GATEWAY_TYPE_CREDIT_CARD],