<?php

namespace App\Http\Requests\Refunds;

use App\Http\Requests\ApiFormRequest;

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

    public function rules(): array
    {
        return [
            'parent_id' => ['required', 'integer', 'min:1'],
            'request_type' => ['required', 'string', 'in:tuition,overpayment,duplicate,extra'],
            'amount' => ['required_unless:request_type,tuition', 'numeric', 'min:0.01'],
            'invoice_id' => ['nullable', 'integer', 'min:1'],
            'payment_id' => ['nullable', 'integer', 'min:1'],
            'reason' => ['nullable', 'string', 'max:2000'],
            'school_year' => ['nullable', 'string', 'max:20'],
            'semester' => ['nullable', 'string', 'max:20'],
        ];
    }
}
