commit melhorias compras3
tests / ci (push) Canceled after 0s

This commit is contained in:
2026-11-22 10:56:58 +02:00
parent 4fac443dda
commit efd97e265b
130 changed files with 8917 additions and 363 deletions
+2 -24
View File
@@ -3,8 +3,8 @@
namespace App\Http\Requests;
use App\Models\User;
use App\Services\RequisitionDraftInput;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
class StoreRequisitionRequest extends FormRequest
{
@@ -21,29 +21,7 @@ class StoreRequisitionRequest extends FormRequest
$user = $this->user('web');
abort_unless($user instanceof User, 403);
return [
'operation_key' => 'nullable|uuid',
'process_version' => 'nullable|integer|min:1',
'cost_center_id' => ['required', 'integer', Rule::exists('cost_centers', 'id')->where('tenant_id', $user->tenant_id)->where('department_id', $user->department_id)],
'priority' => ['required', Rule::in(['normal', 'high', 'urgent'])],
'needed_by' => ['required', 'date_format:Y-m-d', 'after_or_equal:today'],
'justification' => ['required', 'string', 'min:10', 'max:5000'],
'items' => ['required', 'array', 'min:1', 'max:50'],
'items.*.catalogue_entry_id' => 'nullable|integer|min:1',
'items.*.catalogue_version' => 'nullable|required_with:items.*.catalogue_entry_id|integer|min:1',
'items.*.source_line_id' => 'nullable|integer|min:1',
'items.*.description' => ['required_without:items.*.catalogue_entry_id', 'string', 'max:255'],
'items.*.category' => ['required_without:items.*.catalogue_entry_id', 'string', 'max:100'],
'items.*.purchase_type' => ['required_without:items.*.catalogue_entry_id', Rule::in(['consumable', 'service', 'other', 'equipment', 'spare_part'])],
'items.*.equipment_id' => ['exclude_unless:items.*.purchase_type,spare_part', 'required', 'integer', Rule::exists('equipment', 'id')->where('tenant_id', $user->tenant_id)->where('department_id', $user->department_id)],
'items.*.spare_part_id' => ['exclude_unless:items.*.purchase_type,spare_part', 'required', 'integer', Rule::exists('spare_parts', 'id')->where('tenant_id', $user->tenant_id)],
'items.*.production_area' => 'exclude_unless:items.*.purchase_type,equipment|required|string|max:200',
'items.*.downtime_started_at' => 'exclude_unless:items.*.purchase_type,spare_part|nullable|date_format:Y-m-d\TH:i|before_or_equal:now',
'items.*.quantity' => ['required', 'numeric', 'min:0.001', 'max:1000000', 'regex:/^\d+(\.\d{1,3})?$/'],
'items.*.unit' => ['required_without:items.*.catalogue_entry_id', 'string', 'max:30'],
'items.*.unit_price' => ['required', 'numeric', 'min:0.01', 'max:100000000', 'regex:/^\d+(\.\d{1,2})?$/'],
'items.*.tax_rate' => ['required', 'numeric', 'between:0,100', 'regex:/^\d+(\.\d{1,2})?$/'],
];
return app(RequisitionDraftInput::class)->rules($user);
}
/** @return array<string, string> */