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
-171
View File
@@ -1106,35 +1106,6 @@ export interface PolicyClause {
value: unknown;
}
export interface PolicyCondition {
match?: 'all' | 'any';
conditions?: PolicyClause[];
}
export interface PolicyEffect {
type: string;
value?: unknown;
reason?: string;
}
export interface Policy {
uuid: string;
category: PolicyCategory;
name: string;
condition: PolicyCondition;
effects: PolicyEffect[];
priority: number;
version: number;
active: boolean;
valid_from: number | null;
valid_to: number | null;
address_uuid: string | null;
service_uuid: string | null;
catalog_category_uuid: string | null;
specificity: number;
versions?: PolicyVersionLog[];
}
export interface PolicyVersionLog {
version: number;
snapshot: Record<string, unknown>;
@@ -1175,13 +1146,6 @@ export interface PolicyTemplateInput {
max?: number;
}
export interface PolicyTemplate {
key: string;
title: string;
description: string;
category: PolicyCategory;
inputs: PolicyTemplateInput[];
}
export interface SimulationRow {
appointment_uuid: string;
@@ -1205,7 +1169,6 @@ export interface PolicySimulationRun {
warning: string | null;
}
// ── پکیج و اعتبار جلسات (تسک ۱۱) ─────────────────────────────────────────────
export interface PackageDefinition {
uuid: string;
@@ -1219,70 +1182,9 @@ export interface PackageDefinition {
created_at: number;
}
export interface PatientPackage {
uuid: string;
package_uuid: string;
package_name: string;
patient_uuid: string;
session_count: number;
price_paid_rials: number;
purchased_at: number;
valid_to: number | null;
expired: boolean;
/** همیشه از جمع دفتر می‌آید — هیچ ستونی در دیتابیس نیست */
balance: number;
}
export interface CreditLedgerRow {
uuid: string;
kind: 'purchase' | 'consume' | 'refund' | 'adjustment' | 'expiry';
delta: number;
appointment_uuid: string | null;
service_uuid: string | null;
service_name: string | null;
reason: string | null;
created_by: string | null;
created_at: number;
/** در UI محاسبه‌شده نیست — سرور همان جمع تجمعی را می‌دهد */
running_balance: number;
}
export interface CreditLedger {
package: PatientPackage;
rows: CreditLedgerRow[];
}
// ── دورهٔ درمان (تسک ۱۲) ──────────────────────────────────────────────────────
export interface CourseProtocolStep {
session_number: number;
params: Record<string, string | number | boolean>;
override_duration_minutes: number | null;
}
export interface CourseProtocol {
uuid: string;
service_uuid: string;
service_name: string;
session_count: number;
min_days: number;
ideal_days: number;
max_days: number;
prefer_same_resource: boolean;
active: boolean;
steps: CourseProtocolStep[];
created_at: number;
}
export interface CourseSessionRow {
uuid: string;
session_number: number;
params: Record<string, string | number | boolean>;
appointment_uuid: string | null;
slot_start: number | null;
status: 'planned' | 'booked' | 'completed' | 'skipped';
completed_at: number | null;
}
export interface CourseProgress {
completed: number;
@@ -1295,29 +1197,6 @@ export interface CourseProgress {
last_completed_at: number | null;
}
export interface TreatmentCourse {
uuid: string;
patient_uuid: string;
service_uuid: string;
service_name: string;
protocol_uuid: string;
session_count: number;
min_days: number;
ideal_days: number;
max_days: number;
patient_package_uuid: string | null;
preferred_resource_uuid: string | null;
preferred_resource_name: string | null;
package_balance?: number | null;
package_shortfall?: number | null;
status: 'active' | 'completed' | 'abandoned';
abandon_reason: string | null;
started_at: number;
completed_at: number | null;
progress: CourseProgress;
sessions?: CourseSessionRow[];
}
export interface NextSlotSuggestion {
session_number: number | null;
params: Record<string, string | number | boolean>;
@@ -1327,57 +1206,7 @@ export interface NextSlotSuggestion {
warning: string | null;
}
// ── لغو و لیست انتظار (تسک ۱۳) ───────────────────────────────────────────────
export interface CancellationPolicy {
uuid: string;
service_uuid: string | null;
service_name: string | null;
free_window_hours: number;
penalty_mode: 'none' | 'percent' | 'fixed';
penalty_value: number;
deposit_refundable: boolean;
credit_refundable: boolean;
no_show_threshold: number;
risk_tag_uuid: string | null;
active: boolean;
created_at: number;
}
export interface CancellationPreview {
penalty_rials: number;
deposit_refundable: boolean;
credit_refundable: boolean;
within_free_window: boolean;
notes: string[];
paid_rials: number;
}
export interface CancellationResult extends Omit<CancellationPreview, 'paid_rials'> {
appointment_uuid: string;
status: string;
released_resources: number;
waitlist_notified: number;
penalty_charged: boolean;
}
export interface WaitlistEntry {
uuid: string;
patient_uuid: string;
service_uuid: string;
service_name: string;
branch_id: number | null;
desired_from: number;
desired_to: number;
preferred_day_parts: string[];
priority: number;
status: 'waiting' | 'notified' | 'converted' | 'expired';
notified_at: number | null;
notify_count: number;
created_at: number;
}
// ── گزارش‌ها (تسک ۱۴) ────────────────────────────────────────────────────────
export interface UtilizationRow {
resource_uuid: string;