feat(G2-1,G2-2,G2-3): 扩展预算编号与工作流跨域桥接
这个提交包含在:
@@ -0,0 +1,25 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "budget_ledger_entries" ADD COLUMN "entity_id" UUID,
|
||||
ADD COLUMN "entity_type" VARCHAR(32);
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "budget_pools" ADD COLUMN "cost_center_id" UUID,
|
||||
ADD COLUMN "legal_entity_id" UUID;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "workflow_instances" ADD COLUMN "purchase_request_id" UUID;
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "idx_budget_ledger_entity" ON "budget_ledger_entries"("entity_type", "entity_id");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "idx_budget_pools_scope_status" ON "budget_pools"("legal_entity_id", "cost_center_id", "status");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "workflow_instances_purchase_request_id_idx" ON "workflow_instances"("purchase_request_id");
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "budget_pools" ADD CONSTRAINT "budget_pools_legal_entity_id_fkey" FOREIGN KEY ("legal_entity_id") REFERENCES "legal_entities"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "budget_pools" ADD CONSTRAINT "budget_pools_cost_center_id_fkey" FOREIGN KEY ("cost_center_id") REFERENCES "cost_centers"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
+24
-12
@@ -410,6 +410,7 @@ model LegalEntity {
|
||||
employees Employee[]
|
||||
holiday_calendars HolidayCalendar[] @relation("HolidayCalendarLegalEntity")
|
||||
suppliers Supplier[]
|
||||
budget_pools BudgetPool[] @relation("BudgetPoolLegalEntity")
|
||||
|
||||
@@index([enabled, archived_at], map: "idx_legal_entities_status")
|
||||
@@index([default_holiday_calendar_id], map: "idx_legal_entities_default_calendar")
|
||||
@@ -435,6 +436,7 @@ model CostCenter {
|
||||
parent CostCenter? @relation("CostCenterToParent", fields: [parent_id], references: [id], onDelete: Restrict)
|
||||
children CostCenter[] @relation("CostCenterToParent")
|
||||
owner_employee Employee? @relation("CostCenterOwner", fields: [owner_employee_id], references: [id], onDelete: SetNull)
|
||||
budget_pools BudgetPool[] @relation("BudgetPoolCostCenter")
|
||||
|
||||
@@unique([legal_entity_id, code], map: "legal_entity_cost_center_code_ux")
|
||||
@@index([legal_entity_id, enabled, archived_at], map: "idx_cost_centers_legal_entity_status")
|
||||
@@ -824,6 +826,8 @@ model BudgetPool {
|
||||
code String @unique
|
||||
name String
|
||||
department_id String? @db.Uuid
|
||||
legal_entity_id String? @db.Uuid
|
||||
cost_center_id String? @db.Uuid
|
||||
status String @default("active") @db.VarChar(16)
|
||||
period_start DateTime @db.Date
|
||||
period_end DateTime @db.Date
|
||||
@@ -838,9 +842,12 @@ model BudgetPool {
|
||||
updated_by String? @db.Uuid
|
||||
|
||||
department Department? @relation(fields: [department_id], references: [id], onDelete: SetNull)
|
||||
legal_entity LegalEntity? @relation("BudgetPoolLegalEntity", fields: [legal_entity_id], references: [id], onDelete: SetNull)
|
||||
cost_center CostCenter? @relation("BudgetPoolCostCenter", fields: [cost_center_id], references: [id], onDelete: SetNull)
|
||||
ledger_entries BudgetLedgerEntry[]
|
||||
|
||||
@@index([department_id, status], map: "idx_budget_pools_department_status")
|
||||
@@index([legal_entity_id, cost_center_id, status], map: "idx_budget_pools_scope_status")
|
||||
@@index([status, period_start, period_end], map: "idx_budget_pools_period")
|
||||
@@map("budget_pools")
|
||||
}
|
||||
@@ -849,6 +856,8 @@ model BudgetLedgerEntry {
|
||||
id String @id @default(uuid()) @db.Uuid
|
||||
budget_pool_id String @db.Uuid
|
||||
reimbursement_id String? @db.Uuid
|
||||
entity_type String? @db.VarChar(32)
|
||||
entity_id String? @db.Uuid
|
||||
kind String @db.VarChar(32)
|
||||
amount Decimal @db.Decimal(14, 2)
|
||||
note String?
|
||||
@@ -860,6 +869,7 @@ model BudgetLedgerEntry {
|
||||
|
||||
@@index([budget_pool_id, created_at], map: "idx_budget_ledger_pool_created_at")
|
||||
@@index([reimbursement_id])
|
||||
@@index([entity_type, entity_id], map: "idx_budget_ledger_entity")
|
||||
@@map("budget_ledger_entries")
|
||||
}
|
||||
|
||||
@@ -969,18 +979,19 @@ model WorkflowDefinition {
|
||||
}
|
||||
|
||||
model WorkflowInstance {
|
||||
id String @id @default(uuid()) @db.Uuid
|
||||
workflow_id String @db.Uuid
|
||||
entity_type String
|
||||
entity_id String @db.Uuid
|
||||
reimbursement_id String? @db.Uuid
|
||||
leave_request_id String? @db.Uuid
|
||||
submitter_id String @db.Uuid
|
||||
current_status WorkflowInstanceStatus @default(pending)
|
||||
current_step_id String
|
||||
context_data Json
|
||||
started_at DateTime @default(now())
|
||||
completed_at DateTime?
|
||||
id String @id @default(uuid()) @db.Uuid
|
||||
workflow_id String @db.Uuid
|
||||
entity_type String
|
||||
entity_id String @db.Uuid
|
||||
reimbursement_id String? @db.Uuid
|
||||
leave_request_id String? @db.Uuid
|
||||
purchase_request_id String? @db.Uuid
|
||||
submitter_id String @db.Uuid
|
||||
current_status WorkflowInstanceStatus @default(pending)
|
||||
current_step_id String
|
||||
context_data Json
|
||||
started_at DateTime @default(now())
|
||||
completed_at DateTime?
|
||||
|
||||
created_at DateTime @default(now())
|
||||
created_by String? @db.Uuid
|
||||
@@ -1003,6 +1014,7 @@ model WorkflowInstance {
|
||||
@@index([entity_type, entity_id])
|
||||
@@index([reimbursement_id])
|
||||
@@index([leave_request_id])
|
||||
@@index([purchase_request_id])
|
||||
@@index([current_status])
|
||||
@@index([submitter_id])
|
||||
@@index([context_department_id])
|
||||
|
||||
在新工单中引用
屏蔽一个用户