<?php

namespace App\Http\Requests\Finance;

use Illuminate\Foundation\Http\FormRequest;

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

    public function rules(): array
    {
        return [
            'date' => ['sometimes', 'required', 'date_format:Y-m-d'],
            'kg_sold' => ['sometimes', 'required', 'numeric', 'min:0'],
            'price_crc_per_kg' => ['sometimes', 'required', 'numeric', 'min:0'],
            'total_crc' => ['sometimes', 'required', 'numeric', 'min:0'],
            'customer_name' => ['sometimes', 'nullable', 'string', 'max:255'],
            'scope' => ['sometimes', 'nullable', 'array'],
            'scope.batch_id' => ['sometimes', 'nullable', 'integer'],
            'scope.tank_id' => ['sometimes', 'nullable', 'integer'],
            'notes' => ['sometimes', 'nullable', 'string', 'max:4000'],
            'updated_at' => ['sometimes', 'nullable', 'date'],
        ];
    }
}
