tuqin
2 天以前 1d372d5e4916eaecf9b773e52e0d887d4fd0e47a
yudao-module-hrm/src/main/java/cn/iocoder/yudao/module/hrm/service/salary/HrmSalaryCalculationServiceImpl.java
@@ -281,7 +281,7 @@
                .add(fullAttendanceBonus)
                .add(mealAllowance).add(transportAllowance).add(otherAllowance).add(overtimePay);
        // 获取社保基数:员工社保档案 > 员工基本工资
        // 社保基数:只取员工社保档案里配置的缴纳基数;未配置时用基本工资
        BigDecimal socialSecurityBase = (socialSecurity != null && socialSecurity.getSocialSecurityBase() != null)
                ? socialSecurity.getSocialSecurityBase() : baseSalary;
@@ -292,17 +292,31 @@
                ? scheme.getMedicalPersonalRatio() : DEFAULT_MEDICAL_PERSONAL_RATIO;
        BigDecimal unemploymentPersonalRatio = (scheme != null && scheme.getUnemploymentPersonalRatio() != null)
                ? scheme.getUnemploymentPersonalRatio() : DEFAULT_UNEMPLOYMENT_PERSONAL_RATIO;
        // 大病医疗 / 长期护理的个人比例:方案里可能为空,为空视为 0(不扣)
        BigDecimal seriousIllnessPersonalRatio = (scheme != null && scheme.getSeriousIllnessPersonalRatio() != null)
                ? scheme.getSeriousIllnessPersonalRatio() : BigDecimal.ZERO;
        BigDecimal longTermCarePersonalRatio = (scheme != null && scheme.getLongTermCarePersonalRatio() != null)
                ? scheme.getLongTermCarePersonalRatio() : BigDecimal.ZERO;
        // 公积金个人比例:只取方案配置值,不再回退默认比例。
        // 否则「公司没配公积金方案」时会被按默认 12% 扣款(这就是客户反馈的问题)。
        BigDecimal housingFundPersonalRatio = scheme != null ? scheme.getHousingFundPersonalRatio() : null;
        // 社保扣除 = 基数 × (养老个人比例 + 医疗个人比例 + 失业个人比例)
        BigDecimal socialSecurityDeduction = socialSecurityBase
                .multiply(pensionPersonalRatio)
                .add(socialSecurityBase.multiply(medicalPersonalRatio))
                .add(socialSecurityBase.multiply(unemploymentPersonalRatio))
        // 社保扣除:必须「员工配置了社保档案」才扣款。
        // 之前无论有没有社保档案都按 基数 × 默认比例(0.08+0.02+0.005=10.5%) 扣款,
        // 导致 102 个没加社保的员工被扣了 204.75(= 基本工资 1950 × 10.5%)。
        // 个人应缴 = 养老 + 医疗 + 失业 + 大病医疗 + 长期护理。
        // 注意:原来漏算了后两项,使得「兵团五险」与「地方五险」两个方案算出来的扣款完全一样。
        BigDecimal socialSecurityDeduction = BigDecimal.ZERO;
        if (socialSecurity != null) {
            BigDecimal personalTotalRatio = pensionPersonalRatio
                    .add(medicalPersonalRatio)
                    .add(unemploymentPersonalRatio)
                    .add(seriousIllnessPersonalRatio)
                    .add(longTermCarePersonalRatio);
            socialSecurityDeduction = socialSecurityBase.multiply(personalTotalRatio)
                .setScale(2, RoundingMode.HALF_UP);
        }
        // 公积金扣除:必须同时满足「方案配置了公积金比例 > 0」且「员工档案配置了公积金基数 > 0」才扣款,
        // 任一不满足都视为公司未缴纳公积金,扣款为 0。