Support adding the pdf into the XML
This commit is contained in:
parent
63d5a4ca52
commit
37a4f5ba62
|
|
@ -42,6 +42,8 @@ class ZugferdEDocument extends AbstractService
|
||||||
|
|
||||||
private ?string $exemption_reason_code = null;
|
private ?string $exemption_reason_code = null;
|
||||||
|
|
||||||
|
private ?string $temp_file_path = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* __construct
|
* __construct
|
||||||
*
|
*
|
||||||
|
|
@ -90,7 +92,8 @@ class ZugferdEDocument extends AbstractService
|
||||||
->setPaymentTerms() // 3. Then payment terms
|
->setPaymentTerms() // 3. Then payment terms
|
||||||
->setLineItems() // 4. Then line items
|
->setLineItems() // 4. Then line items
|
||||||
->setCustomSurcharges() // 4a. Surcharges
|
->setCustomSurcharges() // 4a. Surcharges
|
||||||
->setDocumentSummation(); // 5. Finally document summation
|
->setDocumentSummation() // 5. Finally document summation
|
||||||
|
->setAdditionalReferencedDocument(); // 6. Additional referenced document
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
|
|
||||||
|
|
@ -125,6 +128,27 @@ class ZugferdEDocument extends AbstractService
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function setAdditionalReferencedDocument(): self
|
||||||
|
{
|
||||||
|
if($this->document->client->getSetting('merge_e_invoice_to_pdf')) {
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
$invitation = $this->document->invitations()->first();
|
||||||
|
$pdf = (new \App\Jobs\Entity\CreateRawPdf($invitation))->handle();
|
||||||
|
$file_name = $this->document->numberFormatter().'.pdf';
|
||||||
|
|
||||||
|
$this->temp_file_path = \App\Utils\TempFile::filePath($pdf, $file_name);
|
||||||
|
|
||||||
|
$this->xdocument->addDocumentInvoiceSupportingDocumentWithFile(
|
||||||
|
$this->document->number,
|
||||||
|
$this->temp_file_path,
|
||||||
|
$file_name,
|
||||||
|
);
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* setDocumentTaxes
|
* setDocumentTaxes
|
||||||
*
|
*
|
||||||
|
|
@ -249,7 +273,14 @@ class ZugferdEDocument extends AbstractService
|
||||||
|
|
||||||
public function getXml(): string
|
public function getXml(): string
|
||||||
{
|
{
|
||||||
return $this->xdocument->getContent();
|
$xml = $this->xdocument->getContent();
|
||||||
|
|
||||||
|
//used if we are embedding the document within the PDF
|
||||||
|
if($this->temp_file_path){
|
||||||
|
unlink($this->temp_file_path);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $xml;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function bootFlags(): self
|
private function bootFlags(): self
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue