<?php

namespace Database\Factories;

use App\Models\Purchase;
use App\Models\Supplier;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;

/**
 * @extends Factory<Purchase>
 */
class PurchaseFactory extends Factory
{
    public function definition(): array
    {
        $subtotal = fake()->numberBetween(100_000, 10_000_000);
        $discount = fake()->numberBetween(0, (int) ($subtotal * 0.1));
        $shippingCost = fake()->numberBetween(0, 100_000);

        return [
            'supplier_id' => Supplier::factory(),
            'created_by_id' => User::factory(),
            'subtotal' => $subtotal,
            'discount' => $discount,
            'shipping_cost' => $shippingCost,
            'total' => $subtotal - $discount + $shippingCost,
            'notes' => fake()->optional()->sentence(3),
        ];
    }
}
