fix: 劳务协议人员社保基数为0时仍按基本工资计算的bug

根因:socialInsBase || baseSalary 中 0 是 falsy,导致基数为0
的劳务协议/实习人员回退到基本工资计算社保。

修复:改为 nullish check(!= null),区分"明确设置为0"
和"未设置(null)":
- socialInsBase = 0 → 用 0(劳务协议不交社保)
- socialInsBase = null → 用 baseSalary(回退)
- socialInsBase = 5000 → 用 5000(核定基数)

涉及文件:
- payroll.service.ts calcBatchEntry + prePayrollCheck
- payroll.routes.ts 旧版薪资计算

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:12:07 +08:00
parent 54d138cc73
commit 2f1e339413
2 changed files with 7 additions and 7 deletions
+2 -2
View File
@@ -596,8 +596,8 @@ router.post('/tax-preview', async (req: AuthRequest, res: Response, next: NextFu
])
const emp = employee || { socialInsBase: baseSalary, housingFundBase: baseSalary }
const socialBase = emp.socialInsBase || baseSalary
const housingBase = emp.housingFundBase || baseSalary
const socialBase = emp.socialInsBase != null ? emp.socialInsBase : baseSalary
const housingBase = emp.housingFundBase != null ? emp.housingFundBase : baseSalary
// 计算社保公积金
let socialEmp = 0, housingEmp = 0