From f117e79d43663cd9c39360974a084762aa09e7b8 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 2 Sep 2024 13:07:01 +1000 Subject: [PATCH] Patches for inbound emails --- app/Http/Controllers/PostMarkController.php | 10 +++++----- app/Services/EDocument/Imports/ParseEDocument.php | 1 + app/Services/EDocument/Imports/ZugferdEDocument.php | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/app/Http/Controllers/PostMarkController.php b/app/Http/Controllers/PostMarkController.php index 25bf7976d43a..88e6812fd38e 100644 --- a/app/Http/Controllers/PostMarkController.php +++ b/app/Http/Controllers/PostMarkController.php @@ -300,11 +300,11 @@ class PostMarkController extends BaseController // prepare data for ingresEngine $inboundMail = new InboundMail(); - $inboundMail->from = $input["From"]; - $inboundMail->to = $input["To"]; // usage of data-input, because we need a single email here - $inboundMail->subject = $input["Subject"]; - $inboundMail->body = $input["HtmlBody"]; - $inboundMail->text_body = $input["TextBody"]; + $inboundMail->from = $input["From"] ?? ''; + $inboundMail->to = $input["To"] ; // usage of data-input, because we need a single email here + $inboundMail->subject = $input["Subject"] ?? ''; + $inboundMail->body = $input["HtmlBody"] ?? ''; + $inboundMail->text_body = $input["TextBody"] ?? ''; $inboundMail->date = Carbon::createFromTimeString($input["Date"]); // parse documents as UploadedFile from webhook-data diff --git a/app/Services/EDocument/Imports/ParseEDocument.php b/app/Services/EDocument/Imports/ParseEDocument.php index b58d4d7664b1..e49d39d68b9e 100644 --- a/app/Services/EDocument/Imports/ParseEDocument.php +++ b/app/Services/EDocument/Imports/ParseEDocument.php @@ -57,6 +57,7 @@ class ParseEDocument extends AbstractService try { return (new ZugferdEDocument($this->file, $this->company))->run(); } catch (Exception $e) { + nlog($this->file->get()); nlog("Zugferd Exception: " . $e->getMessage()); } } diff --git a/app/Services/EDocument/Imports/ZugferdEDocument.php b/app/Services/EDocument/Imports/ZugferdEDocument.php index f221b3547f64..cc70e4cd6694 100644 --- a/app/Services/EDocument/Imports/ZugferdEDocument.php +++ b/app/Services/EDocument/Imports/ZugferdEDocument.php @@ -104,7 +104,7 @@ class ZugferdEDocument extends AbstractService } $vendor = Vendor::query() - ->where("company_id", $user->company()->id) + ->where("company_id", $this->company->id) ->where(function ($q) use($taxid, $person_name, $contact_email){ $q->when(!is_null($taxid), function ($when_query) use($taxid){ $when_query->orWhere('vat_number', $taxid);