<?php

namespace Database\Factories;

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

/**
 * @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\DelayedGood>
 */
class DelayedGoodFactory extends Factory
{
    /**
     * Define the model's default state.
     *
     * @return array<string, mixed>
     */
    public function definition(): array
    {
        $quantity = fake()->numberBetween(1, 100);
        $unitPrice = fake()->numberBetween(5000, 20000);
        $totalAmount = $quantity * $unitPrice;
        $isPaid = fake()->boolean();
        $paidAmount = $isPaid ? $totalAmount : fake()->numberBetween(0, $totalAmount);
        $storedDate = fake()->dateTimeBetween('-1 month', 'now');

        return [
            'customer_id' => Customer::factory(),
            'unit_id' => Unit::factory(),
            'quantity' => $quantity,
            'unit_price' => $unitPrice,
            'total_amount' => $totalAmount,
            'paid_amount' => $paidAmount,
            'stored_date' => $storedDate,
            'is_paid' => $isPaid,
            'payment_date' => $isPaid ? fake()->dateTimeBetween($storedDate, 'now') : null,
            'notes' => fake()->optional()->sentence(),
        ];
    }
}
