1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 21:22:58 +01:00

Fixes for duplicated XInvoice file attachments

This commit is contained in:
Lars Kusch 2023-07-04 09:25:34 +02:00
parent 2f83d0126c
commit 760e2281d2

View File

@ -168,7 +168,7 @@ class EmailDefaults
*/
private function setBody(): self
{
if (strlen($this->email->email_object->body) > 3) {
// A Custom Message has been set in the email screen.
// return $this;
@ -181,7 +181,7 @@ class EmailDefaults
}
$this->email->email_object->text_body = strip_tags($this->email->email_object->body);
if ($this->template == 'email.template.custom') {
$this->email->email_object->body = (str_replace('$body', $this->email->email_object->body, str_replace(["\r","\n"], "", $this->email->email_object->settings->email_style_custom)));
}
@ -230,7 +230,7 @@ class EmailDefaults
$this->email->email_object->subject = strtr($this->email->email_object->subject, $this->email->email_object->variables);
//06-06-2023 ensure we do not parse markdown in custom templates
if ($this->template != 'custom' && $this->template != 'email.template.custom') {
$this->email->email_object->body = $this->parseMarkdownToHtml($this->email->email_object->body);
@ -303,17 +303,6 @@ class EmailDefaults
$this->email->email_object->entity instanceof Quote ||
$this->email->email_object->entity instanceof Credit)) {
$pdf = ((new CreateRawPdf($this->email->email_object->invitation, $this->email->company->db))->handle());
if ($this->email->email_object->settings->enable_e_invoice && $this->email->email_object->entity instanceof Invoice) {
$xinvoice_path = $this->email->email_object->entity->service()->getEInvoice();
if(Storage::disk(config('filesystems.default'))->exists($xinvoice_path))
$this->email->email_object->attachments = array_merge($this->email->email_object->attachments, [['file' => base64_encode(Storage::get($xinvoice_path)), 'name' => explode(".", $this->email->email_object->entity->getFileName('xml'))[0]."-xinvoice.xml"]]);
}
else {
$this->email->email_object->attachments = array_merge($this->email->email_object->attachments, [['file' => base64_encode($pdf), 'name' => $this->email->email_object->entity->numberFormatter().'.pdf']]);
}
$this->email->email_object->attachments = array_merge($this->email->email_object->attachments, [['file' => base64_encode($pdf), 'name' => $this->email->email_object->entity->numberFormatter().'.pdf']]);
}