<?php

namespace Database\Factories;

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

/**
 * @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\LoanPenalty>
 */
class LoanPenaltyFactory extends Factory
{
    /**
     * Define the model's default state.
     *
     * @return array<string, mixed>
     */
    public function definition(): array
    {
        return [
            'loan_id' => Loan::factory(),
            'penalty_type' => $this->faker->randomElement(['late_payment', 'early_repayment', 'missed_installment', 'default_fee']),
            'amount' => $this->faker->numberBetween(50, 1000),
            'status' => $this->faker->randomElement(['unpaid', 'paid', 'waived']),
            'assessment_date' => $this->faker->dateTimeBetween('-6 months', 'now'),
            'due_date' => $this->faker->optional()->dateTimeBetween('now', '+1 month'),
            'paid_at' => $this->faker->optional()->dateTimeBetween('-1 month', 'now'),
            'paid_by' => $this->faker->optional()->randomElement(User::pluck('id')->toArray()),
            'payment_notes' => $this->faker->optional()->sentence(),
            'waived_at' => $this->faker->optional()->dateTimeBetween('-1 month', 'now'),
            'waived_by' => $this->faker->optional()->randomElement(User::pluck('id')->toArray()),
            'waiver_notes' => $this->faker->optional()->sentence(),
            'description' => $this->faker->sentence(),
        ];
    }
}
