Added option to enable/disable xml-attachments in the e-mail

This commit is contained in:
Lars Kusch 2024-07-14 07:05:08 +02:00
parent bbd8403fe1
commit 510953630e

View File

@ -327,12 +327,14 @@ class EmailDefaults
} }
/** E-Invoice xml file */ /** E-Invoice xml file */
if ($this->email->email_object->settings->enable_e_invoice) { if ($this->email->email_object->settings->enable_e_invoice) {
if ($this->email_object->settings->e_invoice_attachment ?? true){
$xml_string = $this->email->email_object->entity->service()->getEDocument(); $xml_string = $this->email->email_object->entity->service()->getEDocument();
if($xml_string) { if($xml_string) {
$this->email->email_object->attachments = array_merge($this->email->email_object->attachments, [['file' => base64_encode($xml_string), 'name' => explode(".", $this->email->email_object->entity->getFileName('xml'))[0]."-e_invoice.xml"]]); $this->email->email_object->attachments = array_merge($this->email->email_object->attachments, [['file' => base64_encode($xml_string), 'name' => explode(".", $this->email->email_object->entity->getFileName('xml'))[0]."-e_invoice.xml"]]);
} }
} }
}
if (!$this->email->email_object->settings->document_email_attachment || !$this->email->company->account->hasFeature(Account::FEATURE_DOCUMENTS)) { if (!$this->email->email_object->settings->document_email_attachment || !$this->email->company->account->hasFeature(Account::FEATURE_DOCUMENTS)) {
return $this; return $this;