refactor(pricing): make the service the only price source
Price lists, annual tariffs and per-branch price overrides each answered
"what does this service cost?" differently, so a single date could carry
several answers and nobody could say which one was right. Price now lives
only on ServiceItem.price_rials, edited from the services page.
- drop PriceList/PriceListItem, their repositories and the seven
/api/v1/price-list(s) endpoints; PricingController keeps only quote and
the appointment price snapshot
- drop Tariff, TariffRepository, TariffService and the two
/service-items/{uuid}/tariffs endpoints; creating or repricing a service
no longer upserts a current-year tariff
- drop price_rials from ServiceBranchOverride; the entity stays for its
duration columns, which DurationCalculator and ServiceSelectionValidator
still read
- InvoiceService reads the item price directly
- PricingEngine collapses to a single source; breakdown.sources always
reports service_item, keeping the response contract intact
- remove the price-lists admin page, its route and settings-menu entry, the
tariff modal and the service detail tariffs tab; useAppointmentInvoice
moves to its own hook file
Migration drops price_lists, price_list_items, service_tariffs and the
override price column.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -18,8 +18,6 @@ use App\ClinicService\Entity\ServiceItem;
|
||||
use App\ClinicService\Entity\ServiceItemRelation;
|
||||
use App\Doctor\Entity\DoctorAddress;
|
||||
use App\Patient\Entity\PatientRecord;
|
||||
use App\Pricing\Entity\PriceList;
|
||||
use App\Pricing\Entity\PriceListItem;
|
||||
use App\Pricing\Service\PriceSnapshotService;
|
||||
use App\Pricing\ValueObject\PriceQuote;
|
||||
use App\Resource\Entity\ClinicResource;
|
||||
@@ -87,7 +85,6 @@ final class BookingEngineSeeder
|
||||
$counts['catalog'] = $this->catalog($entityType, $entityId, $services, $address);
|
||||
$counts['resources'] = $this->skillsPoolsAndExceptions($entityType, $entityId, $address, $devices, $deviceType);
|
||||
$counts['segments'] = $this->multiSegmentPlan($flagship, $deviceType, $entityType, $entityId, $address);
|
||||
$counts['pricing'] = $this->priceList($entityType, $entityId, $services);
|
||||
$counts['offerings'] = $this->serviceOfferings($address, $devices, $services);
|
||||
$counts['booked'] = $this->realBookings($flagship, $address, $patients, $doctor, $clinic, $entityType, $entityId);
|
||||
|
||||
@@ -127,9 +124,9 @@ final class BookingEngineSeeder
|
||||
$this->em()->persist(new ServiceItemRelation($services[0], $services[1], ServiceItemRelation::TYPE_INCOMPATIBLE));
|
||||
}
|
||||
|
||||
// قیمت و مدت این سرویس در این شعبه فرق دارد — تا override واقعاً تست شود.
|
||||
// مدت این سرویس در این شعبه فرق دارد — تا override واقعاً تست شود.
|
||||
$override = new ServiceBranchOverride($services[1] ?? $services[0], $address);
|
||||
$override->setPriceRials((int) round(($services[1] ?? $services[0])->getPriceRials() * 1.2));
|
||||
$override->setSoloDurationMinutes(max(5, (($services[1] ?? $services[0])->getSoloDurationMinutes() ?? 20) + 10));
|
||||
$this->em()->persist($override);
|
||||
|
||||
$this->em()->flush();
|
||||
@@ -261,25 +258,6 @@ final class BookingEngineSeeder
|
||||
return $made;
|
||||
}
|
||||
|
||||
// ── تسک ۰۸: لیست قیمت ───────────────────────────────────────────────────
|
||||
|
||||
private function priceList(string $entityType, int $entityId, array $services): int
|
||||
{
|
||||
$list = new PriceList($entityType, $entityId, 'تعرفهٔ نیمسال دوم', strtotime('-30 days'), strtotime('+180 days'));
|
||||
$list->setActive(true);
|
||||
$this->em()->persist($list);
|
||||
$this->em()->flush();
|
||||
|
||||
foreach ($services as $service) {
|
||||
// قیمت لیست عمداً با قیمت پایهٔ سرویس فرق دارد: اگر یکی بودند، معلوم نمیشد
|
||||
// snapshot از کدام منبع خوانده است.
|
||||
$this->em()->persist(new PriceListItem($list, $service, (int) round($service->getPriceRials() * 0.9)));
|
||||
}
|
||||
$this->em()->flush();
|
||||
|
||||
return count($services);
|
||||
}
|
||||
|
||||
// ── تسک ۰۹: سیاستها، یکی از هر دسته ────────────────────────────────────
|
||||
|
||||
// ── تسک ۰۶ و ۰۷: رزرو واقعی روی تقویم منابع ─────────────────────────────
|
||||
|
||||
@@ -109,12 +109,10 @@ final class GlobalTables
|
||||
|
||||
\App\ClinicService\Entity\ServiceItemAuditLog::class => \App\ClinicService\Entity\ServiceItem::class,
|
||||
\App\ClinicService\Entity\ServiceItemConsumable::class => \App\ClinicService\Entity\ServiceItem::class,
|
||||
\App\ClinicService\Entity\Tariff::class => \App\ClinicService\Entity\ServiceItem::class,
|
||||
\App\ClinicService\Entity\ItemGroupMember::class => \App\ClinicService\Entity\ItemGroup::class,
|
||||
// یال «این دسته شامل آن دسته است» جزئی از تعریف دستهٔ والد است؛ هر دو سرِ یال
|
||||
// در یک محیطاند و سازندهٔ یال همین را اجبار میکند.
|
||||
\App\ClinicService\Entity\CatalogCategoryInclude::class => \App\ClinicService\Entity\CatalogCategory::class,
|
||||
\App\Pricing\Entity\PriceListItem::class => \App\Pricing\Entity\PriceList::class,
|
||||
|
||||
\App\Billing\Entity\ClaimItem::class => \App\Billing\Entity\Claim::class,
|
||||
\App\Billing\Entity\ClaimStatusLog::class => \App\Billing\Entity\Claim::class,
|
||||
|
||||
Reference in New Issue
Block a user