fix: 薪资批次排除预入职员工(hireDate > 批次月末)

原查询只过滤status=ACTIVE,预入职员工status也是ACTIVE会被错误纳入。
增加hireDate <= monthEnd条件,确保只拉入已入职员工。

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-18 14:15:38 +08:00
parent 1feada76d1
commit 9ac07eba0f
11 changed files with 474 additions and 120 deletions
+1 -8
View File
@@ -341,14 +341,7 @@ router.post('/excel', authMiddleware, requireAdmin, upload.single('file'), async
},
})
// 仅在未 opt-out 时创建社保记录
if (!socialInsOptOut) {
await prisma.employeeSocialInsRecord.create({ data: { orgId, employeeId: emp.id, startMonth: dateToMonth(hireDate), endMonth: null, base: socialInsBase, changeType: 'ONBOARDING', createdBy: userId } })
}
// 仅在未 opt-out 时创建公积金记录
if (!housingFundOptOut) {
await prisma.employeeHousingFundRecord.create({ data: { orgId, employeeId: emp.id, startMonth: dateToMonth(hireDate), endMonth: null, base: housingFundBase, changeType: 'ONBOARDING', createdBy: userId } })
}
// 社保公积金记录不在导入时创建,由 HR 在社保模块办理增员后创建
await prisma.salaryChangeRecord.create({ data: { orgId, employeeId: emp.id, oldSalary: 0, newSalary: num(salary), effectiveDate: hireDate, effectiveMonth: dateToMonth(hireDate), endMonth: null, changeType: 'ONBOARDING', createdBy: userId } })
await prisma.employeeDepartmentRecord.create({ data: { orgId, employeeId: emp.id, oldDepartment: '', newDepartment: dept, effectiveMonth: dateToMonth(hireDate), endMonth: null, changeType: 'ONBOARDING', createdBy: userId } })