<?php

namespace Database\Factories;

use App\Models\Company;
use App\Models\NotaFiscal;
use Illuminate\Database\Eloquent\Factories\Factory;

/**
 * @extends Factory<NotaFiscal>
 */
class NotaFiscalFactory extends Factory
{
    protected $model = NotaFiscal::class;

    public function definition(): array
    {
        return [
            'company_id' => Company::factory(),
            'chave' => (string) $this->faker->numerify(str_repeat('#', 44)),
            'nsu' => $this->faker->numberBetween(1, 5000),
            'tipo' => 'resumo',
            'tem_xml_completo' => false,
            'emit_cnpj' => $this->faker->numerify(str_repeat('#', 14)),
            'emit_nome' => $this->faker->company(),
            'emit_uf' => 'SP',
            'modelo' => '55',
            'serie' => '1',
            'numero' => $this->faker->numberBetween(1, 99999),
            'data_emissao' => now()->subDays($this->faker->numberBetween(0, 300)),
            'valor_total' => $this->faker->randomFloat(2, 50, 25000),
            'situacao' => 'autorizada',
        ];
    }

    public function completa(): static
    {
        return $this->state(fn () => [
            'tipo' => 'completo',
            'tem_xml_completo' => true,
        ]);
    }
}
