Add a per-tenant (doctor/clinic) Inventory domain and admin page, ported from clinic-pro-tauri /inventory (which was static/mock) into a real feature. Backend (src/Inventory/): - Entities InventoryItem, InventoryPackage, InventoryPackageItem, scoped via entity_type/entity_id like TenantTag. Item status is derived, package total and availability derived at read time. - InventoryService (stats, package assembly, availability), thin InventoryController with CRUD for items and packages + categories endpoint. - Migration + docs/api/inventory.md + functional tests (10 tests, 42 assertions). Frontend (assets/admin/): - InventoryPage with two tabs (کالاهای مصرفی / پکیج), stat cards, items table (desktop + mobile cards), packages accordion, add/edit item and package modals, search + category filter — pixel-matched to the tauri source. - useInventory hook (TanStack Query), route + sidebar link for doctor/clinic. - Vitest coverage (real data, empty state, modal, packages tab). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
40 lines
2.6 KiB
PHP
40 lines
2.6 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 Version20260715100324 extends AbstractMigration
|
|
{
|
|
public function getDescription(): string
|
|
{
|
|
return 'Create inventory tables: items, packages and package items (per-tenant).';
|
|
}
|
|
|
|
public function up(Schema $schema): void
|
|
{
|
|
// this up() migration is auto-generated, please modify it to your needs
|
|
$this->addSql('CREATE TABLE inventory_items (id INT AUTO_INCREMENT NOT NULL, uuid VARCHAR(36) NOT NULL, entity_type VARCHAR(20) NOT NULL, entity_id INT NOT NULL, name VARCHAR(120) NOT NULL, consumable VARCHAR(120) DEFAULT NULL, unit VARCHAR(30) NOT NULL, price INT NOT NULL, stock INT NOT NULL, alert_threshold INT NOT NULL, created_at INT NOT NULL, updated_at INT NOT NULL, UNIQUE INDEX UNIQ_3D82424DD17F50A6 (uuid), INDEX idx_inventory_items_owner (entity_type, entity_id), PRIMARY KEY (id)) DEFAULT CHARACTER SET utf8mb4');
|
|
$this->addSql('CREATE TABLE inventory_package_items (id INT AUTO_INCREMENT NOT NULL, amount INT NOT NULL, package_id INT NOT NULL, item_id INT NOT NULL, INDEX IDX_17172D5EF44CABFF (package_id), INDEX IDX_17172D5E126F525E (item_id), PRIMARY KEY (id)) DEFAULT CHARACTER SET utf8mb4');
|
|
$this->addSql('CREATE TABLE inventory_packages (id INT AUTO_INCREMENT NOT NULL, uuid VARCHAR(36) NOT NULL, entity_type VARCHAR(20) NOT NULL, entity_id INT NOT NULL, title VARCHAR(120) NOT NULL, created_at INT NOT NULL, updated_at INT NOT NULL, UNIQUE INDEX UNIQ_2FFF7A36D17F50A6 (uuid), INDEX idx_inventory_packages_owner (entity_type, entity_id), PRIMARY KEY (id)) DEFAULT CHARACTER SET utf8mb4');
|
|
$this->addSql('ALTER TABLE inventory_package_items ADD CONSTRAINT FK_17172D5EF44CABFF FOREIGN KEY (package_id) REFERENCES inventory_packages (id) ON DELETE CASCADE');
|
|
$this->addSql('ALTER TABLE inventory_package_items ADD CONSTRAINT FK_17172D5E126F525E FOREIGN KEY (item_id) REFERENCES inventory_items (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 inventory_package_items DROP FOREIGN KEY FK_17172D5EF44CABFF');
|
|
$this->addSql('ALTER TABLE inventory_package_items DROP FOREIGN KEY FK_17172D5E126F525E');
|
|
$this->addSql('DROP TABLE inventory_items');
|
|
$this->addSql('DROP TABLE inventory_package_items');
|
|
$this->addSql('DROP TABLE inventory_packages');
|
|
}
|
|
}
|