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
@@ -9,7 +9,9 @@ use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Uid\Uuid;
/**
* قیمت و مدتِ اختصاصیِ یک سرویس در یک شعبه.
* مدتِ اختصاصیِ یک سرویس در یک شعبه.
*
* قیمت اینجا نیست: تنها منبع قیمت `ServiceItem::priceRials` است.
*
* «شعبه» همان `doctor_addresses` است ({@see docs/new_feture/taskes/_shared/branch-is-doctor-address.md}).
* هر ستون تهی‌پذیر است و `null` یعنی «همان مقدار خودِ سرویس» — نه صفر.
@@ -38,9 +40,6 @@ class ServiceBranchOverride
#[ORM\JoinColumn(name: 'address_id', referencedColumnName: 'id', nullable: false, onDelete: 'CASCADE')]
private DoctorAddress $address;
#[ORM\Column(name: 'price_rials', type: 'bigint', nullable: true)]
private ?int $priceRials = null;
#[ORM\Column(name: 'solo_duration_minutes', type: 'smallint', nullable: true)]
private ?int $soloDurationMinutes = null;
@@ -68,11 +67,9 @@ class ServiceBranchOverride
public function getUuid(): string { return $this->uuid; }
public function getItem(): ServiceItem { return $this->item; }
public function getAddress(): DoctorAddress { return $this->address; }
public function getPriceRials(): ?int { return $this->priceRials === null ? null : (int) $this->priceRials; }
public function getSoloDurationMinutes(): ?int { return $this->soloDurationMinutes; }
public function getAdditionalDurationMinutes(): ?int { return $this->additionalDurationMinutes; }
public function setPriceRials(?int $v): self { $this->priceRials = $v; $this->touch(); return $this; }
public function setSoloDurationMinutes(?int $v): self { $this->soloDurationMinutes = $v; $this->touch(); return $this; }
public function setAdditionalDurationMinutes(?int $v): self { $this->additionalDurationMinutes = $v; $this->touch(); return $this; }
@@ -85,7 +82,6 @@ class ServiceBranchOverride
'item_uuid' => $this->item->getUuid(),
'address_uuid' => $this->address->getUuid(),
'address_name' => $this->address->getName(),
'price_rials' => $this->getPriceRials(),
'solo_duration_minutes' => $this->soloDurationMinutes,
'additional_duration_minutes' => $this->additionalDurationMinutes,
];
+1 -1
View File
@@ -104,7 +104,7 @@ class ServiceItem
/**
* پکیج کالای مصرفی این خدمت ({@see \App\Inventory\Entity\InventoryPackage}).
* ارجاع خام int بدون FK — همان الگوی Tariff و TenantServiceCoverage — تا دامنهٔ
* ارجاع خام int بدون FK — همان الگوی TenantServiceCoverage — تا دامنهٔ
* ClinicService به Inventory وابسته نشود.
*/
#[ORM\Column(name: 'inventory_package_id', type: 'integer', nullable: true)]
-71
View File
@@ -1,71 +0,0 @@
<?php
namespace App\ClinicService\Entity;
use App\ClinicService\Repository\TariffRepository;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Uid\Uuid;
#[ORM\Entity(repositoryClass: TariffRepository::class)]
#[ORM\Table(name: 'service_tariffs')]
#[ORM\UniqueConstraint(name: 'uniq_service_tariff_year', columns: ['service_item_id', 'year'])]
#[ORM\Index(columns: ['service_item_id', 'is_active'], name: 'idx_tariff_service_active')]
class Tariff
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private ?int $id = null;
#[ORM\Column(type: 'string', length: 36, unique: true)]
private string $uuid;
#[ORM\Column(name: 'service_item_id', type: 'integer')]
private int $serviceItemId;
#[ORM\Column(type: 'smallint')]
private int $year;
#[ORM\Column(name: 'price_rials', type: 'integer')]
private int $priceRials = 0;
#[ORM\Column(name: 'is_active', type: 'boolean')]
private bool $isActive = true;
#[ORM\Column(name: 'created_at', type: 'integer')]
private int $createdAt;
#[ORM\Column(name: 'updated_at', type: 'integer')]
private int $updatedAt;
public function __construct(int $serviceItemId, int $year, int $priceRials = 0)
{
$this->uuid = Uuid::v4()->toRfc4122();
$this->serviceItemId = $serviceItemId;
$this->year = $year;
$this->priceRials = $priceRials;
$this->createdAt = time();
$this->updatedAt = time();
}
public function getId(): ?int { return $this->id; }
public function getUuid(): string { return $this->uuid; }
public function getServiceItemId(): int { return $this->serviceItemId; }
public function getYear(): int { return $this->year; }
public function getPriceRials(): int { return $this->priceRials; }
public function isActive(): bool { return $this->isActive; }
public function setPriceRials(int $v): self { $this->priceRials = $v; $this->updatedAt = time(); return $this; }
public function setActive(bool $v): self { $this->isActive = $v; $this->updatedAt = time(); return $this; }
public function toArray(): array
{
return [
'uuid' => $this->uuid,
'service_item_id' => $this->serviceItemId,
'year' => $this->year,
'price_rials' => $this->priceRials,
'is_active' => $this->isActive,
];
}
}