@@ -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')) {
|
||||
|
||||
Reference in New Issue
Block a user