Fix for invoice items w/Zapier trigger
This commit is contained in:
parent
a2df6bdc51
commit
ae5ce395bd
2 changed files with 23 additions and 20 deletions
|
|
@ -3,11 +3,7 @@
|
|||
namespace App\Models;
|
||||
|
||||
use App\Events\InvoiceInvitationWasEmailed;
|
||||
use App\Events\InvoiceWasCreated;
|
||||
use App\Events\InvoiceWasUpdated;
|
||||
use App\Events\QuoteInvitationWasEmailed;
|
||||
use App\Events\QuoteWasCreated;
|
||||
use App\Events\QuoteWasUpdated;
|
||||
use App\Libraries\CurlUtils;
|
||||
use App\Models\Activity;
|
||||
use App\Models\Traits\ChargesFees;
|
||||
|
|
@ -1529,19 +1525,3 @@ 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));
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -2,6 +2,10 @@
|
|||
|
||||
namespace App\Ninja\Repositories;
|
||||
|
||||
use App\Events\InvoiceWasCreated;
|
||||
use App\Events\InvoiceWasUpdated;
|
||||
use App\Events\QuoteWasCreated;
|
||||
use App\Events\QuoteWasUpdated;
|
||||
use App\Jobs\SendInvoiceEmail;
|
||||
use App\Models\Account;
|
||||
use App\Models\Client;
|
||||
|
|
@ -693,6 +697,8 @@ class InvoiceRepository extends BaseRepository
|
|||
$invoice = $this->saveInvitations($invoice);
|
||||
}
|
||||
|
||||
$this->dispachEvents($invoice);
|
||||
|
||||
return $invoice;
|
||||
}
|
||||
|
||||
|
|
@ -734,6 +740,23 @@ class InvoiceRepository extends BaseRepository
|
|||
return $invoice;
|
||||
}
|
||||
|
||||
private function dispachEvents($invoice)
|
||||
{
|
||||
if ($invoice->isType(INVOICE_TYPE_QUOTE)) {
|
||||
if ($invoice->wasRecentlyCreated) {
|
||||
event(new QuoteWasCreated($invoice));
|
||||
} else {
|
||||
event(new QuoteWasUpdated($invoice));
|
||||
}
|
||||
} else {
|
||||
if ($invoice->wasRecentlyCreated) {
|
||||
event(new InvoiceWasCreated($invoice));
|
||||
} else {
|
||||
event(new InvoiceWasUpdated($invoice));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Invoice $invoice
|
||||
* @param null $quotePublicId
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue