27 lines
895 B
PHP
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;
|
|
}
|
|
}
|