<?php

namespace Database\Factories;

use App\Enums\OverrideScope;
use App\Models\DeliveryCalendarOverride;
use App\Models\DeliverySchedule;
use Illuminate\Database\Eloquent\Factories\Factory;

/**
 * @extends Factory<DeliveryCalendarOverride>
 */
class DeliveryCalendarOverrideFactory extends Factory
{
    /**
     * Define the model's default state.
     *
     * @return array<string, mixed>
     */
    public function definition(): array
    {
        return [
            'supplier_id' => \App\Models\Supplier::factory(),
            'override_scope' => OverrideScope::General,
            'delivery_schedule_id' => null,
            'profit_center_id' => null,
            'date' => $this->faker->date(),
            'is_delivery_day' => $this->faker->boolean(),
            'description' => $this->faker->sentence(),
        ];
    }

    public function general(): static
    {
        return $this->state([
            'override_scope' => OverrideScope::General,
            'delivery_schedule_id' => null,
            'profit_center_id' => null,
        ]);
    }

    public function forDeliverySchedule(DeliverySchedule $schedule): static
    {
        return $this->state([
            'override_scope' => OverrideScope::Region,
            'delivery_schedule_id' => $schedule->id,
            'profit_center_id' => null,
        ]);
    }

    public function forProfitCenter(\App\Models\ProfitCenter $profitCenter): static
    {
        return $this->state([
            'override_scope' => OverrideScope::ProfitCenter,
            'delivery_schedule_id' => null,
            'profit_center_id' => $profitCenter->id,
        ]);
    }
}
