refactor: 新增员工去掉参保城市选择器,城市从社保账户继承
- 前端:参保城市改为只读显示,从选中的社保账户自动继承 - 前端:去掉参保城市下拉选择器和 cities 查询 - 后端:clampSocialInsBase/clampHousingFundBase 改为优先按 accountId 查年度标准裁剪基数,回退旧配置表 - 后端:createEmployee 传入 socialAccountId/housingAccountId 给 clamp 函数 Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
@@ -14,7 +14,16 @@ function dateToMonth(date: Date): string {
|
||||
return `${y}-${m}`
|
||||
}
|
||||
|
||||
async function clampSocialInsBase(orgId: string, base: number, city?: string): Promise<number> {
|
||||
async function clampSocialInsBase(orgId: string, base: number, city?: string, accountId?: string): Promise<number> {
|
||||
// 优先按账户查年度标准
|
||||
if (accountId) {
|
||||
const standard = await prisma.socialYearStandard.findFirst({
|
||||
where: { accountId, isCurrent: true },
|
||||
orderBy: { effectiveFrom: 'desc' },
|
||||
})
|
||||
if (standard) return Math.min(Math.max(base, standard.baseMin), standard.baseMax)
|
||||
}
|
||||
// 回退到旧配置表
|
||||
const config = await prisma.socialInsuranceConfig.findFirst({
|
||||
where: { orgId, ...(city ? { city } : {}) },
|
||||
orderBy: { effectiveFrom: 'desc' },
|
||||
@@ -23,7 +32,16 @@ async function clampSocialInsBase(orgId: string, base: number, city?: string): P
|
||||
return base
|
||||
}
|
||||
|
||||
async function clampHousingFundBase(orgId: string, base: number, city?: string): Promise<number> {
|
||||
async function clampHousingFundBase(orgId: string, base: number, city?: string, accountId?: string): Promise<number> {
|
||||
// 优先按账户查年度标准
|
||||
if (accountId) {
|
||||
const standard = await prisma.socialYearStandard.findFirst({
|
||||
where: { accountId, isCurrent: true },
|
||||
orderBy: { effectiveFrom: 'desc' },
|
||||
})
|
||||
if (standard) return Math.min(Math.max(base, standard.baseMin), standard.baseMax)
|
||||
}
|
||||
// 回退到旧配置表
|
||||
const config = await prisma.housingFundConfig.findFirst({
|
||||
where: { orgId, ...(city ? { city } : {}) },
|
||||
orderBy: { effectiveFrom: 'desc' },
|
||||
@@ -350,8 +368,8 @@ export async function createEmployee(orgId: string, userId: string, data: any) {
|
||||
const isNoSocialContract = data.contract && ['LABOR', 'INTERNSHIP'].includes(data.contract.contractType)
|
||||
const rawSocialInsBase = isNoSocialContract ? 0 : (data.socialInsBase != null ? Number(data.socialInsBase) : salaryNum)
|
||||
const rawHousingFundBase = isNoSocialContract ? 0 : (data.housingFundBase != null ? Number(data.housingFundBase) : salaryNum)
|
||||
const socialInsBase = isNoSocialContract ? 0 : await clampSocialInsBase(orgId, rawSocialInsBase, city)
|
||||
const housingFundBase = isNoSocialContract ? 0 : await clampHousingFundBase(orgId, rawHousingFundBase, city)
|
||||
const socialInsBase = isNoSocialContract ? 0 : await clampSocialInsBase(orgId, rawSocialInsBase, city, data.socialAccountId)
|
||||
const housingFundBase = isNoSocialContract ? 0 : await clampHousingFundBase(orgId, rawHousingFundBase, city, data.housingAccountId)
|
||||
const socialInsStartMonth = isNoSocialContract ? '' : (data.socialInsStartMonth || hireMonth)
|
||||
const housingFundStartMonth = isNoSocialContract ? '' : (data.housingFundStartMonth || hireMonth)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user