minor fixes for imports

This commit is contained in:
David Bomba 2020-11-17 10:04:10 +11:00
parent 5a6d543e34
commit a182c5a8ca
3 changed files with 14 additions and 7 deletions

View File

@ -66,7 +66,7 @@ class SendRemindersCron extends Command
->cursor(); ->cursor();
$invoices->each(function ($invoice){ $invoices->each(function ($invoice){
WebHookHandler::dispatch(Webhook::EVENT_LATE_INVOICE, $invoice); WebHookHandler::dispatch(Webhook::EVENT_LATE_INVOICE, $invoice, $invoice->company);
}); });
} }
@ -79,7 +79,7 @@ class SendRemindersCron extends Command
->cursor(); ->cursor();
$quotes->each(function ($quote){ $quotes->each(function ($quote){
WebHookHandler::dispatch(Webhook::EVENT_EXPIRED_QUOTE, $quote); WebHookHandler::dispatch(Webhook::EVENT_EXPIRED_QUOTE, $quote, $quote->company);
}); });
} }
} }

View File

@ -21,6 +21,7 @@ use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels; use Illuminate\Queue\SerializesModels;
use League\Fractal\Manager; use League\Fractal\Manager;
use League\Fractal\Resource\Item; use League\Fractal\Resource\Item;
use App\Libraries\MultiDB;
class WebhookHandler implements ShouldQueue class WebhookHandler implements ShouldQueue
{ {
@ -30,16 +31,18 @@ class WebhookHandler implements ShouldQueue
private $event_id; private $event_id;
private $company;
/** /**
* Create a new job instance. * Create a new job instance.
* *
* @param $event_id * @param $event_id
* @param $entity * @param $entity
*/ */
public function __construct($event_id, $entity) public function __construct($event_id, $entity, $company)
{ {
$this->event_id = $event_id; $this->event_id = $event_id;
$this->entity = $entity; $this->entity = $entity;
$this->company = $company;
} }
/** /**
@ -49,6 +52,9 @@ class WebhookHandler implements ShouldQueue
*/ */
public function handle() :bool public function handle() :bool
{//todo set multidb here {//todo set multidb here
MultiDB::setDb($this->company->db);
if (! $this->entity->company || $this->entity->company->is_disabled) { if (! $this->entity->company || $this->entity->company->is_disabled) {
return true; return true;
} }

View File

@ -138,10 +138,6 @@ class InvoiceMigrationRepository extends BaseRepository
$model = $model->service()->applyNumber()->save(); $model = $model->service()->applyNumber()->save();
if ($model->company->update_products !== false) {
UpdateOrCreateProduct::dispatch($model->line_items, $model, $model->company);
}
if ($class->name == Invoice::class || $class->name == RecurringInvoice::class) { if ($class->name == Invoice::class || $class->name == RecurringInvoice::class) {
if (($state['finished_amount'] != $state['starting_amount']) && ($model->status_id != Invoice::STATUS_DRAFT)) { if (($state['finished_amount'] != $state['starting_amount']) && ($model->status_id != Invoice::STATUS_DRAFT)) {
@ -152,6 +148,11 @@ class InvoiceMigrationRepository extends BaseRepository
if (! $model->design_id) { if (! $model->design_id) {
$model->design_id = $this->decodePrimaryKey($client->getSetting('invoice_design_id')); $model->design_id = $this->decodePrimaryKey($client->getSetting('invoice_design_id'));
} }
if ($model->company->update_products !== false) {
UpdateOrCreateProduct::dispatchNow($model->line_items, $model, $model->company);
}
} }
if ($class->name == Credit::class) { if ($class->name == Credit::class) {