feat: add account groups, scheduled payments and cash flow calendar

This commit is contained in:
陈煜 committed 2026-10-02 17:42:57 +08:00
1 parent a7e0a0fe58
commit 86c6daf695
46 files changed
+2548 -290

No files matched your search

@@ -0,0 +1,12 @@
ALTER TABLE `Position` ADD COLUMN `groupName` VARCHAR(60) NOT NULL DEFAULT '' COMMENT '自定义账户分组';
CREATE TABLE `Schedule` (
`id` CHAR(36) NOT NULL, `userId` CHAR(36) NOT NULL, `importedFromId` CHAR(36) NULL,
`name` VARCHAR(100) NOT NULL, `operation` VARCHAR(16) NOT NULL,
`sourceId` CHAR(36) NOT NULL, `targetId` CHAR(36) NULL,
`amount` DECIMAL(24,8) NOT NULL, `received` DECIMAL(24,8) NOT NULL,
`nextAt` DATETIME(3) NOT NULL, `intervalDays` INTEGER NOT NULL,
`enabled` BOOLEAN NOT NULL DEFAULT true, `completed` BOOLEAN NOT NULL DEFAULT false, `notes` TEXT NOT NULL,
PRIMARY KEY (`id`), INDEX `Schedule_userId_enabled_nextAt_idx` (`userId`,`enabled`,`nextAt`),
UNIQUE INDEX `Schedule_userId_importedFromId_key` (`userId`,`importedFromId`),
CONSTRAINT `Schedule_userId_fkey` FOREIGN KEY (`userId`) REFERENCES `User` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
+24
View File
@@ -30,6 +30,7 @@ model User {
sessions Session[]
icons Icon[]
transfers Transfer[]
schedules Schedule[]
}
/// 登录会话与隐藏项目查看授权
model Session {
@@ -67,6 +68,8 @@ model Position {
name String @db.VarChar(100)
/// 项目分类代码
category String @db.VarChar(40)
/// 自定义账户分组;空字符串表示未分组
groupName String @default("") @db.VarChar(60)
/// 原始币种代码
currency String @db.Char(3)
/// 用户备注,原文保留
@@ -210,3 +213,24 @@ model Transfer {
@@unique([userId,importedFromId])
@@index([userId,effectiveDate,id])
}
/// 按需执行的定时支出或转账计划
model Schedule {
id String @id @default(uuid()) @db.Char(36)
userId String @db.Char(36)
user User @relation(fields:[userId],references:[id],onDelete:Cascade)
importedFromId String? @db.Char(36)
name String @db.VarChar(100)
operation String @db.VarChar(16)
sourceId String @db.Char(36)
targetId String? @db.Char(36)
amount Decimal @db.Decimal(24,8)
received Decimal @db.Decimal(24,8)
nextAt DateTime @db.DateTime(3)
intervalDays Int
enabled Boolean @default(true)
completed Boolean @default(false)
notes String @db.Text
@@index([userId,enabled,nextAt])
@@unique([userId,importedFromId])
}