<?php

namespace Database\Factories;

use App\Models\Customer;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;

class OrderFactory extends Factory
{
    public function definition(): array
    {
        $subtotal = fake()->numberBetween(10000, 1000000);
        $discount = fake()->numberBetween(0, $subtotal);

        return [
            'customer_id' => Customer::factory(),
            'created_by_id' => User::factory(),
            'order_number' => fake()->unique()->numerify('ORD-####'),
            'channel' => fake()->randomElement(['store', 'shopee', 'tiktok']),
            'price_type' => fake()->randomElement(['retail', 'wholesale']),
            'status' => 'pending',
            'payment_type' => fake()->randomElement(['cash', 'transfer', 'marketplace', 'qris']),
            'subtotal' => $subtotal,
            'discount' => $discount,
            'total_amount' => $subtotal - $discount,
            'notes' => fake()->sentence(),
        ];
    }
}
