<?php

namespace Database\Factories;

use App\Models\OrderDetail;
use Illuminate\Database\Eloquent\Factories\Factory;

/** @extends Factory<OrderDetail> */
class OrderDetailFactory extends Factory
{
    protected $model = OrderDetail::class;

    public function definition(): array
    {
        $quantity = $this->faker->numberBetween(1, 5);
        $priceTE = $this->faker->randomFloat(6, 5, 100);
        $taxPct = 13.00;
        $priceTI = $priceTE * (1 + ($taxPct / 100));

        $totalTE = $priceTE * $quantity;
        $totalTI = $priceTI * $quantity;

        return [
            'order_reference' => 'XXXXXXXXX',
            'product_reference' => strtoupper($this->faker->bothify('SKU-###??')),
            'product_name' => $this->faker->words(3, true),
            'product_quantity' => $quantity,
            'product_tax' => $taxPct,
            'product_priceTI' => $priceTI,
            'product_priceTE' => $priceTE,
            'total_priceTI' => $totalTI,
            'total_priceTE' => $totalTE,
            'warehouse_assigned' => $this->faker->randomElement(['Bodega Central', 'Sucursal 01', 'Sucursal 02']),
        ];
    }
}
