mirror of
				https://github.com/invoiceninja/invoiceninja.git
				synced 2025-11-04 03:29:03 -05:00 
			
		
		
		
	Readded merged pdf with xml-file
This commit is contained in:
		
							parent
							
								
									c9213c1a80
								
							
						
					
					
						commit
						9fcde1ffc8
					
				
							
								
								
									
										65
									
								
								app/Jobs/EDocument/MergeEDocument.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										65
									
								
								app/Jobs/EDocument/MergeEDocument.php
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,65 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
namespace App\Jobs\EDocument;
 | 
			
		||||
 | 
			
		||||
use App\Models\Invoice;
 | 
			
		||||
use App\Models\PurchaseOrder;
 | 
			
		||||
use horstoeko\zugferd\ZugferdDocumentPdfBuilder;
 | 
			
		||||
use Illuminate\Bus\Queueable;
 | 
			
		||||
use Illuminate\Queue\SerializesModels;
 | 
			
		||||
use Illuminate\Queue\InteractsWithQueue;
 | 
			
		||||
use Illuminate\Contracts\Queue\ShouldQueue;
 | 
			
		||||
use Illuminate\Foundation\Bus\Dispatchable;
 | 
			
		||||
 | 
			
		||||
class MergeEDocument implements ShouldQueue
 | 
			
		||||
{
 | 
			
		||||
    use Dispatchable;
 | 
			
		||||
    use InteractsWithQueue;
 | 
			
		||||
    use Queueable;
 | 
			
		||||
    use SerializesModels;
 | 
			
		||||
 | 
			
		||||
    public $deleteWhenMissingModels = true;
 | 
			
		||||
 | 
			
		||||
    public function __construct(private object $document, private object $pdf_file)
 | 
			
		||||
    {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Execute the job.
 | 
			
		||||
     *
 | 
			
		||||
     * @return string
 | 
			
		||||
     */
 | 
			
		||||
    public function handle(): string
 | 
			
		||||
    {
 | 
			
		||||
        global $mergeToPdf;
 | 
			
		||||
        $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_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;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -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');
 | 
			
		||||
 | 
			
		||||
@ -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
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user