mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-23 20:00:33 -04:00
Sending einvoices
This commit is contained in:
parent
73ed01a9bc
commit
52630f06e3
@ -70,7 +70,7 @@ class CreateEDocument implements ShouldQueue
|
|||||||
if ($this->document instanceof Invoice) {
|
if ($this->document instanceof Invoice) {
|
||||||
switch ($e_document_type) {
|
switch ($e_document_type) {
|
||||||
case "PEPPOL":
|
case "PEPPOL":
|
||||||
return (new Peppol($this->document))->toXml();
|
return (new Peppol($this->document))->run()->toXml();
|
||||||
case "FACT1":
|
case "FACT1":
|
||||||
return (new RoEInvoice($this->document))->generateXml();
|
return (new RoEInvoice($this->document))->generateXml();
|
||||||
case "FatturaPA":
|
case "FatturaPA":
|
||||||
|
@ -17,6 +17,7 @@ use App\Utils\Traits\MakesHash;
|
|||||||
use App\Jobs\Entity\CreateRawPdf;
|
use App\Jobs\Entity\CreateRawPdf;
|
||||||
use App\Jobs\Util\WebhookHandler;
|
use App\Jobs\Util\WebhookHandler;
|
||||||
use App\Models\Traits\Excludable;
|
use App\Models\Traits\Excludable;
|
||||||
|
use App\Services\EDocument\Jobes\SendEDocument;
|
||||||
use App\Services\PdfMaker\PdfMerge;
|
use App\Services\PdfMaker\PdfMerge;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use App\Utils\Traits\UserSessionAttributes;
|
use App\Utils\Traits\UserSessionAttributes;
|
||||||
@ -297,8 +298,8 @@ class BaseModel extends Model
|
|||||||
}
|
}
|
||||||
|
|
||||||
// special catch here for einvoicing eventing
|
// special catch here for einvoicing eventing
|
||||||
if($event_id == Webhook::EVENT_SENT_INVOICE && ($this instanceof Invoice) && $this->e_invoice){
|
if($event_id == Webhook::EVENT_SENT_INVOICE && ($this instanceof Invoice) && is_null($this->backup)){
|
||||||
// Einvoice
|
\App\Services\EDocument\Jobs\SendEDocument::dispatch(get_class($this), $this->id, $this->company->db);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
* @license https://www.elastic.co/licensing/elastic-license
|
* @license https://www.elastic.co/licensing/elastic-license
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace App\Services\EDocument\Jobes;
|
namespace App\Services\EDocument\Jobs;
|
||||||
|
|
||||||
use App\Utils\Ninja;
|
use App\Utils\Ninja;
|
||||||
use App\Models\Invoice;
|
use App\Models\Invoice;
|
||||||
@ -125,6 +125,9 @@ class SendEDocument implements ShouldQueue
|
|||||||
$activity->notes = $guid;
|
$activity->notes = $guid;
|
||||||
$activity->save();
|
$activity->save();
|
||||||
|
|
||||||
|
$model->backup = $guid;
|
||||||
|
$model->saveQuietly();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -272,7 +272,7 @@ class Peppol extends AbstractService
|
|||||||
|
|
||||||
if($this->invoice->e_invoice) {
|
if($this->invoice->e_invoice) {
|
||||||
|
|
||||||
$this->p_invoice = $this->e->decode('Peppol', json_encode($this->invoice->e_invoice->Invoice), 'json');
|
$this->p_invoice = $this->e->decode('Peppol', json_encode($this->invoice->e_invoice), 'json');
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
|
|
||||||
@ -331,6 +331,11 @@ class Peppol extends AbstractService
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function toObject(): mixed
|
||||||
|
{
|
||||||
|
return json_decode($this->toJson());
|
||||||
|
}
|
||||||
|
|
||||||
public function toArray(): array
|
public function toArray(): array
|
||||||
{
|
{
|
||||||
return json_decode($this->toJson(), true);
|
return json_decode($this->toJson(), true);
|
||||||
@ -356,6 +361,9 @@ class Peppol extends AbstractService
|
|||||||
$this->senderSpecificLevelMutators()
|
$this->senderSpecificLevelMutators()
|
||||||
->receiverSpecificLevelMutators();
|
->receiverSpecificLevelMutators();
|
||||||
|
|
||||||
|
$this->invoice->e_invoice = $this->toObject();
|
||||||
|
$this->invoice->save();
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user