R57 A1-A6:报销模板与差旅申请关联
这个提交包含在:
@@ -0,0 +1,28 @@
|
||||
CREATE TABLE "reimbursement_templates" (
|
||||
"id" UUID NOT NULL,
|
||||
"name" VARCHAR(100) NOT NULL,
|
||||
"description" TEXT,
|
||||
"items" JSONB NOT NULL DEFAULT '[]',
|
||||
"sort_order" INTEGER NOT NULL DEFAULT 0,
|
||||
"enabled" BOOLEAN NOT NULL DEFAULT true,
|
||||
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"created_by" UUID,
|
||||
"updated_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updated_by" UUID,
|
||||
|
||||
CONSTRAINT "reimbursement_templates_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
CREATE INDEX "reimbursement_templates_enabled_sort_order_idx"
|
||||
ON "reimbursement_templates"("enabled", "sort_order");
|
||||
|
||||
ALTER TABLE "reimbursement_forms"
|
||||
ADD COLUMN "linked_travel_request_id" UUID;
|
||||
|
||||
CREATE INDEX "idx_reimbursement_forms_linked_travel_request"
|
||||
ON "reimbursement_forms"("linked_travel_request_id");
|
||||
|
||||
ALTER TABLE "reimbursement_forms"
|
||||
ADD CONSTRAINT "reimbursement_forms_linked_travel_request_id_fkey"
|
||||
FOREIGN KEY ("linked_travel_request_id") REFERENCES "travel_requests"("id")
|
||||
ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
@@ -842,6 +842,23 @@ model ExpenseStandard {
|
||||
@@map("expense_standards")
|
||||
}
|
||||
|
||||
model ReimbursementTemplate {
|
||||
id String @id @default(uuid()) @db.Uuid
|
||||
name String @db.VarChar(100)
|
||||
description String?
|
||||
items Json @default("[]")
|
||||
sort_order Int @default(0)
|
||||
enabled Boolean @default(true)
|
||||
|
||||
created_at DateTime @default(now())
|
||||
created_by String? @db.Uuid
|
||||
updated_at DateTime @default(now()) @updatedAt
|
||||
updated_by String? @db.Uuid
|
||||
|
||||
@@index([enabled, sort_order])
|
||||
@@map("reimbursement_templates")
|
||||
}
|
||||
|
||||
model DocumentSequence {
|
||||
document_type String @id
|
||||
prefix String
|
||||
@@ -1269,6 +1286,7 @@ model ReimbursementForm {
|
||||
paid_at DateTime?
|
||||
paid_by String? @db.Uuid
|
||||
project_id String? @db.Uuid
|
||||
linked_travel_request_id String? @db.Uuid
|
||||
|
||||
created_at DateTime @default(now())
|
||||
created_by String? @db.Uuid
|
||||
@@ -1280,6 +1298,7 @@ model ReimbursementForm {
|
||||
paid_by_employee Employee? @relation("ReimbursementPaidBy", fields: [paid_by], references: [id], onDelete: SetNull)
|
||||
department Department @relation(fields: [department_id], references: [id], onDelete: Restrict)
|
||||
project Project? @relation(fields: [project_id], references: [id], onDelete: SetNull)
|
||||
travel_request TravelRequest? @relation(fields: [linked_travel_request_id], references: [id], onDelete: SetNull)
|
||||
|
||||
items ReimbursementItem[]
|
||||
invoice_pool_items InvoicePool[]
|
||||
@@ -1293,6 +1312,7 @@ model ReimbursementForm {
|
||||
@@index([department_id])
|
||||
@@index([paid_by])
|
||||
@@index([project_id], map: "idx_reimbursement_forms_project")
|
||||
@@index([linked_travel_request_id], map: "idx_reimbursement_forms_linked_travel_request")
|
||||
@@index([status])
|
||||
@@index([reimbursement_date])
|
||||
@@index([owner_id, status, updated_at], map: "idx_reimbursement_owner_status_updated_at")
|
||||
@@ -2479,6 +2499,7 @@ model TravelRequest {
|
||||
|
||||
segments TravelRequestSegment[]
|
||||
travel_orders TravelOrder[]
|
||||
linked_reimbursements ReimbursementForm[]
|
||||
reconciliation_items TravelReconciliationItem[]
|
||||
card_authorizations CardAuthorization[]
|
||||
card_transactions CardTransaction[]
|
||||
|
||||
在新工单中引用
屏蔽一个用户