diff --git a/app/Http/Controllers/InvoiceController.php b/app/Http/Controllers/InvoiceController.php index c9df6ee849..39e807126e 100644 --- a/app/Http/Controllers/InvoiceController.php +++ b/app/Http/Controllers/InvoiceController.php @@ -733,7 +733,7 @@ class InvoiceController extends BaseController } break; case 'mark_sent': - $invoice->service()->markSent()->save(); + $invoice->service()->markSent(true)->save(); if (! $bulk) { return $this->itemResponse($invoice); diff --git a/app/Services/Invoice/InvoiceService.php b/app/Services/Invoice/InvoiceService.php index 6905bd03e6..bdc770c782 100644 --- a/app/Services/Invoice/InvoiceService.php +++ b/app/Services/Invoice/InvoiceService.php @@ -175,9 +175,9 @@ class InvoiceService return $this; } - public function markSent() + public function markSent($fire_event = false) { - $this->invoice = (new MarkSent($this->invoice->client, $this->invoice))->run(); + $this->invoice = (new MarkSent($this->invoice->client, $this->invoice))->run($fire_event); $this->setExchangeRate(); diff --git a/app/Services/Invoice/MarkSent.php b/app/Services/Invoice/MarkSent.php index 07bae6f986..1fc7db1773 100644 --- a/app/Services/Invoice/MarkSent.php +++ b/app/Services/Invoice/MarkSent.php @@ -30,7 +30,7 @@ class MarkSent extends AbstractService $this->invoice = $invoice; } - public function run() + public function run($fire_webhook = false) { /* Return immediately if status is not draft or invoice has been deleted */ @@ -68,6 +68,10 @@ class MarkSent extends AbstractService event(new InvoiceWasUpdated($this->invoice, $this->invoice->company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null))); + if($fire_webhook) + event('eloquent.updated: App\Models\Invoice', $this->invoice); + + return $this->invoice->fresh(); } } diff --git a/app/Services/Invoice/TriggeredActions.php b/app/Services/Invoice/TriggeredActions.php index 5f52483ad0..d31c35b9bb 100644 --- a/app/Services/Invoice/TriggeredActions.php +++ b/app/Services/Invoice/TriggeredActions.php @@ -48,7 +48,7 @@ class TriggeredActions extends AbstractService if ($this->request->has('mark_sent') && $this->request->input('mark_sent') == 'true' && $this->invoice->status_id == Invoice::STATUS_DRAFT) { $this->invoice = $this->invoice->service()->markSent()->save(); //update notification NOT sent - $this->updated = true; + $this->updated = false; } if ($this->request->has('amount_paid') && is_numeric($this->request->input('amount_paid'))) { diff --git a/resources/views/portal/ninja2020/layout/clean_setup.blade.php b/resources/views/portal/ninja2020/layout/clean_setup.blade.php index b734256dc6..66ab27da36 100644 --- a/resources/views/portal/ninja2020/layout/clean_setup.blade.php +++ b/resources/views/portal/ninja2020/layout/clean_setup.blade.php @@ -3,7 +3,7 @@
- @if ($company && $company->matomo_url && $company->matomo_id) + @if (isset($company) && $company->matomo_url && $company->matomo_id)