Refactor booking system: Remove unused policies, packages, and related entities

- Removed package consumption flags and related properties from PriceQuote.
- Eliminated unused domain event publishing for policies and waitlist in Schedule.
- Cleaned up BookingEngineSeeder by removing package and policy related logic.
- Updated SeedScenariosCommand to reflect removal of policies from output.
- Dropped policy, package, treatment course, cancellation, waitlist, and domain event tables in migration.
- Removed domain event assertions from tests related to resource blocking.
This commit is contained in:
hamed
2026-08-01 20:50:47 +03:30
parent 9486721fa3
commit c4f1f25c80
27 changed files with 129 additions and 1510 deletions
@@ -9,8 +9,6 @@ use App\ClinicService\Entity\ServiceItemRelation;
use App\ClinicService\Repository\ItemGroupMemberRepository;
use App\ClinicService\Repository\ServiceItemRelationRepository;
use App\Doctor\Entity\DoctorAddress;
use App\Policy\Entity\Policy;
use App\Policy\Engine\SelectionPolicyEngine;
use App\ClinicService\Repository\ServiceBranchOverrideRepository;
/**
@@ -30,7 +28,6 @@ final class ServiceSelectionValidator
private readonly ServiceItemRelationRepository $relations,
private readonly ServiceBranchOverrideRepository $overrides,
private readonly DurationCalculator $durations,
private readonly SelectionPolicyEngine $selectionPolicies,
) {}
/**
@@ -43,7 +40,6 @@ final class ServiceSelectionValidator
$errors = [
...$this->groupErrors($selected, $groups),
...$this->relationErrors($selected),
...$this->policyErrors($selected, $address),
];
$overrides = $address === null
@@ -62,52 +58,6 @@ final class ServiceSelectionValidator
];
}
/**
* ممنوعیت‌های دستهٔ «انتخاب» — لایه‌ای روی گروه و رابطه، نه جایگزینشان.
*
* گروه و رابطه ساختار ثابتِ کاتالوگ‌اند؛ قانون چیزی است که کلینیک بدون دست زدن
* به کاتالوگ روشن و خاموش می‌کند. بدون شعبه اجرا نمی‌شود چون محیط از آدرس
* می‌آید و بی‌آن هیچ محیطی برای جست‌وجو نیست.
*
* @param ServiceItem[] $selected
* @return list<array<string, mixed>>
*/
private function policyErrors(array $selected, ?DoctorAddress $address): array
{
if ($address === null || $selected === []) {
return [];
}
$facts = [
'item_count' => count($selected),
'item_uuids' => array_map(static fn (ServiceItem $i): string => $i->getUuid(), $selected),
];
$errors = [];
// هر آیتم جداگانه حل می‌شود: قانونی که دامنه‌اش یک سرویس خاص است فقط وقتی
// معنا دارد که همان سرویس در انتخاب باشد، و پیام خطا باید بگوید کدام.
foreach ($selected as $item) {
$outcome = $this->selectionPolicies->evaluate(
$address->tenantEntityType(),
$address->tenantEntityId(),
$facts + ['catalog_category' => $item->getCatalogCategory()?->getUuid()],
$address,
$item,
);
foreach ($outcome->forbidReasons as $reason) {
$errors[] = [
'code' => 'policy_forbidden',
'items' => [$item->getUuid()],
'message' => $reason,
];
}
}
return $errors;
}
/**
* @param ServiceItem[] $selected
* @param ItemGroup[] $groups