diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index 092404a870f9..2c1a731228ad 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -129,7 +129,6 @@ class Kernel extends ConsoleKernel $schedule->command('queue:restart')->everyFiveMinutes()->withoutOverlapping(); } - } /** diff --git a/app/Jobs/EDocument/ImportEDocument.php b/app/Jobs/EDocument/ImportEDocument.php index 13fb22de94f8..59d8e7b99596 100644 --- a/app/Jobs/EDocument/ImportEDocument.php +++ b/app/Jobs/EDocument/ImportEDocument.php @@ -12,7 +12,7 @@ namespace App\Jobs\EDocument; use App\Models\Expense; -use App\Services\EDocument\Imports\ZugferdEDocument; +use App\Services\EDocument\Imports\ParseEDocument; use Exception; use Illuminate\Bus\Queueable; use Illuminate\Queue\SerializesModels; @@ -28,13 +28,10 @@ class ImportEDocument implements ShouldQueue use SerializesModels; public $deleteWhenMissingModels = true; - private string $file_name; - private readonly string $file_content; - public function __construct(string $file_content, string $file_name) + public function __construct(private readonly string $file_content, private string $file_name) { - $this->file_content = $file_content; - $this->file_name = $file_name; + } /** @@ -45,20 +42,6 @@ class ImportEDocument implements ShouldQueue */ public function handle(): Expense { - if (str_contains($this->file_name, ".xml")){ - switch (true) { - case stristr($this->file_content, "urn:cen.eu:en16931:2017"): - case stristr($this->file_content, "urn:cen.eu:en16931:2017#compliant#urn:xeinkauf.de:kosit:xrechnung_3.0"): - case stristr($this->file_content, "urn:cen.eu:en16931:2017#compliant#urn:xeinkauf.de:kosit:xrechnung_2.1"): - case stristr($this->file_content, "urn:cen.eu:en16931:2017#compliant#urn:xeinkauf.de:kosit:xrechnung_2.0"): - return (new ZugferdEDocument($this->file_content, $this->file_name))->run(); - default: - throw new Exception("E-Invoice standard not supported"); - } - } - else { - throw new Exception("File type not supported"); - } - + return (new ParseEDocument($this->file_content, $this->file_name))->run(); } } diff --git a/app/Services/EDocument/Imports/ParseEDocument.php b/app/Services/EDocument/Imports/ParseEDocument.php new file mode 100644 index 000000000000..89ad20986eb7 --- /dev/null +++ b/app/Services/EDocument/Imports/ParseEDocument.php @@ -0,0 +1,52 @@ +file_name, ".xml")) { + switch (true) { + case stristr($this->file_content, "urn:cen.eu:en16931:2017"): + case stristr($this->file_content, "urn:cen.eu:en16931:2017#compliant#urn:xeinkauf.de:kosit:xrechnung_3.0"): + case stristr($this->file_content, "urn:cen.eu:en16931:2017#compliant#urn:xeinkauf.de:kosit:xrechnung_2.1"): + case stristr($this->file_content, "urn:cen.eu:en16931:2017#compliant#urn:xeinkauf.de:kosit:xrechnung_2.0"): + return (new ZugferdEDocument($this->file_content, $this->file_name))->run(); + default: + throw new Exception("E-Invoice standard not supported"); + } + } else { + throw new Exception("File type not supported"); + } + } +} +