下面是一个用于计算个税专项扣除附加的函数,主要的功能是根据税前收入和税前扣除额来计算个税专项扣除附加。

具体地,该函数首先通过计算税前收入和税前扣除额之差来确定纳税起征点。接下来,根据纳税起征点和个人缴税状况,在个税专项扣除附加的规定基础上,计算出个税专项扣除附加。

最后,该函数会返回计算出的个税专项扣除附加金额。

function calculateTaxDeduction($income, $deductions) {
$taxableIncome = $income - $deductions;
$taxRate = 0.3;
$quickDeduction = 0;
if ($taxableIncome <= 36000) {
$taxRate = 0.03;
$quickDeduction = 0;
} else if ($taxableIncome <= 144000) {
$taxRate = 0.1;
$quickDeduction = 2520;
} else if ($taxableIncome <= 300000) {
$taxRate = 0.2;
$quickDeduction = 16920;
} else if ($taxableIncome <= 420000) {
$taxRate = 0.25;
$quickDeduction = 31920;
} else if ($taxableIncome <= 660000) {
$taxRate = 0.3;
$quickDeduction = 52920;
} else if ($taxableIncome <= 960000) {
$taxRate = 0.35;
$quickDeduction = 85920;
} else {
$taxRate = 0.45;
$quickDeduction = 181920;
}
$tax = $taxableIncome * $taxRate - $quickDeduction;
return $tax;
}

$income = 100000;
$deductions = 5000;
$tax = calculateTaxDeduction($income, $deductions);
echo "您的所得税为:" . $tax . " 元";

下面的函数用于计算起征点和专项扣除。

<?php
// 定义基本扣除数额
$basic_deduction = 5000;

// 计算专项扣除
function getDeductions($income, $deductions_list) {
global $basic_deduction;

// 减去基本扣除数额
$taxable_income = $income - $basic_deduction;

// 遍历专项扣除列表
$total_deductions = 0;
foreach ($deductions_list as $deduction) {
if ($taxable_income > 0) {
$total_deductions += min($taxable_income, $deduction['amount']);
$taxable_income -= $deduction['amount'];
} else {
break;
}
}

return $total_deductions;
}

// 定义专项扣除列表
$deductions_list = [
['name' => '住房贷款利息', 'amount' => 1500],
['name' => '住房租金', 'amount' => 1000],
['name' => '子女教育', 'amount' => 1000],
['name' => '继续教育', 'amount' => 2000],
['name' => '赡养老人', 'amount' => 1500],
['name' => '大病医疗', 'amount' => 4000],
];

// 计算收入为10000元的专项扣除额度
$income = 10000;
$deductions = getDeductions($income, $deductions_list);

echo "收入为{$income}元,专项扣除额度为{$deductions}元";

请注意,以上代码仅为示例,实际扣除额度应根据个人情况和最新的政策法规计算。

由于不同城市的住房租金扣除金额不同,下面给出函数,根据给定的城市名称,计算住房租金扣除。

function calculateRentDeduction($city, $rentPaid) {
// 设置各个城市的住房租金比例
$rentPercentage = array(
'Beijing' => 0.3,
'Shanghai' => 0.35,
'Guangzhou' => 0.4,
'Shenzhen' => 0.45,
'Other' => 0.25
);

// 如果该城市有对应的住房租金比例,则计算住房租金扣除额
if (isset($rentPercentage[$city])) {
$deduction = $rentPaid * $rentPercentage[$city];
} else {
$deduction = $rentPaid * $rentPercentage['Other'];
}

return $deduction;
}

该函数接收两个参数:$city 和 $rentPaid。函数内部定义了一个数组 $rentPercentage,用于存储各个城市的住房租金扣除比例。如果给定的城市名称在数组中有对应的住房租金比例,则使用该比例计算住房租金扣除额;否则,使用默认的比例,即 Other