Try to merge e-invoice in as many cases as possible.

This commit is contained in:
Lars Kusch 2023-08-07 22:02:02 +02:00
parent dd17119fd6
commit 5f929f7a6c
5 changed files with 14 additions and 6 deletions

View File

@ -13,6 +13,7 @@ namespace App\Jobs\Entity;
use App\Exceptions\FilePermissionsFailure; use App\Exceptions\FilePermissionsFailure;
use App\Jobs\Invoice\CreateEInvoice; use App\Jobs\Invoice\CreateEInvoice;
use App\Jobs\Invoice\MergeEInvoice;
use App\Libraries\MultiDB; use App\Libraries\MultiDB;
use App\Models\Credit; use App\Models\Credit;
use App\Models\CreditInvitation; use App\Models\CreditInvitation;
@ -214,6 +215,8 @@ class CreateEntityPdf implements ShouldQueue
} }
if ($this->entity_string == "invoice" && $this->client->getSetting('enable_e_invoice')){ if ($this->entity_string == "invoice" && $this->client->getSetting('enable_e_invoice')){
(new CreateEInvoice($this->entity))->handle(); (new CreateEInvoice($this->entity))->handle();
(new MergeEInvoice($this->entity))->handle();
} }
$this->invitation = null; $this->invitation = null;
// $this->entity = null; // $this->entity = null;

View File

@ -77,6 +77,7 @@ class ZipInvoices implements ShouldQueue
(new CreateEntityPdf($invoice->invitations()->first()))->handle(); (new CreateEntityPdf($invoice->invitations()->first()))->handle();
if ($invoice->client->getSetting('enable_e_invoice')){ if ($invoice->client->getSetting('enable_e_invoice')){
(new CreateEInvoice($invoice))->handle(); (new CreateEInvoice($invoice))->handle();
(new MergeEInvoice($invoice))->handle();
} }
}); });

View File

@ -44,6 +44,8 @@ class GetInvoiceEInvoice extends AbstractService
if (! $file) { if (! $file) {
$file_path = (new CreateEInvoice($this->invoice))->handle(); $file_path = (new CreateEInvoice($this->invoice))->handle();
(new \App\Jobs\Invoice\MergeEInvoice($this->invoice))->handle();
} }
return $file_path; return $file_path;

View File

@ -468,6 +468,7 @@ class InvoiceService
if ($invitation->invoice->client->getSetting('enable_e_invoice') && $invitation instanceof InvoiceInvitation) if ($invitation->invoice->client->getSetting('enable_e_invoice') && $invitation instanceof InvoiceInvitation)
{ {
(new CreateEInvoice($invitation->invoice))->handle(); (new CreateEInvoice($invitation->invoice))->handle();
(new MergeEInvoice($invitation->invoice))->run();
} }
}); });

View File

@ -42,9 +42,10 @@ class EInvoiceTest extends TestCase
$this->company->e_invoice_type = "EN16931"; $this->company->e_invoice_type = "EN16931";
$this->invoice->client->routing_id = 'DE123456789'; $this->invoice->client->routing_id = 'DE123456789';
$this->invoice->client->save(); $this->invoice->client->save();
$xinvoice = (new CreateEInvoice($this->invoice))->handle(); $e_invoice = (new CreateEInvoice($this->invoice))->handle();
$this->assertNotNull($xinvoice); (new \App\Jobs\Invoice\MergeEInvoice($this->invoice))->handle();
$this->assertTrue(Storage::exists($xinvoice)); $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->routing_id = 'DE123456789';
$this->invoice->client->save(); $this->invoice->client->save();
$xinvoice = (new CreateEInvoice($this->invoice))->handle(); $e_invoice = (new CreateEInvoice($this->invoice))->handle();
nlog(Storage::path($xinvoice)); $document = ZugferdDocumentReader::readAndGuessFromFile(Storage::path($e_invoice));
$document = ZugferdDocumentReader::readAndGuessFromFile(Storage::path($xinvoice));
$document->getDocumentInformation($documentno, $documenttypecode, $documentdate, $documentcurrency, $taxcurrency, $taxname, $documentlangeuage, $rest); $document->getDocumentInformation($documentno, $documenttypecode, $documentdate, $documentcurrency, $taxcurrency, $taxname, $documentlangeuage, $rest);
$this->assertEquals($this->invoice->number, $documentno); $this->assertEquals($this->invoice->number, $documentno);
} }
@ -70,6 +70,7 @@ class EInvoiceTest extends TestCase
{ {
$pdf = (new CreateEntityPdf($this->invoice->invitations()->first()))->handle(); $pdf = (new CreateEntityPdf($this->invoice->invitations()->first()))->handle();
(new CreateEInvoice($this->invoice))->handle(); (new CreateEInvoice($this->invoice))->handle();
(new \App\Jobs\Invoice\MergeEInvoice($this->invoice))->handle();
$document = ZugferdDocumentReader::readAndGuessFromFile($pdf); $document = ZugferdDocumentReader::readAndGuessFromFile($pdf);
$document->getDocumentInformation($documentno, $documenttypecode, $documentdate, $documentcurrency, $taxcurrency, $taxname, $documentlangeuage, $rest); $document->getDocumentInformation($documentno, $documenttypecode, $documentdate, $documentcurrency, $taxcurrency, $taxname, $documentlangeuage, $rest);
$this->assertEquals($this->invoice->number, $documentno); $this->assertEquals($this->invoice->number, $documentno);