<?php

namespace App\Http\Requests\InventoryMovements;

use Illuminate\Foundation\Http\FormRequest;

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

    public function rules(): array
    {
        return [
            'date' => ['sometimes', 'required', 'date_format:Y-m-d'],
            'item_id' => ['sometimes', 'required', 'integer'],
            'type' => ['sometimes', 'required', 'string', 'in:IN,OUT,ADJUST'],
            'quantity' => ['sometimes', 'required', 'numeric', 'gt:0'],
            'reason' => ['sometimes', 'required', 'string', 'max:50'],
            'ref' => ['sometimes', 'nullable', 'array'],
            'ref.batch_id' => ['sometimes', 'nullable', 'integer'],
            'ref.tank_id' => ['sometimes', 'nullable', 'integer'],
            'ref.daily_log_id' => ['sometimes', 'nullable', 'integer'],
            'ref.note' => ['sometimes', 'nullable', 'string', 'max:2000'],
        ];
    }
}
