feat(P17A-1,P17A-2): 新增采购模型权限与系统种子

这个提交包含在:
2026-03-07 20:59:28 +08:00
父节点 9de1169d78
当前提交 1cd4290b4d
共修改 8 个文件,包含 354 行新增和 18 行删除
+114 -8
查看文件
@@ -44,6 +44,14 @@ enum LeaveRequestStatus {
cancelled
}
enum PurchaseRequestStatus {
draft
reviewing
approved
rejected
cancelled
}
enum LeaveDaySession {
am
pm
@@ -162,6 +170,7 @@ model Department {
employees Employee[]
reimbursement_forms ReimbursementForm[]
leave_requests LeaveRequest[]
purchase_requests PurchaseRequest[]
workflow_instances WorkflowInstance[]
budget_pools BudgetPool[]
travel_orders TravelOrder[]
@@ -217,9 +226,12 @@ model Employee {
submitted_reimbursements ReimbursementForm[] @relation("ReimbursementSubmitter")
owned_reimbursements ReimbursementForm[] @relation("ReimbursementOwner")
paid_reimbursements ReimbursementForm[] @relation("ReimbursementPaidBy")
leave_requests LeaveRequest[]
leave_ledgers LeaveLedger[]
owned_cost_centers CostCenter[] @relation("CostCenterOwner")
leave_requests LeaveRequest[]
leave_ledgers LeaveLedger[]
owned_cost_centers CostCenter[] @relation("CostCenterOwner")
purchase_requests_applicant PurchaseRequest[] @relation("PurchaseRequestApplicant")
purchase_requests_submitted PurchaseRequest[] @relation("PurchaseRequestSubmitter")
purchase_attachments_uploaded PurchaseAttachment[] @relation("PurchaseAttachmentUploader")
owned_invoices InvoicePool[] @relation("InvoiceOwner")
uploaded_invoices InvoicePool[] @relation("InvoiceUploader")
@@ -410,6 +422,7 @@ model LegalEntity {
employees Employee[]
holiday_calendars HolidayCalendar[] @relation("HolidayCalendarLegalEntity")
suppliers Supplier[]
purchase_requests PurchaseRequest[]
budget_pools BudgetPool[] @relation("BudgetPoolLegalEntity")
@@index([enabled, archived_at], map: "idx_legal_entities_status")
@@ -437,6 +450,7 @@ model CostCenter {
children CostCenter[] @relation("CostCenterToParent")
owner_employee Employee? @relation("CostCenterOwner", fields: [owner_employee_id], references: [id], onDelete: SetNull)
budget_pools BudgetPool[] @relation("BudgetPoolCostCenter")
purchase_requests PurchaseRequest[]
@@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")
@@ -462,6 +476,8 @@ model DocumentCategory {
updated_at DateTime @updatedAt
updated_by String? @db.Uuid
purchase_requests PurchaseRequest[]
@@index([entity_type, enabled, archived_at], map: "idx_document_categories_entity_status")
@@map("document_categories")
}
@@ -526,13 +542,101 @@ model Supplier {
updated_at DateTime @updatedAt
updated_by String? @db.Uuid
legal_entity LegalEntity? @relation(fields: [legal_entity_id], references: [id], onDelete: SetNull)
legal_entity LegalEntity? @relation(fields: [legal_entity_id], references: [id], onDelete: SetNull)
purchase_requests PurchaseRequest[]
@@index([legal_entity_id, enabled, archived_at], map: "idx_suppliers_legal_entity_status")
@@index([name], map: "idx_suppliers_name")
@@map("suppliers")
}
model PurchaseRequest {
id String @id @default(uuid()) @db.Uuid
request_no String? @unique
applicant_id String @db.Uuid
submitter_id String? @db.Uuid
department_id String @db.Uuid
legal_entity_id String? @db.Uuid
cost_center_id String? @db.Uuid
supplier_id String? @db.Uuid
document_category_id String? @db.Uuid
budget_pool_id String? @db.Uuid
title String @default("")
reason String?
currency_code String @default("CNY") @db.VarChar(8)
total_amount Decimal @default(0) @db.Decimal(14, 2)
expected_delivery_date DateTime? @db.Date
status PurchaseRequestStatus @default(draft)
created_at DateTime @default(now())
created_by String? @db.Uuid
updated_at DateTime @updatedAt
updated_by String? @db.Uuid
applicant Employee @relation("PurchaseRequestApplicant", fields: [applicant_id], references: [id], onDelete: Restrict)
submitter Employee? @relation("PurchaseRequestSubmitter", fields: [submitter_id], references: [id], onDelete: SetNull)
department Department @relation(fields: [department_id], references: [id], onDelete: Restrict)
legal_entity LegalEntity? @relation(fields: [legal_entity_id], references: [id], onDelete: SetNull)
cost_center CostCenter? @relation(fields: [cost_center_id], references: [id], onDelete: SetNull)
supplier Supplier? @relation(fields: [supplier_id], references: [id], onDelete: SetNull)
document_category DocumentCategory? @relation(fields: [document_category_id], references: [id], onDelete: SetNull)
budget_pool BudgetPool? @relation(fields: [budget_pool_id], references: [id], onDelete: SetNull)
items PurchaseRequestItem[]
attachments PurchaseAttachment[]
workflow_instances WorkflowInstance[]
@@index([applicant_id, status, updated_at], map: "idx_purchase_requests_applicant_status_updated")
@@index([submitter_id], map: "idx_purchase_requests_submitter")
@@index([department_id], map: "idx_purchase_requests_department")
@@index([legal_entity_id], map: "idx_purchase_requests_legal_entity")
@@index([cost_center_id], map: "idx_purchase_requests_cost_center")
@@index([supplier_id], map: "idx_purchase_requests_supplier")
@@index([document_category_id], map: "idx_purchase_requests_document_category")
@@index([budget_pool_id], map: "idx_purchase_requests_budget_pool")
@@index([status], map: "idx_purchase_requests_status")
@@map("purchase_requests")
}
model PurchaseRequestItem {
id String @id @default(uuid()) @db.Uuid
purchase_request_id String @db.Uuid
description String
specification String?
quantity Decimal @db.Decimal(14, 2)
unit_price Decimal @db.Decimal(14, 2)
line_amount Decimal @db.Decimal(14, 2)
is_asset_candidate Boolean @default(false)
created_at DateTime @default(now())
created_by String? @db.Uuid
updated_at DateTime @updatedAt
updated_by String? @db.Uuid
purchase_request PurchaseRequest @relation(fields: [purchase_request_id], references: [id], onDelete: Cascade)
@@index([purchase_request_id], map: "idx_purchase_request_items_request")
@@map("purchase_request_items")
}
model PurchaseAttachment {
id String @id @default(uuid()) @db.Uuid
purchase_request_id String @db.Uuid
storage_path String
original_name String
mime_type String
file_size Int
uploaded_by String @db.Uuid
created_at DateTime @default(now())
purchase_request PurchaseRequest @relation(fields: [purchase_request_id], references: [id], onDelete: Cascade)
uploader Employee @relation("PurchaseAttachmentUploader", fields: [uploaded_by], references: [id], onDelete: Restrict)
@@index([purchase_request_id, created_at], map: "idx_purchase_attachments_request_created")
@@index([uploaded_by], map: "idx_purchase_attachments_uploader")
@@map("purchase_attachments")
}
model ReimbursementForm {
id String @id @default(uuid()) @db.Uuid
form_number String? @unique
@@ -841,10 +945,11 @@ model BudgetPool {
updated_at DateTime @updatedAt
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[]
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[]
purchase_requests PurchaseRequest[]
@@index([department_id, status], map: "idx_budget_pools_department_status")
@@index([legal_entity_id, cost_center_id, status], map: "idx_budget_pools_scope_status")
@@ -1001,6 +1106,7 @@ model WorkflowInstance {
workflow_definition WorkflowDefinition @relation(fields: [workflow_id], references: [id], onDelete: Restrict)
reimbursement_form ReimbursementForm? @relation(fields: [reimbursement_id], references: [id], onDelete: Cascade)
leave_request LeaveRequest? @relation(fields: [leave_request_id], references: [id], onDelete: Cascade)
purchase_request PurchaseRequest? @relation(fields: [purchase_request_id], references: [id], onDelete: Cascade)
submitter Employee @relation("WorkflowInstanceSubmitter", fields: [submitter_id], references: [id], onDelete: Restrict)
department Department? @relation(fields: [context_department_id], references: [id], onDelete: SetNull)