feat: 社保/公积金缴纳截止日改为按账户配置
- SocialAccount 模型增加 paymentDay 字段 - detectMonthlyTasks 社保/公积金改为按账户 paymentDay 生成提醒 - 账户表单增加缴纳截止日输入 - 设置页面移除社保/公积金缴纳日,保留发薪日和个税日
This commit is contained in:
@@ -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?
|
||||
|
||||
@@ -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(),
|
||||
})
|
||||
|
||||
@@ -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' },
|
||||
|
||||
Reference in New Issue
Block a user