一切福田,不離方寸,從心而覓,感無不通。

JS版的个税计算器

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>个税计算器</title>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
</head>
<body>
<style>
.descBlock
{
margin: 0 auto;
width: 550px;
display: none;
}
.descBlock_on
{
margin: 0 auto;
width: 550px;
}
.descTitle
{
color: #FF0000;
font-size: 18px;
text-align: center;
line-height: 120%;
}
.descContent
{
line-height: 150%;
}
</style>
<script language="javascript">
//工资、薪金所得 OK 2000
function calcTax1(income) {
var tax;
var diff = (income – 2000);
if (diff <= 0) { tax = 0; }
if (diff > 0 && diff <= 500) { tax = diff * 0.05; }
if (diff > 500 && diff <= 2000) { tax = diff * 0.1 – 25; }
if (diff > 2000 && diff <= 5000) { tax = diff * 0.15 – 125; }
if (diff > 5000 && diff <= 20000) { tax = diff * 0.2 – 375; }
if (diff > 20000 && diff <= 40000) { tax = diff * 0.25 – 1375; }
if (diff > 40000 && diff <= 60000) { tax = diff * 0.30 – 3375; }
if (diff > 60000 && diff <= 80000) { tax = diff * 0.35 – 6375; }
if (diff > 80000 && diff <= 100000) { tax = diff * 0.4 – 10375; }
if (diff > 100000 && diff > 100000) { tax = diff * 0.45 – 15375; }
return tax;
}

//3500
function calcTaxnew(income) {
var tax;
var diff = (income – 3500);
if (diff <= 0) { tax = 0; }
if (diff > 0 && diff <= 1500) { tax = diff * 0.03; }
if (diff > 1500 && diff <= 4500) { tax = diff * 0.1 – 105; }
if (diff > 4500 && diff <= 9000) { tax = diff * 0.20 – 555; }
if (diff > 9000 && diff <= 35000) { tax = diff * 0.25 – 1005; }
if (diff > 35000 && diff <= 55000) { tax = diff * 0.30 – 2755; }
if (diff > 55000 && diff <= 80000) { tax = diff * 0.35 – 5505; }
if (diff > 80000 && diff > 80000) { tax = diff * 0.45 – 13505; }
return tax;
}

//个体工商户的生产、经营所得
function calcTax2(income) {
return 0
}
//对企事业单位的承包经营、承租经营所得
function calcTax3(income) {
return 0
}
//劳务报酬所得 OK
function calcTax4(income) {

var tax;
var a; //taxable amount 应税所得;
if (income <= 800) { return 0; }

if (income <= 4000) { tax = (income – 800) * 0.2 }
else {
a = income * 0.8
if (a <= 20000) { tax = a * 0.2 }
if (a > 20000 && a <= 50000) { tax = a * 0.3 – 2000 }
if (a > 50000) { tax = a * 0.4 – 7000 }
}

return tax;

}

 

//稿酬所得 OK
function calcTax5(income) {

if (income <= 800) { return 0; } //少于800不用缴

if (income <= 4000)//定额扣除800,税率20%,减征30%
{

return ((income – 800) * 0.2 * (1 – 0.3))
}
else//定率扣除20%,税率20%,减征30%
{
return (income * (1 – 0.2) * 0.2 * (1 – 0.3));
}
}

 
//特许权使用费所得 OK
function calcTax6(income) {

if (income <= 800) { return 0; } //少于800不用缴

if (income <= 4000)//定额扣除800,税率20%
{

return ((income – 800) * 0.2);
}
else//定率扣除20%,税率20%
{
return (income * (1 – 0.2) * 0.2);
}
}

 
//利息、股息、红利所得 OK
function calcTax7(income) {
return (income * 0.2);
}
//财产租赁所得
function calcTax8(income) {
if (income <= 800) { return 0; } //少于800不用缴

var rate = 0.2; //税率20%【对个人出租房屋取得的所得暂减按10%的税率征收个人所得税】
if (document.getElementById("radioEx8_a").checked) { rate = 0.1 }

if (income <= 4000)//定额扣除800
{

return ((income – 800) * rate);
}
else//定率扣除20%
{
return (income * (1 – 0.2) * rate);
}

}

 

