diff --git a/app/Jobs/EDocument/MergeEDocument.php b/app/Jobs/EDocument/MergeEDocument.php new file mode 100644 index 000000000000..2642cb0ea6bc --- /dev/null +++ b/app/Jobs/EDocument/MergeEDocument.php @@ -0,0 +1,65 @@ +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_quote_type = strlen($settings_entity->getSetting('e_quote_type')) > 2 ? $settings_entity->getSetting('e_quote_type') : "OrderX_Extended"; + + if ($this->document instanceof Invoice){ + switch ($e_document_type) { + case "EN16931": + case "XInvoice_3_0": + case "XInvoice_2_3": + case "XInvoice_2_2": + case "XInvoice_2_1": + case "XInvoice_2_0": + case "XInvoice_1_0": + case "XInvoice-Extended": + case "XInvoice-BasicWL": + case "XInvoice-Basic": + $xml = (new CreateEDocument($this->document))->handle(); + (new ZugferdDocumentPdfBuilder($xml, $this->pdf_file))->generateDocument()->saveDocument($mergeToPdf); + return $mergeToPdf; + default: + return $this->pdf_file; + + } + } + else{ + return $this->pdf_file; + } + } +} + diff --git a/app/Jobs/Entity/CreateRawPdf.php b/app/Jobs/Entity/CreateRawPdf.php index ac4320f1a89d..684860e492e1 100644 --- a/app/Jobs/Entity/CreateRawPdf.php +++ b/app/Jobs/Entity/CreateRawPdf.php @@ -12,9 +12,11 @@ namespace App\Jobs\Entity; use App\Exceptions\FilePermissionsFailure; +use App\Jobs\EDocument\MergeEDocument; use App\Models\Credit; use App\Models\CreditInvitation; use App\Models\Invoice; +use App\Models\Company; use App\Models\InvoiceInvitation; use App\Models\PurchaseOrder; use App\Models\PurchaseOrderInvitation; @@ -39,7 +41,7 @@ class CreateRawPdf public Invoice | Credit | Quote | RecurringInvoice | PurchaseOrder $entity; - public $company; + public Company $company; public $contact; @@ -105,7 +107,11 @@ class CreateRawPdf ]); $pdf = $ps->boot()->getPdf(); + nlog("pdf timer = ". $ps->execution_time); + if ($this->company->getSetting("enable_e_invoice")){ + $pdf = (new MergeEDocument($this->entity))->handle(); + } return $pdf; throw new FilePermissionsFailure('Unable to generate the raw PDF'); diff --git a/app/Services/EDocument/Standards/ZugferdEDokument.php b/app/Services/EDocument/Standards/ZugferdEDokument.php index a51e5f5675a1..3c445a37843b 100644 --- a/app/Services/EDocument/Standards/ZugferdEDokument.php +++ b/app/Services/EDocument/Standards/ZugferdEDokument.php @@ -20,7 +20,6 @@ use App\Services\AbstractService; use horstoeko\zugferd\codelists\ZugferdDutyTaxFeeCategories; use horstoeko\zugferd\ZugferdDocumentBuilder; use horstoeko\zugferd\ZugferdProfiles; -use horstoeko\zugferd\codelists\ZugferdSchemeIdentifiers; class ZugferdEDokument extends AbstractService {