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>
48 lines
3.8 KiB
PHP
48 lines
3.8 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace DoctrineMigrations;
|
|
|
|
use Doctrine\DBAL\Schema\Schema;
|
|
use Doctrine\Migrations\AbstractMigration;
|
|
|
|
/**
|
|
* Drop every price source other than the service itself.
|
|
*
|
|
* Price lists, annual tariffs and per-branch price overrides each answered
|
|
* "what does this service cost?" differently, so one date could carry several
|
|
* answers. Price is now owned solely by `service_items.price_rials`; branch
|
|
* overrides keep their duration columns.
|
|
*/
|
|
final class Version20260802140757 extends AbstractMigration
|
|
{
|
|
public function getDescription(): string
|
|
{
|
|
return 'Drop price_lists, price_list_items, service_tariffs and service_branch_overrides.price_rials';
|
|
}
|
|
|
|
public function up(Schema $schema): void
|
|
{
|
|
$this->addSql('ALTER TABLE price_lists DROP FOREIGN KEY `FK_23EF97C5F5B7AF75`');
|
|
$this->addSql('ALTER TABLE price_list_items DROP FOREIGN KEY `FK_8C05724A5688DED7`');
|
|
$this->addSql('ALTER TABLE price_list_items DROP FOREIGN KEY `FK_8C05724ADDEB00C2`');
|
|
$this->addSql('DROP TABLE price_list_items');
|
|
$this->addSql('DROP TABLE price_lists');
|
|
$this->addSql('DROP TABLE service_tariffs');
|
|
$this->addSql('ALTER TABLE service_branch_overrides DROP price_rials');
|
|
}
|
|
|
|
public function down(Schema $schema): void
|
|
{
|
|
// Schema only — the dropped rows are gone for good.
|
|
$this->addSql('CREATE TABLE price_lists (id INT AUTO_INCREMENT NOT NULL, uuid VARCHAR(36) CHARACTER SET utf8mb4 NOT NULL COLLATE `utf8mb4_unicode_520_ci`, name VARCHAR(150) CHARACTER SET utf8mb4 NOT NULL COLLATE `utf8mb4_unicode_520_ci`, starts_at INT NOT NULL, ends_at INT NOT NULL, active TINYINT DEFAULT 0 NOT NULL, created_at INT NOT NULL, updated_at INT NOT NULL, entity_type VARCHAR(10) CHARACTER SET utf8mb4 NOT NULL COLLATE `utf8mb4_unicode_520_ci`, entity_id INT NOT NULL, address_id INT DEFAULT NULL, INDEX IDX_23EF97C5F5B7AF75 (address_id), INDEX idx_price_list_range (starts_at, ends_at), INDEX idx_price_list_tenant (entity_type, entity_id, active), UNIQUE INDEX UNIQ_23EF97C5D17F50A6 (uuid), PRIMARY KEY (id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_520_ci` ENGINE = InnoDB');
|
|
$this->addSql('CREATE TABLE price_list_items (id INT AUTO_INCREMENT NOT NULL, price_rials BIGINT NOT NULL, price_list_id INT NOT NULL, service_item_id INT NOT NULL, INDEX IDX_8C05724ADDEB00C2 (service_item_id), UNIQUE INDEX uniq_price_list_service (price_list_id, service_item_id), INDEX IDX_8C05724A5688DED7 (price_list_id), PRIMARY KEY (id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_520_ci` ENGINE = InnoDB');
|
|
$this->addSql('CREATE TABLE service_tariffs (id INT AUTO_INCREMENT NOT NULL, uuid VARCHAR(36) CHARACTER SET utf8mb4 NOT NULL COLLATE `utf8mb4_unicode_520_ci`, service_item_id INT NOT NULL, year SMALLINT NOT NULL, price_rials INT NOT NULL, is_active TINYINT NOT NULL, created_at INT NOT NULL, updated_at INT NOT NULL, INDEX idx_tariff_service_active (service_item_id, is_active), UNIQUE INDEX UNIQ_FAAAF536D17F50A6 (uuid), UNIQUE INDEX uniq_service_tariff_year (service_item_id, year), PRIMARY KEY (id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_520_ci` ENGINE = InnoDB');
|
|
$this->addSql('ALTER TABLE price_lists ADD CONSTRAINT `FK_23EF97C5F5B7AF75` FOREIGN KEY (address_id) REFERENCES doctor_addresses (id) ON DELETE CASCADE');
|
|
$this->addSql('ALTER TABLE price_list_items ADD CONSTRAINT `FK_8C05724A5688DED7` FOREIGN KEY (price_list_id) REFERENCES price_lists (id) ON DELETE CASCADE');
|
|
$this->addSql('ALTER TABLE price_list_items ADD CONSTRAINT `FK_8C05724ADDEB00C2` FOREIGN KEY (service_item_id) REFERENCES service_items (id) ON DELETE CASCADE');
|
|
$this->addSql('ALTER TABLE service_branch_overrides ADD price_rials BIGINT DEFAULT NULL');
|
|
}
|
|
}
|