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' },
|
||||
|
||||
@@ -866,15 +866,11 @@ function NotificationSettings() {
|
||||
</label>
|
||||
<div className="border-t pt-3 space-y-3">
|
||||
<div className="text-xs font-medium">月度事务提醒</div>
|
||||
<div className="text-xs text-gray-500">设置每月截止日,到期后自动生成待办提醒</div>
|
||||
<div className="grid grid-cols-3 gap-3">
|
||||
<div className="text-xs text-gray-500">设置每月截止日,到期后自动生成待办提醒。社保/公积金缴纳日请在对应账户中设置。</div>
|
||||
<div className="grid grid-cols-2 gap-3">
|
||||
<div>
|
||||
<Label>社保缴纳日</Label>
|
||||
<Input type="number" min={1} max={28} value={form.socialInsDay ?? 15} onChange={(e) => setForm({ ...form, socialInsDay: Number(e.target.value) })} />
|
||||
</div>
|
||||
<div>
|
||||
<Label>公积金缴纳日</Label>
|
||||
<Input type="number" min={1} max={28} value={form.housingFundDay ?? 15} onChange={(e) => setForm({ ...form, housingFundDay: Number(e.target.value) })} />
|
||||
<Label>发薪日</Label>
|
||||
<Input type="number" min={1} max={28} value={form.payrollDay ?? 10} onChange={(e) => setForm({ ...form, payrollDay: Number(e.target.value) })} />
|
||||
</div>
|
||||
<div>
|
||||
<Label>个税申报日</Label>
|
||||
|
||||
@@ -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<string[]>([])
|
||||
|
||||
@@ -91,6 +92,11 @@ export function AccountFormModal({ type, account, onClose, onSubmit, saving }: {
|
||||
<Label>缴费主体统一社会信用代码</Label>
|
||||
<Input value={orgCode} onChange={(e) => setOrgCode(e.target.value)} />
|
||||
</div>
|
||||
<div>
|
||||
<Label>每月缴纳截止日</Label>
|
||||
<Input type="number" min={1} max={28} value={paymentDay} onChange={(e) => setPaymentDay(e.target.value)} placeholder="如:15(每月15日前完成缴纳)" />
|
||||
<p className="text-xs text-gray-400 mt-1">设置后,工作台将按此日期生成缴纳提醒</p>
|
||||
</div>
|
||||
<div>
|
||||
<Label>备注</Label>
|
||||
<Input value={remark} onChange={(e) => setRemark(e.target.value)} />
|
||||
@@ -127,7 +133,7 @@ export function AccountFormModal({ type, account, onClose, onSubmit, saving }: {
|
||||
<Button variant="secondary" onClick={onClose}>取消</Button>
|
||||
<Button
|
||||
disabled={!name || !city || saving}
|
||||
onClick={() => onSubmit({ name, city, accountNo, orgName, orgCode, bankName, bankAccount, accountType: accountTypeVal, isDefault, remark }, selectedDeptIds)}
|
||||
onClick={() => onSubmit({ name, city, accountNo, orgName, orgCode, bankName, bankAccount, accountType: accountTypeVal, paymentDay: paymentDay ? Number(paymentDay) : undefined, isDefault, remark }, selectedDeptIds)}
|
||||
>
|
||||
{saving ? '保存中...' : '保存'}
|
||||
</Button>
|
||||
|
||||
Reference in New Issue
Block a user