mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Merge pull request #6818 from turbo124/v5-develop
Trigger model created event manually after model calculations have been performed
This commit is contained in:
commit
1de7b0077f
@ -58,6 +58,10 @@ class StoreDesignRequest extends Request
|
|||||||
$input['design']['header'] = '';
|
$input['design']['header'] = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (! array_key_exists('body', $input['design']) || is_null($input['design']['body'])) {
|
||||||
|
$input['design']['body'] = '';
|
||||||
|
}
|
||||||
|
|
||||||
$this->replace($input);
|
$this->replace($input);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -57,6 +57,10 @@ class UpdateDesignRequest extends Request
|
|||||||
$input['design']['header'] = '';
|
$input['design']['header'] = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (! array_key_exists('body', $input['design']) || is_null($input['design']['body'])) {
|
||||||
|
$input['design']['body'] = '';
|
||||||
|
}
|
||||||
|
|
||||||
$this->replace($input);
|
$this->replace($input);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -64,12 +64,12 @@ class SupportMessageSent extends Mailable
|
|||||||
$db = str_replace("db-ninja-", "", $company->db);
|
$db = str_replace("db-ninja-", "", $company->db);
|
||||||
$is_large = $company->is_large ? "L" : "S";
|
$is_large = $company->is_large ? "L" : "S";
|
||||||
$platform = array_key_exists('platform', $this->data) ? $this->data['platform'] : "U";
|
$platform = array_key_exists('platform', $this->data) ? $this->data['platform'] : "U";
|
||||||
$migrated = strlen($company->company_key) == 32 ? "M" : "T";
|
$migrated = strlen($company->company_key) == 32 ? "M" : "";
|
||||||
|
|
||||||
if(Ninja::isHosted())
|
if(Ninja::isHosted())
|
||||||
$subject = "{$priority}Hosted-{$db}-{$is_large}{$platform}{$migrated} :: {$plan} :: ".date('M jS, g:ia');
|
$subject = "{$priority}Hosted-{$db}-{$is_large}{$platform}{$migrated} :: {$plan} :: ".date('M jS, g:ia');
|
||||||
else
|
else
|
||||||
$subject = "{$priority}Self Hosted :: {$plan}{$platform} :: ".date('M jS, g:ia');
|
$subject = "{$priority}Self Hosted :: {$plan} :: {$platform} :: ".date('M jS, g:ia');
|
||||||
|
|
||||||
return $this->from(config('mail.from.address'), $user->present()->name())
|
return $this->from(config('mail.from.address'), $user->present()->name())
|
||||||
->replyTo($user->email, $user->present()->name())
|
->replyTo($user->email, $user->present()->name())
|
||||||
|
@ -84,9 +84,9 @@ class Client extends BaseModel implements HasLocalePreference
|
|||||||
];
|
];
|
||||||
|
|
||||||
protected $with = [
|
protected $with = [
|
||||||
// 'gateway_tokens',
|
'gateway_tokens',
|
||||||
// 'documents',
|
'documents',
|
||||||
// 'contacts.company',
|
'contacts.company',
|
||||||
// 'currency',
|
// 'currency',
|
||||||
// 'primary_contact',
|
// 'primary_contact',
|
||||||
// 'country',
|
// 'country',
|
||||||
|
@ -34,7 +34,6 @@ class InvoiceObserver
|
|||||||
->where('event_id', Webhook::EVENT_CREATE_INVOICE)
|
->where('event_id', Webhook::EVENT_CREATE_INVOICE)
|
||||||
->exists();
|
->exists();
|
||||||
|
|
||||||
|
|
||||||
if ($subscriptions) {
|
if ($subscriptions) {
|
||||||
|
|
||||||
$invoice->load('client');
|
$invoice->load('client');
|
||||||
|
@ -29,8 +29,9 @@ class BaseRepository
|
|||||||
use MakesHash;
|
use MakesHash;
|
||||||
use SavesDocuments;
|
use SavesDocuments;
|
||||||
|
|
||||||
public $import_mode = false;
|
public bool $import_mode = false;
|
||||||
|
|
||||||
|
private bool $new_model = false;
|
||||||
/**
|
/**
|
||||||
* @param $entity
|
* @param $entity
|
||||||
* @param $type
|
* @param $type
|
||||||
@ -207,9 +208,9 @@ class BaseRepository
|
|||||||
$model->custom_surcharge_tax4 = $client->company->custom_surcharge_taxes4;
|
$model->custom_surcharge_tax4 = $client->company->custom_surcharge_taxes4;
|
||||||
|
|
||||||
if(!$model->id)
|
if(!$model->id)
|
||||||
$model->save();
|
$this->new_model = true;
|
||||||
else
|
|
||||||
$model->saveQuietly();
|
$model->saveQuietly();
|
||||||
|
|
||||||
/* Model now persisted, now lets do some child tasks */
|
/* Model now persisted, now lets do some child tasks */
|
||||||
|
|
||||||
@ -323,6 +324,9 @@ class BaseRepository
|
|||||||
//links tasks and expenses back to the invoice.
|
//links tasks and expenses back to the invoice.
|
||||||
$model->service()->linkEntities()->save();
|
$model->service()->linkEntities()->save();
|
||||||
|
|
||||||
|
if($this->new_model)
|
||||||
|
event('eloquent.created: App\Models\Invoice', $model);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($model instanceof Credit) {
|
if ($model instanceof Credit) {
|
||||||
@ -331,7 +335,10 @@ class BaseRepository
|
|||||||
|
|
||||||
if (! $model->design_id)
|
if (! $model->design_id)
|
||||||
$model->design_id = $this->decodePrimaryKey($client->getSetting('credit_design_id'));
|
$model->design_id = $this->decodePrimaryKey($client->getSetting('credit_design_id'));
|
||||||
|
|
||||||
|
|
||||||
|
if($this->new_model)
|
||||||
|
event('eloquent.created: App\Models\Credit', $model);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($model instanceof Quote) {
|
if ($model instanceof Quote) {
|
||||||
@ -341,6 +348,10 @@ class BaseRepository
|
|||||||
|
|
||||||
$model = $model->calc()->getQuote();
|
$model = $model->calc()->getQuote();
|
||||||
|
|
||||||
|
|
||||||
|
if($this->new_model)
|
||||||
|
event('eloquent.created: App\Models\Quote', $model);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($model instanceof RecurringInvoice) {
|
if ($model instanceof RecurringInvoice) {
|
||||||
@ -350,6 +361,9 @@ class BaseRepository
|
|||||||
|
|
||||||
$model = $model->calc()->getRecurringInvoice();
|
$model = $model->calc()->getRecurringInvoice();
|
||||||
|
|
||||||
|
|
||||||
|
if($this->new_model)
|
||||||
|
event('eloquent.created: App\Models\RecurringInvoice', $model);
|
||||||
}
|
}
|
||||||
|
|
||||||
$model->save();
|
$model->save();
|
||||||
|
@ -155,7 +155,7 @@ class CreditService
|
|||||||
*/
|
*/
|
||||||
public function save() : ?Credit
|
public function save() : ?Credit
|
||||||
{
|
{
|
||||||
$this->credit->save();
|
$this->credit->saveQuietly();
|
||||||
|
|
||||||
return $this->credit;
|
return $this->credit;
|
||||||
}
|
}
|
||||||
|
@ -490,7 +490,7 @@ class InvoiceService
|
|||||||
*/
|
*/
|
||||||
public function save() :?Invoice
|
public function save() :?Invoice
|
||||||
{
|
{
|
||||||
$this->invoice->save();
|
$this->invoice->saveQuietly();
|
||||||
|
|
||||||
return $this->invoice;
|
return $this->invoice;
|
||||||
}
|
}
|
||||||
|
@ -202,7 +202,7 @@ class QuoteService
|
|||||||
*/
|
*/
|
||||||
public function save() : ?Quote
|
public function save() : ?Quote
|
||||||
{
|
{
|
||||||
$this->quote->save();
|
$this->quote->saveQuietly();
|
||||||
|
|
||||||
return $this->quote;
|
return $this->quote;
|
||||||
}
|
}
|
||||||
|
@ -105,7 +105,7 @@ class RecurringService
|
|||||||
|
|
||||||
public function save()
|
public function save()
|
||||||
{
|
{
|
||||||
$this->recurring_entity->save();
|
$this->recurring_entity->saveQuietly();
|
||||||
|
|
||||||
return $this->recurring_entity;
|
return $this->recurring_entity;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user