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:
hamed
2026-08-02 18:00:48 +03:30
co-authored by Claude Opus 5
parent f06efe26c0
commit 4fe0c4f9bf
41 changed files with 208 additions and 1835 deletions
@@ -81,10 +81,10 @@ class ResourceServiceResolverTest extends ApiTestCase
return $offering;
}
private function branchOverride(ServiceItem $item, ?int $minutes, ?int $price): void
private function branchOverride(ServiceItem $item, ?int $minutes): void
{
$override = new ServiceBranchOverride($item, $this->address);
$override->setSoloDurationMinutes($minutes)->setPriceRials($price);
$override->setSoloDurationMinutes($minutes);
$this->em->persist($override);
$this->em->flush();
}
@@ -100,7 +100,7 @@ class ResourceServiceResolverTest extends ApiTestCase
{
$this->offer($this->option, 15, 9_500_000);
$this->offer($this->service, 40, 12_000_000);
$this->branchOverride($this->option, 50, 11_000_000);
$this->branchOverride($this->option, 50);
$spec = $this->resolve();
@@ -113,7 +113,7 @@ class ResourceServiceResolverTest extends ApiTestCase
public function testLevelTwoResourcePlusServiceWinsWhenTheOptionHasNothing(): void
{
$this->offer($this->service, 40, 12_000_000);
$this->branchOverride($this->option, 50, 11_000_000);
$this->branchOverride($this->option, 50);
$spec = $this->resolve();
@@ -122,15 +122,17 @@ class ResourceServiceResolverTest extends ApiTestCase
self::assertSame(ResolvedServiceSpec::SOURCE_RESOURCE_SERVICE, $spec->durationSource);
}
public function testLevelThreeBranchWinsWhenTheResourceHasNothing(): void
/** شعبه فقط مدت می‌دهد؛ قیمتش را از خودِ سرویس می‌گیرد. */
public function testLevelThreeBranchWinsForDurationOnly(): void
{
$this->branchOverride($this->option, 50, 11_000_000);
$this->branchOverride($this->option, 50);
$spec = $this->resolve();
self::assertSame(50, $spec->durationMinutes);
self::assertSame(11_000_000, $spec->priceRials);
self::assertSame(ResolvedServiceSpec::SOURCE_BRANCH, $spec->durationSource);
self::assertSame(8_000_000, $spec->priceRials);
self::assertSame(ResolvedServiceSpec::SOURCE_SERVICE_DEFAULT, $spec->priceSource);
}
public function testLevelFourFallsBackToTheItemItself(): void
@@ -147,17 +149,17 @@ class ResourceServiceResolverTest extends ApiTestCase
public function testDurationAndPriceResolveIndependently(): void
{
// منبع فقط مدت را می‌گوید؛ قیمت باید تا سطح شعبه پایین برود.
// منبع فقط مدت را می‌گوید؛ قیمت باید تا خودِ سرویس پایین برود.
$this->offer($this->option, 15, null);
$this->branchOverride($this->option, null, 11_000_000);
$this->branchOverride($this->option, null);
$spec = $this->resolve();
self::assertSame(15, $spec->durationMinutes);
self::assertSame(ResolvedServiceSpec::SOURCE_RESOURCE_OPTION, $spec->durationSource);
self::assertSame(11_000_000, $spec->priceRials);
self::assertSame(ResolvedServiceSpec::SOURCE_BRANCH, $spec->priceSource);
self::assertSame(8_000_000, $spec->priceRials);
self::assertSame(ResolvedServiceSpec::SOURCE_SERVICE_DEFAULT, $spec->priceSource);
}
public function testAnInactiveOfferingIsSkippedEntirely(): void