feat(P18B-1,P18B-2): 新增资产流转模型与受控接口
这个提交包含在:
@@ -60,6 +60,26 @@ enum AssetCardStatus {
|
||||
archived
|
||||
}
|
||||
|
||||
enum InventoryCheckScopeType {
|
||||
all
|
||||
legal_entity
|
||||
cost_center
|
||||
location
|
||||
}
|
||||
|
||||
enum InventoryCheckStatus {
|
||||
draft
|
||||
counting
|
||||
completed
|
||||
}
|
||||
|
||||
enum InventoryCheckResult {
|
||||
matched
|
||||
missing
|
||||
extra
|
||||
damaged
|
||||
}
|
||||
|
||||
enum LeaveDaySession {
|
||||
am
|
||||
pm
|
||||
@@ -242,6 +262,9 @@ model Employee {
|
||||
purchase_attachments_uploaded PurchaseAttachment[] @relation("PurchaseAttachmentUploader")
|
||||
purchase_order_archives PurchaseOrderArchive[] @relation("PurchaseOrderArchiveArchivedBy")
|
||||
assigned_asset_cards AssetCard[] @relation("AssetCardAssignee")
|
||||
asset_assignments AssetAssignment[]
|
||||
asset_transfers_from AssetTransfer[] @relation("AssetTransferFromEmployee")
|
||||
asset_transfers_to AssetTransfer[] @relation("AssetTransferToEmployee")
|
||||
|
||||
owned_invoices InvoicePool[] @relation("InvoiceOwner")
|
||||
uploaded_invoices InvoicePool[] @relation("InvoiceUploader")
|
||||
@@ -715,6 +738,9 @@ model AssetCard {
|
||||
cost_center CostCenter @relation(fields: [cost_center_id], references: [id], onDelete: Restrict)
|
||||
purchase_request PurchaseRequest? @relation(fields: [purchase_request_id], references: [id], onDelete: SetNull)
|
||||
assignee Employee? @relation("AssetCardAssignee", fields: [assignee_employee_id], references: [id], onDelete: SetNull)
|
||||
assignments AssetAssignment[]
|
||||
transfers AssetTransfer[]
|
||||
inventory_items InventoryCheckItem[]
|
||||
|
||||
@@index([category_id], map: "idx_asset_cards_category")
|
||||
@@index([legal_entity_id], map: "idx_asset_cards_legal_entity")
|
||||
@@ -725,6 +751,78 @@ model AssetCard {
|
||||
@@map("asset_cards")
|
||||
}
|
||||
|
||||
model AssetAssignment {
|
||||
id String @id @default(uuid()) @db.Uuid
|
||||
asset_id String @db.Uuid
|
||||
employee_id String @db.Uuid
|
||||
assigned_at DateTime @default(now())
|
||||
returned_at DateTime?
|
||||
note String?
|
||||
|
||||
asset AssetCard @relation(fields: [asset_id], references: [id], onDelete: Cascade)
|
||||
employee Employee @relation(fields: [employee_id], references: [id], onDelete: Restrict)
|
||||
|
||||
@@index([asset_id, returned_at], map: "idx_asset_assignments_asset_open")
|
||||
@@index([employee_id, returned_at], map: "idx_asset_assignments_employee_open")
|
||||
@@map("asset_assignments")
|
||||
}
|
||||
|
||||
model AssetTransfer {
|
||||
id String @id @default(uuid()) @db.Uuid
|
||||
asset_id String @db.Uuid
|
||||
from_employee_id String? @db.Uuid
|
||||
to_employee_id String? @db.Uuid
|
||||
from_location String?
|
||||
to_location String?
|
||||
transferred_at DateTime @default(now())
|
||||
note String?
|
||||
|
||||
asset AssetCard @relation(fields: [asset_id], references: [id], onDelete: Cascade)
|
||||
from_employee Employee? @relation("AssetTransferFromEmployee", fields: [from_employee_id], references: [id], onDelete: SetNull)
|
||||
to_employee Employee? @relation("AssetTransferToEmployee", fields: [to_employee_id], references: [id], onDelete: SetNull)
|
||||
|
||||
@@index([asset_id, transferred_at], map: "idx_asset_transfers_asset_time")
|
||||
@@index([from_employee_id], map: "idx_asset_transfers_from_employee")
|
||||
@@index([to_employee_id], map: "idx_asset_transfers_to_employee")
|
||||
@@map("asset_transfers")
|
||||
}
|
||||
|
||||
model InventoryCheck {
|
||||
id String @id @default(uuid()) @db.Uuid
|
||||
check_no String @unique
|
||||
scope_type InventoryCheckScopeType
|
||||
scope_ref_id String? @db.VarChar(200)
|
||||
status InventoryCheckStatus @default(draft)
|
||||
started_at DateTime?
|
||||
completed_at DateTime?
|
||||
|
||||
created_at DateTime @default(now())
|
||||
created_by String? @db.Uuid
|
||||
updated_at DateTime @updatedAt
|
||||
updated_by String? @db.Uuid
|
||||
|
||||
items InventoryCheckItem[]
|
||||
|
||||
@@index([status, created_at], map: "idx_inventory_checks_status_created")
|
||||
@@index([scope_type, scope_ref_id], map: "idx_inventory_checks_scope")
|
||||
@@map("inventory_checks")
|
||||
}
|
||||
|
||||
model InventoryCheckItem {
|
||||
id String @id @default(uuid()) @db.Uuid
|
||||
inventory_check_id String @db.Uuid
|
||||
asset_id String @db.Uuid
|
||||
result InventoryCheckResult
|
||||
note String?
|
||||
|
||||
inventory_check InventoryCheck @relation(fields: [inventory_check_id], references: [id], onDelete: Cascade)
|
||||
asset AssetCard @relation(fields: [asset_id], references: [id], onDelete: Restrict)
|
||||
|
||||
@@unique([inventory_check_id, asset_id], map: "inventory_check_asset_ux")
|
||||
@@index([asset_id], map: "idx_inventory_check_items_asset")
|
||||
@@map("inventory_check_items")
|
||||
}
|
||||
|
||||
model ReimbursementForm {
|
||||
id String @id @default(uuid()) @db.Uuid
|
||||
form_number String? @unique
|
||||
|
||||
在新工单中引用
屏蔽一个用户