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:
@@ -436,36 +436,8 @@ export async function createEmployee(orgId: string, userId: string, data: any) {
|
||||
},
|
||||
})
|
||||
|
||||
// 劳务/实习协议不创建社保公积金记录
|
||||
if (!isNoSocialContract) {
|
||||
await tx.employeeSocialInsRecord.create({
|
||||
data: {
|
||||
orgId,
|
||||
employeeId: emp.id,
|
||||
startMonth: socialInsStartMonth,
|
||||
endMonth: null,
|
||||
base: socialInsBase,
|
||||
changeType: 'ONBOARDING',
|
||||
createdBy: userId,
|
||||
city: data.city || '北京',
|
||||
accountId: data.socialAccountId || null,
|
||||
},
|
||||
})
|
||||
|
||||
await tx.employeeHousingFundRecord.create({
|
||||
data: {
|
||||
orgId,
|
||||
employeeId: emp.id,
|
||||
startMonth: housingFundStartMonth,
|
||||
endMonth: null,
|
||||
base: housingFundBase,
|
||||
changeType: 'ONBOARDING',
|
||||
createdBy: userId,
|
||||
city: data.city || '北京',
|
||||
accountId: data.housingAccountId || null,
|
||||
},
|
||||
})
|
||||
}
|
||||
// 社保公积金记录不在录入时创建,由 HR 在社保模块办理增员后创建
|
||||
// 录入时仅保存社保基数到 Employee 表,工资计算直接用 employee.socialInsBase
|
||||
|
||||
await tx.salaryChangeRecord.create({
|
||||
data: {
|
||||
@@ -620,36 +592,7 @@ export async function rehireEmployee(orgId: string, userId: string, id: string,
|
||||
},
|
||||
})
|
||||
|
||||
// 劳务/实习协议不创建社保公积金记录
|
||||
if (!isNoSocialContract) {
|
||||
// 创建新社保缴费记录
|
||||
await prisma.employeeSocialInsRecord.create({
|
||||
data: {
|
||||
orgId,
|
||||
employeeId: id,
|
||||
startMonth: socialInsStartMonth,
|
||||
endMonth: null,
|
||||
base: socialInsBase,
|
||||
changeType: 'REHIRE',
|
||||
createdBy: userId,
|
||||
city: data.city || employee.city || '北京',
|
||||
},
|
||||
})
|
||||
|
||||
// 创建新公积金缴费记录
|
||||
await prisma.employeeHousingFundRecord.create({
|
||||
data: {
|
||||
orgId,
|
||||
employeeId: id,
|
||||
startMonth: housingFundStartMonth,
|
||||
endMonth: null,
|
||||
base: housingFundBase,
|
||||
changeType: 'REHIRE',
|
||||
createdBy: userId,
|
||||
city: data.city || employee.city || '北京',
|
||||
},
|
||||
})
|
||||
}
|
||||
// 社保公积金记录不在重新入职时创建,由 HR 在社保模块办理增员后创建
|
||||
|
||||
// 创建新薪资记录
|
||||
await prisma.salaryChangeRecord.create({
|
||||
|
||||
Reference in New Issue
Block a user