链接:https://pan.quark.cn/s/b89282e8f37d?pwd=tYVZ
提取码:tYVZ
一、核心规则(必须先明确)
中国工资个税 = 累计预扣法
每月应纳税所得额 = 税前工资 - 个人五险一金 - 5000(起征点)
累计应纳税所得额 = 本年 1 月至今 累加
个税 = 累计应缴个税 - 当年已缴个税
税率表(综合所得):
plaintext
0-36000 3%
36000-144000 10% - 2520
144000-300000 20% - 16920
300000-420000 25% - 31920
...更高档位
二、PHP 开发结构(最标准)
plaintext
个税模拟器功能拆解:
- 输入:月薪、五险一金个人部分、专项附加扣除、月份
- 计算:累计收入、累计扣除、累计应纳税所得额
- 匹配税率 & 速算扣除数
- 计算当月个税、税后工资
- 输出:明细表格
三、完整可运行 PHP 代码(求职模拟器专用)
php
运行
<?php
/**- 个人求职个税模拟器 PHP 完整版
- 累计预扣法 | 2025最新税率
*/
class TaxCalculator
{
// 个税起征点
private $threshold = 5000;
// 年度税率表 (累计应纳税所得额 => [税率, 速算扣除数])
private $taxRate = [
36000 => [0.03, 0],
144000 => [0.10, 2520],
300000 => [0.20, 16920],
420000 => [0.25, 31920],
660000 => [0.30, 52920],
960000 => [0.35, 85920],
PHP_INT_MAX => [0.45, 181920],
];
/**
* 计算单月工资个税
* @param $month 当前月份 1-12
* @param $salary 税前月薪
* @param $social 个人五险一金
* @param $deduction 专项附加扣除(子女教育/房贷等)
* @param $prevTotalTax 前N个月已缴纳总个税
* @return array
*/
public function calculate($month, $salary, $social, $deduction = 0, $prevTotalTax = 0)
{
// 1. 当月应纳税所得额
$monthlyTaxable = $salary - $social - $this->threshold - $deduction;
$monthlyTaxable = max($monthlyTaxable, 0); // 不能为负
// 2. 累计应纳税所得额
$totalTaxable = $monthlyTaxable * $month;
// 3. 获取税率和速算扣除数
[$rate, $quick] = $this->getRate($totalTaxable);
// 4. 累计应缴个税
$totalTax = $totalTaxable * $rate - $quick;
$totalTax = max($totalTax, 0);
// 5. 当月应缴个税
$currentTax = $totalTax - $prevTotalTax;
$currentTax = max($currentTax, 0);
// 6. 税后工资
$takeHome = $salary - $social - $currentTax;
return [
'month' => $month,
'salary' => round($salary, 2),
'social' => round($social, 2),
'monthly_taxable' => round($monthlyTaxable, 2),
'total_taxable' => round($totalTaxable, 2),
'tax_rate' => $rate * 100 . '%',
'current_tax' => round($currentTax, 2),
'total_tax' => round($totalTax, 2),
'take_home' => round($takeHome, 2),
];
}
// 匹配税率
private function getRate($total)
{
foreach ($this->taxRate as $limit => $item) {
if ($total <= $limit) {
return $item;
}
}
return [0.45, 181920];
}
// 生成全年12个月工资明细(求职最常用)
public function getYearList($monthlySalary, $monthlySocial, $deduction = 0)
{
$result = [];
$prevTax = 0;
for ($m = 1; $m <= 12; $m++) {
$item = $this->calculate($m, $monthlySalary, $monthlySocial, $deduction, $prevTax);
$prevTax = $item['total_tax'];
$result[] = $item;
}
return $result;
}
}
// ====================== 调用示例(求职场景)======================
$salary = 12000; // 税前月薪
$social = 825; // 个人五险一金(5000基数 6%公积金)
$deduction = 0; // 专项附加扣除
$tax = new TaxCalculator();
$yearList = $tax->getYearList($salary, $social, $deduction);
?>
个人求职个税模拟器(PHP 计算结果)
月份
税前工资
个人社保公积金
当月应税
累计应税
税率
当月个税
累计个税
税后到手
<?php foreach($yearList as $item): ?>
<?=$item['month']?>
<?=$item['salary']?>
<?=$item['social']?>
<?=$item['monthly_taxable']?>
<?=$item['total_taxable']?>
<?=$item['tax_rate']?>
<?=$item['current_tax']?>
<?=$item['total_tax']?>
<?=$item['take_home']?>
<?php endforeach; ?>