diff --git a/backend/prisma/schema.prisma b/backend/prisma/schema.prisma index 68f506b..c9a5739 100644 --- a/backend/prisma/schema.prisma +++ b/backend/prisma/schema.prisma @@ -481,6 +481,7 @@ model SocialAccount { orgName String? // 缴费主体名称(子公司/分公司名称) orgCode String? // 缴费主体统一社会信用代码 accountType String? // 公积金账户类型 BASIC=基本, SUPPLEMENTARY=补充 + paymentDay Int? // 每月缴纳截止日(1-28),用于按账户生成缴纳提醒 isDefault Boolean @default(false) status String @default("ACTIVE") // ACTIVE=正常, SUSPENDED=停用 remark String? diff --git a/backend/src/routes/social.routes.ts b/backend/src/routes/social.routes.ts index 7010471..a3719eb 100644 --- a/backend/src/routes/social.routes.ts +++ b/backend/src/routes/social.routes.ts @@ -51,6 +51,7 @@ const accountSchema = z.object({ orgName: z.string().optional(), orgCode: z.string().optional(), accountType: z.string().optional(), + paymentDay: z.number().int().min(1).max(28).optional(), isDefault: z.boolean().optional(), remark: z.string().optional(), }) diff --git a/backend/src/services/risk.service.ts b/backend/src/services/risk.service.ts index e6bb64a..6502d41 100644 --- a/backend/src/services/risk.service.ts +++ b/backend/src/services/risk.service.ts @@ -406,19 +406,16 @@ export async function detectMonthlyTasks(orgId: string) { const currentMonth = `${now.getFullYear()}-${String(now.getMonth() + 1).padStart(2, '0')}` const today = now.getDate() - const tasks = [ + // 工资和个税仍用全局通知设置 + const globalTasks = [ { day: setting.payrollDay, title: `${currentMonth}月 发放工资`, desc: `每月${setting.payrollDay}日前完成工资发放`, url: '/money?tab=batch' }, - { day: setting.socialInsDay, title: `${currentMonth}月 缴纳社保`, desc: `每月${setting.socialInsDay}日前完成社保缴纳`, url: '/social?tab=monthly' }, - { day: setting.housingFundDay, title: `${currentMonth}月 缴纳公积金`, desc: `每月${setting.housingFundDay}日前完成公积金缴纳`, url: '/social?tab=monthly' }, { 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; deadline?: Date }[] = [] - for (const task of tasks) { - // 当月已过截止日或正好到截止日时生成提醒 + for (const task of globalTasks) { if (today >= task.day) { - // deadline 为当月截止日 const deadline = new Date(now.getFullYear(), now.getMonth(), task.day) risks.push({ employeeId: null, @@ -432,6 +429,27 @@ export async function detectMonthlyTasks(orgId: string) { } } + // 社保和公积金按账户 paymentDay 生成提醒 + const accounts = await prisma.socialAccount.findMany({ + where: { orgId, status: 'ACTIVE', paymentDay: { not: null } }, + }) + for (const acc of accounts) { + const day = acc.paymentDay! + if (today >= day) { + const deadline = new Date(now.getFullYear(), now.getMonth(), day) + const typeLabel = acc.type === 'SOCIAL' ? '社保' : '公积金' + risks.push({ + employeeId: null, + type: 'MONTHLY', + level: today > day + 3 ? 'HIGH' : 'MEDIUM', + title: `${currentMonth}月 缴纳${typeLabel}(${acc.name})`, + description: `账户「${acc.name}」每月${day}日前完成${typeLabel}缴纳`, + actionUrl: '/social?tab=monthly', + deadline, + }) + } + } + // 工资条生成提醒:当月有已归档批次时提醒生成工资条 const archivedBatches = await prisma.payrollBatch.count({ where: { orgId, month: currentMonth, status: 'ARCHIVED' }, diff --git a/frontend/src/pages/Settings.tsx b/frontend/src/pages/Settings.tsx index 6c1c6fb..b1e1780 100644 --- a/frontend/src/pages/Settings.tsx +++ b/frontend/src/pages/Settings.tsx @@ -866,15 +866,11 @@ function NotificationSettings() {
设置后,工作台将按此日期生成缴纳提醒
+