由于项目需要计算个税,自己就根据最新税法以及税率表,写了计算个人所得税的C#版代码,贴出来,指高手指正不足之处。
代码如下:
1、TaxInfo.cs
using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
/// <summary>
///TaxInfo 个人所得税详细信息
///版本:1.0
///官网:http://www.9aicai.com
///名称:爱财个人所得税计算器(C#版) 2012-2013
/// </summary>
public class TaxInfo
{
public TaxInfo()
{
//
//TODO: 在此处添加构造函数逻辑
//
}
/// <summary>
/// 工资收入
/// </summary>
public decimal Income
{
set;
get;
}
/// <summary>
/// 纳税人员类型,是否外籍人士
/// </summary>
public bool IsForeign
{
set;
get;
}
/// <summary>
/// 五险一金
/// </summary>
public decimal Golds
{
set;
get;
}
/// <summary>
/// 个人所得税起征点
/// </summary>
public decimal StartPoint
{
set;
get;
}
/// <summary>
/// 应纳税所得额
/// </summary>
public decimal TaxableIncome
{
set;
get;
}
/// <summary>
/// 适用税率
/// </summary>
public decimal Rate
{
set;
get;
}
/// <summary>
/// 速算扣除数
/// </summary>
public decimal Deduct
{
set;
get;
}
/// <summary>
/// 应纳税额
/// </summary>
public decimal Tax
{
set;
get;
}
/// <summary>
/// 税后收入
/// </summary>
public decimal IncomeAfterTax
{
set;
get;
}
}
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
/// <summary>
///TaxInfo 个人所得税详细信息
///版本:1.0
///官网:http://www.9aicai.com
///名称:爱财个人所得税计算器(C#版) 2012-2013
/// </summary>
public class TaxInfo
{
public TaxInfo()
{
//
//TODO: 在此处添加构造函数逻辑
//
}
/// <summary>
/// 工资收入
/// </summary>
public decimal Income
{
set;
get;
}
/// <summary>
/// 纳税人员类型,是否外籍人士
/// </summary>
public bool IsForeign
{
set;
get;
}
/// <summary>
/// 五险一金
/// </summary>
public decimal Golds
{
set;
get;
}
/// <summary>
/// 个人所得税起征点
/// </summary>
public decimal StartPoint
{
set;
get;
}
/// <summary>
/// 应纳税所得额
/// </summary>
public decimal TaxableIncome
{
set;
get;
}
/// <summary>
/// 适用税率
/// </summary>
public decimal Rate
{
set;
get;
}
/// <summary>
/// 速算扣除数
/// </summary>
public decimal Deduct
{
set;
get;
}
/// <summary>
/// 应纳税额
/// </summary>
public decimal Tax
{
set;
get;
}
/// <summary>
/// 税后收入
/// </summary>
public decimal IncomeAfterTax
{
set;
get;
}
}
2、TaxManager.cs
using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
/// <summary>
///TaxManager 个人所得税的计算处理
///版本:1.0
///官网:http://www.9aicai.com
///名称:爱财个人所得税计算器(C#版) 2012-2013
/// </summary>
public class TaxManager
{
public TaxManager()
{
//
//TODO: 在此处添加构造函数逻辑
//
}
/// <summary>
/// 计算个人所得税
/// </summary>
/// <param name="income">工资收入</param>
/// <param name="golds">五险一金</param>
/// <param name="isForeign">是否是外籍人员</param>
/// <returns>个人所得税计算结果</returns>
public static TaxInfo Calc(decimal income, decimal golds, bool isForeign)
{
TaxInfo taxInfo = new TaxInfo();
taxInfo.Income = income;
taxInfo.Golds = golds;
taxInfo.IsForeign = isForeign;
//国内人员与外籍人员的起征点是不一样的,
taxInfo.StartPoint = taxInfo.IsForeign ? 4800 : 3500;
taxInfo.TaxableIncome = taxInfo.Income - taxInfo.Golds - taxInfo.StartPoint;
decimal rate, deduct;
//不需要纳税,应纳税额小于等于0
if (taxInfo.TaxableIncome <= 0)
{
taxInfo.Rate = 0;
taxInfo.Deduct = 0;
taxInfo.Tax = 0;
taxInfo.IncomeAfterTax = taxInfo.Income;
}//下面是需要纳税部分
else
{
//获取对应的税率与速算扣除数
getRateAndDeduct(taxInfo.TaxableIncome, out rate, out deduct);
taxInfo.Rate = rate;
taxInfo.Deduct = deduct;
taxInfo.Tax = taxInfo.TaxableIncome * taxInfo.Rate - taxInfo.Deduct;
taxInfo.IncomeAfterTax = taxInfo.Income - taxInfo.Golds - taxInfo.Tax;
}
return taxInfo;
}
/// <summary>
/// 获取对应的税率与速算扣除数,采用最新七级超额累进个人所得税税率表
/// </summary>
/// <param name="taxableIncome">应纳税所得额</param>
/// <param name="rate">适用税率</param>
/// <param name="deduct">速算扣除数</param>
private static void getRateAndDeduct(decimal taxableIncome, out decimal rate, out decimal deduct)
{
if (taxableIncome <= 1500)
{
rate = 3; deduct = 0;
}
else if (taxableIncome > 1500 && taxableIncome <= 4500)
{
rate = 10; deduct = 105;
}
else if (taxableIncome > 4500 && taxableIncome <= 9000)
{
rate = 20; deduct = 555;
}
else if (taxableIncome > 9000 && taxableIncome <= 35000)
{
rate = 25; deduct = 1005;
}
else if (taxableIncome > 35000 && taxableIncome <= 55000)
{
rate = 30; deduct = 2755;
}
else if (taxableIncome > 55000 && taxableIncome <= 80000)
{
rate = 35; deduct = 5505;
}
else
{
rate = 45; deduct = 13505;
}
}
}
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
/// <summary>
///TaxManager 个人所得税的计算处理
///版本:1.0
///官网:http://www.9aicai.com
///名称:爱财个人所得税计算器(C#版) 2012-2013
/// </summary>
public class TaxManager
{
public TaxManager()
{
//
//TODO: 在此处添加构造函数逻辑
//
}
/// <summary>
/// 计算个人所得税
/// </summary>
/// <param name="income">工资收入</param>
/// <param name="golds">五险一金</param>
/// <param name="isForeign">是否是外籍人员</param>
/// <returns>个人所得税计算结果</returns>
public static TaxInfo Calc(decimal income, decimal golds, bool isForeign)
{
TaxInfo taxInfo = new TaxInfo();
taxInfo.Income = income;
taxInfo.Golds = golds;
taxInfo.IsForeign = isForeign;
//国内人员与外籍人员的起征点是不一样的,
taxInfo.StartPoint = taxInfo.IsForeign ? 4800 : 3500;
taxInfo.TaxableIncome = taxInfo.Income - taxInfo.Golds - taxInfo.StartPoint;
decimal rate, deduct;
//不需要纳税,应纳税额小于等于0
if (taxInfo.TaxableIncome <= 0)
{
taxInfo.Rate = 0;
taxInfo.Deduct = 0;
taxInfo.Tax = 0;
taxInfo.IncomeAfterTax = taxInfo.Income;
}//下面是需要纳税部分
else
{
//获取对应的税率与速算扣除数
getRateAndDeduct(taxInfo.TaxableIncome, out rate, out deduct);
taxInfo.Rate = rate;
taxInfo.Deduct = deduct;
taxInfo.Tax = taxInfo.TaxableIncome * taxInfo.Rate - taxInfo.Deduct;
taxInfo.IncomeAfterTax = taxInfo.Income - taxInfo.Golds - taxInfo.Tax;
}
return taxInfo;
}
/// <summary>
/// 获取对应的税率与速算扣除数,采用最新七级超额累进个人所得税税率表
/// </summary>
/// <param name="taxableIncome">应纳税所得额</param>
/// <param name="rate">适用税率</param>
/// <param name="deduct">速算扣除数</param>
private static void getRateAndDeduct(decimal taxableIncome, out decimal rate, out decimal deduct)
{
if (taxableIncome <= 1500)
{
rate = 3; deduct = 0;
}
else if (taxableIncome > 1500 && taxableIncome <= 4500)
{
rate = 10; deduct = 105;
}
else if (taxableIncome > 4500 && taxableIncome <= 9000)
{
rate = 20; deduct = 555;
}
else if (taxableIncome > 9000 && taxableIncome <= 35000)
{
rate = 25; deduct = 1005;
}
else if (taxableIncome > 35000 && taxableIncome <= 55000)
{
rate = 30; deduct = 2755;
}
else if (taxableIncome > 55000 && taxableIncome <= 80000)
{
rate = 35; deduct = 5505;
}
else
{
rate = 45; deduct = 13505;
}
}
}