diff --git a/app/Listeners/ActivityListener.php b/app/Listeners/ActivityListener.php index 55056453eb7b..2a3985f54ff6 100644 --- a/app/Listeners/ActivityListener.php +++ b/app/Listeners/ActivityListener.php @@ -127,6 +127,10 @@ class ActivityListener */ public function updatedInvoice(InvoiceWasUpdated $event) { + if (! $event->invoice->isChanged()) { + return; + } + $backupInvoice = Invoice::with('invoice_items', 'client.account', 'client.contacts') ->withTrashed() ->find($event->invoice->id); diff --git a/app/Models/Invoice.php b/app/Models/Invoice.php index a68a9527c212..fe6879efa292 100644 --- a/app/Models/Invoice.php +++ b/app/Models/Invoice.php @@ -190,6 +190,15 @@ class Invoice extends EntityModel implements BalanceAffecting return floatval($this->amount) - floatval($this->getOriginal('amount')); } + public function isChanged() + { + $dirty = $this->getDirty(); + + unset($dirty['invoice_status_id']); + + return count($dirty) > 0; + } + /** * @param bool $calculate * @return int|mixed