refactor: 社保公积金Tab重构为账户卡片列表+展开年度标准管理

1. 社保/公积金Tab从"选账户→展示配置"改为"账户卡片列表+展开管理"
2. 每个账户卡片可展开显示:当前标准/最低工资编辑/新建年度标准/版本历史/调基/试算
3. 账户新建/编辑/删除/设默认从设置页面迁移到社保公积金菜单
4. 设置页面去掉"社保公积金账户"Tab
5. "新建版本"改名为"新建年度标准"
6. 新增AccountCard组件独立管理每个账户的展开状态和数据查询

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
selfrelease
2026-08-16 15:05:06 +08:00
parent a5911d1874
commit 8391c123fc
10 changed files with 985 additions and 849 deletions
+51 -30
View File
@@ -391,37 +391,58 @@ export async function calcBatchEntry(
let deferredMinWage = 0
let minWageApplied = 0 // 当月实际补齐到最低工资的金额
// 最低工资保护:实发不得低于最低工资标准(仅 REGULAR / TERMINATION 批次)
if (minWage > 0 && batchType !== 'BONUS' && batchType !== 'SEVERANCE' && netPay < minWage) {
const shortfall = minWage - netPay // 需要补齐的金额
// 最低工资保护:当月累计实发不得低于最低工资标准(仅 REGULAR / TERMINATION 批次)
// 第二批次时需判断"当月累计实发"(已归档批次 netPay 之和 + 本批次 netPay)是否低于 minWage
if (minWage > 0 && batchType !== 'BONUS' && batchType !== 'SEVERANCE') {
// 查当月已归档批次的累计实发(同月已归档的 REGULAR/TERMINATION 批次)
const archivedNetPayEntries = await prisma.batchEntry.findMany({
where: {
orgId,
employeeId,
batch: { month, status: 'ARCHIVED', type: { in: ['REGULAR', 'TERMINATION'] } },
},
select: { netPay: true },
})
const archivedNetPay = archivedNetPayEntries.reduce((s, e) => s + e.netPay, 0)
// 优先递延社保个人部分(减少当月社保扣款)
if (shortfall <= socialEmp) {
// 只递延社保就够了
deferredSocialEmp = shortfall
socialEmp -= shortfall
netPay = minWage
minWageApplied = shortfall
} else if (shortfall <= socialEmp + housingEmp) {
// 递延全部社保 + 部分公积金
deferredSocialEmp = socialEmp
deferredHousingEmp = shortfall - socialEmp
socialEmp = 0
housingEmp -= deferredHousingEmp
netPay = minWage
minWageApplied = shortfall
} else {
// 递延全部社保 + 全部公积金,仍不足 → 差额作为最低工资补齐递延
deferredSocialEmp = socialEmp
deferredHousingEmp = housingEmp
const remainingShortfall = shortfall - socialEmp - housingEmp
socialEmp = 0
housingEmp = 0
// 此时 netPay = totalPay - tax - prevDeferredMinWage
// 差额 = minWage - (totalPay - tax - prevDeferredMinWage)
deferredMinWage = remainingShortfall
netPay = minWage
minWageApplied = shortfall
// 当月累计实发 = 已归档批次实发 + 本批次实发
const monthlyCumulativeNetPay = archivedNetPay + netPay
// 仅当当月累计实发低于最低工资时才触发保护
if (monthlyCumulativeNetPay < minWage) {
// 需要补齐的金额 = 最低工资 - 当月累计实发
// 但本批次最多补齐到本批次实发为正,且不超过 minWage - archivedNetPay
const targetNetPay = Math.max(0, minWage - archivedNetPay)
const shortfall = targetNetPay - netPay // 需要补齐的金额(正数表示需要补齐)
if (shortfall > 0) {
// 优先递延社保个人部分(减少当月社保扣款)
if (shortfall <= socialEmp) {
// 只递延社保就够了
deferredSocialEmp = shortfall
socialEmp -= shortfall
netPay = targetNetPay
minWageApplied = shortfall
} else if (shortfall <= socialEmp + housingEmp) {
// 递延全部社保 + 部分公积金
deferredSocialEmp = socialEmp
deferredHousingEmp = shortfall - socialEmp
socialEmp = 0
housingEmp -= deferredHousingEmp
netPay = targetNetPay
minWageApplied = shortfall
} else {
// 递延全部社保 + 全部公积金,仍不足 → 差额作为最低工资补齐递延
deferredSocialEmp = socialEmp
deferredHousingEmp = housingEmp
const remainingShortfall = shortfall - socialEmp - housingEmp
socialEmp = 0
housingEmp = 0
deferredMinWage = remainingShortfall
netPay = targetNetPay
minWageApplied = shortfall
}
}
}
}