chore: 添加社保公积金账户数据修复脚本
- fix-missing-standards.ts: 补齐无年度标准的账户 - fix-housing-base-limits.ts: 更新各城市公积金基数上下限 - check-test-accounts.ts: 删除不完整的测试账户 - assign-accounts.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:
@@ -0,0 +1,47 @@
|
||||
/**
|
||||
* 批量更新公积金账户的 housingBaseMin/housingBaseMax
|
||||
* 数据来源:各城市2025年度公积金缴存基数上下限
|
||||
*/
|
||||
import { PrismaClient } from '@prisma/client'
|
||||
const prisma = new PrismaClient()
|
||||
|
||||
// 2025年度各城市公积金基数上下限
|
||||
const CITY_LIMITS: Record<string, { min: number; max: number }> = {
|
||||
'北京': { min: 2540, max: 35811 },
|
||||
'上海': { min: 2690, max: 37302 },
|
||||
'深圳': { min: 2360, max: 44265 },
|
||||
'杭州': { min: 2490, max: 40694 },
|
||||
'石家庄': { min: 2200, max: 26420 },
|
||||
'天津': { min: 2320, max: 27861 },
|
||||
'唐山': { min: 2200, max: 26420 }, // 河北省标准
|
||||
}
|
||||
|
||||
async function main() {
|
||||
const accounts = await prisma.socialAccount.findMany({ where: { type: 'HOUSING' } })
|
||||
let updated = 0
|
||||
let skipped = 0
|
||||
|
||||
for (const account of accounts) {
|
||||
const limits = CITY_LIMITS[account.city]
|
||||
if (!limits) {
|
||||
console.log(`[跳过] ${account.name} (${account.city}) — 无该城市的公积金上下限数据`)
|
||||
skipped++
|
||||
continue
|
||||
}
|
||||
|
||||
// 更新该账户下所有年度标准的 housingBaseMin/housingBaseMax
|
||||
const result = await prisma.socialYearStandard.updateMany({
|
||||
where: { accountId: account.id },
|
||||
data: {
|
||||
housingBaseMin: limits.min,
|
||||
housingBaseMax: limits.max,
|
||||
},
|
||||
})
|
||||
console.log(`[更新] ${account.name} (${account.city}) → 下限 ${limits.min} / 上限 ${limits.max},影响 ${result.count} 条标准`)
|
||||
updated++
|
||||
}
|
||||
|
||||
console.log(`\n完成:更新 ${updated} 个账户,跳过 ${skipped} 个`)
|
||||
}
|
||||
|
||||
main().then(() => process.exit(0)).catch(e => { console.error(e); process.exit(1) })
|
||||
Reference in New Issue
Block a user