diff --git a/app/Models/Invoice.php b/app/Models/Invoice.php index 08b89b2929..570d14e28d 100644 --- a/app/Models/Invoice.php +++ b/app/Models/Invoice.php @@ -2,6 +2,10 @@ namespace App\Models; +use App\Events\InvoiceWasCreated; +use App\Events\InvoiceWasUpdated; +use App\Events\QuoteWasCreated; +use App\Events\QuoteWasUpdated; use App\Events\InvoiceInvitationWasEmailed; use App\Events\QuoteInvitationWasEmailed; use App\Libraries\CurlUtils; @@ -1518,3 +1522,19 @@ Invoice::creating(function ($invoice) { $invoice->account->incrementCounter($invoice); } }); + +Invoice::created(function ($invoice) { + if ($invoice->isType(INVOICE_TYPE_QUOTE)) { + event(new QuoteWasCreated($invoice)); + } else { + event(new InvoiceWasCreated($invoice)); + } +}); + +Invoice::updating(function ($invoice) { + if ($invoice->isType(INVOICE_TYPE_QUOTE)) { + event(new QuoteWasUpdated($invoice)); + } else { + event(new InvoiceWasUpdated($invoice)); + } +}); diff --git a/app/Ninja/Repositories/InvoiceRepository.php b/app/Ninja/Repositories/InvoiceRepository.php index 4ee96b02d1..0929c74410 100644 --- a/app/Ninja/Repositories/InvoiceRepository.php +++ b/app/Ninja/Repositories/InvoiceRepository.php @@ -697,7 +697,7 @@ class InvoiceRepository extends BaseRepository $invoice = $this->saveInvitations($invoice); } - $this->dispachEvents($invoice); + //$this->dispachEvents($invoice); return $invoice; }