<?php

namespace App\Http\Requests\V1\Withdrawal;

use Illuminate\Foundation\Http\FormRequest;

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

    public function rules(): array
    {
        return [
            'withdrawal_date' => ['sometimes', 'date'],
            'client_id' => ['nullable', 'integer', 'exists:clients,id'],
            'client_name' => ['nullable', 'string', 'max:100'],
            'bank_account_id' => ['nullable', 'integer', 'exists:bank_accounts,id'],
            'amount' => ['sometimes', 'numeric', 'min:0'],
            'payment_method' => ['sometimes', 'string', 'in:cash,transfer,card,check'],
            'account_code' => ['nullable', 'string', 'max:20'],
            'description' => ['nullable', 'string', 'max:1000'],
            'reference_type' => ['nullable', 'string', 'max:50'],
            'reference_id' => ['nullable', 'integer'],
        ];
    }

    public function attributes(): array
    {
        return [
            'withdrawal_date' => __('validation.attributes.withdrawal_date'),
            'client_id' => __('validation.attributes.client_id'),
            'client_name' => __('validation.attributes.client_name'),
            'bank_account_id' => __('validation.attributes.bank_account_id'),
            'amount' => __('validation.attributes.amount'),
            'payment_method' => __('validation.attributes.payment_method'),
            'account_code' => __('validation.attributes.account_code'),
            'description' => __('validation.attributes.description'),
        ];
    }
}
