feat(P16C-1,P16C-3): 完成供应商主数据后端与种子

这个提交包含在:
2026-03-07 17:39:49 +08:00
父节点 195f46a2e3
当前提交 aafa911ee7
共修改 6 个文件,包含 645 行新增和 0 行删除
@@ -0,0 +1,32 @@
-- CreateTable
CREATE TABLE "suppliers" (
"id" UUID NOT NULL,
"code" TEXT NOT NULL,
"name" TEXT NOT NULL,
"short_name" TEXT,
"tax_no" TEXT,
"contact_name" TEXT,
"contact_phone" TEXT,
"payment_terms" TEXT,
"legal_entity_id" UUID,
"enabled" BOOLEAN NOT NULL DEFAULT true,
"archived_at" TIMESTAMP(3),
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"created_by" UUID,
"updated_at" TIMESTAMP(3) NOT NULL,
"updated_by" UUID,
CONSTRAINT "suppliers_pkey" PRIMARY KEY ("id")
);
-- CreateIndex
CREATE UNIQUE INDEX "suppliers_code_key" ON "suppliers"("code");
-- CreateIndex
CREATE INDEX "idx_suppliers_legal_entity_status" ON "suppliers"("legal_entity_id", "enabled", "archived_at");
-- CreateIndex
CREATE INDEX "idx_suppliers_name" ON "suppliers"("name");
-- AddForeignKey
ALTER TABLE "suppliers" ADD CONSTRAINT "suppliers_legal_entity_id_fkey" FOREIGN KEY ("legal_entity_id") REFERENCES "legal_entities"("id") ON DELETE SET NULL ON UPDATE CASCADE;
+26
查看文件
@@ -409,6 +409,7 @@ model LegalEntity {
cost_centers CostCenter[]
employees Employee[]
holiday_calendars HolidayCalendar[] @relation("HolidayCalendarLegalEntity")
suppliers Supplier[]
@@index([enabled, archived_at], map: "idx_legal_entities_status")
@@index([default_holiday_calendar_id], map: "idx_legal_entities_default_calendar")
@@ -505,6 +506,31 @@ model HolidayCalendarDay {
@@map("holiday_calendar_days")
}
model Supplier {
id String @id @default(uuid()) @db.Uuid
code String @unique
name String
short_name String?
tax_no String?
contact_name String?
contact_phone String?
payment_terms String?
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(fields: [legal_entity_id], references: [id], onDelete: SetNull)
@@index([legal_entity_id, enabled, archived_at], map: "idx_suppliers_legal_entity_status")
@@index([name], map: "idx_suppliers_name")
@@map("suppliers")
}
model ReimbursementForm {
id String @id @default(uuid()) @db.Uuid
form_number String? @unique