<?php

namespace App\Http\Requests\Expense;

use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;

class StoreExpenseRequest extends FormRequest
{
    public function authorize(): bool
    {
        return true;
    }

    public function rules(): array
    {
        return [
            'shift_id' => ['nullable', 'integer', 'exists:shifts,id'],
            'expense_category_id' => ['nullable', 'integer', 'exists:expense_categories,id'],
            'amount' => ['required', 'numeric', 'gt:0'],
            'description' => ['required', 'string'],
            'payment_method' => ['nullable', Rule::in(['cash', 'mpesa', 'card', 'bank_transfer', 'other'])],
            'reference' => ['nullable', 'string', 'max:191'],
            'receipt_url' => ['nullable', 'string', 'max:500'],
            'expense_date' => ['required', 'date'],
            'device_id' => ['nullable', 'string', 'max:100'],
        ];
    }
}
