<?php

namespace App\Http\Requests\Finance;

use App\Http\Requests\ApiFormRequest;

class StoreExtraChargeRequest extends ApiFormRequest
{
    public function authorize(): bool
    {
        return $this->user() !== null;
    }

    public function rules(): array
    {
        return [
            'parent_id' => ['required', 'integer', 'min:1'],
            'title' => ['required', 'string', 'min:2', 'max:255'],
            'amount' => ['required', 'numeric', 'min:0.01'],
            'charge_type' => ['required', 'in:add,deduct'],
            'description' => ['nullable', 'string', 'max:2000'],
            'due_date' => ['nullable', 'date_format:Y-m-d'],
            'invoice_id' => ['nullable', 'integer', 'min:1'],
            'school_year' => ['nullable', 'string', 'max:20'],
            'semester' => ['nullable', 'string', 'max:20'],
        ];
    }
}
