diff --git a/app/Services/EDocument/Imports/ParseEDocument.php b/app/Services/EDocument/Imports/ParseEDocument.php index 3c9f8f048483..fbd739122ee4 100644 --- a/app/Services/EDocument/Imports/ParseEDocument.php +++ b/app/Services/EDocument/Imports/ParseEDocument.php @@ -46,11 +46,11 @@ class ParseEDocument extends AbstractService // ZUGFERD - try to parse via Zugferd lib switch (true) { - case $this->file->getExtension() == 'pdf': - case $this->file->getExtension() == 'xml' && stristr($this->file->get(), "urn:cen.eu:en16931:2017"): - case $this->file->getExtension() == 'xml' && stristr($this->file->get(), "urn:cen.eu:en16931:2017#compliant#urn:xeinkauf.de:kosit:xrechnung_3.0"): - case $this->file->getExtension() == 'xml' && stristr($this->file->get(), "urn:cen.eu:en16931:2017#compliant#urn:xeinkauf.de:kosit:xrechnung_2.1"): - case $this->file->getExtension() == 'xml' && stristr($this->file->get(), "urn:cen.eu:en16931:2017#compliant#urn:xeinkauf.de:kosit:xrechnung_2.0"): + case ($this->file->getExtension() == 'pdf' || $this->file->getMimeType() == 'application/pdf'): + case ($this->file->getExtension() == 'xml' || $this->file->getMimeType() == 'application/xml') && stristr($this->file->get(), "urn:cen.eu:en16931:2017"): + case ($this->file->getExtension() == 'xml' || $this->file->getMimeType() == 'application/xml') && stristr($this->file->get(), "urn:cen.eu:en16931:2017#compliant#urn:xeinkauf.de:kosit:xrechnung_3.0"): + case ($this->file->getExtension() == 'xml' || $this->file->getMimeType() == 'application/xml') && stristr($this->file->get(), "urn:cen.eu:en16931:2017#compliant#urn:xeinkauf.de:kosit:xrechnung_2.1"): + case ($this->file->getExtension() == 'xml' || $this->file->getMimeType() == 'application/xml') && stristr($this->file->get(), "urn:cen.eu:en16931:2017#compliant#urn:xeinkauf.de:kosit:xrechnung_2.0"): try { return (new ZugferdEDocument($this->file, $this->company))->run(); } catch (Exception $e) { diff --git a/app/Services/InboundMail/InboundMailEngine.php b/app/Services/InboundMail/InboundMailEngine.php index f40fbf50a0df..d4d4a9d322e6 100644 --- a/app/Services/InboundMail/InboundMailEngine.php +++ b/app/Services/InboundMail/InboundMailEngine.php @@ -229,20 +229,20 @@ class InboundMailEngine if (!$expense->vendor_id && $expense_vendor) $expense->vendor_id = $expense_vendor->id; + if ($is_imported_by_parser) + $expense->saveQuietly(); + else + $expense->save(); + // save document only, when not imported by parser $documents = []; - if ($is_imported_by_parser) + if (!$is_imported_by_parser) array_push($documents, $document); // email document if ($email->body_document !== null) array_push($documents, $email->body_document); - if ($is_imported_by_parser) - $expense->saveQuietly(); - else - $expense->save(); - $this->saveDocuments($documents, $expense); }