// 欠薪计算逻辑,基于 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,
|
};
|
};
|