1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 13:12:50 +01:00

Fixes for invoice observer

This commit is contained in:
David Bomba 2021-10-07 17:34:23 +11:00
parent 20bfc999d0
commit 40a90c4ea8
2 changed files with 14 additions and 7 deletions

View File

@ -34,9 +34,11 @@ class InvoiceObserver
->where('event_id', Webhook::EVENT_CREATE_INVOICE)
->exists();
$invoice->load('client');
if ($subscriptions) {
$invoice->load('client');
WebhookHandler::dispatch(Webhook::EVENT_CREATE_INVOICE, $invoice, $invoice->company);
}
}
@ -53,11 +55,14 @@ class InvoiceObserver
->where('event_id', Webhook::EVENT_UPDATE_INVOICE)
->exists();
$invoice->load('client');
if ($subscriptions) {
$invoice->load('client');
WebhookHandler::dispatch(Webhook::EVENT_UPDATE_INVOICE, $invoice, $invoice->company);
}
}
@ -75,6 +80,9 @@ class InvoiceObserver
->exists();
if ($subscriptions) {
$invoice->load('client');
WebhookHandler::dispatch(Webhook::EVENT_DELETE_INVOICE, $invoice, $invoice->company);
}
}

View File

@ -174,10 +174,6 @@ class BaseRepository
if(array_key_exists('client_id', $data))
$model->client_id = $data['client_id'];
//pickup changes here to recalculate reminders
//if($model instanceof Invoice && ($model->isDirty('date') || $model->isDirty('due_date')))
// $model->service()->setReminder()->save();
$client = Client::where('id', $model->client_id)->withTrashed()->first();
$state = [];
@ -210,7 +206,10 @@ class BaseRepository
$model->custom_surcharge_tax3 = $client->company->custom_surcharge_taxes3;
$model->custom_surcharge_tax4 = $client->company->custom_surcharge_taxes4;
$model->saveQuietly();
if(!$model->id)
$model->save();
else
$model->saveQuietly();
/* Model now persisted, now lets do some child tasks */