<?php

namespace Database\Factories;

use App\Models\Purchase;
use App\Models\PurchaseItem;
use App\Models\RawMaterialPrice;
use Illuminate\Database\Eloquent\Factories\Factory;

/**
 * @extends Factory<PurchaseItem>
 */
class PurchaseItemFactory extends Factory
{
    public function definition(): array
    {
        $quantity = fake()->randomFloat(4, 1, 50);
        $unitPrice = fake()->numberBetween(10_000, 200_000);

        return [
            'purchase_id' => Purchase::factory(),
            'raw_material_price_id' => RawMaterialPrice::factory(),
            'quantity' => $quantity,
            'unit_price' => $unitPrice,
            'subtotal' => (int) round($quantity * $unitPrice),
        ];
    }
}
