user()->account; // 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"): try { return (new ZugferdEDocument($this->file))->run(); } catch (Exception $e) { nlog("Zugferd Exception: " . $e->getMessage()); } } // MINDEE OCR - try to parse via mindee external service if (config('services.mindee.api_key') && !(Ninja::isHosted() && !($this->company->account->isPaid() && $this->company->account->plan == 'enterprise'))) try { return (new MindeeEDocument($this->file))->run(); } catch (Exception $e) { if (!($e->getMessage() == 'Unsupported document type')) nlog("Mindee Exception: " . $e->getMessage()); } // NO PARSER OR ERROR throw new Exception("File type not supported or issue while parsing", 409); } }