feat(G1,P16A,P16B): 收口主数据核心与节假日日历增强
这个提交包含在:
+137
-3
@@ -90,6 +90,20 @@ enum DocumentResetPeriod {
|
||||
yearly
|
||||
}
|
||||
|
||||
enum DocumentCategoryEntityType {
|
||||
reimbursement
|
||||
leave
|
||||
purchase_request
|
||||
asset_card
|
||||
general
|
||||
}
|
||||
|
||||
enum HolidayCalendarDayType {
|
||||
holiday
|
||||
workday
|
||||
adjusted_workday
|
||||
}
|
||||
|
||||
enum WorkflowInstanceStatus {
|
||||
pending
|
||||
approved
|
||||
@@ -163,6 +177,7 @@ model Employee {
|
||||
phone String @unique
|
||||
email String @unique
|
||||
department_id String @db.Uuid
|
||||
legal_entity_id String? @db.Uuid
|
||||
title String
|
||||
direct_manager_id String? @db.Uuid
|
||||
hire_date DateTime @db.Date
|
||||
@@ -185,9 +200,10 @@ model Employee {
|
||||
updated_at DateTime @updatedAt
|
||||
updated_by String? @db.Uuid
|
||||
|
||||
department Department @relation(fields: [department_id], references: [id], onDelete: Restrict)
|
||||
direct_manager Employee? @relation("EmployeeToManager", fields: [direct_manager_id], references: [id], onDelete: Restrict)
|
||||
subordinates Employee[] @relation("EmployeeToManager")
|
||||
department Department @relation(fields: [department_id], references: [id], onDelete: Restrict)
|
||||
legal_entity LegalEntity? @relation(fields: [legal_entity_id], references: [id], onDelete: SetNull)
|
||||
direct_manager Employee? @relation("EmployeeToManager", fields: [direct_manager_id], references: [id], onDelete: Restrict)
|
||||
subordinates Employee[] @relation("EmployeeToManager")
|
||||
|
||||
roles EmployeeRole[]
|
||||
|
||||
@@ -203,6 +219,7 @@ model Employee {
|
||||
paid_reimbursements ReimbursementForm[] @relation("ReimbursementPaidBy")
|
||||
leave_requests LeaveRequest[]
|
||||
leave_ledgers LeaveLedger[]
|
||||
owned_cost_centers CostCenter[] @relation("CostCenterOwner")
|
||||
|
||||
owned_invoices InvoicePool[] @relation("InvoiceOwner")
|
||||
uploaded_invoices InvoicePool[] @relation("InvoiceUploader")
|
||||
@@ -220,6 +237,7 @@ model Employee {
|
||||
password_reset_codes PasswordResetCode[]
|
||||
|
||||
@@index([department_id])
|
||||
@@index([legal_entity_id], map: "idx_employees_legal_entity")
|
||||
@@index([direct_manager_id])
|
||||
@@map("employees")
|
||||
}
|
||||
@@ -371,6 +389,122 @@ model DocumentSequence {
|
||||
@@map("document_sequences")
|
||||
}
|
||||
|
||||
model LegalEntity {
|
||||
id String @id @default(uuid()) @db.Uuid
|
||||
code String @unique
|
||||
name String
|
||||
short_name String?
|
||||
currency_code String @default("CNY") @db.VarChar(8)
|
||||
tax_no String?
|
||||
default_holiday_calendar_id String? @db.Uuid
|
||||
enabled Boolean @default(true)
|
||||
archived_at DateTime?
|
||||
|
||||
created_at DateTime @default(now())
|
||||
created_by String? @db.Uuid
|
||||
updated_at DateTime @updatedAt
|
||||
updated_by String? @db.Uuid
|
||||
|
||||
default_holiday_calendar HolidayCalendar? @relation("LegalEntityDefaultHolidayCalendar", fields: [default_holiday_calendar_id], references: [id], onDelete: SetNull)
|
||||
cost_centers CostCenter[]
|
||||
employees Employee[]
|
||||
holiday_calendars HolidayCalendar[] @relation("HolidayCalendarLegalEntity")
|
||||
|
||||
@@index([enabled, archived_at], map: "idx_legal_entities_status")
|
||||
@@index([default_holiday_calendar_id], map: "idx_legal_entities_default_calendar")
|
||||
@@map("legal_entities")
|
||||
}
|
||||
|
||||
model CostCenter {
|
||||
id String @id @default(uuid()) @db.Uuid
|
||||
legal_entity_id String @db.Uuid
|
||||
code String
|
||||
name String
|
||||
parent_id String? @db.Uuid
|
||||
owner_employee_id String? @db.Uuid
|
||||
enabled Boolean @default(true)
|
||||
archived_at DateTime?
|
||||
|
||||
created_at DateTime @default(now())
|
||||
created_by String? @db.Uuid
|
||||
updated_at DateTime @updatedAt
|
||||
updated_by String? @db.Uuid
|
||||
|
||||
legal_entity LegalEntity @relation(fields: [legal_entity_id], references: [id], onDelete: Restrict)
|
||||
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)
|
||||
|
||||
@@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")
|
||||
@@index([parent_id], map: "idx_cost_centers_parent")
|
||||
@@index([owner_employee_id], map: "idx_cost_centers_owner")
|
||||
@@map("cost_centers")
|
||||
}
|
||||
|
||||
model DocumentCategory {
|
||||
id String @id @default(uuid()) @db.Uuid
|
||||
code String @unique
|
||||
name String
|
||||
entity_type DocumentCategoryEntityType
|
||||
sequence_prefix String
|
||||
number_length Int @default(4)
|
||||
reset_period DocumentResetPeriod
|
||||
default_workflow_key String?
|
||||
enabled Boolean @default(true)
|
||||
archived_at DateTime?
|
||||
|
||||
created_at DateTime @default(now())
|
||||
created_by String? @db.Uuid
|
||||
updated_at DateTime @updatedAt
|
||||
updated_by String? @db.Uuid
|
||||
|
||||
@@index([entity_type, enabled, archived_at], map: "idx_document_categories_entity_status")
|
||||
@@map("document_categories")
|
||||
}
|
||||
|
||||
model HolidayCalendar {
|
||||
id String @id @default(uuid()) @db.Uuid
|
||||
code String @unique
|
||||
name String
|
||||
timezone String @default("Asia/Shanghai") @db.VarChar(64)
|
||||
legal_entity_id String? @db.Uuid
|
||||
enabled Boolean @default(true)
|
||||
archived_at DateTime?
|
||||
|
||||
created_at DateTime @default(now())
|
||||
created_by String? @db.Uuid
|
||||
updated_at DateTime @updatedAt
|
||||
updated_by String? @db.Uuid
|
||||
|
||||
legal_entity LegalEntity? @relation("HolidayCalendarLegalEntity", fields: [legal_entity_id], references: [id], onDelete: SetNull)
|
||||
days HolidayCalendarDay[]
|
||||
default_for_legal_entities LegalEntity[] @relation("LegalEntityDefaultHolidayCalendar")
|
||||
|
||||
@@index([legal_entity_id, enabled, archived_at], map: "idx_holiday_calendars_legal_entity_status")
|
||||
@@map("holiday_calendars")
|
||||
}
|
||||
|
||||
model HolidayCalendarDay {
|
||||
id String @id @default(uuid()) @db.Uuid
|
||||
calendar_id String @db.Uuid
|
||||
date DateTime @db.Date
|
||||
day_type HolidayCalendarDayType
|
||||
name String
|
||||
note String?
|
||||
|
||||
created_at DateTime @default(now())
|
||||
created_by String? @db.Uuid
|
||||
updated_at DateTime @updatedAt
|
||||
updated_by String? @db.Uuid
|
||||
|
||||
calendar HolidayCalendar @relation(fields: [calendar_id], references: [id], onDelete: Cascade)
|
||||
|
||||
@@unique([calendar_id, date], map: "holiday_calendar_day_ux")
|
||||
@@index([calendar_id, date], map: "idx_holiday_calendar_days_calendar_date")
|
||||
@@map("holiday_calendar_days")
|
||||
}
|
||||
|
||||
model ReimbursementForm {
|
||||
id String @id @default(uuid()) @db.Uuid
|
||||
form_number String? @unique
|
||||
|
||||
在新工单中引用
屏蔽一个用户