<?php

namespace App\Modules\Integration\Requests;

use Illuminate\Foundation\Http\FormRequest;

class SyncOrderRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     */
    public function authorize(): bool
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
     */
    public function rules(): array
    {
        return [
            'external_order_id' => 'required|string',
            'warehouse_code' => 'required|string',
            'payment_method' => 'nullable|string|in:cash,credit_card,line_pay,ecpay,transfer,other',
            'sold_at' => 'nullable|date',
            'items' => 'required|array|min:1',
            'items.*.pos_product_id' => 'required|string',
            'items.*.qty' => 'required|numeric|min:0.0001',
            'items.*.price' => 'required|numeric|min:0',
        ];
    }
}
