diff --git a/app/Http/Controllers/PostMarkController.php b/app/Http/Controllers/PostMarkController.php index 7eac5dfaf3f5..97b487450d58 100644 --- a/app/Http/Controllers/PostMarkController.php +++ b/app/Http/Controllers/PostMarkController.php @@ -320,7 +320,9 @@ class PostMarkController extends BaseController // perform try { + $inboundEngine->handleExpenseMailbox($inboundMail); + } catch (\Exception $e) { if ($e->getCode() == 409) return response()->json(['message' => $e->getMessage()], 409); diff --git a/app/Services/InboundMail/InboundMailEngine.php b/app/Services/InboundMail/InboundMailEngine.php index 5d4df9e8c970..f40fbf50a0df 100644 --- a/app/Services/InboundMail/InboundMailEngine.php +++ b/app/Services/InboundMail/InboundMailEngine.php @@ -204,19 +204,19 @@ class InboundMailEngine // throw error, only, when its not expected switch (true) { case ($err->getMessage() === 'E-Invoice standard not supported'): - case ($err->getMessage() === 'File type not supported'): + case ($err->getMessage() === 'File type not supported or issue while parsing'): break; default: throw $err; } } - $is_imported_by_parser = array_search($expense->id, $parsed_expense_ids); - // populate missing data with data from email if (!$expense) $expense = ExpenseFactory::create($company->id, $company->owner()->id); + $is_imported_by_parser = array_search($expense->id, $parsed_expense_ids); + if ($is_imported_by_parser) $expense->public_notes = $expense->public_notes . $email->subject; @@ -238,13 +238,13 @@ class InboundMailEngine if ($email->body_document !== null) array_push($documents, $email->body_document); - $this->saveDocuments($documents, $expense); - if ($is_imported_by_parser) $expense->saveQuietly(); else $expense->save(); + $this->saveDocuments($documents, $expense); + } }