feat(discount): add DiscountRule entity and session discount-rule audit columns
New Discount domain: DiscountRule (generic per-tenant rule with 6 types, priority, combinable, validity window, and per-type target fields) plus its repository. PatientSession gains applied_discount_rule_id/label audit columns and setDiscount() now records the source rule. Migration creates the table and columns. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace DoctrineMigrations;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Auto-generated Migration: Please modify to your needs!
|
||||
*/
|
||||
final class Version20260717081632 extends AbstractMigration
|
||||
{
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'Add discount_rules table + applied_discount_rule audit columns on patient_sessions';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
$this->addSql('CREATE TABLE discount_rules (id INT AUTO_INCREMENT NOT NULL, uuid VARCHAR(36) NOT NULL, owner_type VARCHAR(10) NOT NULL, owner_id INT NOT NULL, name VARCHAR(120) NOT NULL, type VARCHAR(20) NOT NULL, discount_type VARCHAR(10) NOT NULL, value INT NOT NULL, priority INT NOT NULL, combinable TINYINT DEFAULT 0 NOT NULL, active TINYINT DEFAULT 1 NOT NULL, valid_from INT DEFAULT NULL, valid_to INT DEFAULT NULL, target_tag_id INT DEFAULT NULL, target_record_id INT DEFAULT NULL, target_service_item_id INT DEFAULT NULL, min_amount_rials INT DEFAULT NULL, min_visit_count INT DEFAULT NULL, occasion_kind VARCHAR(20) DEFAULT NULL, created_at INT NOT NULL, updated_at INT NOT NULL, UNIQUE INDEX UNIQ_A2B041ABD17F50A6 (uuid), INDEX idx_discount_rules_owner (owner_type, owner_id, active), PRIMARY KEY (id)) DEFAULT CHARACTER SET utf8mb4');
|
||||
$this->addSql('ALTER TABLE patient_sessions ADD applied_discount_rule_id INT DEFAULT NULL, ADD applied_discount_rule_label VARCHAR(120) DEFAULT NULL');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->addSql('DROP TABLE discount_rules');
|
||||
$this->addSql('ALTER TABLE patient_sessions DROP applied_discount_rule_id, DROP applied_discount_rule_label');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user