<?php

declare(strict_types=1);

namespace Database\Factories;

use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;
use ImovelZapAi\Conversations\Infrastructure\Persistence\Eloquent\ContactModel;
use ImovelZapAi\Proposals\Domain\Enums\ProposalStatus;
use ImovelZapAi\Proposals\Infrastructure\Persistence\Eloquent\ProposalModel;
use ImovelZapAi\Proposals\Infrastructure\Persistence\Eloquent\ProposalTemplateModel;
use ImovelZapAi\Tenancy\Infrastructure\Persistence\Eloquent\TenantModel;

/** @extends Factory<ProposalModel> */
class ProposalFactory extends Factory
{
    protected $model = ProposalModel::class;

    public function definition(): array
    {
        return [
            'tenant_id' => TenantModel::factory(),
            'contact_id' => ContactModel::factory(),
            'template_id' => ProposalTemplateModel::factory(),
            'number' => 'P-'.now()->format('ymd').'-'.Str::upper(Str::random(4)),
            'title' => 'Proposta — '.fake()->firstName(),
            'status' => ProposalStatus::Draft,
            'amount' => fake()->randomFloat(2, 100000, 900000),
            'currency' => 'BRL',
            'commission_percent' => 5,
            'intro_message' => 'Segue nossa proposta comercial.',
            'expires_at' => now()->addDays(7),
            'view_count' => 0,
            'created_by' => User::factory(),
            'responsible_user_id' => User::factory(),
        ];
    }
}
