From 9e54a34dd67a353aeb81f885736bc6515f629145 Mon Sep 17 00:00:00 2001 From: freedakgmail Date: Mon, 17 Aug 2026 21:42:17 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E7=A4=BE=E4=BF=9D/=E5=85=AC=E7=A7=AF?= =?UTF-8?q?=E9=87=91=E7=BC=B4=E7=BA=B3=E6=88=AA=E6=AD=A2=E6=97=A5=E6=94=B9?= =?UTF-8?q?=E4=B8=BA=E6=8C=89=E8=B4=A6=E6=88=B7=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - SocialAccount 模型增加 paymentDay 字段 - detectMonthlyTasks 社保/公积金改为按账户 paymentDay 生成提醒 - 账户表单增加缴纳截止日输入 - 设置页面移除社保/公积金缴纳日,保留发薪日和个税日 --- backend/prisma/schema.prisma | 1 + backend/src/routes/social.routes.ts | 1 + backend/src/services/risk.service.ts | 30 +++++++++++++++---- frontend/src/pages/Settings.tsx | 12 +++----- .../social-insurance/AccountFormModal.tsx | 8 ++++- 5 files changed, 37 insertions(+), 15 deletions(-) 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() {
月度事务提醒
-
设置每月截止日,到期后自动生成待办提醒
-
+
设置每月截止日,到期后自动生成待办提醒。社保/公积金缴纳日请在对应账户中设置。
+
- - setForm({ ...form, socialInsDay: Number(e.target.value) })} /> -
-
- - setForm({ ...form, housingFundDay: Number(e.target.value) })} /> + + setForm({ ...form, payrollDay: Number(e.target.value) })} />
diff --git a/frontend/src/pages/social-insurance/AccountFormModal.tsx b/frontend/src/pages/social-insurance/AccountFormModal.tsx index 07d18dc..96f5940 100644 --- a/frontend/src/pages/social-insurance/AccountFormModal.tsx +++ b/frontend/src/pages/social-insurance/AccountFormModal.tsx @@ -26,6 +26,7 @@ export function AccountFormModal({ type, account, onClose, onSubmit, saving }: { const [bankAccount, setBankAccount] = useState(account?.bankAccount || '') const [accountTypeVal, setAccountTypeVal] = useState(account?.accountType || 'BASIC') const [isDefault, setIsDefault] = useState(account?.isDefault || false) + const [paymentDay, setPaymentDay] = useState(account?.paymentDay || '') const [remark, setRemark] = useState(account?.remark || '') const [selectedDeptIds, setSelectedDeptIds] = useState([]) @@ -91,6 +92,11 @@ export function AccountFormModal({ type, account, onClose, onSubmit, saving }: { setOrgCode(e.target.value)} />
+
+ + setPaymentDay(e.target.value)} placeholder="如:15(每月15日前完成缴纳)" /> +

设置后,工作台将按此日期生成缴纳提醒

+
setRemark(e.target.value)} /> @@ -127,7 +133,7 @@ export function AccountFormModal({ type, account, onClose, onSubmit, saving }: {