49 lines
1.8 KiB
PHP
49 lines
1.8 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Http\Requests;
|
|
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
|
|
class UpdatePurchaseOrderRequest extends FormRequest
|
|
{
|
|
/**
|
|
* Determine if the user is authorized to make this request.
|
|
*/
|
|
public function authorize(): bool
|
|
{
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* Get the validation rules that apply to the request.
|
|
*
|
|
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
|
*/
|
|
public function rules(): array
|
|
{
|
|
return [
|
|
'fournisseur_id' => ['nullable', 'exists:fournisseurs,id'],
|
|
'po_number' => ['nullable', 'string', 'max:191', 'unique:purchase_orders,po_number,' . $this->route('purchase_order')],
|
|
'status' => ['nullable', 'in:brouillon,confirmee,livree,facturee,annulee'],
|
|
'order_date' => ['nullable', 'date'],
|
|
'expected_date' => ['nullable', 'date'],
|
|
'currency' => ['nullable', 'string', 'size:3'],
|
|
'total_ht' => ['nullable', 'numeric', 'min:0'],
|
|
'total_tva' => ['nullable', 'numeric', 'min:0'],
|
|
'total_ttc' => ['nullable', 'numeric', 'min:0'],
|
|
'notes' => ['nullable', 'string'],
|
|
'delivery_address' => ['nullable', 'string'],
|
|
'lines' => ['nullable', 'array', 'min:1'],
|
|
'lines.*.product_id' => ['nullable', 'exists:products,id'],
|
|
'lines.*.description' => ['required', 'string'],
|
|
'lines.*.quantity' => ['required', 'numeric', 'min:0.001'],
|
|
'lines.*.unit_price' => ['required', 'numeric', 'min:0'],
|
|
'lines.*.tva_rate' => ['required', 'numeric', 'min:0'],
|
|
'lines.*.discount_pct' => ['nullable', 'numeric', 'min:0', 'max:100'],
|
|
'lines.*.total_ht' => ['required', 'numeric', 'min:0'],
|
|
];
|
|
}
|
|
}
|