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

This commit is contained in:
2026-11-22 16:28:03 +02:00
parent efd97e265b
commit 36dcfdf00c
118 changed files with 6042 additions and 92 deletions
+10 -3
View File
@@ -73,9 +73,15 @@ final class InternalRequisitionPort implements RequisitionPort
abort_unless($record['requester_id'] === $this->actor->id, 403);
}
} elseif ($action === 'decide') {
abort_unless($this->actor->hasFunctions(['department_head', 'procurement', 'finance']), 403);
abort_unless($this->actor->hasFunctions(['department_head', 'procurement', 'finance', 'requisition_approve']), 403);
} elseif (str_starts_with($action, 'step:')) {
$role = substr($action, 5);
if (str_starts_with($role, 'configured_')) {
$step = $this->model($record['id'])->steps()->where('role', $role)->firstOrFail();
abort_unless(app(RequisitionApprovalLevels::class)->eligible($this->actor, $this->model($record['id']), $step->toArray()), 403);
return;
}
abort_unless($this->actor->hasFunctions([$role]) && ($role !== 'department_head' || $this->actor->department_id === $record['department_id']), 403);
}
}
@@ -117,7 +123,7 @@ final class InternalRequisitionPort implements RequisitionPort
throw ValidationException::withMessages(['submission' => 'Actualize a data de entrega antes de submeter.']);
}
return Tenant::query()->findOrFail($this->actor->tenant_id)->only(['first_limit_minor', 'second_limit_minor', 'approval_includes_tax', 'rules_provisional']);
return [...Tenant::query()->findOrFail($this->actor->tenant_id)->only(['first_limit_minor', 'second_limit_minor', 'approval_includes_tax', 'rules_provisional']), ...app(RequisitionApprovalLevels::class)->policy($r)];
}
public function reserve(array $record): ?array
@@ -129,7 +135,8 @@ final class InternalRequisitionPort implements RequisitionPort
{
$r = $this->model($record['id']);
foreach ($roles as $position => $role) {
$r->steps()->create(['tenant_id' => $this->actor->tenant_id, 'position' => $position + 1, 'role' => $role]);
$r->steps()->create(['tenant_id' => $this->actor->tenant_id, 'position' => $position + 1, 'role' => $role,
...(isset($policy['additional_levels'][$role]) ? ['routing' => $policy['additional_levels'][$role]] : [])]);
}
$values = ['status' => 'pending', 'submitted_at' => now(), 'approval_snapshot' => $policy];
if (Schema::hasColumn('requisitions', 'process_version')) {