<?php

namespace Database\Factories\INSURANCE;

use App\Models\CRM\Entity;
use App\Models\INSURANCE\Insurer;
use App\Models\INSURANCE\CommissionDefault;
use Illuminate\Database\Eloquent\Factories\Factory;

/**
 * @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\INSURANCE\InsurancePolicy>
 */
class InsurancePolicyFactory extends Factory
{
    /**
     * Define the model's default state.
     *
     * @return array<string, mixed>
     */
    public function definition(): array
    {
        return [
            // your tests always override entity_id, but this makes standalone usage safe:
            'entity_id'               => Entity::factory(),

            'insurer_id'              => Insurer::factory(),
            'commission_default_id'   => CommissionDefault::factory(),

            'policy_number'           => $this->faker->unique()->bothify('POL-####'),
            'custom_name'             => $this->faker->optional()->sentence(3),
            'commission_pct_default'  => $this->faker->randomFloat(2, 0, 100),
            'commission_pct'          => $this->faker->optional()->randomFloat(2, 0, 100),
            'expected_commission'     => $this->faker->optional()->randomFloat(2, 0, 100000),
            'insured_amount'          => $this->faker->optional()->randomFloat(2, 1_000, 100_000),
            'premium'                 => $this->faker->optional()->randomFloat(2, 100, 1_000),
            'start_date'              => $this->faker->optional()->date(),
            'end_date'                => $this->faker->dateTimeBetween('now', '+1 year')->format('Y-m-d'),
            'status'                  => 'active',
        ];
    }
}
