<?php

declare(strict_types=1);

namespace Database\Factories;

use App\Models\DebitNote;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;

/** @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\DebitNote> */
class DebitNoteFactory extends Factory
{
    /** @return array<string, mixed> */
    public function definition(): array
    {
        return [
            'user_id' => User::factory(),
            'number' => DebitNote::generateNumber(),
            'amount' => fake()->randomFloat(2, 5, 100),
            'currency' => 'USD',
            'reason_type' => fake()->randomElement(['late_fee', 'adjustment', 'underpayment']),
            'reason' => fake()->sentence(),
            'status' => 'issued',
            'issued_at' => now(),
        ];
    }

    public function draft(): static
    {
        return $this->state(fn (array $attributes): array => [
            'status' => 'draft',
            'issued_at' => null,
        ]);
    }

    public function voided(): static
    {
        return $this->state(fn (array $attributes): array => [
            'status' => 'voided',
        ]);
    }
}
