<?php

namespace App\Jobs;

use App\Models\PricelistFile;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Queue\Queueable;

class PricelistPreProcessJob implements ShouldQueue
{
    use Queueable;

    /**
     * Create a new job instance.
     */
    public function __construct(
        public PricelistFile $pricelistFile
    )
    {
        //
    }

    /**
     * Execute the job.
     */
    public function handle(\App\Services\PricelistFileProcessService $service): void
    {
        if (!$service->preProcess($this->pricelistFile)) {
            throw new \Exception('Pricelist pre-processing failed.');
        }
    }
}
