<?php

namespace App\Http\Requests\V1\Deposit;

use Illuminate\Foundation\Http\FormRequest;

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

    public function rules(): array
    {
        return [
            'deposit_date' => ['required', 'date'],
            'client_id' => ['nullable', 'integer', 'exists:clients,id'],
            'client_name' => ['nullable', 'string', 'max:100'],
            'bank_account_id' => ['nullable', 'integer', 'exists:bank_accounts,id'],
            'amount' => ['required', 'numeric', 'min:0'],
            'payment_method' => ['required', '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 messages(): array
    {
        return [
            'deposit_date.required' => __('validation.required', ['attribute' => __('validation.attributes.deposit_date')]),
            'amount.required' => __('validation.required', ['attribute' => __('validation.attributes.amount')]),
            'amount.min' => __('validation.min.numeric', ['attribute' => __('validation.attributes.amount'), 'min' => 0]),
            'payment_method.required' => __('validation.required', ['attribute' => __('validation.attributes.payment_method')]),
            'payment_method.in' => __('validation.in', ['attribute' => __('validation.attributes.payment_method')]),
        ];
    }

    public function attributes(): array
    {
        return [
            'deposit_date' => __('validation.attributes.deposit_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'),
        ];
    }
}
