Multi-tenant insurance contracts, service coverage, versioned tariffs, invoice calculation, and insurance claims with debt reporting. - TenantInsurance: per-tenant insurance contracts (coverage/franchise/ceiling, versioning, soft-deactivate) + active guard - ServiceItem.insuranceCovered + TenantServiceCoverage per-service overrides - Tariff: versioned yearly tariffs with fallback to ServiceItem price - Billing domain: Money/ShareBreakdown VOs, BillingCalculator (unit-tested), Invoice/InvoiceItem aggregate, InvoiceService.createFromSession - Claim/ClaimItem with state machine (pending->submitted->approved/rejected->paid), ClaimService, insurance-debt report - ClaimSubmitterInterface + ManualClaimSubmitter (future insurance API ready) - Admin UI: insurance-pricing page, claims page, service tariff modal, service insurance toggle; routes + sidebar entries - Architecture doc + billing/insurance/clinic-services API docs Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
36 lines
2.2 KiB
PHP
36 lines
2.2 KiB
PHP
<?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 Version20260622184409 extends AbstractMigration
|
|
{
|
|
public function getDescription(): string
|
|
{
|
|
return '';
|
|
}
|
|
|
|
public function up(Schema $schema): void
|
|
{
|
|
// this up() migration is auto-generated, please modify it to your needs
|
|
$this->addSql('CREATE TABLE invoice_items (id INT AUTO_INCREMENT NOT NULL, uuid VARCHAR(36) NOT NULL, service_item_id INT DEFAULT NULL, title VARCHAR(200) NOT NULL, tariff_rials INT NOT NULL, quantity INT NOT NULL, total_rials INT NOT NULL, base_insurance_rials INT NOT NULL, supplementary_rials INT NOT NULL, patient_rials INT NOT NULL, invoice_id INT NOT NULL, UNIQUE INDEX UNIQ_DCC4B9F8D17F50A6 (uuid), INDEX IDX_DCC4B9F82989F1FD (invoice_id), PRIMARY KEY (id)) DEFAULT CHARACTER SET utf8mb4');
|
|
$this->addSql('CREATE TABLE invoices (id INT AUTO_INCREMENT NOT NULL, uuid VARCHAR(36) NOT NULL, entity_type VARCHAR(10) NOT NULL, entity_id INT NOT NULL, patient_session_id INT DEFAULT NULL, patient_record_id INT DEFAULT NULL, base_insurance_id INT DEFAULT NULL, supplementary_insurance_id INT DEFAULT NULL, total_rials INT NOT NULL, base_insurance_rials INT NOT NULL, supplementary_rials INT NOT NULL, patient_rials INT NOT NULL, status VARCHAR(15) NOT NULL, issued_at INT NOT NULL, created_at INT NOT NULL, updated_at INT NOT NULL, UNIQUE INDEX UNIQ_6A2F2F95D17F50A6 (uuid), INDEX idx_invoice_tenant (entity_type, entity_id), INDEX idx_invoice_session (patient_session_id), PRIMARY KEY (id)) DEFAULT CHARACTER SET utf8mb4');
|
|
$this->addSql('ALTER TABLE invoice_items ADD CONSTRAINT FK_DCC4B9F82989F1FD FOREIGN KEY (invoice_id) REFERENCES invoices (id) ON DELETE CASCADE');
|
|
}
|
|
|
|
public function down(Schema $schema): void
|
|
{
|
|
// this down() migration is auto-generated, please modify it to your needs
|
|
$this->addSql('ALTER TABLE invoice_items DROP FOREIGN KEY FK_DCC4B9F82989F1FD');
|
|
$this->addSql('DROP TABLE invoice_items');
|
|
$this->addSql('DROP TABLE invoices');
|
|
}
|
|
}
|