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:
@@ -233,9 +233,9 @@ export async function calcBatchEntry(
|
||||
})
|
||||
}
|
||||
|
||||
// 社保基数:优先用员工核定基数,否则用基本工资
|
||||
const socialBase = employee.socialInsBase || inputs.baseSalary
|
||||
const housingBase = employee.housingFundBase || inputs.baseSalary
|
||||
// 社保基数:优先用员工核定基数(含0,劳务协议人员基数为0不交社保),未设置时回退到基本工资
|
||||
const socialBase = employee.socialInsBase != null ? employee.socialInsBase : inputs.baseSalary
|
||||
const housingBase = employee.housingFundBase != null ? employee.housingFundBase : inputs.baseSalary
|
||||
|
||||
let socialEmp = 0, socialOrg = 0, housingEmp = 0, housingOrg = 0
|
||||
|
||||
@@ -689,7 +689,7 @@ export async function prePayrollCheck(orgId: string, batchId: string): Promise<P
|
||||
// 1. 社保基数是否在上下限范围内
|
||||
if (socialConfig) {
|
||||
for (const entry of entries) {
|
||||
const base = entry.employee.socialInsBase || entry.baseSalary
|
||||
const base = entry.employee.socialInsBase != null ? entry.employee.socialInsBase : entry.baseSalary
|
||||
if (base < socialConfig.baseMin || base > socialConfig.baseMax) {
|
||||
checks.push({
|
||||
code: 'SOCIAL_BASE_OUT_OF_RANGE',
|
||||
@@ -707,7 +707,7 @@ export async function prePayrollCheck(orgId: string, batchId: string): Promise<P
|
||||
// 2. 公积金基数是否在上下限范围内
|
||||
if (housingConfig) {
|
||||
for (const entry of entries) {
|
||||
const base = entry.employee.housingFundBase || entry.baseSalary
|
||||
const base = entry.employee.housingFundBase != null ? entry.employee.housingFundBase : entry.baseSalary
|
||||
if (base < housingConfig.baseMin || base > housingConfig.baseMax) {
|
||||
checks.push({
|
||||
code: 'HOUSING_BASE_OUT_OF_RANGE',
|
||||
|
||||
Reference in New Issue
Block a user