mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Stubs for sending edocs
This commit is contained in:
parent
ac5718b6e8
commit
9f7ff7dc59
@ -48,6 +48,7 @@ class NinjaMailerJob implements ShouldQueue
|
|||||||
use MakesHash;
|
use MakesHash;
|
||||||
|
|
||||||
public $tries = 4; //number of retries
|
public $tries = 4; //number of retries
|
||||||
|
|
||||||
public $deleteWhenMissingModels = true;
|
public $deleteWhenMissingModels = true;
|
||||||
|
|
||||||
/** @var null|\App\Models\Company $company **/
|
/** @var null|\App\Models\Company $company **/
|
||||||
|
@ -294,6 +294,17 @@ class BaseModel extends Model
|
|||||||
if ($subscriptions) {
|
if ($subscriptions) {
|
||||||
WebhookHandler::dispatch($event_id, $this->withoutRelations(), $this->company, $additional_data);
|
WebhookHandler::dispatch($event_id, $this->withoutRelations(), $this->company, $additional_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// special catch here for einvoicing eventing
|
||||||
|
if($event_id == Webhook::EVENT_SENT_INVOICE && $this->e_invoice){
|
||||||
|
$this->handleEinvoiceSending();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private function handleEinvoiceSending()
|
||||||
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
68
app/Services/EDocument/Jobs/SendEDocument.php
Normal file
68
app/Services/EDocument/Jobs/SendEDocument.php
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Invoice Ninja (https://invoiceninja.com).
|
||||||
|
*
|
||||||
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||||
|
*
|
||||||
|
* @copyright Copyright (c) 2024. Invoice Ninja LLC (https://invoiceninja.com)
|
||||||
|
*
|
||||||
|
* @license https://www.elastic.co/licensing/elastic-license
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace App\Services\EDocument\Jobes;
|
||||||
|
|
||||||
|
use App\Libraries\MultiDB;
|
||||||
|
use Illuminate\Bus\Queueable;
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
use Illuminate\Foundation\Bus\Dispatchable;
|
||||||
|
use Illuminate\Queue\Middleware\WithoutOverlapping;
|
||||||
|
|
||||||
|
class SendEDocument implements ShouldQueue
|
||||||
|
{
|
||||||
|
use Dispatchable;
|
||||||
|
use InteractsWithQueue;
|
||||||
|
use Queueable;
|
||||||
|
use SerializesModels;
|
||||||
|
|
||||||
|
public $tries = 2;
|
||||||
|
|
||||||
|
public $deleteWhenMissingModels = true;
|
||||||
|
|
||||||
|
public function __construct(private string $entity, private int $id, private string $db)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public function backoff()
|
||||||
|
{
|
||||||
|
return [rand(5, 29), rand(30, 59)];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function handle()
|
||||||
|
{
|
||||||
|
MultiDB::setDB($this->db);
|
||||||
|
|
||||||
|
$model = $this->entity::find($this->id);
|
||||||
|
$e_invoice_standard = $model->client ? $model->client->getSetting('e_invoice_type') : $model->company->getSetting('e_invoice_type');
|
||||||
|
|
||||||
|
if($e_invoice_standard != 'PEPPOL')
|
||||||
|
return;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function failed($exception = null)
|
||||||
|
{
|
||||||
|
if ($exception) {
|
||||||
|
nlog("EXCEPTION:: SENDEDOCUMENT::");
|
||||||
|
nlog($exception->getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
config(['queue.failed.driver' => null]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function middleware()
|
||||||
|
{
|
||||||
|
return [new WithoutOverlapping($this->entity.$this->id.$this->db)];
|
||||||
|
}
|
||||||
|
}
|
@ -646,7 +646,7 @@ class Email implements ShouldQueue
|
|||||||
|
|
||||||
$user = $this->resolveSendingUser();
|
$user = $this->resolveSendingUser();
|
||||||
|
|
||||||
$sending_email = (isset($this->email_object->settings->custom_sending_email) && stripos($this->email_object->settings->custom_sending_email, "@")) ? $this->email_object->settings->custom_sending_email : $user->email;
|
$sending_email = (isset($this->email_object->settings->custom_sending_email) && (stripos($this->email_object->settings->custom_sending_email, "@")) !== false) ? $this->email_object->settings->custom_sending_email : $user->email;
|
||||||
$sending_user = (isset($this->email_object->settings->email_from_name) && strlen($this->email_object->settings->email_from_name) > 2) ? $this->email_object->settings->email_from_name : $user->name();
|
$sending_user = (isset($this->email_object->settings->email_from_name) && strlen($this->email_object->settings->email_from_name) > 2) ? $this->email_object->settings->email_from_name : $user->name();
|
||||||
|
|
||||||
$this->mailable
|
$this->mailable
|
||||||
|
Loading…
x
Reference in New Issue
Block a user