Files
compras/app/Services/SupplierParticipation.php
2026-11-03 11:51:44 +02:00

27 lines
895 B
PHP

<?php
namespace App\Services;
use App\Models\Supplier;
use App\Models\User;
/** Shared eligibility; review commands still validate the current version and activation facts. */
class SupplierParticipation
{
public function canPrepare(User $actor): bool
{
return $actor->tenant_id !== null && $actor->hasFunctions(['procurement']) && ! app(OrganizationAccess::class)->maintenanceOnly($actor);
}
public function canReviewRole(User $actor): bool
{
return $actor->tenant_id !== null && $actor->hasFunctions(['finance']) && ! app(OrganizationAccess::class)->maintenanceOnly($actor);
}
public function canReview(User $actor, Supplier $supplier): bool
{
return $actor->tenant_id === $supplier->tenant_id && $this->canReviewRole($actor)
&& $actor->id !== $supplier->created_by && $actor->id !== $supplier->last_changed_by;
}
}