Fixes for updateinvoice events

This commit is contained in:
David Bomba 2022-12-08 11:17:18 +11:00
parent dff9c9566c
commit 69a1419e9b
5 changed files with 10 additions and 6 deletions

View File

@ -733,7 +733,7 @@ class InvoiceController extends BaseController
} }
break; break;
case 'mark_sent': case 'mark_sent':
$invoice->service()->markSent()->save(); $invoice->service()->markSent(true)->save();
if (! $bulk) { if (! $bulk) {
return $this->itemResponse($invoice); return $this->itemResponse($invoice);

View File

@ -175,9 +175,9 @@ class InvoiceService
return $this; 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(); $this->setExchangeRate();

View File

@ -30,7 +30,7 @@ class MarkSent extends AbstractService
$this->invoice = $invoice; $this->invoice = $invoice;
} }
public function run() public function run($fire_webhook = false)
{ {
/* Return immediately if status is not draft or invoice has been deleted */ /* 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))); 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(); return $this->invoice->fresh();
} }
} }

View File

@ -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) { 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->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'))) { if ($this->request->has('amount_paid') && is_numeric($this->request->input('amount_paid'))) {

View File

@ -3,7 +3,7 @@
<head> <head>
<!-- Error: {{ session('error') }} --> <!-- Error: {{ session('error') }} -->
@if ($company && $company->matomo_url && $company->matomo_id) @if (isset($company) && $company->matomo_url && $company->matomo_id)
<script> <script>
var _paq = window._paq = window._paq || []; var _paq = window._paq = window._paq || [];
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */ /* tracker methods like "setCustomDimension" should be called before "trackPageView" */