<?php

namespace App\Http\Requests\V1\Sale;

use Illuminate\Foundation\Http\FormRequest;

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

    public function rules(): array
    {
        return [
            'sale_date' => ['sometimes', 'date'],
            'client_id' => ['sometimes', 'integer', 'exists:clients,id'],
            'supply_amount' => ['sometimes', 'numeric', 'min:0'],
            'tax_amount' => ['sometimes', 'numeric', 'min:0'],
            'total_amount' => ['sometimes', 'numeric', 'min:0'],
            'description' => ['nullable', 'string', 'max:1000'],
            'deposit_id' => ['nullable', 'integer', 'exists:deposits,id'],
            'tax_invoice_issued' => ['sometimes', 'boolean'],
            'transaction_statement_issued' => ['sometimes', 'boolean'],
        ];
    }

    public function messages(): array
    {
        return [
            'client_id.exists' => __('validation.exists', ['attribute' => '거래처']),
            'supply_amount.numeric' => __('validation.numeric', ['attribute' => '공급가액']),
            'deposit_id.exists' => __('validation.exists', ['attribute' => '입금']),
        ];
    }
}
