Files
clinicpro/migrations/Version20260725144018.php
hamed 8d2b0d908a feat: Add online share functionality for secretaries
- Introduced `online_share_enabled` and `online_share_percent` fields in the `doctor_secretaries` table to manage secretary shares from online appointments.
- Added `bank_account` field in the `profiles` table to store user-level IBANs for settlements.
- Created `secretary_earnings` table to track earnings per secretary from online appointments, including a foreign key relationship with `financial_breakdowns`.
- Implemented `SecretaryEarning` entity and repository for managing secretary earnings.
- Developed `SecretaryShareResolver` service to determine which secretaries earn from online payments.
- Added `UserIbanResolver` service to handle user IBAN retrieval and management.
- Created `HasIbansTrait` for entities to manage IBANs in a JSON format.
- Implemented tests for secretary earnings and API endpoints for managing secretary shares and IBANs.
2026-07-25 18:34:18 +03:30

37 lines
1.9 KiB
PHP

<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Secretary share of an online appointment: the total on the payment's financial
* breakdown, plus one row per secretary so the panel can report per user.
*/
final class Version20260725144018 extends AbstractMigration
{
public function getDescription(): string
{
return 'Add secretary_earnings and financial_breakdowns.secretary_share_rials';
}
public function up(Schema $schema): void
{
$this->addSql('CREATE TABLE secretary_earnings (id INT AUTO_INCREMENT NOT NULL, uuid VARCHAR(36) NOT NULL, relation_uuid VARCHAR(36) NOT NULL, share_percent NUMERIC(5, 2) NOT NULL, share_rials INT NOT NULL, created_at INT NOT NULL, breakdown_id INT NOT NULL, secretary_user_id INT NOT NULL, UNIQUE INDEX UNIQ_8F257C76D17F50A6 (uuid), INDEX IDX_8F257C7667F54C40 (breakdown_id), INDEX IDX_8F257C7658E93B3D (secretary_user_id), INDEX idx_secretary_earnings_user_time (secretary_user_id, created_at), PRIMARY KEY (id)) DEFAULT CHARACTER SET utf8mb4');
$this->addSql('ALTER TABLE secretary_earnings ADD CONSTRAINT FK_8F257C7667F54C40 FOREIGN KEY (breakdown_id) REFERENCES financial_breakdowns (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE secretary_earnings ADD CONSTRAINT FK_8F257C7658E93B3D FOREIGN KEY (secretary_user_id) REFERENCES users (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE financial_breakdowns ADD secretary_share_rials INT DEFAULT 0 NOT NULL');
}
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE secretary_earnings DROP FOREIGN KEY FK_8F257C7667F54C40');
$this->addSql('ALTER TABLE secretary_earnings DROP FOREIGN KEY FK_8F257C7658E93B3D');
$this->addSql('DROP TABLE secretary_earnings');
$this->addSql('ALTER TABLE financial_breakdowns DROP secretary_share_rials');
}
}