1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 13:12:50 +01:00
This commit is contained in:
Lars Kusch 2024-05-16 07:54:03 +02:00
parent 9fcde1ffc8
commit b3127a3d2e
2 changed files with 6 additions and 9 deletions

View File

@ -20,7 +20,7 @@ class MergeEDocument implements ShouldQueue
public $deleteWhenMissingModels = true; public $deleteWhenMissingModels = true;
public function __construct(private object $document, private object $pdf_file) public function __construct(private object $document, private string $pdf_file)
{ {
} }
@ -35,7 +35,6 @@ class MergeEDocument implements ShouldQueue
$settings_entity = ($this->document instanceof PurchaseOrder) ? $this->document->vendor : $this->document->client; $settings_entity = ($this->document instanceof PurchaseOrder) ? $this->document->vendor : $this->document->client;
$e_document_type = strlen($settings_entity->getSetting('e_invoice_type')) > 2 ? $settings_entity->getSetting('e_invoice_type') : "XInvoice_3_0"; $e_document_type = strlen($settings_entity->getSetting('e_invoice_type')) > 2 ? $settings_entity->getSetting('e_invoice_type') : "XInvoice_3_0";
$e_quote_type = strlen($settings_entity->getSetting('e_quote_type')) > 2 ? $settings_entity->getSetting('e_quote_type') : "OrderX_Extended";
if ($this->document instanceof Invoice){ if ($this->document instanceof Invoice){
switch ($e_document_type) { switch ($e_document_type) {
@ -49,9 +48,8 @@ class MergeEDocument implements ShouldQueue
case "XInvoice-Extended": case "XInvoice-Extended":
case "XInvoice-BasicWL": case "XInvoice-BasicWL":
case "XInvoice-Basic": case "XInvoice-Basic":
$xml = (new CreateEDocument($this->document))->handle(); $xml = (new CreateEDocument($this->document, true))->handle();
(new ZugferdDocumentPdfBuilder($xml, $this->pdf_file))->generateDocument()->saveDocument($mergeToPdf); return(new ZugferdDocumentPdfBuilder($xml, $this->pdf_file))->generateDocument()->downloadString("Invoice.pdf");
return $mergeToPdf;
default: default:
return $this->pdf_file; return $this->pdf_file;

View File

@ -16,7 +16,6 @@ use App\Jobs\EDocument\MergeEDocument;
use App\Models\Credit; use App\Models\Credit;
use App\Models\CreditInvitation; use App\Models\CreditInvitation;
use App\Models\Invoice; use App\Models\Invoice;
use App\Models\Company;
use App\Models\InvoiceInvitation; use App\Models\InvoiceInvitation;
use App\Models\PurchaseOrder; use App\Models\PurchaseOrder;
use App\Models\PurchaseOrderInvitation; use App\Models\PurchaseOrderInvitation;
@ -41,7 +40,7 @@ class CreateRawPdf
public Invoice | Credit | Quote | RecurringInvoice | PurchaseOrder $entity; public Invoice | Credit | Quote | RecurringInvoice | PurchaseOrder $entity;
public Company $company; public $company;
public $contact; public $contact;
@ -109,8 +108,8 @@ class CreateRawPdf
$pdf = $ps->boot()->getPdf(); $pdf = $ps->boot()->getPdf();
nlog("pdf timer = ". $ps->execution_time); nlog("pdf timer = ". $ps->execution_time);
if ($this->company->getSetting("enable_e_invoice")){ if ($this->entity_string == "invoice" && $this->entity->company->getSetting("enable_e_invoice")){
$pdf = (new MergeEDocument($this->entity))->handle(); $pdf = (new MergeEDocument($this->entity, $pdf))->handle();
} }
return $pdf; return $pdf;