diff --git a/backend/prisma/schema.prisma b/backend/prisma/schema.prisma index c47125a..dcfcabf 100644 --- a/backend/prisma/schema.prisma +++ b/backend/prisma/schema.prisma @@ -522,6 +522,8 @@ model SocialYearStandard { // 公积金比例(type=HOUSING 时使用) housingOrg Float @default(12) housingEmp Float @default(12) + housingBaseMin Float @default(0) // 公积金基数下限(0 时 fallback 到 baseMin) + housingBaseMax Float @default(0) // 公积金基数上限(0 时 fallback 到 baseMax) // 最低工资标准(按参保城市,每年调整) minWage Float @default(0) // 当地月最低工资标准(0=不检查) diff --git a/backend/src/routes/social.routes.ts b/backend/src/routes/social.routes.ts index dfe2bba..279b9ff 100644 --- a/backend/src/routes/social.routes.ts +++ b/backend/src/routes/social.routes.ts @@ -205,6 +205,8 @@ const yearStandardSchema = z.object({ extraInsurances: z.any().optional(), housingOrg: z.number().optional(), housingEmp: z.number().optional(), + housingBaseMin: z.number().min(0).optional(), + housingBaseMax: z.number().min(0).optional(), minWage: z.number().min(0).optional(), }) diff --git a/backend/src/services/contract.service.ts b/backend/src/services/contract.service.ts index bcf5c3c..f5464cd 100644 --- a/backend/src/services/contract.service.ts +++ b/backend/src/services/contract.service.ts @@ -39,7 +39,12 @@ async function clampHousingFundBase(orgId: string, base: number, city?: string, where: { accountId, isCurrent: true }, orderBy: { effectiveFrom: 'desc' }, }) - if (standard) return Math.min(Math.max(base, standard.baseMin), standard.baseMax) + if (standard) { + // 公积金专用上下限(housingBaseMin/Max),为0时回退到社保的 baseMin/baseMax + const min = standard.housingBaseMin > 0 ? standard.housingBaseMin : standard.baseMin + const max = standard.housingBaseMax > 0 ? standard.housingBaseMax : standard.baseMax + return Math.min(Math.max(base, min), max) + } } // 回退到旧配置表 const config = await prisma.housingFundConfig.findFirst({ diff --git a/backend/src/services/payroll.service.ts b/backend/src/services/payroll.service.ts index 698359f..b03da19 100644 --- a/backend/src/services/payroll.service.ts +++ b/backend/src/services/payroll.service.ts @@ -139,7 +139,10 @@ export function calcSocialInsurance(base: number, config: any) { } export function calcHousingFund(base: number, config: any) { - const actualBase = Math.min(Math.max(base, config.baseMin), config.baseMax) + // 公积金专用上下限(housingBaseMin/Max),为0时回退到社保的 baseMin/baseMax + const min = (config.housingBaseMin && config.housingBaseMin > 0) ? config.housingBaseMin : config.baseMin + const max = (config.housingBaseMax && config.housingBaseMax > 0) ? config.housingBaseMax : config.baseMax + const actualBase = Math.min(Math.max(base, min), max) const housingEmp = actualBase * config.housingEmp / 100 const housingOrg = actualBase * config.housingOrg / 100 return { actualBase, housingEmp, housingOrg } diff --git a/frontend/src/pages/social-insurance/AccountCard.tsx b/frontend/src/pages/social-insurance/AccountCard.tsx index b289f91..c35cf9f 100644 --- a/frontend/src/pages/social-insurance/AccountCard.tsx +++ b/frontend/src/pages/social-insurance/AccountCard.tsx @@ -52,6 +52,7 @@ export function AccountCard({ // 公积金字段 accountType: account.accountType || 'BASIC', housingOrg: 12, housingEmp: 12, + housingBaseMin: 0, housingBaseMax: 0, }) // 查询当前年度标准(展开时才查询) @@ -331,8 +332,8 @@ export function AccountCard({ )}
0 时使用缴费基数下限
0 时使用缴费基数上限