Clean up invoice activity records

This commit is contained in:
Hillel Coren 2017-01-06 12:36:46 +02:00
parent 06d5509805
commit 84ac76cff1
2 changed files with 13 additions and 0 deletions

View File

@ -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);

View File

@ -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