diff --git a/app/Http/Livewire/SubscriptionInvoicesTable.php b/app/Http/Livewire/SubscriptionInvoicesTable.php index 787662596ddf..4c5a56355fca 100644 --- a/app/Http/Livewire/SubscriptionInvoicesTable.php +++ b/app/Http/Livewire/SubscriptionInvoicesTable.php @@ -30,6 +30,7 @@ class SubscriptionInvoicesTable extends Component ->where('client_id', auth('contact')->user()->client->id) ->whereNotNull('subscription_id') ->orderBy($this->sort_field, $this->sort_asc ? 'asc' : 'desc') + ->where('balance', '=', 0) ->paginate($this->per_page); return render('components.livewire.subscriptions-invoices-table', [ diff --git a/app/Services/Subscription/SubscriptionService.php b/app/Services/Subscription/SubscriptionService.php index d78a530247c2..4178cbfba3f3 100644 --- a/app/Services/Subscription/SubscriptionService.php +++ b/app/Services/Subscription/SubscriptionService.php @@ -122,7 +122,8 @@ class SubscriptionService 'context' => 'is_eligible', 'subscription' => $this->subscription->hashed_id, 'contact' => $contact->hashed_id, - 'contact_email' => $contact->email + 'contact_email' => $contact->email, + 'client' => $contact->client->hashed_id, ]; $response = $this->triggerWebhook($context); @@ -277,4 +278,28 @@ class SubscriptionService { return Product::whereIn('id', $this->transformKeys(explode(",", $this->subscription->recurring_product_ids)))->get(); } + + /** + * Get available upgrades & downgrades for the plan. + * + * @return \Illuminate\Database\Eloquent\Builder[]|\Illuminate\Database\Eloquent\Collection + */ + public function getPlans() + { + return Subscription::query() + ->where('company_id', $this->subscription->company_id) + ->where('group_id', $this->subscription->group_id) + ->where('id', '!=', $this->subscription->id) + ->get(); + } + + public function completePlanChange(PaymentHash $paymentHash) + { + // .. handle redirect, after upgrade redirects, etc.. + } + + public function handleCancellation() + { + // .. + } } diff --git a/resources/lang/en/texts.php b/resources/lang/en/texts.php index 408d8a4add7b..f1668102b436 100644 --- a/resources/lang/en/texts.php +++ b/resources/lang/en/texts.php @@ -4202,6 +4202,7 @@ $LANG = array( 'invoice_task_datelog_help' => 'Add date details to the invoice line items', 'promo_code' => 'Promo code', 'recurring_invoice_issued_to' => 'Recurring invoice issued to', + 'subscription' => 'Subscription', ); return $LANG; diff --git a/resources/views/portal/ninja2020/components/livewire/subscriptions-invoices-table.blade.php b/resources/views/portal/ninja2020/components/livewire/subscriptions-invoices-table.blade.php index 086b4d0b6a52..5e821756fea7 100644 --- a/resources/views/portal/ninja2020/components/livewire/subscriptions-invoices-table.blade.php +++ b/resources/views/portal/ninja2020/components/livewire/subscriptions-invoices-table.blade.php @@ -19,6 +19,11 @@