//财产转让所得
function calcTax9(income) {

return (income * 0.2);

}
//偶然所得 OK
function calcTax10(income) {
if (income <= 10000) { return 0 } else { return (income * 0.2) }
}
//

 

function calcTax(num) {

var objIncome = document.getElementById("txtIncome" + num);
var objTax = document.getElementById("txtTax" + num);

if (objIncome.value == "" | isNaN(objIncome.value)) {
objIncome.focus();
objIncome.select();
alert("请填正确写收入金额!");
return;
}

var income = objIncome.value;

switch (num) {
case 1:
objTax.value = 1 * calcTax1(income).toFixed(2) * 1;
break;
case 2:
objTax.value = calcTax2(income).toFixed(2) * 1;
break;

case 3:
objTax.value = calcTax3(income).toFixed(2) * 1;
break;

case 4:
objTax.value = calcTax4(income).toFixed(2) * 1;
break;

case 5:
objTax.value = calcTax5(income).toFixed(2) * 1;
break;

case 6:
objTax.value = calcTax6(income).toFixed(2) * 1;
break;

case 7:
objTax.value = calcTax7(income).toFixed(2) * 1;
break;

case 8:
objTax.value = calcTax8(income).toFixed(2) * 1;
break;

case 9:
objTax.value = calcTax9(income).toFixed(2) * 1;
break;

case 10:
objTax.value = calcTax10(income).toFixed(2) * 1;
break;

case 11:
document.form1.textfield4.value = spe(srSum);
break;

}

}

 
function new_taxCalc() {
var incomeType = parseFloat(document.getElementById("selIncomeType").value);
var objIncome = document.getElementById("txtIncome");
if (objIncome.value == "" | isNaN(objIncome.value)) {
objIncome.focus();
objIncome.select();
alert("请填正确写收入金额!");
return;
}

var income = parseFloat(objIncome.value);
var objTax = document.getElementById("txtTax");
switch (incomeType) {
case 1:

var obj = document.getElementById("txtEx1_a");
if (obj.value == "") { obj.value = "0" }
if (isNaN(obj.value)) {
obj.focus();
obj.select();
alert("请填正确写社保、公积金金额!");
return;
}
income = income – parseFloat(obj.value);
//objTax.value = calcTax1(income).toFixed(2) * 1; //原公式,基数2000
objTax.value = calcTaxnew(income).toFixed(2) * 1;
break;

case 2:
objTax.value = calcTax2(income).toFixed(2) * 1;
break;

case 3:
objTax.value = calcTax3(income).toFixed(2) * 1;
break;

case 4:
objTax.value = calcTax4(income).toFixed(2) * 1;
break;

case 5:
objTax.value = calcTax5(income).toFixed(2) * 1;
break;

case 6:
objTax.value = calcTax6(income).toFixed(2) * 1;
break;

case 7:
objTax.value = calcTax7(income).toFixed(2) * 1;
break;

case 8:
objTax.value = calcTax8(income).toFixed(2) * 1;
break;

case 9:
var obj = document.getElementById("txtEx9_a");
if (obj.value == "") { obj.value = "0" }
if (isNaN(obj.value)) {
obj.focus();
obj.select();
alert("请填正确写财产原值金额!");
return;
}
income = income – parseFloat(obj.value);

obj = document.getElementById("txtEx9_b");
if (obj.value == "") { obj.value = "0" }
if (isNaN(obj.value)) {
obj.focus();
obj.select();
alert("请填正确写合理手续费!");
return;
}

income = income – parseFloat(obj.value);

objTax.value = calcTax9(income).toFixed(2) * 1;
break;

case 10:
objTax.value = calcTax10(income).toFixed(2) * 1;
break;

case 11:
document.form1.textfield4.value = spe(srSum);
break;

}
if (objTax.value < 0) { objTax.value = 0 }
}
function changeIncomeType() {
document.getElementById("divEx1").style.display = "none";
document.getElementById("divEx8").style.display = "none";
document.getElementById("divEx9").style.display = "none";

var selIncomeType = document.getElementById("selIncomeType");

//var incomeType=selIncomeType.options[selIncomeType.selectedIndex].value;
var incomeType = parseFloat(selIncomeType.value);
switch (incomeType) {
case 1:
document.getElementById("divEx1").style.display = "";
break;

case 8:
document.getElementById("divEx8").style.display = "";
break;

case 9:
document.getElementById("divEx9").style.display = "";
break;
}

document.getElementById("divDesc1").className = "descBlock";
document.getElementById("divDesc2").className = "descBlock";
document.getElementById("divDesc3").className = "descBlock";
document.getElementById("divDesc4").className = "descBlock";
document.getElementById("divDesc5").className = "descBlock";
document.getElementById("divDesc6").className = "descBlock";
document.getElementById("divDesc7").className = "descBlock";
document.getElementById("divDesc8").className = "descBlock";
document.getElementById("divDesc9").className = "descBlock";
document.getElementById("divDesc10").className = "descBlock";
document.getElementById("divDesc" + incomeType).className = "descBlock_on";

 
}
</script>
<table width="600" border="0" cellpadding="3" cellspacing="1" bgcolor="#77ADFF" style="bforder: #5fa7f9 solid 5px;"
align="center">
<tr>
<td align="center" bgcolor="#F1F5FA">
个人所得税计算器
</td>
</tr>
<tr>
<td bgcolor="#f5fbff">
<table width="100%" border="0" cellspacing="0" cellpadding="3">
<tr>
<td width="179" align="right">
收入类型:
</td>
<td>
<select id="selIncomeType" name="selIncomeType" onchange="changeIncomeType()">
<option value="1" selected="selected">工资、薪金所得 </option>
<option value="4">劳务报酬所得 </option>
<option value="5">稿酬所得 </option>
<option value="6">特许权使用所得 </option>
<option value="7">利息、股息、红利所得 </option>
<option value="8">财产租赁所得 </option>
<option value="9">财产转让所得 </option>
<option value="10">偶然所得(如:中奖、中彩)</option>
</select>
</td>
</tr>
<tr>
<td width="179" align="right">
收入总额:
</td>
<td>
<input name="txtIncome" type="text" id="txtIncome" size="20" />
(元)
</td>
</tr>
</table>
<div id="divEx1">
<table width="100%" border="0" cellpadding="3" cellspacing="0">
<tr>
<td width="179" align="right">
允许扣除部分:
</td>
<td>
<input name="txtEx1_a" type="text" id="txtEx1_a" size="20" />
(元) [如:三费一金等]
</td>
</tr>
</table>
</div>
<div id="divEx8" style="display: none;">
<table width="100%" border="0" cellpadding="3" cellspacing="0">
<tr>
<td width="179" align="right">
&nbsp;
</td>
<td>
<input type="radio" value="1" name="radioEx8" id="radioEx8_a" checked="checked" />
个人房屋出租
<input type="radio" name="radioEx8" id="radioEx8_b" value="2" />
其他财产租赁
</td>
</tr>
</table>
</div>
<div id="divEx9" style="display: none;">
<table width="100%" border="0" cellpadding="3" cellspacing="0">
<tr>
<td width="179" align="right">
财产原值:
</td>
<td>
<input name="txtEx9a" type="text" id="txtEx9_a" size="20" />
(元)
</td>
</tr>
<tr>
<td width="179" align="right">
合理交易费用:
</td>
<td>
<input name="txtEx9b" type="text" id="txtEx9_b" size="20" />
(元)
</td>
</tr>
</table>
</div>
</td>
</tr>
<tr>
<td bgcolor="#f5fbff">
<table width="100%" border="0" cellpadding="3" cellspacing="0">
<tr>
<td width="179" align="right">
&nbsp;
</td>
<td>
<input type="submit" name="Submit" value=" 计 算 " onclick="new_taxCalc()" />
</td>
</tr>
<tr>
<td width="179" align="right">
应缴税额:
</td>
<td>
<input name="tax" type="text" id="txtTax" size="20" /><input name="tax" type="hidden"
id="txtTaxnew" size="20" />(元)
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>