是任何人谁可以帮助我创建PHP或mysql代码为我们的办公室员工工资税表。这是我们税收监管的基础。
If salary is >= 0 and <= 150 it will be 0% (Nill),
If salary is >= 151 and <= 650 it will be 10% - 15.00,
If salary is >= 651 and <= 1400 it will be 15% - 47.50,
If salary is >= 1401 and <= 2350 it will be 20% -117.50,
If salary is >= 2351 and <= 3550 it will be 25% - 235.00,
If salary is >= 3551 and <= 5000 it will be 30% - 412.5,
If salary is >= 5001 it will be 35% - 662.50发布于 2012-01-21 16:08:18
function get_taxed_salary($salary){
if ($salary <= 150 ){
return $salary;
};
if ($salary <= 650){
return ( 0.9 * $salary - 15.0 );
};
...
}在稍后的代码中,您可以像这样使用该函数:
$taxed_salary = get_taxed_salary($salary);发布于 2014-05-26 12:54:20
在大多数国家,这不是税收的运作方式--你不会根据你的收入按一定的百分比缴税。如果真是这样,那么收入略高于税级的人的税后净收入将低于收入略低于税级的人。
它的实际工作原理是:你为属于每个税级的收入的每一部分按不同的百分比缴税。因此,如果你的收入是11,000美元,并且有一个从0到10,000和从10,000到20,000的税级,那么第一个10k将按第一个税级的税率征税,剩余的1k将按第二个税级的较高税率征税。
以这种方式计算税收的代码:
//the tops of each tax band
$band1_top = 14000;
$band2_top = 48000;
$band3_top = 70000;
//no top of band 4
//the tax rates of each band
$band1_rate = 0.105;
$band2_rate = 0.175;
$band3_rate = 0.30;
$band4_rate = 0.33;
$starting_income = $income = 71000; //set this to your income
$band1 = $band2 = $band3 = $band4 = 0;
if($income > $band3_top) {
$band4 = ($income - $band3_top) * $band4_rate;
$income = $band3_top;
}
if($income > $band2_top) {
$band3 = ($income - $band2_top) * $band3_rate;
$income = $band2_top;
}
if($income > $band1_top) {
$band2 = ($income - $band1_top) * $band2_rate;
$income = $band1_top;
}
$band1 = $income * $band1_rate;
$total_tax_paid = $band1 + $band2 + $band3 + $band4;
echo "Tax paid on $starting_income is $total_tax_paid";
?>发布于 2012-01-21 16:07:20
你应该学习基本的PHP。解决方案很简单。
function getTax($salary) {
$percent = 0;
$subt = 0;
if ($salary >= 0 && $salary <= 150) {
$percent = 10;
$subt = 15;
} elseif ($salary >= 151 && $salary <= 650) {
...
} ...
// do calculations here, ex:
$final = $salary * $percent / 100 - $subt;
return $final;
}编辑:感谢Constantin的函数提醒
https://stackoverflow.com/questions/8951553
复制相似问题