fix: 月度任务截止日使用配置的实际日期,不再用 today+N天 硬编码

detectMonthlyTasks 生成风险时设置 deadline 为当月配置的截止日
runRiskDetection 创建记录时优先使用风险自带的 deadline
This commit is contained in:
freedakgmail
2026-08-17 21:16:22 +08:00
parent 802604c9e5
commit 2b8a5d6e30
+5 -2
View File
@@ -449,11 +449,13 @@ export async function detectMonthlyTasks(orgId: string) {
{ day: setting.taxDay, title: `${currentMonth}月 申报个税`, desc: `每月${setting.taxDay}日前完成个税申报`, url: '/money?tab=batch' },
]
const risks: { employeeId: null; type: RiskType; level: RiskLevel; title: string; description: string; actionUrl: string }[] = []
const risks: { employeeId: null; type: RiskType; level: RiskLevel; title: string; description: string; actionUrl: string; deadline?: Date }[] = []
for (const task of tasks) {
// 当月已过截止日或正好到截止日时生成提醒
if (today >= task.day) {
// deadline 为当月截止日
const deadline = new Date(now.getFullYear(), now.getMonth(), task.day)
risks.push({
employeeId: null,
type: 'MONTHLY',
@@ -461,6 +463,7 @@ export async function detectMonthlyTasks(orgId: string) {
title: task.title,
description: task.desc,
actionUrl: task.url,
deadline,
})
}
}
@@ -664,7 +667,7 @@ export async function runRiskDetection(orgId: string) {
actionUrl: r.actionUrl,
estimatedLoss: cost.estimatedLoss,
lossRange: cost.lossRange,
deadline: cost.deadline,
deadline: (r as any).deadline || cost.deadline,
}
})
await prisma.riskItem.createMany({ data: createData })