1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// 欠薪计算逻辑,基于 PRD 中的说明
export const calculateUnpaidSalary = (input) => {
  const {
    salary = 0,
    unpaidMonths = 0,
    overtimeHours = 0,
    compensationType = '0',
    yearsOfWork = 0,
    startDate,
    endDate,
  } = input || {};
 
  const s = Number(salary) || 0;
  const m = Number(unpaidMonths) || 0;
  const otHours = Number(overtimeHours) || 0;
  const years = Number(yearsOfWork) || 0;
 
  // 基本欠薪
  const basicUnpaid = s * m;
 
  // 加班费:小时工资 * 1.5 * 每月加班小时 * 月数
  const hourlyWage = s / 21.75 / 8;
  const overtimeUnpaid = hourlyWage * 1.5 * otHours * m;
 
  // 经济补偿金
  let compensation = 0;
  if (compensationType === 'n') {
    compensation = s * years;
  } else {
    compensation = s * (Number(compensationType) || 0);
  }
 
  // 滞纳金(按日利率 0.05%估算)
  let daysDiff = 0;
  let lateFee = 0;
  if (startDate && endDate) {
    const start = new Date(startDate);
    const end = new Date(endDate);
    if (!Number.isNaN(start.getTime()) && !Number.isNaN(end.getTime())) {
      const diff = end.getTime() - start.getTime();
      daysDiff = Math.max(0, Math.floor(diff / (1000 * 60 * 60 * 24)));
      lateFee = basicUnpaid * 0.0005 * daysDiff;
    }
  }
 
  const totalUnpaid = basicUnpaid + overtimeUnpaid + compensation + lateFee;
 
  return {
    basicUnpaid,
    overtimeUnpaid,
    compensation,
    lateFee,
    totalUnpaid,
    daysDiff,
  };
};