diff --git a/app/Jobs/Entity/CreateEntityPdf.php b/app/Jobs/Entity/CreateEntityPdf.php index 58c60b7cb5..266437cd77 100644 --- a/app/Jobs/Entity/CreateEntityPdf.php +++ b/app/Jobs/Entity/CreateEntityPdf.php @@ -13,6 +13,7 @@ namespace App\Jobs\Entity; use App\Exceptions\FilePermissionsFailure; use App\Jobs\Invoice\CreateEInvoice; +use App\Jobs\Invoice\MergeEInvoice; use App\Libraries\MultiDB; use App\Models\Credit; use App\Models\CreditInvitation; @@ -214,6 +215,8 @@ class CreateEntityPdf implements ShouldQueue } if ($this->entity_string == "invoice" && $this->client->getSetting('enable_e_invoice')){ (new CreateEInvoice($this->entity))->handle(); + (new MergeEInvoice($this->entity))->handle(); + } $this->invitation = null; // $this->entity = null; diff --git a/app/Jobs/Invoice/ZipInvoices.php b/app/Jobs/Invoice/ZipInvoices.php index d8c1505434..c257e647cc 100644 --- a/app/Jobs/Invoice/ZipInvoices.php +++ b/app/Jobs/Invoice/ZipInvoices.php @@ -77,6 +77,7 @@ class ZipInvoices implements ShouldQueue (new CreateEntityPdf($invoice->invitations()->first()))->handle(); if ($invoice->client->getSetting('enable_e_invoice')){ (new CreateEInvoice($invoice))->handle(); + (new MergeEInvoice($invoice))->handle(); } }); diff --git a/app/Services/Invoice/GetInvoiceEInvoice.php b/app/Services/Invoice/GetInvoiceEInvoice.php index b3690eef60..66a4759fb6 100644 --- a/app/Services/Invoice/GetInvoiceEInvoice.php +++ b/app/Services/Invoice/GetInvoiceEInvoice.php @@ -44,6 +44,8 @@ class GetInvoiceEInvoice extends AbstractService if (! $file) { $file_path = (new CreateEInvoice($this->invoice))->handle(); + (new \App\Jobs\Invoice\MergeEInvoice($this->invoice))->handle(); + } return $file_path; diff --git a/app/Services/Invoice/InvoiceService.php b/app/Services/Invoice/InvoiceService.php index d8fc0f47d5..2e167561f7 100644 --- a/app/Services/Invoice/InvoiceService.php +++ b/app/Services/Invoice/InvoiceService.php @@ -468,6 +468,7 @@ class InvoiceService if ($invitation->invoice->client->getSetting('enable_e_invoice') && $invitation instanceof InvoiceInvitation) { (new CreateEInvoice($invitation->invoice))->handle(); + (new MergeEInvoice($invitation->invoice))->run(); } }); diff --git a/tests/Unit/EInvoiceTest.php b/tests/Unit/EInvoiceTest.php index 2a76d59718..41349c264b 100644 --- a/tests/Unit/EInvoiceTest.php +++ b/tests/Unit/EInvoiceTest.php @@ -42,9 +42,10 @@ class EInvoiceTest extends TestCase $this->company->e_invoice_type = "EN16931"; $this->invoice->client->routing_id = 'DE123456789'; $this->invoice->client->save(); - $xinvoice = (new CreateEInvoice($this->invoice))->handle(); - $this->assertNotNull($xinvoice); - $this->assertTrue(Storage::exists($xinvoice)); + $e_invoice = (new CreateEInvoice($this->invoice))->handle(); + (new \App\Jobs\Invoice\MergeEInvoice($this->invoice))->handle(); + $this->assertNotNull($e_invoice); + $this->assertTrue(Storage::exists($e_invoice)); } /** @@ -56,9 +57,8 @@ class EInvoiceTest extends TestCase $this->invoice->client->routing_id = 'DE123456789'; $this->invoice->client->save(); - $xinvoice = (new CreateEInvoice($this->invoice))->handle(); - nlog(Storage::path($xinvoice)); - $document = ZugferdDocumentReader::readAndGuessFromFile(Storage::path($xinvoice)); + $e_invoice = (new CreateEInvoice($this->invoice))->handle(); + $document = ZugferdDocumentReader::readAndGuessFromFile(Storage::path($e_invoice)); $document->getDocumentInformation($documentno, $documenttypecode, $documentdate, $documentcurrency, $taxcurrency, $taxname, $documentlangeuage, $rest); $this->assertEquals($this->invoice->number, $documentno); } @@ -70,6 +70,7 @@ class EInvoiceTest extends TestCase { $pdf = (new CreateEntityPdf($this->invoice->invitations()->first()))->handle(); (new CreateEInvoice($this->invoice))->handle(); + (new \App\Jobs\Invoice\MergeEInvoice($this->invoice))->handle(); $document = ZugferdDocumentReader::readAndGuessFromFile($pdf); $document->getDocumentInformation($documentno, $documenttypecode, $documentdate, $documentcurrency, $taxcurrency, $taxname, $documentlangeuage, $rest); $this->assertEquals($this->invoice->number, $documentno);