<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

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

    public function rules(): array
    {
        return [
            'type'        => 'required|in:receipt,payment,journal,contra',
            'voucher_date'=> 'required|date',
            'account_id'  => 'required|exists:accounts,id',
            'party_id'    => 'nullable|exists:parties,id',
            'amount'      => 'required|numeric|min:0.01',
            'mode'        => 'nullable|string|max:30',
            'cheque_no'   => 'nullable|string|max:30',
            'cheque_date' => 'nullable|date',
            'description'  => 'nullable|string|max:500',
            'sale_id'     => 'nullable|exists:sales,id',
            'purchase_id' => 'nullable|exists:purchases,id',
        ];
    }
}
